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

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

Issue 22694006: Infobar system refactor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
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" 10 #include "chrome/browser/infobars/infobar_service.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 enum InfoBarAutomationType { 43 enum InfoBarAutomationType {
44 CONFIRM_INFOBAR, 44 CONFIRM_INFOBAR,
45 PASSWORD_INFOBAR, 45 PASSWORD_INFOBAR,
46 RPH_INFOBAR, 46 RPH_INFOBAR,
47 UNKNOWN_INFOBAR, 47 UNKNOWN_INFOBAR,
48 }; 48 };
49 49
50 // Value to use when the InfoBar has no icon to show. 50 // Value to use when the InfoBar has no icon to show.
51 static const int kNoIconID; 51 static const int kNoIconID;
52 52
53 // Called when the InfoBar that owns this delegate is being destroyed. At
54 // this point nothing is visible onscreen.
53 virtual ~InfoBarDelegate(); 55 virtual ~InfoBarDelegate();
54 56
55 virtual InfoBarAutomationType GetInfoBarAutomationType() const; 57 virtual InfoBarAutomationType GetInfoBarAutomationType() const;
56 58
57 // Called to create the InfoBar. Implementation of this method is
58 // platform-specific.
59 virtual InfoBar* CreateInfoBar(InfoBarService* owner) = 0;
60
61 // TODO(pkasting): Move to InfoBar once InfoBars own their delegates.
62 InfoBarService* owner() { return owner_; }
63
64 void clear_owner() { owner_ = NULL; }
65
66 // 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
67 // 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
68 // InfoBarService when determining whether or not a delegate should be 61 // InfoBarService when determining whether or not a delegate should be
69 // 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,
70 // the InfoBarService will not add the new delegate because it considers 63 // the InfoBarService will not add the new delegate because it considers
71 // one to already be present. 64 // one to already be present.
72 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; 65 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const;
73 66
74 // Returns true if the InfoBar should be closed automatically after the page 67 // Returns true if the InfoBar should be closed automatically after the page
75 // is navigated. By default this returns true if the navigation is to a new 68 // is navigated. By default this returns true if the navigation is to a new
(...skipping 19 matching lines...) Expand all
95 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate(); 88 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate();
96 virtual InsecureContentInfoBarDelegate* AsInsecureContentInfoBarDelegate(); 89 virtual InsecureContentInfoBarDelegate* AsInsecureContentInfoBarDelegate();
97 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate(); 90 virtual MediaStreamInfoBarDelegate* AsMediaStreamInfoBarDelegate();
98 virtual RegisterProtocolHandlerInfoBarDelegate* 91 virtual RegisterProtocolHandlerInfoBarDelegate*
99 AsRegisterProtocolHandlerInfoBarDelegate(); 92 AsRegisterProtocolHandlerInfoBarDelegate();
100 virtual ScreenCaptureInfoBarDelegate* AsScreenCaptureInfoBarDelegate(); 93 virtual ScreenCaptureInfoBarDelegate* AsScreenCaptureInfoBarDelegate();
101 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate(); 94 virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate();
102 virtual ThreeDAPIInfoBarDelegate* AsThreeDAPIInfoBarDelegate(); 95 virtual ThreeDAPIInfoBarDelegate* AsThreeDAPIInfoBarDelegate();
103 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate(); 96 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate();
104 97
105 // Return the icon to be shown for this InfoBar. If the returned Image is 98 void set_infobar(InfoBar* infobar) { infobar_ = infobar; }
106 // empty, no icon is shown.
107 virtual gfx::Image GetIcon() const;
108
109 content::WebContents* web_contents() {
110 return owner_ ? owner_->web_contents() : NULL;
111 }
112
113 protected:
114 // If |contents| is non-NULL, its active entry's unique ID will be stored
115 // using StoreActiveEntryUniqueID automatically.
116 explicit InfoBarDelegate(InfoBarService* owner);
117 99
118 // Store the unique id for the active entry in our WebContents, to be used 100 // Store the unique id for the active entry in our WebContents, to be used
119 // later upon navigation to determine if this InfoBarDelegate should be 101 // later upon navigation to determine if this InfoBarDelegate should be
120 // expired. 102 // expired.
121 void StoreActiveEntryUniqueID(); 103 void StoreActiveEntryUniqueID();
122 104
123 int contents_unique_id() const { return contents_unique_id_; } 105 // Return the icon to be shown for this InfoBar. If the returned Image is
106 // empty, no icon is shown.
107 virtual gfx::Image GetIcon() const;
108
109 // This trivial getter is defined out-of-line in order to avoid needing to
110 // #include infobar.h, which would lead to circular #includes.
111 content::WebContents* web_contents();
112
113 protected:
114 InfoBarDelegate();
124 115
125 // Returns true if the navigation is to a new URL or a reload occured. 116 // Returns true if the navigation is to a new URL or a reload occured.
126 virtual bool ShouldExpireInternal( 117 virtual bool ShouldExpireInternal(
127 const content::LoadCommittedDetails& details) const; 118 const content::LoadCommittedDetails& details) const;
128 119
129 // Removes ourself from |owner_| if we haven't already been removed. 120 int contents_unique_id() const { return contents_unique_id_; }
130 // TODO(pkasting): Move to InfoBar. 121 InfoBar* infobar() { return infobar_; }
131 void RemoveSelf();
132 122
133 private: 123 private:
134 // The unique id of the active NavigationEntry of the WebContents that we were 124 // The unique id of the active NavigationEntry of the WebContents that we were
135 // opened for. Used to help expire on navigations. 125 // opened for. Used to help expire on navigations.
136 int contents_unique_id_; 126 int contents_unique_id_;
137 127
138 // TODO(pkasting): Remove. 128 // The InfoBar associated with us.
139 InfoBarService* owner_; 129 InfoBar* infobar_;
140 130
141 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate); 131 DISALLOW_COPY_AND_ASSIGN(InfoBarDelegate);
142 }; 132 };
143 133
144 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_ 134 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698