OLD | NEW |
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 "chrome/browser/plugin_updater.h" | 5 #include "chrome/browser/plugin_updater.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "base/version.h" | 14 #include "base/version.h" |
15 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
16 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 16 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/common/chrome_content_client.h" | 18 #include "chrome/common/chrome_content_client.h" |
| 19 #include "chrome/common/chrome_notification_types.h" |
19 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
20 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
21 #include "content/browser/browser_thread.h" | 22 #include "content/browser/browser_thread.h" |
22 #include "content/common/notification_service.h" | 23 #include "content/common/notification_service.h" |
23 #include "webkit/plugins/npapi/plugin_list.h" | 24 #include "webkit/plugins/npapi/plugin_list.h" |
24 #include "webkit/plugins/npapi/webplugininfo.h" | 25 #include "webkit/plugins/npapi/webplugininfo.h" |
25 | 26 |
26 // How long to wait to save the plugin enabled information, which might need to | 27 // How long to wait to save the plugin enabled information, which might need to |
27 // go to disk. | 28 // go to disk. |
28 #define kPluginUpdateDelayMs (60 * 1000) | 29 #define kPluginUpdateDelayMs (60 * 1000) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 const FilePath::StringType& path) { | 64 const FilePath::StringType& path) { |
64 FilePath file_path(path); | 65 FilePath file_path(path); |
65 if (enable) | 66 if (enable) |
66 webkit::npapi::PluginList::Singleton()->EnablePlugin(file_path); | 67 webkit::npapi::PluginList::Singleton()->EnablePlugin(file_path); |
67 else | 68 else |
68 webkit::npapi::PluginList::Singleton()->DisablePlugin(file_path); | 69 webkit::npapi::PluginList::Singleton()->DisablePlugin(file_path); |
69 | 70 |
70 NotifyPluginStatusChanged(); | 71 NotifyPluginStatusChanged(); |
71 } | 72 } |
72 | 73 |
73 void PluginUpdater::Observe(NotificationType type, | 74 void PluginUpdater::Observe(int type, |
74 const NotificationSource& source, | 75 const NotificationSource& source, |
75 const NotificationDetails& details) { | 76 const NotificationDetails& details) { |
76 DCHECK_EQ(NotificationType::PREF_CHANGED, type.value); | 77 DCHECK_EQ(chrome::NOTIFICATION_PREF_CHANGED, type); |
77 const std::string* pref_name = Details<std::string>(details).ptr(); | 78 const std::string* pref_name = Details<std::string>(details).ptr(); |
78 if (!pref_name) { | 79 if (!pref_name) { |
79 NOTREACHED(); | 80 NOTREACHED(); |
80 return; | 81 return; |
81 } | 82 } |
82 if (*pref_name == prefs::kPluginsDisabledPlugins || | 83 if (*pref_name == prefs::kPluginsDisabledPlugins || |
83 *pref_name == prefs::kPluginsDisabledPluginsExceptions || | 84 *pref_name == prefs::kPluginsDisabledPluginsExceptions || |
84 *pref_name == prefs::kPluginsEnabledPlugins) { | 85 *pref_name == prefs::kPluginsEnabledPlugins) { |
85 PrefService* pref_service = Source<PrefService>(source).ptr(); | 86 PrefService* pref_service = Source<PrefService>(source).ptr(); |
86 const ListValue* disabled_list = | 87 const ListValue* disabled_list = |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 return; | 322 return; |
322 notify_pending_ = true; | 323 notify_pending_ = true; |
323 MessageLoop::current()->PostTask( | 324 MessageLoop::current()->PostTask( |
324 FROM_HERE, | 325 FROM_HERE, |
325 NewRunnableFunction(&PluginUpdater::OnNotifyPluginStatusChanged)); | 326 NewRunnableFunction(&PluginUpdater::OnNotifyPluginStatusChanged)); |
326 } | 327 } |
327 | 328 |
328 void PluginUpdater::OnNotifyPluginStatusChanged() { | 329 void PluginUpdater::OnNotifyPluginStatusChanged() { |
329 GetInstance()->notify_pending_ = false; | 330 GetInstance()->notify_pending_ = false; |
330 NotificationService::current()->Notify( | 331 NotificationService::current()->Notify( |
331 NotificationType::PLUGIN_ENABLE_STATUS_CHANGED, | 332 content::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, |
332 Source<PluginUpdater>(GetInstance()), | 333 Source<PluginUpdater>(GetInstance()), |
333 NotificationService::NoDetails()); | 334 NotificationService::NoDetails()); |
334 } | 335 } |
335 | 336 |
336 /*static*/ | 337 /*static*/ |
337 PluginUpdater* PluginUpdater::GetInstance() { | 338 PluginUpdater* PluginUpdater::GetInstance() { |
338 return Singleton<PluginUpdater>::get(); | 339 return Singleton<PluginUpdater>::get(); |
339 } | 340 } |
340 | 341 |
341 /*static*/ | 342 /*static*/ |
342 void PluginUpdater::RegisterPrefs(PrefService* prefs) { | 343 void PluginUpdater::RegisterPrefs(PrefService* prefs) { |
343 FilePath internal_dir; | 344 FilePath internal_dir; |
344 PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir); | 345 PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir); |
345 prefs->RegisterFilePathPref(prefs::kPluginsLastInternalDirectory, | 346 prefs->RegisterFilePathPref(prefs::kPluginsLastInternalDirectory, |
346 internal_dir, | 347 internal_dir, |
347 PrefService::UNSYNCABLE_PREF); | 348 PrefService::UNSYNCABLE_PREF); |
348 prefs->RegisterListPref(prefs::kPluginsDisabledPlugins, | 349 prefs->RegisterListPref(prefs::kPluginsDisabledPlugins, |
349 PrefService::UNSYNCABLE_PREF); | 350 PrefService::UNSYNCABLE_PREF); |
350 prefs->RegisterListPref(prefs::kPluginsDisabledPluginsExceptions, | 351 prefs->RegisterListPref(prefs::kPluginsDisabledPluginsExceptions, |
351 PrefService::UNSYNCABLE_PREF); | 352 PrefService::UNSYNCABLE_PREF); |
352 prefs->RegisterListPref(prefs::kPluginsEnabledPlugins, | 353 prefs->RegisterListPref(prefs::kPluginsEnabledPlugins, |
353 PrefService::UNSYNCABLE_PREF); | 354 PrefService::UNSYNCABLE_PREF); |
354 } | 355 } |
OLD | NEW |