| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/interstitials/security_interstitial_page.h" | 5 #include "chrome/browser/interstitials/security_interstitial_page.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "components/security_interstitials/core/metrics_helper.h" | 22 #include "components/security_interstitials/core/metrics_helper.h" |
| 23 #include "content/public/browser/interstitial_page.h" | 23 #include "content/public/browser/interstitial_page.h" |
| 24 #include "content/public/browser/page_navigator.h" | 24 #include "content/public/browser/page_navigator.h" |
| 25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 26 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
| 27 #include "ui/base/webui/jstemplate_builder.h" | 27 #include "ui/base/webui/jstemplate_builder.h" |
| 28 #include "ui/base/webui/web_ui_util.h" | 28 #include "ui/base/webui/web_ui_util.h" |
| 29 | 29 |
| 30 SecurityInterstitialPage::SecurityInterstitialPage( | 30 SecurityInterstitialPage::SecurityInterstitialPage( |
| 31 content::WebContents* web_contents, | 31 content::WebContents* web_contents, |
| 32 const GURL& request_url) | 32 const GURL& request_url, |
| 33 std::unique_ptr<security_interstitials::MetricsHelper> metrics_helper) |
| 33 : web_contents_(web_contents), | 34 : web_contents_(web_contents), |
| 34 request_url_(request_url), | 35 request_url_(request_url), |
| 35 interstitial_page_(NULL), | 36 interstitial_page_(NULL), |
| 36 create_view_(true), | 37 create_view_(true), |
| 37 controller_(new ChromeControllerClient(web_contents)) { | 38 controller_( |
| 39 new ChromeControllerClient(web_contents, std::move(metrics_helper))) { |
| 38 // Creating interstitial_page_ without showing it leaks memory, so don't | 40 // Creating interstitial_page_ without showing it leaks memory, so don't |
| 39 // create it here. | 41 // create it here. |
| 40 } | 42 } |
| 41 | 43 |
| 42 SecurityInterstitialPage::~SecurityInterstitialPage() { | 44 SecurityInterstitialPage::~SecurityInterstitialPage() { |
| 43 } | 45 } |
| 44 | 46 |
| 45 content::InterstitialPage* SecurityInterstitialPage::interstitial_page() const { | 47 content::InterstitialPage* SecurityInterstitialPage::interstitial_page() const { |
| 46 return interstitial_page_; | 48 return interstitial_page_; |
| 47 } | 49 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 69 controller_->set_interstitial_page(interstitial_page_); | 71 controller_->set_interstitial_page(interstitial_page_); |
| 70 AfterShow(); | 72 AfterShow(); |
| 71 } | 73 } |
| 72 | 74 |
| 73 bool SecurityInterstitialPage::IsPrefEnabled(const char* pref) { | 75 bool SecurityInterstitialPage::IsPrefEnabled(const char* pref) { |
| 74 Profile* profile = | 76 Profile* profile = |
| 75 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 77 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 76 return profile->GetPrefs()->GetBoolean(pref); | 78 return profile->GetPrefs()->GetBoolean(pref); |
| 77 } | 79 } |
| 78 | 80 |
| 81 ChromeControllerClient* SecurityInterstitialPage::controller() { |
| 82 return controller_.get(); |
| 83 } |
| 84 |
| 85 security_interstitials::MetricsHelper* |
| 86 SecurityInterstitialPage::metrics_helper() { |
| 87 return controller_->metrics_helper(); |
| 88 } |
| 89 |
| 79 base::string16 SecurityInterstitialPage::GetFormattedHostName() const { | 90 base::string16 SecurityInterstitialPage::GetFormattedHostName() const { |
| 80 return security_interstitials::common_string_util::GetFormattedHostName( | 91 return security_interstitials::common_string_util::GetFormattedHostName( |
| 81 request_url_); | 92 request_url_); |
| 82 } | 93 } |
| 83 | 94 |
| 84 std::string SecurityInterstitialPage::GetHTMLContents() { | 95 std::string SecurityInterstitialPage::GetHTMLContents() { |
| 85 base::DictionaryValue load_time_data; | 96 base::DictionaryValue load_time_data; |
| 86 PopulateInterstitialStrings(&load_time_data); | 97 PopulateInterstitialStrings(&load_time_data); |
| 87 const std::string& app_locale = g_browser_process->GetApplicationLocale(); | 98 const std::string& app_locale = g_browser_process->GetApplicationLocale(); |
| 88 webui::SetLoadTimeDataDefaults(app_locale, &load_time_data); | 99 webui::SetLoadTimeDataDefaults(app_locale, &load_time_data); |
| 89 std::string html = ResourceBundle::GetSharedInstance() | 100 std::string html = ResourceBundle::GetSharedInstance() |
| 90 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_HTML) | 101 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_HTML) |
| 91 .as_string(); | 102 .as_string(); |
| 92 webui::AppendWebUiCssTextDefaults(&html); | 103 webui::AppendWebUiCssTextDefaults(&html); |
| 93 return webui::GetI18nTemplateHtml(html, &load_time_data); | 104 return webui::GetI18nTemplateHtml(html, &load_time_data); |
| 94 } | 105 } |
| 95 | |
| 96 security_interstitials::MetricsHelper* | |
| 97 SecurityInterstitialPage::metrics_helper() { | |
| 98 return controller_->metrics_helper(); | |
| 99 } | |
| 100 | |
| 101 void SecurityInterstitialPage::set_metrics_helper( | |
| 102 std::unique_ptr<security_interstitials::MetricsHelper> metrics_helper) { | |
| 103 controller_->set_metrics_helper(std::move(metrics_helper)); | |
| 104 } | |
| 105 | |
| 106 ChromeControllerClient* SecurityInterstitialPage::controller() { | |
| 107 return controller_.get(); | |
| 108 } | |
| OLD | NEW |