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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTERNAL_INSTALL_MANAGER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_INSTALL_MANAGER_H_
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"
15 class GlobalErrorService
;
19 class NotificationDetails
;
20 class NotificationSource
;
23 namespace extensions
{
25 class ExtensionRegistry
;
26 class ExternalInstallError
;
28 class ExternalInstallManager
: public ExtensionRegistryObserver
,
29 public content::NotificationObserver
{
31 explicit ExternalInstallManager(content::BrowserContext
* browser_context
);
32 virtual ~ExternalInstallManager();
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
);
39 // Removes the global error, if one existed.
40 void RemoveExternalInstallError();
42 // Returns true if there is a global error for an external install.
43 bool HasExternalInstallError() const;
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;
49 // Returns the current install error, if one exists.
50 const ExternalInstallError
* error() { return error_
.get(); }
52 // Returns a mutable copy of the error for testing purposes.
53 ExternalInstallError
* error_for_testing() { return error_
.get(); }
56 // ExtensionRegistryObserver implementation.
57 virtual void OnExtensionLoaded(content::BrowserContext
* browser_context
,
58 const Extension
* extension
) OVERRIDE
;
60 // content::NotificationObserver implementation.
61 virtual void Observe(int type
,
62 const content::NotificationSource
& source
,
63 const content::NotificationDetails
& details
) OVERRIDE
;
65 // The associated BrowserContext.
66 content::BrowserContext
* browser_context_
;
68 // The current ExternalInstallError, if one exists.
69 scoped_ptr
<ExternalInstallError
> error_
;
71 content::NotificationRegistrar registrar_
;
73 ScopedObserver
<ExtensionRegistry
, ExtensionRegistryObserver
>
74 extension_registry_observer_
;
76 DISALLOW_COPY_AND_ASSIGN(ExternalInstallManager
);
79 } // namespace extensions
81 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_INSTALL_MANAGER_H_