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 "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/interstitials/security_interstitial_metrics_helper.h" | 14 #include "chrome/browser/interstitials/security_interstitial_metrics_helper.h" |
15 #include "chrome/browser/net/referrer.h" | 15 #include "chrome/browser/net/referrer.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
18 #include "chrome/grit/browser_resources.h" | 18 #include "chrome/grit/browser_resources.h" |
19 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" |
20 #include "components/google/core/browser/google_util.h" | 20 #include "components/google/core/browser/google_util.h" |
| 21 #include "components/url_formatter/url_formatter.h" |
21 #include "content/public/browser/interstitial_page.h" | 22 #include "content/public/browser/interstitial_page.h" |
22 #include "content/public/browser/page_navigator.h" | 23 #include "content/public/browser/page_navigator.h" |
23 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
24 #include "net/base/net_util.h" | |
25 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.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 namespace interstitials { | 30 namespace interstitials { |
31 const char kBoxChecked[] = "boxchecked"; | 31 const char kBoxChecked[] = "boxchecked"; |
32 const char kDisplayCheckBox[] = "displaycheckbox"; | 32 const char kDisplayCheckBox[] = "displaycheckbox"; |
33 const char kOptInLink[] = "optInLink"; | 33 const char kOptInLink[] = "optInLink"; |
34 const char kPrivacyLinkHtml[] = | 34 const char kPrivacyLinkHtml[] = |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 SecurityInterstitialMetricsHelper* metrics_helper) { | 115 SecurityInterstitialMetricsHelper* metrics_helper) { |
116 metrics_helper_.reset(metrics_helper); | 116 metrics_helper_.reset(metrics_helper); |
117 } | 117 } |
118 | 118 |
119 base::string16 SecurityInterstitialPage::GetFormattedHostName() const { | 119 base::string16 SecurityInterstitialPage::GetFormattedHostName() const { |
120 std::string languages; | 120 std::string languages; |
121 Profile* profile = | 121 Profile* profile = |
122 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 122 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
123 if (profile) | 123 if (profile) |
124 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); | 124 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); |
125 base::string16 host = net::IDNToUnicode(request_url_.host(), languages); | 125 base::string16 host = |
| 126 url_formatter::IDNToUnicode(request_url_.host(), languages); |
126 if (base::i18n::IsRTL()) | 127 if (base::i18n::IsRTL()) |
127 base::i18n::WrapStringWithLTRFormatting(&host); | 128 base::i18n::WrapStringWithLTRFormatting(&host); |
128 return host; | 129 return host; |
129 } | 130 } |
130 | 131 |
131 std::string SecurityInterstitialPage::GetHTMLContents() { | 132 std::string SecurityInterstitialPage::GetHTMLContents() { |
132 base::DictionaryValue load_time_data; | 133 base::DictionaryValue load_time_data; |
133 PopulateInterstitialStrings(&load_time_data); | 134 PopulateInterstitialStrings(&load_time_data); |
134 const std::string& app_locale = g_browser_process->GetApplicationLocale(); | 135 const std::string& app_locale = g_browser_process->GetApplicationLocale(); |
135 webui::SetLoadTimeDataDefaults(app_locale, &load_time_data); | 136 webui::SetLoadTimeDataDefaults(app_locale, &load_time_data); |
136 std::string html = ResourceBundle::GetSharedInstance() | 137 std::string html = ResourceBundle::GetSharedInstance() |
137 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_HTML) | 138 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_HTML) |
138 .as_string(); | 139 .as_string(); |
139 webui::AppendWebUiCssTextDefaults(&html); | 140 webui::AppendWebUiCssTextDefaults(&html); |
140 return webui::GetI18nTemplateHtml(html, &load_time_data); | 141 return webui::GetI18nTemplateHtml(html, &load_time_data); |
141 } | 142 } |
OLD | NEW |