diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-20 15:48:53 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-20 15:48:53 +0000 |
commit | 9abfa1903f72e0735c9c1ef6570eef94f26eb4a7 (patch) | |
tree | 0a9cc60eebf84295d1a0dd5896d80f96b9461f75 | |
parent | 056f879b0a2a3281818bda56011081a6c683208e (diff) | |
download | chromium_src-9abfa1903f72e0735c9c1ef6570eef94f26eb4a7.zip chromium_src-9abfa1903f72e0735c9c1ef6570eef94f26eb4a7.tar.gz chromium_src-9abfa1903f72e0735c9c1ef6570eef94f26eb4a7.tar.bz2 |
Deprecate Profile::GetDefaultRequestContext().
Make it private and establish a friend whitelist for existing users.
BUG=64339
TEST=none
Review URL: http://codereview.chromium.org/7438002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93200 0039d316-1c4b-4281-b951-d872f2087c98
21 files changed, 104 insertions, 42 deletions
diff --git a/chrome/browser/autofill/autofill_download.cc b/chrome/browser/autofill/autofill_download.cc index bc5fd17..7664210 100644 --- a/chrome/browser/autofill/autofill_download.cc +++ b/chrome/browser/autofill/autofill_download.cc @@ -186,7 +186,7 @@ bool AutofillDownloadManager::StartRequest( const std::string& form_xml, const FormRequestData& request_data) { net::URLRequestContextGetter* request_context = - Profile::GetDefaultRequestContext(); + Profile::Deprecated::GetDefaultRequestContext(); // Check if default request context is NULL: this very rarely happens, // I think, this could happen only if user opens chrome with some pages // loading the forms immediately; I cannot reproduce this even in that diff --git a/chrome/browser/chrome_plugin_message_filter.cc b/chrome/browser/chrome_plugin_message_filter.cc index a41d1d6..d38436f 100644 --- a/chrome/browser/chrome_plugin_message_filter.cc +++ b/chrome/browser/chrome_plugin_message_filter.cc @@ -45,7 +45,7 @@ void ChromePluginMessageFilter::OnDownloadUrl(const std::string& url, PluginDownloadUrlHelper* download_url_helper = new PluginDownloadUrlHelper(url, caller_window, NULL); download_url_helper->InitiateDownload( - Profile::GetDefaultRequestContext()->GetURLRequestContext()); + Profile::Deprecated::GetDefaultRequestContext()->GetURLRequestContext()); } #endif diff --git a/chrome/browser/chromeos/cros/libcros_service_library.cc b/chrome/browser/chromeos/cros/libcros_service_library.cc index b4f2b32..7376821 100644 --- a/chrome/browser/chromeos/cros/libcros_service_library.cc +++ b/chrome/browser/chromeos/cros/libcros_service_library.cc @@ -206,7 +206,8 @@ void LibCrosServiceLibraryImpl::NetworkProxyLibrary::ResolveProxy( &NetworkProxyLibrary::NotifyProxyResolved, request); // Retrieve ProxyService from profile's request context. - net::URLRequestContextGetter* getter = Profile::GetDefaultRequestContext(); + net::URLRequestContextGetter* getter = + Profile::Deprecated::GetDefaultRequestContext(); net::ProxyService* proxy_service = NULL; if (getter) proxy_service = getter->GetURLRequestContext()->proxy_service(); @@ -311,4 +312,3 @@ LibCrosServiceLibrary* LibCrosServiceLibrary::GetImpl(bool stub) { DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::LibCrosServiceLibraryImpl); DISABLE_RUNNABLE_METHOD_REFCOUNT( chromeos::LibCrosServiceLibraryImpl::NetworkProxyLibrary); - diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc index 4623533..c66571e 100644 --- a/chrome/browser/chromeos/login/login_utils.cc +++ b/chrome/browser/chromeos/login/login_utils.cc @@ -80,6 +80,8 @@ const char kSwitchFormatString[] = " --%s=\"%s\""; // User name which is used in the Guest session. const char kGuestUserName[] = ""; +} // namespace + // Resets the proxy configuration service for the default request context. class ResetDefaultProxyConfigServiceTask : public Task { public: @@ -91,7 +93,10 @@ class ResetDefaultProxyConfigServiceTask : public Task { // Task override. virtual void Run() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - net::URLRequestContextGetter* getter = Profile::GetDefaultRequestContext(); + // TODO(willchan): Move this class back into the anonymous namespace after + // we stop using this deprecated API. + net::URLRequestContextGetter* getter = + Profile::Deprecated::GetDefaultRequestContext(); DCHECK(getter); if (getter) { getter->GetURLRequestContext()->proxy_service()->ResetConfigService( @@ -147,8 +152,6 @@ class TransferDefaultCookiesOnIOThreadTask : public Task { DISALLOW_COPY_AND_ASSIGN(TransferDefaultCookiesOnIOThreadTask); }; -} // namespace - class LoginUtilsImpl : public LoginUtils, public ProfileManagerObserver { public: diff --git a/chrome/browser/importer/toolbar_importer.cc b/chrome/browser/importer/toolbar_importer.cc index 44a512d..a2b3251 100644 --- a/chrome/browser/importer/toolbar_importer.cc +++ b/chrome/browser/importer/toolbar_importer.cc @@ -209,7 +209,8 @@ void Toolbar5Importer::GetAuthenticationFromServer() { GURL url(url_string); token_fetcher_ = new URLFetcher(url, URLFetcher::GET, this); - token_fetcher_->set_request_context(Profile::GetDefaultRequestContext()); + token_fetcher_->set_request_context( + Profile::Deprecated::GetDefaultRequestContext()); token_fetcher_->Start(); } @@ -242,7 +243,8 @@ void Toolbar5Importer::GetBookmarkDataFromServer(const std::string& response) { GURL url(conn_string); data_fetcher_ = new URLFetcher(url, URLFetcher::GET, this); - data_fetcher_->set_request_context(Profile::GetDefaultRequestContext()); + data_fetcher_->set_request_context( + Profile::Deprecated::GetDefaultRequestContext()); data_fetcher_->Start(); } diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc index e5fbe6f..647ca99 100644 --- a/chrome/browser/metrics/metrics_service.cc +++ b/chrome/browser/metrics/metrics_service.cc @@ -1268,7 +1268,8 @@ void MetricsService::PrepareFetchWithPendingLog() { current_fetch_.reset(new URLFetcher(GURL(WideToUTF16(server_url_)), URLFetcher::POST, this)); - current_fetch_->set_request_context(Profile::GetDefaultRequestContext()); + current_fetch_->set_request_context( + Profile::Deprecated::GetDefaultRequestContext()); current_fetch_->set_upload_data(kMetricsType, compressed_log_); } diff --git a/chrome/browser/net/preconnect.cc b/chrome/browser/net/preconnect.cc index b5fd87b..e85a326 100644 --- a/chrome/browser/net/preconnect.cc +++ b/chrome/browser/net/preconnect.cc @@ -37,7 +37,8 @@ void PreconnectOnIOThread( const GURL& url, UrlInfo::ResolutionMotivation motivation, int count) { - net::URLRequestContextGetter* getter = Profile::GetDefaultRequestContext(); + net::URLRequestContextGetter* getter = + Profile::Deprecated::GetDefaultRequestContext(); if (!getter) return; if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { diff --git a/chrome/browser/net/sdch_dictionary_fetcher.cc b/chrome/browser/net/sdch_dictionary_fetcher.cc index 90f317a..6fc5bde 100644 --- a/chrome/browser/net/sdch_dictionary_fetcher.cc +++ b/chrome/browser/net/sdch_dictionary_fetcher.cc @@ -53,7 +53,8 @@ void SdchDictionaryFetcher::StartFetching() { DCHECK(task_is_pending_); task_is_pending_ = false; - net::URLRequestContextGetter* context = Profile::GetDefaultRequestContext(); + net::URLRequestContextGetter* context = + Profile::Deprecated::GetDefaultRequestContext(); if (!context) { // Shutdown in progress. // Simulate handling of all dictionary requests by clearing queue. diff --git a/chrome/browser/net/websocket_experiment/websocket_experiment_task.cc b/chrome/browser/net/websocket_experiment/websocket_experiment_task.cc index 6740e53..4933d40 100644 --- a/chrome/browser/net/websocket_experiment/websocket_experiment_task.cc +++ b/chrome/browser/net/websocket_experiment/websocket_experiment_task.cc @@ -35,10 +35,10 @@ static std::string GetProtocolVersionName( URLFetcher* WebSocketExperimentTask::Context::CreateURLFetcher( const Config& config, URLFetcher::Delegate* delegate) { net::URLRequestContextGetter* getter = - Profile::GetDefaultRequestContext(); - // Profile::GetDefaultRequestContext() is initialized lazily, on the UI - // thread. So here, where we access it from the IO thread, if the task runs - // before it has gotten lazily initialized yet. + Profile::Deprecated::GetDefaultRequestContext(); + // Profile::Deprecated::GetDefaultRequestContext() is initialized lazily, on + // the UI thread. So here, where we access it from the IO thread, if the task + // runs before it has gotten lazily initialized yet. if (!getter) return NULL; URLFetcher* fetcher = @@ -54,10 +54,10 @@ URLFetcher* WebSocketExperimentTask::Context::CreateURLFetcher( net::WebSocket* WebSocketExperimentTask::Context::CreateWebSocket( const Config& config, net::WebSocketDelegate* delegate) { net::URLRequestContextGetter* getter = - Profile::GetDefaultRequestContext(); - // Profile::GetDefaultRequestContext() is initialized lazily, on the UI - // thread. So here, where we access it from the IO thread, if the task runs - // before it has gotten lazily initialized yet. + Profile::Deprecated::GetDefaultRequestContext(); + // Profile::Deprecated::GetDefaultRequestContext() is initialized lazily, on + // the UI thread. So here, where we access it from the IO thread, if the task + // runs before it has gotten lazily initialized yet. if (!getter) return NULL; net::WebSocket::Request* request( diff --git a/chrome/browser/profiles/profile.cc b/chrome/browser/profiles/profile.cc index f82826c..20c5452 100644 --- a/chrome/browser/profiles/profile.cc +++ b/chrome/browser/profiles/profile.cc @@ -95,7 +95,7 @@ Profile::Profile() } // static -const char* Profile::kProfileKey = "__PROFILE__"; +const char* const Profile::kProfileKey = "__PROFILE__"; #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) // static diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h index 8d335b1..f02e925 100644 --- a/chrome/browser/profiles/profile.h +++ b/chrome/browser/profiles/profile.h @@ -12,12 +12,22 @@ #include "base/basictypes.h" #include "base/logging.h" +#include "chrome/browser/net/preconnect.h" // TODO: remove this. #include "chrome/common/extensions/extension.h" namespace base { class Time; } +namespace chrome_browser_net_websocket_experiment { +class WebSocketExperimentTask; +} + +namespace chromeos { +class LibCrosServiceLibraryImpl; +class ResetDefaultProxyConfigServiceTask; +} + namespace content { class ResourceContext; } @@ -45,6 +55,10 @@ namespace quota { class QuotaManager; } +namespace speech_input { +class SpeechRecognizer; +} + namespace webkit_database { class DatabaseTracker; } @@ -143,8 +157,40 @@ class Profile { virtual void OnProfileCreated(Profile* profile, bool success) = 0; }; + // Whitelist access to deprecated API in order to prevent new regressions. + class Deprecated { + private: + friend bool IsGoogleGAIACookieInstalled(); + friend void chrome_browser_net::PreconnectOnIOThread( + const GURL&, + chrome_browser_net::UrlInfo::ResolutionMotivation, + int); + + friend class AutofillDownloadManager; + friend class ChromePluginMessageFilter; + friend class DefaultGeolocationArbitratorDependencyFactory; + friend class DevToolsHttpProtocolHandler; + friend class DevToolsUI; + friend class LiveSyncTest; + friend class MetricsService; + friend class ResolveProxyMsgHelper; + friend class SafeBrowsingServiceTestHelper; + friend class SdchDictionaryFetcher; + friend class Toolbar5Importer; + friend class TranslateManager; + friend class + chrome_browser_net_websocket_experiment::WebSocketExperimentTask; + friend class chromeos::LibCrosServiceLibraryImpl; + friend class chromeos::ResetDefaultProxyConfigServiceTask; + friend class speech_input::SpeechRecognizer; + + static net::URLRequestContextGetter* GetDefaultRequestContext() { + return Profile::GetDefaultRequestContext(); + } + }; + // Key used to bind profile to the widget with which it is associated. - static const char* kProfileKey; + static const char* const kProfileKey; #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) // Value that represents no local profile id. @@ -165,12 +211,6 @@ class Profile { static Profile* CreateProfileAsync(const FilePath& path, Delegate* delegate); - // Returns the request context for the "default" profile. This may be called - // from any thread. This CAN return NULL if a first request context has not - // yet been created. If necessary, listen on the UI thread for - // NOTIFY_DEFAULT_REQUEST_CONTEXT_AVAILABLE. - static net::URLRequestContextGetter* GetDefaultRequestContext(); - // Returns the name associated with this profile. This name is displayed in // the browser frame. virtual std::string GetProfileName() = 0; @@ -568,6 +608,15 @@ class Profile { static net::URLRequestContextGetter* default_request_context_; private: + // ***DEPRECATED**: You should be passing in the specific profile's + // URLRequestContextGetter or using the system URLRequestContextGetter. + // + // Returns the request context for the "default" profile. This may be called + // from any thread. This CAN return NULL if a first request context has not + // yet been created. If necessary, listen on the UI thread for + // NOTIFY_DEFAULT_REQUEST_CONTEXT_AVAILABLE. + static net::URLRequestContextGetter* GetDefaultRequestContext(); + bool restored_last_session_; // Accessibility events will only be propagated when the pause diff --git a/chrome/browser/safe_browsing/safe_browsing_test.cc b/chrome/browser/safe_browsing/safe_browsing_test.cc index 826db15..0a82907 100644 --- a/chrome/browser/safe_browsing/safe_browsing_test.cc +++ b/chrome/browser/safe_browsing/safe_browsing_test.cc @@ -526,7 +526,8 @@ class SafeBrowsingServiceTestHelper net::URLRequestStatus::Status FetchUrl(const GURL& url) { url_fetcher_.reset(new URLFetcher(url, URLFetcher::GET, this)); url_fetcher_->set_load_flags(net::LOAD_DISABLE_CACHE); - url_fetcher_->set_request_context(Profile::GetDefaultRequestContext()); + url_fetcher_->set_request_context( + Profile::Deprecated::GetDefaultRequestContext()); url_fetcher_->Start(); ui_test_utils::RunMessageLoop(); return response_status_; diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc index 1fcf475..34f1b64 100644 --- a/chrome/browser/translate/translate_manager.cc +++ b/chrome/browser/translate/translate_manager.cc @@ -59,7 +59,7 @@ namespace { // mr Marathi // ta Tamil // te Telugu -const char* kSupportedLanguages[] = { +const char* const kSupportedLanguages[] = { "af", // Afrikaans "az", // Azerbaijani "sq", // Albanian @@ -721,7 +721,7 @@ void TranslateManager::FetchLanguageListFromTranslateServer( language_list_request_pending_.reset(URLFetcher::Create( 1, GURL(kLanguageListFetchURL), URLFetcher::GET, this)); language_list_request_pending_->set_request_context( - Profile::GetDefaultRequestContext()); + Profile::Deprecated::GetDefaultRequestContext()); language_list_request_pending_->set_max_retries(kMaxRetryLanguageListFetch); language_list_request_pending_->Start(); } @@ -738,7 +738,7 @@ void TranslateManager::RequestTranslateScript() { translate_script_request_pending_.reset(URLFetcher::Create( 0, GURL(kTranslateScriptURL), URLFetcher::GET, this)); translate_script_request_pending_->set_request_context( - Profile::GetDefaultRequestContext()); + Profile::Deprecated::GetDefaultRequestContext()); translate_script_request_pending_->set_extra_request_headers( kTranslateScriptHeader); translate_script_request_pending_->Start(); diff --git a/chrome/browser/ui/webui/devtools_ui.cc b/chrome/browser/ui/webui/devtools_ui.cc index afe8e32..d340a72 100644 --- a/chrome/browser/ui/webui/devtools_ui.cc +++ b/chrome/browser/ui/webui/devtools_ui.cc @@ -91,7 +91,8 @@ void DevToolsUI::RegisterDevToolsDataSource() { if (!registered) { DevToolsDataSource* data_source = new DevToolsDataSource(); ChromeURLRequestContext* context = static_cast<ChromeURLRequestContext*>( - Profile::GetDefaultRequestContext()->GetURLRequestContext()); + Profile::Deprecated::GetDefaultRequestContext()-> + GetURLRequestContext()); context->chrome_url_data_manager_backend()->AddDataSource(data_source); registered = true; } diff --git a/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc b/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc index 217af76..0cf46ff 100644 --- a/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc +++ b/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc @@ -52,7 +52,8 @@ bool IsGoogleGAIACookieInstalled() { for (size_t i = 0; i < arraysize(kGAIACookieFilters); ++i) { // Since we are running on the UI thread don't call GetURLRequestContext(). net::CookieStore* store = - Profile::GetDefaultRequestContext()->DONTUSEME_GetCookieStore(); + Profile::Deprecated::GetDefaultRequestContext()-> + DONTUSEME_GetCookieStore(); GURL url(kGAIACookieFilters[i].url); net::CookieOptions options; options.set_include_httponly(); // The SID cookie might be httponly. diff --git a/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h b/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h index debb24f..2edc464 100644 --- a/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h +++ b/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.h @@ -68,4 +68,6 @@ class NewTabPageSyncHandler : public WebUIMessageHandler, DISALLOW_COPY_AND_ASSIGN(NewTabPageSyncHandler); }; +bool IsGoogleGAIACookieInstalled(); + #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_PAGE_SYNC_HANDLER_H_ diff --git a/chrome/test/live_sync/live_sync_test.cc b/chrome/test/live_sync/live_sync_test.cc index a47d67f..910c2f2 100644 --- a/chrome/test/live_sync/live_sync_test.cc +++ b/chrome/test/live_sync/live_sync_test.cc @@ -460,7 +460,7 @@ bool LiveSyncTest::IsTestServerRunning() { GURL sync_url_status(sync_url.append("/healthz")); SyncServerStatusChecker delegate; URLFetcher fetcher(sync_url_status, URLFetcher::GET, &delegate); - fetcher.set_request_context(Profile::GetDefaultRequestContext()); + fetcher.set_request_context(Profile::Deprecated::GetDefaultRequestContext()); fetcher.Start(); ui_test_utils::RunMessageLoop(); return delegate.running(); diff --git a/content/browser/debugger/devtools_http_protocol_handler.cc b/content/browser/debugger/devtools_http_protocol_handler.cc index 346b0c8..9852b65 100644 --- a/content/browser/debugger/devtools_http_protocol_handler.cc +++ b/content/browser/debugger/devtools_http_protocol_handler.cc @@ -182,7 +182,7 @@ void DevToolsHttpProtocolHandler::OnHttpRequest( } // Proxy static files from chrome-devtools://devtools/*. - if (!Profile::GetDefaultRequestContext()) { + if (!Profile::Deprecated::GetDefaultRequestContext()) { server_->Send404(connection_id); return; } @@ -211,7 +211,7 @@ void DevToolsHttpProtocolHandler::OnHttpRequest( DevToolsUI::RegisterDevToolsDataSource(); Bind(request, connection_id); request->set_context( - Profile::GetDefaultRequestContext()->GetURLRequestContext()); + Profile::Deprecated::GetDefaultRequestContext()->GetURLRequestContext()); request->Start(); } diff --git a/content/browser/geolocation/arbitrator_dependency_factory.cc b/content/browser/geolocation/arbitrator_dependency_factory.cc index 7dd9c34..547227a 100644 --- a/content/browser/geolocation/arbitrator_dependency_factory.cc +++ b/content/browser/geolocation/arbitrator_dependency_factory.cc @@ -16,7 +16,7 @@ GeolocationArbitratorDependencyFactory:: // DefaultGeolocationArbitratorDependencyFactory net::URLRequestContextGetter* DefaultGeolocationArbitratorDependencyFactory::GetContextGetter() { - return Profile::GetDefaultRequestContext(); + return Profile::Deprecated::GetDefaultRequestContext(); } DefaultGeolocationArbitratorDependencyFactory::GetTimeNow @@ -43,4 +43,3 @@ LocationProviderBase* DefaultGeolocationArbitratorDependencyFactory::NewSystemLocationProvider() { return ::NewSystemLocationProvider(); } - diff --git a/content/browser/resolve_proxy_msg_helper.cc b/content/browser/resolve_proxy_msg_helper.cc index edacad9..80ab29b 100644 --- a/content/browser/resolve_proxy_msg_helper.cc +++ b/content/browser/resolve_proxy_msg_helper.cc @@ -91,7 +91,7 @@ bool ResolveProxyMsgHelper::GetProxyService(net::ProxyService** out) const { // If there is no default request context (say during shut down). net::URLRequestContextGetter* context_getter = - Profile::GetDefaultRequestContext(); + Profile::Deprecated::GetDefaultRequestContext(); if (!context_getter) return false; @@ -104,7 +104,8 @@ ResolveProxyMsgHelper::~ResolveProxyMsgHelper() { // Clear all pending requests if the ProxyService is still alive (if we have a // default request context or override). if (!pending_requests_.empty() && - (Profile::GetDefaultRequestContext() || proxy_service_override_)) { + (Profile::Deprecated::GetDefaultRequestContext() || + proxy_service_override_)) { PendingRequest req = pending_requests_.front(); proxy_service_->CancelPacRequest(req.pac_req); } diff --git a/content/browser/speech/speech_recognizer.cc b/content/browser/speech/speech_recognizer.cc index 9408f46..3c44401 100644 --- a/content/browser/speech/speech_recognizer.cc +++ b/content/browser/speech/speech_recognizer.cc @@ -222,7 +222,7 @@ void SpeechRecognizer::HandleOnData(string* data) { // server to send the data and inform the delegate. delegate_->DidStartReceivingAudio(caller_id_); request_.reset(new SpeechRecognitionRequest( - Profile::GetDefaultRequestContext(), this)); + Profile::Deprecated::GetDefaultRequestContext(), this)); request_->Start(language_, grammar_, hardware_info_, origin_url_, encoder_->mime_type()); } |