summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/automation/automation_profile_impl.cc203
-rw-r--r--chrome/browser/automation/automation_profile_impl.h26
-rw-r--r--chrome/browser/automation/automation_provider.cc14
-rw-r--r--chrome/browser/automation/automation_resource_message_filter.cc129
-rw-r--r--chrome/browser/automation/automation_resource_message_filter.h26
-rw-r--r--chrome/browser/background_contents_service.cc2
-rw-r--r--chrome/browser/extensions/extension_host.cc3
-rw-r--r--chrome/browser/external_tab_container_win.cc17
-rw-r--r--chrome/browser/external_tab_container_win.h4
-rw-r--r--chrome/browser/notifications/balloon_host.cc2
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc6
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.h3
-rw-r--r--chrome/browser/renderer_host/mock_render_process_host.cc3
-rw-r--r--chrome/browser/renderer_host/mock_render_process_host.h3
-rw-r--r--chrome/browser/renderer_host/render_process_host.h3
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc5
-rw-r--r--chrome/browser/renderer_host/render_view_host.h3
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc54
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h13
-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.h3
-rw-r--r--chrome/browser/tab_contents/interstitial_page.cc7
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc10
-rw-r--r--chrome/browser/tab_contents/tab_contents.h11
-rw-r--r--chrome/browser/tab_contents/test_tab_contents.cc3
-rw-r--r--chrome/browser/visitedlink_unittest.cc6
26 files changed, 186 insertions, 376 deletions
diff --git a/chrome/browser/automation/automation_profile_impl.cc b/chrome/browser/automation/automation_profile_impl.cc
deleted file mode 100644
index 0b14c7e..0000000
--- a/chrome/browser/automation/automation_profile_impl.cc
+++ /dev/null
@@ -1,203 +0,0 @@
-// Copyright (c) 2006-2009 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/browser/automation/automation_profile_impl.h"
-
-#include <map>
-
-#include "chrome/browser/automation/automation_resource_message_filter.h"
-#include "chrome/browser/chrome_thread.h"
-#include "chrome/browser/net/chrome_url_request_context.h"
-#include "chrome/browser/profile.h"
-#include "net/base/net_errors.h"
-#include "net/url_request/url_request_context.h"
-#include "chrome/test/automation/automation_messages.h"
-
-namespace AutomationRequestContext {
-
-// A special Request context for automation. Substitute a few things
-// like cookie store, proxy settings etc to handle them differently
-// for automation.
-class AutomationURLRequestContext : public ChromeURLRequestContext {
- public:
- AutomationURLRequestContext(ChromeURLRequestContext* original_context,
- net::CookieStore* automation_cookie_store,
- net::CookiePolicy* automation_cookie_policy)
- : ChromeURLRequestContext(original_context),
- // We must hold a reference to |original_context|, since many
- // of the dependencies that ChromeURLRequestContext(original_context)
- // copied are scoped to |original_context|.
- original_context_(original_context) {
- cookie_policy_ = automation_cookie_policy;
- cookie_store_ = automation_cookie_store;
- }
-
- virtual bool IsExternal() const {
- return true;
- }
-
- private:
- virtual ~AutomationURLRequestContext() {
- // Clear out members before calling base class dtor since we don't
- // own any of them.
-
- // Clear URLRequestContext members.
- host_resolver_ = NULL;
- proxy_service_ = NULL;
- http_transaction_factory_ = NULL;
- ftp_transaction_factory_ = NULL;
- cookie_store_ = NULL;
- transport_security_state_ = NULL;
- }
-
- scoped_refptr<ChromeURLRequestContext> original_context_;
- DISALLOW_COPY_AND_ASSIGN(AutomationURLRequestContext);
-};
-
-// CookieStore specialization to have automation specific
-// behavior for cookies.
-class AutomationCookieStore : public net::CookieStore {
- public:
- AutomationCookieStore(net::CookieStore* original_cookie_store,
- AutomationResourceMessageFilter* automation_client,
- int tab_handle)
- : original_cookie_store_(original_cookie_store),
- automation_client_(automation_client),
- tab_handle_(tab_handle) {
- }
-
- virtual ~AutomationCookieStore() {
- DLOG(INFO) << "In " << __FUNCTION__;
- }
-
- // CookieStore implementation.
- virtual bool SetCookieWithOptions(const GURL& url,
- const std::string& cookie_line,
- const net::CookieOptions& options) {
- // The cookie_string_ is available only once, i.e. once it is read by
- // it is invalidated.
- cookie_string_ = cookie_line;
- return true;
- }
-
- virtual std::string GetCookiesWithOptions(const GURL& url,
- const net::CookieOptions& options) {
- return cookie_string_;
- }
-
- virtual void DeleteCookie(const GURL& url,
- const std::string& cookie_name) {
- NOTREACHED() << "Should not get called for an automation profile";
- }
-
- virtual net::CookieMonster* GetCookieMonster() {
- NOTREACHED() << "Should not get called for an automation profile";
- return NULL;
- }
-
- protected:
- net::CookieStore* original_cookie_store_;
- scoped_refptr<AutomationResourceMessageFilter> automation_client_;
- int tab_handle_;
- std::string cookie_string_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(AutomationCookieStore);
-};
-
-// CookiePolicy specialization for automation specific cookie policies.
-class AutomationCookiePolicy : public net::CookiePolicy {
- public:
- AutomationCookiePolicy(AutomationResourceMessageFilter* automation_client,
- int tab_handle, net::CookieStore* cookie_store)
- : automation_client_(automation_client),
- tab_handle_(tab_handle),
- cookie_store_(cookie_store) {}
-
- virtual int CanGetCookies(const GURL& url,
- const GURL& first_party_for_cookies,
- net::CompletionCallback* callback) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
-
- AutomationResourceMessageFilter::GetCookiesForUrl(tab_handle_, url,
- callback,
- cookie_store_.get());
- return net::ERR_IO_PENDING;
- }
-
- virtual int CanSetCookie(const GURL& url,
- const GURL& first_party_for_cookies,
- const std::string& cookie_line,
- net::CompletionCallback* callback) {
- AutomationResourceMessageFilter::SetCookiesForUrl(tab_handle_, url,
- cookie_line,
- callback);
- return net::ERR_IO_PENDING;
- }
-
- private:
- scoped_refptr<AutomationResourceMessageFilter> automation_client_;
- int tab_handle_;
- scoped_refptr<net::CookieStore> cookie_store_;
-
- DISALLOW_COPY_AND_ASSIGN(AutomationCookiePolicy);
-};
-
-class Factory : public ChromeURLRequestContextFactory {
- public:
- Factory(ChromeURLRequestContextGetter* original_context_getter,
- Profile* profile,
- AutomationResourceMessageFilter* automation_client,
- int tab_handle)
- : ChromeURLRequestContextFactory(profile),
- original_context_getter_(original_context_getter),
- automation_client_(automation_client),
- tab_handle_(tab_handle) {
- }
-
- virtual ChromeURLRequestContext* Create() {
- ChromeURLRequestContext* original_context =
- original_context_getter_->GetIOContext();
-
- // Create an automation cookie store.
- scoped_refptr<net::CookieStore> automation_cookie_store =
- new AutomationCookieStore(original_context->cookie_store(),
- automation_client_,
- tab_handle_);
-
- // Create an automation cookie policy.
- AutomationCookiePolicy* automation_cookie_policy =
- new AutomationCookiePolicy(automation_client_,
- tab_handle_,
- automation_cookie_store);
-
- return new AutomationURLRequestContext(original_context,
- automation_cookie_store,
- automation_cookie_policy);
- }
-
- private:
- scoped_refptr<ChromeURLRequestContextGetter> original_context_getter_;
- scoped_refptr<AutomationResourceMessageFilter> automation_client_;
- int tab_handle_;
-};
-
-ChromeURLRequestContextGetter* CreateAutomationURLRequestContextForTab(
- int tab_handle,
- Profile* profile,
- AutomationResourceMessageFilter* automation_client) {
- ChromeURLRequestContextGetter* original_context =
- static_cast<ChromeURLRequestContextGetter*>(
- 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
deleted file mode 100644
index a3ff9f0..0000000
--- a/chrome/browser/automation/automation_profile_impl.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) 2009 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_BROWSER_AUTOMATION_AUTOMATION_PROFILE_IMPL_H_
-#define CHROME_BROWSER_AUTOMATION_AUTOMATION_PROFILE_IMPL_H_
-#pragma once
-
-#include "ipc/ipc_message.h"
-
-class Profile;
-class ChromeURLRequestContextGetter;
-class AutomationResourceMessageFilter;
-
-namespace AutomationRequestContext {
-
-// Returns the URL request context to be used by HTTP requests handled over
-// the automation channel.
-ChromeURLRequestContextGetter* CreateAutomationURLRequestContextForTab(
- int tab_handle,
- Profile* profile,
- AutomationResourceMessageFilter* automation_client);
-
-}
-
-#endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROFILE_IMPL_H_
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index bfe879f..12371bc6 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -1251,12 +1251,7 @@ void AutomationProvider::GetCookies(const GURL& url, int handle,
NavigationController* tab = tab_tracker_->GetResource(handle);
// Since we are running on the UI thread don't call GetURLRequestContext().
- scoped_refptr<URLRequestContextGetter> request_context =
- tab->tab_contents()->request_context();
- if (!request_context.get())
- request_context = tab->profile()->GetRequestContext();
-
- *value = GetCookiesForURL(url, request_context.get());
+ *value = GetCookiesForURL(url, tab->profile()->GetRequestContext());
*value_size = static_cast<int>(value->size());
}
}
@@ -1270,12 +1265,7 @@ void AutomationProvider::SetCookie(const GURL& url,
if (url.is_valid() && tab_tracker_->ContainsHandle(handle)) {
NavigationController* tab = tab_tracker_->GetResource(handle);
- scoped_refptr<URLRequestContextGetter> request_context =
- tab->tab_contents()->request_context();
- if (!request_context.get())
- request_context = tab->profile()->GetRequestContext();
-
- if (SetCookieForURL(url, value, request_context.get()))
+ if (SetCookieForURL(url, value, tab->profile()->GetRequestContext()))
*response_value = 1;
}
}
diff --git a/chrome/browser/automation/automation_resource_message_filter.cc b/chrome/browser/automation/automation_resource_message_filter.cc
index b570152..c9237c8 100644
--- a/chrome/browser/automation/automation_resource_message_filter.cc
+++ b/chrome/browser/automation/automation_resource_message_filter.cc
@@ -18,7 +18,6 @@
#include "chrome/browser/chrome_thread.h"
#include "chrome/test/automation/automation_messages.h"
#include "googleurl/src/gurl.h"
-#include "net/base/cookie_store.h"
#include "net/base/net_errors.h"
#include "net/url_request/url_request_filter.h"
@@ -33,6 +32,57 @@ base::LazyInstance<AutomationResourceMessageFilter::CompletionCallbackMap>
int AutomationResourceMessageFilter::unique_request_id_ = 1;
int AutomationResourceMessageFilter::next_completion_callback_id_ = 0;
+// CookieStore specialization to enable fetching and setting cookies over the
+// automation channel. This cookie store is transient i.e. it maintains cookies
+// for the duration of the current request to set or get cookies from the
+// renderer.
+class AutomationCookieStore : public net::CookieStore {
+ public:
+ AutomationCookieStore(AutomationResourceMessageFilter* automation_client,
+ int tab_handle)
+ : automation_client_(automation_client),
+ tab_handle_(tab_handle) {
+ }
+
+ virtual ~AutomationCookieStore() {
+ DLOG(INFO) << "In " << __FUNCTION__;
+ }
+
+ // CookieStore implementation.
+ virtual bool SetCookieWithOptions(const GURL& url,
+ const std::string& cookie_line,
+ const net::CookieOptions& options) {
+ // The cookie_string_ is available only once, i.e. once it is read by
+ // it is invalidated.
+ cookie_string_ = cookie_line;
+ return true;
+ }
+
+ virtual std::string GetCookiesWithOptions(const GURL& url,
+ const net::CookieOptions& options) {
+ return cookie_string_;
+ }
+
+ virtual void DeleteCookie(const GURL& url,
+ const std::string& cookie_name) {
+ NOTREACHED() << "Should not get called for an automation profile";
+ }
+
+ virtual net::CookieMonster* GetCookieMonster() {
+ NOTREACHED() << "Should not get called for an automation profile";
+ return NULL;
+ }
+
+ protected:
+ scoped_refptr<AutomationResourceMessageFilter> automation_client_;
+ int tab_handle_;
+ std::string cookie_string_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AutomationCookieStore);
+};
+
+
AutomationResourceMessageFilter::AutomationResourceMessageFilter()
: channel_(NULL) {
// Ensure that an instance of the callback map is created.
@@ -209,16 +259,22 @@ void AutomationResourceMessageFilter::RegisterRenderViewInIOThread(
int renderer_pid, int renderer_id,
int tab_handle, AutomationResourceMessageFilter* filter,
bool pending_view) {
+ RendererId renderer_key(renderer_pid, renderer_id);
+
+ scoped_refptr<net::CookieStore> cookie_store =
+ new AutomationCookieStore(filter, tab_handle);
+
RenderViewMap::iterator automation_details_iter(
- filtered_render_views_.Get().find(RendererId(renderer_pid,
- renderer_id)));
+ filtered_render_views_.Get().find(renderer_key));
if (automation_details_iter != filtered_render_views_.Get().end()) {
DCHECK(automation_details_iter->second.ref_count > 0);
automation_details_iter->second.ref_count++;
} else {
- filtered_render_views_.Get()[RendererId(renderer_pid, renderer_id)] =
+ filtered_render_views_.Get()[renderer_key] =
AutomationDetails(tab_handle, filter, pending_view);
}
+
+ filtered_render_views_.Get()[renderer_key].set_cookie_store(cookie_store);
}
// static
@@ -246,9 +302,10 @@ bool AutomationResourceMessageFilter::ResumePendingRenderViewInIOThread(
AutomationResourceMessageFilter* filter) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
+ RendererId renderer_key(renderer_pid, renderer_id);
+
RenderViewMap::iterator automation_details_iter(
- filtered_render_views_.Get().find(RendererId(renderer_pid,
- renderer_id)));
+ filtered_render_views_.Get().find(renderer_key));
if (automation_details_iter == filtered_render_views_.Get().end()) {
NOTREACHED() << "Failed to find pending view for renderer pid:"
@@ -260,13 +317,18 @@ bool AutomationResourceMessageFilter::ResumePendingRenderViewInIOThread(
DCHECK(automation_details_iter->second.is_pending_render_view);
+ scoped_refptr<net::CookieStore> cookie_store =
+ new AutomationCookieStore(filter, tab_handle);
+
AutomationResourceMessageFilter* old_filter =
automation_details_iter->second.filter;
DCHECK(old_filter != NULL);
- filtered_render_views_.Get()[RendererId(renderer_pid, renderer_id)] =
+ filtered_render_views_.Get()[renderer_key] =
AutomationDetails(tab_handle, filter, false);
+ filtered_render_views_.Get()[renderer_key].set_cookie_store(cookie_store);
+
ResumeJobsForPendingView(tab_handle, old_filter, filter);
return true;
}
@@ -332,42 +394,42 @@ void AutomationResourceMessageFilter::OnRecordHistograms(
}
}
-void AutomationResourceMessageFilter::GetCookiesForUrl(
- int tab_handle, const GURL& url, net::CompletionCallback* callback,
- net::CookieStore* cookie_store) {
- DCHECK(callback != NULL);
- DCHECK(cookie_store != NULL);
-
+bool AutomationResourceMessageFilter::GetCookiesForUrl(
+ const GURL& url, net::CompletionCallback* callback) {
GetCookiesCompletion* get_cookies_callback =
static_cast<GetCookiesCompletion*>(callback);
+ RendererId renderer_key(get_cookies_callback->render_process_id(),
+ get_cookies_callback->render_view_id());
+
RenderViewMap::iterator automation_details_iter(
- filtered_render_views_.Get().find(RendererId(
- get_cookies_callback->render_process_id(),
- get_cookies_callback->render_view_id())));
+ filtered_render_views_.Get().find(renderer_key));
+
if (automation_details_iter == filtered_render_views_.Get().end()) {
- OnGetCookiesHostResponseInternal(tab_handle, false, url, "", callback,
- cookie_store);
- return;
+ return false;
}
DCHECK(automation_details_iter->second.filter != NULL);
+ DCHECK(automation_details_iter->second.cookie_store_.get() != NULL);
int completion_callback_id = GetNextCompletionCallbackId();
DCHECK(!ContainsKey(completion_callback_map_.Get(), completion_callback_id));
CookieCompletionInfo cookie_info;
cookie_info.completion_callback = callback;
- cookie_info.cookie_store = cookie_store;
+ cookie_info.cookie_store = automation_details_iter->second.cookie_store_;
completion_callback_map_.Get()[completion_callback_id] = cookie_info;
+ DCHECK(automation_details_iter->second.filter != NULL);
+
if (automation_details_iter->second.filter) {
automation_details_iter->second.filter->Send(
new AutomationMsg_GetCookiesFromHost(
0, automation_details_iter->second.tab_handle, url,
completion_callback_id));
}
+ return true;
}
void AutomationResourceMessageFilter::OnGetCookiesHostResponse(
@@ -377,6 +439,7 @@ void AutomationResourceMessageFilter::OnGetCookiesHostResponse(
completion_callback_map_.Get().find(cookie_id);
if (index != completion_callback_map_.Get().end()) {
net::CompletionCallback* callback = index->second.completion_callback;
+
scoped_refptr<net::CookieStore> cookie_store = index->second.cookie_store;
DCHECK(callback != NULL);
@@ -398,6 +461,11 @@ void AutomationResourceMessageFilter::OnGetCookiesHostResponseInternal(
DCHECK(callback);
DCHECK(cookie_store);
+ GetCookiesCompletion* get_cookies_callback =
+ static_cast<GetCookiesCompletion*>(callback);
+
+ get_cookies_callback->set_cookie_store(cookie_store);
+
// Set the cookie in the cookie store so that the callback can read it.
cookie_store->SetCookieWithOptions(url, cookies, net::CookieOptions());
@@ -409,8 +477,8 @@ void AutomationResourceMessageFilter::OnGetCookiesHostResponseInternal(
cookie_store->SetCookieWithOptions(url, "", net::CookieOptions());
}
-void AutomationResourceMessageFilter::SetCookiesForUrl(
- int tab_handle, const GURL&url, const std::string& cookie_line,
+bool AutomationResourceMessageFilter::SetCookiesForUrl(
+ const GURL& url, const std::string& cookie_line,
net::CompletionCallback* callback) {
SetCookieCompletion* set_cookies_callback =
static_cast<SetCookieCompletion*>(callback);
@@ -420,14 +488,19 @@ void AutomationResourceMessageFilter::SetCookiesForUrl(
set_cookies_callback->render_process_id(),
set_cookies_callback->render_view_id())));
- if (automation_details_iter != filtered_render_views_.Get().end()) {
- DCHECK(automation_details_iter->second.filter != NULL);
+ if (automation_details_iter == filtered_render_views_.Get().end()) {
+ return false;
+ }
- if (automation_details_iter->second.filter) {
- automation_details_iter->second.filter->Send(
- new AutomationMsg_SetCookieAsync(0, tab_handle, url, cookie_line));
- }
+ DCHECK(automation_details_iter->second.filter != NULL);
+
+ if (automation_details_iter->second.filter) {
+ automation_details_iter->second.filter->Send(
+ new AutomationMsg_SetCookieAsync(
+ 0, automation_details_iter->second.tab_handle, url, cookie_line));
}
+
+ return true;
}
// static
diff --git a/chrome/browser/automation/automation_resource_message_filter.h b/chrome/browser/automation/automation_resource_message_filter.h
index 5ed2a81..c245f280 100644
--- a/chrome/browser/automation/automation_resource_message_filter.h
+++ b/chrome/browser/automation/automation_resource_message_filter.h
@@ -14,6 +14,7 @@
#include "base/platform_thread.h"
#include "ipc/ipc_channel_proxy.h"
#include "net/base/completion_callback.h"
+#include "net/base/cookie_store.h"
class URLRequestAutomationJob;
class GURL;
@@ -41,12 +42,23 @@ class AutomationResourceMessageFilter
is_pending_render_view(pending_view) {
}
+ void set_cookie_store(net::CookieStore* cookie_store) {
+ cookie_store_ = cookie_store;
+ }
+
+ net::CookieStore* cookie_store() {
+ return cookie_store_.get();
+ }
+
int tab_handle;
int ref_count;
scoped_refptr<AutomationResourceMessageFilter> filter;
// Indicates whether network requests issued by this render view need to
// be executed later.
bool is_pending_render_view;
+
+ // The cookie store associated with this render view.
+ scoped_refptr<net::CookieStore> cookie_store_;
};
// Create the filter.
@@ -101,9 +113,13 @@ class AutomationResourceMessageFilter
// Retrieves cookies for the url passed in from the external host. The
// callback passed in is notified on success or failure asynchronously.
- static void GetCookiesForUrl(int tab_handle, const GURL& url,
- net::CompletionCallback* callback,
- net::CookieStore* cookie_store);
+ // Returns true on success.
+ static bool GetCookiesForUrl(const GURL& url,
+ net::CompletionCallback* callback);
+
+ // Sets cookies on the URL in the external host. Returns true on success.
+ static bool SetCookiesForUrl(const GURL& url, const std::string& cookie_line,
+ net::CompletionCallback* callback);
// This function gets invoked when we receive a response from the external
// host for the cookie request sent in GetCookiesForUrl above. It sets the
@@ -113,10 +129,6 @@ class AutomationResourceMessageFilter
void OnGetCookiesHostResponse(int tab_handle, bool success, const GURL& url,
const std::string& cookies, int cookie_id);
- // Set cookies in the external host.
- static void SetCookiesForUrl(int tab_handle, const GURL&url,
- const std::string& cookie_line, net::CompletionCallback* callback);
-
protected:
// Retrieves the automation request id for the passed in chrome request
// id and returns it in the automation_request_id parameter.
diff --git a/chrome/browser/background_contents_service.cc b/chrome/browser/background_contents_service.cc
index 654a0a1..3c0e003 100644
--- a/chrome/browser/background_contents_service.cc
+++ b/chrome/browser/background_contents_service.cc
@@ -196,7 +196,7 @@ void BackgroundContentsService::CreateBackgroundContents(
RenderViewHost* render_view_host = contents->render_view_host();
// TODO(atwilson): Create RenderViews asynchronously to avoid increasing
// startup latency (http://crbug.com/47236).
- render_view_host->CreateRenderView(profile->GetRequestContext(), frame_name);
+ render_view_host->CreateRenderView(frame_name);
render_view_host->NavigateToURL(url);
}
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index e52f41b..321a0f0 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -202,8 +202,7 @@ void ExtensionHost::CreateRenderViewSoon(RenderWidgetHostView* host_view) {
}
void ExtensionHost::CreateRenderViewNow() {
- render_view_host_->CreateRenderView(profile_->GetRequestContext(),
- string16());
+ render_view_host_->CreateRenderView(string16());
NavigateToURL(url_);
DCHECK(IsRenderViewLive());
}
diff --git a/chrome/browser/external_tab_container_win.cc b/chrome/browser/external_tab_container_win.cc
index 1093c45..4f65e6b 100644
--- a/chrome/browser/external_tab_container_win.cc
+++ b/chrome/browser/external_tab_container_win.cc
@@ -220,10 +220,6 @@ bool ExternalTabContainer::Reinitialize(
void ExternalTabContainer::SetTabHandle(int handle) {
tab_handle_ = handle;
- if (automation_resource_message_filter_.get() &&
- load_requests_via_automation_) {
- InitializeAutomationRequestContext(tab_handle_);
- }
}
void ExternalTabContainer::ProcessUnhandledAccelerator(const MSG& msg) {
@@ -884,17 +880,6 @@ bool ExternalTabContainer::OnGoToEntryOffset(int offset) {
return true;
}
-void ExternalTabContainer::InitializeAutomationRequestContext(
- int tab_handle) {
- 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());
-}
-
void ExternalTabContainer::LoadAccelerators() {
HACCEL accelerator_table = AtlLoadAccelerators(IDR_CHROMEFRAME);
DCHECK(accelerator_table);
@@ -933,8 +918,6 @@ void ExternalTabContainer::LoadAccelerators() {
void ExternalTabContainer::OnReinitialize() {
if (load_requests_via_automation_) {
- InitializeAutomationRequestContext(tab_handle_);
-
RenderViewHost* rvh = tab_contents_->render_view_host();
if (rvh) {
AutomationResourceMessageFilter::ResumePendingRenderView(
diff --git a/chrome/browser/external_tab_container_win.h b/chrome/browser/external_tab_container_win.h
index 0db6625..a957b6a 100644
--- a/chrome/browser/external_tab_container_win.h
+++ b/chrome/browser/external_tab_container_win.h
@@ -10,7 +10,6 @@
#include <map>
#include "base/lazy_instance.h"
#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"
@@ -220,9 +219,6 @@ 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>;
diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc
index e962f5a..621fa7e 100644
--- a/chrome/browser/notifications/balloon_host.cc
+++ b/chrome/browser/notifications/balloon_host.cc
@@ -154,7 +154,7 @@ void BalloonHost::Init() {
DCHECK(render_widget_host_view());
rvh->set_view(render_widget_host_view());
- rvh->CreateRenderView(GetProfile()->GetRequestContext(), string16());
+ rvh->CreateRenderView(string16());
rvh->NavigateToURL(balloon_->notification().content_url());
initialized_ = true;
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index bcd8c2b..796aa710 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -247,8 +247,7 @@ BrowserRenderProcessHost::~BrowserRenderProcessHost() {
NotificationService::NoDetails());
}
-bool BrowserRenderProcessHost::Init(bool is_extensions_process,
- URLRequestContextGetter* request_context) {
+bool BrowserRenderProcessHost::Init(bool is_extensions_process) {
// 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())
@@ -271,8 +270,7 @@ bool BrowserRenderProcessHost::Init(bool is_extensions_process,
PluginService::GetInstance(),
g_browser_process->print_job_manager(),
profile(),
- widget_helper_,
- request_context);
+ widget_helper_);
std::wstring renderer_prefix;
#if defined(OS_POSIX)
diff --git a/chrome/browser/renderer_host/browser_render_process_host.h b/chrome/browser/renderer_host/browser_render_process_host.h
index 23de0315..c72f4d7 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.h
+++ b/chrome/browser/renderer_host/browser_render_process_host.h
@@ -60,8 +60,7 @@ class BrowserRenderProcessHost : public RenderProcessHost,
~BrowserRenderProcessHost();
// RenderProcessHost implementation (public portion).
- virtual bool Init(bool is_extensions_process,
- URLRequestContextGetter* request_context);
+ virtual bool Init(bool is_extensions_process);
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 21fa34d..9c8eac3 100644
--- a/chrome/browser/renderer_host/mock_render_process_host.cc
+++ b/chrome/browser/renderer_host/mock_render_process_host.cc
@@ -20,8 +20,7 @@ MockRenderProcessHost::~MockRenderProcessHost() {
delete transport_dib_;
}
-bool MockRenderProcessHost::Init(bool is_extensions_process,
- URLRequestContextGetter* request_context) {
+bool MockRenderProcessHost::Init(bool is_extensions_process) {
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 0dc5e02..608821d 100644
--- a/chrome/browser/renderer_host/mock_render_process_host.h
+++ b/chrome/browser/renderer_host/mock_render_process_host.h
@@ -31,8 +31,7 @@ class MockRenderProcessHost : public RenderProcessHost {
int bad_msg_count() const { return bad_msg_count_; }
// RenderProcessHost implementation (public portion).
- virtual bool Init(bool is_extensions_process,
- URLRequestContextGetter* request_context);
+ virtual bool Init(bool is_extensions_process);
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 82c3572..45b643f 100644
--- a/chrome/browser/renderer_host/render_process_host.h
+++ b/chrome/browser/renderer_host/render_process_host.h
@@ -149,8 +149,7 @@ 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,
- URLRequestContextGetter* request_context) = 0;
+ virtual bool Init(bool is_extensions_process) = 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 c3a7713..b8a03f4 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -146,15 +146,14 @@ RenderViewHost::~RenderViewHost() {
NotificationService::NoDetails());
}
-bool RenderViewHost::CreateRenderView(
- URLRequestContextGetter* request_context, const string16& frame_name) {
+bool RenderViewHost::CreateRenderView(const string16& frame_name) {
DCHECK(!IsRenderViewLive()) << "Creating view twice";
// The process may (if we're sharing a process with another host that already
// initialized it) or may not (we have our own process or the old process
// crashed) have been initialized. Calling Init multiple times will be
// ignored, so this is safe.
- if (!process()->Init(is_extension_process_, request_context))
+ if (!process()->Init(is_extension_process_))
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 ff5ff94..0fda85e 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -109,8 +109,7 @@ class RenderViewHost : public RenderWidgetHost {
// Set up the RenderView child process. Virtual because it is overridden by
// TestRenderViewHost. If the |frame_name| parameter is non-empty, it is used
// as the name of the new top-level frame.
- virtual bool CreateRenderView(URLRequestContextGetter* request_context,
- const string16& frame_name);
+ virtual bool CreateRenderView(const string16& frame_name);
// 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 3d60d80..e28146b 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -19,6 +19,7 @@
#include "base/utf_string_conversions.h"
#include "base/worker_pool.h"
#include "chrome/browser/appcache/appcache_dispatcher_host.h"
+#include "chrome/browser/automation/automation_resource_message_filter.h"
#include "chrome/browser/browser_about_handler.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/child_process_security_policy.h"
@@ -201,8 +202,7 @@ ResourceMessageFilter::ResourceMessageFilter(
PluginService* plugin_service,
printing::PrintJobManager* print_job_manager,
Profile* profile,
- RenderWidgetHelper* render_widget_helper,
- URLRequestContextGetter* request_context)
+ RenderWidgetHelper* render_widget_helper)
: Receiver(RENDER_PROCESS, child_id),
channel_(NULL),
resource_dispatcher_host_(resource_dispatcher_host),
@@ -210,7 +210,6 @@ ResourceMessageFilter::ResourceMessageFilter(
print_job_manager_(print_job_manager),
profile_(profile),
ALLOW_THIS_IN_INITIALIZER_LIST(resolve_proxy_msg_helper_(this, NULL)),
- request_context_(request_context),
media_request_context_(profile->GetRequestContextForMedia()),
extensions_request_context_(profile->GetRequestContextForExtensions()),
extensions_message_service_(profile->GetExtensionMessageService()),
@@ -234,6 +233,8 @@ ResourceMessageFilter::ResourceMessageFilter(
ALLOW_THIS_IN_INITIALIZER_LIST(geolocation_dispatcher_host_(
GeolocationDispatcherHost::New(
this->id(), profile->GetGeolocationPermissionContext()))) {
+ request_context_ = profile_->GetRequestContext();
+
DCHECK(request_context_);
DCHECK(media_request_context_);
DCHECK(audio_renderer_host_.get());
@@ -560,16 +561,22 @@ void ResourceMessageFilter::OnSetCookie(const IPC::Message& message,
ChromeURLRequestContext* context = GetRequestContextForURL(url);
SetCookieCompletion* callback =
- new SetCookieCompletion(id(), message.routing_id(), url, cookie, context);
-
- int policy = net::OK;
- if (context->cookie_policy()) {
- policy = context->cookie_policy()->CanSetCookie(
- url, first_party_for_cookies, cookie, callback);
- if (policy == net::ERR_IO_PENDING)
- return;
+ new SetCookieCompletion(id(), message.routing_id(), url, cookie,
+ context);
+
+ // If this render view is associated with an automation channel, aka
+ // ChromeFrame then we need to set cookies in the external host.
+ if (!AutomationResourceMessageFilter::SetCookiesForUrl(url, cookie,
+ callback)) {
+ int policy = net::OK;
+ if (context->cookie_policy()) {
+ policy = context->cookie_policy()->CanSetCookie(
+ url, first_party_for_cookies, cookie, callback);
+ if (policy == net::ERR_IO_PENDING)
+ return;
+ }
+ callback->Run(policy);
}
- callback->Run(policy);
}
void ResourceMessageFilter::OnGetCookies(const GURL& url,
@@ -581,16 +588,20 @@ void ResourceMessageFilter::OnGetCookies(const GURL& url,
new GetCookiesCompletion(id(), reply_msg->routing_id(), url, reply_msg,
this, context, false);
- int policy = net::OK;
- if (context->cookie_policy()) {
- policy = context->cookie_policy()->CanGetCookies(
- url, first_party_for_cookies, callback);
- if (policy == net::ERR_IO_PENDING) {
- Send(new ViewMsg_SignalCookiePromptEvent());
- return;
+ // If this render view is associated with an automation channel, aka
+ // ChromeFrame then we need to retrieve cookies from the external host.
+ if (!AutomationResourceMessageFilter::GetCookiesForUrl(url, callback)) {
+ int policy = net::OK;
+ if (context->cookie_policy()) {
+ policy = context->cookie_policy()->CanGetCookies(
+ url, first_party_for_cookies, callback);
+ if (policy == net::ERR_IO_PENDING) {
+ Send(new ViewMsg_SignalCookiePromptEvent());
+ return;
+ }
}
+ callback->Run(policy);
}
- callback->Run(policy);
}
void ResourceMessageFilter::OnGetRawCookies(
@@ -1627,6 +1638,7 @@ GetCookiesCompletion::GetCookiesCompletion(int render_process_id,
render_process_id_(render_process_id),
render_view_id_(render_view_id),
raw_cookies_(raw_cookies) {
+ set_cookie_store(context_->cookie_store());
}
void GetCookiesCompletion::RunWithParams(const Tuple1<int>& params) {
@@ -1634,7 +1646,7 @@ void GetCookiesCompletion::RunWithParams(const Tuple1<int>& params) {
int result = params.a;
std::string cookies;
if (result == net::OK)
- cookies = context_->cookie_store()->GetCookies(url_);
+ cookies = cookie_store()->GetCookies(url_);
ViewHostMsg_GetCookies::WriteReplyParams(reply_msg_, cookies);
filter_->Send(reply_msg_);
delete this;
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index c112b77..2a4e6ce 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -27,6 +27,7 @@
#include "chrome/common/window_container_type.h"
#include "gfx/native_widget_types.h"
#include "ipc/ipc_channel_proxy.h"
+#include "net/base/cookie_store.h"
#include "third_party/WebKit/WebKit/chromium/public/WebCache.h"
#include "third_party/WebKit/WebKit/chromium/public/WebPopupType.h"
@@ -87,8 +88,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
PluginService* plugin_service,
printing::PrintJobManager* print_job_manager,
Profile* profile,
- RenderWidgetHelper* render_widget_helper,
- URLRequestContextGetter* request_context);
+ RenderWidgetHelper* render_widget_helper);
// IPC::ChannelProxy::MessageFilter methods:
virtual void OnFilterAdded(IPC::Channel* channel);
@@ -494,6 +494,14 @@ class GetCookiesCompletion : public net::CompletionCallback {
return render_view_id_;
}
+ void set_cookie_store(net::CookieStore* cookie_store) {
+ cookie_store_ = cookie_store;
+ }
+
+ net::CookieStore* cookie_store() {
+ return cookie_store_.get();
+ }
+
private:
GURL url_;
IPC::Message* reply_msg_;
@@ -502,6 +510,7 @@ class GetCookiesCompletion : public net::CompletionCallback {
int render_process_id_;
int render_view_id_;
bool raw_cookies_;
+ scoped_refptr<net::CookieStore> cookie_store_;
};
#endif // CHROME_BROWSER_RENDERER_HOST_RESOURCE_MESSAGE_FILTER_H_
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 ac4efda..f5883ed 100644
--- a/chrome/browser/renderer_host/test/test_render_view_host.cc
+++ b/chrome/browser/renderer_host/test/test_render_view_host.cc
@@ -50,8 +50,7 @@ TestRenderViewHost::~TestRenderViewHost() {
delete view();
}
-bool TestRenderViewHost::CreateRenderView(
- URLRequestContextGetter* request_context, const string16& frame_name) {
+bool TestRenderViewHost::CreateRenderView(const string16& frame_name) {
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 82ff1c6..b4971bd 100644
--- a/chrome/browser/renderer_host/test/test_render_view_host.h
+++ b/chrome/browser/renderer_host/test/test_render_view_host.h
@@ -176,8 +176,7 @@ class TestRenderViewHost : public RenderViewHost {
// RenderViewHost overrides --------------------------------------------------
- virtual bool CreateRenderView(URLRequestContextGetter* request_context,
- const string16& frame_name);
+ virtual bool CreateRenderView(const string16& frame_name);
virtual bool IsRenderViewLive() const;
private:
diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc
index 10c8d7c..3d09052 100644
--- a/chrome/browser/tab_contents/interstitial_page.cc
+++ b/chrome/browser/tab_contents/interstitial_page.cc
@@ -404,12 +404,7 @@ TabContentsView* InterstitialPage::CreateTabContentsView() {
render_view_host_->set_view(view);
render_view_host_->AllowBindings(BindingsPolicy::DOM_AUTOMATION);
- scoped_refptr<URLRequestContextGetter> request_context =
- tab()->request_context();
- if (!request_context.get())
- request_context = tab()->profile()->GetRequestContext();
-
- render_view_host_->CreateRenderView(request_context.get(), string16());
+ render_view_host_->CreateRenderView(string16());
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 83bd9c4..f551248 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -1359,10 +1359,6 @@ void TabContents::OnCloseStarted() {
tab_close_start_time_ = base::TimeTicks::Now();
}
-void TabContents::set_request_context(URLRequestContextGetter* context) {
- request_context_ = context;
-}
-
bool TabContents::ShouldAcceptDragAndDrop() const {
#if defined(OS_CHROMEOS)
// ChromeOS panels (pop-ups) do not take drag-n-drop.
@@ -2974,11 +2970,7 @@ bool TabContents::CreateRenderViewForRenderManager(
RenderViewHost* render_view_host) {
RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(render_view_host);
- scoped_refptr<URLRequestContextGetter> request_context = request_context_;
- if (!request_context.get())
- request_context = profile()->GetRequestContext();
-
- if (!render_view_host->CreateRenderView(request_context, string16()))
+ if (!render_view_host->CreateRenderView(string16()))
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 255a152..7e37c1a 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -652,12 +652,6 @@ 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);
- URLRequestContextGetter* request_context() const {
- return request_context_.get();
- }
-
LanguageState& language_state() {
return language_state_;
}
@@ -1265,11 +1259,6 @@ 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_;
-
// Information about the language the page is in and has been translated to.
LanguageState language_state_;
diff --git a/chrome/browser/tab_contents/test_tab_contents.cc b/chrome/browser/tab_contents/test_tab_contents.cc
index 9e1cad0..86c62fd 100644
--- a/chrome/browser/tab_contents/test_tab_contents.cc
+++ b/chrome/browser/tab_contents/test_tab_contents.cc
@@ -50,8 +50,7 @@ TestRenderViewHost* TestTabContents::pending_rvh() {
bool TestTabContents::CreateRenderViewForRenderManager(
RenderViewHost* render_view_host) {
// This will go to a TestRenderViewHost.
- render_view_host->CreateRenderView(profile()->GetRequestContext(),
- string16());
+ render_view_host->CreateRenderView(string16());
return true;
}
diff --git a/chrome/browser/visitedlink_unittest.cc b/chrome/browser/visitedlink_unittest.cc
index 64d30bb..c69c745 100644
--- a/chrome/browser/visitedlink_unittest.cc
+++ b/chrome/browser/visitedlink_unittest.cc
@@ -676,7 +676,7 @@ TEST_F(VisitedLinkEventsTest, Coalescense) {
TEST_F(VisitedLinkRelayTest, Basics) {
VisitedLinkMaster* master = profile_->GetVisitedLinkMaster();
- rvh()->CreateRenderView(profile_->GetRequestContext(), string16());
+ rvh()->CreateRenderView(string16());
// Add a few URLs.
master->AddURL(GURL("http://acidtests.org/"));
@@ -700,7 +700,7 @@ TEST_F(VisitedLinkRelayTest, Basics) {
TEST_F(VisitedLinkRelayTest, TabVisibility) {
VisitedLinkMaster* master = profile_->GetVisitedLinkMaster();
- rvh()->CreateRenderView(profile_->GetRequestContext(), string16());
+ rvh()->CreateRenderView(string16());
// Simulate tab becoming inactive.
rvh()->WasHidden();
@@ -763,7 +763,7 @@ TEST_F(VisitedLinkRelayTest, WebViewReadiness) {
EXPECT_EQ(0, profile()->add_event_count());
EXPECT_EQ(0, profile()->reset_event_count());
- rvh()->CreateRenderView(profile_->GetRequestContext(), string16());
+ rvh()->CreateRenderView(string16());
// We should now have just a reset event: adds are eaten up by a reset
// that followed.