diff options
Diffstat (limited to 'chrome/browser')
15 files changed, 66 insertions, 76 deletions
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); } |