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

Side by Side Diff: chrome/browser/ssl/ssl_blocking_page.cc

Issue 368143002: Add a chrome://interstitials page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix client side phishing interstitial Created 6 years, 5 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/ssl/ssl_blocking_page.h" 5 #include "chrome/browser/ssl/ssl_blocking_page.h"
6 6
7 #include "base/build_time.h" 7 #include "base/build_time.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/i18n/time_formatting.h" 10 #include "base/i18n/time_formatting.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 271 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
272 CaptivePortalService* captive_portal_service = 272 CaptivePortalService* captive_portal_service =
273 CaptivePortalServiceFactory::GetForProfile(profile); 273 CaptivePortalServiceFactory::GetForProfile(profile);
274 captive_portal_detection_enabled_ = captive_portal_service ->enabled(); 274 captive_portal_detection_enabled_ = captive_portal_service ->enabled();
275 captive_portal_service ->DetectCaptivePortal(); 275 captive_portal_service ->DetectCaptivePortal();
276 registrar_.Add(this, 276 registrar_.Add(this,
277 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, 277 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT,
278 content::Source<Profile>(profile)); 278 content::Source<Profile>(profile));
279 #endif 279 #endif
280 280
281 // chrome://interstitials page uses this class without actually creating an
282 // interstitial so that it can be debugged. Set |create_interstitial| to true
283 // if the page is going to be used as an actual interstitial and not just part
284 // of the chrome://interstitials webui.
281 interstitial_page_ = InterstitialPage::Create( 285 interstitial_page_ = InterstitialPage::Create(
282 web_contents_, true, request_url, this); 286 web_contents_, true, request_url, this);
283 interstitial_page_->Show();
284 } 287 }
285 288
286 SSLBlockingPage::~SSLBlockingPage() { 289 SSLBlockingPage::~SSLBlockingPage() {
287 if (!callback_.is_null()) { 290 if (!callback_.is_null()) {
288 RecordSSLBlockingPageDetailedStats(false, 291 RecordSSLBlockingPageDetailedStats(false,
289 cert_error_, 292 cert_error_,
290 overridable_ && !strict_enforcement_, 293 overridable_ && !strict_enforcement_,
291 internal_, 294 internal_,
292 num_visits_, 295 num_visits_,
293 captive_portal_detection_enabled_, 296 captive_portal_detection_enabled_,
294 captive_portal_probe_completed_, 297 captive_portal_probe_completed_,
295 captive_portal_no_response_, 298 captive_portal_no_response_,
296 captive_portal_detected_); 299 captive_portal_detected_);
297 // The page is closed without the user having chosen what to do, default to 300 // The page is closed without the user having chosen what to do, default to
298 // deny. 301 // deny.
299 NotifyDenyCertificate(); 302 NotifyDenyCertificate();
300 } 303 }
301 } 304 }
302 305
306 // static
307 void SSLBlockingPage::Show(content::WebContents* web_contents,
308 int cert_error,
309 const net::SSLInfo& ssl_info,
310 const GURL& request_url,
311 bool overridable,
312 bool strict_enforcement,
313 const base::Callback<void(bool)>& callback) {
314 SSLBlockingPage* ssl_blocking_page = new SSLBlockingPage(web_contents,
315 cert_error,
316 ssl_info,
317 request_url,
318 overridable,
319 strict_enforcement,
320 callback);
321 ssl_blocking_page->interstitial_page_->Show();
322 }
323
324 // static
325 SSLBlockingPage* SSLBlockingPage::CreateForWebUI(
326 content::WebContents* web_contents,
327 int cert_error,
328 const net::SSLInfo& ssl_info,
329 const GURL& request_url,
330 bool overridable,
331 bool strict_enforcement) {
332 return new SSLBlockingPage(web_contents,
333 cert_error,
334 ssl_info,
335 request_url,
336 overridable,
337 strict_enforcement,
338 base::Callback<void(bool)>());
339 }
340
303 std::string SSLBlockingPage::GetHTMLContents() { 341 std::string SSLBlockingPage::GetHTMLContents() {
304 if (trial_condition_ == kCondV1 || trial_condition_ == kCondV1LayoutV2Text) 342 if (trial_condition_ == kCondV1 || trial_condition_ == kCondV1LayoutV2Text)
305 return GetHTMLContentsV1(); 343 return GetHTMLContentsV1();
306 return GetHTMLContentsV2(); 344 return GetHTMLContentsV2();
307 } 345 }
308 346
309 std::string SSLBlockingPage::GetHTMLContentsV1() { 347 std::string SSLBlockingPage::GetHTMLContentsV1() {
310 base::DictionaryValue strings; 348 base::DictionaryValue strings;
311 int resource_id; 349 int resource_id;
312 if (overridable_ && !strict_enforcement_) { 350 if (overridable_ && !strict_enforcement_) {
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 // sure we don't clear the captive portal flag, since the interstitial was 759 // sure we don't clear the captive portal flag, since the interstitial was
722 // potentially caused by the captive portal. 760 // potentially caused by the captive portal.
723 captive_portal_detected_ = captive_portal_detected_ || 761 captive_portal_detected_ = captive_portal_detected_ ||
724 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); 762 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL);
725 // Also keep track of non-HTTP portals and error cases. 763 // Also keep track of non-HTTP portals and error cases.
726 captive_portal_no_response_ = captive_portal_no_response_ || 764 captive_portal_no_response_ = captive_portal_no_response_ ||
727 (results->result == captive_portal::RESULT_NO_RESPONSE); 765 (results->result == captive_portal::RESULT_NO_RESPONSE);
728 } 766 }
729 #endif 767 #endif
730 } 768 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698