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_UI_GLOBAL_ERROR_GLOBAL_ERROR_H_
6 #define CHROME_BROWSER_UI_GLOBAL_ERROR_GLOBAL_ERROR_H_
10 #include "base/basictypes.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/strings/string16.h"
15 class GlobalErrorBubbleViewBase
;
21 // This object describes a single global error.
31 virtual ~GlobalError();
33 // Returns the error's severity level. If there are multiple errors,
34 // the error with the highest severity will display in the menu. If not
35 // overridden, this is based on the badge resource ID.
36 virtual Severity
GetSeverity();
38 // Returns true if a menu item should be added to the wrench menu.
39 virtual bool HasMenuItem() = 0;
40 // Returns the command ID for the menu item.
41 virtual int MenuItemCommandID() = 0;
42 // Returns the label for the menu item.
43 virtual base::string16
MenuItemLabel() = 0;
44 // Returns the menu item icon.
45 virtual gfx::Image
MenuItemIcon();
46 // Called when the user clicks on the menu item.
47 virtual void ExecuteMenuItem(Browser
* browser
) = 0;
49 // Returns true if a bubble view should be shown.
50 virtual bool HasBubbleView() = 0;
51 // Returns true if the bubble view has been shown.
52 virtual bool HasShownBubbleView() = 0;
53 // Called to show the bubble view.
54 virtual void ShowBubbleView(Browser
* browser
) = 0;
55 // Returns the bubble view.
56 virtual GlobalErrorBubbleViewBase
* GetBubbleView() = 0;
59 // This object describes a single global error that already comes with support
60 // for showing a standard Bubble UI. Derived classes just need to supply the
61 // content to be displayed in the bubble.
62 class GlobalErrorWithStandardBubble
64 public base::SupportsWeakPtr
<GlobalErrorWithStandardBubble
> {
66 GlobalErrorWithStandardBubble();
67 ~GlobalErrorWithStandardBubble() override
;
69 // Returns an icon to use for the bubble view.
70 virtual gfx::Image
GetBubbleViewIcon();
72 // Returns the title for the bubble view.
73 virtual base::string16
GetBubbleViewTitle() = 0;
74 // Returns the messages for the bubble view, one per line. Multiple messages
75 // are only supported on Views.
76 // TODO(yoz): Add multi-line support for GTK and Cocoa.
77 virtual std::vector
<base::string16
> GetBubbleViewMessages() = 0;
78 // Returns the accept button label for the bubble view.
79 virtual base::string16
GetBubbleViewAcceptButtonLabel() = 0;
80 // Returns true if the bubble needs a close(x) button.
81 virtual bool ShouldShowCloseButton() const;
82 // Returns true if the accept button needs elevation icon (only effective
83 // on Windows platform).
84 virtual bool ShouldAddElevationIconToAcceptButton();
85 // Returns the cancel button label for the bubble view. To hide the cancel
86 // button return an empty string.
87 virtual base::string16
GetBubbleViewCancelButtonLabel() = 0;
88 // Called when the bubble view is closed. |browser| is the Browser that the
89 // bubble view was shown on.
90 void BubbleViewDidClose(Browser
* browser
);
91 // Notifies subclasses that the bubble view is closed. |browser| is the
92 // Browser that the bubble view was shown on.
93 virtual void OnBubbleViewDidClose(Browser
* browser
) = 0;
94 // Called when the user clicks on the accept button. |browser| is the
95 // Browser that the bubble view was shown on.
96 virtual void BubbleViewAcceptButtonPressed(Browser
* browser
) = 0;
97 // Called when the user clicks the cancel button. |browser| is the
98 // Browser that the bubble view was shown on.
99 virtual void BubbleViewCancelButtonPressed(Browser
* browser
) = 0;
100 // Returns true if the bubble should close when focus is lost. If false, the
101 // bubble will stick around until the user explicitly acknowledges it.
103 virtual bool ShouldCloseOnDeactivate() const;
105 // GlobalError overrides:
106 bool HasBubbleView() override
;
107 bool HasShownBubbleView() override
;
108 void ShowBubbleView(Browser
* browser
) override
;
109 GlobalErrorBubbleViewBase
* GetBubbleView() override
;
112 bool has_shown_bubble_view_
;
113 GlobalErrorBubbleViewBase
* bubble_view_
;
115 DISALLOW_COPY_AND_ASSIGN(GlobalErrorWithStandardBubble
);
118 #endif // CHROME_BROWSER_UI_GLOBAL_ERROR_GLOBAL_ERROR_H_