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