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/chrome_controller_client.h" | 14 #include "chrome/browser/interstitials/chrome_controller_client.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
17 #include "chrome/grit/browser_resources.h" | 17 #include "chrome/grit/browser_resources.h" |
18 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
19 #include "components/grit/components_resources.h" | 19 #include "components/grit/components_resources.h" |
20 #include "components/security_interstitials/core/common_string_util.h" | |
20 #include "components/security_interstitials/core/metrics_helper.h" | 21 #include "components/security_interstitials/core/metrics_helper.h" |
21 #include "components/url_formatter/url_formatter.h" | 22 #include "components/url_formatter/url_formatter.h" |
Peter Kasting
2015/12/02 01:14:40
Seems like this can be removed now?
felt
2015/12/02 03:30:38
Done.
| |
22 #include "content/public/browser/interstitial_page.h" | 23 #include "content/public/browser/interstitial_page.h" |
23 #include "content/public/browser/page_navigator.h" | 24 #include "content/public/browser/page_navigator.h" |
24 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
25 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
26 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
27 #include "ui/base/webui/jstemplate_builder.h" | 28 #include "ui/base/webui/jstemplate_builder.h" |
28 #include "ui/base/webui/web_ui_util.h" | 29 #include "ui/base/webui/web_ui_util.h" |
29 | 30 |
30 SecurityInterstitialPage::SecurityInterstitialPage( | 31 SecurityInterstitialPage::SecurityInterstitialPage( |
31 content::WebContents* web_contents, | 32 content::WebContents* web_contents, |
(...skipping 26 matching lines...) Expand all Loading... | |
58 create_view_ = false; | 59 create_view_ = false; |
59 } | 60 } |
60 | 61 |
61 void SecurityInterstitialPage::Show() { | 62 void SecurityInterstitialPage::Show() { |
62 DCHECK(!interstitial_page_); | 63 DCHECK(!interstitial_page_); |
63 interstitial_page_ = content::InterstitialPage::Create( | 64 interstitial_page_ = content::InterstitialPage::Create( |
64 web_contents_, ShouldCreateNewNavigation(), request_url_, this); | 65 web_contents_, ShouldCreateNewNavigation(), request_url_, this); |
65 if (!create_view_) | 66 if (!create_view_) |
66 interstitial_page_->DontCreateViewForTesting(); | 67 interstitial_page_->DontCreateViewForTesting(); |
67 interstitial_page_->Show(); | 68 interstitial_page_->Show(); |
69 | |
70 controller_->set_interstitial_page(interstitial_page_); | |
71 AfterShow(); | |
68 } | 72 } |
69 | 73 |
70 bool SecurityInterstitialPage::IsPrefEnabled(const char* pref) { | 74 bool SecurityInterstitialPage::IsPrefEnabled(const char* pref) { |
71 Profile* profile = | 75 Profile* profile = |
72 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 76 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
73 return profile->GetPrefs()->GetBoolean(pref); | 77 return profile->GetPrefs()->GetBoolean(pref); |
74 } | 78 } |
75 | 79 |
76 base::string16 SecurityInterstitialPage::GetFormattedHostName() const { | 80 base::string16 SecurityInterstitialPage::GetFormattedHostName() const { |
77 std::string languages; | 81 std::string languages; |
78 Profile* profile = | 82 Profile* profile = |
79 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 83 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
80 if (profile) | 84 if (profile) |
81 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); | 85 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); |
82 base::string16 host = | 86 return security_interstitials::common_string_util::GetFormattedHostName( |
83 url_formatter::IDNToUnicode(request_url_.host(), languages); | 87 request_url_, languages); |
84 if (base::i18n::IsRTL()) | |
85 base::i18n::WrapStringWithLTRFormatting(&host); | |
86 return host; | |
87 } | 88 } |
88 | 89 |
89 std::string SecurityInterstitialPage::GetHTMLContents() { | 90 std::string SecurityInterstitialPage::GetHTMLContents() { |
90 base::DictionaryValue load_time_data; | 91 base::DictionaryValue load_time_data; |
91 PopulateInterstitialStrings(&load_time_data); | 92 PopulateInterstitialStrings(&load_time_data); |
92 const std::string& app_locale = g_browser_process->GetApplicationLocale(); | 93 const std::string& app_locale = g_browser_process->GetApplicationLocale(); |
93 webui::SetLoadTimeDataDefaults(app_locale, &load_time_data); | 94 webui::SetLoadTimeDataDefaults(app_locale, &load_time_data); |
94 std::string html = ResourceBundle::GetSharedInstance() | 95 std::string html = ResourceBundle::GetSharedInstance() |
95 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_HTML) | 96 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_HTML) |
96 .as_string(); | 97 .as_string(); |
(...skipping 11 matching lines...) Expand all Loading... | |
108 | 109 |
109 security_interstitials::MetricsHelper* | 110 security_interstitials::MetricsHelper* |
110 SecurityInterstitialPage::metrics_helper() { | 111 SecurityInterstitialPage::metrics_helper() { |
111 return controller_->metrics_helper(); | 112 return controller_->metrics_helper(); |
112 } | 113 } |
113 | 114 |
114 void SecurityInterstitialPage::set_metrics_helper( | 115 void SecurityInterstitialPage::set_metrics_helper( |
115 scoped_ptr<security_interstitials::MetricsHelper> metrics_helper) { | 116 scoped_ptr<security_interstitials::MetricsHelper> metrics_helper) { |
116 controller_->set_metrics_helper(metrics_helper.Pass()); | 117 controller_->set_metrics_helper(metrics_helper.Pass()); |
117 } | 118 } |
OLD | NEW |