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

Side by Side Diff: chrome/browser/plugin_status_pref_setter.cc

Issue 10387161: Pepper Flash settings integration: add UI for "deauthorize content licenses". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes in response to Scott's suggestions Created 8 years, 7 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) 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/plugin_data_remover_helper.h" 5 #include "chrome/browser/plugin_status_pref_setter.h"
6
7 #include <string>
8 6
9 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/pepper_flash_settings_manager.h"
9 #include "chrome/browser/plugin_data_remover_helper.h"
10 #include "chrome/browser/plugin_prefs.h" 10 #include "chrome/browser/plugin_prefs.h"
11 #include "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
14 #include "chrome/common/pref_names.h"
14 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/notification_source.h" 16 #include "content/public/browser/notification_source.h"
16 #include "content/public/browser/plugin_data_remover.h"
17 #include "content/public/browser/plugin_service.h" 17 #include "content/public/browser/plugin_service.h"
18 #include "webkit/plugins/webplugininfo.h" 18 #include "webkit/plugins/webplugininfo.h"
19 19
20 using content::BrowserThread; 20 using content::BrowserThread;
21 using content::PluginService; 21 using content::PluginService;
22 22
23 PluginDataRemoverHelper::PluginDataRemoverHelper() 23 PluginStatusPrefSetter::PluginStatusPrefSetter()
24 : profile_(NULL), 24 : profile_(NULL),
25 ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {} 25 ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {}
26 26
27 PluginDataRemoverHelper::~PluginDataRemoverHelper() { 27 PluginStatusPrefSetter::~PluginStatusPrefSetter() {
28 } 28 }
29 29
30 void PluginDataRemoverHelper::Init(const char* pref_name, 30 void PluginStatusPrefSetter::Init(Profile* profile,
31 Profile* profile, 31 content::NotificationObserver* observer) {
32 content::NotificationObserver* observer) { 32 clear_plugin_lso_data_enabled_.Init(prefs::kClearPluginLSODataEnabled,
33 pref_.Init(pref_name, profile->GetPrefs(), observer); 33 profile->GetPrefs(), observer);
34 pepper_flash_settings_enabled_.Init(prefs::kPepperFlashSettingsEnabled,
35 profile->GetPrefs(), observer);
34 profile_ = profile; 36 profile_ = profile;
35 registrar_.Add(this, chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, 37 registrar_.Add(this, chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED,
36 content::Source<Profile>(profile)); 38 content::Source<Profile>(profile));
37 StartUpdate(); 39 StartUpdate();
38 } 40 }
39 41
40 // static 42 void PluginStatusPrefSetter::Observe(
41 bool PluginDataRemoverHelper::IsSupported(PluginPrefs* plugin_prefs) {
42 std::vector<webkit::WebPluginInfo> plugins;
43 content::PluginDataRemover::GetSupportedPlugins(&plugins);
44 for (std::vector<webkit::WebPluginInfo>::const_iterator it = plugins.begin();
45 it != plugins.end(); ++it) {
46 if (plugin_prefs->IsPluginEnabled(*it))
47 return true;
48 }
49 return false;
50 }
51
52 void PluginDataRemoverHelper::Observe(
53 int type, 43 int type,
54 const content::NotificationSource& source, 44 const content::NotificationSource& source,
55 const content::NotificationDetails& details) { 45 const content::NotificationDetails& details) {
56 if (type == chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED) { 46 if (type == chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED) {
57 StartUpdate(); 47 StartUpdate();
58 } else { 48 } else {
59 NOTREACHED(); 49 NOTREACHED();
60 } 50 }
61 } 51 }
62 52
63 void PluginDataRemoverHelper::StartUpdate() { 53 void PluginStatusPrefSetter::StartUpdate() {
64 PluginService::GetInstance()->GetPlugins( 54 PluginService::GetInstance()->GetPlugins(
65 base::Bind(&PluginDataRemoverHelper::GotPlugins, factory_.GetWeakPtr(), 55 base::Bind(&PluginStatusPrefSetter::GotPlugins, factory_.GetWeakPtr(),
66 PluginPrefs::GetForProfile(profile_))); 56 PluginPrefs::GetForProfile(profile_)));
67 } 57 }
68 58
69 void PluginDataRemoverHelper::GotPlugins( 59 void PluginStatusPrefSetter::GotPlugins(
70 scoped_refptr<PluginPrefs> plugin_prefs, 60 scoped_refptr<PluginPrefs> plugin_prefs,
71 const std::vector<webkit::WebPluginInfo>& plugins) { 61 const std::vector<webkit::WebPluginInfo>& /* plugins */) {
72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
73 bool supported = IsSupported(plugin_prefs); 63 // Set the values on the PrefService instead of through the PrefMembers to
74 // Set the value on the PrefService instead of through the PrefMember to 64 // notify observers if they changed.
75 // notify observers if it changed. 65 profile_->GetPrefs()->SetBoolean(
76 profile_->GetPrefs()->SetBoolean(pref_.GetPrefName().c_str(), supported); 66 clear_plugin_lso_data_enabled_.GetPrefName().c_str(),
67 PluginDataRemoverHelper::IsSupported(plugin_prefs));
68 profile_->GetPrefs()->SetBoolean(
69 pepper_flash_settings_enabled_.GetPrefName().c_str(),
70 PepperFlashSettingsManager::IsPepperFlashInUse(plugin_prefs, NULL));
77 } 71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698