summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-17 00:12:52 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-17 00:12:52 +0000
commit1a98a93fc1977683c3789dedbef2806b3fcdf5b4 (patch)
tree4a8b6aa1e55e0d2d93e9f646f3bdde3aaa98cab4 /chrome
parentf09d9379d6e654e7fd95b9d601b1e77f1ac13c3d (diff)
downloadchromium_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')
-rw-r--r--chrome/browser/automation/automation_profile_impl.cc65
-rw-r--r--chrome/browser/automation/automation_profile_impl.h237
-rw-r--r--chrome/browser/automation/automation_provider_win.cc3
-rw-r--r--chrome/browser/chromeos/main_menu.cc3
-rw-r--r--chrome/browser/extensions/extension_host.cc2
-rw-r--r--chrome/browser/external_tab_container.cc45
-rw-r--r--chrome/browser/external_tab_container.h16
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc7
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.h4
-rw-r--r--chrome/browser/renderer_host/mock_render_process_host.cc3
-rw-r--r--chrome/browser/renderer_host/mock_render_process_host.h4
-rw-r--r--chrome/browser/renderer_host/render_process_host.h5
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc6
-rw-r--r--chrome/browser/renderer_host/render_view_host.h4
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc5
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h3
-rw-r--r--chrome/browser/renderer_host/test/test_render_view_host.cc3
-rw-r--r--chrome/browser/renderer_host/test/test_render_view_host.h2
-rw-r--r--chrome/browser/tab_contents/interstitial_page.cc9
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc7
-rw-r--r--chrome/browser/tab_contents/tab_contents.h15
-rw-r--r--chrome/browser/tab_contents/test_tab_contents.h3
-rw-r--r--chrome/browser/views/notifications/balloon_view_host.cc2
-rw-r--r--chrome/browser/visitedlink_unittest.cc6
24 files changed, 153 insertions, 306 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 {
diff --git a/chrome/browser/chromeos/main_menu.cc b/chrome/browser/chromeos/main_menu.cc
index 5a8e2e1..e5a2bae 100644
--- a/chrome/browser/chromeos/main_menu.cc
+++ b/chrome/browser/chromeos/main_menu.cc
@@ -14,6 +14,7 @@
#include "base/string_util.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser.h"
+#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_view_host_factory.h"
#include "chrome/browser/renderer_host/render_widget_host_view.h"
@@ -151,7 +152,7 @@ MainMenu::MainMenu()
rwhv_ = new RenderWidgetHostViewGtk(menu_rvh_);
rwhv_->InitAsChild();
- menu_rvh_->CreateRenderView();
+ menu_rvh_->CreateRenderView(browser_->profile()->GetRequestContext());
menu_popup->AddChild(rwhv_->GetNativeView());
gfx::Size rwhv_size = CalculateRWHVSize(popup_size);
menu_popup->PositionChild(rwhv_->GetNativeView(), kRendererX, kRendererY,
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index c34cb96..85f48de5 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -172,7 +172,7 @@ void ExtensionHost::CreateRenderViewSoon(RenderWidgetHostView* host_view) {
}
void ExtensionHost::CreateRenderViewNow() {
- render_view_host_->CreateRenderView();
+ render_view_host_->CreateRenderView(profile_->GetRequestContext());
NavigateToURL(url_);
DCHECK(IsRenderViewLive());
LOG(INFO) << "Sending EXTENSION_PROCESS_CREATED";
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc
index 806c4c6..9689ade 100644
--- a/chrome/browser/external_tab_container.cc
+++ b/chrome/browser/external_tab_container.cc
@@ -81,17 +81,6 @@ bool ExternalTabContainer::Init(Profile* profile,
// is the same as the lifetime of the window
SetProp(GetNativeView(), kWindowObjectKey, this);
- if (load_requests_via_automation) {
- // Customize our profile.
- // TODO(joshia): If we are loading requests via automation
- // and handling cookies in automation then it's probably better to
- // use OTR profile so that cookies are not persisted in chrome.
- automation_profile_.reset(new AutomationProfileImpl);
- automation_profile_->Initialize(profile,
- automation_resource_message_filter_);
- profile = automation_profile_.get();
- }
-
if (existing_contents) {
tab_contents_ = existing_contents;
tab_contents_->controller().set_profile(profile);
@@ -182,6 +171,11 @@ void ExternalTabContainer::Uninitialize() {
delete tab_contents_;
tab_contents_ = NULL;
}
+
+ if (request_context_.get()) {
+ AutomationRequestContext::CleanupRequestContext(
+ request_context_.release());
+ }
}
bool ExternalTabContainer::Reinitialize(
@@ -202,11 +196,6 @@ bool ExternalTabContainer::Reinitialize(
rvh->process()->id(), rvh->routing_id(),
tab_handle_, automation_resource_message_filter_);
}
-
- DCHECK(automation_profile_.get() != NULL);
- Profile* profile = tab_contents_->profile()->GetOriginalProfile();
- DCHECK(profile != NULL);
- automation_profile_->Initialize(profile, filter);
}
// We cannot send the navigation state right away as the automation channel
@@ -218,6 +207,13 @@ bool ExternalTabContainer::Reinitialize(
return true;
}
+void ExternalTabContainer::SetTabHandle(int handle) {
+ tab_handle_ = handle;
+ if (load_requests_via_automation_) {
+ InitializeAutomationRequestContext(handle);
+ }
+}
+
void ExternalTabContainer::ProcessUnhandledAccelerator(const MSG& msg) {
DefWindowProc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
}
@@ -700,3 +696,20 @@ bool ExternalTabContainer::OnGoToEntryOffset(int offset) {
return true;
}
+
+void ExternalTabContainer::InitializeAutomationRequestContext(
+ int tab_handle) {
+ if (request_context_.get()) {
+ AutomationRequestContext::CleanupRequestContext(
+ request_context_.release());
+ }
+
+ request_context_ =
+ AutomationRequestContext::CreateAutomationURLRequestContextForTab(
+ tab_handle, tab_contents_->profile(),
+ automation_resource_message_filter_);
+
+ DCHECK(request_context_.get() != NULL);
+ tab_contents_->set_request_context(request_context_.get());
+}
+
diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h
index 95ab846..56317d8 100644
--- a/chrome/browser/external_tab_container.h
+++ b/chrome/browser/external_tab_container.h
@@ -11,6 +11,7 @@
#include "chrome/browser/automation/automation_resource_message_filter.h"
#include "chrome/browser/automation/automation_profile_impl.h"
#include "chrome/browser/browser.h"
+#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
#include "chrome/common/navigation_types.h"
#include "chrome/common/notification_observer.h"
@@ -43,11 +44,7 @@ class ExternalTabContainer : public TabContentsDelegate,
TabContents* tab_contents() const { return tab_contents_; }
// Temporary hack so we can send notifications back
- void set_tab_handle(int handle) {
- tab_handle_ = handle;
- if (automation_profile_.get())
- automation_profile_->set_tab_handle(handle);
- }
+ void SetTabHandle(int handle);
int tab_handle() const {
return tab_handle_;
@@ -174,6 +171,9 @@ class ExternalTabContainer : public TabContentsDelegate,
int relative_offset);
void Navigate(const GURL& url, const GURL& referrer);
+ // Initializes the request context to be used for automation HTTP requests.
+ void InitializeAutomationRequestContext(int tab_handle);
+
private:
friend class base::RefCounted<ExternalTabContainer>;
@@ -216,9 +216,6 @@ class ExternalTabContainer : public TabContentsDelegate,
// Scoped browser object for this ExternalTabContainer instance.
scoped_ptr<Browser> browser_;
- // A customized profile for automation specific needs.
- scoped_ptr<AutomationProfileImpl> automation_profile_;
-
// Contains ExternalTabContainers that have not been connected to as yet.
static PendingTabs pending_tabs_;
@@ -229,6 +226,9 @@ class ExternalTabContainer : public TabContentsDelegate,
// bound by its lifetime.
ScopedRunnableMethodFactory<ExternalTabContainer> external_method_factory_;
+ // The URL request context to be used for this tab. Can be NULL.
+ scoped_refptr<ChromeURLRequestContextGetter> request_context_;
+
DISALLOW_COPY_AND_ASSIGN(ExternalTabContainer);
};
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index 200fecf..896b2fd 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -29,6 +29,7 @@
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/extensions/user_script_master.h"
#include "chrome/browser/history/history.h"
+#include "chrome/browser/net/url_request_context_getter.h"
#include "chrome/browser/plugin_service.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/audio_renderer_host.h"
@@ -261,7 +262,8 @@ BrowserRenderProcessHost::~BrowserRenderProcessHost() {
NotificationService::NoDetails());
}
-bool BrowserRenderProcessHost::Init(bool is_extensions_process) {
+bool BrowserRenderProcessHost::Init(bool is_extensions_process,
+ URLRequestContextGetter* request_context) {
// calling Init() more than once does nothing, this makes it more convenient
// for the view host which may not be sure in some cases
if (channel_.get()) {
@@ -289,7 +291,8 @@ bool BrowserRenderProcessHost::Init(bool is_extensions_process) {
g_browser_process->print_job_manager(),
profile(),
widget_helper_,
- profile()->GetSpellChecker());
+ profile()->GetSpellChecker(),
+ request_context);
// Find the renderer before creating the channel so if this fails early we
// return without creating the channel.
diff --git a/chrome/browser/renderer_host/browser_render_process_host.h b/chrome/browser/renderer_host/browser_render_process_host.h
index 42f6fe2..caf55d7 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.h
+++ b/chrome/browser/renderer_host/browser_render_process_host.h
@@ -28,6 +28,7 @@ class RendererMainThread;
class RenderWidgetHelper;
class TabContents;
class VisitedLinkUpdater;
+class URLRequestContextGetter;
namespace gfx {
class Size;
@@ -54,7 +55,8 @@ class BrowserRenderProcessHost : public RenderProcessHost,
~BrowserRenderProcessHost();
// RenderProcessHost implementation (public portion).
- virtual bool Init(bool is_extensions_process);
+ virtual bool Init(bool is_extensions_process,
+ URLRequestContextGetter* request_context);
virtual int GetNextRoutingID();
virtual void CancelResourceRequests(int render_widget_id);
virtual void CrossSiteClosePageACK(const ViewMsg_ClosePage_Params& params);
diff --git a/chrome/browser/renderer_host/mock_render_process_host.cc b/chrome/browser/renderer_host/mock_render_process_host.cc
index 55fd014..7ce8c66 100644
--- a/chrome/browser/renderer_host/mock_render_process_host.cc
+++ b/chrome/browser/renderer_host/mock_render_process_host.cc
@@ -14,7 +14,8 @@ MockRenderProcessHost::~MockRenderProcessHost() {
delete transport_dib_;
}
-bool MockRenderProcessHost::Init(bool is_extensions_process) {
+bool MockRenderProcessHost::Init(bool is_extensions_process,
+ URLRequestContextGetter* request_context) {
return true;
}
diff --git a/chrome/browser/renderer_host/mock_render_process_host.h b/chrome/browser/renderer_host/mock_render_process_host.h
index 005225f2..f9e3143 100644
--- a/chrome/browser/renderer_host/mock_render_process_host.h
+++ b/chrome/browser/renderer_host/mock_render_process_host.h
@@ -10,6 +10,7 @@
#include "chrome/common/ipc_test_sink.h"
class TransportDIB;
+class URLRequestContextGetter;
// A mock render process host that has no corresponding renderer process. All
// IPC messages are sent into the message sink for inspection by tests.
@@ -29,7 +30,8 @@ class MockRenderProcessHost : public RenderProcessHost {
int bad_msg_count() const { return bad_msg_count_; }
// RenderProcessHost implementation (public portion).
- virtual bool Init(bool is_extensions_process);
+ virtual bool Init(bool is_extensions_process,
+ URLRequestContextGetter* request_context);
virtual int GetNextRoutingID();
virtual void CancelResourceRequests(int render_widget_id);
virtual void CrossSiteClosePageACK(const ViewMsg_ClosePage_Params& params);
diff --git a/chrome/browser/renderer_host/render_process_host.h b/chrome/browser/renderer_host/render_process_host.h
index 2887f88..1b2d9ef 100644
--- a/chrome/browser/renderer_host/render_process_host.h
+++ b/chrome/browser/renderer_host/render_process_host.h
@@ -19,6 +19,8 @@
class Profile;
struct ViewMsg_ClosePage_Params;
+class URLRequestContextGetter;
+
// Virtual interface that represents the browser side of the browser <->
// renderer communication channel. There will generally be one
// RenderProcessHost per renderer process.
@@ -133,7 +135,8 @@ class RenderProcessHost : public IPC::Channel::Sender,
// be called once before the object can be used, but can be called after
// that with no effect. Therefore, if the caller isn't sure about whether
// the process has been created, it should just call Init().
- virtual bool Init(bool is_extensions_process) = 0;
+ virtual bool Init(bool is_extensions_process,
+ URLRequestContextGetter* request_context) = 0;
// Gets the next available routing id.
virtual int GetNextRoutingID() = 0;
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 34ba64d..5609bae 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/dom_operation_notification_details.h"
#include "chrome/browser/extensions/extension_message_service.h"
#include "chrome/browser/metrics/user_metrics.h"
+#include "chrome/browser/net/url_request_context_getter.h"
#include "chrome/browser/notifications/desktop_notification_service.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/render_process_host.h"
@@ -165,7 +166,8 @@ void RenderViewHost::Observe(NotificationType type,
}
}
-bool RenderViewHost::CreateRenderView() {
+bool RenderViewHost::CreateRenderView(
+ URLRequestContextGetter* request_context) {
DCHECK(!IsRenderViewLive()) << "Creating view twice";
CHECK(process());
CHECK(!process()->ListenersIterator().IsAtEnd()) <<
@@ -177,7 +179,7 @@ bool RenderViewHost::CreateRenderView() {
// ignored, so this is safe.
bool is_extensions_process =
BindingsPolicy::is_extension_enabled(enabled_bindings_);
- if (!process()->Init(is_extensions_process))
+ if (!process()->Init(is_extensions_process, request_context))
return false;
DCHECK(process()->HasConnection());
DCHECK(process()->profile());
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index a66f371..21f72c5c 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -52,6 +52,8 @@ namespace WebKit {
struct WebMediaPlayerAction;
}
+class URLRequestContextGetter;
+
//
// RenderViewHost
//
@@ -98,7 +100,7 @@ class RenderViewHost : public RenderWidgetHost,
// Set up the RenderView child process. Virtual because it is overridden by
// TestRenderViewHost.
- virtual bool CreateRenderView();
+ virtual bool CreateRenderView(URLRequestContextGetter* request_context);
// Returns true if the RenderView is active and has not crashed. Virtual
// because it is overridden by TestRenderViewHost.
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index ba34532..93ee409 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -150,7 +150,8 @@ ResourceMessageFilter::ResourceMessageFilter(
printing::PrintJobManager* print_job_manager,
Profile* profile,
RenderWidgetHelper* render_widget_helper,
- SpellChecker* spellchecker)
+ SpellChecker* spellchecker,
+ URLRequestContextGetter* request_context)
: Receiver(RENDER_PROCESS, child_id),
channel_(NULL),
resource_dispatcher_host_(resource_dispatcher_host),
@@ -158,7 +159,7 @@ ResourceMessageFilter::ResourceMessageFilter(
print_job_manager_(print_job_manager),
spellchecker_(spellchecker),
ALLOW_THIS_IN_INITIALIZER_LIST(resolve_proxy_msg_helper_(this, NULL)),
- request_context_(profile->GetRequestContext()),
+ request_context_(request_context),
media_request_context_(profile->GetRequestContextForMedia()),
extensions_request_context_(profile->GetRequestContextForExtensions()),
extensions_message_service_(profile->GetExtensionMessageService()),
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index 31f87d4..50507db 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -87,7 +87,8 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
printing::PrintJobManager* print_job_manager,
Profile* profile,
RenderWidgetHelper* render_widget_helper,
- SpellChecker* spellchecker);
+ SpellChecker* spellchecker,
+ URLRequestContextGetter* request_context);
// IPC::ChannelProxy::MessageFilter methods:
virtual void OnFilterAdded(IPC::Channel* channel);
diff --git a/chrome/browser/renderer_host/test/test_render_view_host.cc b/chrome/browser/renderer_host/test/test_render_view_host.cc
index 72a0c6b..e9e848f 100644
--- a/chrome/browser/renderer_host/test/test_render_view_host.cc
+++ b/chrome/browser/renderer_host/test/test_render_view_host.cc
@@ -28,7 +28,8 @@ TestRenderViewHost::~TestRenderViewHost() {
delete view();
}
-bool TestRenderViewHost::CreateRenderView() {
+bool TestRenderViewHost::CreateRenderView(
+ URLRequestContextGetter* request_context) {
DCHECK(!render_view_created_);
render_view_created_ = true;
process()->ViewCreated();
diff --git a/chrome/browser/renderer_host/test/test_render_view_host.h b/chrome/browser/renderer_host/test/test_render_view_host.h
index cc58d37..b1458a1 100644
--- a/chrome/browser/renderer_host/test/test_render_view_host.h
+++ b/chrome/browser/renderer_host/test/test_render_view_host.h
@@ -131,7 +131,7 @@ class TestRenderViewHost : public RenderViewHost {
// RenderViewHost overrides --------------------------------------------------
- virtual bool CreateRenderView();
+ virtual bool CreateRenderView(URLRequestContextGetter* request_context);
virtual bool IsRenderViewLive() const;
private:
diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc
index 34e008c..aae90da 100644
--- a/chrome/browser/tab_contents/interstitial_page.cc
+++ b/chrome/browser/tab_contents/interstitial_page.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/dom_operation_notification_details.h"
+#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/renderer_host/render_widget_host_view.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
@@ -391,7 +392,13 @@ TabContentsView* InterstitialPage::CreateTabContentsView() {
tab_contents_view->CreateViewForWidget(render_view_host_);
render_view_host_->set_view(view);
render_view_host_->AllowBindings(BindingsPolicy::DOM_AUTOMATION);
- render_view_host_->CreateRenderView();
+
+ scoped_refptr<URLRequestContextGetter> request_context =
+ tab()->request_context();
+ if (!request_context.get())
+ request_context = tab()->profile()->GetRequestContext();
+
+ render_view_host_->CreateRenderView(request_context.get());
view->SetSize(tab_contents_view->GetContainerSize());
// Don't show the interstitial until we have navigated to it.
view->Hide();
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 84dba1a..c373a6a 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -2598,7 +2598,12 @@ bool TabContents::CreateRenderViewForRenderManager(
render_manager_.pending_dom_ui()->bindings());
RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(render_view_host);
- if (!render_view_host->CreateRenderView())
+
+ scoped_refptr<URLRequestContextGetter> request_context = request_context_;
+ if (!request_context.get())
+ request_context = profile()->GetRequestContext();
+
+ if (!render_view_host->CreateRenderView(request_context))
return false;
// Now that the RenderView has been created, we need to tell it its size.
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index ee25ef3..b8e84a7 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -23,6 +23,7 @@
#include "chrome/browser/fav_icon_helper.h"
#include "chrome/browser/find_notification_details.h"
#include "chrome/browser/jsmessage_box_client.h"
+#include "chrome/browser/net/url_request_context_getter.h"
#include "chrome/browser/shell_dialogs.h"
#include "chrome/browser/renderer_host/render_view_host_delegate.h"
#include "chrome/browser/tab_contents/constrained_window.h"
@@ -622,6 +623,15 @@ class TabContents : public PageNavigator,
// times, subsequent calls are ignored.
void OnCloseStarted();
+ // Getter/Setters for the url request context to be used for this tab.
+ void set_request_context(URLRequestContextGetter* context) {
+ request_context_ = context;
+ }
+
+ URLRequestContextGetter* request_context() const {
+ return request_context_;
+ }
+
private:
friend class NavigationController;
// Used to access the child_windows_ (ConstrainedWindowList) for testing
@@ -1179,6 +1189,11 @@ class TabContents : public PageNavigator,
// The time that we started to close the tab.
base::TimeTicks tab_close_start_time_;
+ // Contextual information to be used for requests created here.
+ // Can be NULL in which case we defer to the request context from the
+ // profile
+ scoped_refptr<URLRequestContextGetter> request_context_;
+
// ---------------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(TabContents);
diff --git a/chrome/browser/tab_contents/test_tab_contents.h b/chrome/browser/tab_contents/test_tab_contents.h
index ff9c6b7..7bab690 100644
--- a/chrome/browser/tab_contents/test_tab_contents.h
+++ b/chrome/browser/tab_contents/test_tab_contents.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_
#define CHROME_BROWSER_TAB_CONTENTS_TEST_TAB_CONTENTS_H_
+#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
class RenderViewHostFactory;
@@ -42,7 +43,7 @@ class TestTabContents : public TabContents {
// Prevent interaction with views.
bool CreateRenderViewForRenderManager(RenderViewHost* render_view_host) {
// This will go to a TestRenderViewHost.
- render_view_host->CreateRenderView();
+ render_view_host->CreateRenderView(profile()->GetRequestContext());
return true;
}
void UpdateRenderViewSizeForRenderManager() {}
diff --git a/chrome/browser/views/notifications/balloon_view_host.cc b/chrome/browser/views/notifications/balloon_view_host.cc
index fa8e842..9bef667 100644
--- a/chrome/browser/views/notifications/balloon_view_host.cc
+++ b/chrome/browser/views/notifications/balloon_view_host.cc
@@ -104,7 +104,7 @@ void BalloonViewHost::Init(gfx::NativeView parent_hwnd) {
#endif
// Start up the renderer and point it at the balloon contents URL.
- rvh->CreateRenderView();
+ rvh->CreateRenderView(GetProfile()->GetRequestContext());
rvh->NavigateToURL(balloon_->notification().content_url());
initialized_ = true;
}
diff --git a/chrome/browser/visitedlink_unittest.cc b/chrome/browser/visitedlink_unittest.cc
index d8906f7..b873243 100644
--- a/chrome/browser/visitedlink_unittest.cc
+++ b/chrome/browser/visitedlink_unittest.cc
@@ -673,7 +673,7 @@ TEST_F(VisitedLinkEventsTest, Coalescense) {
TEST_F(VisitedLinkRelayTest, Basics) {
VisitedLinkMaster* master = profile_->GetVisitedLinkMaster();
- rvh()->CreateRenderView();
+ rvh()->CreateRenderView(profile_->GetRequestContext());
// Add a few URLs.
master->AddURL(GURL("http://acidtests.org/"));
@@ -697,7 +697,7 @@ TEST_F(VisitedLinkRelayTest, Basics) {
TEST_F(VisitedLinkRelayTest, TabVisibility) {
VisitedLinkMaster* master = profile_->GetVisitedLinkMaster();
- rvh()->CreateRenderView();
+ rvh()->CreateRenderView(profile_->GetRequestContext());
// Simulate tab becoming inactive.
rvh()->WasHidden();
@@ -760,7 +760,7 @@ TEST_F(VisitedLinkRelayTest, WebViewReadiness) {
EXPECT_EQ(0, profile()->add_event_count());
EXPECT_EQ(0, profile()->reset_event_count());
- rvh()->CreateRenderView();
+ rvh()->CreateRenderView(profile_->GetRequestContext());
// We should now have just a reset event: adds are eaten up by a reset
// that followed.