OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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_INSTALL_MANAGER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_INSTALL_MANAGER_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/scoped_observer.h" |
| 11 #include "content/public/browser/notification_observer.h" |
| 12 #include "content/public/browser/notification_registrar.h" |
| 13 #include "extensions/browser/extension_registry_observer.h" |
| 14 |
| 15 class GlobalErrorService; |
| 16 |
| 17 namespace content { |
| 18 class BrowserContext; |
| 19 class NotificationDetails; |
| 20 class NotificationSource; |
| 21 } |
| 22 |
| 23 namespace extensions { |
| 24 class Extension; |
| 25 class ExtensionRegistry; |
| 26 class ExternalInstallError; |
| 27 |
| 28 class ExternalInstallManager : public ExtensionRegistryObserver, |
| 29 public content::NotificationObserver { |
| 30 public: |
| 31 explicit ExternalInstallManager(content::BrowserContext* browser_context); |
| 32 virtual ~ExternalInstallManager(); |
| 33 |
| 34 // Adds a global error informing the user that an external extension was |
| 35 // installed. If |is_new_profile| is true, then this error is from the first |
| 36 // time our profile checked for new extensions. |
| 37 void AddExternalInstallError(const Extension* extension, bool is_new_profile); |
| 38 |
| 39 // Removes the global error, if one existed. |
| 40 void RemoveExternalInstallError(); |
| 41 |
| 42 // Returns true if there is a global error for an external install. |
| 43 bool HasExternalInstallError() const; |
| 44 |
| 45 // Returns true if there is a global error with a bubble view for an external |
| 46 // install. Used for testing. |
| 47 bool HasExternalInstallBubble() const; |
| 48 |
| 49 // Returns the current install error, if one exists. |
| 50 const ExternalInstallError* error() { return error_.get(); } |
| 51 |
| 52 private: |
| 53 // ExtensionRegistryObserver implementation. |
| 54 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 55 const Extension* extension) OVERRIDE; |
| 56 |
| 57 // content::NotificationObserver implementation. |
| 58 virtual void Observe(int type, |
| 59 const content::NotificationSource& source, |
| 60 const content::NotificationDetails& details) OVERRIDE; |
| 61 |
| 62 // The associated BrowserContext. |
| 63 content::BrowserContext* browser_context_; |
| 64 |
| 65 // The current ExternalInstallError, if one exists. |
| 66 scoped_ptr<ExternalInstallError> error_; |
| 67 |
| 68 content::NotificationRegistrar registrar_; |
| 69 |
| 70 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 71 extension_registry_observer_; |
| 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(ExternalInstallManager); |
| 74 }; |
| 75 |
| 76 } // namespace extensions |
| 77 |
| 78 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_INSTALL_MANAGER_H_ |
OLD | NEW |