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