| 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTERNAL_POLICY_LOADER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTERNAL_POLICY_LOADER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_POLICY_LOADER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_POLICY_LOADER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/prefs/pref_change_registrar.h" | 11 #include "chrome/browser/extensions/extension_management.h" |
| 12 #include "chrome/browser/extensions/external_loader.h" | 12 #include "chrome/browser/extensions/external_loader.h" |
| 13 #include "content/public/browser/notification_observer.h" | |
| 14 #include "content/public/browser/notification_registrar.h" | |
| 15 | |
| 16 class Profile; | |
| 17 | 13 |
| 18 namespace base { | 14 namespace base { |
| 19 class DictionaryValue; | 15 class DictionaryValue; |
| 20 } | 16 } |
| 21 | 17 |
| 22 namespace extensions { | 18 namespace extensions { |
| 23 | 19 |
| 24 // A specialization of the ExternalProvider that uses | 20 // A specialization of the ExternalProvider that uses extension management |
| 25 // pref_names::kInstallForceList to look up which external extensions are | 21 // policies to look up which external extensions are registered. |
| 26 // registered. | 22 class ExternalPolicyLoader : public ExternalLoader, |
| 27 class ExternalPolicyLoader | 23 public ExtensionManagement::Observer { |
| 28 : public ExternalLoader, | |
| 29 public content::NotificationObserver { | |
| 30 public: | 24 public: |
| 31 explicit ExternalPolicyLoader(Profile* profile); | 25 explicit ExternalPolicyLoader(ExtensionManagement* settings); |
| 32 | 26 |
| 33 // content::NotificationObserver implementation | 27 // ExtensionManagement::Observer implementation |
| 34 virtual void Observe(int type, | 28 virtual void OnExtensionManagementSettingsChanged() OVERRIDE; |
| 35 const content::NotificationSource& source, | |
| 36 const content::NotificationDetails& details) OVERRIDE; | |
| 37 | 29 |
| 38 // Adds an extension to be updated to the pref dictionary. | 30 // Adds an extension to be updated to the pref dictionary. |
| 39 static void AddExtension(base::DictionaryValue* dict, | 31 static void AddExtension(base::DictionaryValue* dict, |
| 40 const std::string& extension_id, | 32 const std::string& extension_id, |
| 41 const std::string& update_url); | 33 const std::string& update_url); |
| 42 | 34 |
| 43 protected: | 35 protected: |
| 44 virtual void StartLoading() OVERRIDE; | 36 virtual void StartLoading() OVERRIDE; |
| 45 | 37 |
| 46 private: | 38 private: |
| 47 friend class base::RefCountedThreadSafe<ExternalLoader>; | 39 friend class base::RefCountedThreadSafe<ExternalLoader>; |
| 48 | 40 |
| 49 virtual ~ExternalPolicyLoader() {} | 41 virtual ~ExternalPolicyLoader(); |
| 50 | 42 |
| 51 PrefChangeRegistrar pref_change_registrar_; | 43 ExtensionManagement* settings_; |
| 52 content::NotificationRegistrar notification_registrar_; | |
| 53 | |
| 54 Profile* profile_; | |
| 55 | 44 |
| 56 DISALLOW_COPY_AND_ASSIGN(ExternalPolicyLoader); | 45 DISALLOW_COPY_AND_ASSIGN(ExternalPolicyLoader); |
| 57 }; | 46 }; |
| 58 | 47 |
| 59 } // namespace extensions | 48 } // namespace extensions |
| 60 | 49 |
| 61 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_POLICY_LOADER_H_ | 50 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_POLICY_LOADER_H_ |
| OLD | NEW |