blob: f6b7b1c80ef8da5da88abaea350a36669c3eb87c [file] [log] [blame]
[email protected]89226982012-07-16 20:09:181// 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]373daf972014-04-10 01:50:448#include <vector>
[email protected]89226982012-07-16 20:09:189
[email protected]373daf972014-04-10 01:50:4410#include "base/macros.h"
11#include "base/strings/string16.h"
12
13namespace content {
14class BrowserContext;
15}
16
17namespace extensions {
18
19class ExtensionSet;
[email protected]89226982012-07-16 20:09:1820
21// This class encapsulates the UI we want to show users when certain events
22// occur related to installed extensions.
23class ExtensionErrorUI {
24 public:
[email protected]373daf972014-04-10 01:50:4425 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]89226982012-07-16 20:09:1847
48 virtual ~ExtensionErrorUI();
49
[email protected]89226982012-07-16 20:09:1850 // 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]73a85e012013-04-04 10:45:3060 // Closes the error UI. This will end up calling BubbleViewDidClose, possibly
61 // synchronously.
62 virtual void Close() = 0;
63
[email protected]89226982012-07-16 20:09:1864 protected:
[email protected]373daf972014-04-10 01:50:4465 explicit ExtensionErrorUI(Delegate* delegate);
[email protected]89226982012-07-16 20:09:1866
67 // Model methods for the bubble view.
[email protected]439f1e32013-12-09 20:09:0968 base::string16 GetBubbleViewTitle();
[email protected]d2065e062013-12-12 23:49:5269 std::vector<base::string16> GetBubbleViewMessages();
[email protected]439f1e32013-12-09 20:09:0970 base::string16 GetBubbleViewAcceptButtonLabel();
71 base::string16 GetBubbleViewCancelButtonLabel();
[email protected]89226982012-07-16 20:09:1872
73 // Sub-classes should call this methods based on the actions taken by the user
74 // in the error bubble.
[email protected]73a85e012013-04-04 10:45:3075 void BubbleViewDidClose(); // destroys |this|
[email protected]89226982012-07-16 20:09:1876 void BubbleViewAcceptButtonPressed();
77 void BubbleViewCancelButtonPressed();
78
79 private:
[email protected]439f1e32013-12-09 20:09:0980 base::string16 GenerateMessage();
[email protected]89226982012-07-16 20:09:1881
[email protected]373daf972014-04-10 01:50:4482 Delegate* delegate_;
83
84 base::string16 message_; // Displayed in the body of the alert.
85
[email protected]89226982012-07-16 20:09:1886 DISALLOW_COPY_AND_ASSIGN(ExtensionErrorUI);
87};
88
[email protected]373daf972014-04-10 01:50:4489} // namespace extensions
90
[email protected]89226982012-07-16 20:09:1891#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_UI_H_