Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: components/infobars/core/infobar_delegate.h

Issue 922953002: Minor infobar cleanup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resync Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_INFOBARS_CORE_INFOBAR_DELEGATE_H_ 5 #ifndef COMPONENTS_INFOBARS_CORE_INFOBAR_DELEGATE_H_
6 #define COMPONENTS_INFOBARS_CORE_INFOBAR_DELEGATE_H_ 6 #define COMPONENTS_INFOBARS_CORE_INFOBAR_DELEGATE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "ui/base/window_open_disposition.h" 10 #include "ui/base/window_open_disposition.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 bool is_redirect; 68 bool is_redirect;
69 }; 69 };
70 70
71 // Value to use when the InfoBar has no icon to show. 71 // Value to use when the InfoBar has no icon to show.
72 static const int kNoIconID; 72 static const int kNoIconID;
73 73
74 // Called when the InfoBar that owns this delegate is being destroyed. At 74 // Called when the InfoBar that owns this delegate is being destroyed. At
75 // this point nothing is visible onscreen. 75 // this point nothing is visible onscreen.
76 virtual ~InfoBarDelegate(); 76 virtual ~InfoBarDelegate();
77 77
78 // Returns the type of the infobar. The type determines the appearance (such
79 // as background color) of the infobar.
80 virtual Type GetInfoBarType() const;
81
78 virtual InfoBarAutomationType GetInfoBarAutomationType() const; 82 virtual InfoBarAutomationType GetInfoBarAutomationType() const;
79 83
84 // Returns the resource ID of the icon to be shown for this InfoBar. If the
85 // value is equal to |kNoIconID|, GetIcon() will not show an icon by default.
86 virtual int GetIconID() const;
87
88 // Returns the icon to be shown for this InfoBar. If the returned Image is
89 // empty, no icon is shown.
90 //
91 // Most subclasses should not override this; override GetIconID() instead
92 // unless the infobar needs to show an image from somewhere other than the
93 // resource bundle as its icon.
94 virtual gfx::Image GetIcon() const;
95
80 // Returns true if the supplied |delegate| is equal to this one. Equality is 96 // Returns true if the supplied |delegate| is equal to this one. Equality is
81 // left to the implementation to define. This function is called by the 97 // left to the implementation to define. This function is called by the
82 // InfoBarManager when determining whether or not a delegate should be 98 // InfoBarManager when determining whether or not a delegate should be
83 // added because a matching one already exists. If this function returns true, 99 // added because a matching one already exists. If this function returns true,
84 // the InfoBarManager will not add the new delegate because it considers 100 // the InfoBarManager will not add the new delegate because it considers
85 // one to already be present. 101 // one to already be present.
86 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; 102 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const;
87 103
88 // Returns true if the InfoBar should be closed automatically after the page 104 // Returns true if the InfoBar should be closed automatically after the page
89 // is navigated. By default this returns true if the navigation is to a new 105 // is navigated. By default this returns true if the navigation is to a new
90 // page (not including reloads). Subclasses wishing to change this behavior 106 // page (not including reloads). Subclasses wishing to change this behavior
91 // can override either this function or ShouldExpireInternal(), depending on 107 // can override either this function or ShouldExpireInternal(), depending on
92 // what level of control they need. 108 // what level of control they need.
93 virtual bool ShouldExpire(const NavigationDetails& details) const; 109 virtual bool ShouldExpire(const NavigationDetails& details) const;
94 110
95 // Called when the user clicks on the close button to dismiss the infobar. 111 // Called when the user clicks on the close button to dismiss the infobar.
96 virtual void InfoBarDismissed(); 112 virtual void InfoBarDismissed();
97 113
98 // Return the resource ID of the icon to be shown for this InfoBar. If the
99 // value is equal to |kNoIconID|, no icon is shown.
100 virtual int GetIconID() const;
101
102 // Returns the type of the infobar. The type determines the appearance (such
103 // as background color) of the infobar.
104 virtual Type GetInfoBarType() const;
105
106 // Type-checking downcast routines: 114 // Type-checking downcast routines:
107 virtual AutoLoginInfoBarDelegate* AsAutoLoginInfoBarDelegate(); 115 virtual AutoLoginInfoBarDelegate* AsAutoLoginInfoBarDelegate();
108 virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate(); 116 virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate();
109 virtual InsecureContentInfoBarDelegate* AsInsecureContentInfoBarDelegate(); 117 virtual InsecureContentInfoBarDelegate* AsInsecureContentInfoBarDelegate();
110 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate(); 118 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate();
111 virtual NativeAppInfoBarDelegate* AsNativeAppInfoBarDelegate(); 119 virtual NativeAppInfoBarDelegate* AsNativeAppInfoBarDelegate();
112 virtual PopupBlockedInfoBarDelegate* AsPopupBlockedInfoBarDelegate(); 120 virtual PopupBlockedInfoBarDelegate* AsPopupBlockedInfoBarDelegate();
113 virtual RegisterProtocolHandlerInfoBarDelegate* 121 virtual RegisterProtocolHandlerInfoBarDelegate*
114 AsRegisterProtocolHandlerInfoBarDelegate(); 122 AsRegisterProtocolHandlerInfoBarDelegate();
115 virtual ScreenCaptureInfoBarDelegate* AsScreenCaptureInfoBarDelegate(); 123 virtual ScreenCaptureInfoBarDelegate* AsScreenCaptureInfoBarDelegate();
116 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate(); 124 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate();
125 virtual ThreeDAPIInfoBarDelegate* AsThreeDAPIInfoBarDelegate();
117 virtual translate::TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); 126 virtual translate::TranslateInfoBarDelegate* AsTranslateInfoBarDelegate();
118 127
119 void set_infobar(InfoBar* infobar) { infobar_ = infobar; } 128 void set_infobar(InfoBar* infobar) { infobar_ = infobar; }
120 129
121 // Store the unique id for the active entry, to be used later upon navigation 130 // Store the unique id for the active entry, to be used later upon navigation
122 // to determine if this InfoBarDelegate should be expired. 131 // to determine if this InfoBarDelegate should be expired.
123 void StoreActiveEntryUniqueID(); 132 void StoreActiveEntryUniqueID();
124 133
125 // Return the icon to be shown for this InfoBar. If the returned Image is
126 // empty, no icon is shown.
127 virtual gfx::Image GetIcon() const;
128
129 protected: 134 protected:
130 InfoBarDelegate(); 135 InfoBarDelegate();
131 136
132 // Returns true if the navigation is to a new URL or a reload occured. 137 // Returns true if the navigation is to a new URL or a reload occured.
133 virtual bool ShouldExpireInternal(const NavigationDetails& details) const; 138 virtual bool ShouldExpireInternal(const NavigationDetails& details) const;
134 139
135 int contents_unique_id() const { return contents_unique_id_; } 140 int contents_unique_id() const { return contents_unique_id_; }
136 InfoBar* infobar() { return infobar_; } 141 InfoBar* infobar() { return infobar_; }
137 142
138 private: 143 private:
139 // The unique id of the active NavigationEntry of the WebContents that we were 144 // The unique id of the active NavigationEntry of the WebContents that we were
140 // opened for. Used to help expire on navigations. 145 // opened for. Used to help expire on navigations.
141 int contents_unique_id_; 146 int contents_unique_id_;
142 147
143 // The InfoBar associated with us. 148 // The InfoBar associated with us.
144 InfoBar* infobar_; 149 InfoBar* infobar_;
145 150
146 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); 151 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate);
147 }; 152 };
148 153
149 } // namespace infobars 154 } // namespace infobars
150 155
151 #endif // COMPONENTS_INFOBARS_CORE_INFOBAR_DELEGATE_H_ 156 #endif // COMPONENTS_INFOBARS_CORE_INFOBAR_DELEGATE_H_
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_cc_infobar_delegate.cc ('k') | components/infobars/core/infobar_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698