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