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

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

Issue 6576020: Remove Gears from Chrome (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: remove host_render_view_id Created 9 years, 10 months 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
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 <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "base/synchronization/waitable_event.h" 15 #include "base/synchronization/waitable_event.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/chrome_plugin_host.h" 17 #include "chrome/browser/browser_thread.h"
18 #include "chrome/browser/extensions/extension_service.h" 18 #include "chrome/browser/extensions/extension_service.h"
19 #include "chrome/browser/plugin_updater.h" 19 #include "chrome/browser/plugin_updater.h"
20 #include "chrome/browser/ppapi_plugin_process_host.h" 20 #include "chrome/browser/ppapi_plugin_process_host.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/common/chrome_plugin_lib.h" 22 #include "chrome/browser/renderer_host/render_process_host.h"
23 #include "chrome/browser/renderer_host/render_view_host.h"
23 #include "chrome/common/chrome_paths.h" 24 #include "chrome/common/chrome_paths.h"
24 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/default_plugin.h" 26 #include "chrome/common/default_plugin.h"
26 #include "chrome/common/extensions/extension.h" 27 #include "chrome/common/extensions/extension.h"
27 #include "chrome/common/gpu_plugin.h" 28 #include "chrome/common/gpu_plugin.h"
28 #include "chrome/common/logging_chrome.h" 29 #include "chrome/common/logging_chrome.h"
29 #include "chrome/common/notification_type.h" 30 #include "chrome/common/notification_type.h"
30 #include "chrome/common/notification_service.h" 31 #include "chrome/common/notification_service.h"
31 #include "chrome/common/pepper_plugin_registry.h" 32 #include "chrome/common/pepper_plugin_registry.h"
32 #include "chrome/common/plugin_messages.h" 33 #include "chrome/common/plugin_messages.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 72 }
72 virtual void OnError() { 73 virtual void OnError() {
73 // TODO(pastarmovj): Add some sensible error handling. Maybe silently 74 // TODO(pastarmovj): Add some sensible error handling. Maybe silently
74 // stopping the watcher would be enough. Or possibly restart it. 75 // stopping the watcher would be enough. Or possibly restart it.
75 NOTREACHED(); 76 NOTREACHED();
76 } 77 }
77 }; 78 };
78 #endif 79 #endif
79 80
80 // static 81 // static
81 bool PluginService::enable_chrome_plugins_ = true;
82
83 // static
84 void PluginService::InitGlobalInstance(Profile* profile) { 82 void PluginService::InitGlobalInstance(Profile* profile) {
85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
86 84
87 // We first group the plugins and then figure out which groups to disable. 85 // We first group the plugins and then figure out which groups to disable.
88 PluginUpdater::GetInstance()->DisablePluginGroupsFromPrefs(profile); 86 PluginUpdater::GetInstance()->DisablePluginGroupsFromPrefs(profile);
89
90 // Have Chrome plugins write their data to the profile directory.
91 GetInstance()->SetChromePluginDataDir(profile->GetPath());
92 } 87 }
93 88
94 // static 89 // static
95 PluginService* PluginService::GetInstance() { 90 PluginService* PluginService::GetInstance() {
96 return Singleton<PluginService>::get(); 91 return Singleton<PluginService>::get();
97 } 92 }
98 93
99 // static
100 void PluginService::EnableChromePlugins(bool enable) {
101 enable_chrome_plugins_ = enable;
102 }
103
104 PluginService::PluginService() 94 PluginService::PluginService()
105 : main_message_loop_(MessageLoop::current()), 95 : main_message_loop_(MessageLoop::current()),
106 resource_dispatcher_host_(NULL), 96 resource_dispatcher_host_(NULL),
107 ui_locale_(g_browser_process->GetApplicationLocale()) { 97 ui_locale_(g_browser_process->GetApplicationLocale()) {
108 RegisterPepperPlugins(); 98 RegisterPepperPlugins();
109 99
110 // Have the NPAPI plugin list search for Chrome plugins as well.
111 ChromePluginLib::RegisterPluginsWithNPAPI();
112
113 // Load any specified on the command line as well. 100 // Load any specified on the command line as well.
114 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 101 const CommandLine* command_line = CommandLine::ForCurrentProcess();
115 FilePath path = command_line->GetSwitchValuePath(switches::kLoadPlugin); 102 FilePath path = command_line->GetSwitchValuePath(switches::kLoadPlugin);
116 if (!path.empty()) 103 if (!path.empty())
117 webkit::npapi::PluginList::Singleton()->AddExtraPluginPath(path); 104 webkit::npapi::PluginList::Singleton()->AddExtraPluginPath(path);
118 path = command_line->GetSwitchValuePath(switches::kExtraPluginDir); 105 path = command_line->GetSwitchValuePath(switches::kExtraPluginDir);
119 if (!path.empty()) 106 if (!path.empty())
120 webkit::npapi::PluginList::Singleton()->AddExtraPluginDir(path); 107 webkit::npapi::PluginList::Singleton()->AddExtraPluginDir(path);
121 108
122 chrome::RegisterInternalDefaultPlugin(); 109 chrome::RegisterInternalDefaultPlugin();
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // Release the events since they're owned by RegKey, not WaitableEvent. 200 // Release the events since they're owned by RegKey, not WaitableEvent.
214 hkcu_watcher_.StopWatching(); 201 hkcu_watcher_.StopWatching();
215 hklm_watcher_.StopWatching(); 202 hklm_watcher_.StopWatching();
216 if (hkcu_event_.get()) 203 if (hkcu_event_.get())
217 hkcu_event_->Release(); 204 hkcu_event_->Release();
218 if (hklm_event_.get()) 205 if (hklm_event_.get())
219 hklm_event_->Release(); 206 hklm_event_->Release();
220 #endif 207 #endif
221 } 208 }
222 209
223 void PluginService::LoadChromePlugins(
224 ResourceDispatcherHost* resource_dispatcher_host) {
225 if (!enable_chrome_plugins_)
226 return;
227
228 resource_dispatcher_host_ = resource_dispatcher_host;
229 ChromePluginLib::LoadChromePlugins(GetCPBrowserFuncsForBrowser());
230 }
231
232 void PluginService::SetChromePluginDataDir(const FilePath& data_dir) {
233 chrome_plugin_data_dir_ = data_dir;
234 }
235
236 const FilePath& PluginService::GetChromePluginDataDir() {
237 return chrome_plugin_data_dir_;
238 }
239
240 const std::string& PluginService::GetUILocale() { 210 const std::string& PluginService::GetUILocale() {
241 return ui_locale_; 211 return ui_locale_;
242 } 212 }
243 213
244 PluginProcessHost* PluginService::FindNpapiPluginProcess( 214 PluginProcessHost* PluginService::FindNpapiPluginProcess(
245 const FilePath& plugin_path) { 215 const FilePath& plugin_path) {
246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 216 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
247 217
248 for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS); 218 for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS);
249 !iter.Done(); ++iter) { 219 !iter.Done(); ++iter) {
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 #if defined(OS_LINUX) 545 #if defined(OS_LINUX)
576 // static 546 // static
577 void PluginService::RegisterFilePathWatcher( 547 void PluginService::RegisterFilePathWatcher(
578 FilePathWatcher *watcher, 548 FilePathWatcher *watcher,
579 const FilePath& path, 549 const FilePath& path,
580 FilePathWatcher::Delegate* delegate) { 550 FilePathWatcher::Delegate* delegate) {
581 bool result = watcher->Watch(path, delegate); 551 bool result = watcher->Watch(path, delegate);
582 DCHECK(result); 552 DCHECK(result);
583 } 553 }
584 #endif 554 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698