diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser_process_impl.cc | 5 | ||||
-rw-r--r-- | chrome/browser/browsing_data_remover.cc | 2 | ||||
-rw-r--r-- | chrome/browser/chrome_plugin_service_filter.cc | 139 | ||||
-rw-r--r-- | chrome/browser/chrome_plugin_service_filter.h | 87 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_service.cc | 9 | ||||
-rw-r--r-- | chrome/browser/pdf_unsupported_feature.cc | 22 | ||||
-rw-r--r-- | chrome/browser/plugin_data_remover.cc | 10 | ||||
-rw-r--r-- | chrome/browser/plugin_data_remover.h | 6 | ||||
-rw-r--r-- | chrome/browser/plugin_data_remover_browsertest.cc | 3 | ||||
-rw-r--r-- | chrome/browser/plugin_data_remover_helper.cc | 5 | ||||
-rw-r--r-- | chrome/browser/plugin_prefs.cc | 2 | ||||
-rw-r--r-- | chrome/browser/printing/print_preview_tab_controller.cc | 16 | ||||
-rw-r--r-- | chrome/browser/profiles/off_the_record_profile_impl.cc | 8 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_impl.cc | 8 | ||||
-rw-r--r-- | chrome/browser/ui/webui/plugins_ui.cc | 5 |
15 files changed, 294 insertions, 33 deletions
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index c46580a..57fc0c4 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -20,6 +20,7 @@ #include "chrome/browser/browser_main.h" #include "chrome/browser/browser_process_sub_thread.h" #include "chrome/browser/browser_trial.h" +#include "chrome/browser/chrome_plugin_service_filter.h" #include "chrome/browser/component_updater/component_updater_configurator.h" #include "chrome/browser/component_updater/component_updater_service.h" #include "chrome/browser/debugger/devtools_protocol_handler.h" @@ -739,7 +740,9 @@ void BrowserProcessImpl::CreateIOThread() { // it is predominantly used from the io thread, but must be created // on the main thread. The service ctor is inexpensive and does not // invoke the io_thread() accessor. - PluginService::GetInstance(); + PluginService* plugin_service = PluginService::GetInstance(); + plugin_service->set_filter(ChromePluginServiceFilter::GetInstance()); + plugin_service->StartWatchingPlugins(); // Add the Chrome specific plugins. chrome::RegisterInternalDefaultPlugin(); diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc index bd05876..6f8a387 100644 --- a/chrome/browser/browsing_data_remover.cc +++ b/chrome/browser/browsing_data_remover.cc @@ -276,7 +276,7 @@ void BrowsingDataRemover::Remove(int remove_mask) { waiting_for_clear_lso_data_ = true; if (!plugin_data_remover_.get()) - plugin_data_remover_ = new PluginDataRemover(); + plugin_data_remover_ = new PluginDataRemover(profile_); base::WaitableEvent* event = plugin_data_remover_->StartRemoving(delete_begin_); watcher_.StartWatching(event, this); diff --git a/chrome/browser/chrome_plugin_service_filter.cc b/chrome/browser/chrome_plugin_service_filter.cc new file mode 100644 index 0000000..23e11c8 --- /dev/null +++ b/chrome/browser/chrome_plugin_service_filter.cc @@ -0,0 +1,139 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/chrome_plugin_service_filter.h" + +#include "base/logging.h" +#include "chrome/browser/plugin_prefs.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/common/chrome_notification_types.h" +#include "content/browser/browser_thread.h" +#include "content/browser/plugin_service.h" +#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/resource_context.h" +#include "content/common/notification_service.h" +#include "webkit/plugins/npapi/plugin_list.h" + +// static +ChromePluginServiceFilter* ChromePluginServiceFilter::GetInstance() { + return Singleton<ChromePluginServiceFilter>::get(); +} + +void ChromePluginServiceFilter::RegisterResourceContext( + PluginPrefs* plugin_prefs, + const void* context) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + base::AutoLock lock(lock_); + resource_context_map_[context] = plugin_prefs; +} + +void ChromePluginServiceFilter::UnregisterResourceContext( + const void* context) { + base::AutoLock lock(lock_); + resource_context_map_.erase(context); +} + +void ChromePluginServiceFilter::OverridePluginForTab( + int render_process_id, + int render_view_id, + const GURL& url, + const webkit::WebPluginInfo& plugin) { + OverriddenPlugin overridden_plugin; + overridden_plugin.render_process_id = render_process_id; + overridden_plugin.render_view_id = render_view_id; + overridden_plugin.url = url; + overridden_plugin.plugin = plugin; + base::AutoLock auto_lock(lock_); + overridden_plugins_.push_back(overridden_plugin); +} + +void ChromePluginServiceFilter::RestrictPluginToUrl(const FilePath& plugin_path, + const GURL& url) { + base::AutoLock auto_lock(lock_); + if (url.is_empty()) + restricted_plugins_.erase(plugin_path); + else + restricted_plugins_[plugin_path] = url; +} + +bool ChromePluginServiceFilter::ShouldUsePlugin( + int render_process_id, + int render_view_id, + const void* context, + const GURL& url, + const GURL& policy_url, + webkit::WebPluginInfo* plugin) { + base::AutoLock auto_lock(lock_); + // Check whether the plugin is overridden. + for (size_t i = 0; i < overridden_plugins_.size(); ++i) { + if (overridden_plugins_[i].render_process_id == render_process_id && + overridden_plugins_[i].render_view_id == render_view_id && + (overridden_plugins_[i].url == url || + overridden_plugins_[i].url.is_empty())) { + if (overridden_plugins_[i].plugin.path != plugin->path) + return false; + *plugin = overridden_plugins_[i].plugin; + return true; + } + } + + // Check whether the plugin is disabled. + ResourceContextMap::iterator prefs_it = + resource_context_map_.find(context); + if (prefs_it == resource_context_map_.end()) + return false; + + PluginPrefs* plugin_prefs = prefs_it->second.get(); + if (!plugin_prefs->IsPluginEnabled(*plugin)) + return false; + + // Check whether the plugin is restricted to a URL. + RestrictedPluginMap::const_iterator it = + restricted_plugins_.find(plugin->path); + if (it != restricted_plugins_.end() && + (policy_url.scheme() != it->second.scheme() || + policy_url.host() != it->second.host())) { + return false; + } + + return true; +} + +ChromePluginServiceFilter::ChromePluginServiceFilter() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, + NotificationService::AllSources()); + registrar_.Add(this, chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, + NotificationService::AllSources()); +} + +ChromePluginServiceFilter::~ChromePluginServiceFilter() { +} + +void ChromePluginServiceFilter::Observe(int type, + const NotificationSource& source, + const NotificationDetails& details) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + switch (type) { + case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { + int render_process_id = Source<RenderProcessHost>(source).ptr()->id(); + + base::AutoLock auto_lock(lock_); + for (size_t i = 0; i < overridden_plugins_.size(); ++i) { + if (overridden_plugins_[i].render_process_id == render_process_id) { + overridden_plugins_.erase(overridden_plugins_.begin() + i); + break; + } + } + break; + } + case chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED: { + PluginService::GetInstance()->PurgePluginListCache(false); + break; + } + default: { + NOTREACHED(); + } + } +} diff --git a/chrome/browser/chrome_plugin_service_filter.h b/chrome/browser/chrome_plugin_service_filter.h new file mode 100644 index 0000000..81bbfa1 --- /dev/null +++ b/chrome/browser/chrome_plugin_service_filter.h @@ -0,0 +1,87 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROME_PLUGIN_SERVICE_FILTER_H_ +#define CHROME_BROWSER_CHROME_PLUGIN_SERVICE_FILTER_H_ +#pragma once + +#include <map> +#include <vector> + +#include "base/hash_tables.h" +#include "base/file_path.h" +#include "base/memory/ref_counted.h" +#include "base/memory/singleton.h" +#include "base/synchronization/lock.h" +#include "content/browser/plugin_service_filter.h" +#include "content/common/notification_observer.h" +#include "content/common/notification_registrar.h" +#include "googleurl/src/gurl.h" +#include "webkit/plugins/webplugininfo.h" + +class PluginPrefs; + +// This class must be created (by calling the |GetInstance| method) on the UI +// thread, but is safe to use on any thread after that. +class ChromePluginServiceFilter : public content::PluginServiceFilter, + public NotificationObserver { + public: + static ChromePluginServiceFilter* GetInstance(); + + // This method should be called on the UI thread. + void RegisterResourceContext(PluginPrefs* plugin_prefs, const void* context); + + void UnregisterResourceContext(const void* context); + + // Overrides the plugin lookup mechanism for a given tab and object URL to use + // a specifc plugin. + void OverridePluginForTab(int render_process_id, + int render_view_id, + const GURL& url, + const webkit::WebPluginInfo& plugin); + + // Restricts the given plugin to the the scheme and host of the given url. + // Call with an empty url to reset this. + void RestrictPluginToUrl(const FilePath& plugin_path, const GURL& url); + + // PluginServiceFilter implementation: + virtual bool ShouldUsePlugin( + int render_process_id, + int render_view_id, + const void* context, + const GURL& url, + const GURL& policy_url, + webkit::WebPluginInfo* plugin) OVERRIDE; + + private: + friend struct DefaultSingletonTraits<ChromePluginServiceFilter>; + + struct OverriddenPlugin { + int render_process_id; + int render_view_id; + GURL url; // If empty, the override applies to all urls in render_view. + webkit::WebPluginInfo plugin; + }; + + ChromePluginServiceFilter(); + virtual ~ChromePluginServiceFilter(); + + // NotificationObserver implementation: + virtual void Observe(int type, + const NotificationSource& source, + const NotificationDetails& details); + + NotificationRegistrar registrar_; + + base::Lock lock_; // Guards access to member variables. + // Map of plugin paths to the origin they are restricted to. + typedef base::hash_map<FilePath, GURL> RestrictedPluginMap; + RestrictedPluginMap restricted_plugins_; + typedef std::map<const void*, scoped_refptr<PluginPrefs> > ResourceContextMap; + ResourceContextMap resource_context_map_; + + std::vector<OverriddenPlugin> overridden_plugins_; +}; + +#endif // CHROME_BROWSER_CHROME_PLUGIN_SERVICE_FILTER_H_ diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index e9143d0..dc4d403 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -24,6 +24,7 @@ #include "base/values.h" #include "base/version.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/chrome_plugin_service_filter.h" #include "chrome/browser/extensions/apps_promo.h" #include "chrome/browser/extensions/crx_installer.h" #include "chrome/browser/extensions/extension_accessibility_api.h" @@ -1502,7 +1503,7 @@ void ExtensionService::NotifyExtensionLoaded(const Extension* extension) { webkit::npapi::PluginList::Singleton()->AddExtraPluginPath(plugin.path); plugins_changed = true; if (!plugin.is_public) { - PluginService::GetInstance()->RestrictPluginToUrl( + ChromePluginServiceFilter::GetInstance()->RestrictPluginToUrl( plugin.path, extension->url()); } } @@ -1597,8 +1598,10 @@ void ExtensionService::NotifyExtensionUnloaded( webkit::npapi::PluginList::Singleton()->RemoveExtraPluginPath( plugin.path); plugins_changed = true; - if (!plugin.is_public) - PluginService::GetInstance()->RestrictPluginToUrl(plugin.path, GURL()); + if (!plugin.is_public) { + ChromePluginServiceFilter::GetInstance()->RestrictPluginToUrl( + plugin.path, GURL()); + } } bool nacl_modules_changed = false; diff --git a/chrome/browser/pdf_unsupported_feature.cc b/chrome/browser/pdf_unsupported_feature.cc index 3f5f6d0..1a91a39 100644 --- a/chrome/browser/pdf_unsupported_feature.cc +++ b/chrome/browser/pdf_unsupported_feature.cc @@ -9,6 +9,7 @@ #include "base/version.h" #include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/plugin_prefs.h" +#include "chrome/browser/chrome_plugin_service_filter.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tab_contents/chrome_interstitial_page.h" @@ -140,19 +141,19 @@ void OpenUsingReader(TabContentsWrapper* tab, const WebPluginInfo& reader_plugin, InfoBarDelegate* old_delegate, InfoBarDelegate* new_delegate) { - PluginService::OverriddenPlugin plugin; - plugin.render_process_id = tab->render_view_host()->process()->id(); - plugin.render_view_id = tab->render_view_host()->routing_id(); - plugin.url = tab->tab_contents()->GetURL(); - plugin.plugin = reader_plugin; + WebPluginInfo plugin = reader_plugin; // The plugin is disabled, so enable it to get around the renderer check. // Also give it a new version so that the renderer doesn't show the blocked // plugin UI if it's vulnerable, since we already went through the // interstitial. - plugin.plugin.enabled = WebPluginInfo::USER_ENABLED; - plugin.plugin.version = ASCIIToUTF16("11.0.0.0"); - - PluginService::GetInstance()->OverridePluginForTab(plugin); + plugin.enabled = WebPluginInfo::USER_ENABLED; + plugin.version = ASCIIToUTF16("11.0.0.0"); + + ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( + tab->render_view_host()->process()->id(), + tab->render_view_host()->routing_id(), + tab->tab_contents()->GetURL(), + plugin); tab->render_view_host()->Send(new ViewMsg_ReloadFrame( tab->render_view_host()->routing_id())); @@ -386,8 +387,7 @@ void PDFHasUnsupportedFeature(TabContentsWrapper* tab) { PluginGroup* reader_group = NULL; std::vector<PluginGroup> plugin_groups; - PluginList::Singleton()->GetPluginGroups( - false, &plugin_groups); + PluginList::Singleton()->GetPluginGroups(false, &plugin_groups); for (size_t i = 0; i < plugin_groups.size(); ++i) { if (plugin_groups[i].GetGroupName() == reader_group_name) { reader_group = &plugin_groups[i]; diff --git a/chrome/browser/plugin_data_remover.cc b/chrome/browser/plugin_data_remover.cc index b547b60..5b06586 100644 --- a/chrome/browser/plugin_data_remover.cc +++ b/chrome/browser/plugin_data_remover.cc @@ -10,6 +10,7 @@ #include "base/synchronization/waitable_event.h" #include "base/version.h" #include "chrome/browser/plugin_prefs.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_switches.h" #include "content/browser/browser_thread.h" #include "content/browser/plugin_service.h" @@ -31,9 +32,10 @@ const uint64 kClearAllData = 0; } // namespace -PluginDataRemover::PluginDataRemover() +PluginDataRemover::PluginDataRemover(Profile* profile) : mime_type_(kFlashMimeType), is_removing_(false), + context_(profile->GetResourceContext()), event_(new base::WaitableEvent(true, false)), channel_(NULL) { } @@ -55,7 +57,7 @@ base::WaitableEvent* PluginDataRemover::StartRemoving(base::Time begin_time) { // called, so we need to keep this object around until then. AddRef(); PluginService::GetInstance()->OpenChannelToNpapiPlugin( - 0, 0, GURL(), mime_type_, this); + 0, 0, GURL(), GURL(), mime_type_, this); BrowserThread::PostDelayedTask( BrowserThread::IO, @@ -87,6 +89,10 @@ bool PluginDataRemover::OffTheRecord() { return false; } +const content::ResourceContext& PluginDataRemover::GetResourceContext() { + return context_; +} + void PluginDataRemover::SetPluginInfo( const webkit::WebPluginInfo& info) { } diff --git a/chrome/browser/plugin_data_remover.h b/chrome/browser/plugin_data_remover.h index 9cad19b..9ff4235 100644 --- a/chrome/browser/plugin_data_remover.h +++ b/chrome/browser/plugin_data_remover.h @@ -11,6 +11,7 @@ #include "content/browser/plugin_process_host.h" class PluginPrefs; +class Profile; class Task; namespace base { @@ -22,7 +23,7 @@ class PluginDataRemover : public base::RefCountedThreadSafe<PluginDataRemover>, public PluginProcessHost::Client, public IPC::Channel::Listener { public: - PluginDataRemover(); + explicit PluginDataRemover(Profile* profile); // The plug-in whose data should be removed (usually Flash) is specified via // its MIME type. This method sets a different MIME type in order to call a @@ -48,6 +49,7 @@ class PluginDataRemover : public base::RefCountedThreadSafe<PluginDataRemover>, // PluginProcessHost::Client methods. virtual int ID(); virtual bool OffTheRecord(); + virtual const content::ResourceContext& GetResourceContext(); virtual void SetPluginInfo(const webkit::WebPluginInfo& info); virtual void OnChannelOpened(const IPC::ChannelHandle& handle); virtual void OnError(); @@ -78,6 +80,8 @@ class PluginDataRemover : public base::RefCountedThreadSafe<PluginDataRemover>, base::Time remove_start_time_; // The point in time from which on we remove data. base::Time begin_time_; + // The resource context for the profile. + const content::ResourceContext& context_; scoped_ptr<base::WaitableEvent> event_; // We own the channel, but it's used on the IO thread, so it needs to be // deleted there. It's NULL until we have opened a connection to the plug-in diff --git a/chrome/browser/plugin_data_remover_browsertest.cc b/chrome/browser/plugin_data_remover_browsertest.cc index aa85045..5e4a7b2 100644 --- a/chrome/browser/plugin_data_remover_browsertest.cc +++ b/chrome/browser/plugin_data_remover_browsertest.cc @@ -41,7 +41,8 @@ class PluginDataRemoverTest : public InProcessBrowserTest, }; IN_PROC_BROWSER_TEST_F(PluginDataRemoverTest, RemoveData) { - scoped_refptr<PluginDataRemover> plugin_data_remover(new PluginDataRemover()); + scoped_refptr<PluginDataRemover> plugin_data_remover( + new PluginDataRemover(browser()->profile())); plugin_data_remover->set_mime_type(kNPAPITestPluginMimeType); base::WaitableEventWatcher watcher; base::WaitableEvent* event = diff --git a/chrome/browser/plugin_data_remover_helper.cc b/chrome/browser/plugin_data_remover_helper.cc index 9d4e176..df0c907 100644 --- a/chrome/browser/plugin_data_remover_helper.cc +++ b/chrome/browser/plugin_data_remover_helper.cc @@ -11,6 +11,7 @@ #include "chrome/browser/plugin_prefs.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/common/chrome_notification_types.h" #include "content/browser/browser_thread.h" #include "content/common/notification_service.h" @@ -76,7 +77,7 @@ void PluginDataRemoverHelper::Init(const char* pref_name, Profile* profile, NotificationObserver* observer) { pref_.Init(pref_name, profile->GetPrefs(), observer); - registrar_.Add(this, content::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, + registrar_.Add(this, chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, NotificationService::AllSources()); internal_ = make_scoped_refptr(new Internal(pref_name, profile)); internal_->StartUpdate(); @@ -85,7 +86,7 @@ void PluginDataRemoverHelper::Init(const char* pref_name, void PluginDataRemoverHelper::Observe(int type, const NotificationSource& source, const NotificationDetails& details) { - if (type == content::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED) { + if (type == chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED) { internal_->StartUpdate(); } else { NOTREACHED(); diff --git a/chrome/browser/plugin_prefs.cc b/chrome/browser/plugin_prefs.cc index 9af4c67..7b2ce4d 100644 --- a/chrome/browser/plugin_prefs.cc +++ b/chrome/browser/plugin_prefs.cc @@ -440,7 +440,7 @@ void PluginPrefs::NotifyPluginStatusChanged() { void PluginPrefs::OnNotifyPluginStatusChanged() { notify_pending_ = false; NotificationService::current()->Notify( - content::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, + chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, Source<PluginPrefs>(this), NotificationService::NoDetails()); } diff --git a/chrome/browser/printing/print_preview_tab_controller.cc b/chrome/browser/printing/print_preview_tab_controller.cc index 6f5078c..cdcb02c 100644 --- a/chrome/browser/printing/print_preview_tab_controller.cc +++ b/chrome/browser/printing/print_preview_tab_controller.cc @@ -9,6 +9,7 @@ #include "base/command_line.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/chrome_plugin_service_filter.h" #include "chrome/browser/printing/print_view_manager.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sessions/restore_tab_helper.h" @@ -21,7 +22,6 @@ #include "chrome/common/chrome_content_client.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/url_constants.h" -#include "content/browser/plugin_service.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/navigation_details.h" #include "content/browser/tab_contents/tab_contents.h" @@ -55,13 +55,13 @@ void EnableInternalPDFPluginForTab(TabContentsWrapper* preview_tab) { std::vector<WebPluginInfo> plugins = internal_pdf_group->web_plugin_infos(); DCHECK_EQ(plugins.size(), 1U); - PluginService::OverriddenPlugin plugin; - plugin.render_process_id = preview_tab->render_view_host()->process()->id(); - plugin.render_view_id = preview_tab->render_view_host()->routing_id(); - plugin.plugin = plugins[0]; - plugin.plugin.enabled = WebPluginInfo::USER_ENABLED; - - PluginService::GetInstance()->OverridePluginForTab(plugin); + webkit::WebPluginInfo plugin = plugins[0]; + plugin.enabled = WebPluginInfo::USER_ENABLED; + ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( + preview_tab->render_view_host()->process()->id(), + preview_tab->render_view_host()->routing_id(), + GURL(), + plugin); } } diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc index 964bc8b..ed0a2f4 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.cc +++ b/chrome/browser/profiles/off_the_record_profile_impl.cc @@ -16,6 +16,7 @@ #include "build/build_config.h" #include "chrome/browser/background/background_contents_service_factory.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/chrome_plugin_service_filter.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/download/chrome_download_manager_delegate.h" #include "chrome/browser/extensions/extension_info_map.h" @@ -26,6 +27,7 @@ #include "chrome/browser/extensions/extension_special_storage_policy.h" #include "chrome/browser/extensions/extension_webrequest_api.h" #include "chrome/browser/net/pref_proxy_config_service.h" +#include "chrome/browser/plugin_prefs.h" #include "chrome/browser/prefs/incognito_mode_prefs.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/off_the_record_profile_io_data.h" @@ -117,6 +119,9 @@ class OffTheRecordProfileImpl : public Profile, ExtensionIconSource* icon_source = new ExtensionIconSource(real_profile); GetChromeURLDataManager()->AddDataSource(icon_source); + ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( + PluginPrefs::GetForProfile(this), &GetResourceContext()); + BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, NewRunnableFunction(&NotifyOTRProfileCreatedOnIOThread, profile_, this)); @@ -127,6 +132,9 @@ class OffTheRecordProfileImpl : public Profile, chrome::NOTIFICATION_PROFILE_DESTROYED, Source<Profile>(this), NotificationService::NoDetails()); + ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( + &GetResourceContext()); + ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); BrowserThread::PostTask( diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index 1ddbd12..db3a11c 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -21,6 +21,7 @@ #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browsing_data_remover.h" +#include "chrome/browser/chrome_plugin_service_filter.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h" #include "chrome/browser/defaults.h" @@ -49,6 +50,7 @@ #include "chrome/browser/net/pref_proxy_config_service.h" #include "chrome/browser/net/ssl_config_service_manager.h" #include "chrome/browser/password_manager/password_store_default.h" +#include "chrome/browser/plugin_prefs.h" #include "chrome/browser/policy/configuration_policy_pref_store.h" #include "chrome/browser/prefs/browser_prefs.h" #include "chrome/browser/prefs/pref_value_store.h" @@ -438,6 +440,9 @@ void ProfileImpl::DoFinalInit() { cache_max_size, media_cache_path, media_cache_max_size, extensions_cookie_path, app_path); + ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( + PluginPrefs::GetForProfile(this), &GetResourceContext()); + // Creation has been finished. if (delegate_) delegate_->OnProfileCreated(this, true); @@ -687,6 +692,9 @@ ProfileImpl::~ProfileImpl() { // of the cleanup below. sync_service_.reset(); + ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( + &GetResourceContext()); + ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); if (db_tracker_) { diff --git a/chrome/browser/ui/webui/plugins_ui.cc b/chrome/browser/ui/webui/plugins_ui.cc index 78a3c18..f2fc958 100644 --- a/chrome/browser/ui/webui/plugins_ui.cc +++ b/chrome/browser/ui/webui/plugins_ui.cc @@ -22,6 +22,7 @@ #include "chrome/browser/ui/webui/chrome_url_data_manager.h" #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" #include "chrome/common/chrome_content_client.h" +#include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" @@ -150,7 +151,7 @@ class PluginsDOMHandler : public WebUIMessageHandler, PluginsDOMHandler::PluginsDOMHandler() : ALLOW_THIS_IN_INITIALIZER_LIST(get_plugins_factory_(this)) { registrar_.Add(this, - content::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, + chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, NotificationService::AllSources()); } @@ -248,7 +249,7 @@ void PluginsDOMHandler::HandleGetShowDetails(const ListValue* args) { void PluginsDOMHandler::Observe(int type, const NotificationSource& source, const NotificationDetails& details) { - DCHECK_EQ(content::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, type); + DCHECK_EQ(chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, type); LoadPlugins(); } |