Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / chrome / browser / extensions / external_install_manager.h
blobcd351afab0e5ec906e3160b2700c5c36c64a131d
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 namespace content {
16 class BrowserContext;
17 class NotificationDetails;
18 class NotificationSource;
21 namespace extensions {
22 class Extension;
23 class ExtensionRegistry;
24 class ExtensionPrefs;
25 class ExternalInstallError;
27 class ExternalInstallManager : public ExtensionRegistryObserver,
28 public content::NotificationObserver {
29 public:
30 ExternalInstallManager(content::BrowserContext* browser_context,
31 bool is_first_run);
32 ~ExternalInstallManager() override;
34 // Removes the global error, if one existed.
35 void RemoveExternalInstallError();
37 // Returns true if there is a global error for an external install.
38 bool HasExternalInstallError() const;
40 // Checks if there are any new external extensions to notify the user about.
41 void UpdateExternalExtensionAlert();
43 // Given a (presumably just-installed) extension id, mark that extension as
44 // acknowledged.
45 void AcknowledgeExternalExtension(const std::string& extension_id);
47 // Returns true if there is a global error with a bubble view for an external
48 // install. Used for testing.
49 bool HasExternalInstallBubbleForTesting() const;
51 // Returns the current install error, if one exists.
52 const ExternalInstallError* error() { return error_.get(); }
54 // Returns a mutable copy of the error for testing purposes.
55 ExternalInstallError* error_for_testing() { return error_.get(); }
57 private:
58 // ExtensionRegistryObserver implementation.
59 void OnExtensionLoaded(content::BrowserContext* browser_context,
60 const Extension* extension) override;
61 void OnExtensionInstalled(content::BrowserContext* browser_context,
62 const Extension* extension,
63 bool is_update) override;
64 void OnExtensionUninstalled(content::BrowserContext* browser_context,
65 const Extension* extension,
66 extensions::UninstallReason reason) override;
68 // content::NotificationObserver implementation.
69 void Observe(int type,
70 const content::NotificationSource& source,
71 const content::NotificationDetails& details) override;
73 // Adds a global error informing the user that an external extension was
74 // installed. If |is_new_profile| is true, then this error is from the first
75 // time our profile checked for new extensions.
76 void AddExternalInstallError(const Extension* extension, bool is_new_profile);
78 // Returns true if this extension is an external one that has yet to be
79 // marked as acknowledged.
80 bool IsUnacknowledgedExternalExtension(const Extension* extension) const;
82 // The associated BrowserContext.
83 content::BrowserContext* browser_context_;
85 // Whether or not this is the first run for the profile.
86 bool is_first_run_;
88 // The associated ExtensionPrefs.
89 ExtensionPrefs* extension_prefs_;
91 // The current ExternalInstallError, if one exists.
92 scoped_ptr<ExternalInstallError> error_;
94 content::NotificationRegistrar registrar_;
96 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
97 extension_registry_observer_;
99 DISALLOW_COPY_AND_ASSIGN(ExternalInstallManager);
102 } // namespace extensions
104 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_INSTALL_MANAGER_H_