OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ios/chrome/browser/interstitials/ios_security_interstitial_page.h" | 5 #include "ios/chrome/browser/interstitials/ios_security_interstitial_page.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "components/grit/components_resources.h" | 8 #include "components/grit/components_resources.h" |
9 #include "components/prefs/pref_service.h" | 9 #include "components/prefs/pref_service.h" |
10 #include "components/security_interstitials/core/common_string_util.h" | 10 #include "components/security_interstitials/core/common_string_util.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // Creating web_interstitial_ without showing it leaks memory, so don't | 28 // Creating web_interstitial_ without showing it leaks memory, so don't |
29 // create it here. | 29 // create it here. |
30 } | 30 } |
31 | 31 |
32 IOSSecurityInterstitialPage::~IOSSecurityInterstitialPage() {} | 32 IOSSecurityInterstitialPage::~IOSSecurityInterstitialPage() {} |
33 | 33 |
34 void IOSSecurityInterstitialPage::Show() { | 34 void IOSSecurityInterstitialPage::Show() { |
35 DCHECK(!web_interstitial_); | 35 DCHECK(!web_interstitial_); |
36 web_interstitial_ = web::WebInterstitial::CreateHtmlInterstitial( | 36 web_interstitial_ = web::WebInterstitial::CreateHtmlInterstitial( |
37 web_state_, ShouldCreateNewNavigation(), request_url_, | 37 web_state_, ShouldCreateNewNavigation(), request_url_, |
38 scoped_ptr<web::HtmlWebInterstitialDelegate>(this)); | 38 std::unique_ptr<web::HtmlWebInterstitialDelegate>(this)); |
39 web_interstitial_->Show(); | 39 web_interstitial_->Show(); |
40 AfterShow(); | 40 AfterShow(); |
41 } | 41 } |
42 | 42 |
43 std::string IOSSecurityInterstitialPage::GetHtmlContents() const { | 43 std::string IOSSecurityInterstitialPage::GetHtmlContents() const { |
44 base::DictionaryValue load_time_data; | 44 base::DictionaryValue load_time_data; |
45 PopulateInterstitialStrings(&load_time_data); | 45 PopulateInterstitialStrings(&load_time_data); |
46 webui::SetLoadTimeDataDefaults( | 46 webui::SetLoadTimeDataDefaults( |
47 GetApplicationContext()->GetApplicationLocale(), &load_time_data); | 47 GetApplicationContext()->GetApplicationLocale(), &load_time_data); |
48 std::string html = ResourceBundle::GetSharedInstance() | 48 std::string html = ResourceBundle::GetSharedInstance() |
49 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_HTML) | 49 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_HTML) |
50 .as_string(); | 50 .as_string(); |
51 webui::AppendWebUiCssTextDefaults(&html); | 51 webui::AppendWebUiCssTextDefaults(&html); |
52 return webui::GetI18nTemplateHtml(html, &load_time_data); | 52 return webui::GetI18nTemplateHtml(html, &load_time_data); |
53 } | 53 } |
54 | 54 |
55 base::string16 IOSSecurityInterstitialPage::GetFormattedHostName() const { | 55 base::string16 IOSSecurityInterstitialPage::GetFormattedHostName() const { |
56 return security_interstitials::common_string_util::GetFormattedHostName( | 56 return security_interstitials::common_string_util::GetFormattedHostName( |
57 request_url_); | 57 request_url_); |
58 } | 58 } |
59 | 59 |
60 bool IOSSecurityInterstitialPage::IsPrefEnabled(const char* pref_name) const { | 60 bool IOSSecurityInterstitialPage::IsPrefEnabled(const char* pref_name) const { |
61 ios::ChromeBrowserState* browser_state = | 61 ios::ChromeBrowserState* browser_state = |
62 ios::ChromeBrowserState::FromBrowserState(web_state_->GetBrowserState()); | 62 ios::ChromeBrowserState::FromBrowserState(web_state_->GetBrowserState()); |
63 return browser_state->GetPrefs()->GetBoolean(pref_name); | 63 return browser_state->GetPrefs()->GetBoolean(pref_name); |
64 } | 64 } |
OLD | NEW |