summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--android_webview/browser/aw_browser_main_parts.cc4
-rw-r--r--android_webview/browser/aw_content_browser_client.cc43
-rw-r--r--android_webview/browser/aw_content_browser_client.h10
-rw-r--r--android_webview/browser/net/aw_url_request_context_getter.cc4
-rw-r--r--android_webview/lib/aw_browser_dependency_factory_impl.cc3
-rw-r--r--android_webview/native/aw_quota_manager_bridge_impl.cc10
-rw-r--r--android_webview/native/state_serializer_unittests.cc4
-rw-r--r--chrome/browser/autofill/risk/fingerprint_browsertest.cc2
-rw-r--r--chrome/browser/browser_process_impl.cc3
-rw-r--r--chrome/browser/chrome_content_browser_client.cc63
-rw-r--r--chrome/browser/chrome_content_browser_client.h16
-rw-r--r--chrome/browser/chromeos/login/login_browsertest.cc6
-rw-r--r--chrome/browser/devtools/devtools_sanity_browsertest.cc9
-rw-r--r--chrome/browser/download/download_query.cc7
-rw-r--r--chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc6
-rw-r--r--chrome/browser/media/media_stream_capture_indicator.cc7
-rw-r--r--chrome/browser/metrics/metrics_log.cc3
-rw-r--r--chrome/browser/search/local_ntp_source.cc4
-rw-r--r--chrome/browser/search/local_omnibox_popup_source.cc4
-rw-r--r--chrome/browser/sync/profile_sync_service_unittest.cc7
-rw-r--r--chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc1
-rw-r--r--chrome/browser/ui/browser_commands.cc4
-rw-r--r--chrome/common/chrome_content_client.cc12
-rw-r--r--chrome/common/chrome_content_client.h3
-rw-r--r--chrome/renderer/chrome_content_renderer_client.cc21
-rw-r--r--chrome/renderer/chrome_content_renderer_client.h30
-rw-r--r--chrome/renderer/net/net_error_helper.cc1
-rw-r--r--chrome/renderer/page_load_histograms.cc18
-rw-r--r--chrome/renderer/plugins/plugin_placeholder.cc7
-rw-r--r--chrome/test/base/chrome_render_view_test.cc3
-rw-r--r--chrome/test/base/chrome_test_suite.cc6
-rw-r--r--chrome/test/base/in_process_browser_test.cc2
-rw-r--r--chrome_frame/test/net/fake_external_tab.cc3
-rw-r--r--components/autofill/browser/android/personal_data_manager_android.cc10
-rw-r--r--components/autofill/browser/autocheckout_manager.cc9
-rw-r--r--components/autofill/browser/risk/fingerprint.cc17
-rw-r--r--components/autofill/browser/risk/fingerprint.h2
-rw-r--r--content/browser/child_process_security_policy_unittest.cc5
-rw-r--r--content/browser/devtools/devtools_manager_unittest.cc5
-rw-r--r--content/browser/download/drag_download_file_browsertest.cc4
-rw-r--r--content/browser/loader/resource_dispatcher_host_unittest.cc10
-rw-r--r--content/browser/loader/resource_loader_unittest.cc5
-rw-r--r--content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc11
-rw-r--r--content/browser/site_instance_impl_unittest.cc5
-rw-r--r--content/browser/webui/web_ui_data_source_unittest.cc8
-rw-r--r--content/browser/worker_host/test/worker_browsertest.cc2
-rw-r--r--content/public/browser/content_browser_client.h3
-rw-r--r--content/public/common/content_client.cc23
-rw-r--r--content/public/common/content_client.h17
-rw-r--r--content/public/test/render_view_fake_resources_test.cc2
-rw-r--r--content/public/test/render_view_test.cc6
-rw-r--r--content/public/test/test_content_client_initializer.cc4
-rw-r--r--content/renderer/browser_plugin/browser_plugin_browsertest.cc3
-rw-r--r--content/renderer/pepper/pepper_file_chooser_host_unittest.cc8
-rw-r--r--content/shell/android/shell_manager.cc3
-rw-r--r--content/shell/shell_application_mac.mm3
-rw-r--r--content/shell/shell_content_browser_client.cc9
-rw-r--r--content/shell/shell_content_browser_client.h3
-rw-r--r--content/shell/shell_content_renderer_client.cc11
-rw-r--r--content/shell/shell_content_renderer_client.h2
-rw-r--r--content/shell/shell_devtools_frontend.cc7
-rw-r--r--content/shell/shell_gtk.cc3
-rw-r--r--content/shell/shell_render_process_observer.cc5
-rw-r--r--content/shell/shell_web_contents_view_delegate_gtk.cc3
-rw-r--r--content/shell/shell_web_contents_view_delegate_mac.mm3
-rw-r--r--content/shell/shell_web_contents_view_delegate_win.cc3
-rw-r--r--content/shell/webkit_test_controller.cc5
-rw-r--r--content/test/content_browser_test.cc11
-rw-r--r--content/test/content_test_launcher.cc4
-rw-r--r--content/test/webrtc_audio_device_test.cc5
70 files changed, 272 insertions, 293 deletions
diff --git a/android_webview/browser/aw_browser_main_parts.cc b/android_webview/browser/aw_browser_main_parts.cc
index 05840fe..338ba4b 100644
--- a/android_webview/browser/aw_browser_main_parts.cc
+++ b/android_webview/browser/aw_browser_main_parts.cc
@@ -8,10 +8,10 @@
#include "android_webview/browser/aw_devtools_delegate.h"
#include "android_webview/browser/aw_result_codes.h"
#include "base/android/build_info.h"
+#include "base/android/locale_utils.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "content/public/browser/android/compositor.h"
-#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_client.h"
#include "content/public/common/result_codes.h"
@@ -51,7 +51,7 @@ int AwBrowserMainParts::PreCreateThreads() {
browser_context_->InitializeBeforeThreadCreation();
ui::ResourceBundle::InitSharedInstanceLocaleOnly(
- content::GetContentClient()->browser()->GetApplicationLocale(), NULL);
+ base::android::GetDefaultLocale(), NULL);
base::FilePath pak_path;
PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &pak_path);
diff --git a/android_webview/browser/aw_content_browser_client.cc b/android_webview/browser/aw_content_browser_client.cc
index 869d50b..a5ff403 100644
--- a/android_webview/browser/aw_content_browser_client.cc
+++ b/android_webview/browser/aw_content_browser_client.cc
@@ -26,8 +26,11 @@
#include "net/ssl/ssl_info.h"
#include "ui/base/resource/resource_bundle.h"
+namespace android_webview {
namespace {
+AwBrowserContext* g_browser_context;
+
class AwAccessTokenStore : public content::AccessTokenStore {
public:
AwAccessTokenStore() { }
@@ -51,12 +54,20 @@ class AwAccessTokenStore : public content::AccessTokenStore {
}
-namespace android_webview {
+std::string AwContentBrowserClient::GetAcceptLangsImpl() {
+ // Start with the currnet locale.
+ std::string langs = base::android::GetDefaultLocale();
+
+ // If we're not en-US, add in en-US which will be
+ // used with a lower q-value.
+ if (StringToLowerASCII(langs) != "en-us") {
+ langs += ",en-US";
+ }
+ return langs;
+}
-// static
-AwContentBrowserClient* AwContentBrowserClient::FromContentBrowserClient(
- content::ContentBrowserClient* client) {
- return static_cast<AwContentBrowserClient*>(client);
+AwBrowserContext* AwContentBrowserClient::GetAwBrowserContext() {
+ return g_browser_context;
}
AwContentBrowserClient::AwContentBrowserClient(
@@ -68,9 +79,11 @@ AwContentBrowserClient::AwContentBrowserClient(
}
browser_context_.reset(
new AwBrowserContext(user_data_dir, native_factory_));
+ g_browser_context = browser_context_.get();
}
AwContentBrowserClient::~AwContentBrowserClient() {
+ g_browser_context = NULL;
}
void AwContentBrowserClient::AddCertificate(net::URLRequest* request,
@@ -83,10 +96,6 @@ void AwContentBrowserClient::AddCertificate(net::URLRequest* request,
net::android::StoreCertificate(cert_type, cert_data, cert_size);
}
-AwBrowserContext* AwContentBrowserClient::GetAwBrowserContext() {
- return browser_context_.get();
-}
-
content::BrowserMainParts* AwContentBrowserClient::CreateBrowserMainParts(
const content::MainFunctionParams& parameters) {
return new AwBrowserMainParts(browser_context_.get());
@@ -151,15 +160,7 @@ std::string AwContentBrowserClient::GetApplicationLocale() {
std::string AwContentBrowserClient::GetAcceptLangs(
content::BrowserContext* context) {
- // Start with the currnet locale.
- std::string langs = GetApplicationLocale();
-
- // If we're not en-US, add in en-US which will be
- // used with a lower q-value.
- if (StringToLowerASCII(langs) != "en-us") {
- langs += ",en-US";
- }
- return langs;
+ return GetAcceptLangsImpl();
}
gfx::ImageSkia* AwContentBrowserClient::GetDefaultFavicon() {
@@ -340,12 +341,6 @@ void AwContentBrowserClient::UpdateInspectorSetting(
NOTIMPLEMENTED();
}
-void AwContentBrowserClient::ClearInspectorSettings(
- content::RenderViewHost* rvh) {
- // TODO(boliu): Implement persisting inspector settings.
- NOTIMPLEMENTED();
-}
-
void AwContentBrowserClient::ClearCache(content::RenderViewHost* rvh) {
RemoveHttpDiskCache(rvh->GetProcess()->GetBrowserContext(),
rvh->GetProcess()->GetID());
diff --git a/android_webview/browser/aw_content_browser_client.h b/android_webview/browser/aw_content_browser_client.h
index 874caa7..dfb1bcd 100644
--- a/android_webview/browser/aw_content_browser_client.h
+++ b/android_webview/browser/aw_content_browser_client.h
@@ -18,14 +18,15 @@ class JniDependencyFactory;
class AwContentBrowserClient : public content::ContentBrowserClient {
public:
- static AwContentBrowserClient* FromContentBrowserClient(
- content::ContentBrowserClient* client);
+ // This is what AwContentBrowserClient::GetAcceptLangs uses.
+ static std::string GetAcceptLangsImpl();
+
+ // Returns the one AwBrowserContext for this process.
+ static AwBrowserContext* GetAwBrowserContext();
AwContentBrowserClient(JniDependencyFactory* native_factory);
virtual ~AwContentBrowserClient();
- AwBrowserContext* GetAwBrowserContext();
-
// Overriden methods from ContentBrowserClient.
virtual void AddCertificate(net::URLRequest* request,
net::CertificateMimeType cert_type,
@@ -130,7 +131,6 @@ class AwContentBrowserClient : public content::ContentBrowserClient {
virtual void UpdateInspectorSetting(content::RenderViewHost* rvh,
const std::string& key,
const std::string& value) OVERRIDE;
- virtual void ClearInspectorSettings(content::RenderViewHost* rvh) OVERRIDE;
virtual void ClearCache(content::RenderViewHost* rvh) OVERRIDE;
virtual void ClearCookies(content::RenderViewHost* rvh) OVERRIDE;
virtual base::FilePath GetDefaultDownloadDirectory() OVERRIDE;
diff --git a/android_webview/browser/net/aw_url_request_context_getter.cc b/android_webview/browser/net/aw_url_request_context_getter.cc
index 882a967..d4481e8 100644
--- a/android_webview/browser/net/aw_url_request_context_getter.cc
+++ b/android_webview/browser/net/aw_url_request_context_getter.cc
@@ -7,6 +7,7 @@
#include <vector>
#include "android_webview/browser/aw_browser_context.h"
+#include "android_webview/browser/aw_content_browser_client.h"
#include "android_webview/browser/aw_request_interceptor.h"
#include "android_webview/browser/net/aw_network_delegate.h"
#include "android_webview/browser/net/aw_url_request_job_factory.h"
@@ -55,8 +56,7 @@ void AwURLRequestContextGetter::Init() {
builder.set_ftp_enabled(false); // Android WebView does not support ftp yet.
builder.set_proxy_config_service(proxy_config_service_.release());
builder.set_accept_language(net::HttpUtil::GenerateAcceptLanguageHeader(
- content::GetContentClient()->browser()->GetAcceptLangs(
- browser_context_)));
+ AwContentBrowserClient::GetAcceptLangsImpl()));
url_request_context_.reset(builder.Build());
diff --git a/android_webview/lib/aw_browser_dependency_factory_impl.cc b/android_webview/lib/aw_browser_dependency_factory_impl.cc
index 200df11..b054881 100644
--- a/android_webview/lib/aw_browser_dependency_factory_impl.cc
+++ b/android_webview/lib/aw_browser_dependency_factory_impl.cc
@@ -32,8 +32,7 @@ void AwBrowserDependencyFactoryImpl::InstallInstance() {
}
content::BrowserContext* AwBrowserDependencyFactoryImpl::GetBrowserContext() {
- return static_cast<AwContentBrowserClient*>(
- content::GetContentClient()->browser())->GetAwBrowserContext();
+ return AwContentBrowserClient::GetAwBrowserContext();
}
WebContents* AwBrowserDependencyFactoryImpl::CreateWebContents() {
diff --git a/android_webview/native/aw_quota_manager_bridge_impl.cc b/android_webview/native/aw_quota_manager_bridge_impl.cc
index 1de22bd..b6bac6c 100644
--- a/android_webview/native/aw_quota_manager_bridge_impl.cc
+++ b/android_webview/native/aw_quota_manager_bridge_impl.cc
@@ -146,14 +146,8 @@ void GetOriginsTask::DoneOnUIThread() {
// static
jint GetDefaultNativeAwQuotaManagerBridge(JNIEnv* env, jclass clazz) {
- content::ContentBrowserClient* browser_client =
- content::GetContentClient()->browser();
- DCHECK(browser_client);
-
- AwContentBrowserClient* aw_browser_client =
- AwContentBrowserClient::FromContentBrowserClient(browser_client);
- AwBrowserContext* browser_context = aw_browser_client->GetAwBrowserContext();
- DCHECK(browser_context);
+ AwBrowserContext* browser_context =
+ AwContentBrowserClient::GetAwBrowserContext();
AwQuotaManagerBridgeImpl* bridge = static_cast<AwQuotaManagerBridgeImpl*>(
browser_context->GetQuotaManagerBridge());
diff --git a/android_webview/native/state_serializer_unittests.cc b/android_webview/native/state_serializer_unittests.cc
index d47a390..53c4087 100644
--- a/android_webview/native/state_serializer_unittests.cc
+++ b/android_webview/native/state_serializer_unittests.cc
@@ -33,9 +33,9 @@ TEST(AndroidWebViewStateSerializerTest, TestHeaderSerialization) {
TEST(AndroidWebViewStateSerializerTest, TestNavigationEntrySerialization) {
// This is required for NavigationEntry::Create.
content::ContentClient content_client;
- content::ContentBrowserClient browser_client;
- content_client.set_browser_for_testing(&browser_client);
content::SetContentClient(&content_client);
+ content::ContentBrowserClient browser_client;
+ content::SetBrowserClientForTesting(&browser_client);
scoped_ptr<content::NavigationEntry> entry(
content::NavigationEntry::Create());
diff --git a/chrome/browser/autofill/risk/fingerprint_browsertest.cc b/chrome/browser/autofill/risk/fingerprint_browsertest.cc
index 168f169..5394ea7 100644
--- a/chrome/browser/autofill/risk/fingerprint_browsertest.cc
+++ b/chrome/browser/autofill/risk/fingerprint_browsertest.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/message_loop.h"
#include "base/port.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/autofill/browser/risk/proto/fingerprint.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -130,6 +131,7 @@ IN_PROC_BROWSER_TEST_F(AutofillRiskFingerprintTest, MAYBE_GetFingerprint) {
internal::GetFingerprintInternal(
kGaiaId, kWindowBounds, kContentBounds, screen_info, "25.0.0.123",
kCharset, kAcceptLanguages, base::Time::Now(), DIALOG_TYPE_AUTOCHECKOUT,
+ g_browser_process->GetApplicationLocale(),
base::Bind(&AutofillRiskFingerprintTest::GetFingerprintTestCallback,
base::Unretained(this)));
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index c86d034..fa976f5 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -612,8 +612,7 @@ const std::string& BrowserProcessImpl::GetApplicationLocale() {
void BrowserProcessImpl::SetApplicationLocale(const std::string& locale) {
locale_ = locale;
extension_l10n_util::SetProcessLocale(locale);
- static_cast<chrome::ChromeContentBrowserClient*>(
- content::GetContentClient()->browser())->SetApplicationLocale(locale);
+ chrome::ChromeContentBrowserClient::SetApplicationLocale(locale);
}
DownloadStatusUpdater* BrowserProcessImpl::download_status_updater() {
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index c7821c1..4f09d56 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/command_line.h"
+#include "base/lazy_instance.h"
#include "base/path_service.h"
#include "base/prefs/pref_service.h"
#include "base/strings/string_tokenizer.h"
@@ -180,6 +181,10 @@ using webkit_glue::WebPreferences;
namespace {
+// Cached version of the locale so we can return the locale on the I/O
+// thread.
+base::LazyInstance<std::string> g_io_thread_application_locale;
+
const char* kPredefinedAllowedSocketOrigins[] = {
"okddffdblfhhnmhodogpojmfkjmhinfp", // Test SSH Client
"pnhechapfaindjhompbnflcldabbghjo", // HTerm App (SSH Client)
@@ -461,6 +466,11 @@ GURL GetEffectiveURLForSignin(const GURL& url) {
return effective_url;
}
+void SetApplicationLocaleOnIOThread(const std::string& locale) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ g_io_thread_application_locale.Get() = locale;
+}
+
} // namespace
namespace chrome {
@@ -487,6 +497,25 @@ void ChromeContentBrowserClient::RegisterUserPrefs(
PrefRegistrySyncable::UNSYNCABLE_PREF);
}
+// static
+void ChromeContentBrowserClient::SetApplicationLocale(
+ const std::string& locale) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // This object is guaranteed to outlive all threads so we don't have to
+ // worry about the lack of refcounting and can just post as Unretained.
+ //
+ // The common case is that this function is called early in Chrome startup
+ // before any threads are created (it will also be called later if the user
+ // changes the pref). In this case, there will be no threads created and
+ // posting will fail. When there are no threads, we can just set the string
+ // without worrying about threadsafety.
+ if (!BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
+ base::Bind(&SetApplicationLocaleOnIOThread, locale))) {
+ g_io_thread_application_locale.Get() = locale;
+ }
+}
+
content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts(
const content::MainFunctionParams& parameters) {
ChromeBrowserMainParts* main_parts;
@@ -1263,7 +1292,7 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
std::string ChromeContentBrowserClient::GetApplicationLocale() {
if (BrowserThread::CurrentlyOn(BrowserThread::IO))
- return io_thread_application_locale_;
+ return g_io_thread_application_locale.Get();
return g_browser_process->GetApplicationLocale();
}
@@ -1901,13 +1930,6 @@ void ChromeContentBrowserClient::UpdateInspectorSetting(
Value::CreateStringValue(value));
}
-void ChromeContentBrowserClient::ClearInspectorSettings(RenderViewHost* rvh) {
- content::BrowserContext* browser_context =
- rvh->GetProcess()->GetBrowserContext();
- Profile::FromBrowserContext(browser_context)->GetPrefs()->
- ClearPref(prefs::kWebKitInspectorSettings);
-}
-
void ChromeContentBrowserClient::BrowserURLHandlerCreated(
BrowserURLHandler* handler) {
// Add the default URL handlers.
@@ -2167,29 +2189,4 @@ crypto::CryptoModuleBlockingPasswordDelegate*
}
#endif
-void ChromeContentBrowserClient::SetApplicationLocale(
- const std::string& locale) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- // This object is guaranteed to outlive all threads so we don't have to
- // worry about the lack of refcounting and can just post as Unretained.
- //
- // The common case is that this function is called early in Chrome startup
- // before any threads are created (it will also be called later if the user
- // changes the pref). In this case, there will be no threads created and
- // posting will fail. When there are no threads, we can just set the string
- // without worrying about threadsafety.
- if (!BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
- base::Bind(
- &ChromeContentBrowserClient::SetApplicationLocaleOnIOThread,
- base::Unretained(this), locale)))
- io_thread_application_locale_ = locale;
-}
-
-void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread(
- const std::string& locale) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- io_thread_application_locale_ = locale;
-}
-
} // namespace chrome
diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h
index da9409f..56e78e9 100644
--- a/chrome/browser/chrome_content_browser_client.h
+++ b/chrome/browser/chrome_content_browser_client.h
@@ -36,6 +36,10 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
static void RegisterUserPrefs(PrefRegistrySyncable* registry);
+ // Notification that the application locale has changed. This allows us to
+ // update our I/O thread cache of this value.
+ static void SetApplicationLocale(const std::string& locale);
+
virtual content::BrowserMainParts* CreateBrowserMainParts(
const content::MainFunctionParams& parameters) OVERRIDE;
virtual std::string GetStoragePartitionIdForSite(
@@ -200,7 +204,6 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
virtual void UpdateInspectorSetting(content::RenderViewHost* rvh,
const std::string& key,
const std::string& value) OVERRIDE;
- virtual void ClearInspectorSettings(content::RenderViewHost* rvh) OVERRIDE;
virtual void BrowserURLHandlerCreated(
content::BrowserURLHandler* handler) OVERRIDE;
virtual void ClearCache(content::RenderViewHost* rvh) OVERRIDE;
@@ -238,21 +241,10 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
const GURL& url) OVERRIDE;
#endif
- // Notification that the application locale has changed. This allows us to
- // update our I/O thread cache of this value.
- void SetApplicationLocale(const std::string& locale);
-
private:
- // Sets io_thread_application_locale_ to the given value.
- void SetApplicationLocaleOnIOThread(const std::string& locale);
-
// Set of origins that can use TCP/UDP private APIs from NaCl.
std::set<std::string> allowed_socket_origins_;
- // Cached version of the locale so we can return the locale on the I/O
- // thread.
- std::string io_thread_application_locale_;
-
DISALLOW_COPY_AND_ASSIGN(ChromeContentBrowserClient);
};
diff --git a/chrome/browser/chromeos/login/login_browsertest.cc b/chrome/browser/chromeos/login/login_browsertest.cc
index 1e62260..afef1e2 100644
--- a/chrome/browser/chromeos/login/login_browsertest.cc
+++ b/chrome/browser/chromeos/login/login_browsertest.cc
@@ -157,14 +157,12 @@ class LoginSigninTest : public CrosInProcessBrowserTest {
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
content_browser_client_.reset(new TestContentBrowserClient());
- original_content_browser_client_ = content::GetContentClient()->browser();
- content::GetContentClient()->set_browser_for_testing(
+ original_content_browser_client_ = content::SetBrowserClientForTesting(
content_browser_client_.get());
}
virtual void TearDownInProcessBrowserTestFixture() OVERRIDE {
- content::GetContentClient()->set_browser_for_testing(
- original_content_browser_client_);
+ content::SetBrowserClientForTesting(original_content_browser_client_);
}
scoped_ptr<TestContentBrowserClient> content_browser_client_;
diff --git a/chrome/browser/devtools/devtools_sanity_browsertest.cc b/chrome/browser/devtools/devtools_sanity_browsertest.cc
index 827e3c1..8de5cb0 100644
--- a/chrome/browser/devtools/devtools_sanity_browsertest.cc
+++ b/chrome/browser/devtools/devtools_sanity_browsertest.cc
@@ -8,6 +8,7 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/path_service.h"
+#include "base/prefs/pref_service.h"
#include "base/stringprintf.h"
#include "base/test/test_timeouts.h"
#include "base/utf_string_conversions.h"
@@ -25,6 +26,7 @@
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
@@ -426,8 +428,11 @@ IN_PROC_BROWSER_TEST_F(
TestScriptsTabIsPopulatedOnInspectedPageRefresh) {
// Clear inspector settings to ensure that Elements will be
// current panel when DevTools window is open.
- content::GetContentClient()->browser()->ClearInspectorSettings(
- GetInspectedTab()->GetRenderViewHost());
+ content::BrowserContext* browser_context =
+ GetInspectedTab()->GetBrowserContext();
+ Profile::FromBrowserContext(browser_context)->GetPrefs()->
+ ClearPref(prefs::kWebKitInspectorSettings);
+
RunTest("testScriptsTabIsPopulatedOnInspectedPageRefresh",
kDebuggerTestPage);
}
diff --git a/chrome/browser/download/download_query.cc b/chrome/browser/download/download_query.cc
index e67be5e..ccb9516 100644
--- a/chrome/browser/download/download_query.cc
+++ b/chrome/browser/download/download_query.cc
@@ -15,6 +15,7 @@
#include "base/i18n/string_search.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "base/prefs/pref_service.h"
#include "base/stl_util.h"
#include "base/string16.h"
#include "base/stringprintf.h"
@@ -22,6 +23,8 @@
#include "base/time.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/pref_names.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/download_item.h"
#include "googleurl/src/gurl.h"
@@ -65,10 +68,10 @@ static bool MatchesQuery(const string16& query, const DownloadItem& item) {
string16 url_formatted = url_raw;
if (item.GetBrowserContext()) {
+ Profile* profile = Profile::FromBrowserContext(item.GetBrowserContext());
url_formatted = net::FormatUrl(
item.GetOriginalUrl(),
- content::GetContentClient()->browser()->GetAcceptLangs(
- item.GetBrowserContext()));
+ profile->GetPrefs()->GetString(prefs::kAcceptLanguages));
}
if (base::i18n::StringSearchIgnoringCaseAndAccents(
query, url_formatted, NULL, NULL)) {
diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc b/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc
index d599ede..d0d0ca7 100644
--- a/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc
+++ b/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc
@@ -351,8 +351,7 @@ class WebNavigationApiTest : public ExtensionApiTest {
test_navigation_listener_ = new TestNavigationListener();
content_browser_client_.reset(
new TestContentBrowserClient(test_navigation_listener_.get()));
- original_content_browser_client_ = content::GetContentClient()->browser();
- content::GetContentClient()->set_browser_for_testing(
+ original_content_browser_client_ = content::SetBrowserClientForTesting(
content_browser_client_.get());
FrameNavigationState::set_allow_extension_scheme(true);
@@ -366,8 +365,7 @@ class WebNavigationApiTest : public ExtensionApiTest {
virtual void TearDownInProcessBrowserTestFixture() OVERRIDE {
ExtensionApiTest::TearDownInProcessBrowserTestFixture();
- content::GetContentClient()->set_browser_for_testing(
- original_content_browser_client_);
+ content::SetBrowserClientForTesting(original_content_browser_client_);
}
TestNavigationListener* test_navigation_listener() {
diff --git a/chrome/browser/media/media_stream_capture_indicator.cc b/chrome/browser/media/media_stream_capture_indicator.cc
index 4d25886..48c7631 100644
--- a/chrome/browser/media/media_stream_capture_indicator.cc
+++ b/chrome/browser/media/media_stream_capture_indicator.cc
@@ -8,6 +8,7 @@
#include "base/i18n/rtl.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "base/prefs/pref_service.h"
#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser_process.h"
@@ -19,6 +20,7 @@
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/browser/ui/screen_capture_notification_ui.h"
#include "chrome/common/extensions/api/icons/icons_handler.h"
+#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/invalidate_type.h"
@@ -94,9 +96,10 @@ string16 GetTitle(WebContents* web_contents) {
tab_title = GetSecurityOrigin(web_contents);
} else {
// If the page's title matches its URL, use its security originator.
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents->GetBrowserContext());
std::string languages =
- content::GetContentClient()->browser()->GetAcceptLangs(
- web_contents->GetBrowserContext());
+ profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
if (tab_title == net::FormatUrl(web_contents->GetURL(), languages))
tab_title = GetSecurityOrigin(web_contents);
}
diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc
index 141dac8..72fff96 100644
--- a/chrome/browser/metrics/metrics_log.cc
+++ b/chrome/browser/metrics/metrics_log.cc
@@ -41,7 +41,6 @@
#include "chrome/common/metrics/variations/variations_util.h"
#include "chrome/common/pref_names.h"
#include "chrome/installer/util/google_update_settings.h"
-#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/common/content_client.h"
#include "content/public/common/gpu_info.h"
@@ -803,7 +802,7 @@ void MetricsLog::RecordEnvironmentProto(
system_profile->set_uma_enabled_date(enabled_date);
system_profile->set_application_locale(
- content::GetContentClient()->browser()->GetApplicationLocale());
+ g_browser_process->GetApplicationLocale());
SystemProfileProto::Hardware* hardware = system_profile->mutable_hardware();
hardware->set_cpu_architecture(base::SysInfo::OperatingSystemArchitecture());
diff --git a/chrome/browser/search/local_ntp_source.cc b/chrome/browser/search/local_ntp_source.cc
index 8b8418e..d1fde35 100644
--- a/chrome/browser/search/local_ntp_source.cc
+++ b/chrome/browser/search/local_ntp_source.cc
@@ -8,11 +8,11 @@
#include "base/memory/ref_counted_memory.h"
#include "base/string_util.h"
#include "chrome/common/url_constants.h"
-#include "content/public/common/content_client.h"
#include "googleurl/src/gurl.h"
#include "grit/browser_resources.h"
#include "grit/ui_resources.h"
#include "net/url_request/url_request.h"
+#include "ui/base/resource/resource_bundle.h"
namespace {
@@ -58,7 +58,7 @@ void LocalNtpSource::StartDataRequest(
}
scoped_refptr<base::RefCountedStaticMemory> response(
- content::GetContentClient()->GetDataResourceBytes(identifier));
+ ResourceBundle::GetSharedInstance().LoadDataResourceBytes(identifier));
callback.Run(response);
}
diff --git a/chrome/browser/search/local_omnibox_popup_source.cc b/chrome/browser/search/local_omnibox_popup_source.cc
index aedf140..1ae3c8a 100644
--- a/chrome/browser/search/local_omnibox_popup_source.cc
+++ b/chrome/browser/search/local_omnibox_popup_source.cc
@@ -9,10 +9,10 @@
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "chrome/common/url_constants.h"
-#include "content/public/common/content_client.h"
#include "googleurl/src/gurl.h"
#include "grit/browser_resources.h"
#include "net/url_request/url_request.h"
+#include "ui/base/resource/resource_bundle.h"
namespace {
@@ -61,7 +61,7 @@ void LocalOmniboxPopupSource::StartDataRequest(
}
scoped_refptr<base::RefCountedStaticMemory> response(
- content::GetContentClient()->GetDataResourceBytes(identifier));
+ ResourceBundle::GetSharedInstance().LoadDataResourceBytes(identifier));
callback.Run(response);
}
diff --git a/chrome/browser/sync/profile_sync_service_unittest.cc b/chrome/browser/sync/profile_sync_service_unittest.cc
index ae45358..dba84a3 100644
--- a/chrome/browser/sync/profile_sync_service_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_unittest.cc
@@ -20,7 +20,6 @@
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_pref_service_syncable.h"
#include "chrome/test/base/testing_profile.h"
-#include "content/public/common/content_client.h"
#include "content/public/test/test_browser_thread.h"
#include "google/cacheinvalidation/include/types.h"
#include "google_apis/gaia/gaia_constants.h"
@@ -33,7 +32,6 @@
#include "sync/notifier/object_id_invalidation_map_test_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/user_agent/user_agent.h"
// TODO(akalin): Add tests here that exercise the whole
// ProfileSyncService/SyncBackendHost stack while mocking out as
@@ -66,11 +64,6 @@ class ProfileSyncServiceTestHarness {
io_thread_.StartIOThread();
profile.reset(new TestingProfile());
profile->CreateRequestContext();
-
- // We need to set the user agent before the backend host can call
- // webkit_glue::GetUserAgent().
- webkit_glue::SetUserAgent(content::GetContentClient()->GetUserAgent(),
- false);
}
void TearDown() {
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
index 197287de..d08aacc 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
@@ -1865,6 +1865,7 @@ void AutofillDialogControllerImpl::LoadRiskFingerprintData() {
risk::GetFingerprint(
gaia_id, window_bounds, *web_contents(), chrome::VersionInfo().Version(),
charset, accept_languages, install_time, dialog_type_,
+ g_browser_process->GetApplicationLocale(),
base::Bind(&AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData,
weak_ptr_factory_.GetWeakPtr()));
}
diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc
index ce7a12e..e36b735 100644
--- a/chrome/browser/ui/browser_commands.cc
+++ b/chrome/browser/ui/browser_commands.cc
@@ -55,6 +55,7 @@
#include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
#include "chrome/browser/upgrade_detector.h"
#include "chrome/browser/web_applications/web_app.h"
+#include "chrome/common/chrome_content_client.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
@@ -67,7 +68,6 @@
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
-#include "content/public/common/content_client.h"
#include "content/public/common/content_restriction.h"
#include "content/public/common/renderer_preferences.h"
#include "content/public/common/url_constants.h"
@@ -960,7 +960,7 @@ void ToggleRequestTabletSite(Browser* browser) {
current_tab->SetUserAgentOverride(
webkit_glue::BuildUserAgentFromOSAndProduct(
kOsOverrideForTabletSite,
- content::GetContentClient()->GetProduct()));
+ ChromeContentClient::GetProductImpl()));
}
controller.ReloadOriginalRequestURL(true);
}
diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc
index 0bcc7a3..d2cd685 100644
--- a/chrome/common/chrome_content_client.cc
+++ b/chrome/common/chrome_content_client.cc
@@ -358,6 +358,13 @@ const char* const ChromeContentClient::kNaClPluginName = ::kNaClPluginName;
const char* const ChromeContentClient::kNaClOldPluginName =
::kNaClOldPluginName;
+std::string ChromeContentClient::GetProductImpl() {
+ chrome::VersionInfo version_info;
+ std::string product("Chrome/");
+ product += version_info.is_valid() ? version_info.Version() : "0.0.0.0";
+ return product;
+}
+
void ChromeContentClient::SetActiveURL(const GURL& url) {
child_process_logging::SetActiveURL(url);
}
@@ -403,10 +410,7 @@ bool ChromeContentClient::CanHandleWhileSwappedOut(
}
std::string ChromeContentClient::GetProduct() const {
- chrome::VersionInfo version_info;
- std::string product("Chrome/");
- product += version_info.is_valid() ? version_info.Version() : "0.0.0.0";
- return product;
+ return GetProductImpl();
}
std::string ChromeContentClient::GetUserAgent() const {
diff --git a/chrome/common/chrome_content_client.h b/chrome/common/chrome_content_client.h
index 62b7ed8..a161049 100644
--- a/chrome/common/chrome_content_client.h
+++ b/chrome/common/chrome_content_client.h
@@ -19,6 +19,9 @@ class ChromeContentClient : public content::ContentClient {
static const char* const kNaClPluginName;
static const char* const kNaClOldPluginName;
+ // This is what the ContentClient::GetProduct implementation calls.
+ static std::string GetProductImpl();
+
virtual void SetActiveURL(const GURL& url) OVERRIDE;
virtual void SetGpuInfo(const content::GPUInfo& gpu_info) OVERRIDE;
virtual void AddPepperPlugins(
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
index 2211993f..917a6c8 100644
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -140,6 +140,8 @@ namespace {
const char kWebViewTagName[] = "WEBVIEW";
const char kAdViewTagName[] = "ADVIEW";
+chrome::ChromeContentRendererClient* g_current_client;
+
// Explicitly register all extension ManifestHandlers needed to parse
// fields used in the renderer.
void RegisterExtensionManifestHandlers() {
@@ -235,9 +237,11 @@ content::RenderView* GetRenderViewFromWebFrame(WebKit::WebFrame* webframe) {
namespace chrome {
ChromeContentRendererClient::ChromeContentRendererClient() {
+ g_current_client = this;
}
ChromeContentRendererClient::~ChromeContentRendererClient() {
+ g_current_client = NULL;
}
void ChromeContentRendererClient::RenderThreadStarted() {
@@ -598,8 +602,8 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
GURL manifest_url = is_nacl_mime_type ?
url : GetNaClContentHandlerURL(actual_mime_type, plugin);
const Extension* extension =
- extension_dispatcher_->extensions()->GetExtensionOrAppByURL(
- ExtensionURLInfo(manifest_url));
+ g_current_client->extension_dispatcher_->extensions()->
+ GetExtensionOrAppByURL(ExtensionURLInfo(manifest_url));
GURL top_url = frame->top()->document().url();
if (!IsNaClAllowed(manifest_url,
top_url,
@@ -1150,25 +1154,28 @@ void ChromeContentRendererClient::OnPurgeMemory() {
}
bool ChromeContentRendererClient::IsAdblockInstalled() {
- return extension_dispatcher_->extensions()->Contains(
+ return g_current_client->extension_dispatcher_->extensions()->Contains(
"gighmmpiobklfepjocnamgkkbiglidom");
}
bool ChromeContentRendererClient::IsAdblockPlusInstalled() {
- return extension_dispatcher_->extensions()->Contains(
+ return g_current_client->extension_dispatcher_->extensions()->Contains(
"cfhdojbkjhnklbpkdaibdccddilifddb");
}
bool ChromeContentRendererClient::IsAdblockWithWebRequestInstalled() {
- return extension_dispatcher_->IsAdblockWithWebRequestInstalled();
+ return g_current_client->extension_dispatcher_->
+ IsAdblockWithWebRequestInstalled();
}
bool ChromeContentRendererClient::IsAdblockPlusWithWebRequestInstalled() {
- return extension_dispatcher_->IsAdblockPlusWithWebRequestInstalled();
+ return g_current_client->extension_dispatcher_->
+ IsAdblockPlusWithWebRequestInstalled();
}
bool ChromeContentRendererClient::IsOtherExtensionWithWebRequestInstalled() {
- return extension_dispatcher_->IsOtherExtensionWithWebRequestInstalled();
+ return g_current_client->extension_dispatcher_->
+ IsOtherExtensionWithWebRequestInstalled();
}
void ChromeContentRendererClient::RegisterPPAPIInterfaceFactories(
diff --git a/chrome/renderer/chrome_content_renderer_client.h b/chrome/renderer/chrome_content_renderer_client.h
index 71bae7c..deb767e 100644
--- a/chrome/renderer/chrome_content_renderer_client.h
+++ b/chrome/renderer/chrome_content_renderer_client.h
@@ -115,16 +115,12 @@ class ChromeContentRendererClient : public content::ContentRendererClient {
const GURL& url,
const GURL& first_party_for_cookies,
const std::string& value) OVERRIDE;
- virtual bool AllowBrowserPlugin(WebKit::WebPluginContainer* container) const
- OVERRIDE;
-
- // TODO(mpcomplete): remove after we collect histogram data.
- // http://crbug.com/100411
- bool IsAdblockInstalled();
- bool IsAdblockPlusInstalled();
- bool IsAdblockWithWebRequestInstalled();
- bool IsAdblockPlusWithWebRequestInstalled();
- bool IsOtherExtensionWithWebRequestInstalled();
+ virtual bool AllowBrowserPlugin(
+ WebKit::WebPluginContainer* container) const OVERRIDE;
+ virtual void RegisterPPAPIInterfaceFactories(
+ webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager) OVERRIDE;
+ virtual bool IsRequestOSFileHandleAllowedForURL(
+ const GURL& url) const OVERRIDE;
// For testing.
void SetExtensionDispatcher(extensions::Dispatcher* extension_dispatcher);
@@ -137,17 +133,19 @@ class ChromeContentRendererClient : public content::ContentRendererClient {
// and start over.
void OnPurgeMemory();
- virtual void RegisterPPAPIInterfaceFactories(
- webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager) OVERRIDE;
-
- WebKit::WebPlugin* CreatePlugin(
+ static WebKit::WebPlugin* CreatePlugin(
content::RenderView* render_view,
WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params,
const ChromeViewHostMsg_GetPluginInfo_Output& output);
- virtual bool IsRequestOSFileHandleAllowedForURL(
- const GURL& url) const OVERRIDE;
+ // TODO(mpcomplete): remove after we collect histogram data.
+ // http://crbug.com/100411
+ static bool IsAdblockInstalled();
+ static bool IsAdblockPlusInstalled();
+ static bool IsAdblockWithWebRequestInstalled();
+ static bool IsAdblockPlusWithWebRequestInstalled();
+ static bool IsOtherExtensionWithWebRequestInstalled();
private:
FRIEND_TEST_ALL_PREFIXES(ChromeContentRendererClientTest, NaClRestriction);
diff --git a/chrome/renderer/net/net_error_helper.cc b/chrome/renderer/net/net_error_helper.cc
index c51a7c2..3e7b9ee 100644
--- a/chrome/renderer/net/net_error_helper.cc
+++ b/chrome/renderer/net/net_error_helper.cc
@@ -25,7 +25,6 @@
using base::DictionaryValue;
using chrome_common_net::DnsProbeResult;
-using content::GetContentClient;
using content::RenderThread;
using content::RenderView;
using content::RenderViewObserver;
diff --git a/chrome/renderer/page_load_histograms.cc b/chrome/renderer/page_load_histograms.cc
index e78ebd9..154cf01 100644
--- a/chrome/renderer/page_load_histograms.cc
+++ b/chrome/renderer/page_load_histograms.cc
@@ -439,11 +439,8 @@ void PageLoadHistograms::Dump(WebFrame* frame) {
// TODO(mpcomplete): remove the extension-related histograms after we collect
// enough data. http://crbug.com/100411
- chrome::ChromeContentRendererClient* client =
- static_cast<chrome::ChromeContentRendererClient*>(
- content::GetContentClient()->renderer());
-
- const bool use_adblock_histogram = client->IsAdblockInstalled();
+ const bool use_adblock_histogram =
+ chrome::ChromeContentRendererClient::IsAdblockInstalled();
if (use_adblock_histogram) {
UMA_HISTOGRAM_ENUMERATION(
"PLT.Abandoned_ExtensionAdblock",
@@ -474,7 +471,8 @@ void PageLoadHistograms::Dump(WebFrame* frame) {
}
}
- const bool use_adblockplus_histogram = client->IsAdblockPlusInstalled();
+ const bool use_adblockplus_histogram =
+ chrome::ChromeContentRendererClient::IsAdblockPlusInstalled();
if (use_adblockplus_histogram) {
UMA_HISTOGRAM_ENUMERATION(
"PLT.Abandoned_ExtensionAdblockPlus",
@@ -506,7 +504,7 @@ void PageLoadHistograms::Dump(WebFrame* frame) {
}
const bool use_webrequest_adblock_histogram =
- client->IsAdblockWithWebRequestInstalled();
+ chrome::ChromeContentRendererClient::IsAdblockWithWebRequestInstalled();
if (use_webrequest_adblock_histogram) {
UMA_HISTOGRAM_ENUMERATION(
"PLT.Abandoned_ExtensionWebRequestAdblock",
@@ -538,7 +536,8 @@ void PageLoadHistograms::Dump(WebFrame* frame) {
}
const bool use_webrequest_adblockplus_histogram =
- client->IsAdblockPlusWithWebRequestInstalled();
+ chrome::ChromeContentRendererClient::
+ IsAdblockPlusWithWebRequestInstalled();
if (use_webrequest_adblockplus_histogram) {
UMA_HISTOGRAM_ENUMERATION(
"PLT.Abandoned_ExtensionWebRequestAdblockPlus",
@@ -570,7 +569,8 @@ void PageLoadHistograms::Dump(WebFrame* frame) {
}
const bool use_webrequest_other_histogram =
- client->IsOtherExtensionWithWebRequestInstalled();
+ chrome::ChromeContentRendererClient::
+ IsOtherExtensionWithWebRequestInstalled();
if (use_webrequest_other_histogram) {
UMA_HISTOGRAM_ENUMERATION(
"PLT.Abandoned_ExtensionWebRequestOther",
diff --git a/chrome/renderer/plugins/plugin_placeholder.cc b/chrome/renderer/plugins/plugin_placeholder.cc
index 5366aee..79fc269 100644
--- a/chrome/renderer/plugins/plugin_placeholder.cc
+++ b/chrome/renderer/plugins/plugin_placeholder.cc
@@ -449,11 +449,8 @@ void PluginPlaceholder::PluginListChanged() {
mime_type, &output));
if (output.status.value == status_->value)
return;
- chrome::ChromeContentRendererClient* client =
- static_cast<chrome::ChromeContentRendererClient*>(
- content::GetContentClient()->renderer());
- WebPlugin* new_plugin =
- client->CreatePlugin(render_view(), frame_, plugin_params_, output);
+ WebPlugin* new_plugin = chrome::ChromeContentRendererClient::CreatePlugin(
+ render_view(), frame_, plugin_params_, output);
ReplacePlugin(new_plugin);
}
diff --git a/chrome/test/base/chrome_render_view_test.cc b/chrome/test/base/chrome_render_view_test.cc
index 92d0128..1ea2554 100644
--- a/chrome/test/base/chrome_render_view_test.cc
+++ b/chrome/test/base/chrome_render_view_test.cc
@@ -52,8 +52,7 @@ ChromeRenderViewTest::~ChromeRenderViewTest() {
}
void ChromeRenderViewTest::SetUp() {
- content::GetContentClient()->set_renderer_for_testing(
- &chrome_content_renderer_client_);
+ content::SetRendererClientForTesting(&chrome_content_renderer_client_);
extension_dispatcher_ = new extensions::Dispatcher();
chrome_content_renderer_client_.SetExtensionDispatcher(extension_dispatcher_);
chrome_content_renderer_client_.SetSpellcheck(new SpellCheck());
diff --git a/chrome/test/base/chrome_test_suite.cc b/chrome/test/base/chrome_test_suite.cc
index 62a85ab..25d7334 100644
--- a/chrome/test/base/chrome_test_suite.cc
+++ b/chrome/test/base/chrome_test_suite.cc
@@ -133,14 +133,13 @@ class ChromeTestSuiteInitializer : public testing::EmptyTestEventListener {
DCHECK(!g_browser_process);
g_browser_process = new TestingBrowserProcess;
- DCHECK(!content::GetContentClient());
content_client_.reset(new chrome::ChromeContentClient);
+ content::SetContentClient(content_client_.get());
// TODO(ios): Bring this back once ChromeContentBrowserClient is building.
#if !defined(OS_IOS)
browser_content_client_.reset(new chrome::ChromeContentBrowserClient());
- content_client_->set_browser_for_testing(browser_content_client_.get());
+ SetBrowserClientForTesting(browser_content_client_.get());
#endif
- content::SetContentClient(content_client_.get());
SetUpHostResolver();
}
@@ -151,7 +150,6 @@ class ChromeTestSuiteInitializer : public testing::EmptyTestEventListener {
g_browser_process = NULL;
}
- DCHECK_EQ(content_client_.get(), content::GetContentClient());
// TODO(ios): Bring this back once ChromeContentBrowserClient is building.
#if !defined(OS_IOS)
browser_content_client_.reset();
diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc
index fb99e8f..35c24fe 100644
--- a/chrome/test/base/in_process_browser_test.cc
+++ b/chrome/test/base/in_process_browser_test.cc
@@ -118,7 +118,7 @@ void InProcessBrowserTest::SetUp() {
// Single-process mode is not set in BrowserMain, so process it explicitly,
// and set up renderer.
if (command_line->HasSwitch(switches::kSingleProcess)) {
- content::GetContentClient()->set_renderer_for_testing(
+ content::SetRendererClientForTesting(
&g_chrome_content_renderer_client.Get());
}
diff --git a/chrome_frame/test/net/fake_external_tab.cc b/chrome_frame/test/net/fake_external_tab.cc
index 887abf6..f5bbfba 100644
--- a/chrome_frame/test/net/fake_external_tab.cc
+++ b/chrome_frame/test/net/fake_external_tab.cc
@@ -153,8 +153,7 @@ class FakeMainDelegate : public content::ContentMainDelegate {
testing::UnitTest::GetInstance());
content::SetContentClient(&g_chrome_content_client.Get());
- content::GetContentClient()->set_renderer_for_testing(
- &g_renderer_client.Get());
+ content::SetRendererClientForTesting(&g_renderer_client.Get());
return false;
}
diff --git a/components/autofill/browser/android/personal_data_manager_android.cc b/components/autofill/browser/android/personal_data_manager_android.cc
index 8d7a6d1..2075ee5 100644
--- a/components/autofill/browser/android/personal_data_manager_android.cc
+++ b/components/autofill/browser/android/personal_data_manager_android.cc
@@ -8,10 +8,6 @@
#include "components/autofill/browser/android/auxiliary_profiles_android.h"
#include "components/autofill/browser/personal_data_manager.h"
-// TODO(jam) remove once https://codereview.chromium.org/13488009/ lands, since
-// that brings localle to PDM.
-#include "content/public/browser/content_browser_client.h"
-
void PersonalDataManager::LoadAuxiliaryProfiles() {
auxiliary_profiles_.clear();
autofill::AuxiliaryProfileLoaderAndroid profile_loader;
@@ -19,11 +15,7 @@ void PersonalDataManager::LoadAuxiliaryProfiles() {
base::android::AttachCurrentThread(),
base::android::GetApplicationContext());
if (profile_loader.GetHasPermissions()) {
- autofill::AuxiliaryProfilesAndroid impl(
- profile_loader,
- // TODO(jam) remove once https://codereview.chromium.org/13488009/
- // lands, since that brings localle to PDM.
- content::GetContentClient()->browser()->GetApplicationLocale());
+ autofill::AuxiliaryProfilesAndroid impl(profile_loader, app_locale_);
auxiliary_profiles_.push_back(impl.LoadContactsProfile().release());
}
}
diff --git a/components/autofill/browser/autocheckout_manager.cc b/components/autofill/browser/autocheckout_manager.cc
index a66f9d1..a48cb8a 100644
--- a/components/autofill/browser/autocheckout_manager.cc
+++ b/components/autofill/browser/autocheckout_manager.cc
@@ -20,9 +20,6 @@
#include "components/autofill/common/form_data.h"
#include "components/autofill/common/form_field_data.h"
#include "components/autofill/common/web_element_descriptor.h"
-// TODO(jam) remove once https://codereview.chromium.org/13488009/ lands, since
-// that brings localle to AutofillManager.
-#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/ssl_status.h"
@@ -294,11 +291,7 @@ void AutocheckoutManager::ReturnAutocheckoutData(
result->field(i)->type() == ADDRESS_BILLING_COUNTRY) {
profile_->SetInfo(result->field(i)->type(),
result->field(i)->value,
- // TODO(jam) remove once
- // https://codereview.chromium.org/13488009/
- // lands, since that brings localle to AutofillManager.
- content::GetContentClient()->browser()->
- GetApplicationLocale());
+ autofill_manager_->app_locale());
} else {
profile_->SetRawInfo(result->field(i)->type(), result->field(i)->value);
}
diff --git a/components/autofill/browser/risk/fingerprint.cc b/components/autofill/browser/risk/fingerprint.cc
index 466378a..6dd0b6a 100644
--- a/components/autofill/browser/risk/fingerprint.cc
+++ b/components/autofill/browser/risk/fingerprint.cc
@@ -14,7 +14,6 @@
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "components/autofill/browser/risk/proto/fingerprint.pb.h"
-#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/font_list_async.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/gpu_data_manager_observer.h"
@@ -189,6 +188,7 @@ class FingerprintDataLoader : public content::GpuDataManagerObserver {
const std::string& accept_languages,
const base::Time& install_time,
DialogType dialog_type,
+ const std::string& app_locale,
const base::Callback<void(scoped_ptr<Fingerprint>)>& callback);
private:
@@ -227,6 +227,9 @@ class FingerprintDataLoader : public content::GpuDataManagerObserver {
std::vector<webkit::WebPluginInfo> plugins_;
bool has_loaded_plugins_;
+ // The current application locale.
+ std::string app_locale_;
+
// The callback that will be called once all the data is available.
base::Callback<void(scoped_ptr<Fingerprint>)> callback_;
@@ -243,6 +246,7 @@ FingerprintDataLoader::FingerprintDataLoader(
const std::string& accept_languages,
const base::Time& install_time,
DialogType dialog_type,
+ const std::string& app_locale,
const base::Callback<void(scoped_ptr<Fingerprint>)>& callback)
: gpu_data_manager_(content::GpuDataManager::GetInstance()),
gaia_id_(gaia_id),
@@ -318,10 +322,9 @@ void FingerprintDataLoader::FillFingerprint() {
machine->set_browser_install_time_hours(
(install_time_ - base::Time::UnixEpoch()).InHours());
machine->set_utc_offset_ms(GetTimezoneOffset().InMilliseconds());
- machine->set_browser_language(
- content::GetContentClient()->browser()->GetApplicationLocale());
+ machine->set_browser_language(app_locale_);
machine->set_charset(charset_);
- machine->set_user_agent(content::GetContentClient()->GetUserAgent());
+ machine->set_user_agent(content::GetUserAgent(GURL()));
machine->set_ram(base::SysInfo::AmountOfPhysicalMemory());
machine->set_browser_build(version_);
machine->set_browser_feature(DialogTypeToBrowserFeature(dialog_type_));
@@ -371,6 +374,7 @@ void GetFingerprint(
const std::string& accept_languages,
const base::Time& install_time,
DialogType dialog_type,
+ const std::string& app_locale,
const base::Callback<void(scoped_ptr<Fingerprint>)>& callback) {
gfx::Rect content_bounds;
web_contents.GetView()->GetContainerBounds(&content_bounds);
@@ -383,7 +387,7 @@ void GetFingerprint(
internal::GetFingerprintInternal(
gaia_id, window_bounds, content_bounds, screen_info, version, charset,
- accept_languages, install_time, dialog_type, callback);
+ accept_languages, install_time, dialog_type, app_locale, callback);
}
namespace internal {
@@ -398,12 +402,13 @@ void GetFingerprintInternal(
const std::string& accept_languages,
const base::Time& install_time,
DialogType dialog_type,
+ const std::string& app_locale,
const base::Callback<void(scoped_ptr<Fingerprint>)>& callback) {
// Begin loading all of the data that we need to load asynchronously.
// This class is responsible for freeing its own memory.
new FingerprintDataLoader(gaia_id, window_bounds, content_bounds, screen_info,
version, charset, accept_languages, install_time,
- dialog_type, callback);
+ dialog_type, app_locale, callback);
}
} // namespace internal
diff --git a/components/autofill/browser/risk/fingerprint.h b/components/autofill/browser/risk/fingerprint.h
index b4595e1..d498ec2 100644
--- a/components/autofill/browser/risk/fingerprint.h
+++ b/components/autofill/browser/risk/fingerprint.h
@@ -53,6 +53,7 @@ void GetFingerprint(
const std::string& accept_languages,
const base::Time& install_time,
DialogType dialog_type,
+ const std::string& app_locale,
const base::Callback<void(scoped_ptr<Fingerprint>)>& callback);
// Exposed for testing:
@@ -68,6 +69,7 @@ void GetFingerprintInternal(
const std::string& accept_languages,
const base::Time& install_time,
DialogType dialog_type,
+ const std::string& app_locale,
const base::Callback<void(scoped_ptr<Fingerprint>)>& callback);
} // namespace internal
diff --git a/content/browser/child_process_security_policy_unittest.cc b/content/browser/child_process_security_policy_unittest.cc
index a2eed34..6aad9d9 100644
--- a/content/browser/child_process_security_policy_unittest.cc
+++ b/content/browser/child_process_security_policy_unittest.cc
@@ -55,8 +55,7 @@ class ChildProcessSecurityPolicyTest : public testing::Test {
}
virtual void SetUp() {
- old_browser_client_ = GetContentClient()->browser();
- GetContentClient()->set_browser_for_testing(&test_browser_client_);
+ old_browser_client_ = SetBrowserClientForTesting(&test_browser_client_);
// Claim to always handle chrome:// URLs because the CPSP's notion of
// allowing WebUI bindings is hard-wired to this particular scheme.
@@ -65,7 +64,7 @@ class ChildProcessSecurityPolicyTest : public testing::Test {
virtual void TearDown() {
test_browser_client_.ClearSchemes();
- GetContentClient()->set_browser_for_testing(old_browser_client_);
+ SetBrowserClientForTesting(old_browser_client_);
}
protected:
diff --git a/content/browser/devtools/devtools_manager_unittest.cc b/content/browser/devtools/devtools_manager_unittest.cc
index 1208856..0438b7a 100644
--- a/content/browser/devtools/devtools_manager_unittest.cc
+++ b/content/browser/devtools/devtools_manager_unittest.cc
@@ -112,8 +112,7 @@ class DevToolsManagerTest : public RenderViewHostImplTestHarness {
protected:
virtual void SetUp() OVERRIDE {
- original_browser_client_ = GetContentClient()->browser();
- GetContentClient()->set_browser_for_testing(&browser_client_);
+ original_browser_client_ = SetBrowserClientForTesting(&browser_client_);
RenderViewHostImplTestHarness::SetUp();
TestDevToolsClientHost::ResetCounters();
@@ -121,7 +120,7 @@ class DevToolsManagerTest : public RenderViewHostImplTestHarness {
virtual void TearDown() OVERRIDE {
RenderViewHostImplTestHarness::TearDown();
- GetContentClient()->set_browser_for_testing(original_browser_client_);
+ SetBrowserClientForTesting(original_browser_client_);
}
private:
diff --git a/content/browser/download/drag_download_file_browsertest.cc b/content/browser/download/drag_download_file_browsertest.cc
index e35cbfb..040ddce 100644
--- a/content/browser/download/drag_download_file_browsertest.cc
+++ b/content/browser/download/drag_download_file_browsertest.cc
@@ -116,10 +116,6 @@ IN_PROC_BROWSER_TEST_F(DragDownloadFileTest, DragDownloadFileTest_Complete) {
Referrer referrer;
std::string referrer_encoding;
net::FileStream* stream = NULL;
-#if defined(OS_POSIX)
- stream = CreateFileStreamForDrop(
- &name, GetContentClient()->browser()->GetNetLog());
-#endif
SetUpServer();
DragDownloadFile* file = new DragDownloadFile(
name, scoped_ptr<net::FileStream>(stream), url, referrer,
diff --git a/content/browser/loader/resource_dispatcher_host_unittest.cc b/content/browser/loader/resource_dispatcher_host_unittest.cc
index 329c939..3a64c33 100644
--- a/content/browser/loader/resource_dispatcher_host_unittest.cc
+++ b/content/browser/loader/resource_dispatcher_host_unittest.cc
@@ -1733,14 +1733,13 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigation) {
// Temporarily replace ContentBrowserClient with one that will trigger the
// transfer navigation code paths.
- ContentBrowserClient* old_client = GetContentClient()->browser();
TransfersAllNavigationsContentBrowserClient new_client;
- GetContentClient()->set_browser_for_testing(&new_client);
+ ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client);
MakeTestRequest(render_view_id, request_id, GURL("http://example.com/blah"));
// Restore.
- GetContentClient()->set_browser_for_testing(old_client);
+ SetBrowserClientForTesting(old_client);
// This second filter is used to emulate a second process.
scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(
@@ -1792,14 +1791,13 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigationAndThenRedirect) {
// Temporarily replace ContentBrowserClient with one that will trigger the
// transfer navigation code paths.
- ContentBrowserClient* old_client = GetContentClient()->browser();
TransfersAllNavigationsContentBrowserClient new_client;
- GetContentClient()->set_browser_for_testing(&new_client);
+ ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client);
MakeTestRequest(render_view_id, request_id, GURL("http://example.com/blah"));
// Restore.
- GetContentClient()->set_browser_for_testing(old_client);
+ SetBrowserClientForTesting(old_client);
// This second filter is used to emulate a second process.
scoped_refptr<ForwardingFilter> second_filter = new ForwardingFilter(
diff --git a/content/browser/loader/resource_loader_unittest.cc b/content/browser/loader/resource_loader_unittest.cc
index 5e68b6d..82394f9 100644
--- a/content/browser/loader/resource_loader_unittest.cc
+++ b/content/browser/loader/resource_loader_unittest.cc
@@ -230,9 +230,8 @@ TEST_F(ResourceLoaderTest, ClientCertStoreLookup) {
cert_request_info->cert_authorities = dummy_authority;
// Plug in test content browser client.
- ContentBrowserClient* old_client = GetContentClient()->browser();
SelectCertificateBrowserClient test_client;
- GetContentClient()->set_browser_for_testing(&test_client);
+ ContentBrowserClient* old_client = SetBrowserClientForTesting(&test_client);
// Everything is set up. Trigger the resource loader certificate request event
// and run the message loop.
@@ -240,7 +239,7 @@ TEST_F(ResourceLoaderTest, ClientCertStoreLookup) {
message_loop_->RunUntilIdle();
// Restore the original content browser client.
- GetContentClient()->set_browser_for_testing(old_client);
+ SetBrowserClientForTesting(old_client);
// Check if the test store was queried against correct |cert_authorities|.
EXPECT_EQ(1, raw_ptr_to_store->request_count());
diff --git a/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc b/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc
index 99fdc6b..0f9f0b6 100644
--- a/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc
+++ b/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc
@@ -128,8 +128,7 @@ class MockMediaStreamDispatcherHost : public MediaStreamDispatcherHost,
class MediaStreamDispatcherHostTest : public testing::Test {
public:
- MediaStreamDispatcherHostTest() : old_client_(NULL),
- old_browser_client_(NULL) {}
+ MediaStreamDispatcherHostTest() : old_browser_client_(NULL) {}
virtual ~MediaStreamDispatcherHostTest() {}
void WaitForResult() {
@@ -156,19 +155,16 @@ class MediaStreamDispatcherHostTest : public testing::Test {
media_stream_manager_.get());
// Use the fake content client and browser.
- old_client_ = GetContentClient();
- old_browser_client_ = GetContentClient()->browser();
content_client_.reset(new TestContentClient);
SetContentClient(content_client_.get());
- content_client_->set_browser_for_testing(host_);
+ old_browser_client_ = SetBrowserClientForTesting(host_);
}
virtual void TearDown() OVERRIDE {
message_loop_->RunUntilIdle();
// Recover the old browser client and content client.
- GetContentClient()->set_browser_for_testing(old_browser_client_);
- SetContentClient(old_client_);
+ SetBrowserClientForTesting(old_browser_client_);
content_client_.reset();
// Delete the IO message loop to delete the device thread,
@@ -181,7 +177,6 @@ class MediaStreamDispatcherHostTest : public testing::Test {
scoped_ptr<BrowserThreadImpl> io_thread_;
scoped_ptr<media::AudioManager> audio_manager_;
scoped_ptr<MediaStreamManager> media_stream_manager_;
- ContentClient* old_client_;
ContentBrowserClient* old_browser_client_;
scoped_ptr<ContentClient> content_client_;
scoped_ptr<MockMediaObserver> media_observer_;
diff --git a/content/browser/site_instance_impl_unittest.cc b/content/browser/site_instance_impl_unittest.cc
index a66e5c8..cf44325 100644
--- a/content/browser/site_instance_impl_unittest.cc
+++ b/content/browser/site_instance_impl_unittest.cc
@@ -92,8 +92,7 @@ class SiteInstanceTest : public testing::Test {
}
virtual void SetUp() {
- old_browser_client_ = GetContentClient()->browser();
- GetContentClient()->set_browser_for_testing(&browser_client_);
+ old_browser_client_ = SetBrowserClientForTesting(&browser_client_);
url_util::AddStandardScheme(kPrivilegedScheme);
url_util::AddStandardScheme(chrome::kChromeUIScheme);
}
@@ -102,7 +101,7 @@ class SiteInstanceTest : public testing::Test {
// Ensure that no RenderProcessHosts are left over after the tests.
EXPECT_TRUE(RenderProcessHost::AllHostsIterator().IsAtEnd());
- GetContentClient()->set_browser_for_testing(old_browser_client_);
+ SetBrowserClientForTesting(old_browser_client_);
// http://crbug.com/143565 found SiteInstanceTest leaking an
// AppCacheDatabase. This happens because some part of the test indirectly
diff --git a/content/browser/webui/web_ui_data_source_unittest.cc b/content/browser/webui/web_ui_data_source_unittest.cc
index b58161c..24d1d2b 100644
--- a/content/browser/webui/web_ui_data_source_unittest.cc
+++ b/content/browser/webui/web_ui_data_source_unittest.cc
@@ -52,7 +52,7 @@ class TestClient : public TestContentClient {
class WebUIDataSourceTest : public testing::Test {
public:
- WebUIDataSourceTest() : result_data_(NULL), old_client_(NULL) {}
+ WebUIDataSourceTest() : result_data_(NULL) {}
virtual ~WebUIDataSourceTest() {}
WebUIDataSourceImpl* source() { return source_.get(); }
@@ -72,7 +72,6 @@ class WebUIDataSourceTest : public testing::Test {
private:
virtual void SetUp() {
- old_client_ = GetContentClient();
SetContentClient(&client_);
WebUIDataSource* source = WebUIDataSourceImpl::Create("host");
WebUIDataSourceImpl* source_impl = static_cast<WebUIDataSourceImpl*>(
@@ -81,10 +80,6 @@ class WebUIDataSourceTest : public testing::Test {
source_ = make_scoped_refptr(source_impl);
}
- virtual void TearDown() {
- SetContentClient(old_client_);
- }
-
// Store response for later comparisons.
void SendResult(base::RefCountedMemory* data) {
result_data_ = data;
@@ -92,7 +87,6 @@ class WebUIDataSourceTest : public testing::Test {
scoped_refptr<WebUIDataSourceImpl> source_;
TestClient client_;
- ContentClient* old_client_;
};
TEST_F(WebUIDataSourceTest, EmptyStrings) {
diff --git a/content/browser/worker_host/test/worker_browsertest.cc b/content/browser/worker_host/test/worker_browsertest.cc
index 7928718..1be3007 100644
--- a/content/browser/worker_host/test/worker_browsertest.cc
+++ b/content/browser/worker_host/test/worker_browsertest.cc
@@ -289,7 +289,7 @@ class WorkerTest : public ContentBrowserTest {
void NavigateAndWaitForAuth(const GURL& url) {
ShellContentBrowserClient* browser_client =
- static_cast<ShellContentBrowserClient*>(GetContentClient()->browser());
+ ShellContentBrowserClient::Get();
scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner();
browser_client->resource_dispatcher_host_delegate()->
set_login_request_callback(
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
index b89fffa..abc5834 100644
--- a/content/public/browser/content_browser_client.h
+++ b/content/public/browser/content_browser_client.h
@@ -448,9 +448,6 @@ class CONTENT_EXPORT ContentBrowserClient {
const std::string& key,
const std::string& value) {}
- // Clear the Inspector settings.
- virtual void ClearInspectorSettings(RenderViewHost* rvh) {}
-
// Notifies that BrowserURLHandler has been created, so that the embedder can
// optionally add their own handlers.
virtual void BrowserURLHandlerCreated(BrowserURLHandler* handler) {}
diff --git a/content/public/common/content_client.cc b/content/public/common/content_client.cc
index 31bbb8a..06f31a4 100644
--- a/content/public/common/content_client.cc
+++ b/content/public/common/content_client.cc
@@ -17,6 +17,21 @@ namespace content {
static ContentClient* g_client;
+class InternalTestInitializer {
+ public:
+ static ContentBrowserClient* SetBrowser(ContentBrowserClient* b) {
+ ContentBrowserClient* rv = g_client->browser_;
+ g_client->browser_ = b;
+ return rv;
+ }
+
+ static ContentRendererClient* SetRenderer(ContentRendererClient* r) {
+ ContentRendererClient* rv = g_client->renderer_;
+ g_client->renderer_ = r;
+ return rv;
+ }
+};
+
void SetContentClient(ContentClient* client) {
g_client = client;
@@ -32,6 +47,14 @@ ContentClient* GetContentClient() {
return g_client;
}
+ContentBrowserClient* SetBrowserClientForTesting(ContentBrowserClient* b) {
+ return InternalTestInitializer::SetBrowser(b);
+}
+
+ContentRendererClient* SetRendererClientForTesting(ContentRendererClient* r) {
+ return InternalTestInitializer::SetRenderer(r);
+}
+
const std::string& GetUserAgent(const GURL& url) {
DCHECK(g_client);
return webkit_glue::GetUserAgent(url);
diff --git a/content/public/common/content_client.h b/content/public/common/content_client.h
index ab397b0..f7d21c2 100644
--- a/content/public/common/content_client.h
+++ b/content/public/common/content_client.h
@@ -57,7 +57,18 @@ struct PepperPluginInfo;
// Setter and getter for the client. The client should be set early, before any
// content code is called.
CONTENT_EXPORT void SetContentClient(ContentClient* client);
-CONTENT_EXPORT ContentClient* GetContentClient();
+
+#if defined(CONTENT_IMPLEMENTATION)
+// Content's embedder API should only be used by content.
+ContentClient* GetContentClient();
+#endif
+
+// Used for tests to override the relevant embedder interfaces. Each method
+// returns the old value.
+CONTENT_EXPORT ContentBrowserClient* SetBrowserClientForTesting(
+ ContentBrowserClient* b);
+CONTENT_EXPORT ContentRendererClient* SetRendererClientForTesting(
+ ContentRendererClient* r);
// Returns the user agent string being used by the browser. SetContentClient()
// must be called prior to calling this, and this routine must be used
@@ -154,11 +165,9 @@ class CONTENT_EXPORT ContentClient {
virtual std::string GetCarbonInterposePath() const;
#endif
- void set_browser_for_testing(ContentBrowserClient* c) { browser_ = c; }
- void set_renderer_for_testing(ContentRendererClient* r) { renderer_ = r; }
-
private:
friend class ContentClientInitializer; // To set these pointers.
+ friend class InternalTestInitializer;
// The embedder API for participating in browser logic.
ContentBrowserClient* browser_;
diff --git a/content/public/test/render_view_fake_resources_test.cc b/content/public/test/render_view_fake_resources_test.cc
index 4bb0204..eda8ef9 100644
--- a/content/public/test/render_view_fake_resources_test.cc
+++ b/content/public/test/render_view_fake_resources_test.cc
@@ -60,7 +60,7 @@ void RenderViewFakeResourcesTest::SetUp() {
// but we use a real RenderThread so that we can use the ResourceDispatcher
// to fetch network resources. These are then served canned content
// in OnRequestResource().
- GetContentClient()->set_renderer_for_testing(&content_renderer_client_);
+ SetRendererClientForTesting(&content_renderer_client_);
// Generate a unique channel id so that multiple instances of the test can
// run in parallel.
std::string channel_id = IPC::Channel::GenerateVerifiedChannelID(
diff --git a/content/public/test/render_view_test.cc b/content/public/test/render_view_test.cc
index dec696e..deec4da 100644
--- a/content/public/test/render_view_test.cc
+++ b/content/public/test/render_view_test.cc
@@ -126,8 +126,10 @@ void RenderViewTest::GoForward(const WebKit::WebHistoryItem& item) {
void RenderViewTest::SetUp() {
// Subclasses can set the ContentClient's renderer before calling
// RenderViewTest::SetUp().
- if (!GetContentClient()->renderer())
- GetContentClient()->set_renderer_for_testing(&content_renderer_client_);
+ ContentRendererClient* old_client =
+ SetRendererClientForTesting(&content_renderer_client_);
+ if (old_client)
+ SetRendererClientForTesting(old_client);
// Subclasses can set render_thread_ with their own implementation before
// calling RenderViewTest::SetUp().
diff --git a/content/public/test/test_content_client_initializer.cc b/content/public/test/test_content_client_initializer.cc
index b2ecdfe..0c210d2 100644
--- a/content/public/test/test_content_client_initializer.cc
+++ b/content/public/test/test_content_client_initializer.cc
@@ -16,12 +16,11 @@ namespace content {
TestContentClientInitializer::TestContentClientInitializer() {
notification_service_.reset(new NotificationServiceImpl());
- DCHECK(!GetContentClient());
content_client_.reset(new TestContentClient);
SetContentClient(content_client_.get());
content_browser_client_.reset(new TestContentBrowserClient());
- content_client_->set_browser_for_testing(content_browser_client_.get());
+ content::SetBrowserClientForTesting(content_browser_client_.get());
}
TestContentClientInitializer::~TestContentClientInitializer() {
@@ -29,7 +28,6 @@ TestContentClientInitializer::~TestContentClientInitializer() {
rph_factory_.reset();
notification_service_.reset();
- DCHECK_EQ(content_client_.get(), GetContentClient());
SetContentClient(NULL);
content_client_.reset();
diff --git a/content/renderer/browser_plugin/browser_plugin_browsertest.cc b/content/renderer/browser_plugin/browser_plugin_browsertest.cc
index e8f38ee..5efffe9 100644
--- a/content/renderer/browser_plugin/browser_plugin_browsertest.cc
+++ b/content/renderer/browser_plugin/browser_plugin_browsertest.cc
@@ -98,8 +98,7 @@ BrowserPluginTest::~BrowserPluginTest() {}
void BrowserPluginTest::SetUp() {
test_content_renderer_client_.reset(new TestContentRendererClient);
- GetContentClient()->set_renderer_for_testing(
- test_content_renderer_client_.get());
+ SetRendererClientForTesting(test_content_renderer_client_.get());
BrowserPluginManager::set_factory_for_testing(
TestBrowserPluginManagerFactory::GetInstance());
content::RenderViewTest::SetUp();
diff --git a/content/renderer/pepper/pepper_file_chooser_host_unittest.cc b/content/renderer/pepper/pepper_file_chooser_host_unittest.cc
index 8517220..b5d2f98 100644
--- a/content/renderer/pepper/pepper_file_chooser_host_unittest.cc
+++ b/content/renderer/pepper/pepper_file_chooser_host_unittest.cc
@@ -31,11 +31,9 @@ namespace {
class PepperFileChooserHostTest : public RenderViewTest {
public:
PepperFileChooserHostTest()
- : pp_instance_(123456),
- old_content_client_(NULL) {}
+ : pp_instance_(123456) {}
virtual void SetUp() {
- old_content_client_ = GetContentClient();
SetContentClient(&client_);
RenderViewTest::SetUp();
@@ -45,7 +43,6 @@ class PepperFileChooserHostTest : public RenderViewTest {
globals_.GetResourceTracker()->DidDeleteInstance(pp_instance_);
RenderViewTest::TearDown();
- SetContentClient(old_content_client_);
}
PP_Instance pp_instance() const { return pp_instance_; }
@@ -55,9 +52,6 @@ class PepperFileChooserHostTest : public RenderViewTest {
ppapi::TestGlobals globals_;
TestContentClient client_;
-
- // Original value for the content client.
- ContentClient* old_content_client_;
};
// For testing to convert our hardcoded file paths to 8-bit.
diff --git a/content/shell/android/shell_manager.cc b/content/shell/android/shell_manager.cc
index 39fd872..0b12e1d 100644
--- a/content/shell/android/shell_manager.cc
+++ b/content/shell/android/shell_manager.cc
@@ -50,8 +50,7 @@ static void Init(JNIEnv* env, jclass clazz, jobject obj) {
void LaunchShell(JNIEnv* env, jclass clazz, jstring jurl) {
ShellBrowserContext* browserContext =
- static_cast<ShellContentBrowserClient*>(
- GetContentClient()->browser())->browser_context();
+ ShellContentBrowserClient::Get()->browser_context();
GURL url(base::android::ConvertJavaStringToUTF8(env, jurl));
Shell::CreateNewWindow(browserContext,
url,
diff --git a/content/shell/shell_application_mac.mm b/content/shell/shell_application_mac.mm
index 7918c1d..a810804 100644
--- a/content/shell/shell_application_mac.mm
+++ b/content/shell/shell_application_mac.mm
@@ -27,8 +27,7 @@
- (IBAction)newDocument:(id)sender {
content::ShellBrowserContext* browserContext =
- static_cast<content::ShellContentBrowserClient*>(
- content::GetContentClient()->browser())->browser_context();
+ content::ShellContentBrowserClient::Get()->browser_context();
content::Shell::CreateNewWindow(browserContext,
GURL("about:blank"),
NULL,
diff --git a/content/shell/shell_content_browser_client.cc b/content/shell/shell_content_browser_client.cc
index 163027f..1605583 100644
--- a/content/shell/shell_content_browser_client.cc
+++ b/content/shell/shell_content_browser_client.cc
@@ -37,6 +37,8 @@ namespace content {
namespace {
+ShellContentBrowserClient* g_browser_client;
+
base::FilePath GetWebKitRootDirFilePath() {
base::FilePath base_path;
PathService::Get(base::DIR_SOURCE_ROOT, &base_path);
@@ -72,9 +74,15 @@ base::FilePath GetChromiumRootDirFilePath() {
} // namespace
+ShellContentBrowserClient* ShellContentBrowserClient::Get() {
+ return g_browser_client;
+}
+
ShellContentBrowserClient::ShellContentBrowserClient()
: hyphen_dictionary_file_(base::kInvalidPlatformFileValue),
shell_browser_main_parts_(NULL) {
+ DCHECK(!g_browser_client);
+ g_browser_client = this;
if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
return;
webkit_source_dir_ = GetWebKitRootDirFilePath();
@@ -89,6 +97,7 @@ ShellContentBrowserClient::ShellContentBrowserClient()
}
ShellContentBrowserClient::~ShellContentBrowserClient() {
+ g_browser_client = NULL;
}
BrowserMainParts* ShellContentBrowserClient::CreateBrowserMainParts(
diff --git a/content/shell/shell_content_browser_client.h b/content/shell/shell_content_browser_client.h
index 6fce1f8..edd5474 100644
--- a/content/shell/shell_content_browser_client.h
+++ b/content/shell/shell_content_browser_client.h
@@ -21,6 +21,9 @@ class ShellResourceDispatcherHostDelegate;
class ShellContentBrowserClient : public ContentBrowserClient {
public:
+ // Gets the current instance.
+ static ShellContentBrowserClient* Get();
+
ShellContentBrowserClient();
virtual ~ShellContentBrowserClient();
diff --git a/content/shell/shell_content_renderer_client.cc b/content/shell/shell_content_renderer_client.cc
index e794f0d..0623506 100644
--- a/content/shell/shell_content_renderer_client.cc
+++ b/content/shell/shell_content_renderer_client.cc
@@ -42,7 +42,17 @@ using WebTestRunner::WebTestProxyBase;
namespace content {
+namespace {
+ShellContentRendererClient* g_renderer_client;
+}
+
+ShellContentRendererClient* ShellContentRendererClient::Get() {
+ return g_renderer_client;
+}
+
ShellContentRendererClient::ShellContentRendererClient() {
+ DCHECK(!g_renderer_client);
+ g_renderer_client = this;
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) {
EnableWebTestProxyCreation(
base::Bind(&ShellContentRendererClient::WebTestProxyCreated,
@@ -51,6 +61,7 @@ ShellContentRendererClient::ShellContentRendererClient() {
}
ShellContentRendererClient::~ShellContentRendererClient() {
+ g_renderer_client = NULL;
}
void ShellContentRendererClient::LoadHyphenDictionary(
diff --git a/content/shell/shell_content_renderer_client.h b/content/shell/shell_content_renderer_client.h
index 14bc54d..857b5c9 100644
--- a/content/shell/shell_content_renderer_client.h
+++ b/content/shell/shell_content_renderer_client.h
@@ -33,6 +33,8 @@ class ShellRenderProcessObserver;
class ShellContentRendererClient : public ContentRendererClient {
public:
+ static ShellContentRendererClient* Get();
+
ShellContentRendererClient();
virtual ~ShellContentRendererClient();
diff --git a/content/shell/shell_devtools_frontend.cc b/content/shell/shell_devtools_frontend.cc
index ee78b81..fcb810c 100644
--- a/content/shell/shell_devtools_frontend.cc
+++ b/content/shell/shell_devtools_frontend.cc
@@ -56,11 +56,8 @@ ShellDevToolsFrontend* ShellDevToolsFrontend::Show(
DevToolsAgentHost::GetOrCreateFor(
inspected_contents->GetRenderViewHost()));
- ShellContentBrowserClient* browser_client =
- static_cast<ShellContentBrowserClient*>(
- GetContentClient()->browser());
- ShellDevToolsDelegate* delegate =
- browser_client->shell_browser_main_parts()->devtools_delegate();
+ ShellDevToolsDelegate* delegate = ShellContentBrowserClient::Get()->
+ shell_browser_main_parts()->devtools_delegate();
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
shell->LoadURL(GetDevToolsPathAsURL());
else
diff --git a/content/shell/shell_gtk.cc b/content/shell/shell_gtk.cc
index 8d024ce..b1ef588 100644
--- a/content/shell/shell_gtk.cc
+++ b/content/shell/shell_gtk.cc
@@ -271,8 +271,7 @@ gboolean Shell::OnNewWindowKeyPressed(GtkAccelGroup* accel_group,
guint keyval,
GdkModifierType modifier) {
ShellBrowserContext* browser_context =
- static_cast<ShellContentBrowserClient*>(
- GetContentClient()->browser())->browser_context();
+ ShellContentBrowserClient::Get()->browser_context();
Shell::CreateNewWindow(browser_context,
GURL(),
NULL,
diff --git a/content/shell/shell_render_process_observer.cc b/content/shell/shell_render_process_observer.cc
index da8a5d0..dc32bef 100644
--- a/content/shell/shell_render_process_observer.cc
+++ b/content/shell/shell_render_process_observer.cc
@@ -96,10 +96,7 @@ void ShellRenderProcessObserver::OnSetWebKitSourceDir(
void ShellRenderProcessObserver::OnLoadHyphenDictionary(
const IPC::PlatformFileForTransit& dict_file) {
- ShellContentRendererClient* renderer_client =
- static_cast<content::ShellContentRendererClient*>(
- content::GetContentClient()->renderer());
- renderer_client->LoadHyphenDictionary(
+ ShellContentRendererClient::Get()->LoadHyphenDictionary(
IPC::PlatformFileForTransitToPlatformFile(dict_file));
}
diff --git a/content/shell/shell_web_contents_view_delegate_gtk.cc b/content/shell/shell_web_contents_view_delegate_gtk.cc
index cd72e03..ca0a2af 100644
--- a/content/shell/shell_web_contents_view_delegate_gtk.cc
+++ b/content/shell/shell_web_contents_view_delegate_gtk.cc
@@ -211,8 +211,7 @@ void ShellWebContentsViewDelegate::OnReloadMenuActivated(GtkWidget* widget) {
void ShellWebContentsViewDelegate::OnOpenURLMenuActivated(GtkWidget* widget) {
ShellBrowserContext* browser_context =
- static_cast<ShellContentBrowserClient*>(
- GetContentClient()->browser())->browser_context();
+ ShellContentBrowserClient::Get()->browser_context();
Shell::CreateNewWindow(browser_context,
params_.link_url,
NULL,
diff --git a/content/shell/shell_web_contents_view_delegate_mac.mm b/content/shell/shell_web_contents_view_delegate_mac.mm
index 2460595..32a9aad 100644
--- a/content/shell/shell_web_contents_view_delegate_mac.mm
+++ b/content/shell/shell_web_contents_view_delegate_mac.mm
@@ -237,8 +237,7 @@ void ShellWebContentsViewDelegate::ActionPerformed(int tag) {
break;
case ShellContextMenuItemOpenLinkTag: {
ShellBrowserContext* browser_context =
- static_cast<ShellContentBrowserClient*>(
- GetContentClient()->browser())->browser_context();
+ ShellContentBrowserClient::Get()->browser_context();
Shell::CreateNewWindow(browser_context,
params_.link_url,
NULL,
diff --git a/content/shell/shell_web_contents_view_delegate_win.cc b/content/shell/shell_web_contents_view_delegate_win.cc
index df400f7..52bc21f 100644
--- a/content/shell/shell_web_contents_view_delegate_win.cc
+++ b/content/shell/shell_web_contents_view_delegate_win.cc
@@ -205,8 +205,7 @@ void ShellWebContentsViewDelegate::MenuItemSelected(int selection) {
break;
case ShellContextMenuItemOpenLinkId: {
ShellBrowserContext* browser_context =
- static_cast<ShellContentBrowserClient*>(
- GetContentClient()->browser())->browser_context();
+ ShellContentBrowserClient::Get()->browser_context();
Shell::CreateNewWindow(browser_context,
params_.link_url,
NULL,
diff --git a/content/shell/webkit_test_controller.cc b/content/shell/webkit_test_controller.cc
index bbc644d..4f604c3 100644
--- a/content/shell/webkit_test_controller.cc
+++ b/content/shell/webkit_test_controller.cc
@@ -205,9 +205,8 @@ bool WebKitTestController::PrepareForLayoutTest(
expected_pixel_hash_ = expected_pixel_hash;
test_url_ = test_url;
printer_->reset();
- content::ShellBrowserContext* browser_context =
- static_cast<content::ShellContentBrowserClient*>(
- content::GetContentClient()->browser())->browser_context();
+ ShellBrowserContext* browser_context =
+ ShellContentBrowserClient::Get()->browser_context();
if (test_url.spec().find("compositing/") != std::string::npos)
is_compositing_test_ = true;
gfx::Size initial_size(kTestWindowWidthDip, kTestWindowHeightDip);
diff --git a/content/test/content_browser_test.cc b/content/test/content_browser_test.cc
index aa91303..90e4d8c 100644
--- a/content/test/content_browser_test.cc
+++ b/content/test/content_browser_test.cc
@@ -60,8 +60,7 @@ void ContentBrowserTest::SetUp() {
// and set up renderer.
if (command_line->HasSwitch(switches::kSingleProcess)) {
single_process_renderer_client_.reset(new ShellContentRendererClient);
- GetContentClient()->set_renderer_for_testing(
- single_process_renderer_client_.get());
+ SetRendererClientForTesting(single_process_renderer_client_.get());
}
#if defined(OS_MACOSX)
@@ -131,10 +130,8 @@ void ContentBrowserTest::RunTestOnMainThreadLoop() {
}
Shell* ContentBrowserTest::CreateBrowser() {
- ShellContentBrowserClient* browser_client =
- static_cast<ShellContentBrowserClient*>(GetContentClient()->browser());
return Shell::CreateNewWindow(
- browser_client->browser_context(),
+ ShellContentBrowserClient::Get()->browser_context(),
GURL(chrome::kAboutBlankURL),
NULL,
MSG_ROUTING_NONE,
@@ -142,10 +139,8 @@ Shell* ContentBrowserTest::CreateBrowser() {
}
Shell* ContentBrowserTest::CreateOffTheRecordBrowser() {
- ShellContentBrowserClient* browser_client =
- static_cast<ShellContentBrowserClient*>(GetContentClient()->browser());
return Shell::CreateNewWindow(
- browser_client->off_the_record_browser_context(),
+ ShellContentBrowserClient::Get()->off_the_record_browser_context(),
GURL(chrome::kAboutBlankURL),
NULL,
MSG_ROUTING_NONE,
diff --git a/content/test/content_test_launcher.cc b/content/test/content_test_launcher.cc
index aa1f362..2a662e7 100644
--- a/content/test/content_test_launcher.cc
+++ b/content/test/content_test_launcher.cc
@@ -36,15 +36,13 @@ class ContentShellTestSuiteInitializer
}
virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE {
- DCHECK(!GetContentClient());
content_client_.reset(new ShellContentClient);
browser_content_client_.reset(new ShellContentBrowserClient());
- content_client_->set_browser_for_testing(browser_content_client_.get());
SetContentClient(content_client_.get());
+ SetBrowserClientForTesting(browser_content_client_.get());
}
virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE {
- DCHECK_EQ(content_client_.get(), GetContentClient());
browser_content_client_.reset();
content_client_.reset();
SetContentClient(NULL);
diff --git a/content/test/webrtc_audio_device_test.cc b/content/test/webrtc_audio_device_test.cc
index 1ebcce9..c206283 100644
--- a/content/test/webrtc_audio_device_test.cc
+++ b/content/test/webrtc_audio_device_test.cc
@@ -87,12 +87,11 @@ class WebRTCMockRenderProcess : public RenderProcess {
class ReplaceContentClientRenderer {
public:
explicit ReplaceContentClientRenderer(ContentRendererClient* new_renderer) {
- saved_renderer_ = GetContentClient()->renderer();
- GetContentClient()->set_renderer_for_testing(new_renderer);
+ saved_renderer_ = SetRendererClientForTesting(new_renderer);
}
~ReplaceContentClientRenderer() {
// Restore the original renderer.
- GetContentClient()->set_renderer_for_testing(saved_renderer_);
+ SetRendererClientForTesting(saved_renderer_);
}
private:
ContentRendererClient* saved_renderer_;