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 "chrome/browser/plugins/plugin_prefs.h" | 5 #include "chrome/browser/plugins/plugin_prefs.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/prefs/scoped_user_pref_update.h" | 14 #include "base/prefs/scoped_user_pref_update.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/chrome_notification_types.h" | 20 #include "chrome/browser/chrome_notification_types.h" |
21 #include "chrome/browser/plugins/plugin_installer.h" | 21 #include "chrome/browser/plugins/plugin_installer.h" |
22 #include "chrome/browser/plugins/plugin_metadata.h" | 22 #include "chrome/browser/plugins/plugin_metadata.h" |
23 #include "chrome/browser/plugins/plugin_prefs_factory.h" | 23 #include "chrome/browser/plugins/plugin_prefs_factory.h" |
24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/common/chrome_constants.h" | 25 #include "chrome/common/chrome_constants.h" |
26 #include "chrome/common/chrome_content_client.h" | |
27 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
28 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
29 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
30 #include "components/keyed_service/core/keyed_service.h" | 29 #include "components/keyed_service/core/keyed_service.h" |
31 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
32 #include "content/public/browser/notification_service.h" | 31 #include "content/public/browser/notification_service.h" |
33 #include "content/public/browser/plugin_service.h" | 32 #include "content/public/browser/plugin_service.h" |
34 #include "content/public/common/webplugininfo.h" | 33 #include "content/public/common/webplugininfo.h" |
35 | 34 |
| 35 #if !defined(DISABLE_NACL) |
| 36 #include "components/nacl/common/nacl_constants.h" |
| 37 #endif |
| 38 |
36 using content::BrowserThread; | 39 using content::BrowserThread; |
37 using content::PluginService; | 40 using content::PluginService; |
38 | 41 |
39 namespace { | 42 namespace { |
40 | 43 |
41 bool IsComponentUpdatedPepperFlash(const base::FilePath& plugin) { | 44 bool IsComponentUpdatedPepperFlash(const base::FilePath& plugin) { |
42 if (plugin.BaseName().value() == chrome::kPepperFlashPluginFilename) { | 45 if (plugin.BaseName().value() == chrome::kPepperFlashPluginFilename) { |
43 base::FilePath component_updated_pepper_flash_dir; | 46 base::FilePath component_updated_pepper_flash_dir; |
44 if (PathService::Get(chrome::DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN, | 47 if (PathService::Get(chrome::DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN, |
45 &component_updated_pepper_flash_dir) && | 48 &component_updated_pepper_flash_dir) && |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 // Check if the plug-in or its group is enabled by policy. | 237 // Check if the plug-in or its group is enabled by policy. |
235 PolicyStatus plugin_status = PolicyStatusForPlugin(plugin.name); | 238 PolicyStatus plugin_status = PolicyStatusForPlugin(plugin.name); |
236 PolicyStatus group_status = PolicyStatusForPlugin(group_name); | 239 PolicyStatus group_status = PolicyStatusForPlugin(group_name); |
237 if (plugin_status == POLICY_ENABLED || group_status == POLICY_ENABLED) | 240 if (plugin_status == POLICY_ENABLED || group_status == POLICY_ENABLED) |
238 return true; | 241 return true; |
239 | 242 |
240 // Check if the plug-in or its group is disabled by policy. | 243 // Check if the plug-in or its group is disabled by policy. |
241 if (plugin_status == POLICY_DISABLED || group_status == POLICY_DISABLED) | 244 if (plugin_status == POLICY_DISABLED || group_status == POLICY_DISABLED) |
242 return false; | 245 return false; |
243 | 246 |
| 247 #if !defined(DISABLE_NACL) |
244 // If enabling NaCl, make sure the plugin is also enabled. See bug | 248 // If enabling NaCl, make sure the plugin is also enabled. See bug |
245 // http://code.google.com/p/chromium/issues/detail?id=81010 for more | 249 // http://code.google.com/p/chromium/issues/detail?id=81010 for more |
246 // information. | 250 // information. |
247 // TODO(dspringer): When NaCl is on by default, remove this code. | 251 // TODO(dspringer): When NaCl is on by default, remove this code. |
248 if ((plugin.name == | 252 if ((plugin.name == base::ASCIIToUTF16(nacl::kNaClPluginName)) && |
249 base::ASCIIToUTF16(ChromeContentClient::kNaClPluginName)) && | |
250 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableNaCl)) { | 253 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableNaCl)) { |
251 return true; | 254 return true; |
252 } | 255 } |
| 256 #endif |
253 | 257 |
254 base::AutoLock auto_lock(lock_); | 258 base::AutoLock auto_lock(lock_); |
255 // Check user preferences for the plug-in. | 259 // Check user preferences for the plug-in. |
256 bool plugin_enabled = false; | 260 bool plugin_enabled = false; |
257 if (plugin_state_.Get(plugin.path, &plugin_enabled)) | 261 if (plugin_state_.Get(plugin.path, &plugin_enabled)) |
258 return plugin_enabled; | 262 return plugin_enabled; |
259 | 263 |
260 // Check user preferences for the plug-in group. | 264 // Check user preferences for the plug-in group. |
261 std::map<base::string16, bool>::const_iterator group_it( | 265 std::map<base::string16, bool>::const_iterator group_it( |
262 plugin_group_state_.find(group_name)); | 266 plugin_group_state_.find(group_name)); |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 } | 577 } |
574 } | 578 } |
575 | 579 |
576 void PluginPrefs::NotifyPluginStatusChanged() { | 580 void PluginPrefs::NotifyPluginStatusChanged() { |
577 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 581 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
578 content::NotificationService::current()->Notify( | 582 content::NotificationService::current()->Notify( |
579 chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, | 583 chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, |
580 content::Source<Profile>(profile_), | 584 content::Source<Profile>(profile_), |
581 content::NotificationService::NoDetails()); | 585 content::NotificationService::NoDetails()); |
582 } | 586 } |
OLD | NEW |