Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: chrome/browser/ui/webui/interstitials/interstitial_ui.cc

Issue 940543003: added clock interstitial to chrome://interstitials (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added clock interstitial to chrome://interstitials Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ssl/ssl_error_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" 10 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 content::WebContents* web_contents_; 44 content::WebContents* web_contents_;
45 DISALLOW_COPY_AND_ASSIGN(InterstitialHTMLSource); 45 DISALLOW_COPY_AND_ASSIGN(InterstitialHTMLSource);
46 }; 46 };
47 47
48 SSLBlockingPage* CreateSSLBlockingPage(content::WebContents* web_contents) { 48 SSLBlockingPage* CreateSSLBlockingPage(content::WebContents* web_contents) {
49 // Random parameters for SSL blocking page. 49 // Random parameters for SSL blocking page.
50 int cert_error = net::ERR_CERT_CONTAINS_ERRORS; 50 int cert_error = net::ERR_CERT_CONTAINS_ERRORS;
51 GURL request_url("https://example.com"); 51 GURL request_url("https://example.com");
52 bool overridable = false; 52 bool overridable = false;
53 bool strict_enforcement = false; 53 bool strict_enforcement = false;
54 base::Time time_triggered_ = base::Time::NowFromSystemTime();
55
54 std::string url_param; 56 std::string url_param;
55 if (net::GetValueForKeyInQuery(web_contents->GetURL(), 57 if (net::GetValueForKeyInQuery(web_contents->GetURL(),
56 "url", 58 "url",
57 &url_param)) { 59 &url_param)) {
58 if (GURL(url_param).is_valid()) 60 if (GURL(url_param).is_valid())
59 request_url = GURL(url_param); 61 request_url = GURL(url_param);
60 } 62 }
61 std::string overridable_param; 63 std::string overridable_param;
62 if (net::GetValueForKeyInQuery(web_contents->GetURL(), 64 if (net::GetValueForKeyInQuery(web_contents->GetURL(),
63 "overridable", 65 "overridable",
64 &overridable_param)) { 66 &overridable_param)) {
65 overridable = overridable_param == "1"; 67 overridable = overridable_param == "1";
66 } 68 }
67 std::string strict_enforcement_param; 69 std::string strict_enforcement_param;
68 if (net::GetValueForKeyInQuery(web_contents->GetURL(), 70 if (net::GetValueForKeyInQuery(web_contents->GetURL(),
69 "strict_enforcement", 71 "strict_enforcement",
70 &strict_enforcement_param)) { 72 &strict_enforcement_param)) {
71 strict_enforcement = strict_enforcement_param == "1"; 73 strict_enforcement = strict_enforcement_param == "1";
72 } 74 }
75
76 std::string clock_manipulation_param;
77 if (net::GetValueForKeyInQuery(web_contents->GetURL(), "clock_manipulation",
78 &clock_manipulation_param) == 1) {
79 cert_error = net::ERR_CERT_DATE_INVALID;
80 time_triggered_ +=
81 base::TimeDelta::FromDays(365 * atoi(clock_manipulation_param.c_str()));
Bernhard Bauer 2015/02/25 16:41:08 There is base::StringToInt (from base/strings/stri
fahl 2015/02/26 04:52:41 Done.
82 }
83
73 net::SSLInfo ssl_info; 84 net::SSLInfo ssl_info;
74 ssl_info.cert = new net::X509Certificate( 85 ssl_info.cert = new net::X509Certificate(
75 request_url.host(), "CA", base::Time::Max(), base::Time::Max()); 86 request_url.host(), "CA", base::Time::Max(), base::Time::Max());
76 // This delegate doesn't create an interstitial. 87 // This delegate doesn't create an interstitial.
77 int options_mask = 0; 88 int options_mask = 0;
78 if (overridable) 89 if (overridable)
79 options_mask |= SSLBlockingPage::OVERRIDABLE; 90 options_mask |= SSLBlockingPage::OVERRIDABLE;
80 if (strict_enforcement) 91 if (strict_enforcement)
81 options_mask |= SSLBlockingPage::STRICT_ENFORCEMENT; 92 options_mask |= SSLBlockingPage::STRICT_ENFORCEMENT;
82 return new SSLBlockingPage(web_contents, 93 return new SSLBlockingPage(web_contents, cert_error, ssl_info, request_url,
83 cert_error, 94 options_mask, base::Callback<void(bool)>(),
84 ssl_info, 95 time_triggered_);
85 request_url,
86 options_mask,
87 base::Callback<void(bool)>());
88 } 96 }
89 97
90 SafeBrowsingBlockingPage* CreateSafeBrowsingBlockingPage( 98 SafeBrowsingBlockingPage* CreateSafeBrowsingBlockingPage(
91 content::WebContents* web_contents) { 99 content::WebContents* web_contents) {
92 SBThreatType threat_type = SB_THREAT_TYPE_URL_MALWARE; 100 SBThreatType threat_type = SB_THREAT_TYPE_URL_MALWARE;
93 GURL request_url("http://example.com"); 101 GURL request_url("http://example.com");
94 std::string url_param; 102 std::string url_param;
95 if (net::GetValueForKeyInQuery(web_contents->GetURL(), 103 if (net::GetValueForKeyInQuery(web_contents->GetURL(),
96 "url", 104 "url",
97 &url_param)) { 105 &url_param)) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 if (StartsWithASCII(path, "ssl", true)) { 186 if (StartsWithASCII(path, "ssl", true)) {
179 interstitial_delegate.reset(CreateSSLBlockingPage(web_contents_)); 187 interstitial_delegate.reset(CreateSSLBlockingPage(web_contents_));
180 } else if (StartsWithASCII(path, "safebrowsing", true)) { 188 } else if (StartsWithASCII(path, "safebrowsing", true)) {
181 interstitial_delegate.reset(CreateSafeBrowsingBlockingPage(web_contents_)); 189 interstitial_delegate.reset(CreateSafeBrowsingBlockingPage(web_contents_));
182 } 190 }
183 191
184 std::string html; 192 std::string html;
185 if (interstitial_delegate.get()) { 193 if (interstitial_delegate.get()) {
186 html = interstitial_delegate.get()->GetHTMLContents(); 194 html = interstitial_delegate.get()->GetHTMLContents();
187 } else { 195 } else {
188 html = "<html><head><title>Interstitials</title></head>" 196 html = "<html><head><title>Interstitials</title></head>"
Bernhard Bauer 2015/02/25 16:41:08 Would it make sense to put this into chrome/browse
fahl 2015/02/26 03:00:26 I think that probably makes sense. What's felt's a
felt 2015/02/26 03:14:00 Sounds fine to me.
fahl 2015/02/26 04:52:41 Done.
189 "<body><h2>Choose an interstitial<h2>" 197 "<body><h2>Choose an interstitial<h2>"
190 "<h3>SSL</h3>" 198 "<h3>SSL</h3>"
191 "<a href='ssl'>example.com</a><br>" 199 "<a href='ssl'>example.com</a><br>"
192 "<a href='ssl?url=https://google.com'>SSL (google.com)</a><br>" 200 "<a href='ssl?url=https://google.com'>SSL (google.com)</a><br>"
193 "<a href='ssl?overridable=1&strict_enforcement=0'>" 201 "<a href='ssl?overridable=1&strict_enforcement=0'>"
194 " example.com (Overridable)</a>" 202 " example.com (Overridable)</a><br>"
195 "<br><br>" 203 "<a href='ssl?clock_manipulation=1'>Clock is ahead</a><br>"
196 "<h3>SafeBrowsing</h3>" 204 "<a href='ssl?clock_manipulation=-1'>Clock is behind</a><br>"
197 "<a href='safebrowsing?type=malware'>Malware</a><br>" 205 "<br><br>"
198 "<a href='safebrowsing?type=phishing'>Phishing</a><br>" 206 "<h3>SafeBrowsing</h3>"
199 "<a href='safebrowsing?type=clientside_malware'>" 207 "<a href='safebrowsing?type=malware'>Malware</a><br>"
200 " Client Side Malware</a><br>" 208 "<a href='safebrowsing?type=phishing'>Phishing</a><br>"
201 "<a href='safebrowsing?type=clientside_phishing'>" 209 "<a href='safebrowsing?type=clientside_malware'>"
202 " Client Side Phishing</a><br>" 210 " Client Side Malware</a><br>"
203 "</body></html>"; 211 "<a href='safebrowsing?type=clientside_phishing'>"
212 " Client Side Phishing</a><br>"
213 "</body></html>";
204 } 214 }
205 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString; 215 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString;
206 html_bytes->data().assign(html.begin(), html.end()); 216 html_bytes->data().assign(html.begin(), html.end());
207 callback.Run(html_bytes.get()); 217 callback.Run(html_bytes.get());
208 } 218 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_error_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698