OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_impl.h" | 5 #include "content/browser/plugin_service_impl.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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 } | 128 } |
129 | 129 |
130 } // namespace content | 130 } // namespace content |
131 | 131 |
132 // static | 132 // static |
133 PluginServiceImpl* PluginServiceImpl::GetInstance() { | 133 PluginServiceImpl* PluginServiceImpl::GetInstance() { |
134 return Singleton<PluginServiceImpl>::get(); | 134 return Singleton<PluginServiceImpl>::get(); |
135 } | 135 } |
136 | 136 |
137 PluginServiceImpl::PluginServiceImpl() | 137 PluginServiceImpl::PluginServiceImpl() |
138 : plugin_list_(NULL), | 138 : plugin_list_(NULL), filter_(NULL) { |
139 ui_locale_( | |
140 content::GetContentClient()->browser()->GetApplicationLocale()), | |
141 filter_(NULL) { | |
142 } | 139 } |
143 | 140 |
144 PluginServiceImpl::~PluginServiceImpl() { | 141 PluginServiceImpl::~PluginServiceImpl() { |
145 #if defined(OS_WIN) | 142 #if defined(OS_WIN) |
146 // Release the events since they're owned by RegKey, not WaitableEvent. | 143 // Release the events since they're owned by RegKey, not WaitableEvent. |
147 hkcu_watcher_.StopWatching(); | 144 hkcu_watcher_.StopWatching(); |
148 hklm_watcher_.StopWatching(); | 145 hklm_watcher_.StopWatching(); |
149 if (hkcu_event_.get()) | 146 if (hkcu_event_.get()) |
150 hkcu_event_->Release(); | 147 hkcu_event_->Release(); |
151 if (hklm_event_.get()) | 148 if (hklm_event_.get()) |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 VLOG(1) << "Watching for changes in: " << plugin_dirs[i].value(); | 222 VLOG(1) << "Watching for changes in: " << plugin_dirs[i].value(); |
226 BrowserThread::PostTask( | 223 BrowserThread::PostTask( |
227 BrowserThread::FILE, FROM_HERE, | 224 BrowserThread::FILE, FROM_HERE, |
228 base::Bind(&PluginServiceImpl::RegisterFilePathWatcher, watcher, | 225 base::Bind(&PluginServiceImpl::RegisterFilePathWatcher, watcher, |
229 plugin_dirs[i], file_watcher_delegate_)); | 226 plugin_dirs[i], file_watcher_delegate_)); |
230 file_watchers_.push_back(watcher); | 227 file_watchers_.push_back(watcher); |
231 } | 228 } |
232 #endif | 229 #endif |
233 } | 230 } |
234 | 231 |
235 const std::string& PluginServiceImpl::GetUILocale() { | |
236 return ui_locale_; | |
237 } | |
238 | |
239 PluginProcessHost* PluginServiceImpl::FindNpapiPluginProcess( | 232 PluginProcessHost* PluginServiceImpl::FindNpapiPluginProcess( |
240 const FilePath& plugin_path) { | 233 const FilePath& plugin_path) { |
241 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 234 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
242 | 235 |
243 for (BrowserChildProcessHost::Iterator iter(content::PROCESS_TYPE_PLUGIN); | 236 for (BrowserChildProcessHost::Iterator iter(content::PROCESS_TYPE_PLUGIN); |
244 !iter.Done(); ++iter) { | 237 !iter.Done(); ++iter) { |
245 PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter); | 238 PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter); |
246 if (plugin->info().path == plugin_path) | 239 if (plugin->info().path == plugin_path) |
247 return plugin; | 240 return plugin; |
248 } | 241 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 if (plugin_host) | 283 if (plugin_host) |
291 return plugin_host; | 284 return plugin_host; |
292 | 285 |
293 webkit::WebPluginInfo info; | 286 webkit::WebPluginInfo info; |
294 if (!GetPluginInfoByPath(plugin_path, &info)) { | 287 if (!GetPluginInfoByPath(plugin_path, &info)) { |
295 return NULL; | 288 return NULL; |
296 } | 289 } |
297 | 290 |
298 // This plugin isn't loaded by any plugin process, so create a new process. | 291 // This plugin isn't loaded by any plugin process, so create a new process. |
299 scoped_ptr<PluginProcessHost> new_host(new PluginProcessHost()); | 292 scoped_ptr<PluginProcessHost> new_host(new PluginProcessHost()); |
300 if (!new_host->Init(info, ui_locale_)) { | 293 if (!new_host->Init(info)) { |
301 NOTREACHED(); // Init is not expected to fail. | 294 NOTREACHED(); // Init is not expected to fail. |
302 return NULL; | 295 return NULL; |
303 } | 296 } |
304 return new_host.release(); | 297 return new_host.release(); |
305 } | 298 } |
306 | 299 |
307 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess( | 300 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess( |
308 const FilePath& plugin_path, | 301 const FilePath& plugin_path, |
309 PpapiPluginProcessHost::PluginClient* client) { | 302 PpapiPluginProcessHost::PluginClient* client) { |
310 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 303 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 plugin_list_->RegisterInternalPlugin(info); | 666 plugin_list_->RegisterInternalPlugin(info); |
674 } | 667 } |
675 | 668 |
676 string16 PluginServiceImpl::GetPluginGroupName(const std::string& plugin_name) { | 669 string16 PluginServiceImpl::GetPluginGroupName(const std::string& plugin_name) { |
677 return plugin_list_->GetPluginGroupName(plugin_name); | 670 return plugin_list_->GetPluginGroupName(plugin_name); |
678 } | 671 } |
679 | 672 |
680 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { | 673 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { |
681 return plugin_list_; | 674 return plugin_list_; |
682 } | 675 } |
OLD | NEW |