diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-17 00:12:52 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-17 00:12:52 +0000 |
commit | 1a98a93fc1977683c3789dedbef2806b3fcdf5b4 (patch) | |
tree | 4a8b6aa1e55e0d2d93e9f646f3bdde3aaa98cab4 /chrome/browser/automation | |
parent | f09d9379d6e654e7fd95b9d601b1e77f1ac13c3d (diff) | |
download | chromium_src-1a98a93fc1977683c3789dedbef2806b3fcdf5b4.zip chromium_src-1a98a93fc1977683c3789dedbef2806b3fcdf5b4.tar.gz chromium_src-1a98a93fc1977683c3789dedbef2806b3fcdf5b4.tar.bz2 |
amit, please review everything, jam please review the changes to the tab_contents and the
renderer_host sources.
Remove the AutomationProfileImpl class which wraps the Chrome profile for an external tab
container, which hosts ChromeFrame. This object was used to carry a custom URL request
context which was used to intercept HTTP requests and cookie requests issued by external
tabs.
However as the life time of the automation profile class depended on the lifetime of the external
tab container object this caused a number of crashes in objects which held on to the automation profile
pointer retrieved from the associated tab contents. This does not happen in a regualar Chrome browser
instance as the profile is deleted at the very end.
We can associate the automation URL request context with the underlying tab_contents which would
eventually percolate down to the resource message filter. Doing this would avoid the need for the
AutomationProfile class.
This CL achieves that.
Bug=27695,27662
Review URL: http://codereview.chromium.org/385117
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32127 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/automation')
-rw-r--r-- | chrome/browser/automation/automation_profile_impl.cc | 65 | ||||
-rw-r--r-- | chrome/browser/automation/automation_profile_impl.h | 237 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider_win.cc | 3 |
3 files changed, 46 insertions, 259 deletions
diff --git a/chrome/browser/automation/automation_profile_impl.cc b/chrome/browser/automation/automation_profile_impl.cc index bb9b106..37caf33 100644 --- a/chrome/browser/automation/automation_profile_impl.cc +++ b/chrome/browser/automation/automation_profile_impl.cc @@ -5,9 +5,11 @@ #include "chrome/browser/automation/automation_profile_impl.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/net/chrome_url_request_context.h" +#include "chrome/browser/profile.h" +#include "net/url_request/url_request_context.h" #include "chrome/test/automation/automation_messages.h" -namespace { +namespace AutomationRequestContext { // A special Request context for automation. Substitute a few things // like cookie store, proxy settings etc to handle them differently @@ -49,12 +51,12 @@ class AutomationURLRequestContext : public ChromeURLRequestContext { // behavior for cookies. class AutomationCookieStore : public net::CookieStore { public: - AutomationCookieStore(AutomationProfileImpl* profile, - net::CookieStore* original_cookie_store, - IPC::Message::Sender* automation_client) - : profile_(profile), - original_cookie_store_(original_cookie_store), - automation_client_(automation_client) { + AutomationCookieStore(net::CookieStore* original_cookie_store, + IPC::Message::Sender* automation_client, + int tab_handle) + : original_cookie_store_(original_cookie_store), + automation_client_(automation_client), + tab_handle_(tab_handle) { } // CookieStore implementation. @@ -64,7 +66,7 @@ class AutomationCookieStore : public net::CookieStore { // TODO(eroman): Should NOT be accessing the profile from here, as this // is running on the IO thread. SendIPCMessageOnIOThread(new AutomationMsg_SetCookieAsync(0, - profile_->tab_handle(), url, cookie_line)); + tab_handle_, url, cookie_line)); } return cookie_set; } @@ -116,9 +118,9 @@ class AutomationCookieStore : public net::CookieStore { } } - AutomationProfileImpl* profile_; net::CookieStore* original_cookie_store_; IPC::Message::Sender* automation_client_; + int tab_handle_; private: DISALLOW_COPY_AND_ASSIGN(AutomationCookieStore); @@ -127,12 +129,13 @@ class AutomationCookieStore : public net::CookieStore { class Factory : public ChromeURLRequestContextFactory { public: Factory(ChromeURLRequestContextGetter* original_context_getter, - AutomationProfileImpl* profile, - IPC::Message::Sender* automation_client) + Profile* profile, + IPC::Message::Sender* automation_client, + int tab_handle) : ChromeURLRequestContextFactory(profile), original_context_getter_(original_context_getter), - profile_(profile), - automation_client_(automation_client) { + automation_client_(automation_client), + tab_handle_(tab_handle) { } virtual ChromeURLRequestContext* Create() { @@ -141,9 +144,9 @@ class Factory : public ChromeURLRequestContextFactory { // Create an automation cookie store. scoped_refptr<net::CookieStore> automation_cookie_store = - new AutomationCookieStore(profile_, - original_context->cookie_store(), - automation_client_); + new AutomationCookieStore(original_context->cookie_store(), + automation_client_, + tab_handle_); return new AutomationURLRequestContext(original_context, automation_cookie_store); @@ -151,8 +154,8 @@ class Factory : public ChromeURLRequestContextFactory { private: scoped_refptr<ChromeURLRequestContextGetter> original_context_getter_; - AutomationProfileImpl* profile_; IPC::Message::Sender* automation_client_; + int tab_handle_; }; // TODO(eroman): This duplicates CleanupRequestContext() from profile.cc. @@ -163,23 +166,21 @@ void CleanupRequestContext(ChromeURLRequestContextGetter* context) { ChromeThread::ReleaseSoon(ChromeThread::IO, FROM_HERE, context); } -} // namespace - -AutomationProfileImpl::~AutomationProfileImpl() { - CleanupRequestContext(alternate_request_context_); -} - -void AutomationProfileImpl::Initialize(Profile* original_profile, +ChromeURLRequestContextGetter* CreateAutomationURLRequestContextForTab( + int tab_handle, + Profile* profile, IPC::Message::Sender* automation_client) { - DCHECK(original_profile); - original_profile_ = original_profile; - ChromeURLRequestContextGetter* original_context = static_cast<ChromeURLRequestContextGetter*>( - original_profile_->GetRequestContext()); - alternate_request_context_ = new ChromeURLRequestContextGetter( - NULL, // Don't register an observer on PrefService. - new Factory(original_context, this, automation_client)); - alternate_request_context_->AddRef(); // Balananced in the destructor. + profile->GetRequestContext()); + + ChromeURLRequestContextGetter* request_context = + new ChromeURLRequestContextGetter( + NULL, // Don't register an observer on PrefService. + new Factory(original_context, profile, automation_client, + tab_handle)); + return request_context; } +} // namespace AutomationRequestContext + diff --git a/chrome/browser/automation/automation_profile_impl.h b/chrome/browser/automation/automation_profile_impl.h index 0151193..040c278 100644 --- a/chrome/browser/automation/automation_profile_impl.h +++ b/chrome/browser/automation/automation_profile_impl.h @@ -5,236 +5,23 @@ #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_PROFILE_IMPL_H_ #define CHROME_BROWSER_AUTOMATION_AUTOMATION_PROFILE_IMPL_H_ -#include "chrome/browser/net/chrome_url_request_context.h" -#include "chrome/browser/profile.h" -#include "net/url_request/url_request_context.h" +#include "ipc/ipc_message.h" -namespace net { -class CookieStore; -} +class Profile; +class ChromeURLRequestContextGetter; -// Automation overrides for profile settings. -class AutomationProfileImpl : public Profile { - public: - AutomationProfileImpl() : original_profile_(NULL), - tab_handle_(0) { - } +namespace AutomationRequestContext { - virtual ~AutomationProfileImpl(); +// Returns the URL request context to be used by HTTP requests handled over +// the automation channel. +ChromeURLRequestContextGetter* CreateAutomationURLRequestContextForTab( + int tab_handle, + Profile* profile, + IPC::Message::Sender* automation_client); - void Initialize(Profile* original_profile, - IPC::Message::Sender* automation_client); +// Cleans up the request context on the IO thread. +void CleanupRequestContext(ChromeURLRequestContextGetter* context); - void set_tab_handle(int tab_handle) { - tab_handle_ = tab_handle; - } - int tab_handle() const { - return tab_handle_; - } - - // Profile implementation. - virtual ProfileId GetRuntimeId() { - return original_profile_->GetRuntimeId(); - } - virtual FilePath GetPath() { - return original_profile_->GetPath(); - } - virtual bool IsOffTheRecord() { - return original_profile_->IsOffTheRecord(); - } - virtual Profile* GetOffTheRecordProfile() { - return original_profile_->GetOffTheRecordProfile(); - } - virtual void DestroyOffTheRecordProfile() { - return original_profile_->DestroyOffTheRecordProfile(); - } - virtual Profile* GetOriginalProfile() { - return original_profile_->GetOriginalProfile(); - } - virtual webkit_database::DatabaseTracker* GetDatabaseTracker() { - return original_profile_->GetDatabaseTracker(); - } - virtual VisitedLinkMaster* GetVisitedLinkMaster() { - return original_profile_->GetVisitedLinkMaster(); - } - virtual ExtensionsService* GetExtensionsService() { - return original_profile_->GetExtensionsService(); - } - virtual UserScriptMaster* GetUserScriptMaster() { - return original_profile_->GetUserScriptMaster(); - } - virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() { - return original_profile_->GetExtensionDevToolsManager(); - } - virtual ExtensionProcessManager* GetExtensionProcessManager() { - return original_profile_->GetExtensionProcessManager(); - } - virtual ExtensionMessageService* GetExtensionMessageService() { - return original_profile_->GetExtensionMessageService(); - } - virtual SSLHostState* GetSSLHostState() { - return original_profile_->GetSSLHostState(); - } - virtual net::StrictTransportSecurityState* GetStrictTransportSecurityState() { - return original_profile_->GetStrictTransportSecurityState(); - } - virtual FaviconService* GetFaviconService(ServiceAccessType access) { - return original_profile_->GetFaviconService(access); - } - virtual HistoryService* GetHistoryService(ServiceAccessType access) { - return original_profile_->GetHistoryService(access); - } - virtual HistoryService* GetHistoryServiceWithoutCreating() { - return original_profile_->GetHistoryServiceWithoutCreating(); - } - virtual SearchVersusNavigateClassifier* GetSearchVersusNavigateClassifier() { - return original_profile_->GetSearchVersusNavigateClassifier(); - } - virtual WebDataService* GetWebDataService(ServiceAccessType access) { - return original_profile_->GetWebDataService(access); - } - virtual WebDataService* GetWebDataServiceWithoutCreating() { - return original_profile_->GetWebDataServiceWithoutCreating(); - } - virtual PasswordStore* GetPasswordStore(ServiceAccessType access) { - return original_profile_->GetPasswordStore(access); - } - virtual PrefService* GetPrefs() { - return original_profile_->GetPrefs(); - } - virtual TemplateURLModel* GetTemplateURLModel() { - return original_profile_->GetTemplateURLModel(); - } - virtual TemplateURLFetcher* GetTemplateURLFetcher() { - return original_profile_->GetTemplateURLFetcher(); - } - virtual DownloadManager* GetDownloadManager() { - return original_profile_->GetDownloadManager(); - } - virtual bool HasCreatedDownloadManager() const { - return original_profile_->HasCreatedDownloadManager(); - } - virtual PersonalDataManager* GetPersonalDataManager() { - return original_profile_->GetPersonalDataManager(); - } - virtual void InitThemes() { - return original_profile_->InitThemes(); - } - virtual void SetTheme(Extension* extension) { - return original_profile_->SetTheme(extension); - } - virtual void SetNativeTheme() { - return original_profile_->SetNativeTheme(); - } - virtual void ClearTheme() { - return original_profile_->ClearTheme(); - } - virtual Extension* GetTheme() { - return original_profile_->GetTheme(); - } - virtual ThemeProvider* GetThemeProvider() { - return original_profile_->GetThemeProvider(); - } - virtual ThumbnailStore* GetThumbnailStore() { - return original_profile_->GetThumbnailStore(); - } - virtual URLRequestContextGetter* GetRequestContext() { - return alternate_request_context_; - } - virtual URLRequestContextGetter* GetRequestContextForMedia() { - return original_profile_->GetRequestContextForMedia(); - } - virtual URLRequestContextGetter* GetRequestContextForExtensions() { - return original_profile_->GetRequestContextForExtensions(); - } - virtual net::SSLConfigService* GetSSLConfigService() { - return original_profile_->GetSSLConfigService(); - } - virtual Blacklist* GetBlacklist() { - return original_profile_->GetBlacklist(); - } - virtual SessionService* GetSessionService() { - return original_profile_->GetSessionService(); - } - virtual void ShutdownSessionService() { - return original_profile_->ShutdownSessionService(); - } - virtual bool HasSessionService() const { - return original_profile_->HasSessionService(); - } - virtual std::wstring GetName() { - return original_profile_->GetName(); - } - virtual void SetName(const std::wstring& name) { - return original_profile_->SetName(name); - } - virtual std::wstring GetID() { - return original_profile_->GetID(); - } - virtual void SetID(const std::wstring& id) { - return original_profile_->SetID(id); - } - virtual bool DidLastSessionExitCleanly() { - return original_profile_->DidLastSessionExitCleanly(); - } - virtual BookmarkModel* GetBookmarkModel() { - return original_profile_->GetBookmarkModel(); - } - virtual DesktopNotificationService* GetDesktopNotificationService() { - return original_profile_->GetDesktopNotificationService(); - } - virtual ProfileSyncService* GetProfileSyncService() { - return original_profile_->GetProfileSyncService(); - } - virtual bool IsSameProfile(Profile* profile) { - return original_profile_->IsSameProfile(profile); - } - virtual base::Time GetStartTime() const { - return original_profile_->GetStartTime(); - } - virtual TabRestoreService* GetTabRestoreService() { - return original_profile_->GetTabRestoreService(); - } - virtual void ResetTabRestoreService() { - return original_profile_->ResetTabRestoreService(); - } - virtual void ReinitializeSpellChecker() { - return original_profile_->ReinitializeSpellChecker(); - } - virtual SpellChecker* GetSpellChecker() { - return original_profile_->GetSpellChecker(); - } - virtual void DeleteSpellChecker() { - return original_profile_->DeleteSpellChecker(); - } -#if defined(SPELLCHECKER_IN_RENDERER) - virtual SpellCheckHost* GetSpellCheckHost() { - return original_profile_->GetSpellCheckHost(); - } - virtual void ReinitializeSpellCheckHost(bool force) { - return original_profile_->ReinitializeSpellCheckHost(force); - } -#endif - virtual WebKitContext* GetWebKitContext() { - return original_profile_->GetWebKitContext(); - } - virtual void MarkAsCleanShutdown() { - return original_profile_->MarkAsCleanShutdown(); - } - virtual void InitExtensions() { - return original_profile_->InitExtensions(); - } - virtual void InitWebResources() { - return original_profile_->InitWebResources(); - } - - protected: - Profile* original_profile_; - ChromeURLRequestContextGetter* alternate_request_context_; - int tab_handle_; - - private: - DISALLOW_COPY_AND_ASSIGN(AutomationProfileImpl); }; #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROFILE_IMPL_H_ diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc index 109fa09..6cda550 100644 --- a/chrome/browser/automation/automation_provider_win.cc +++ b/chrome/browser/automation/automation_provider_win.cc @@ -359,7 +359,7 @@ bool AutomationProvider::AddExternalTab(ExternalTabContainer* external_tab) { TabContents* tab_contents = external_tab->tab_contents(); if (tab_contents) { int tab_handle = tab_tracker_->Add(&tab_contents->controller()); - external_tab->set_tab_handle(tab_handle); + external_tab->SetTabHandle(tab_handle); return true; } @@ -472,7 +472,6 @@ void AutomationProvider::ConnectExternalTab( automation_resource_message_filter_); TabContents* tab_contents = external_tab_container->tab_contents(); *tab_handle = external_tab_container->tab_handle(); - external_tab_container->set_tab_handle(*tab_handle); *tab_container_window = external_tab_container->GetNativeView(); *tab_window = tab_contents->GetNativeView(); } else { |