[email protected] | 8922698 | 2012-07-16 20:09:18 | [diff] [blame] | 1 | // Copyright (c) 2012 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_UI_H_ | ||||
6 | #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_UI_H_ | ||||
7 | |||||
[email protected] | 373daf97 | 2014-04-10 01:50:44 | [diff] [blame] | 8 | #include <vector> |
[email protected] | 8922698 | 2012-07-16 20:09:18 | [diff] [blame] | 9 | |
[email protected] | 373daf97 | 2014-04-10 01:50:44 | [diff] [blame] | 10 | #include "base/macros.h" |
11 | #include "base/strings/string16.h" | ||||
12 | |||||
13 | namespace content { | ||||
14 | class BrowserContext; | ||||
15 | } | ||||
16 | |||||
17 | namespace extensions { | ||||
18 | |||||
19 | class ExtensionSet; | ||||
[email protected] | 8922698 | 2012-07-16 20:09:18 | [diff] [blame] | 20 | |
21 | // This class encapsulates the UI we want to show users when certain events | ||||
22 | // occur related to installed extensions. | ||||
23 | class ExtensionErrorUI { | ||||
24 | public: | ||||
[email protected] | 373daf97 | 2014-04-10 01:50:44 | [diff] [blame] | 25 | class Delegate { |
26 | public: | ||||
27 | // Get the BrowserContext associated with this UI. | ||||
28 | virtual content::BrowserContext* GetContext() = 0; | ||||
29 | |||||
30 | // Get the set of external extensions to warn the user about. | ||||
31 | virtual const ExtensionSet& GetExternalExtensions() = 0; | ||||
32 | |||||
33 | // Get the set of blacklisted extensions to warn the user about. | ||||
34 | virtual const ExtensionSet& GetBlacklistedExtensions() = 0; | ||||
35 | |||||
36 | // Handle the user clicking to get more details on the extension alert. | ||||
37 | virtual void OnAlertDetails() = 0; | ||||
38 | |||||
39 | // Handle the user clicking "accept" on the extension alert. | ||||
40 | virtual void OnAlertAccept() = 0; | ||||
41 | |||||
42 | // Handle the alert closing. | ||||
43 | virtual void OnAlertClosed() = 0; | ||||
44 | }; | ||||
45 | |||||
46 | static ExtensionErrorUI* Create(Delegate* delegate); | ||||
[email protected] | 8922698 | 2012-07-16 20:09:18 | [diff] [blame] | 47 | |
48 | virtual ~ExtensionErrorUI(); | ||||
49 | |||||
[email protected] | 8922698 | 2012-07-16 20:09:18 | [diff] [blame] | 50 | // Shows the installation error in a bubble view. Should return true if a |
51 | // bubble is shown, false if one could not be shown. | ||||
52 | virtual bool ShowErrorInBubbleView() = 0; | ||||
53 | |||||
54 | // Shows the extension page. Called as a result of the user clicking more | ||||
55 | // info and should be only called from the context of a callback | ||||
56 | // (BubbleViewDidClose or BubbleViewAccept/CancelButtonPressed). | ||||
57 | // It should use the same browser as where the bubble was shown. | ||||
58 | virtual void ShowExtensions() = 0; | ||||
59 | |||||
[email protected] | 73a85e01 | 2013-04-04 10:45:30 | [diff] [blame] | 60 | // Closes the error UI. This will end up calling BubbleViewDidClose, possibly |
61 | // synchronously. | ||||
62 | virtual void Close() = 0; | ||||
63 | |||||
[email protected] | 8922698 | 2012-07-16 20:09:18 | [diff] [blame] | 64 | protected: |
[email protected] | 373daf97 | 2014-04-10 01:50:44 | [diff] [blame] | 65 | explicit ExtensionErrorUI(Delegate* delegate); |
[email protected] | 8922698 | 2012-07-16 20:09:18 | [diff] [blame] | 66 | |
67 | // Model methods for the bubble view. | ||||
[email protected] | 439f1e3 | 2013-12-09 20:09:09 | [diff] [blame] | 68 | base::string16 GetBubbleViewTitle(); |
[email protected] | d2065e06 | 2013-12-12 23:49:52 | [diff] [blame] | 69 | std::vector<base::string16> GetBubbleViewMessages(); |
[email protected] | 439f1e3 | 2013-12-09 20:09:09 | [diff] [blame] | 70 | base::string16 GetBubbleViewAcceptButtonLabel(); |
71 | base::string16 GetBubbleViewCancelButtonLabel(); | ||||
[email protected] | 8922698 | 2012-07-16 20:09:18 | [diff] [blame] | 72 | |
73 | // Sub-classes should call this methods based on the actions taken by the user | ||||
74 | // in the error bubble. | ||||
[email protected] | 73a85e01 | 2013-04-04 10:45:30 | [diff] [blame] | 75 | void BubbleViewDidClose(); // destroys |this| |
[email protected] | 8922698 | 2012-07-16 20:09:18 | [diff] [blame] | 76 | void BubbleViewAcceptButtonPressed(); |
77 | void BubbleViewCancelButtonPressed(); | ||||
78 | |||||
79 | private: | ||||
[email protected] | 439f1e3 | 2013-12-09 20:09:09 | [diff] [blame] | 80 | base::string16 GenerateMessage(); |
[email protected] | 8922698 | 2012-07-16 20:09:18 | [diff] [blame] | 81 | |
[email protected] | 373daf97 | 2014-04-10 01:50:44 | [diff] [blame] | 82 | Delegate* delegate_; |
83 | |||||
84 | base::string16 message_; // Displayed in the body of the alert. | ||||
85 | |||||
[email protected] | 8922698 | 2012-07-16 20:09:18 | [diff] [blame] | 86 | DISALLOW_COPY_AND_ASSIGN(ExtensionErrorUI); |
87 | }; | ||||
88 | |||||
[email protected] | 373daf97 | 2014-04-10 01:50:44 | [diff] [blame] | 89 | } // namespace extensions |
90 | |||||
[email protected] | 8922698 | 2012-07-16 20:09:18 | [diff] [blame] | 91 | #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_UI_H_ |