Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/captive_portal/captive_portal_service.h" | |
| 10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 12 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
| 12 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 13 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 14 #include "chrome/browser/ssl/captive_portal_blocking_page.h" | |
| 13 #include "chrome/browser/ssl/ssl_blocking_page.h" | 15 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| 14 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 15 #include "chrome/grit/browser_resources.h" | 17 #include "chrome/grit/browser_resources.h" |
| 16 #include "content/public/browser/interstitial_page_delegate.h" | 18 #include "content/public/browser/interstitial_page_delegate.h" |
| 17 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 18 #include "content/public/browser/web_ui.h" | 20 #include "content/public/browser/web_ui.h" |
| 19 #include "content/public/browser/web_ui_controller.h" | 21 #include "content/public/browser/web_ui_controller.h" |
| 20 #include "content/public/browser/web_ui_data_source.h" | 22 #include "content/public/browser/web_ui_data_source.h" |
| 21 #include "net/base/net_errors.h" | 23 #include "net/base/net_errors.h" |
| 22 #include "net/base/url_util.h" | 24 #include "net/base/url_util.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 SafeBrowsingBlockingPage::UnsafeResource resource; | 134 SafeBrowsingBlockingPage::UnsafeResource resource; |
| 133 resource.url = request_url; | 135 resource.url = request_url; |
| 134 resource.threat_type = threat_type; | 136 resource.threat_type = threat_type; |
| 135 // Create a blocking page without showing the interstitial. | 137 // Create a blocking page without showing the interstitial. |
| 136 return SafeBrowsingBlockingPage::CreateBlockingPage( | 138 return SafeBrowsingBlockingPage::CreateBlockingPage( |
| 137 g_browser_process->safe_browsing_service()->ui_manager().get(), | 139 g_browser_process->safe_browsing_service()->ui_manager().get(), |
| 138 web_contents, | 140 web_contents, |
| 139 resource); | 141 resource); |
| 140 } | 142 } |
| 141 | 143 |
| 144 CaptivePortalBlockingPage* CreateCaptivePortalBlockingPage( | |
| 145 content::WebContents* web_contents) { | |
| 146 GURL request_url("https://example.com"); | |
| 147 GURL landing_url("https://example.com"); | |
|
meacer
2015/06/19 17:46:25
You might want to make this a different URL than r
Bhanu Dev
2015/06/19 18:05:41
I think using request params is a good idea. Thank
meacer
2015/06/19 18:48:59
Either one works since we aren't issuing any reque
| |
| 148 net::SSLInfo ssl_info; | |
| 149 ssl_info.cert = new net::X509Certificate( | |
| 150 request_url.host(), "CA", base::Time::Max(), base::Time::Max()); | |
| 151 return new CaptivePortalBlockingPage( | |
| 152 web_contents, request_url, landing_url,nullptr, ssl_info, | |
|
meacer
2015/06/19 17:46:25
Space between landing_url and nullptr.
Doing |git
Bhanu Dev
2015/06/19 18:05:41
Thanks. I forgot the command. It really save time.
| |
| 153 base::Callback<void(bool)>()); | |
| 154 } | |
| 155 | |
| 142 } // namespace | 156 } // namespace |
| 143 | 157 |
| 144 InterstitialUI::InterstitialUI(content::WebUI* web_ui) | 158 InterstitialUI::InterstitialUI(content::WebUI* web_ui) |
| 145 : WebUIController(web_ui) { | 159 : WebUIController(web_ui) { |
| 146 scoped_ptr<InterstitialHTMLSource> html_source( | 160 scoped_ptr<InterstitialHTMLSource> html_source( |
| 147 new InterstitialHTMLSource(web_ui->GetWebContents())); | 161 new InterstitialHTMLSource(web_ui->GetWebContents())); |
| 148 Profile* profile = Profile::FromWebUI(web_ui); | 162 Profile* profile = Profile::FromWebUI(web_ui); |
| 149 content::URLDataSource::Add(profile, html_source.release()); | 163 content::URLDataSource::Add(profile, html_source.release()); |
| 150 } | 164 } |
| 151 | 165 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 179 void InterstitialHTMLSource::StartDataRequest( | 193 void InterstitialHTMLSource::StartDataRequest( |
| 180 const std::string& path, | 194 const std::string& path, |
| 181 int render_process_id, | 195 int render_process_id, |
| 182 int render_frame_id, | 196 int render_frame_id, |
| 183 const content::URLDataSource::GotDataCallback& callback) { | 197 const content::URLDataSource::GotDataCallback& callback) { |
| 184 scoped_ptr<content::InterstitialPageDelegate> interstitial_delegate; | 198 scoped_ptr<content::InterstitialPageDelegate> interstitial_delegate; |
| 185 if (StartsWithASCII(path, "ssl", true)) { | 199 if (StartsWithASCII(path, "ssl", true)) { |
| 186 interstitial_delegate.reset(CreateSSLBlockingPage(web_contents_)); | 200 interstitial_delegate.reset(CreateSSLBlockingPage(web_contents_)); |
| 187 } else if (StartsWithASCII(path, "safebrowsing", true)) { | 201 } else if (StartsWithASCII(path, "safebrowsing", true)) { |
| 188 interstitial_delegate.reset(CreateSafeBrowsingBlockingPage(web_contents_)); | 202 interstitial_delegate.reset(CreateSafeBrowsingBlockingPage(web_contents_)); |
| 203 } else if (StartsWithASCII(path, "captiveportal", true)) { | |
| 204 interstitial_delegate.reset(CreateCaptivePortalBlockingPage(web_contents_)); | |
| 189 } | 205 } |
| 190 | 206 |
| 191 std::string html; | 207 std::string html; |
| 192 if (interstitial_delegate.get()) { | 208 if (interstitial_delegate.get()) { |
| 193 html = interstitial_delegate.get()->GetHTMLContents(); | 209 html = interstitial_delegate.get()->GetHTMLContents(); |
| 194 } else { | 210 } else { |
| 195 html = ResourceBundle::GetSharedInstance() | 211 html = ResourceBundle::GetSharedInstance() |
| 196 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_UI_HTML) | 212 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_UI_HTML) |
| 197 .as_string(); | 213 .as_string(); |
| 198 } | 214 } |
| 199 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString; | 215 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString; |
| 200 html_bytes->data().assign(html.begin(), html.end()); | 216 html_bytes->data().assign(html.begin(), html.end()); |
| 201 callback.Run(html_bytes.get()); | 217 callback.Run(html_bytes.get()); |
| 202 } | 218 } |
| OLD | NEW |