Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: content/browser/plugin_service.cc

Issue 8493019: Refactor PluginService to take PluginList as a dependency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase ToT Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/plugin_service.h ('k') | content/content_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/plugin_service.h" 5 #include "content/browser/plugin_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 void WillLoadPluginsCallback() { 69 void WillLoadPluginsCallback() {
70 #if defined(OS_WIN) 70 #if defined(OS_WIN)
71 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 71 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
72 #else 72 #else
73 CHECK(false) << "Plugin loading should happen out-of-process."; 73 CHECK(false) << "Plugin loading should happen out-of-process.";
74 #endif 74 #endif
75 } 75 }
76 76
77 } // namespace 77 } // namespace
78 78
79 // Custom Singleton traits to inject the PluginList.
80 struct PluginServiceSingletonTraits :
81 public DefaultSingletonTraits<PluginService> {
82 static PluginService* New() {
83 return new PluginService(webkit::npapi::PluginList::Singleton());
Bernhard Bauer 2011/11/08 17:03:23 If you set the WillLoadPluginsCallback here, you d
Robert Sesek 2011/11/08 17:21:00 Good idea. Done.
84 }
85 };
86
79 #if defined(OS_MACOSX) 87 #if defined(OS_MACOSX)
80 static void NotifyPluginsOfActivation() { 88 static void NotifyPluginsOfActivation() {
81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
82 90
83 for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS); 91 for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS);
84 !iter.Done(); ++iter) { 92 !iter.Done(); ++iter) {
85 PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter); 93 PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter);
86 plugin->OnAppActivation(); 94 plugin->OnAppActivation();
87 } 95 }
88 } 96 }
(...skipping 13 matching lines...) Expand all
102 virtual void OnFilePathError(const FilePath& path) OVERRIDE { 110 virtual void OnFilePathError(const FilePath& path) OVERRIDE {
103 // TODO(pastarmovj): Add some sensible error handling. Maybe silently 111 // TODO(pastarmovj): Add some sensible error handling. Maybe silently
104 // stopping the watcher would be enough. Or possibly restart it. 112 // stopping the watcher would be enough. Or possibly restart it.
105 NOTREACHED(); 113 NOTREACHED();
106 } 114 }
107 }; 115 };
108 #endif 116 #endif
109 117
110 // static 118 // static
111 PluginService* PluginService::GetInstance() { 119 PluginService* PluginService::GetInstance() {
112 return Singleton<PluginService>::get(); 120 return Singleton<PluginService, PluginServiceSingletonTraits>::get();
113 } 121 }
114 122
115 PluginService::PluginService() 123 PluginService::PluginService(webkit::npapi::PluginList* a_plugin_list)
116 : ui_locale_( 124 : plugin_list_(a_plugin_list),
125 ui_locale_(
117 content::GetContentClient()->browser()->GetApplicationLocale()), 126 content::GetContentClient()->browser()->GetApplicationLocale()),
118 filter_(NULL) { 127 filter_(NULL) {
119 plugin_list()->set_will_load_plugins_callback( 128 plugin_list()->set_will_load_plugins_callback(
120 base::Bind(&WillLoadPluginsCallback)); 129 base::Bind(&WillLoadPluginsCallback));
121 130
122 RegisterPepperPlugins(); 131 RegisterPepperPlugins();
123 132
124 content::GetContentClient()->AddNPAPIPlugins(plugin_list()); 133 content::GetContentClient()->AddNPAPIPlugins(plugin_list());
125 134
126 // Load any specified on the command line as well. 135 // Load any specified on the command line as well.
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 return webkit::npapi::PluginList::Singleton(); 649 return webkit::npapi::PluginList::Singleton();
641 } 650 }
642 651
643 void PluginService::RegisterInternalPlugin(const webkit::WebPluginInfo& info) { 652 void PluginService::RegisterInternalPlugin(const webkit::WebPluginInfo& info) {
644 plugin_list()->RegisterInternalPlugin(info); 653 plugin_list()->RegisterInternalPlugin(info);
645 } 654 }
646 655
647 string16 PluginService::GetPluginGroupName(const std::string& plugin_name) { 656 string16 PluginService::GetPluginGroupName(const std::string& plugin_name) {
648 return plugin_list()->GetPluginGroupName(plugin_name); 657 return plugin_list()->GetPluginGroupName(plugin_name);
649 } 658 }
OLDNEW
« no previous file with comments | « content/browser/plugin_service.h ('k') | content/content_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698