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 resource ID for the menu item icon.
45 int MenuItemIconResourceID();
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 virtual ~GlobalErrorWithStandardBubble();
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 the cancel button label for the bubble view. To hide the cancel
81 // button return an empty string.
82 virtual base::string16
GetBubbleViewCancelButtonLabel() = 0;
83 // Called when the bubble view is closed. |browser| is the Browser that the
84 // bubble view was shown on.
85 void BubbleViewDidClose(Browser
* browser
);
86 // Notifies subclasses that the bubble view is closed. |browser| is the
87 // Browser that the bubble view was shown on.
88 virtual void OnBubbleViewDidClose(Browser
* browser
) = 0;
89 // Called when the user clicks on the accept button. |browser| is the
90 // Browser that the bubble view was shown on.
91 virtual void BubbleViewAcceptButtonPressed(Browser
* browser
) = 0;
92 // Called when the user clicks the cancel button. |browser| is the
93 // Browser that the bubble view was shown on.
94 virtual void BubbleViewCancelButtonPressed(Browser
* browser
) = 0;
95 // Returns true if the bubble should close when focus is lost. If false, the
96 // bubble will stick around until the user explicitly acknowledges it.
98 virtual bool ShouldCloseOnDeactivate() const;
100 // GlobalError overrides:
101 virtual bool HasBubbleView() OVERRIDE
;
102 virtual bool HasShownBubbleView() OVERRIDE
;
103 virtual void ShowBubbleView(Browser
* browser
) OVERRIDE
;
104 virtual GlobalErrorBubbleViewBase
* GetBubbleView() OVERRIDE
;
107 bool has_shown_bubble_view_
;
108 GlobalErrorBubbleViewBase
* bubble_view_
;
110 DISALLOW_COPY_AND_ASSIGN(GlobalErrorWithStandardBubble
);
113 #endif // CHROME_BROWSER_UI_GLOBAL_ERROR_GLOBAL_ERROR_H_