diff options
16 files changed, 79 insertions, 68 deletions
diff --git a/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc b/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc index 811a896..c64520f 100644 --- a/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc +++ b/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc @@ -33,8 +33,8 @@ ChromeAutocompleteSchemeClassifier::GetInputTypeForScheme( // Also check for schemes registered via registerProtocolHandler(), which // can be handled by web pages/apps. - ProtocolHandlerRegistry* registry = - profile_ ? ProtocolHandlerRegistryFactory::GetForProfile(profile_) : NULL; + ProtocolHandlerRegistry* registry = profile_ ? + ProtocolHandlerRegistryFactory::GetForBrowserContext(profile_) : NULL; if (registry && registry->IsHandledProtocol(scheme)) return metrics::OmniboxInputType::URL; diff --git a/chrome/browser/custom_handlers/protocol_handler_registry.cc b/chrome/browser/custom_handlers/protocol_handler_registry.cc index 7ed6e28..74188c62 100644 --- a/chrome/browser/custom_handlers/protocol_handler_registry.cc +++ b/chrome/browser/custom_handlers/protocol_handler_registry.cc @@ -12,12 +12,11 @@ #include "base/prefs/pref_service.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.h" -#include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/profiles/profile_io_data.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/custom_handlers/protocol_handler.h" #include "chrome/common/pref_names.h" #include "components/pref_registry/pref_registry_syncable.h" +#include "components/user_prefs/user_prefs.h" #include "content/public/browser/child_process_security_policy.h" #include "grit/generated_resources.h" #include "net/base/network_delegate.h" @@ -309,9 +308,9 @@ void ProtocolHandlerRegistry::Delegate::RegisterWithOSAsDefaultClient( // ProtocolHandlerRegistry ----------------------------------------------------- -ProtocolHandlerRegistry::ProtocolHandlerRegistry(Profile* profile, - Delegate* delegate) - : profile_(profile), +ProtocolHandlerRegistry::ProtocolHandlerRegistry( + content::BrowserContext* context, Delegate* delegate) + : context_(context), delegate_(delegate), enabled_(true), is_loading_(false), @@ -435,7 +434,7 @@ void ProtocolHandlerRegistry::InitProtocolSettings() { is_loaded_ = true; is_loading_ = true; - PrefService* prefs = profile_->GetPrefs(); + PrefService* prefs = user_prefs::UserPrefs::Get(context_); if (prefs->HasPrefPath(prefs::kCustomHandlersEnabled)) { if (prefs->GetBoolean(prefs::kCustomHandlersEnabled)) { Enable(); @@ -739,11 +738,13 @@ void ProtocolHandlerRegistry::Save() { scoped_ptr<base::Value> registered_protocol_handlers( EncodeRegisteredHandlers()); scoped_ptr<base::Value> ignored_protocol_handlers(EncodeIgnoredHandlers()); - profile_->GetPrefs()->Set(prefs::kRegisteredProtocolHandlers, + PrefService* prefs = user_prefs::UserPrefs::Get(context_); + + prefs->Set(prefs::kRegisteredProtocolHandlers, *registered_protocol_handlers); - profile_->GetPrefs()->Set(prefs::kIgnoredProtocolHandlers, + prefs->Set(prefs::kIgnoredProtocolHandlers, *ignored_protocol_handlers); - profile_->GetPrefs()->SetBoolean(prefs::kCustomHandlersEnabled, enabled_); + prefs->SetBoolean(prefs::kCustomHandlersEnabled, enabled_); } const ProtocolHandlerRegistry::ProtocolHandlerList* @@ -823,7 +824,7 @@ void ProtocolHandlerRegistry::NotifyChanged() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); content::NotificationService::current()->Notify( chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, - content::Source<Profile>(profile_), + content::Source<content::BrowserContext>(context_), content::NotificationService::NoDetails()); } @@ -850,7 +851,7 @@ std::vector<const base::DictionaryValue*> ProtocolHandlerRegistry::GetHandlersFromPref(const char* pref_name) const { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); std::vector<const base::DictionaryValue*> result; - PrefService* prefs = profile_->GetPrefs(); + PrefService* prefs = user_prefs::UserPrefs::Get(context_); if (!prefs->HasPrefPath(pref_name)) { return result; } diff --git a/chrome/browser/custom_handlers/protocol_handler_registry.h b/chrome/browser/custom_handlers/protocol_handler_registry.h index f381bd2..724c591 100644 --- a/chrome/browser/custom_handlers/protocol_handler_registry.h +++ b/chrome/browser/custom_handlers/protocol_handler_registry.h @@ -137,7 +137,7 @@ class ProtocolHandlerRegistry : public KeyedService { typedef std::vector<DefaultClientObserver*> DefaultClientObserverList; // Creates a new instance. Assumes ownership of |delegate|. - ProtocolHandlerRegistry(Profile* profile, Delegate* delegate); + ProtocolHandlerRegistry(content::BrowserContext* context, Delegate* delegate); virtual ~ProtocolHandlerRegistry(); // Returns a net::URLRequestJobFactory suitable for use on the IO thread, but @@ -349,8 +349,8 @@ class ProtocolHandlerRegistry : public KeyedService { // Protocol handlers that are the defaults for a given protocol. ProtocolHandlerMap default_handlers_; - // The Profile that owns this ProtocolHandlerRegistry. - Profile* profile_; + // The browser context that owns this ProtocolHandlerRegistry. + content::BrowserContext* context_; // The Delegate that registers / deregisters external handlers on our behalf. scoped_ptr<Delegate> delegate_; diff --git a/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc b/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc index 96753db..9a0f518 100644 --- a/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc +++ b/chrome/browser/custom_handlers/protocol_handler_registry_browsertest.cc @@ -50,7 +50,8 @@ class RegisterProtocolHandlerBrowserTest : public InProcessBrowserTest { ProtocolHandler handler = ProtocolHandler::CreateProtocolHandler(protocol, url); ProtocolHandlerRegistry* registry = - ProtocolHandlerRegistryFactory::GetForProfile(browser()->profile()); + ProtocolHandlerRegistryFactory::GetForBrowserContext( + 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. @@ -64,7 +65,8 @@ class RegisterProtocolHandlerBrowserTest : public InProcessBrowserTest { ProtocolHandler handler = ProtocolHandler::CreateProtocolHandler(protocol, url); ProtocolHandlerRegistry* registry = - ProtocolHandlerRegistryFactory::GetForProfile(browser()->profile()); + ProtocolHandlerRegistryFactory::GetForBrowserContext( + browser()->profile()); registry->RemoveHandler(handler); ASSERT_FALSE(registry->IsHandledProtocol(protocol)); } @@ -80,7 +82,8 @@ IN_PROC_BROWSER_TEST_F(RegisterProtocolHandlerBrowserTest, GURL("http://www.google.com/%s")); GURL url("web+search:testing"); ProtocolHandlerRegistry* registry = - ProtocolHandlerRegistryFactory::GetForProfile(browser()->profile()); + ProtocolHandlerRegistryFactory::GetForBrowserContext( + browser()->profile()); ASSERT_EQ(1u, registry->GetHandlersFor(url.scheme()).size()); menu.reset(CreateContextMenu(url)); ASSERT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKWITH)); @@ -96,7 +99,8 @@ IN_PROC_BROWSER_TEST_F(RegisterProtocolHandlerBrowserTest, GURL("http://www.google.com/%s")); GURL url("web+search:testing"); ProtocolHandlerRegistry* registry = - ProtocolHandlerRegistryFactory::GetForProfile(browser()->profile()); + ProtocolHandlerRegistryFactory::GetForBrowserContext( + 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/custom_handlers/protocol_handler_registry_factory.cc b/chrome/browser/custom_handlers/protocol_handler_registry_factory.cc index 7488ce9..9a975cd 100644 --- a/chrome/browser/custom_handlers/protocol_handler_registry_factory.cc +++ b/chrome/browser/custom_handlers/protocol_handler_registry_factory.cc @@ -7,7 +7,6 @@ #include "base/memory/singleton.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h" #include "chrome/browser/profiles/incognito_helpers.h" -#include "chrome/browser/profiles/profile.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" // static @@ -16,10 +15,10 @@ ProtocolHandlerRegistryFactory* ProtocolHandlerRegistryFactory::GetInstance() { } // static -ProtocolHandlerRegistry* ProtocolHandlerRegistryFactory::GetForProfile( - Profile* profile) { +ProtocolHandlerRegistry* ProtocolHandlerRegistryFactory::GetForBrowserContext( + content::BrowserContext* context) { return static_cast<ProtocolHandlerRegistry*>( - GetInstance()->GetServiceForBrowserContext(profile, true)); + GetInstance()->GetServiceForBrowserContext(context, true)); } ProtocolHandlerRegistryFactory::ProtocolHandlerRegistryFactory() @@ -53,9 +52,9 @@ bool ProtocolHandlerRegistryFactory::ServiceIsNULLWhileTesting() const { } KeyedService* ProtocolHandlerRegistryFactory::BuildServiceInstanceFor( - content::BrowserContext* profile) const { + content::BrowserContext* context) const { ProtocolHandlerRegistry* registry = new ProtocolHandlerRegistry( - static_cast<Profile*>(profile), new ProtocolHandlerRegistry::Delegate()); + context, new ProtocolHandlerRegistry::Delegate()); #if defined(OS_CHROMEOS) // If installing defaults, they must be installed prior calling diff --git a/chrome/browser/custom_handlers/protocol_handler_registry_factory.h b/chrome/browser/custom_handlers/protocol_handler_registry_factory.h index 63b02b3..6b9c6a5 100644 --- a/chrome/browser/custom_handlers/protocol_handler_registry_factory.h +++ b/chrome/browser/custom_handlers/protocol_handler_registry_factory.h @@ -23,8 +23,9 @@ class ProtocolHandlerRegistryFactory static ProtocolHandlerRegistryFactory* GetInstance(); // Returns the ProtocolHandlerRegistry that provides intent registration for - // |profile|. Ownership stays with this factory object. - static ProtocolHandlerRegistry* GetForProfile(Profile* profile); + // |context|. Ownership stays with this factory object. + static ProtocolHandlerRegistry* GetForBrowserContext( + content::BrowserContext* context); protected: // BrowserContextKeyedServiceFactory implementation. diff --git a/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc b/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc index b87384d..c3a9a1f 100644 --- a/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc +++ b/chrome/browser/custom_handlers/protocol_handler_registry_unittest.cc @@ -244,12 +244,12 @@ ShellIntegration::DefaultProtocolClientWorker* FakeDelegate::CreateShellWorker( class NotificationCounter : public content::NotificationObserver { public: - explicit NotificationCounter(Profile* profile) + explicit NotificationCounter(content::BrowserContext* context) : events_(0), notification_registrar_() { notification_registrar_.Add(this, chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, - content::Source<Profile>(profile)); + content::Source<content::BrowserContext>(context)); } int events() { return events_; } @@ -268,14 +268,14 @@ class NotificationCounter : public content::NotificationObserver { class QueryProtocolHandlerOnChange : public content::NotificationObserver { public: - QueryProtocolHandlerOnChange(Profile* profile, + QueryProtocolHandlerOnChange(content::BrowserContext* context, ProtocolHandlerRegistry* registry) : local_registry_(registry), called_(false), notification_registrar_() { notification_registrar_.Add(this, chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, - content::Source<Profile>(profile)); + content::Source<content::BrowserContext>(context)); } virtual void Observe(int type, diff --git a/chrome/browser/profiles/off_the_record_profile_io_data.cc b/chrome/browser/profiles/off_the_record_profile_io_data.cc index 8b091ac..df01282 100644 --- a/chrome/browser/profiles/off_the_record_profile_io_data.cc +++ b/chrome/browser/profiles/off_the_record_profile_io_data.cc @@ -129,7 +129,7 @@ OffTheRecordProfileIOData::Handle::CreateIsolatedAppRequestContextGetter( scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> protocol_handler_interceptor( - ProtocolHandlerRegistryFactory::GetForProfile(profile_)-> + ProtocolHandlerRegistryFactory::GetForBrowserContext(profile_)-> CreateJobInterceptorFactory()); ChromeURLRequestContextGetter* context = ChromeURLRequestContextGetter::CreateForIsolatedApp( diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc index cbbb203..249137d 100644 --- a/chrome/browser/profiles/profile_impl_io_data.cc +++ b/chrome/browser/profiles/profile_impl_io_data.cc @@ -237,7 +237,7 @@ ProfileImplIOData::Handle::CreateIsolatedAppRequestContextGetter( scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> protocol_handler_interceptor( - ProtocolHandlerRegistryFactory::GetForProfile(profile_)-> + ProtocolHandlerRegistryFactory::GetForBrowserContext(profile_)-> CreateJobInterceptorFactory()); ChromeURLRequestContextGetter* context = ChromeURLRequestContextGetter::CreateForIsolatedApp( diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index 5f7cb46..c98f000 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -345,7 +345,7 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) { #endif ProtocolHandlerRegistry* protocol_handler_registry = - ProtocolHandlerRegistryFactory::GetForProfile(profile); + ProtocolHandlerRegistryFactory::GetForBrowserContext(profile); DCHECK(protocol_handler_registry); // The profile instance is only available here in the InitializeOnUIThread diff --git a/chrome/browser/renderer_context_menu/render_view_context_menu.cc b/chrome/browser/renderer_context_menu/render_view_context_menu.cc index de8539e..b9ccdd5 100644 --- a/chrome/browser/renderer_context_menu/render_view_context_menu.cc +++ b/chrome/browser/renderer_context_menu/render_view_context_menu.cc @@ -423,7 +423,7 @@ RenderViewContextMenu::RenderViewContextMenu( base::Bind(MenuItemMatchesParams, params_)), protocol_handler_submenu_model_(this), protocol_handler_registry_( - ProtocolHandlerRegistryFactory::GetForProfile(GetProfile())), + ProtocolHandlerRegistryFactory::GetForBrowserContext(GetProfile())), command_executed_(false) { content_type_.reset(ContextMenuContentTypeFactory::Create( source_web_contents_, params)); diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index c8caf53..0981432 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -1639,16 +1639,15 @@ void Browser::RegisterProtocolHandler(WebContents* web_contents, const std::string& protocol, const GURL& url, bool user_gesture) { - Profile* profile = - Profile::FromBrowserContext(web_contents->GetBrowserContext()); - if (profile->IsOffTheRecord()) + content::BrowserContext* context = web_contents->GetBrowserContext(); + if (context->IsOffTheRecord()) return; ProtocolHandler handler = ProtocolHandler::CreateProtocolHandler(protocol, url); ProtocolHandlerRegistry* registry = - ProtocolHandlerRegistryFactory::GetForProfile(profile); + ProtocolHandlerRegistryFactory::GetForBrowserContext(context); if (registry->SilentlyHandleRegisterHandlerRequest(handler)) return; @@ -1687,16 +1686,15 @@ void Browser::UnregisterProtocolHandler(WebContents* web_contents, bool user_gesture) { // user_gesture will be used in case we decide to have confirmation bubble // for user while un-registering the handler. - Profile* profile = - Profile::FromBrowserContext(web_contents->GetBrowserContext()); - if (profile->IsOffTheRecord()) + content::BrowserContext* context = web_contents->GetBrowserContext(); + if (context->IsOffTheRecord()) return; ProtocolHandler handler = ProtocolHandler::CreateProtocolHandler(protocol, url); ProtocolHandlerRegistry* registry = - ProtocolHandlerRegistryFactory::GetForProfile(profile); + ProtocolHandlerRegistryFactory::GetForBrowserContext(context); registry->RemoveHandler(handler); } diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc index 1627760..6ad1476 100644 --- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc @@ -1268,7 +1268,7 @@ ContentSettingBubbleModel* } if (content_type == CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) { ProtocolHandlerRegistry* registry = - ProtocolHandlerRegistryFactory::GetForProfile(profile); + ProtocolHandlerRegistryFactory::GetForBrowserContext(profile); return new ContentSettingRPHBubbleModel(delegate, web_contents, profile, registry, content_type); } diff --git a/chrome/browser/ui/startup/startup_browser_creator_impl.cc b/chrome/browser/ui/startup/startup_browser_creator_impl.cc index 998a40e..723f3fa 100644 --- a/chrome/browser/ui/startup/startup_browser_creator_impl.cc +++ b/chrome/browser/ui/startup/startup_browser_creator_impl.cc @@ -763,7 +763,7 @@ Browser* StartupBrowserCreatorImpl::OpenTabsInBrowser( bool first_tab = true; ProtocolHandlerRegistry* registry = profile_ ? - ProtocolHandlerRegistryFactory::GetForProfile(profile_) : NULL; + ProtocolHandlerRegistryFactory::GetForBrowserContext(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 diff --git a/chrome/browser/ui/webui/options/content_settings_handler.cc b/chrome/browser/ui/webui/options/content_settings_handler.cc index 20775fe..8252aed 100644 --- a/chrome/browser/ui/webui/options/content_settings_handler.cc +++ b/chrome/browser/ui/webui/options/content_settings_handler.cc @@ -34,10 +34,12 @@ #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "components/google/core/browser/google_util.h" +#include "components/user_prefs/user_prefs.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" #include "content/public/browser/user_metrics.h" +#include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui.h" #include "content/public/common/content_switches.h" #include "content/public/common/page_zoom.h" @@ -74,7 +76,8 @@ typedef std::map<std::pair<ContentSettingsPattern, std::string>, // The AppFilter is used in AddExceptionsGrantedByHostedApps() to choose // extensions which should have their extent displayed. -typedef bool (*AppFilter)(const extensions::Extension& app, Profile* profile); +typedef bool (*AppFilter)(const extensions::Extension& app, + content::BrowserContext* profile); const char kExceptionsLearnMoreUrl[] = "https://support.google.com/chrome/?p=settings_manage_exceptions"; @@ -117,6 +120,10 @@ const ContentSettingsTypeNameEntry kContentSettingsTypeGroupNames[] = { // though it is not a real content setting. const char* kZoomContentType = "zoomlevels"; +content::BrowserContext* GetBrowserContext(content::WebUI* web_ui) { + return web_ui->GetWebContents()->GetBrowserContext(); +} + ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name) { for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) { if (name == kContentSettingsTypeGroupNames[i].name) @@ -210,8 +217,8 @@ base::DictionaryValue* GetNotificationExceptionForPage( // Returns true whenever the |extension| is hosted and has |permission|. // Must have the AppFilter signature. template <APIPermission::ID permission> -bool HostedAppHasPermission( - const extensions::Extension& extension, Profile* /*profile*/) { +bool HostedAppHasPermission(const extensions::Extension& extension, + content::BrowserContext* /* context */) { return extension.is_hosted_app() && extension.permissions_data()->HasAPIPermission(permission); } @@ -232,13 +239,14 @@ void AddExceptionForHostedApp(const std::string& url_pattern, // Asks the |profile| for hosted apps which have the |permission| set, and // adds their web extent and launch URL to the |exceptions| list. -void AddExceptionsGrantedByHostedApps( - Profile* profile, AppFilter app_filter, base::ListValue* exceptions) { +void AddExceptionsGrantedByHostedApps(content::BrowserContext* context, + AppFilter app_filter, + base::ListValue* exceptions) { const extensions::ExtensionSet& extensions = - extensions::ExtensionRegistry::Get(profile)->enabled_extensions(); + extensions::ExtensionRegistry::Get(context)->enabled_extensions(); for (extensions::ExtensionSet::const_iterator extension = extensions.begin(); extension != extensions.end(); ++extension) { - if (!app_filter(*extension->get(), profile)) + if (!app_filter(*extension->get(), context)) continue; extensions::URLPatternSet web_extent = (*extension)->web_extent(); @@ -481,12 +489,12 @@ void ContentSettingsHandler::InitializeHandler() { notification_registrar_.Add( this, chrome::NOTIFICATION_DESKTOP_NOTIFICATION_SETTINGS_CHANGED, content::NotificationService::AllSources()); - Profile* profile = Profile::FromWebUI(web_ui()); + content::BrowserContext* context = GetBrowserContext(web_ui()); notification_registrar_.Add( this, chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, - content::Source<Profile>(profile)); + content::Source<content::BrowserContext>(context)); - PrefService* prefs = profile->GetPrefs(); + PrefService* prefs = user_prefs::UserPrefs::Get(context); pref_change_registrar_.Init(prefs); pref_change_registrar_.Add( prefs::kPepperFlashSettingsEnabled, @@ -507,13 +515,13 @@ void ContentSettingsHandler::InitializeHandler() { base::Unretained(this))); content::HostZoomMap* host_zoom_map = - content::HostZoomMap::GetForBrowserContext(profile); + content::HostZoomMap::GetForBrowserContext(context); host_zoom_map_subscription_ = host_zoom_map->AddZoomLevelChangedCallback( base::Bind(&ContentSettingsHandler::OnZoomLevelChanged, base::Unretained(this))); - flash_settings_manager_.reset(new PepperFlashSettingsManager(this, profile)); + flash_settings_manager_.reset(new PepperFlashSettingsManager(this, context)); } void ContentSettingsHandler::InitializePage() { @@ -608,7 +616,7 @@ void ContentSettingsHandler::UpdateSettingDefaultFromModel( } void ContentSettingsHandler::UpdateMediaSettingsView() { - PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); + PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); bool audio_disabled = !prefs->GetBoolean(prefs::kAudioCaptureAllowed) && prefs->IsManagedPreference(prefs::kAudioCaptureAllowed); bool video_disabled = !prefs->GetBoolean(prefs::kVideoCaptureAllowed) && @@ -984,7 +992,7 @@ void ContentSettingsHandler::UpdateZoomLevelsExceptionsView() { base::ListValue zoom_levels_exceptions; content::HostZoomMap* host_zoom_map = - content::HostZoomMap::GetForBrowserContext(Profile::FromWebUI(web_ui())); + content::HostZoomMap::GetForBrowserContext(GetBrowserContext(web_ui())); content::HostZoomMap::ZoomLevelVector zoom_levels( host_zoom_map->GetAllZoomLevels()); std::sort(zoom_levels.begin(), zoom_levels.end(), HostZoomSort); @@ -1152,6 +1160,7 @@ void ContentSettingsHandler::GetExceptionsFromHostContentSettingsMap( void ContentSettingsHandler::RemoveNotificationException( const base::ListValue* args) { Profile* profile = Profile::FromWebUI(web_ui()); + std::string origin; std::string setting; bool rv = args->GetString(1, &origin); @@ -1236,7 +1245,7 @@ void ContentSettingsHandler::RemoveZoomLevelException( DCHECK(rv); content::HostZoomMap* host_zoom_map = - content::HostZoomMap::GetForBrowserContext(Profile::FromWebUI(web_ui())); + content::HostZoomMap::GetForBrowserContext(GetBrowserContext(web_ui())); double default_level = host_zoom_map->GetDefaultZoomLevel(); host_zoom_map->SetZoomLevelForHost(pattern, default_level); } @@ -1258,12 +1267,11 @@ void ContentSettingsHandler::RegisterMessages() { void ContentSettingsHandler::ApplyWhitelist(ContentSettingsType content_type, ContentSetting default_setting) { - Profile* profile = Profile::FromWebUI(web_ui()); HostContentSettingsMap* map = GetContentSettingsMap(); if (content_type != CONTENT_SETTINGS_TYPE_PLUGINS) return; const int kDefaultWhitelistVersion = 1; - PrefService* prefs = profile->GetPrefs(); + PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); int version = prefs->GetInteger( prefs::kContentSettingsDefaultWhitelistVersion); if (version >= kDefaultWhitelistVersion) @@ -1461,8 +1469,8 @@ HostContentSettingsMap* ContentSettingsHandler::GetContentSettingsMap() { } ProtocolHandlerRegistry* ContentSettingsHandler::GetProtocolHandlerRegistry() { - return ProtocolHandlerRegistryFactory::GetForProfile( - Profile::FromWebUI(web_ui())); + return ProtocolHandlerRegistryFactory::GetForBrowserContext( + GetBrowserContext(web_ui())); } HostContentSettingsMap* @@ -1485,7 +1493,7 @@ void ContentSettingsHandler::OnPepperFlashPrefChanged() { ShowFlashMediaLink(DEFAULT_SETTING, false); ShowFlashMediaLink(EXCEPTIONS, false); - PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); + PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); if (prefs->GetBoolean(prefs::kPepperFlashSettingsEnabled)) RefreshFlashMediaSettings(); else @@ -1557,7 +1565,7 @@ void ContentSettingsHandler::UpdateFlashMediaLinksVisibility() { } void ContentSettingsHandler::UpdateProtectedContentExceptionsButton() { - PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); + PrefService* prefs = user_prefs::UserPrefs::Get(GetBrowserContext(web_ui())); // Exceptions apply only when the feature is enabled. bool enable_exceptions = prefs->GetBoolean(prefs::kEnableDRM); web_ui()->CallJavascriptFunction( diff --git a/chrome/browser/ui/webui/options/handler_options_handler.cc b/chrome/browser/ui/webui/options/handler_options_handler.cc index 6c16466..92b9c71 100644 --- a/chrome/browser/ui/webui/options/handler_options_handler.cc +++ b/chrome/browser/ui/webui/options/handler_options_handler.cc @@ -86,7 +86,7 @@ void HandlerOptionsHandler::RegisterMessages() { } ProtocolHandlerRegistry* HandlerOptionsHandler::GetProtocolHandlerRegistry() { - return ProtocolHandlerRegistryFactory::GetForProfile( + return ProtocolHandlerRegistryFactory::GetForBrowserContext( Profile::FromWebUI(web_ui())); } |