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

Side by Side Diff: chrome/browser/managed_mode/managed_mode_navigation_observer.cc

Issue 14241006: Eliminate InfoBarTabHelper. Make InfoBarService a concrete class. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 8 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 #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h" 5 #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 return BUTTON_OK; 131 return BUTTON_OK;
132 } 132 }
133 133
134 string16 ManagedModeWarningInfobarDelegate::GetButtonLabel( 134 string16 ManagedModeWarningInfobarDelegate::GetButtonLabel(
135 InfoBarButton button) const { 135 InfoBarButton button) const {
136 DCHECK_EQ(BUTTON_OK, button); 136 DCHECK_EQ(BUTTON_OK, button);
137 return l10n_util::GetStringUTF16(IDS_MANAGED_MODE_GO_BACK_ACTION); 137 return l10n_util::GetStringUTF16(IDS_MANAGED_MODE_GO_BACK_ACTION);
138 } 138 }
139 139
140 bool ManagedModeWarningInfobarDelegate::Accept() { 140 bool ManagedModeWarningInfobarDelegate::Accept() {
141 GoBackToSafety(owner()->GetWebContents()); 141 GoBackToSafety(owner()->web_contents());
142 142
143 return false; 143 return false;
144 } 144 }
145 145
146 bool ManagedModeWarningInfobarDelegate::Cancel() { 146 bool ManagedModeWarningInfobarDelegate::Cancel() {
147 NOTREACHED(); 147 NOTREACHED();
148 return false; 148 return false;
149 } 149 }
150 150
151 bool ManagedModeWarningInfobarDelegate::ShouldExpire( 151 bool ManagedModeWarningInfobarDelegate::ShouldExpire(
152 const content::LoadCommittedDetails& details) const { 152 const content::LoadCommittedDetails& details) const {
153 // ManagedModeNavigationObserver removes us below. 153 // ManagedModeNavigationObserver removes us below.
154 return false; 154 return false;
155 } 155 }
156 156
157 void ManagedModeWarningInfobarDelegate::InfoBarDismissed() { 157 void ManagedModeWarningInfobarDelegate::InfoBarDismissed() {
158 ManagedModeNavigationObserver* observer = 158 ManagedModeNavigationObserver* observer =
159 ManagedModeNavigationObserver::FromWebContents(owner()->GetWebContents()); 159 ManagedModeNavigationObserver::FromWebContents(owner()->web_contents());
160 observer->WarnInfobarDismissed(); 160 observer->WarnInfobarDismissed();
161 } 161 }
162 162
163 class ManagedModePreviewInfobarDelegate : public ConfirmInfoBarDelegate { 163 class ManagedModePreviewInfobarDelegate : public ConfirmInfoBarDelegate {
164 public: 164 public:
165 // Creates a managed mode preview delegate and adds it to |infobar_service|. 165 // Creates a managed mode preview delegate and adds it to |infobar_service|.
166 // Returns the delegate if it was successfully added. 166 // Returns the delegate if it was successfully added.
167 static InfoBarDelegate* Create(InfoBarService* infobar_service); 167 static InfoBarDelegate* Create(InfoBarService* infobar_service);
168 168
169 private: 169 private:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 209
210 string16 ManagedModePreviewInfobarDelegate::GetButtonLabel( 210 string16 ManagedModePreviewInfobarDelegate::GetButtonLabel(
211 InfoBarButton button) const { 211 InfoBarButton button) const {
212 return l10n_util::GetStringUTF16( 212 return l10n_util::GetStringUTF16(
213 (button == BUTTON_OK) ? IDS_MANAGED_MODE_PREVIEW_ACCEPT 213 (button == BUTTON_OK) ? IDS_MANAGED_MODE_PREVIEW_ACCEPT
214 : IDS_MANAGED_MODE_GO_BACK_ACTION); 214 : IDS_MANAGED_MODE_GO_BACK_ACTION);
215 } 215 }
216 216
217 bool ManagedModePreviewInfobarDelegate::Accept() { 217 bool ManagedModePreviewInfobarDelegate::Accept() {
218 ManagedModeNavigationObserver* observer = 218 ManagedModeNavigationObserver* observer =
219 ManagedModeNavigationObserver::FromWebContents( 219 ManagedModeNavigationObserver::FromWebContents(owner()->web_contents());
220 owner()->GetWebContents());
221 UMA_HISTOGRAM_ENUMERATION("ManagedMode.PreviewInfobarCommand", 220 UMA_HISTOGRAM_ENUMERATION("ManagedMode.PreviewInfobarCommand",
222 INFOBAR_ACCEPT, 221 INFOBAR_ACCEPT,
223 INFOBAR_HISTOGRAM_BOUNDING_VALUE); 222 INFOBAR_HISTOGRAM_BOUNDING_VALUE);
224 observer->AddSavedURLsToWhitelistAndClearState(); 223 observer->AddSavedURLsToWhitelistAndClearState();
225 return true; 224 return true;
226 } 225 }
227 226
228 bool ManagedModePreviewInfobarDelegate::Cancel() { 227 bool ManagedModePreviewInfobarDelegate::Cancel() {
229 ManagedModeNavigationObserver* observer = 228 ManagedModeNavigationObserver* observer =
230 ManagedModeNavigationObserver::FromWebContents( 229 ManagedModeNavigationObserver::FromWebContents(owner()->web_contents());
231 owner()->GetWebContents());
232 UMA_HISTOGRAM_ENUMERATION("ManagedMode.PreviewInfobarCommand", 230 UMA_HISTOGRAM_ENUMERATION("ManagedMode.PreviewInfobarCommand",
233 INFOBAR_CANCEL, 231 INFOBAR_CANCEL,
234 INFOBAR_HISTOGRAM_BOUNDING_VALUE); 232 INFOBAR_HISTOGRAM_BOUNDING_VALUE);
235 GoBackToSafety(owner()->GetWebContents()); 233 GoBackToSafety(owner()->web_contents());
236 observer->ClearObserverState(); 234 observer->ClearObserverState();
237 return false; 235 return false;
238 } 236 }
239 237
240 bool ManagedModePreviewInfobarDelegate::ShouldExpire( 238 bool ManagedModePreviewInfobarDelegate::ShouldExpire(
241 const content::LoadCommittedDetails& details) const { 239 const content::LoadCommittedDetails& details) const {
242 // ManagedModeNavigationObserver removes us below. 240 // ManagedModeNavigationObserver removes us below.
243 return false; 241 return false;
244 } 242 }
245 243
246 void ManagedModePreviewInfobarDelegate::InfoBarDismissed() { 244 void ManagedModePreviewInfobarDelegate::InfoBarDismissed() {
247 ManagedModeNavigationObserver* observer = 245 ManagedModeNavigationObserver* observer =
248 ManagedModeNavigationObserver::FromWebContents( 246 ManagedModeNavigationObserver::FromWebContents(owner()->web_contents());
249 owner()->GetWebContents());
250 observer->PreviewInfobarDismissed(); 247 observer->PreviewInfobarDismissed();
251 } 248 }
252 249
253 } // namespace 250 } // namespace
254 251
255 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ManagedModeNavigationObserver); 252 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ManagedModeNavigationObserver);
256 253
257 ManagedModeNavigationObserver::~ManagedModeNavigationObserver() { 254 ManagedModeNavigationObserver::~ManagedModeNavigationObserver() {
258 RemoveTemporaryException(); 255 RemoveTemporaryException();
259 } 256 }
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 523
527 if (behavior == ManagedModeURLFilter::BLOCK) { 524 if (behavior == ManagedModeURLFilter::BLOCK) {
528 DCHECK_EQ(RECORDING_URLS_AFTER_PREVIEW, state_); 525 DCHECK_EQ(RECORDING_URLS_AFTER_PREVIEW, state_);
529 // Add the infobar. 526 // Add the infobar.
530 if (!preview_infobar_delegate_) { 527 if (!preview_infobar_delegate_) {
531 preview_infobar_delegate_ = ManagedModePreviewInfobarDelegate::Create( 528 preview_infobar_delegate_ = ManagedModePreviewInfobarDelegate::Create(
532 InfoBarService::FromWebContents(web_contents())); 529 InfoBarService::FromWebContents(web_contents()));
533 } 530 }
534 } 531 }
535 } 532 }
OLDNEW
« no previous file with comments | « chrome/browser/managed_mode/managed_mode_browsertest.cc ('k') | chrome/browser/media/media_stream_infobar_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698