summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslightlyoff@chromium.org <slightlyoff@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-26 04:16:20 +0000
committerslightlyoff@chromium.org <slightlyoff@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-26 04:16:20 +0000
commitbc73b4e541f57b44ac4c53df2589d91549f27eaf (patch)
tree47cf0721b0f9d9cd0a9c83196d4091120300f3a4
parent46215d5ef32784db5544fc5f7ba06b6617935fec (diff)
downloadchromium_src-bc73b4e541f57b44ac4c53df2589d91549f27eaf.zip
chromium_src-bc73b4e541f57b44ac4c53df2589d91549f27eaf.tar.gz
chromium_src-bc73b4e541f57b44ac4c53df2589d91549f27eaf.tar.bz2
3rd try. *sigh*
See: http://codereview.chromium.org/858003 TBR=tommi BUG=22846 TEST=On IE 8, clear the cache entirely, watch GCF launch (via task manager) Review URL: http://codereview.chromium.org/1343004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42732 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/automation/automation_provider.cc10
-rw-r--r--chrome/browser/automation/automation_provider.h3
-rw-r--r--chrome/browser/automation/chrome_frame_automation_provider.cc5
-rw-r--r--chrome/test/automation/automation_messages_internal.h8
-rw-r--r--chrome_frame/bho.h14
-rw-r--r--chrome_frame/bho.rgs49
-rw-r--r--chrome_frame/chrome_frame.gyp10
-rw-r--r--chrome_frame/chrome_frame_activex_base.h39
-rw-r--r--chrome_frame/chrome_frame_automation.cc36
-rw-r--r--chrome_frame/chrome_frame_automation.h8
-rw-r--r--chrome_frame/chrome_frame_plugin.h15
-rw-r--r--chrome_frame/chrome_launcher.cc3
-rw-r--r--chrome_frame/delete_chrome_history.cc82
-rw-r--r--chrome_frame/delete_chrome_history.h65
-rw-r--r--chrome_frame/test/automation_client_mock.cc33
-rw-r--r--chrome_frame/test/automation_client_mock.h16
-rw-r--r--chrome_frame/test/chrome_frame_automation_mock.h8
-rw-r--r--chrome_frame/test/chrome_frame_test_utils.cc11
-rw-r--r--chrome_frame/test/chrome_frame_test_utils.h6
-rw-r--r--chrome_frame/utils.cc29
-rw-r--r--chrome_frame/utils.h3
21 files changed, 356 insertions, 97 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 5dd3743..226f89c 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -33,6 +33,7 @@
#include "chrome/browser/bookmarks/bookmark_storage.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_window.h"
+#include "chrome/browser/browsing_data_remover.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/dom_operation_notification_details.h"
#include "chrome/browser/debugger/devtools_manager.h"
@@ -506,6 +507,7 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForPopupMenuToOpen,
WaitForPopupMenuToOpen)
#endif
+ IPC_MESSAGE_HANDLER(AutomationMsg_RemoveBrowsingData, RemoveBrowsingData)
IPC_END_MESSAGE_MAP()
}
@@ -2349,6 +2351,14 @@ void AutomationProvider::OnSetPageFontSize(int tab_handle,
}
}
+void AutomationProvider::RemoveBrowsingData(int remove_mask) {
+ BrowsingDataRemover* remover;
+ remover = new BrowsingDataRemover(profile(),
+ BrowsingDataRemover::EVERYTHING, // All time periods.
+ base::Time());
+ remover->Remove(remove_mask);
+ // BrowsingDataRemover deletes itself.
+}
void AutomationProvider::WaitForBrowserWindowCountToBecome(
int target_count, IPC::Message* reply_message) {
diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h
index 2328606..2d680b1 100644
--- a/chrome/browser/automation/automation_provider.h
+++ b/chrome/browser/automation/automation_provider.h
@@ -359,6 +359,9 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>,
void OnSetPageFontSize(int tab_handle, int font_size);
+ // See browsing_data_remover.h for explanation of bitmap fields.
+ void RemoveBrowsingData(int remove_mask);
+
void InstallExtension(const FilePath& crx_path,
IPC::Message* reply_message);
diff --git a/chrome/browser/automation/chrome_frame_automation_provider.cc b/chrome/browser/automation/chrome_frame_automation_provider.cc
index c8bada3..9aa403d 100644
--- a/chrome/browser/automation/chrome_frame_automation_provider.cc
+++ b/chrome/browser/automation/chrome_frame_automation_provider.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -62,7 +62,8 @@ bool ChromeFrameAutomationProvider::IsValidMessage(uint32 type) {
case AutomationMsg_RequestStarted::ID:
case AutomationMsg_RequestData::ID:
case AutomationMsg_RequestEnd::ID:
- case AutomationMsg_SaveAsAsync::ID: {
+ case AutomationMsg_SaveAsAsync::ID:
+ case AutomationMsg_RemoveBrowsingData::ID: {
is_valid_message = true;
break;
}
diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h
index 0e82155..bf3eb9b 100644
--- a/chrome/test/automation/automation_messages_internal.h
+++ b/chrome/test/automation/automation_messages_internal.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -1307,4 +1307,10 @@ IPC_BEGIN_MESSAGES(Automation)
IPC_SYNC_MESSAGE_ROUTED0_1(AutomationMsg_WaitForPopupMenuToOpen,
bool /* success */)
+ // This message informs the browser process to remove the history entries
+ // for the specified types across all time ranges. See
+ // browsing_data_remover.h for a list of REMOVE_* types supported in the
+ // remove_mask parameter.
+ IPC_MESSAGE_ROUTED1(AutomationMsg_RemoveBrowsingData, int)
+
IPC_END_MESSAGES(Automation)
diff --git a/chrome_frame/bho.h b/chrome_frame/bho.h
index 9a36795..430436b 100644
--- a/chrome_frame/bho.h
+++ b/chrome_frame/bho.h
@@ -7,6 +7,7 @@
#include <atlbase.h>
#include <atlcom.h>
+#include <deletebrowsinghistory.h>
#include <exdisp.h>
#include <exdispid.h>
#include <mshtml.h>
@@ -16,11 +17,14 @@
#include "base/scoped_comptr_win.h"
#include "chrome_tab.h" // NOLINT
+#include "chrome_frame/delete_chrome_history.h"
#include "chrome_frame/resource.h"
#include "chrome_frame/urlmon_moniker.h"
#include "chrome_frame/urlmon_url_request.h"
#include "grit/chrome_frame_resources.h"
+class DeleteChromeHistory;
+
class PatchHelper {
public:
enum State { UNKNOWN, PATCH_IBROWSER, PATCH_PROTOCOL };
@@ -55,12 +59,18 @@ class ATL_NO_VTABLE Bho
IBrowserService* browser, IShellView* shell_view, BOOL done,
VARIANT* in_arg, VARIANT* out_arg);
+DECLARE_GET_CONTROLLING_UNKNOWN()
DECLARE_REGISTRY_RESOURCEID(IDR_BHO)
DECLARE_NOT_AGGREGATABLE(Bho)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(Bho)
COM_INTERFACE_ENTRY(IObjectWithSite)
+ // When calling DeleteChromeHistory, ensure that only one instance
+ // is created to avoid mulitple message loops.
+ COM_INTERFACE_ENTRY_CACHED_TEAR_OFF(IID_IDeleteBrowsingHistory,
+ DeleteChromeHistory,
+ delete_chrome_history_.p)
END_COM_MAP()
BEGIN_SINK_MAP(Bho)
@@ -96,6 +106,10 @@ END_SINK_MAP()
static void ProcessOptInUrls(IWebBrowser2* browser, BSTR url);
+ // COM_INTERFACE_ENTRY_CACHED_TEAR_OFF manages the raw pointer from CComPtr
+ // which ScopedComPtr doesn't expose.
+ CComPtr<IUnknown> delete_chrome_history_;
+
protected:
bool PatchProtocolHandler(const CLSID& handler_clsid);
diff --git a/chrome_frame/bho.rgs b/chrome_frame/bho.rgs
index 824fd7d..ba057a6 100644
--- a/chrome_frame/bho.rgs
+++ b/chrome_frame/bho.rgs
@@ -1,23 +1,26 @@
-HKLM {
- NoRemove SOFTWARE {
- NoRemove Classes {
- ChromeFrame.Bho.1 = s 'Bho Class' {
- CLSID = s '{ECB3C477-1A0A-44bd-BB57-78F9EFE34FA7}'
- }
- ChromeFrame.Bho = s 'ChromeFrame BHO' {
- CLSID = s '{ECB3C477-1A0A-44bd-BB57-78F9EFE34FA7}'
- CurVer = s 'ChromeFrame.Bho.1'
- }
- NoRemove CLSID {
- ForceRemove {ECB3C477-1A0A-44bd-BB57-78F9EFE34FA7} = s 'ChromeFrame BHO' {
- ProgID = s 'ChromeFrame.Bho.1'
- VersionIndependentProgID = s 'ChromeFrame.Bho'
- InprocServer32 = s '%MODULE%' {
- val ThreadingModel = s 'Apartment'
- }
- 'TypeLib' = s '{6F2664E1-FF6E-488A-BCD1-F4CA6001DFCC}'
- }
- }
- }
- }
-}
+HKLM {
+ NoRemove SOFTWARE {
+ NoRemove Classes {
+ ChromeFrame.Bho.1 = s 'Bho Class' {
+ CLSID = s '{ECB3C477-1A0A-44bd-BB57-78F9EFE34FA7}'
+ }
+ ChromeFrame.Bho = s 'ChromeFrame BHO' {
+ CLSID = s '{ECB3C477-1A0A-44bd-BB57-78F9EFE34FA7}'
+ CurVer = s 'ChromeFrame.Bho.1'
+ }
+ NoRemove CLSID {
+ ForceRemove {ECB3C477-1A0A-44bd-BB57-78F9EFE34FA7} = s 'ChromeFrame BHO' {
+ ProgID = s 'ChromeFrame.Bho.1'
+ VersionIndependentProgID = s 'ChromeFrame.Bho'
+ InprocServer32 = s '%MODULE%' {
+ val ThreadingModel = s 'Apartment'
+ }
+ 'TypeLib' = s '{6F2664E1-FF6E-488A-BCD1-F4CA6001DFCC}'
+ 'Implemented Categories' {
+ {31CAF6E4-D6AA-4090-A050-A5AC8972E9EF}
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/chrome_frame/chrome_frame.gyp b/chrome_frame/chrome_frame.gyp
index 66514ef..d0fc620 100644
--- a/chrome_frame/chrome_frame.gyp
+++ b/chrome_frame/chrome_frame.gyp
@@ -1,4 +1,4 @@
-# Copyright (c) 2009 The Chromium Authors. All rights reserved.
+# Copyright (c) 2010 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -604,10 +604,10 @@
'chrome_active_document.rgs',
'chrome_frame_activex.cc',
'chrome_frame_activex.h',
- 'chrome_frame_activex_base.h',
'chrome_frame_activex.rgs',
- 'chrome_frame_histograms.h',
+ 'chrome_frame_activex_base.h',
'chrome_frame_histograms.cc',
+ 'chrome_frame_histograms.h',
'chrome_frame_reporting.cc',
'chrome_frame_reporting.h',
'chrome_protocol.cc',
@@ -619,12 +619,14 @@
'com_message_event.h',
'com_type_info_holder.cc',
'com_type_info_holder.h',
+ 'delete_chrome_history.cc',
+ 'delete_chrome_history.h',
'find_dialog.cc',
'find_dialog.h',
'function_stub.h',
+ 'http_negotiate.cc',
'function_stub.cc',
'http_negotiate.h',
- 'http_negotiate.cc',
'iids.cc',
'in_place_menu.h',
'ole_document_impl.h',
diff --git a/chrome_frame/chrome_frame_activex_base.h b/chrome_frame/chrome_frame_activex_base.h
index d29eb65..2b9d60d 100644
--- a/chrome_frame/chrome_frame_activex_base.h
+++ b/chrome_frame/chrome_frame_activex_base.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,21 +9,6 @@
#include <atlcom.h>
#include <atlctl.h>
#include <wininet.h>
-
-// Copied min/max defs from windows headers to appease atlimage.h.
-// TODO(slightlyoff): Figure out of more recent platform SDK's (> 6.1)
-// undo the janky "#define NOMINMAX" train wreck. See:
-// http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100703
-#ifndef max
-#define max(a,b) (((a) > (b)) ? (a) : (b)) // NOLINT
-#endif
-#ifndef min
-#define min(a,b) (((a) < (b)) ? (a) : (b)) // NOLINT
-#endif
-#include <atlimage.h>
-#undef max
-#undef min
-
#include <shdeprecated.h> // for IBrowserService2
#include <shlguid.h>
@@ -36,19 +21,23 @@
#include "base/scoped_variant_win.h"
#include "base/string_util.h"
#include "grit/chrome_frame_resources.h"
+#include "chrome/common/url_constants.h"
#include "chrome_frame/chrome_frame_plugin.h"
#include "chrome_frame/com_message_event.h"
#include "chrome_frame/com_type_info_holder.h"
#include "chrome_frame/simple_resource_loader.h"
#include "chrome_frame/urlmon_url_request.h"
#include "chrome_frame/urlmon_url_request_private.h"
-#include "chrome/common/url_constants.h"
+#include "chrome_frame/utils.h"
#include "grit/generated_resources.h"
#include "net/base/cookie_monster.h"
// Include without path to make GYP build see it.
#include "chrome_tab.h" // NOLINT
+static const wchar_t kIexploreProfileName[] = L"iexplore";
+static const wchar_t kRundllProfileName[] = L"rundll32";
+
// Connection point class to support firing IChromeFrameEvents (dispinterface).
template<class T>
class ATL_NO_VTABLE ProxyDIChromeFrameEvents
@@ -361,6 +350,22 @@ END_MSG_MAP()
}
protected:
+ virtual void GetProfilePath(const std::wstring& profile_name,
+ FilePath* profile_path) {
+ bool is_IE = (lstrcmpi(profile_name.c_str(), kIexploreProfileName) == 0) ||
+ (lstrcmpi(profile_name.c_str(), kRundllProfileName) == 0);
+ // Browsers without IDeleteBrowsingHistory in non-priv mode
+ // have their profiles moved into "Temporary Internet Files".
+ if (is_IE && GetIEVersion() < IE_8 && !is_privileged_) {
+ *profile_path = GetIETemporaryFilesFolder();
+ *profile_path = profile_path->Append(L"Google Chrome Frame");
+ } else {
+ ChromeFramePlugin::GetProfilePath(profile_name, profile_path);
+ }
+ DLOG(INFO) << __FUNCTION__ << ": " << profile_path->value();
+ }
+
+
void OnLoad(int tab_handle, const GURL& url) {
if (ready_state_ < READYSTATE_COMPLETE) {
ready_state_ = READYSTATE_COMPLETE;
diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc
index 2c5d238..8c1fb45 100644
--- a/chrome_frame/chrome_frame_automation.cc
+++ b/chrome_frame/chrome_frame_automation.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -19,8 +19,6 @@
#include "base/waitable_event.h"
#include "chrome/app/client_util.h"
#include "chrome/common/chrome_constants.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/common/chrome_paths_internal.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/automation/tab_proxy.h"
#include "chrome_frame/chrome_launcher.h"
@@ -271,20 +269,9 @@ void ProxyFactory::CreateProxy(ProxyFactory::ProxyCacheEntry* entry,
if (IsHeadlessMode())
command_line->AppendSwitch(switches::kFullMemoryCrashReport);
- // Place the profile directory in
- // "<chrome_exe_path>\..\User Data\<profile-name>"
- if (!entry->profile_name.empty()) {
- FilePath profile_path;
- if (chrome::GetChromeFrameUserDataDirectory(&profile_path)) {
- profile_path = profile_path.Append(entry->profile_name);
- command_line->AppendSwitchWithValue(switches::kUserDataDir,
- profile_path.value());
- } else {
- // Can't get the profile dir :-( We need one to work, so fail.
- // We have no code for launch failure.
- entry->launch_result = AutomationLaunchResult(-1);
- }
- }
+ DLOG(INFO) << "Profile path: " << params.profile_path.value();
+ command_line->AppendSwitchWithValue(switches::kUserDataDir,
+ params.profile_path.value());
std::wstring command_line_string(command_line->command_line_string());
// If there are any extra arguments, append them to the command line.
@@ -339,8 +326,6 @@ void ProxyFactory::CreateProxy(ProxyFactory::ProxyCacheEntry* entry,
}
bool ProxyFactory::ReleaseAutomationServer(void* server_id) {
- DLOG(INFO) << __FUNCTION__;
-
if (!server_id) {
NOTREACHED();
return false;
@@ -457,7 +442,7 @@ bool ChromeFrameAutomationClient::Initialize(
ChromeFrameDelegate* chrome_frame_delegate,
int automation_server_launch_timeout,
bool perform_version_check,
- const std::wstring& profile_name,
+ const FilePath& profile_path,
const std::wstring& extra_chrome_arguments,
bool incognito) {
DCHECK(!IsWindow());
@@ -497,7 +482,8 @@ bool ChromeFrameAutomationClient::Initialize(
chrome_launch_params_.automation_server_launch_timeout =
automation_server_launch_timeout;
- chrome_launch_params_.profile_name = profile_name;
+ chrome_launch_params_.profile_path = profile_path;
+ chrome_launch_params_.profile_name = profile_path.BaseName().value();
chrome_launch_params_.extra_chrome_arguments = extra_chrome_arguments;
chrome_launch_params_.perform_version_check = perform_version_check;
chrome_launch_params_.url = navigate_after_initialization_ ? GURL() : url_;
@@ -511,8 +497,6 @@ bool ChromeFrameAutomationClient::Initialize(
}
void ChromeFrameAutomationClient::Uninitialize() {
- DLOG(INFO) << __FUNCTION__;
-
if (init_state_ == UNINITIALIZED) {
DLOG(WARNING) << __FUNCTION__ << ": Automation client not initialized";
return;
@@ -930,6 +914,7 @@ void ChromeFrameAutomationClient::LaunchComplete(
NULL, NULL, NULL);
automation_server_->SendAsAsync(message, NewCallback(this,
&ChromeFrameAutomationClient::CreateExternalTabComplete), this);
+ DLOG(INFO) << __FUNCTION__ << ": sending CreateExternalTabComplete";
}
}
} else {
@@ -1099,7 +1084,6 @@ void ChromeFrameAutomationClient::SetParentWindow(HWND parent_window) {
}
void ChromeFrameAutomationClient::ReleaseAutomationServer() {
- DLOG(INFO) << __FUNCTION__;
if (automation_server_id_) {
// Cache the server id and clear the automation_server_id_ before
// calling ReleaseAutomationServer. The reason we do this is that
@@ -1217,6 +1201,10 @@ void ChromeFrameAutomationClient::SetPageFontSize(
new AutomationMsg_SetPageFontSize(0, tab_handle_, font_size));
}
+void ChromeFrameAutomationClient::RemoveBrowsingData(int remove_mask) {
+ automation_server_->Send(
+ new AutomationMsg_RemoveBrowsingData(0, remove_mask));
+}
//////////////////////////////////////////////////////////////////////////
// PluginUrlRequestDelegate implementation.
diff --git a/chrome_frame/chrome_frame_automation.h b/chrome_frame/chrome_frame_automation.h
index f01d1b4..8a7c54a 100644
--- a/chrome_frame/chrome_frame_automation.h
+++ b/chrome_frame/chrome_frame_automation.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -88,6 +88,7 @@ struct ChromeFrameLaunchParams {
std::wstring extra_chrome_arguments;
bool perform_version_check;
bool incognito_mode;
+ FilePath profile_path;
};
// We must create and destroy automation proxy in a thread with a message loop.
@@ -160,7 +161,7 @@ class ChromeFrameAutomationClient
virtual bool Initialize(ChromeFrameDelegate* chrome_frame_delegate,
int automation_server_launch_timeout,
bool perform_version_check,
- const std::wstring& profile_name,
+ const FilePath& profile_path,
const std::wstring& extra_chrome_arguments,
bool incognito);
void Uninitialize();
@@ -262,6 +263,9 @@ class ChromeFrameAutomationClient
void SetPageFontSize(enum AutomationPageFontSize);
+ // For IDeleteBrowsingHistorySupport
+ void RemoveBrowsingData(int remove_mask);
+
ChromeFrameAutomationProxy* automation_server() {
return automation_server_;
}
diff --git a/chrome_frame/chrome_frame_plugin.h b/chrome_frame/chrome_frame_plugin.h
index 17fb6572..7f397e6 100644
--- a/chrome_frame/chrome_frame_plugin.h
+++ b/chrome_frame/chrome_frame_plugin.h
@@ -8,6 +8,8 @@
#include "base/ref_counted.h"
#include "base/win_util.h"
#include "chrome_frame/chrome_frame_automation.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/common/chrome_paths_internal.h"
#include "chrome_frame/simple_resource_loader.h"
#include "chrome_frame/utils.h"
@@ -35,6 +37,7 @@ BEGIN_MSG_MAP(T)
END_MSG_MAP()
bool Initialize() {
+ DLOG(INFO) << __FUNCTION__;
DCHECK(!automation_client_.get());
automation_client_ = CreateAutomationClient();
if (!automation_client_.get()) {
@@ -46,6 +49,7 @@ END_MSG_MAP()
}
void Uninitialize() {
+ DLOG(INFO) << __FUNCTION__;
if (IsValid()) {
automation_client_->Uninitialize();
automation_client_ = NULL;
@@ -59,8 +63,10 @@ END_MSG_MAP()
// We don't want to do incognito when privileged, since we're
// running in browser chrome or some other privileged context.
bool incognito_mode = !is_privileged_ && incognito;
+ FilePath profile_path;
+ GetProfilePath(profile_name, &profile_path);
return automation_client_->Initialize(this, kCommandExecutionTimeout, true,
- profile_name, extra_chrome_arguments,
+ profile_path, extra_chrome_arguments,
incognito_mode);
}
@@ -211,6 +217,13 @@ END_MSG_MAP()
}
}
+ virtual void GetProfilePath(const std::wstring& profile_name,
+ FilePath* profile_path) {
+ chrome::GetChromeFrameUserDataDirectory(profile_path);
+ *profile_path = profile_path->Append(profile_name);
+ DLOG(INFO) << __FUNCTION__ << ": " << profile_path->value();
+ }
+
protected:
// Our gateway to chrome land
scoped_refptr<ChromeFrameAutomationClient> automation_client_;
diff --git a/chrome_frame/chrome_launcher.cc b/chrome_frame/chrome_launcher.cc
index 31d404e..7646a66 100644
--- a/chrome_frame/chrome_launcher.cc
+++ b/chrome_frame/chrome_launcher.cc
@@ -87,6 +87,9 @@ bool SanitizeAndLaunchChrome(const wchar_t* command_line) {
CommandLine sanitized(GetChromeExecutablePath());
SanitizeCommandLine(original, &sanitized);
+ DLOG(INFO) << sanitized.command_line_string();
+ sanitized.AppendSwitchWithValue("log-level", "0");
+
return base::LaunchApp(sanitized.command_line_string(), false, false, NULL);
}
diff --git a/chrome_frame/delete_chrome_history.cc b/chrome_frame/delete_chrome_history.cc
new file mode 100644
index 0000000..994d609
--- /dev/null
+++ b/chrome_frame/delete_chrome_history.cc
@@ -0,0 +1,82 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Implementation of DeleteChromeHistory
+#include "chrome_frame/delete_chrome_history.h"
+
+#include "chrome_frame/chrome_frame_activex.h"
+#include "chrome/browser/browsing_data_remover.h"
+#include "utils.h"
+
+// Below other header to avoid symbol pollution.
+#define INITGUID
+#include <deletebrowsinghistory.h>
+
+DeleteChromeHistory::DeleteChromeHistory()
+ : remove_mask_(0) {
+ DLOG(INFO) << __FUNCTION__;
+}
+
+DeleteChromeHistory::~DeleteChromeHistory() {
+}
+
+
+HRESULT DeleteChromeHistory::FinalConstruct() {
+ DLOG(INFO) << __FUNCTION__;
+ Initialize();
+ return S_OK;
+}
+
+void DeleteChromeHistory::OnAutomationServerReady() {
+ DLOG(INFO) << __FUNCTION__;
+ automation_client_->RemoveBrowsingData(remove_mask_);
+ loop_.Quit();
+}
+
+void DeleteChromeHistory::OnAutomationServerLaunchFailed(
+ AutomationLaunchResult reason, const std::string& server_version) {
+ DLOG(WARNING) << __FUNCTION__;
+ loop_.Quit();
+}
+
+void DeleteChromeHistory::GetProfilePath(const std::wstring& profile_name,
+ FilePath* profile_path) {
+ ChromeFramePlugin::GetProfilePath(kIexploreProfileName, profile_path);
+}
+
+STDMETHODIMP DeleteChromeHistory::DeleteBrowsingHistory(DWORD flags) {
+ DLOG(INFO) << __FUNCTION__;
+ // Usually called inside a quick startup/tear-down routine by RunDLL32. You
+ // can simulate the process by calling:
+ // RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
+ // Since automation setup isn't synchronous, we can be tearing down while
+ // being only partially set-up, causing even synchronous IPCs to be dropped.
+ // Since the *Chrome* startup/tear-down occurs synchronously from the
+ // perspective of automation, we can add a flag to the chrome.exe invocation
+ // in lieu of sending an IPC when it seems appropriate. Since we assume this
+ // happens in one-off fashion, don't attempt to pack REMOVE_* arguments.
+ // Instead, have the browser process clobber all history.
+ if (!InitializeAutomation(GetHostProcessName(false), L"", false)) {
+ return E_UNEXPECTED;
+ }
+
+ if (flags & DELETE_BROWSING_HISTORY_COOKIES)
+ remove_mask_ |= BrowsingDataRemover::REMOVE_COOKIES;
+ if (flags & DELETE_BROWSING_HISTORY_TIF)
+ remove_mask_ |= BrowsingDataRemover::REMOVE_CACHE;
+ if (flags & DELETE_BROWSING_HISTORY_FORMDATA)
+ remove_mask_ |= BrowsingDataRemover::REMOVE_FORM_DATA;
+ if (flags & DELETE_BROWSING_HISTORY_PASSWORDS)
+ remove_mask_ |= BrowsingDataRemover::REMOVE_PASSWORDS;
+ if (flags & DELETE_BROWSING_HISTORY_HISTORY)
+ remove_mask_ |= BrowsingDataRemover::REMOVE_HISTORY;
+
+ loop_.PostDelayedTask(FROM_HERE,
+ new MessageLoop::QuitTask, 1000 * 600);
+ loop_.MessageLoop::Run();
+
+ return S_OK;
+}
+
+
diff --git a/chrome_frame/delete_chrome_history.h b/chrome_frame/delete_chrome_history.h
new file mode 100644
index 0000000..947f673
--- /dev/null
+++ b/chrome_frame/delete_chrome_history.h
@@ -0,0 +1,65 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_FRAME_DELETE_CHROME_HISTORY_H_
+#define CHROME_FRAME_DELETE_CHROME_HISTORY_H_
+
+#include <atlbase.h>
+#include <atlwin.h>
+#include <atlcom.h>
+
+#include <deletebrowsinghistory.h>
+
+#include "base/message_loop.h"
+#include "chrome_frame/bho.h"
+#include "chrome_frame/chrome_frame_plugin.h"
+#include "grit/chrome_frame_resources.h"
+
+// Include without path to make GYP build see it.
+#include "chrome_tab.h" // NOLINT
+
+class Bho;
+
+// DeleteChromeHistory: Implements IDeleteBrowsingHistory and
+// pumps cache clearing operations over automation. Blocks the UI
+// thread while operating. You have been warned.
+class ATL_NO_VTABLE DeleteChromeHistory
+ : public CComTearOffObjectBase<Bho, CComSingleThreadModel>,
+ public CWindowImpl<DeleteChromeHistory>,
+ public ChromeFramePlugin<DeleteChromeHistory>,
+ public IDeleteBrowsingHistory {
+ public:
+ DeleteChromeHistory();
+ ~DeleteChromeHistory();
+
+ HRESULT FinalConstruct();
+
+DECLARE_CLASSFACTORY_SINGLETON(DeleteChromeHistory)
+
+BEGIN_COM_MAP(DeleteChromeHistory)
+ COM_INTERFACE_ENTRY(IDeleteBrowsingHistory)
+END_COM_MAP()
+
+BEGIN_MSG_MAP(DeleteChromeHistory)
+ CHAIN_MSG_MAP(ChromeFramePlugin<DeleteChromeHistory>)
+END_MSG_MAP()
+
+ // IDeleteBrowsingHistory methods
+ STDMETHOD(DeleteBrowsingHistory)(DWORD flags);
+
+ protected:
+ // ChromeFrameDelegate overrides
+ virtual void OnAutomationServerReady();
+ virtual void OnAutomationServerLaunchFailed(
+ AutomationLaunchResult reason, const std::string& server_version);
+
+ virtual void GetProfilePath(const std::wstring& profile_name,
+ FilePath* profile_path);
+
+ private:
+ unsigned long remove_mask_;
+ MessageLoopForUI loop_;
+};
+
+#endif // CHROME_FRAME_DELETE_CHROME_HISTORY_H_
diff --git a/chrome_frame/test/automation_client_mock.cc b/chrome_frame/test/automation_client_mock.cc
index f699635..36edc57 100644
--- a/chrome_frame/test/automation_client_mock.cc
+++ b/chrome_frame/test/automation_client_mock.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome_frame/test/automation_client_mock.h"
@@ -44,7 +44,7 @@ void MockProxyFactory::GetServerImpl(ChromeFrameAutomationProxy* pxy,
void CFACMockTest::SetAutomationServerOk() {
EXPECT_CALL(factory_, GetAutomationServer(testing::NotNull(),
testing::Field(&ChromeFrameLaunchParams::profile_name,
- testing::StrEq(profile_)),
+ testing::StrEq(profile_path_.BaseName().ToWStringHack())),
testing::NotNull()))
.Times(1)
.WillOnce(testing::Invoke(CreateFunctor(&factory_,
@@ -91,7 +91,8 @@ TEST(CFACWithChrome, CreateTooFast) {
MockCFDelegate cfd;
chrome_frame_test::TimedMsgLoop loop;
int timeout = 0; // Chrome cannot send Hello message so fast.
- const std::wstring profile = L"Adam.N.Epilinter";
+ const FilePath profile_path(
+ chrome_frame_test::GetProfilePath(L"Adam.N.Epilinter"));
scoped_refptr<ChromeFrameAutomationClient> client;
client = new ChromeFrameAutomationClient();
@@ -100,7 +101,8 @@ TEST(CFACWithChrome, CreateTooFast) {
.Times(1)
.WillOnce(QUIT_LOOP(loop));
- EXPECT_TRUE(client->Initialize(&cfd, timeout, false, profile, L"", false));
+ EXPECT_TRUE(client->Initialize(&cfd, timeout, false, profile_path, L"",
+ false));
loop.RunFor(10);
client->Uninitialize();
}
@@ -112,7 +114,8 @@ TEST(CFACWithChrome, CreateTooFast) {
TEST(CFACWithChrome, CreateNotSoFast) {
MockCFDelegate cfd;
chrome_frame_test::TimedMsgLoop loop;
- const std::wstring profile = L"Adam.N.Epilinter";
+ const FilePath profile_path(
+ chrome_frame_test::GetProfilePath(L"Adam.N.Epilinter"));
int timeout = 10000;
scoped_refptr<ChromeFrameAutomationClient> client;
@@ -125,7 +128,8 @@ TEST(CFACWithChrome, CreateNotSoFast) {
EXPECT_CALL(cfd, OnAutomationServerLaunchFailed(_, _))
.Times(0);
- EXPECT_TRUE(client->Initialize(&cfd, timeout, false, profile, L"", false));
+ EXPECT_TRUE(client->Initialize(&cfd, timeout, false, profile_path, L"",
+ false));
loop.RunFor(11);
client->Uninitialize();
@@ -135,8 +139,9 @@ TEST(CFACWithChrome, CreateNotSoFast) {
TEST(CFACWithChrome, NavigateOk) {
MockCFDelegate cfd;
chrome_frame_test::TimedMsgLoop loop;
- const std::wstring profile = L"Adam.N.Epilinter";
const std::string url = "about:version";
+ const FilePath profile_path(
+ chrome_frame_test::GetProfilePath(L"Adam.N.Epilinter"));
int timeout = 10000;
scoped_refptr<ChromeFrameAutomationClient> client;
@@ -165,7 +170,8 @@ TEST(CFACWithChrome, NavigateOk) {
.WillOnce(QUIT_LOOP(loop));
}
- EXPECT_TRUE(client->Initialize(&cfd, timeout, false, profile, L"", false));
+ EXPECT_TRUE(client->Initialize(&cfd, timeout, false, profile_path, L"",
+ false));
loop.RunFor(10);
client->Uninitialize();
client = NULL;
@@ -174,7 +180,8 @@ TEST(CFACWithChrome, NavigateOk) {
TEST(CFACWithChrome, NavigateFailed) {
MockCFDelegate cfd;
chrome_frame_test::TimedMsgLoop loop;
- const std::wstring profile = L"Adam.N.Epilinter";
+ const FilePath profile_path(
+ chrome_frame_test::GetProfilePath(L"Adam.N.Epilinter"));
const std::string url = "http://127.0.0.3:65412/";
const URLRequestStatus connection_failed(URLRequestStatus::FAILED,
net::ERR_INVALID_URL);
@@ -204,7 +211,8 @@ TEST(CFACWithChrome, NavigateFailed) {
.Times(1)
.WillOnce(QUIT_LOOP_SOON(loop, 2));
- EXPECT_TRUE(client->Initialize(&cfd, 10000, false, profile, L"", false));
+ EXPECT_TRUE(client->Initialize(&cfd, 10000, false, profile_path, L"",
+ false));
loop.RunFor(10);
client->Uninitialize();
@@ -237,7 +245,8 @@ TEST_F(CFACMockTest, MockedCreateTabOk) {
EXPECT_CALL(proxy_, CancelAsync(_)).Times(testing::AnyNumber());
// Here we go!
- EXPECT_TRUE(client_->Initialize(&cfd_, timeout, false, profile_, L"", false));
+ EXPECT_TRUE(client_->Initialize(&cfd_, timeout, false, profile_path_, L"",
+ false));
loop_.RunFor(10);
client_->Uninitialize();
}
@@ -262,7 +271,7 @@ TEST_F(CFACMockTest, MockedCreateTabFailed) {
Set_CFD_LaunchFailed(AUTOMATION_CREATE_TAB_FAILED);
// Here we go!
- EXPECT_TRUE(client_->Initialize(&cfd_, timeout_, false, profile_, L"",
+ EXPECT_TRUE(client_->Initialize(&cfd_, timeout_, false, profile_path_, L"",
false));
loop_.RunFor(4);
client_->Uninitialize();
diff --git a/chrome_frame/test/automation_client_mock.h b/chrome_frame/test/automation_client_mock.h
index b81a582..4f65bbb 100644
--- a/chrome_frame/test/automation_client_mock.h
+++ b/chrome_frame/test/automation_client_mock.h
@@ -1,8 +1,8 @@
-// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_FRAME_AUTOMATION_CLIENT_MOCK_H_
-#define CHROME_FRAME_AUTOMATION_CLIENT_MOCK_H_
+#ifndef CHROME_FRAME_TEST_AUTOMATION_CLIENT_MOCK_H_
+#define CHROME_FRAME_TEST_AUTOMATION_CLIENT_MOCK_H_
#include <windows.h>
#include <string>
@@ -137,7 +137,7 @@ class CFACMockTest : public testing::Test {
// the victim of all tests
scoped_refptr<ChromeFrameAutomationClient> client_;
- std::wstring profile_;
+ FilePath profile_path_;
int timeout_;
void* id_; // Automation server id we are going to return
int tab_handle_; // Tab handle. Any non-zero value is Ok.
@@ -156,8 +156,10 @@ class CFACMockTest : public testing::Test {
void Set_CFD_LaunchFailed(AutomationLaunchResult result);
protected:
- CFACMockTest() : tracker_(NULL), timeout_(500),
- profile_(L"Adam.N.Epilinter") {
+ CFACMockTest()
+ : tracker_(NULL), timeout_(500),
+ profile_path_(
+ chrome_frame_test::GetProfilePath(L"Adam.N.Epilinter")) {
id_ = reinterpret_cast<void*>(5);
tab_handle_ = 3;
}
@@ -172,5 +174,5 @@ class CFACMockTest : public testing::Test {
};
-#endif // CHROME_FRAME_AUTOMATION_CLIENT_MOCK_H_
+#endif // CHROME_FRAME_TEST_AUTOMATION_CLIENT_MOCK_H_
diff --git a/chrome_frame/test/chrome_frame_automation_mock.h b/chrome_frame/test/chrome_frame_automation_mock.h
index 6fea200..11d186f 100644
--- a/chrome_frame/test/chrome_frame_automation_mock.h
+++ b/chrome_frame/test/chrome_frame_automation_mock.h
@@ -11,6 +11,8 @@
#include "chrome_frame/chrome_frame_automation.h"
#include "chrome_frame/chrome_frame_plugin.h"
#include "chrome_frame/test/http_server.h"
+#include "chrome_frame/test/chrome_frame_test_utils.h"
+#include "chrome_frame/utils.h"
template <typename T>
class AutomationMockDelegate
@@ -24,9 +26,13 @@ class AutomationMockDelegate
: caller_message_loop_(caller_message_loop), is_connected_(false),
navigation_result_(false) {
test_server_.SetUp();
+
+ FilePath profile_path(
+ chrome_frame_test::GetProfilePath(profile_name));
+
automation_client_ = new ChromeFrameAutomationClient;
automation_client_->Initialize(this, launch_timeout, perform_version_check,
- profile_name, extra_chrome_arguments, incognito);
+ profile_path, extra_chrome_arguments, incognito);
}
~AutomationMockDelegate() {
if (automation_client_.get()) {
diff --git a/chrome_frame/test/chrome_frame_test_utils.cc b/chrome_frame/test/chrome_frame_test_utils.cc
index c2f0abb..9c82b20 100644
--- a/chrome_frame/test/chrome_frame_test_utils.cc
+++ b/chrome_frame/test/chrome_frame_test_utils.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -18,7 +18,10 @@
#include "base/utf_string_conversions.h"
#include "base/win_util.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/common/chrome_paths_internal.h"
#include "chrome_frame/utils.h"
+
#include "testing/gtest/include/gtest/gtest.h"
namespace chrome_frame_test {
@@ -361,6 +364,12 @@ HRESULT LaunchIEAsComServer(IWebBrowser2** web_browser) {
return hr;
}
+FilePath GetProfilePath(const std::wstring& profile_name) {
+ FilePath profile_path;
+ chrome::GetChromeFrameUserDataDirectory(&profile_path);
+ return profile_path.Append(profile_name);
+}
+
_ATL_FUNC_INFO WebBrowserEventSink::kNavigateErrorInfo = {
CC_STDCALL, VT_EMPTY, 5, {
VT_DISPATCH,
diff --git a/chrome_frame/test/chrome_frame_test_utils.h b/chrome_frame/test/chrome_frame_test_utils.h
index c766861..9040d9a 100644
--- a/chrome_frame/test/chrome_frame_test_utils.h
+++ b/chrome_frame/test/chrome_frame_test_utils.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -115,6 +115,8 @@ class TimedMsgLoop {
// Returns S_OK on success.
HRESULT LaunchIEAsComServer(IWebBrowser2** web_browser);
+FilePath GetProfilePath(const std::wstring& suffix);
+
#ifndef DISPID_NEWPROCESS
#define DISPID_NEWPROCESS 284
#endif // DISPID_NEWPROCESS
@@ -255,7 +257,7 @@ END_SINK_MAP()
virtual void OnNewBrowserWindow(IDispatch* new_window, const wchar_t* url) {}
// Window watchdog override
- virtual void OnWindowDetected(HWND hwnd, const std::string& caption) {};
+ virtual void OnWindowDetected(HWND hwnd, const std::string& caption) {}
IWebBrowser2* web_browser2() {
return web_browser2_.get();
diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc
index 7fcdde8..85d4880 100644
--- a/chrome_frame/utils.cc
+++ b/chrome_frame/utils.cc
@@ -13,6 +13,7 @@
#include "base/logging.h"
#include "base/path_service.h"
#include "base/registry.h"
+#include "base/scoped_bstr_win.h"
#include "base/scoped_comptr_win.h"
#include "base/scoped_variant_win.h"
#include "base/string_util.h"
@@ -411,6 +412,34 @@ IEVersion GetIEVersion() {
return ie_version;
}
+FilePath GetIETemporaryFilesFolder() {
+ DCHECK_EQ(BROWSER_IE, GetBrowserType());
+
+ LPITEMIDLIST tif_pidl = NULL;
+ HRESULT hr = SHGetFolderLocation(NULL, CSIDL_INTERNET_CACHE, NULL,
+ SHGFP_TYPE_CURRENT, &tif_pidl);
+ DCHECK(SUCCEEDED(hr) && tif_pidl);
+
+ ScopedComPtr<IShellFolder> parent_folder;
+ LPCITEMIDLIST relative_pidl = NULL;
+ hr = SHBindToParent(tif_pidl, IID_IShellFolder,
+ reinterpret_cast<void**>(parent_folder.Receive()),
+ &relative_pidl);
+ DCHECK(SUCCEEDED(hr) && relative_pidl);
+
+ STRRET path = {0};
+ hr = parent_folder->GetDisplayNameOf(relative_pidl,
+ SHGDN_NORMAL | SHGDN_FORPARSING,
+ &path);
+ DCHECK(SUCCEEDED(hr));
+ ScopedBstr tif_bstr;
+ StrRetToBSTR(&path, relative_pidl, tif_bstr.Receive());
+ FilePath tif(static_cast<BSTR>(tif_bstr));
+
+ ILFree(tif_pidl);
+ return tif;
+}
+
bool IsIEInPrivate() {
typedef BOOL (WINAPI* IEIsInPrivateBrowsingPtr)();
bool incognito_mode = false;
diff --git a/chrome_frame/utils.h b/chrome_frame/utils.h
index 8c387c5..ffa4b08 100644
--- a/chrome_frame/utils.h
+++ b/chrome_frame/utils.h
@@ -13,6 +13,7 @@
#include <string>
#include "base/basictypes.h"
+#include "base/file_path.h"
#include "base/histogram.h"
#include "base/lock.h"
#include "base/logging.h"
@@ -172,6 +173,8 @@ typedef enum IEVersion {
// will be returned.
IEVersion GetIEVersion();
+FilePath GetIETemporaryFilesFolder();
+
// Retrieves the file version from a module handle without extra round trips
// to the disk (as happens with the regular GetFileVersionInfo API).
//