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

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: 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
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
54 std::string url_param; 55 std::string url_param;
55 if (net::GetValueForKeyInQuery(web_contents->GetURL(), 56 if (net::GetValueForKeyInQuery(web_contents->GetURL(),
56 "url", 57 "url",
57 &url_param)) { 58 &url_param)) {
58 if (GURL(url_param).is_valid()) 59 if (GURL(url_param).is_valid())
59 request_url = GURL(url_param); 60 request_url = GURL(url_param);
60 } 61 }
61 std::string overridable_param; 62 std::string overridable_param;
62 if (net::GetValueForKeyInQuery(web_contents->GetURL(), 63 if (net::GetValueForKeyInQuery(web_contents->GetURL(),
63 "overridable", 64 "overridable",
64 &overridable_param)) { 65 &overridable_param)) {
65 overridable = overridable_param == "1"; 66 overridable = overridable_param == "1";
66 } 67 }
67 std::string strict_enforcement_param; 68 std::string strict_enforcement_param;
68 if (net::GetValueForKeyInQuery(web_contents->GetURL(), 69 if (net::GetValueForKeyInQuery(web_contents->GetURL(),
69 "strict_enforcement", 70 "strict_enforcement",
70 &strict_enforcement_param)) { 71 &strict_enforcement_param)) {
71 strict_enforcement = strict_enforcement_param == "1"; 72 strict_enforcement = strict_enforcement_param == "1";
72 } 73 }
74
75 std::string clock_error_param;
76 if (net::GetValueForKeyInQuery(web_contents->GetURL(),
77 "clock_error",
78 &clock_error_param) == 1) {
79 cert_error = net::ERR_CERT_DATE_INVALID;
80 }
81
73 net::SSLInfo ssl_info; 82 net::SSLInfo ssl_info;
74 ssl_info.cert = new net::X509Certificate( 83 ssl_info.cert = new net::X509Certificate(
75 request_url.host(), "CA", base::Time::Max(), base::Time::Max()); 84 request_url.host(), "CA", base::Time::Max(), base::Time::Max());
76 // This delegate doesn't create an interstitial. 85 // This delegate doesn't create an interstitial.
77 int options_mask = 0; 86 int options_mask = 0;
78 if (overridable) 87 if (overridable)
79 options_mask |= SSLBlockingPage::OVERRIDABLE; 88 options_mask |= SSLBlockingPage::OVERRIDABLE;
80 if (strict_enforcement) 89 if (strict_enforcement)
81 options_mask |= SSLBlockingPage::STRICT_ENFORCEMENT; 90 options_mask |= SSLBlockingPage::STRICT_ENFORCEMENT;
82 return new SSLBlockingPage(web_contents, 91 return new SSLBlockingPage(web_contents,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 130 }
122 SafeBrowsingBlockingPage::UnsafeResource resource; 131 SafeBrowsingBlockingPage::UnsafeResource resource;
123 resource.url = request_url; 132 resource.url = request_url;
124 resource.threat_type = threat_type; 133 resource.threat_type = threat_type;
125 // Create a blocking page without showing the interstitial. 134 // Create a blocking page without showing the interstitial.
126 return SafeBrowsingBlockingPage::CreateBlockingPage( 135 return SafeBrowsingBlockingPage::CreateBlockingPage(
127 g_browser_process->safe_browsing_service()->ui_manager().get(), 136 g_browser_process->safe_browsing_service()->ui_manager().get(),
128 web_contents, 137 web_contents,
129 resource); 138 resource);
130 } 139 }
131 140 } // namespace
132 } // namespace
133 141
134 InterstitialUI::InterstitialUI(content::WebUI* web_ui) 142 InterstitialUI::InterstitialUI(content::WebUI* web_ui)
135 : WebUIController(web_ui) { 143 : WebUIController(web_ui) {
136 Profile* profile = Profile::FromWebUI(web_ui); 144 Profile* profile = Profile::FromWebUI(web_ui);
137 scoped_ptr<InterstitialHTMLSource> html_source( 145 scoped_ptr<InterstitialHTMLSource> html_source(
138 new InterstitialHTMLSource(profile->GetOriginalProfile(), 146 new InterstitialHTMLSource(profile->GetOriginalProfile(),
139 web_ui->GetWebContents())); 147 web_ui->GetWebContents()));
140 content::URLDataSource::Add(profile, html_source.release()); 148 content::URLDataSource::Add(profile, html_source.release());
141 } 149 }
142 150
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
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>"
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>"
203 "<a href='ssl?clock_error=1&url=https://yourclockiswrong.com'>"
204 " yourclockiswrong.com</a><br>"
195 "<br><br>" 205 "<br><br>"
196 "<h3>SafeBrowsing</h3>" 206 "<h3>SafeBrowsing</h3>"
197 "<a href='safebrowsing?type=malware'>Malware</a><br>" 207 "<a href='safebrowsing?type=malware'>Malware</a><br>"
198 "<a href='safebrowsing?type=phishing'>Phishing</a><br>" 208 "<a href='safebrowsing?type=phishing'>Phishing</a><br>"
199 "<a href='safebrowsing?type=clientside_malware'>" 209 "<a href='safebrowsing?type=clientside_malware'>"
200 " Client Side Malware</a><br>" 210 " Client Side Malware</a><br>"
201 "<a href='safebrowsing?type=clientside_phishing'>" 211 "<a href='safebrowsing?type=clientside_phishing'>"
202 " Client Side Phishing</a><br>" 212 " Client Side Phishing</a><br>"
203 "</body></html>"; 213 "</body></html>";
204 } 214 }
215
205 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString; 216 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString;
206 html_bytes->data().assign(html.begin(), html.end()); 217 html_bytes->data().assign(html.begin(), html.end());
207 callback.Run(html_bytes.get()); 218 callback.Run(html_bytes.get());
208 } 219 }
OLDNEW
« chrome/browser/ssl/ssl_blocking_page.cc ('K') | « chrome/browser/ssl/ssl_blocking_page.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698