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

Side by Side Diff: chrome/browser/ui/webui/interstitials/interstitial_ui.cc

Issue 2618573002: Add test to check for crash caused by stale WebContents in chrome://interstitials (Closed)
Patch Set: Fix browser side navigation Created 3 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
« no previous file with comments | « no previous file | chrome/browser/ui/webui/interstitials/interstitial_ui_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ui/webui/interstitials/interstitial_ui.h" 5 #include "chrome/browser/ui/webui/interstitials/interstitial_ui.h"
6 6
7 #include "base/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 336
337 std::string InterstitialHTMLSource::GetContentSecurityPolicyImgSrc() const { 337 std::string InterstitialHTMLSource::GetContentSecurityPolicyImgSrc() const {
338 return "img-src data:;"; 338 return "img-src data:;";
339 } 339 }
340 340
341 void InterstitialHTMLSource::StartDataRequest( 341 void InterstitialHTMLSource::StartDataRequest(
342 const std::string& path, 342 const std::string& path,
343 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, 343 const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
344 const content::URLDataSource::GotDataCallback& callback) { 344 const content::URLDataSource::GotDataCallback& callback) {
345 content::WebContents* web_contents = wc_getter.Run(); 345 content::WebContents* web_contents = wc_getter.Run();
346 if (!web_contents) {
347 // When browser-side navigation is enabled, web_contents can be null if
348 // the tab is closing. Nothing to do in this case.
349 return;
350 }
346 std::unique_ptr<content::InterstitialPageDelegate> interstitial_delegate; 351 std::unique_ptr<content::InterstitialPageDelegate> interstitial_delegate;
347 if (base::StartsWith(path, "ssl", base::CompareCase::SENSITIVE)) { 352 if (base::StartsWith(path, "ssl", base::CompareCase::SENSITIVE)) {
348 interstitial_delegate.reset(CreateSSLBlockingPage(web_contents)); 353 interstitial_delegate.reset(CreateSSLBlockingPage(web_contents));
349 } else if (base::StartsWith(path, "safebrowsing", 354 } else if (base::StartsWith(path, "safebrowsing",
350 base::CompareCase::SENSITIVE)) { 355 base::CompareCase::SENSITIVE)) {
351 interstitial_delegate.reset(CreateSafeBrowsingBlockingPage(web_contents)); 356 interstitial_delegate.reset(CreateSafeBrowsingBlockingPage(web_contents));
352 } else if (base::StartsWith(path, "clock", base::CompareCase::SENSITIVE)) { 357 } else if (base::StartsWith(path, "clock", base::CompareCase::SENSITIVE)) {
353 interstitial_delegate.reset(CreateBadClockBlockingPage(web_contents)); 358 interstitial_delegate.reset(CreateBadClockBlockingPage(web_contents));
354 } 359 }
355 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) 360 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION)
356 else if (base::StartsWith(path, "captiveportal", 361 else if (base::StartsWith(path, "captiveportal",
357 base::CompareCase::SENSITIVE)) 362 base::CompareCase::SENSITIVE))
358 { 363 {
359 interstitial_delegate.reset(CreateCaptivePortalBlockingPage(web_contents)); 364 interstitial_delegate.reset(CreateCaptivePortalBlockingPage(web_contents));
360 } 365 }
361 #endif 366 #endif
362 std::string html; 367 std::string html;
363 if (interstitial_delegate.get()) { 368 if (interstitial_delegate.get()) {
364 html = interstitial_delegate.get()->GetHTMLContents(); 369 html = interstitial_delegate.get()->GetHTMLContents();
365 } else { 370 } else {
366 html = ResourceBundle::GetSharedInstance() 371 html = ResourceBundle::GetSharedInstance()
367 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_UI_HTML) 372 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_UI_HTML)
368 .as_string(); 373 .as_string();
369 } 374 }
370 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString; 375 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString;
371 html_bytes->data().assign(html.begin(), html.end()); 376 html_bytes->data().assign(html.begin(), html.end());
372 callback.Run(html_bytes.get()); 377 callback.Run(html_bytes.get());
373 } 378 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/interstitials/interstitial_ui_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698