OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include "chrome/browser/plugin_service.h" | 7 #include "chrome/browser/plugin_service.h" |
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/thread.h" | 12 #include "base/thread.h" |
| 13 #include "base/values.h" |
13 #include "base/waitable_event.h" | 14 #include "base/waitable_event.h" |
14 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/chrome_plugin_host.h" | 16 #include "chrome/browser/chrome_plugin_host.h" |
16 #include "chrome/browser/chrome_thread.h" | 17 #include "chrome/browser/chrome_thread.h" |
17 #include "chrome/browser/extensions/extensions_service.h" | 18 #include "chrome/browser/extensions/extensions_service.h" |
18 #include "chrome/browser/plugin_process_host.h" | 19 #include "chrome/browser/plugin_process_host.h" |
| 20 #include "chrome/browser/pref_service.h" |
| 21 #include "chrome/browser/profile.h" |
19 #include "chrome/browser/renderer_host/render_process_host.h" | 22 #include "chrome/browser/renderer_host/render_process_host.h" |
20 #include "chrome/common/chrome_plugin_lib.h" | 23 #include "chrome/common/chrome_plugin_lib.h" |
21 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
22 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
23 #include "chrome/common/extensions/extension.h" | 26 #include "chrome/common/extensions/extension.h" |
24 #include "chrome/common/gpu_plugin.h" | 27 #include "chrome/common/gpu_plugin.h" |
25 #include "chrome/common/logging_chrome.h" | 28 #include "chrome/common/logging_chrome.h" |
26 #include "chrome/common/notification_type.h" | 29 #include "chrome/common/notification_type.h" |
27 #include "chrome/common/notification_service.h" | 30 #include "chrome/common/notification_service.h" |
| 31 #include "chrome/common/pref_names.h" |
28 #include "chrome/common/render_messages.h" | 32 #include "chrome/common/render_messages.h" |
29 #ifndef DISABLE_NACL | 33 #ifndef DISABLE_NACL |
30 #include "native_client/src/trusted/plugin/nacl_entry_points.h" | 34 #include "native_client/src/trusted/plugin/nacl_entry_points.h" |
31 #endif | 35 #endif |
32 #include "webkit/glue/plugins/plugin_constants_win.h" | 36 #include "webkit/glue/plugins/plugin_constants_win.h" |
33 #include "webkit/glue/plugins/plugin_list.h" | 37 #include "webkit/glue/plugins/plugin_list.h" |
34 | 38 |
35 #if defined(OS_MACOSX) | 39 #if defined(OS_MACOSX) |
36 static void NotifyPluginsOfActivation() { | 40 static void NotifyPluginsOfActivation() { |
37 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 41 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
38 | 42 |
39 for (ChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS); | 43 for (ChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS); |
40 !iter.Done(); ++iter) { | 44 !iter.Done(); ++iter) { |
41 PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter); | 45 PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter); |
42 plugin->OnAppActivation(); | 46 plugin->OnAppActivation(); |
43 } | 47 } |
44 } | 48 } |
45 #endif | 49 #endif |
46 | 50 |
47 // static | 51 // static |
48 bool PluginService::enable_chrome_plugins_ = true; | 52 bool PluginService::enable_chrome_plugins_ = true; |
49 | 53 |
50 // static | 54 // static |
| 55 void PluginService::InitGlobalInstance(Profile* profile) { |
| 56 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
| 57 |
| 58 // Disable plugins listed as disabled in prefs. |
| 59 if (const ListValue* saved_plugins_list = |
| 60 profile->GetPrefs()->GetList(prefs::kPluginsPluginsList)) { |
| 61 for (ListValue::const_iterator it = saved_plugins_list->begin(); |
| 62 it != saved_plugins_list->end(); |
| 63 ++it) { |
| 64 if (!(*it)->IsType(Value::TYPE_DICTIONARY)) { |
| 65 LOG(WARNING) << "Invalid entry in " << prefs::kPluginsPluginsList; |
| 66 continue; // Oops, don't know what to do with this item. |
| 67 } |
| 68 |
| 69 DictionaryValue* plugin = static_cast<DictionaryValue*>(*it); |
| 70 FilePath::StringType path; |
| 71 bool enabled = true; |
| 72 plugin->GetBoolean(L"enabled", &enabled); |
| 73 if (!enabled && plugin->GetString(L"path", &path)) |
| 74 NPAPI::PluginList::Singleton()->DisablePlugin(FilePath(path)); |
| 75 } |
| 76 } |
| 77 |
| 78 // Have Chrome plugins write their data to the profile directory. |
| 79 GetInstance()->SetChromePluginDataDir(profile->GetPath()); |
| 80 } |
| 81 |
| 82 // static |
51 PluginService* PluginService::GetInstance() { | 83 PluginService* PluginService::GetInstance() { |
52 return Singleton<PluginService>::get(); | 84 return Singleton<PluginService>::get(); |
53 } | 85 } |
54 | 86 |
55 // static | 87 // static |
56 void PluginService::EnableChromePlugins(bool enable) { | 88 void PluginService::EnableChromePlugins(bool enable) { |
57 enable_chrome_plugins_ = enable; | 89 enable_chrome_plugins_ = enable; |
58 } | 90 } |
59 | 91 |
60 PluginService::PluginService() | 92 PluginService::PluginService() |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 PrivatePluginMap::iterator it = private_plugins_.find(plugin_path); | 337 PrivatePluginMap::iterator it = private_plugins_.find(plugin_path); |
306 if (it == private_plugins_.end()) | 338 if (it == private_plugins_.end()) |
307 return true; // This plugin is not private, so it's allowed everywhere. | 339 return true; // This plugin is not private, so it's allowed everywhere. |
308 | 340 |
309 // We do a dumb compare of scheme and host, rather than using the domain | 341 // We do a dumb compare of scheme and host, rather than using the domain |
310 // service, since we only care about this for extensions. | 342 // service, since we only care about this for extensions. |
311 const GURL& required_url = it->second; | 343 const GURL& required_url = it->second; |
312 return (url.scheme() == required_url.scheme() && | 344 return (url.scheme() == required_url.scheme() && |
313 url.host() == required_url.host()); | 345 url.host() == required_url.host()); |
314 } | 346 } |
OLD | NEW |