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_EXTENSION_ERROR_CONTROLLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_CONTROLLER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/extensions/extension_error_ui.h"
10 #include "extensions/common/extension_set.h"
16 namespace extensions
{
18 // The controller for the ExtensionErrorUI. This examines extensions for any
19 // blacklisted or external extensions in order to notify the user with an error.
20 // On acceptance, this will acknowledge the extensions.
21 class ExtensionErrorController
: public ExtensionErrorUI::Delegate
{
23 typedef ExtensionErrorUI
* (*UICreateMethod
)(ExtensionErrorUI::Delegate
*);
25 ExtensionErrorController(content::BrowserContext
* context
, bool is_first_run
);
26 virtual ~ExtensionErrorController();
28 void ShowErrorIfNeeded();
30 // Set the factory method for creating a new ExtensionErrorUI.
31 static void SetUICreateMethodForTesting(UICreateMethod method
);
34 // ExtensionErrorUI::Delegate implementation:
35 content::BrowserContext
* GetContext() override
;
36 const ExtensionSet
& GetExternalExtensions() override
;
37 const ExtensionSet
& GetBlacklistedExtensions() override
;
38 void OnAlertDetails() override
;
39 void OnAlertAccept() override
;
40 void OnAlertClosed() override
;
42 // Find any extensions that the user should be alerted about (like blacklisted
44 void IdentifyAlertableExtensions();
46 // TODO(rdevlin.cronin): We never seem to use |external_extensions_| here,
47 // but we do warn about them. Investigate more.
48 ExtensionSet external_extensions_
;
50 // The extensions that are blacklisted and need user approval.
51 ExtensionSet blacklisted_extensions_
;
53 // The UI component of this controller.
54 scoped_ptr
<ExtensionErrorUI
> error_ui_
;
56 // The BrowserContext with which we are associated.
57 content::BrowserContext
* browser_context_
;
59 // Whether or not this is the first run. If it is, we avoid noisy errors, and
60 // silently acknowledge blacklisted extensions.
63 DISALLOW_COPY_AND_ASSIGN(ExtensionErrorController
);
66 } // namespace extensions
68 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_CONTROLLER_H_