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/macros.h" | 7 #include "base/macros.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 "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 web_contents, request_url, landing_url, ssl_info, | 273 web_contents, request_url, landing_url, ssl_info, |
274 base::Callback<void(bool)>(), is_wifi_connection, wifi_ssid); | 274 base::Callback<void(bool)>(), is_wifi_connection, wifi_ssid); |
275 return blocking_page; | 275 return blocking_page; |
276 } | 276 } |
277 #endif | 277 #endif |
278 | 278 |
279 } // namespace | 279 } // namespace |
280 | 280 |
281 InterstitialUI::InterstitialUI(content::WebUI* web_ui) | 281 InterstitialUI::InterstitialUI(content::WebUI* web_ui) |
282 : WebUIController(web_ui) { | 282 : WebUIController(web_ui) { |
283 scoped_ptr<InterstitialHTMLSource> html_source( | 283 std::unique_ptr<InterstitialHTMLSource> html_source( |
284 new InterstitialHTMLSource(web_ui->GetWebContents())); | 284 new InterstitialHTMLSource(web_ui->GetWebContents())); |
285 Profile* profile = Profile::FromWebUI(web_ui); | 285 Profile* profile = Profile::FromWebUI(web_ui); |
286 content::URLDataSource::Add(profile, html_source.release()); | 286 content::URLDataSource::Add(profile, html_source.release()); |
287 } | 287 } |
288 | 288 |
289 InterstitialUI::~InterstitialUI() { | 289 InterstitialUI::~InterstitialUI() { |
290 } | 290 } |
291 | 291 |
292 // InterstitialHTMLSource | 292 // InterstitialHTMLSource |
293 | 293 |
(...skipping 17 matching lines...) Expand all Loading... |
311 bool InterstitialHTMLSource::ShouldAddContentSecurityPolicy() | 311 bool InterstitialHTMLSource::ShouldAddContentSecurityPolicy() |
312 const { | 312 const { |
313 return false; | 313 return false; |
314 } | 314 } |
315 | 315 |
316 void InterstitialHTMLSource::StartDataRequest( | 316 void InterstitialHTMLSource::StartDataRequest( |
317 const std::string& path, | 317 const std::string& path, |
318 int render_process_id, | 318 int render_process_id, |
319 int render_frame_id, | 319 int render_frame_id, |
320 const content::URLDataSource::GotDataCallback& callback) { | 320 const content::URLDataSource::GotDataCallback& callback) { |
321 scoped_ptr<content::InterstitialPageDelegate> interstitial_delegate; | 321 std::unique_ptr<content::InterstitialPageDelegate> interstitial_delegate; |
322 if (base::StartsWith(path, "ssl", base::CompareCase::SENSITIVE)) { | 322 if (base::StartsWith(path, "ssl", base::CompareCase::SENSITIVE)) { |
323 interstitial_delegate.reset(CreateSSLBlockingPage(web_contents_)); | 323 interstitial_delegate.reset(CreateSSLBlockingPage(web_contents_)); |
324 } else if (base::StartsWith(path, "safebrowsing", | 324 } else if (base::StartsWith(path, "safebrowsing", |
325 base::CompareCase::SENSITIVE)) { | 325 base::CompareCase::SENSITIVE)) { |
326 interstitial_delegate.reset(CreateSafeBrowsingBlockingPage(web_contents_)); | 326 interstitial_delegate.reset(CreateSafeBrowsingBlockingPage(web_contents_)); |
327 } else if (base::StartsWith(path, "clock", base::CompareCase::SENSITIVE)) { | 327 } else if (base::StartsWith(path, "clock", base::CompareCase::SENSITIVE)) { |
328 interstitial_delegate.reset(CreateBadClockBlockingPage(web_contents_)); | 328 interstitial_delegate.reset(CreateBadClockBlockingPage(web_contents_)); |
329 } | 329 } |
330 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 330 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
331 else if (base::StartsWith(path, "captiveportal", | 331 else if (base::StartsWith(path, "captiveportal", |
332 base::CompareCase::SENSITIVE)) | 332 base::CompareCase::SENSITIVE)) |
333 { | 333 { |
334 interstitial_delegate.reset(CreateCaptivePortalBlockingPage(web_contents_)); | 334 interstitial_delegate.reset(CreateCaptivePortalBlockingPage(web_contents_)); |
335 } | 335 } |
336 #endif | 336 #endif |
337 std::string html; | 337 std::string html; |
338 if (interstitial_delegate.get()) { | 338 if (interstitial_delegate.get()) { |
339 html = interstitial_delegate.get()->GetHTMLContents(); | 339 html = interstitial_delegate.get()->GetHTMLContents(); |
340 } else { | 340 } else { |
341 html = ResourceBundle::GetSharedInstance() | 341 html = ResourceBundle::GetSharedInstance() |
342 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_UI_HTML) | 342 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_UI_HTML) |
343 .as_string(); | 343 .as_string(); |
344 } | 344 } |
345 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString; | 345 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString; |
346 html_bytes->data().assign(html.begin(), html.end()); | 346 html_bytes->data().assign(html.begin(), html.end()); |
347 callback.Run(html_bytes.get()); | 347 callback.Run(html_bytes.get()); |
348 } | 348 } |
OLD | NEW |