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

Side by Side Diff: chrome/browser/infobars/infobar_delegate.h

Issue 190063006: Infobar Componentization Proof of Concept (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor fixes Created 6 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 (c) 2012 The Chromium Authors. All rights reserved. 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 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 CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_ 5 #ifndef CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_
6 #define CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_ 6 #define CHROME_BROWSER_INFOBARS_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 "chrome/browser/infobars/infobar_service.h"
11 #include "ui/base/window_open_disposition.h" 10 #include "ui/base/window_open_disposition.h"
12 11
13 class AutoLoginInfoBarDelegate; 12 class AutoLoginInfoBarDelegate;
14 class ConfirmInfoBarDelegate; 13 class ConfirmInfoBarDelegate;
15 class ExtensionInfoBarDelegate; 14 class ExtensionInfoBarDelegate;
16 class InfoBar; 15 class InfoBar;
17 class InsecureContentInfoBarDelegate; 16 class InsecureContentInfoBarDelegate;
18 class MediaStreamInfoBarDelegate; 17 class MediaStreamInfoBarDelegate;
19 class PopupBlockedInfoBarDelegate; 18 class PopupBlockedInfoBarDelegate;
20 class RegisterProtocolHandlerInfoBarDelegate; 19 class RegisterProtocolHandlerInfoBarDelegate;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 static const int kNoIconID; 51 static const int kNoIconID;
53 52
54 // Called when the InfoBar that owns this delegate is being destroyed. At 53 // Called when the InfoBar that owns this delegate is being destroyed. At
55 // this point nothing is visible onscreen. 54 // this point nothing is visible onscreen.
56 virtual ~InfoBarDelegate(); 55 virtual ~InfoBarDelegate();
57 56
58 virtual InfoBarAutomationType GetInfoBarAutomationType() const; 57 virtual InfoBarAutomationType GetInfoBarAutomationType() const;
59 58
60 // Returns true if the supplied |delegate| is equal to this one. Equality is 59 // Returns true if the supplied |delegate| is equal to this one. Equality is
61 // left to the implementation to define. This function is called by the 60 // left to the implementation to define. This function is called by the
62 // InfoBarService when determining whether or not a delegate should be 61 // InfoBarManager when determining whether or not a delegate should be
63 // added because a matching one already exists. If this function returns true, 62 // added because a matching one already exists. If this function returns true,
64 // the InfoBarService will not add the new delegate because it considers 63 // the InfoBarManager will not add the new delegate because it considers
65 // one to already be present. 64 // one to already be present.
66 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; 65 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const;
67 66
67 struct NavigationDetails {
droger 2014/03/18 15:59:53 This structure is used instead of content::LoadCom
68 int entry_id;
69 bool is_navigation_to_different_page;
70 bool is_reload;
71 bool is_redirect;
72 bool did_replace_entry;
73 bool is_main_frame;
74 };
75
68 // Returns true if the InfoBar should be closed automatically after the page 76 // Returns true if the InfoBar should be closed automatically after the page
69 // is navigated. By default this returns true if the navigation is to a new 77 // is navigated. By default this returns true if the navigation is to a new
70 // page (not including reloads). Subclasses wishing to change this behavior 78 // page (not including reloads). Subclasses wishing to change this behavior
71 // can override either this function or ShouldExpireInternal(), depending on 79 // can override either this function or ShouldExpireInternal(), depending on
72 // what level of control they need. 80 // what level of control they need.
73 virtual bool ShouldExpire(const content::LoadCommittedDetails& details) const; 81 virtual bool ShouldExpire(const NavigationDetails& details) const;
74 82
75 // Called when the user clicks on the close button to dismiss the infobar. 83 // Called when the user clicks on the close button to dismiss the infobar.
76 virtual void InfoBarDismissed(); 84 virtual void InfoBarDismissed();
77 85
78 // Return the resource ID of the icon to be shown for this InfoBar. If the 86 // Return the resource ID of the icon to be shown for this InfoBar. If the
79 // value is equal to |kNoIconID|, no icon is shown. 87 // value is equal to |kNoIconID|, no icon is shown.
80 virtual int GetIconID() const; 88 virtual int GetIconID() const;
81 89
82 // Returns the type of the infobar. The type determines the appearance (such 90 // Returns the type of the infobar. The type determines the appearance (such
83 // as background color) of the infobar. 91 // as background color) of the infobar.
84 virtual Type GetInfoBarType() const; 92 virtual Type GetInfoBarType() const;
85 93
94 virtual void CleanUp();
Peter Kasting 2014/03/18 18:29:17 Nit: Add comments about when and why this function
95
86 // Type-checking downcast routines: 96 // Type-checking downcast routines:
87 virtual AutoLoginInfoBarDelegate* AsAutoLoginInfoBarDelegate(); 97 virtual AutoLoginInfoBarDelegate* AsAutoLoginInfoBarDelegate();
88 virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate(); 98 virtual ConfirmInfoBarDelegate* AsConfirmInfoBarDelegate();
89 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate(); 99 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate();
90 virtual InsecureContentInfoBarDelegate* AsInsecureContentInfoBarDelegate(); 100 virtual InsecureContentInfoBarDelegate* AsInsecureContentInfoBarDelegate();
91 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate(); 101 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate();
92 virtual PopupBlockedInfoBarDelegate* AsPopupBlockedInfoBarDelegate(); 102 virtual PopupBlockedInfoBarDelegate* AsPopupBlockedInfoBarDelegate();
93 virtual RegisterProtocolHandlerInfoBarDelegate* 103 virtual RegisterProtocolHandlerInfoBarDelegate*
94 AsRegisterProtocolHandlerInfoBarDelegate(); 104 AsRegisterProtocolHandlerInfoBarDelegate();
95 virtual ScreenCaptureInfoBarDelegate* AsScreenCaptureInfoBarDelegate(); 105 virtual ScreenCaptureInfoBarDelegate* AsScreenCaptureInfoBarDelegate();
96 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate(); 106 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate();
97 virtual ThreeDAPIInfoBarDelegate* AsThreeDAPIInfoBarDelegate(); 107 virtual ThreeDAPIInfoBarDelegate* AsThreeDAPIInfoBarDelegate();
98 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); 108 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate();
99 109
100 void set_infobar(InfoBar* infobar) { infobar_ = infobar; } 110 void set_infobar(InfoBar* infobar) { infobar_ = infobar; }
101 111
102 // Store the unique id for the active entry in our WebContents, to be used 112 // Store the unique id for the active entry in our WebContents, to be used
Peter Kasting 2014/03/18 18:29:17 Nit: Seems like this shouldn't refer to WebContent
103 // later upon navigation to determine if this InfoBarDelegate should be 113 // later upon navigation to determine if this InfoBarDelegate should be
104 // expired. 114 // expired.
105 void StoreActiveEntryUniqueID(); 115 void StoreActiveEntryUniqueID(int entry_id);
106 116
107 // Return the icon to be shown for this InfoBar. If the returned Image is 117 // Return the icon to be shown for this InfoBar. If the returned Image is
108 // empty, no icon is shown. 118 // empty, no icon is shown.
109 virtual gfx::Image GetIcon() const; 119 virtual gfx::Image GetIcon() const;
110 120
111 // This trivial getter is defined out-of-line in order to avoid needing to
112 // #include infobar.h, which would lead to circular #includes.
113 content::WebContents* web_contents();
114
115 protected:
116 InfoBarDelegate(); 121 InfoBarDelegate();
117 122
118 // Returns true if the navigation is to a new URL or a reload occured. 123 // Returns true if the navigation is to a new URL or a reload occured.
119 virtual bool ShouldExpireInternal( 124 virtual bool ShouldExpireInternal(const NavigationDetails& details) const;
120 const content::LoadCommittedDetails& details) const;
121 125
122 int contents_unique_id() const { return contents_unique_id_; } 126 int contents_unique_id() const { return contents_unique_id_; }
123 InfoBar* infobar() { return infobar_; } 127 InfoBar* infobar() { return infobar_; }
124 128
125 private: 129 private:
126 // The unique id of the active NavigationEntry of the WebContents that we were 130 // The unique id of the active NavigationEntry of the WebContents that we were
127 // opened for. Used to help expire on navigations. 131 // opened for. Used to help expire on navigations.
128 int contents_unique_id_; 132 int contents_unique_id_;
129 133
130 // The InfoBar associated with us. 134 // The InfoBar associated with us.
131 InfoBar* infobar_; 135 InfoBar* infobar_;
132 136
133 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); 137 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate);
134 }; 138 };
135 139
136 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_ 140 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698