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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_UI_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_UI_H_
10 #include "base/macros.h"
11 #include "base/strings/string16.h"
17 namespace extensions
{
21 // This class encapsulates the UI we want to show users when certain events
22 // occur related to installed extensions.
23 class ExtensionErrorUI
{
27 // Get the BrowserContext associated with this UI.
28 virtual content::BrowserContext
* GetContext() = 0;
30 // Get the set of external extensions to warn the user about.
31 virtual const ExtensionSet
& GetExternalExtensions() = 0;
33 // Get the set of blacklisted extensions to warn the user about.
34 virtual const ExtensionSet
& GetBlacklistedExtensions() = 0;
36 // Handle the user clicking to get more details on the extension alert.
37 virtual void OnAlertDetails() = 0;
39 // Handle the user clicking "accept" on the extension alert.
40 virtual void OnAlertAccept() = 0;
42 // Handle the alert closing.
43 virtual void OnAlertClosed() = 0;
46 static ExtensionErrorUI
* Create(Delegate
* delegate
);
48 virtual ~ExtensionErrorUI();
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;
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;
60 // Closes the error UI. This will end up calling BubbleViewDidClose, possibly
62 virtual void Close() = 0;
65 explicit ExtensionErrorUI(Delegate
* delegate
);
67 // Model methods for the bubble view.
68 base::string16
GetBubbleViewTitle();
69 std::vector
<base::string16
> GetBubbleViewMessages();
70 base::string16
GetBubbleViewAcceptButtonLabel();
71 base::string16
GetBubbleViewCancelButtonLabel();
73 // Sub-classes should call this methods based on the actions taken by the user
74 // in the error bubble.
75 void BubbleViewDidClose(); // destroys |this|
76 void BubbleViewAcceptButtonPressed();
77 void BubbleViewCancelButtonPressed();
80 base::string16
GenerateMessage();
84 base::string16 message_
; // Displayed in the body of the alert.
86 DISALLOW_COPY_AND_ASSIGN(ExtensionErrorUI
);
89 } // namespace extensions
91 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ERROR_UI_H_