1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Implementation of DeleteChromeHistory
6 #include "chrome_frame/delete_chrome_history.h"
8 #include "chrome/browser/browsing_data/browsing_data_remover.h"
10 #include "base/win/windows_version.h"
11 #include "chrome_frame/chrome_frame_activex.h"
12 #include "chrome_frame/utils.h"
14 // Below other header to avoid symbol pollution.
16 #include <deletebrowsinghistory.h>
18 DeleteChromeHistory::DeleteChromeHistory()
20 DVLOG(1) << __FUNCTION__
;
23 DeleteChromeHistory::~DeleteChromeHistory() {
27 HRESULT
DeleteChromeHistory::FinalConstruct() {
28 DVLOG(1) << __FUNCTION__
;
33 void DeleteChromeHistory::OnAutomationServerReady() {
34 DVLOG(1) << __FUNCTION__
;
35 automation_client_
->RemoveBrowsingData(remove_mask_
);
39 void DeleteChromeHistory::OnAutomationServerLaunchFailed(
40 AutomationLaunchResult reason
, const std::string
& server_version
) {
41 DLOG(WARNING
) << __FUNCTION__
;
45 void DeleteChromeHistory::GetProfilePath(const std::wstring
& profile_name
,
46 FilePath
* profile_path
) {
47 ChromeFramePlugin::GetProfilePath(kIexploreProfileName
, profile_path
);
50 STDMETHODIMP
DeleteChromeHistory::DeleteBrowsingHistory(DWORD flags
) {
51 DVLOG(1) << __FUNCTION__
;
52 // Usually called inside a quick startup/tear-down routine by RunDLL32. You
53 // can simulate the process by calling:
54 // RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
55 // Since automation setup isn't synchronous, we can be tearing down while
56 // being only partially set-up, causing even synchronous IPCs to be dropped.
57 // Since the *Chrome* startup/tear-down occurs synchronously from the
58 // perspective of automation, we can add a flag to the chrome.exe invocation
59 // in lieu of sending an IPC when it seems appropriate. Since we assume this
60 // happens in one-off fashion, don't attempt to pack REMOVE_* arguments.
61 // Instead, have the browser process clobber all history.
63 // IE8 on Vista launches us twice when the user asks to delete browsing data -
64 // once in low integrity and once in medium integrity. The low integrity
65 // instance will fail to connect to the automation server and restart it in an
66 // effort to connect. Thus, we detect if we are in that circumstance and exit
68 base::IntegrityLevel integrity_level
;
69 if (base::win::GetVersion() >= base::win::VERSION_VISTA
&&
70 !base::GetProcessIntegrityLevel(base::GetCurrentProcessHandle(),
74 if (integrity_level
== base::LOW_INTEGRITY
) {
77 if (!InitializeAutomation(GetHostProcessName(false), false, false,
78 GURL(), GURL(), true)) {
82 if (flags
& DELETE_BROWSING_HISTORY_COOKIES
)
83 remove_mask_
|= BrowsingDataRemover::REMOVE_SITE_DATA
;
84 if (flags
& DELETE_BROWSING_HISTORY_TIF
)
85 remove_mask_
|= BrowsingDataRemover::REMOVE_CACHE
;
86 if (flags
& DELETE_BROWSING_HISTORY_FORMDATA
)
87 remove_mask_
|= BrowsingDataRemover::REMOVE_FORM_DATA
;
88 if (flags
& DELETE_BROWSING_HISTORY_PASSWORDS
)
89 remove_mask_
|= BrowsingDataRemover::REMOVE_PASSWORDS
;
90 if (flags
& DELETE_BROWSING_HISTORY_HISTORY
)
91 remove_mask_
|= BrowsingDataRemover::REMOVE_HISTORY
;
93 loop_
.PostDelayedTask(FROM_HERE
,
94 MessageLoop::QuitClosure(), base::TimeDelta::FromMinutes(10));
95 loop_
.MessageLoop::Run();