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

Unified Diff: chrome/browser/ui/webui/interstitials/interstitial_ui.cc

Issue 2417463007: Fix crash caused by stale WebContents in chrome://interstitials (Closed)
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/interstitials/interstitial_ui.cc
diff --git a/chrome/browser/ui/webui/interstitials/interstitial_ui.cc b/chrome/browser/ui/webui/interstitials/interstitial_ui.cc
index 674d38463ea368f8378e4c762ba6e625d84704d1..dd641b5459b71fea4263b28df3e424e9ecde91a1 100644
--- a/chrome/browser/ui/webui/interstitials/interstitial_ui.cc
+++ b/chrome/browser/ui/webui/interstitials/interstitial_ui.cc
@@ -65,8 +65,8 @@ scoped_refptr<net::X509Certificate> CreateFakeCert() {
// not used in displaying any real interstitials.
class InterstitialHTMLSource : public content::URLDataSource {
public:
- explicit InterstitialHTMLSource(content::WebContents* web_contents);
- ~InterstitialHTMLSource() override;
+ InterstitialHTMLSource() {}
+ ~InterstitialHTMLSource() override {}
// content::URLDataSource:
std::string GetMimeType(const std::string& mime_type) const override;
@@ -80,7 +80,6 @@ class InterstitialHTMLSource : public content::URLDataSource {
const content::URLDataSource::GotDataCallback& callback) override;
private:
- content::WebContents* web_contents_;
DISALLOW_COPY_AND_ASSIGN(InterstitialHTMLSource);
};
@@ -308,10 +307,8 @@ CaptivePortalBlockingPage* CreateCaptivePortalBlockingPage(
InterstitialUI::InterstitialUI(content::WebUI* web_ui)
: WebUIController(web_ui) {
- std::unique_ptr<InterstitialHTMLSource> html_source(
- new InterstitialHTMLSource(web_ui->GetWebContents()));
Profile* profile = Profile::FromWebUI(web_ui);
- content::URLDataSource::Add(profile, html_source.release());
+ content::URLDataSource::Add(profile, new InterstitialHTMLSource());
}
InterstitialUI::~InterstitialUI() {
@@ -319,14 +316,6 @@ InterstitialUI::~InterstitialUI() {
// InterstitialHTMLSource
-InterstitialHTMLSource::InterstitialHTMLSource(
- content::WebContents* web_contents)
- : web_contents_(web_contents) {
-}
-
-InterstitialHTMLSource::~InterstitialHTMLSource() {
-}
-
std::string InterstitialHTMLSource::GetMimeType(
const std::string& mime_type) const {
return "text/html";
@@ -353,20 +342,21 @@ void InterstitialHTMLSource::StartDataRequest(
const std::string& path,
const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
const content::URLDataSource::GotDataCallback& callback) {
+ content::WebContents* web_contents = wc_getter.Run();
std::unique_ptr<content::InterstitialPageDelegate> interstitial_delegate;
if (base::StartsWith(path, "ssl", base::CompareCase::SENSITIVE)) {
- interstitial_delegate.reset(CreateSSLBlockingPage(web_contents_));
+ interstitial_delegate.reset(CreateSSLBlockingPage(web_contents));
} else if (base::StartsWith(path, "safebrowsing",
base::CompareCase::SENSITIVE)) {
- interstitial_delegate.reset(CreateSafeBrowsingBlockingPage(web_contents_));
+ interstitial_delegate.reset(CreateSafeBrowsingBlockingPage(web_contents));
} else if (base::StartsWith(path, "clock", base::CompareCase::SENSITIVE)) {
- interstitial_delegate.reset(CreateBadClockBlockingPage(web_contents_));
+ interstitial_delegate.reset(CreateBadClockBlockingPage(web_contents));
}
#if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION)
else if (base::StartsWith(path, "captiveportal",
base::CompareCase::SENSITIVE))
{
- interstitial_delegate.reset(CreateCaptivePortalBlockingPage(web_contents_));
+ interstitial_delegate.reset(CreateCaptivePortalBlockingPage(web_contents));
}
#endif
std::string html;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698