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

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

Issue 248963004: "Go back" on the block interstitial closes the tab if there is no previous URL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improved test. Created 6 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_interstitial.h" 5 #include "chrome/browser/managed_mode/managed_mode_interstitial.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 28 matching lines...) Expand all
39 const base::Callback<void(bool)>& callback) 39 const base::Callback<void(bool)>& callback)
40 : web_contents_(web_contents), 40 : web_contents_(web_contents),
41 interstitial_page_(NULL), 41 interstitial_page_(NULL),
42 url_(url), 42 url_(url),
43 callback_(callback) { 43 callback_(callback) {
44 if (ShouldProceed()) { 44 if (ShouldProceed()) {
45 // It can happen that the site was only allowed very recently and the URL 45 // It can happen that the site was only allowed very recently and the URL
46 // filter on the IO thread had not been updated yet. Proceed with the 46 // filter on the IO thread had not been updated yet. Proceed with the
47 // request without showing the interstitial. 47 // request without showing the interstitial.
48 DispatchContinueRequest(true); 48 DispatchContinueRequest(true);
49 delete this; 49 delete this;
Marc Treib 2014/04/25 08:12:38 Unrelated question: AFAIK, deleting an object in t
Bernhard Bauer 2014/04/25 08:30:13 Hm, I think in this case the object is fully const
Marc Treib 2014/04/25 08:50:34 Officially, the object is fully constructed only w
50 return; 50 return;
51 } 51 }
52 52
53 InfoBarService* service = InfoBarService::FromWebContents(web_contents); 53 InfoBarService* service = InfoBarService::FromWebContents(web_contents);
54 if (service) { 54 if (service) {
55 // Remove all the infobars which are attached to |web_contents| and for 55 // Remove all the infobars which are attached to |web_contents| and for
56 // which ShouldExpire() returns true. 56 // which ShouldExpire() returns true.
57 content::LoadCommittedDetails details; 57 content::LoadCommittedDetails details;
58 // |details.is_in_page| is default false, and |details.is_main_frame| is 58 // |details.is_in_page| is default false, and |details.is_main_frame| is
59 // default true. This results in is_navigation_to_different_page() returning 59 // default true. This results in is_navigation_to_different_page() returning
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 return url_filter->GetFilteringBehaviorForURL(url_) != 201 return url_filter->GetFilteringBehaviorForURL(url_) !=
202 ManagedModeURLFilter::BLOCK; 202 ManagedModeURLFilter::BLOCK;
203 } 203 }
204 204
205 void ManagedModeInterstitial::OnFilteringPrefsChanged() { 205 void ManagedModeInterstitial::OnFilteringPrefsChanged() {
206 if (ShouldProceed()) 206 if (ShouldProceed())
207 interstitial_page_->Proceed(); 207 interstitial_page_->Proceed();
208 } 208 }
209 209
210 void ManagedModeInterstitial::DispatchContinueRequest(bool continue_request) { 210 void ManagedModeInterstitial::DispatchContinueRequest(bool continue_request) {
211 // If there is no history entry to go back to, close the tab instead.
212 int nav_entry_count = web_contents_->GetController().GetEntryCount();
213 if (!continue_request && nav_entry_count == 0) {
Bernhard Bauer 2014/04/25 08:30:13 Nit: braces are optional for one-line bodies in ge
Marc Treib 2014/04/25 08:50:34 Done.
214 web_contents_->Close();
215 }
216
211 BrowserThread::PostTask( 217 BrowserThread::PostTask(
212 BrowserThread::IO, FROM_HERE, base::Bind(callback_, continue_request)); 218 BrowserThread::IO, FROM_HERE, base::Bind(callback_, continue_request));
213 } 219 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698