OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ssl/ios_ssl_blocking_page.h" | 5 #include "ios/chrome/browser/ssl/ios_ssl_blocking_page.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "components/security_interstitials/core/metrics_helper.h" | 13 #include "components/security_interstitials/core/metrics_helper.h" |
14 #include "components/security_interstitials/core/ssl_error_ui.h" | 14 #include "components/security_interstitials/core/ssl_error_ui.h" |
15 #include "grit/components_strings.h" | 15 #include "grit/components_strings.h" |
16 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 16 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
17 #include "ios/chrome/browser/interstitials/ios_chrome_controller_client.h" | 17 #include "ios/chrome/browser/interstitials/ios_chrome_controller_client.h" |
18 #include "ios/chrome/browser/interstitials/ios_chrome_metrics_helper.h" | 18 #include "ios/chrome/browser/interstitials/ios_chrome_metrics_helper.h" |
19 #include "ios/chrome/grit/ios_strings.h" | |
20 #include "ios/public/provider/chrome/browser/browser_constants.h" | |
21 #import "ios/web/public/navigation_item.h" | 19 #import "ios/web/public/navigation_item.h" |
22 #include "ios/web/public/ssl_status.h" | 20 #include "ios/web/public/ssl_status.h" |
23 #include "ios/web/public/web_state/web_state.h" | 21 #include "ios/web/public/web_state/web_state.h" |
24 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
25 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
26 #include "url/gurl.h" | 24 #include "url/gurl.h" |
27 | 25 |
28 using security_interstitials::SSLErrorUI; | 26 using security_interstitials::SSLErrorUI; |
29 | 27 |
30 namespace { | 28 namespace { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } | 129 } |
132 } | 130 } |
133 | 131 |
134 void IOSSSLBlockingPage::AfterShow() { | 132 void IOSSSLBlockingPage::AfterShow() { |
135 controller_->SetWebInterstitial(web_interstitial()); | 133 controller_->SetWebInterstitial(web_interstitial()); |
136 } | 134 } |
137 | 135 |
138 void IOSSSLBlockingPage::PopulateInterstitialStrings( | 136 void IOSSSLBlockingPage::PopulateInterstitialStrings( |
139 base::DictionaryValue* load_time_data) const { | 137 base::DictionaryValue* load_time_data) const { |
140 ssl_error_ui_->PopulateStringsForHTML(load_time_data); | 138 ssl_error_ui_->PopulateStringsForHTML(load_time_data); |
141 // Spoofing attempts have a custom message on iOS. | |
142 // This code will no longer be necessary once UIWebView is gone. | |
143 if (ssl_info_.cert->subject().GetDisplayName() == ios::kSpoofingAttemptFlag) { | |
144 load_time_data->SetString( | |
145 "errorCode", base::string16(base::ASCIIToUTF16("Unverified URL"))); | |
146 load_time_data->SetString( | |
147 "tabTitle", l10n_util::GetStringUTF16( | |
148 IDS_IOS_INTERSTITIAL_HEADING_SPOOFING_ATTEMPT_ERROR)); | |
149 load_time_data->SetString( | |
150 "heading", l10n_util::GetStringUTF16( | |
151 IDS_IOS_INTERSTITIAL_HEADING_SPOOFING_ATTEMPT_ERROR)); | |
152 load_time_data->SetString( | |
153 "primaryParagraph", | |
154 l10n_util::GetStringUTF16( | |
155 IDS_IOS_INTERSTITIAL_SUMMARY_SPOOFING_ATTEMPT_ERROR)); | |
156 load_time_data->SetString( | |
157 "explanationParagraph", | |
158 l10n_util::GetStringUTF16( | |
159 IDS_IOS_INTERSTITIAL_DETAILS_SPOOFING_ATTEMPT_ERROR)); | |
160 load_time_data->SetString("finalParagraph", base::string16()); | |
161 } | |
162 } | 139 } |
163 | 140 |
164 // This handles the commands sent from the interstitial JavaScript. | 141 // This handles the commands sent from the interstitial JavaScript. |
165 void IOSSSLBlockingPage::CommandReceived(const std::string& command) { | 142 void IOSSSLBlockingPage::CommandReceived(const std::string& command) { |
166 if (command == "\"pageLoadComplete\"") { | 143 if (command == "\"pageLoadComplete\"") { |
167 // content::WaitForRenderFrameReady sends this message when the page | 144 // content::WaitForRenderFrameReady sends this message when the page |
168 // load completes. Ignore it. | 145 // load completes. Ignore it. |
169 return; | 146 return; |
170 } | 147 } |
171 | 148 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 191 |
215 callback_.Run(false); | 192 callback_.Run(false); |
216 callback_.Reset(); | 193 callback_.Reset(); |
217 } | 194 } |
218 | 195 |
219 // static | 196 // static |
220 bool IOSSSLBlockingPage::IsOverridable(int options_mask) { | 197 bool IOSSSLBlockingPage::IsOverridable(int options_mask) { |
221 return (options_mask & SSLErrorUI::SOFT_OVERRIDE_ENABLED) && | 198 return (options_mask & SSLErrorUI::SOFT_OVERRIDE_ENABLED) && |
222 !(options_mask & SSLErrorUI::STRICT_ENFORCEMENT); | 199 !(options_mask & SSLErrorUI::STRICT_ENFORCEMENT); |
223 } | 200 } |
OLD | NEW |