diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-04 17:07:42 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-04 17:07:42 +0000 |
commit | 8a39b47ee588b1ddc3c2996b8e5c0f400e68c989 (patch) | |
tree | fede0e6391363a92860103f206659b9fe6ec7bdb | |
parent | 8bb46c251e7121e5eee3cb17e4fc3f2edc741462 (diff) | |
download | chromium_src-8a39b47ee588b1ddc3c2996b8e5c0f400e68c989.zip chromium_src-8a39b47ee588b1ddc3c2996b8e5c0f400e68c989.tar.gz chromium_src-8a39b47ee588b1ddc3c2996b8e5c0f400e68c989.tar.bz2 |
Cleanup: Get rid of Profile::GetProtocolHandlerRegistry().
Review URL: https://chromiumcodereview.appspot.com/13446007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192349 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc | 10 | ||||
-rw-r--r-- | chrome/browser/profiles/off_the_record_profile_impl.cc | 4 | ||||
-rw-r--r-- | chrome/browser/profiles/off_the_record_profile_impl.h | 1 | ||||
-rw-r--r-- | chrome/browser/profiles/profile.h | 4 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_impl.cc | 11 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_impl.h | 1 | ||||
-rw-r--r-- | chrome/browser/tab_contents/render_view_context_menu.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 21 | ||||
-rw-r--r-- | chrome/browser/ui/startup/startup_browser_creator_impl.cc | 6 | ||||
-rw-r--r-- | chrome/browser/ui/webui/options/content_settings_handler.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/webui/options/handler_options_handler.cc | 4 | ||||
-rw-r--r-- | chrome/test/base/testing_profile.cc | 18 | ||||
-rw-r--r-- | chrome/test/base/testing_profile.h | 4 |
13 files changed, 34 insertions, 58 deletions
diff --git a/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc b/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc index 6d12e4d..1a66a43 100644 --- a/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc +++ b/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc @@ -8,6 +8,7 @@ #include "base/string16.h" #include "base/utf_string_conversions.h" #include "chrome/app/chrome_command_ids.h" +#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" #include "chrome/browser/tab_contents/render_view_context_menu.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" @@ -72,7 +73,7 @@ class RegisterProtocolHandlerBrowserTest : public InProcessBrowserTest { ProtocolHandler handler = ProtocolHandler::CreateProtocolHandler( protocol, url, title); ProtocolHandlerRegistry* registry = - browser()->profile()->GetProtocolHandlerRegistry(); + ProtocolHandlerRegistryFactory::GetForProfile(browser()->profile()); // Fake that this registration is happening on profile startup. Otherwise // it'll try to register with the OS, which causes DCHECKs on Windows when // running as admin on Windows 7. @@ -81,7 +82,6 @@ class RegisterProtocolHandlerBrowserTest : public InProcessBrowserTest { registry->is_loading_ = false; ASSERT_TRUE(registry->IsHandledProtocol(protocol)); } - }; IN_PROC_BROWSER_TEST_F(RegisterProtocolHandlerBrowserTest, @@ -94,9 +94,9 @@ IN_PROC_BROWSER_TEST_F(RegisterProtocolHandlerBrowserTest, GURL("http://www.google.com/%s"), UTF8ToUTF16(std::string("Test handler"))); GURL url("web+search:testing"); - ASSERT_EQ(1u, - browser()->profile()->GetProtocolHandlerRegistry()->GetHandlersFor( - url.scheme()).size()); + ProtocolHandlerRegistry* registry = + ProtocolHandlerRegistryFactory::GetForProfile(browser()->profile()); + ASSERT_EQ(1u, registry->GetHandlersFor(url.scheme()).size()); menu.reset(CreateContextMenu(url)); ASSERT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKWITH)); } diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc index d2ecc14..c40ae06 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.cc +++ b/chrome/browser/profiles/off_the_record_profile_impl.cc @@ -337,10 +337,6 @@ quota::SpecialStoragePolicy* return GetExtensionSpecialStoragePolicy(); } -ProtocolHandlerRegistry* OffTheRecordProfileImpl::GetProtocolHandlerRegistry() { - return profile_->GetProtocolHandlerRegistry(); -} - bool OffTheRecordProfileImpl::IsSameProfile(Profile* profile) { return (profile == this) || (profile == profile_); } diff --git a/chrome/browser/profiles/off_the_record_profile_impl.h b/chrome/browser/profiles/off_the_record_profile_impl.h index eb407d8..9e549cd 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.h +++ b/chrome/browser/profiles/off_the_record_profile_impl.h @@ -58,7 +58,6 @@ class OffTheRecordProfileImpl : public Profile { content::ProtocolHandlerMap* protocol_handlers) OVERRIDE; virtual net::SSLConfigService* GetSSLConfigService() OVERRIDE; virtual HostContentSettingsMap* GetHostContentSettingsMap() OVERRIDE; - virtual ProtocolHandlerRegistry* GetProtocolHandlerRegistry() OVERRIDE; virtual bool IsSameProfile(Profile* profile) OVERRIDE; virtual Time GetStartTime() const OVERRIDE; virtual history::TopSites* GetTopSitesWithoutCreating() OVERRIDE; diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h index 949a7e5..0bee85a 100644 --- a/chrome/browser/profiles/profile.h +++ b/chrome/browser/profiles/profile.h @@ -234,10 +234,6 @@ class Profile : public content::BrowserContext { // Returns the Hostname <-> Content settings map for this profile. virtual HostContentSettingsMap* GetHostContentSettingsMap() = 0; - // Returns the ProtocolHandlerRegistry, creating if not yet created. - // TODO(smckay): replace this with access via ProtocolHandlerRegistryFactory. - virtual ProtocolHandlerRegistry* GetProtocolHandlerRegistry() = 0; - // Return whether 2 profiles are the same. 2 profiles are the same if they // represent the same profile. This can happen if there is pointer equality // or if one profile is the incognito version of another profile (or vice diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index 8cff519..f99cbba 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -29,8 +29,6 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/content_settings/cookie_settings.h" #include "chrome/browser/content_settings/host_content_settings_map.h" -#include "chrome/browser/custom_handlers/protocol_handler_registry.h" -#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" #include "chrome/browser/download/chrome_download_manager_delegate.h" #include "chrome/browser/download/download_service.h" #include "chrome/browser/download/download_service_factory.h" @@ -569,7 +567,6 @@ void ProfileImpl::DoFinalInit(bool is_new_profile) { model->AddObserver(new BookmarkModelLoadedObserver(this)); } #endif - } void ProfileImpl::InitHostZoomMap() { @@ -924,14 +921,6 @@ quota::SpecialStoragePolicy* ProfileImpl::GetSpecialStoragePolicy() { return GetExtensionSpecialStoragePolicy(); } -ProtocolHandlerRegistry* ProfileImpl::GetProtocolHandlerRegistry() { - // TODO(smckay): Update all existing callers to use - // ProtocolHandlerRegistryFactory. Once that's done, this method - // can be nuked from Profile and ProfileImpl. - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - return ProtocolHandlerRegistryFactory::GetForProfile(this); -} - bool ProfileImpl::IsSameProfile(Profile* profile) { if (profile == static_cast<Profile*>(this)) return true; diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h index 07a3944..7a58dd3 100644 --- a/chrome/browser/profiles/profile_impl.h +++ b/chrome/browser/profiles/profile_impl.h @@ -103,7 +103,6 @@ class ProfileImpl : public Profile { GetRequestContextForExtensions() OVERRIDE; virtual net::SSLConfigService* GetSSLConfigService() OVERRIDE; virtual HostContentSettingsMap* GetHostContentSettingsMap() OVERRIDE; - virtual ProtocolHandlerRegistry* GetProtocolHandlerRegistry() OVERRIDE; virtual bool IsSameProfile(Profile* profile) OVERRIDE; virtual base::Time GetStartTime() const OVERRIDE; virtual net::URLRequestContextGetter* CreateRequestContext( diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index 6cad698..864f086 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -23,6 +23,7 @@ #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" #include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" #include "chrome/browser/devtools/devtools_window.h" #include "chrome/browser/download/download_service.h" #include "chrome/browser/download/download_service_factory.h" @@ -268,7 +269,8 @@ RenderViewContextMenu::RenderViewContextMenu( external_(false), ALLOW_THIS_IN_INITIALIZER_LIST(speech_input_submenu_model_(this)), ALLOW_THIS_IN_INITIALIZER_LIST(protocol_handler_submenu_model_(this)), - protocol_handler_registry_(profile_->GetProtocolHandlerRegistry()) { + protocol_handler_registry_( + ProtocolHandlerRegistryFactory::GetForProfile(profile_)) { } RenderViewContextMenu::~RenderViewContextMenu() { diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 3520d66..2ddc24e 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -41,6 +41,7 @@ #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h" +#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.h" #include "chrome/browser/devtools/devtools_toggle_action.h" #include "chrome/browser/devtools/devtools_window.h" @@ -868,13 +869,13 @@ void Browser::RegisterProtocolHandlerHelper(WebContents* web_contents, ProtocolHandler handler = ProtocolHandler::CreateProtocolHandler(protocol, url, title); - ProtocolHandlerRegistry* registry = profile->GetProtocolHandlerRegistry(); - TabSpecificContentSettings* tab_content_settings = - TabSpecificContentSettings::FromWebContents(web_contents); - + ProtocolHandlerRegistry* registry = + ProtocolHandlerRegistryFactory::GetForProfile(profile); if (registry->SilentlyHandleRegisterHandlerRequest(handler)) return; + TabSpecificContentSettings* tab_content_settings = + TabSpecificContentSettings::FromWebContents(web_contents); if (!user_gesture && window) { tab_content_settings->set_pending_protocol_handler(handler); tab_content_settings->set_previous_protocol_handler( @@ -1731,13 +1732,13 @@ void Browser::Observe(int type, if (window()->GetLocationBar()) window()->GetLocationBar()->UpdatePageActions(); + const extensions::UnloadedExtensionInfo* extension_info = + content::Details<extensions::UnloadedExtensionInfo>(details).ptr(); + // Close any tabs from the unloaded extension, unless it's terminated, // in which case let the sad tabs remain. - if (content::Details<extensions::UnloadedExtensionInfo>( - details)->reason != extension_misc::UNLOAD_REASON_TERMINATE) { - const Extension* extension = - content::Details<extensions::UnloadedExtensionInfo>( - details)->extension; + if (extension_info->reason != extension_misc::UNLOAD_REASON_TERMINATE) { + const Extension* extension = extension_info->extension; // Iterate backwards as we may remove items while iterating. for (int i = tab_strip_model_->count() - 1; i >= 0; --i) { WebContents* web_contents = tab_strip_model_->GetWebContentsAt(i); @@ -1770,7 +1771,7 @@ void Browser::Observe(int type, // During window creation on Windows we may end up calling into // SHAppBarMessage, which internally spawns a nested message loop. This // makes it possible for us to end up here before window creation has - // completed,at which point window_ is NULL. See 94752 for details. + // completed, at which point window_ is NULL. See 94752 for details. if (window() && window()->GetLocationBar()) window()->GetLocationBar()->UpdatePageActions(); break; diff --git a/chrome/browser/ui/startup/startup_browser_creator_impl.cc b/chrome/browser/ui/startup/startup_browser_creator_impl.cc index 4eec6c8..3f6d37c 100644 --- a/chrome/browser/ui/startup/startup_browser_creator_impl.cc +++ b/chrome/browser/ui/startup/startup_browser_creator_impl.cc @@ -27,6 +27,7 @@ #include "chrome/browser/auto_launch_trial.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h" +#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" #include "chrome/browser/defaults.h" #include "chrome/browser/extensions/extension_creator.h" #include "chrome/browser/extensions/extension_service.h" @@ -827,14 +828,15 @@ Browser* StartupBrowserCreatorImpl::OpenTabsInBrowser(Browser* browser, chrome::ToggleFullscreenMode(browser); bool first_tab = true; + ProtocolHandlerRegistry* registry = profile_ ? + ProtocolHandlerRegistryFactory::GetForProfile(profile_) : NULL; for (size_t i = 0; i < tabs.size(); ++i) { // We skip URLs that we'd have to launch an external protocol handler for. // This avoids us getting into an infinite loop asking ourselves to open // a URL, should the handler be (incorrectly) configured to be us. Anyone // asking us to open such a URL should really ask the handler directly. bool handled_by_chrome = ProfileIOData::IsHandledURL(tabs[i].url) || - (profile_ && profile_->GetProtocolHandlerRegistry()->IsHandledProtocol( - tabs[i].url.scheme())); + (registry && registry->IsHandledProtocol(tabs[i].url.scheme())); if (!process_startup && !handled_by_chrome) continue; diff --git a/chrome/browser/ui/webui/options/content_settings_handler.cc b/chrome/browser/ui/webui/options/content_settings_handler.cc index 04cee71..85249bc 100644 --- a/chrome/browser/ui/webui/options/content_settings_handler.cc +++ b/chrome/browser/ui/webui/options/content_settings_handler.cc @@ -18,6 +18,7 @@ #include "chrome/browser/content_settings/content_settings_utils.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h" +#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_special_storage_policy.h" #include "chrome/browser/notifications/desktop_notification_service.h" @@ -1301,7 +1302,8 @@ HostContentSettingsMap* ContentSettingsHandler::GetContentSettingsMap() { } ProtocolHandlerRegistry* ContentSettingsHandler::GetProtocolHandlerRegistry() { - return Profile::FromWebUI(web_ui())->GetProtocolHandlerRegistry(); + return ProtocolHandlerRegistryFactory::GetForProfile( + Profile::FromWebUI(web_ui())); } HostContentSettingsMap* diff --git a/chrome/browser/ui/webui/options/handler_options_handler.cc b/chrome/browser/ui/webui/options/handler_options_handler.cc index adbf8c8..ee52ee6 100644 --- a/chrome/browser/ui/webui/options/handler_options_handler.cc +++ b/chrome/browser/ui/webui/options/handler_options_handler.cc @@ -11,6 +11,7 @@ #include "base/prefs/pref_service.h" #include "base/utf_string_conversions.h" #include "base/values.h" +#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_notification_types.h" #include "content/public/browser/web_ui.h" @@ -83,7 +84,8 @@ void HandlerOptionsHandler::RegisterMessages() { } ProtocolHandlerRegistry* HandlerOptionsHandler::GetProtocolHandlerRegistry() { - return Profile::FromWebUI(web_ui())->GetProtocolHandlerRegistry(); + return ProtocolHandlerRegistryFactory::GetForProfile( + Profile::FromWebUI(web_ui())); } static void GetHandlersAsListValue( diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc index 9cdc621..fed2377 100644 --- a/chrome/test/base/testing_profile.cc +++ b/chrome/test/base/testing_profile.cc @@ -398,23 +398,19 @@ static ProfileKeyedService* BuildBookmarkModel(Profile* profile) { void TestingProfile::CreateBookmarkModel(bool delete_file) { - if (delete_file) { - base::FilePath path = GetPath(); - path = path.Append(chrome::kBookmarksFileName); + base::FilePath path = GetPath().Append(chrome::kBookmarksFileName); file_util::Delete(path, false); } // This will create a bookmark model. - BookmarkModel* bookmark_service = - static_cast<BookmarkModel*>( - BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse( - this, BuildBookmarkModel)); + BookmarkModel* bookmark_service = static_cast<BookmarkModel*>( + BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse( + this, BuildBookmarkModel)); HistoryService* history_service = HistoryServiceFactory::GetForProfileWithoutCreating(this); if (history_service) { - history_service->history_backend_->bookmark_service_ = - bookmark_service; + history_service->history_backend_->bookmark_service_ = bookmark_service; history_service->history_backend_->expirer_.bookmark_service_ = bookmark_service; } @@ -696,10 +692,6 @@ base::Time TestingProfile::GetStartTime() const { return start_time_; } -ProtocolHandlerRegistry* TestingProfile::GetProtocolHandlerRegistry() { - return NULL; -} - base::FilePath TestingProfile::last_selected_directory() { return last_selected_directory_; } diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h index 0bf7716..26ea838 100644 --- a/chrome/test/base/testing_profile.h +++ b/chrome/test/base/testing_profile.h @@ -10,8 +10,6 @@ #include "base/files/scoped_temp_dir.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "base/timer.h" -#include "chrome/browser/custom_handlers/protocol_handler_registry.h" #include "chrome/browser/profiles/profile.h" namespace content { @@ -254,8 +252,6 @@ class TestingProfile : public Profile { virtual void MergeResourceBoolean(int message_id, bool* output_value) {} virtual bool IsSameProfile(Profile *p) OVERRIDE; virtual base::Time GetStartTime() const OVERRIDE; - virtual ProtocolHandlerRegistry* GetProtocolHandlerRegistry() OVERRIDE; - virtual base::FilePath last_selected_directory() OVERRIDE; virtual void set_last_selected_directory(const base::FilePath& path) OVERRIDE; virtual bool WasCreatedByVersionOrLater(const std::string& version) OVERRIDE; |