Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / extension_error_controller.h
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_EXTENSION_ERROR_CONTROLLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_CONTROLLER_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/extensions/extension_error_ui.h"
10 #include "extensions/common/extension_set.h"
11
12 namespace content {
13 class BrowserContext;
14 }
15
16 namespace extensions {
17
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 {
22  public:
23   typedef ExtensionErrorUI* (*UICreateMethod)(ExtensionErrorUI::Delegate*);
24
25   ExtensionErrorController(content::BrowserContext* context, bool is_first_run);
26   virtual ~ExtensionErrorController();
27
28   void ShowErrorIfNeeded();
29
30   // Set the factory method for creating a new ExtensionErrorUI.
31   static void SetUICreateMethodForTesting(UICreateMethod method);
32
33  private:
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;
41
42   // Find any extensions that the user should be alerted about (like blacklisted
43   // extensions).
44   void IdentifyAlertableExtensions();
45
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_;
49
50   // The extensions that are blacklisted and need user approval.
51   ExtensionSet blacklisted_extensions_;
52
53   // The UI component of this controller.
54   scoped_ptr<ExtensionErrorUI> error_ui_;
55
56   // The BrowserContext with which we are associated.
57   content::BrowserContext* browser_context_;
58
59   // Whether or not this is the first run. If it is, we avoid noisy errors, and
60   // silently acknowledge blacklisted extensions.
61   bool is_first_run_;
62
63   DISALLOW_COPY_AND_ASSIGN(ExtensionErrorController);
64 };
65
66 }  // namespace extensions
67
68 #endif  // CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_CONTROLLER_H_