| OLD | NEW |
| 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_PLUGIN_DATA_REMOVER_HELPER_H_ | 5 #ifndef CHROME_BROWSER_PLUGIN_STATUS_PREF_SETTER_H_ |
| 6 #define CHROME_BROWSER_PLUGIN_DATA_REMOVER_HELPER_H_ | 6 #define CHROME_BROWSER_PLUGIN_STATUS_PREF_SETTER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "chrome/browser/prefs/pref_member.h" | 13 #include "chrome/browser/prefs/pref_member.h" |
| 14 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 16 | 16 |
| 17 class PluginPrefs; | 17 class PluginPrefs; |
| 18 class PrefService; |
| 18 class Profile; | 19 class Profile; |
| 19 | 20 |
| 20 namespace webkit { | 21 namespace webkit { |
| 21 struct WebPluginInfo; | 22 struct WebPluginInfo; |
| 22 } | 23 } |
| 23 | 24 |
| 24 // Helper class modeled after BooleanPrefMember to (asynchronously) update | 25 // Helper class modeled after BooleanPrefMember to (asynchronously) update |
| 25 // the preference specifying whether clearing plug-in data is supported | 26 // preferences related to plugin enable status. |
| 26 // by an installed plug-in. | |
| 27 // It should only be used from the UI thread. The client has to make sure that | 27 // It should only be used from the UI thread. The client has to make sure that |
| 28 // the passed profile outlives this object. | 28 // the passed profile outlives this object. |
| 29 class PluginDataRemoverHelper : public content::NotificationObserver { | 29 class PluginStatusPrefSetter : public content::NotificationObserver { |
| 30 public: | 30 public: |
| 31 PluginDataRemoverHelper(); | 31 PluginStatusPrefSetter(); |
| 32 virtual ~PluginDataRemoverHelper(); | 32 virtual ~PluginStatusPrefSetter(); |
| 33 | 33 |
| 34 // Binds this object to the |pref_name| preference in the profile's | 34 // Binds the preferences in the profile's PrefService, notifying |observer| if |
| 35 // PrefService, notifying |observer| if the value changes. | 35 // any value changes. |
| 36 // This asynchronously calls the PluginService to get the list of installed | 36 // This asynchronously calls the PluginService to get the list of installed |
| 37 // plug-ins. | 37 // plug-ins. |
| 38 void Init(const char* pref_name, | 38 void Init(Profile* profile, |
| 39 Profile* profile, | |
| 40 content::NotificationObserver* observer); | 39 content::NotificationObserver* observer); |
| 41 | 40 |
| 42 bool GetValue() const { return pref_.GetValue(); } | 41 bool IsClearPluginLSODataEnabled() const { |
| 42 return clear_plugin_lso_data_enabled_.GetValue(); |
| 43 } |
| 43 | 44 |
| 44 // Like PluginDataRemover::IsSupported, but checks that the returned plugin | 45 bool IsPepperFlashSettingsEnabled() const { |
| 45 // is enabled by PluginPrefs | 46 return pepper_flash_settings_enabled_.GetValue(); |
| 46 static bool IsSupported(PluginPrefs* plugin_prefs); | 47 } |
| 47 | 48 |
| 48 // content::NotificationObserver methods: | 49 // content::NotificationObserver methods: |
| 49 virtual void Observe(int type, | 50 virtual void Observe(int type, |
| 50 const content::NotificationSource& source, | 51 const content::NotificationSource& source, |
| 51 const content::NotificationDetails& details) OVERRIDE; | 52 const content::NotificationDetails& details) OVERRIDE; |
| 52 | 53 |
| 53 private: | 54 private: |
| 54 void StartUpdate(); | 55 void StartUpdate(); |
| 55 void GotPlugins(scoped_refptr<PluginPrefs> plugin_prefs, | 56 void GotPlugins(scoped_refptr<PluginPrefs> plugin_prefs, |
| 56 const std::vector<webkit::WebPluginInfo>& plugins); | 57 const std::vector<webkit::WebPluginInfo>& plugins); |
| 57 | 58 |
| 58 BooleanPrefMember pref_; | |
| 59 content::NotificationRegistrar registrar_; | 59 content::NotificationRegistrar registrar_; |
| 60 // Weak pointer. | 60 // Weak pointer. |
| 61 Profile* profile_; | 61 Profile* profile_; |
| 62 base::WeakPtrFactory<PluginDataRemoverHelper> factory_; | 62 base::WeakPtrFactory<PluginStatusPrefSetter> factory_; |
| 63 | 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(PluginDataRemoverHelper); | 64 // Whether clearing LSO data is supported. |
| 65 BooleanPrefMember clear_plugin_lso_data_enabled_; |
| 66 // Whether we should show Pepper Flash-specific settings. |
| 67 BooleanPrefMember pepper_flash_settings_enabled_; |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(PluginStatusPrefSetter); |
| 65 }; | 70 }; |
| 66 | 71 |
| 67 #endif // CHROME_BROWSER_PLUGIN_DATA_REMOVER_HELPER_H_ | 72 #endif // CHROME_BROWSER_PLUGIN_STATUS_PREF_SETTER_H_ |
| OLD | NEW |