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

Side by Side Diff: chrome/browser/tab_contents/infobar_delegate.cc

Issue 6262018: Cleanup:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/browser/tab_contents/infobar_delegate.h" 5 #include "chrome/browser/tab_contents/infobar_delegate.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/tab_contents/navigation_entry.h" 9 #include "chrome/browser/tab_contents/navigation_entry.h"
10 #include "chrome/browser/tab_contents/navigation_controller.h" 10 #include "chrome/browser/tab_contents/navigation_controller.h"
(...skipping 24 matching lines...) Expand all
35 } 35 }
36 36
37 SkBitmap* InfoBarDelegate::GetIcon() const { 37 SkBitmap* InfoBarDelegate::GetIcon() const {
38 return NULL; 38 return NULL;
39 } 39 }
40 40
41 InfoBarDelegate::Type InfoBarDelegate::GetInfoBarType() const { 41 InfoBarDelegate::Type InfoBarDelegate::GetInfoBarType() const {
42 return WARNING_TYPE; 42 return WARNING_TYPE;
43 } 43 }
44 44
45 AlertInfoBarDelegate* InfoBarDelegate::AsAlertInfoBarDelegate() {
46 return NULL;
47 }
48
49 ConfirmInfoBarDelegate* InfoBarDelegate::AsConfirmInfoBarDelegate() { 45 ConfirmInfoBarDelegate* InfoBarDelegate::AsConfirmInfoBarDelegate() {
50 return NULL; 46 return NULL;
51 } 47 }
52 48
53 CrashedExtensionInfoBarDelegate* 49 CrashedExtensionInfoBarDelegate*
54 InfoBarDelegate::AsCrashedExtensionInfoBarDelegate() { 50 InfoBarDelegate::AsCrashedExtensionInfoBarDelegate() {
55 return NULL; 51 return NULL;
56 } 52 }
57 53
58 ExtensionInfoBarDelegate* InfoBarDelegate::AsExtensionInfoBarDelegate() { 54 ExtensionInfoBarDelegate* InfoBarDelegate::AsExtensionInfoBarDelegate() {
59 return NULL; 55 return NULL;
60 } 56 }
61 57
62 LinkInfoBarDelegate* InfoBarDelegate::AsLinkInfoBarDelegate() { 58 LinkInfoBarDelegate* InfoBarDelegate::AsLinkInfoBarDelegate() {
63 return NULL; 59 return NULL;
64 } 60 }
(...skipping 12 matching lines...) Expand all
77 if (contents) 73 if (contents)
78 StoreActiveEntryUniqueID(contents); 74 StoreActiveEntryUniqueID(contents);
79 } 75 }
80 76
81 void InfoBarDelegate::StoreActiveEntryUniqueID(TabContents* contents) { 77 void InfoBarDelegate::StoreActiveEntryUniqueID(TabContents* contents) {
82 NavigationEntry* active_entry = contents->controller().GetActiveEntry(); 78 NavigationEntry* active_entry = contents->controller().GetActiveEntry();
83 contents_unique_id_ = active_entry ? active_entry->unique_id() : 0; 79 contents_unique_id_ = active_entry ? active_entry->unique_id() : 0;
84 } 80 }
85 81
86 82
87 // AlertInfoBarDelegate -------------------------------------------------------
88
89 bool AlertInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
90 AlertInfoBarDelegate* alert_delegate = delegate->AsAlertInfoBarDelegate();
91 return alert_delegate &&
92 (alert_delegate->GetMessageText() == GetMessageText());
93 }
94
95 AlertInfoBarDelegate::AlertInfoBarDelegate(TabContents* contents)
96 : InfoBarDelegate(contents) {
97 }
98
99 AlertInfoBarDelegate::~AlertInfoBarDelegate() {
100 }
101
102 AlertInfoBarDelegate* AlertInfoBarDelegate::AsAlertInfoBarDelegate() {
103 return this;
104 }
105
106
107 // LinkInfoBarDelegate -------------------------------------------------------- 83 // LinkInfoBarDelegate --------------------------------------------------------
108 84
109 string16 LinkInfoBarDelegate::GetMessageTextWithOffset( 85 string16 LinkInfoBarDelegate::GetMessageTextWithOffset(
110 size_t* link_offset) const { 86 size_t* link_offset) const {
111 *link_offset = string16::npos; 87 *link_offset = string16::npos;
112 return string16(); 88 return string16();
113 } 89 }
114 90
115 bool LinkInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { 91 bool LinkInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
116 return true; 92 return true;
117 } 93 }
118 94
119 LinkInfoBarDelegate::LinkInfoBarDelegate(TabContents* contents) 95 LinkInfoBarDelegate::LinkInfoBarDelegate(TabContents* contents)
120 : InfoBarDelegate(contents) { 96 : InfoBarDelegate(contents) {
121 } 97 }
122 98
123 LinkInfoBarDelegate::~LinkInfoBarDelegate() { 99 LinkInfoBarDelegate::~LinkInfoBarDelegate() {
124 } 100 }
125 101
126 LinkInfoBarDelegate* LinkInfoBarDelegate::AsLinkInfoBarDelegate() { 102 LinkInfoBarDelegate* LinkInfoBarDelegate::AsLinkInfoBarDelegate() {
127 return this; 103 return this;
128 } 104 }
129 105
130 106
131 // ConfirmInfoBarDelegate ----------------------------------------------------- 107 // ConfirmInfoBarDelegate -----------------------------------------------------
132 108
133 int ConfirmInfoBarDelegate::GetButtons() const { 109 int ConfirmInfoBarDelegate::GetButtons() const {
134 return BUTTON_NONE; 110 return BUTTON_OK | BUTTON_CANCEL;
135 } 111 }
136 112
137 string16 ConfirmInfoBarDelegate::GetButtonLabel(InfoBarButton button) const { 113 string16 ConfirmInfoBarDelegate::GetButtonLabel(InfoBarButton button) const {
138 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_OK : IDS_CANCEL); 114 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? IDS_OK : IDS_CANCEL);
139 } 115 }
140 116
141 bool ConfirmInfoBarDelegate::NeedElevation(InfoBarButton button) const { 117 bool ConfirmInfoBarDelegate::NeedElevation(InfoBarButton button) const {
142 return false; 118 return false;
143 } 119 }
144 120
145 bool ConfirmInfoBarDelegate::Accept() { 121 bool ConfirmInfoBarDelegate::Accept() {
146 return true; 122 return true;
147 } 123 }
148 124
149 bool ConfirmInfoBarDelegate::Cancel() { 125 bool ConfirmInfoBarDelegate::Cancel() {
150 return true; 126 return true;
151 } 127 }
152 128
153 string16 ConfirmInfoBarDelegate::GetLinkText() { 129 string16 ConfirmInfoBarDelegate::GetLinkText() {
154 return string16(); 130 return string16();
155 } 131 }
156 132
157 bool ConfirmInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { 133 bool ConfirmInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
158 return true; 134 return true;
159 } 135 }
160 136
161 ConfirmInfoBarDelegate::ConfirmInfoBarDelegate(TabContents* contents) 137 ConfirmInfoBarDelegate::ConfirmInfoBarDelegate(TabContents* contents)
162 : AlertInfoBarDelegate(contents) { 138 : InfoBarDelegate(contents) {
163 } 139 }
164 140
165 ConfirmInfoBarDelegate::~ConfirmInfoBarDelegate() { 141 ConfirmInfoBarDelegate::~ConfirmInfoBarDelegate() {
166 } 142 }
167 143
144 bool ConfirmInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const {
145 ConfirmInfoBarDelegate* confirm_delegate =
146 delegate->AsConfirmInfoBarDelegate();
147 return confirm_delegate &&
148 (confirm_delegate->GetMessageText() == GetMessageText());
149 }
150
168 ConfirmInfoBarDelegate* ConfirmInfoBarDelegate::AsConfirmInfoBarDelegate() { 151 ConfirmInfoBarDelegate* ConfirmInfoBarDelegate::AsConfirmInfoBarDelegate() {
169 return this; 152 return this;
170 } 153 }
171 154
172 155
173 // SimpleAlertInfoBarDelegate ------------------------------------------------- 156 // SimpleAlertInfoBarDelegate -------------------------------------------------
174 157
175 SimpleAlertInfoBarDelegate::SimpleAlertInfoBarDelegate( 158 SimpleAlertInfoBarDelegate::SimpleAlertInfoBarDelegate(
176 TabContents* contents, 159 TabContents* contents,
177 SkBitmap* icon, 160 SkBitmap* icon,
178 const string16& message, 161 const string16& message,
179 bool auto_expire) 162 bool auto_expire)
180 : AlertInfoBarDelegate(contents), 163 : ConfirmInfoBarDelegate(contents),
181 icon_(icon), 164 icon_(icon),
182 message_(message), 165 message_(message),
183 auto_expire_(auto_expire) { 166 auto_expire_(auto_expire) {
184 } 167 }
185 168
186 SimpleAlertInfoBarDelegate::~SimpleAlertInfoBarDelegate() { 169 SimpleAlertInfoBarDelegate::~SimpleAlertInfoBarDelegate() {
187 } 170 }
188 171
189 bool SimpleAlertInfoBarDelegate::ShouldExpire( 172 bool SimpleAlertInfoBarDelegate::ShouldExpire(
190 const NavigationController::LoadCommittedDetails& details) const { 173 const NavigationController::LoadCommittedDetails& details) const {
191 return auto_expire_ && AlertInfoBarDelegate::ShouldExpire(details); 174 return auto_expire_ && ConfirmInfoBarDelegate::ShouldExpire(details);
192 } 175 }
193 176
194 void SimpleAlertInfoBarDelegate::InfoBarClosed() { 177 void SimpleAlertInfoBarDelegate::InfoBarClosed() {
195 delete this; 178 delete this;
196 } 179 }
197 180
198 SkBitmap* SimpleAlertInfoBarDelegate::GetIcon() const { 181 SkBitmap* SimpleAlertInfoBarDelegate::GetIcon() const {
199 return icon_; 182 return icon_;
200 } 183 }
201 184
202 string16 SimpleAlertInfoBarDelegate::GetMessageText() const { 185 string16 SimpleAlertInfoBarDelegate::GetMessageText() const {
203 return message_; 186 return message_;
204 } 187 }
188
189 int SimpleAlertInfoBarDelegate::GetButtons() const {
190 return BUTTON_NONE;
191 }
Elliot Glaysher 2011/01/26 20:52:22 Linter wants newline
Peter Kasting 2011/01/26 20:56:01 It has a newline. The linter is wrong about this
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/infobar_delegate.h ('k') | chrome/browser/tab_contents/tab_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698