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

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

Issue 2405013002: Move some global feature defines to buildflags (Closed)
Patch Set: Comment Created 4 years, 2 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/ui/tab_helpers.cc ('k') | chrome/browser/ui/webui/plugins/plugins_handler.cc » ('j') | 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/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.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 "base/time/time.h" 10 #include "base/time/time.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" 13 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
14 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 14 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
15 #include "chrome/browser/safe_browsing/ui_manager.h" 15 #include "chrome/browser/safe_browsing/ui_manager.h"
16 #include "chrome/browser/ssl/bad_clock_blocking_page.h" 16 #include "chrome/browser/ssl/bad_clock_blocking_page.h"
17 #include "chrome/browser/ssl/ssl_blocking_page.h" 17 #include "chrome/browser/ssl/ssl_blocking_page.h"
18 #include "chrome/common/features.h"
18 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
19 #include "components/grit/components_resources.h" 20 #include "components/grit/components_resources.h"
20 #include "components/security_interstitials/core/ssl_error_ui.h" 21 #include "components/security_interstitials/core/ssl_error_ui.h"
21 #include "content/public/browser/interstitial_page_delegate.h" 22 #include "content/public/browser/interstitial_page_delegate.h"
22 #include "content/public/browser/render_frame_host.h" 23 #include "content/public/browser/render_frame_host.h"
23 #include "content/public/browser/render_process_host.h" 24 #include "content/public/browser/render_process_host.h"
24 #include "content/public/browser/url_data_source.h" 25 #include "content/public/browser/url_data_source.h"
25 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
26 #include "content/public/browser/web_ui.h" 27 #include "content/public/browser/web_ui.h"
27 #include "content/public/browser/web_ui_data_source.h" 28 #include "content/public/browser/web_ui_data_source.h"
28 #include "crypto/rsa_private_key.h" 29 #include "crypto/rsa_private_key.h"
29 #include "net/base/net_errors.h" 30 #include "net/base/net_errors.h"
30 #include "net/base/url_util.h" 31 #include "net/base/url_util.h"
31 #include "net/cert/x509_certificate.h" 32 #include "net/cert/x509_certificate.h"
32 #include "net/cert/x509_util.h" 33 #include "net/cert/x509_util.h"
33 #include "net/ssl/ssl_info.h" 34 #include "net/ssl/ssl_info.h"
34 #include "ui/base/resource/resource_bundle.h" 35 #include "ui/base/resource/resource_bundle.h"
35 36
36 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 37 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION)
37 #include "chrome/browser/ssl/captive_portal_blocking_page.h" 38 #include "chrome/browser/ssl/captive_portal_blocking_page.h"
38 #endif 39 #endif
39 40
40 namespace { 41 namespace {
41 42
42 // NSS requires that serial numbers be unique even for the same issuer; 43 // NSS requires that serial numbers be unique even for the same issuer;
43 // as all fake certificates will contain the same issuer name, it's 44 // as all fake certificates will contain the same issuer name, it's
44 // necessary to ensure the serial number is unique, as otherwise 45 // necessary to ensure the serial number is unique, as otherwise
45 // NSS will fail to parse. 46 // NSS will fail to parse.
46 base::StaticAtomicSequenceNumber g_serial_number; 47 base::StaticAtomicSequenceNumber g_serial_number;
(...skipping 29 matching lines...) Expand all
76 void StartDataRequest( 77 void StartDataRequest(
77 const std::string& path, 78 const std::string& path,
78 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, 79 const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
79 const content::URLDataSource::GotDataCallback& callback) override; 80 const content::URLDataSource::GotDataCallback& callback) override;
80 81
81 private: 82 private:
82 content::WebContents* web_contents_; 83 content::WebContents* web_contents_;
83 DISALLOW_COPY_AND_ASSIGN(InterstitialHTMLSource); 84 DISALLOW_COPY_AND_ASSIGN(InterstitialHTMLSource);
84 }; 85 };
85 86
86 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 87 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION)
87 // Provides fake connection information to the captive portal blocking page so 88 // Provides fake connection information to the captive portal blocking page so
88 // that both Wi-Fi and non Wi-Fi blocking pages can be displayed. 89 // that both Wi-Fi and non Wi-Fi blocking pages can be displayed.
89 class CaptivePortalBlockingPageWithNetInfo : public CaptivePortalBlockingPage { 90 class CaptivePortalBlockingPageWithNetInfo : public CaptivePortalBlockingPage {
90 public: 91 public:
91 CaptivePortalBlockingPageWithNetInfo( 92 CaptivePortalBlockingPageWithNetInfo(
92 content::WebContents* web_contents, 93 content::WebContents* web_contents,
93 const GURL& request_url, 94 const GURL& request_url,
94 const GURL& login_url, 95 const GURL& login_url,
95 const net::SSLInfo& ssl_info, 96 const net::SSLInfo& ssl_info,
96 const base::Callback<void(content::CertificateRequestResultType)>& 97 const base::Callback<void(content::CertificateRequestResultType)>&
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // SB_THREAT_TYPE_URL_UNWANTED on main-frame loads) would expect there to be a 254 // SB_THREAT_TYPE_URL_UNWANTED on main-frame loads) would expect there to be a
254 // pending navigation when the SafeBrowsingBlockingPage is created. This demo 255 // pending navigation when the SafeBrowsingBlockingPage is created. This demo
255 // creates a SafeBrowsingBlockingPage but does not actually show a real 256 // creates a SafeBrowsingBlockingPage but does not actually show a real
256 // interstitial. Instead it extracts the html and displays it manually, so the 257 // interstitial. Instead it extracts the html and displays it manually, so the
257 // parts which depend on the NavigationEntry are not hit. 258 // parts which depend on the NavigationEntry are not hit.
258 return safe_browsing::SafeBrowsingBlockingPage::CreateBlockingPage( 259 return safe_browsing::SafeBrowsingBlockingPage::CreateBlockingPage(
259 g_browser_process->safe_browsing_service()->ui_manager().get(), 260 g_browser_process->safe_browsing_service()->ui_manager().get(),
260 web_contents, main_frame_url, resource); 261 web_contents, main_frame_url, resource);
261 } 262 }
262 263
263 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 264 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION)
264 CaptivePortalBlockingPage* CreateCaptivePortalBlockingPage( 265 CaptivePortalBlockingPage* CreateCaptivePortalBlockingPage(
265 content::WebContents* web_contents) { 266 content::WebContents* web_contents) {
266 bool is_wifi_connection = false; 267 bool is_wifi_connection = false;
267 GURL landing_url("https://captive.portal/login"); 268 GURL landing_url("https://captive.portal/login");
268 GURL request_url("https://google.com"); 269 GURL request_url("https://google.com");
269 // Not initialized to a default value, since non-empty wifi_ssid is 270 // Not initialized to a default value, since non-empty wifi_ssid is
270 // considered a wifi connection, even if is_wifi_connection is false. 271 // considered a wifi connection, even if is_wifi_connection is false.
271 std::string wifi_ssid; 272 std::string wifi_ssid;
272 273
273 std::string request_url_param; 274 std::string request_url_param;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 const content::URLDataSource::GotDataCallback& callback) { 355 const content::URLDataSource::GotDataCallback& callback) {
355 std::unique_ptr<content::InterstitialPageDelegate> interstitial_delegate; 356 std::unique_ptr<content::InterstitialPageDelegate> interstitial_delegate;
356 if (base::StartsWith(path, "ssl", base::CompareCase::SENSITIVE)) { 357 if (base::StartsWith(path, "ssl", base::CompareCase::SENSITIVE)) {
357 interstitial_delegate.reset(CreateSSLBlockingPage(web_contents_)); 358 interstitial_delegate.reset(CreateSSLBlockingPage(web_contents_));
358 } else if (base::StartsWith(path, "safebrowsing", 359 } else if (base::StartsWith(path, "safebrowsing",
359 base::CompareCase::SENSITIVE)) { 360 base::CompareCase::SENSITIVE)) {
360 interstitial_delegate.reset(CreateSafeBrowsingBlockingPage(web_contents_)); 361 interstitial_delegate.reset(CreateSafeBrowsingBlockingPage(web_contents_));
361 } else if (base::StartsWith(path, "clock", base::CompareCase::SENSITIVE)) { 362 } else if (base::StartsWith(path, "clock", base::CompareCase::SENSITIVE)) {
362 interstitial_delegate.reset(CreateBadClockBlockingPage(web_contents_)); 363 interstitial_delegate.reset(CreateBadClockBlockingPage(web_contents_));
363 } 364 }
364 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 365 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION)
365 else if (base::StartsWith(path, "captiveportal", 366 else if (base::StartsWith(path, "captiveportal",
366 base::CompareCase::SENSITIVE)) 367 base::CompareCase::SENSITIVE))
367 { 368 {
368 interstitial_delegate.reset(CreateCaptivePortalBlockingPage(web_contents_)); 369 interstitial_delegate.reset(CreateCaptivePortalBlockingPage(web_contents_));
369 } 370 }
370 #endif 371 #endif
371 std::string html; 372 std::string html;
372 if (interstitial_delegate.get()) { 373 if (interstitial_delegate.get()) {
373 html = interstitial_delegate.get()->GetHTMLContents(); 374 html = interstitial_delegate.get()->GetHTMLContents();
374 } else { 375 } else {
375 html = ResourceBundle::GetSharedInstance() 376 html = ResourceBundle::GetSharedInstance()
376 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_UI_HTML) 377 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_UI_HTML)
377 .as_string(); 378 .as_string();
378 } 379 }
379 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString; 380 scoped_refptr<base::RefCountedString> html_bytes = new base::RefCountedString;
380 html_bytes->data().assign(html.begin(), html.end()); 381 html_bytes->data().assign(html.begin(), html.end());
381 callback.Run(html_bytes.get()); 382 callback.Run(html_bytes.get());
382 } 383 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tab_helpers.cc ('k') | chrome/browser/ui/webui/plugins/plugins_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698