| 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/plugin_data_remover_helper.h" | 5 #include "chrome/browser/plugin_data_remover_helper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "chrome/browser/plugin_prefs.h" | 10 #include "chrome/browser/plugin_prefs.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 content::NotificationObserver* observer) { | 32 content::NotificationObserver* observer) { |
| 33 pref_.Init(pref_name, profile->GetPrefs(), observer); | 33 pref_.Init(pref_name, profile->GetPrefs(), observer); |
| 34 profile_ = profile; | 34 profile_ = profile; |
| 35 registrar_.Add(this, chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, | 35 registrar_.Add(this, chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, |
| 36 content::Source<Profile>(profile)); | 36 content::Source<Profile>(profile)); |
| 37 StartUpdate(); | 37 StartUpdate(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 // static | 40 // static |
| 41 bool PluginDataRemoverHelper::IsSupported(PluginPrefs* plugin_prefs) { | 41 bool PluginDataRemoverHelper::IsSupported(PluginPrefs* plugin_prefs) { |
| 42 webkit::WebPluginInfo plugin; | 42 std::vector<webkit::WebPluginInfo> plugins; |
| 43 return content::PluginDataRemover::IsSupported(&plugin) && | 43 content::PluginDataRemover::GetSupportedPlugins(&plugins); |
| 44 plugin_prefs->IsPluginEnabled(plugin); | 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; |
| 45 } | 50 } |
| 46 | 51 |
| 47 void PluginDataRemoverHelper::Observe( | 52 void PluginDataRemoverHelper::Observe( |
| 48 int type, | 53 int type, |
| 49 const content::NotificationSource& source, | 54 const content::NotificationSource& source, |
| 50 const content::NotificationDetails& details) { | 55 const content::NotificationDetails& details) { |
| 51 if (type == chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED) { | 56 if (type == chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED) { |
| 52 StartUpdate(); | 57 StartUpdate(); |
| 53 } else { | 58 } else { |
| 54 NOTREACHED(); | 59 NOTREACHED(); |
| 55 } | 60 } |
| 56 } | 61 } |
| 57 | 62 |
| 58 void PluginDataRemoverHelper::StartUpdate() { | 63 void PluginDataRemoverHelper::StartUpdate() { |
| 59 PluginService::GetInstance()->GetPlugins( | 64 PluginService::GetInstance()->GetPlugins( |
| 60 base::Bind(&PluginDataRemoverHelper::GotPlugins, factory_.GetWeakPtr(), | 65 base::Bind(&PluginDataRemoverHelper::GotPlugins, factory_.GetWeakPtr(), |
| 61 PluginPrefs::GetForProfile(profile_))); | 66 PluginPrefs::GetForProfile(profile_))); |
| 62 } | 67 } |
| 63 | 68 |
| 64 void PluginDataRemoverHelper::GotPlugins( | 69 void PluginDataRemoverHelper::GotPlugins( |
| 65 scoped_refptr<PluginPrefs> plugin_prefs, | 70 scoped_refptr<PluginPrefs> plugin_prefs, |
| 66 const std::vector<webkit::WebPluginInfo>& plugins) { | 71 const std::vector<webkit::WebPluginInfo>& plugins) { |
| 67 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 68 bool supported = IsSupported(plugin_prefs); | 73 bool supported = IsSupported(plugin_prefs); |
| 69 // Set the value on the PrefService instead of through the PrefMember to | 74 // Set the value on the PrefService instead of through the PrefMember to |
| 70 // notify observers if it changed. | 75 // notify observers if it changed. |
| 71 profile_->GetPrefs()->SetBoolean(pref_.GetPrefName().c_str(), supported); | 76 profile_->GetPrefs()->SetBoolean(pref_.GetPrefName().c_str(), supported); |
| 72 } | 77 } |
| OLD | NEW |