OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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. |
| 4 |
| 5 // Implementation of DeleteChromeHistory |
| 6 #include "chrome_frame/delete_chrome_history.h" |
| 7 |
| 8 #include "chrome_frame/chrome_frame_activex.h" |
| 9 #include "chrome/browser/browsing_data_remover.h" |
| 10 #include "utils.h" |
| 11 |
| 12 // Below other header to avoid symbol pollution. |
| 13 #define INITGUID |
| 14 #include <deletebrowsinghistory.h> |
| 15 |
| 16 DeleteChromeHistory::DeleteChromeHistory() |
| 17 : remove_mask_(0) { |
| 18 DLOG(INFO) << __FUNCTION__; |
| 19 } |
| 20 |
| 21 DeleteChromeHistory::~DeleteChromeHistory() { |
| 22 } |
| 23 |
| 24 |
| 25 HRESULT DeleteChromeHistory::FinalConstruct() { |
| 26 DLOG(INFO) << __FUNCTION__; |
| 27 Initialize(); |
| 28 return S_OK; |
| 29 } |
| 30 |
| 31 void DeleteChromeHistory::OnAutomationServerReady() { |
| 32 DLOG(INFO) << __FUNCTION__; |
| 33 automation_client_->RemoveBrowsingData(remove_mask_); |
| 34 loop_.Quit(); |
| 35 } |
| 36 |
| 37 void DeleteChromeHistory::OnAutomationServerLaunchFailed( |
| 38 AutomationLaunchResult reason, const std::string& server_version) { |
| 39 DLOG(WARNING) << __FUNCTION__; |
| 40 loop_.Quit(); |
| 41 } |
| 42 |
| 43 void DeleteChromeHistory::GetProfilePath(const std::wstring& profile_name, |
| 44 FilePath* profile_path) { |
| 45 ChromeFramePlugin::GetProfilePath(kIexploreProfileName, profile_path); |
| 46 } |
| 47 |
| 48 STDMETHODIMP DeleteChromeHistory::DeleteBrowsingHistory(DWORD flags) { |
| 49 DLOG(INFO) << __FUNCTION__; |
| 50 // Usually called inside a quick startup/tear-down routine by RunDLL32. You |
| 51 // can simulate the process by calling: |
| 52 // RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255 |
| 53 // Since automation setup isn't synchronous, we can be tearing down while |
| 54 // being only partially set-up, causing even synchronous IPCs to be dropped. |
| 55 // Since the *Chrome* startup/tear-down occurs synchronously from the |
| 56 // perspective of automation, we can add a flag to the chrome.exe invocation |
| 57 // in lieu of sending an IPC when it seems appropriate. Since we assume this |
| 58 // happens in one-off fashion, don't attempt to pack REMOVE_* arguments. |
| 59 // Instead, have the browser process clobber all history. |
| 60 if (!InitializeAutomation(GetHostProcessName(false), L"", false)) { |
| 61 return E_UNEXPECTED; |
| 62 } |
| 63 |
| 64 if (flags & DELETE_BROWSING_HISTORY_COOKIES) |
| 65 remove_mask_ |= BrowsingDataRemover::REMOVE_COOKIES; |
| 66 if (flags & DELETE_BROWSING_HISTORY_TIF) |
| 67 remove_mask_ |= BrowsingDataRemover::REMOVE_CACHE; |
| 68 if (flags & DELETE_BROWSING_HISTORY_FORMDATA) |
| 69 remove_mask_ |= BrowsingDataRemover::REMOVE_FORM_DATA; |
| 70 if (flags & DELETE_BROWSING_HISTORY_PASSWORDS) |
| 71 remove_mask_ |= BrowsingDataRemover::REMOVE_PASSWORDS; |
| 72 if (flags & DELETE_BROWSING_HISTORY_HISTORY) |
| 73 remove_mask_ |= BrowsingDataRemover::REMOVE_HISTORY; |
| 74 |
| 75 loop_.PostDelayedTask(FROM_HERE, |
| 76 new MessageLoop::QuitTask, 1000 * 600); |
| 77 loop_.MessageLoop::Run(); |
| 78 |
| 79 return S_OK; |
| 80 } |
| 81 |
| 82 |
OLD | NEW |