OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 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/ui/webui/interstitials/interstitial_ui.h" | 5 #include "chrome/browser/ui/webui/interstitials/interstitial_ui.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 &overridable_param)) { | 149 &overridable_param)) { |
150 overridable = overridable_param == "1"; | 150 overridable = overridable_param == "1"; |
151 } | 151 } |
152 std::string strict_enforcement_param; | 152 std::string strict_enforcement_param; |
153 if (net::GetValueForKeyInQuery(web_contents->GetURL(), "strict_enforcement", | 153 if (net::GetValueForKeyInQuery(web_contents->GetURL(), "strict_enforcement", |
154 &strict_enforcement_param)) { | 154 &strict_enforcement_param)) { |
155 strict_enforcement = strict_enforcement_param == "1"; | 155 strict_enforcement = strict_enforcement_param == "1"; |
156 } | 156 } |
157 | 157 |
158 // Determine whether to change the clock to be ahead or behind. | 158 // Determine whether to change the clock to be ahead or behind. |
159 base::Time time_triggered_ = base::Time::NowFromSystemTime(); | |
160 std::string clock_manipulation_param; | 159 std::string clock_manipulation_param; |
| 160 ssl_errors::ClockState clock_state = ssl_errors::CLOCK_STATE_PAST; |
161 if (net::GetValueForKeyInQuery(web_contents->GetURL(), "clock_manipulation", | 161 if (net::GetValueForKeyInQuery(web_contents->GetURL(), "clock_manipulation", |
162 &clock_manipulation_param)) { | 162 &clock_manipulation_param)) { |
163 int time_offset; | 163 int time_offset; |
164 if (!base::StringToInt(clock_manipulation_param, &time_offset)) | 164 if (base::StringToInt(clock_manipulation_param, &time_offset)) { |
165 time_offset = 2; | 165 clock_state = time_offset > 0 ? ssl_errors::CLOCK_STATE_FUTURE |
166 time_triggered_ += base::TimeDelta::FromDays(365 * time_offset); | 166 : ssl_errors::CLOCK_STATE_PAST; |
| 167 } |
167 } | 168 } |
168 | 169 |
169 net::SSLInfo ssl_info; | 170 net::SSLInfo ssl_info; |
170 ssl_info.cert = new net::X509Certificate( | 171 ssl_info.cert = new net::X509Certificate( |
171 request_url.host(), "CA", base::Time::Max(), base::Time::Max()); | 172 request_url.host(), "CA", base::Time::Max(), base::Time::Max()); |
172 // This delegate doesn't create an interstitial. | 173 // This delegate doesn't create an interstitial. |
173 int options_mask = 0; | 174 int options_mask = 0; |
174 if (overridable) | 175 if (overridable) |
175 options_mask |= security_interstitials::SSLErrorUI::SOFT_OVERRIDE_ENABLED; | 176 options_mask |= security_interstitials::SSLErrorUI::SOFT_OVERRIDE_ENABLED; |
176 if (strict_enforcement) | 177 if (strict_enforcement) |
177 options_mask |= security_interstitials::SSLErrorUI::STRICT_ENFORCEMENT; | 178 options_mask |= security_interstitials::SSLErrorUI::STRICT_ENFORCEMENT; |
178 return new BadClockBlockingPage(web_contents, cert_error, ssl_info, | 179 return new BadClockBlockingPage(web_contents, cert_error, ssl_info, |
179 request_url, time_triggered_, nullptr, | 180 request_url, base::Time::Now(), clock_state, |
180 base::Callback<void(bool)>()); | 181 nullptr, base::Callback<void(bool)>()); |
181 } | 182 } |
182 | 183 |
183 safe_browsing::SafeBrowsingBlockingPage* CreateSafeBrowsingBlockingPage( | 184 safe_browsing::SafeBrowsingBlockingPage* CreateSafeBrowsingBlockingPage( |
184 content::WebContents* web_contents) { | 185 content::WebContents* web_contents) { |
185 safe_browsing::SBThreatType threat_type = | 186 safe_browsing::SBThreatType threat_type = |
186 safe_browsing::SB_THREAT_TYPE_URL_MALWARE; | 187 safe_browsing::SB_THREAT_TYPE_URL_MALWARE; |
187 GURL request_url("http://example.com"); | 188 GURL request_url("http://example.com"); |
188 std::string url_param; | 189 std::string url_param; |
189 if (net::GetValueForKeyInQuery(web_contents->GetURL(), | 190 if (net::GetValueForKeyInQuery(web_contents->GetURL(), |
190 "url", | 191 "url", |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 html = interstitial_delegate.get()->GetHTMLContents(); | 339 html = interstitial_delegate.get()->GetHTMLContents(); |
339 } else { | 340 } else { |
340 html = ResourceBundle::GetSharedInstance() | 341 html = ResourceBundle::GetSharedInstance() |
341 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_UI_HTML) | 342 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_UI_HTML) |
342 .as_string(); | 343 .as_string(); |
343 } | 344 } |
344 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString; | 345 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString; |
345 html_bytes->data().assign(html.begin(), html.end()); | 346 html_bytes->data().assign(html.begin(), html.end()); |
346 callback.Run(html_bytes.get()); | 347 callback.Run(html_bytes.get()); |
347 } | 348 } |
OLD | NEW |