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

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

Powered by Google App Engine
This is Rietveld 408576698