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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 2603823002: Prohibit web payments on sites with bad SSL certificates (Closed)
Patch Set: Created 3 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <utility> 10 #include <utility>
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 #include "content/public/browser/storage_partition.h" 113 #include "content/public/browser/storage_partition.h"
114 #include "content/public/browser/user_metrics.h" 114 #include "content/public/browser/user_metrics.h"
115 #include "content/public/browser/web_contents_binding_set.h" 115 #include "content/public/browser/web_contents_binding_set.h"
116 #include "content/public/browser/web_contents_delegate.h" 116 #include "content/public/browser/web_contents_delegate.h"
117 #include "content/public/browser/web_contents_unresponsive_state.h" 117 #include "content/public/browser/web_contents_unresponsive_state.h"
118 #include "content/public/common/bindings_policy.h" 118 #include "content/public/common/bindings_policy.h"
119 #include "content/public/common/browser_side_navigation_policy.h" 119 #include "content/public/common/browser_side_navigation_policy.h"
120 #include "content/public/common/child_process_host.h" 120 #include "content/public/common/child_process_host.h"
121 #include "content/public/common/content_constants.h" 121 #include "content/public/common/content_constants.h"
122 #include "content/public/common/content_switches.h" 122 #include "content/public/common/content_switches.h"
123 #include "content/public/common/origin_util.h"
123 #include "content/public/common/page_zoom.h" 124 #include "content/public/common/page_zoom.h"
124 #include "content/public/common/result_codes.h" 125 #include "content/public/common/result_codes.h"
125 #include "content/public/common/url_utils.h" 126 #include "content/public/common/url_utils.h"
126 #include "content/public/common/web_preferences.h" 127 #include "content/public/common/web_preferences.h"
127 #include "device/geolocation/geolocation_service_context.h" 128 #include "device/geolocation/geolocation_service_context.h"
128 #include "device/nfc/nfc.mojom.h" 129 #include "device/nfc/nfc.mojom.h"
129 #include "device/wake_lock/wake_lock_service_context.h" 130 #include "device/wake_lock/wake_lock_service_context.h"
130 #include "net/base/url_util.h" 131 #include "net/base/url_util.h"
131 #include "net/http/http_cache.h" 132 #include "net/http/http_cache.h"
132 #include "net/http/http_transaction_factory.h" 133 #include "net/http/http_transaction_factory.h"
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 NavigationEntry* entry = controller_.GetVisibleEntry(); 812 NavigationEntry* entry = controller_.GetVisibleEntry();
812 return entry ? entry->GetVirtualURL() : GURL::EmptyGURL(); 813 return entry ? entry->GetVirtualURL() : GURL::EmptyGURL();
813 } 814 }
814 815
815 const GURL& WebContentsImpl::GetLastCommittedURL() const { 816 const GURL& WebContentsImpl::GetLastCommittedURL() const {
816 // We may not have a navigation entry yet. 817 // We may not have a navigation entry yet.
817 NavigationEntry* entry = controller_.GetLastCommittedEntry(); 818 NavigationEntry* entry = controller_.GetLastCommittedEntry();
818 return entry ? entry->GetVirtualURL() : GURL::EmptyGURL(); 819 return entry ? entry->GetVirtualURL() : GURL::EmptyGURL();
819 } 820 }
820 821
822 bool WebContentsImpl::IsContextSecure() const {
823 NavigationEntry* navigation_entry = controller_.GetLastCommittedEntry();
824 if (!navigation_entry)
825 return false;
826
827 if (!IsOriginSecure(navigation_entry->GetURL()))
828 return false;
829
830 if (!navigation_entry->GetURL().SchemeIsCryptographic())
831 return true;
palmer 2017/01/05 22:55:06 Why return true if the scheme is *not* cryptograph
lgarron 2017/01/05 23:00:20 I was about to comment the same. In general, is t
please use gerrit instead 2017/01/06 18:07:15 I would love to have a single IsOriginSecure() fun
please use gerrit instead 2017/01/06 18:07:15 To prevent checking SSL status of localhost and fi
lgarron 2017/01/06 23:21:25 IsOriginSecure() can't have SSL validity checks be
832
833 SSLStatus ssl_status = navigation_entry->GetSSL();
834 return ssl_status.certificate &&
835 (!net::IsCertStatusError(ssl_status.cert_status) ||
836 net::IsCertStatusMinorError(ssl_status.cert_status)) &&
837 !(ssl_status.content_status & SSLStatus::RAN_INSECURE_CONTENT);
lgarron 2017/01/05 23:00:20 This looks like an ad-hoc implementation of someth
please use gerrit instead 2017/01/06 18:07:15 I also don't like this ad-hoc thing and would like
lgarron 2017/01/06 23:21:25 Interesting. Do you know how these decisions were
838 }
839
821 WebContentsDelegate* WebContentsImpl::GetDelegate() { 840 WebContentsDelegate* WebContentsImpl::GetDelegate() {
822 return delegate_; 841 return delegate_;
823 } 842 }
824 843
825 void WebContentsImpl::SetDelegate(WebContentsDelegate* delegate) { 844 void WebContentsImpl::SetDelegate(WebContentsDelegate* delegate) {
826 // TODO(cbentzel): remove this debugging code? 845 // TODO(cbentzel): remove this debugging code?
827 if (delegate == delegate_) 846 if (delegate == delegate_)
828 return; 847 return;
829 if (delegate_) 848 if (delegate_)
830 delegate_->Detach(this); 849 delegate_->Detach(this);
(...skipping 2315 matching lines...) Expand 10 before | Expand all | Expand 10 after
3146 } 3165 }
3147 3166
3148 int WebContentsImpl::DownloadImage( 3167 int WebContentsImpl::DownloadImage(
3149 const GURL& url, 3168 const GURL& url,
3150 bool is_favicon, 3169 bool is_favicon,
3151 uint32_t max_bitmap_size, 3170 uint32_t max_bitmap_size,
3152 bool bypass_cache, 3171 bool bypass_cache,
3153 const WebContents::ImageDownloadCallback& callback) { 3172 const WebContents::ImageDownloadCallback& callback) {
3154 DCHECK_CURRENTLY_ON(BrowserThread::UI); 3173 DCHECK_CURRENTLY_ON(BrowserThread::UI);
3155 static int next_image_download_id = 0; 3174 static int next_image_download_id = 0;
3156 const content::mojom::ImageDownloaderPtr& mojo_image_downloader = 3175 const mojom::ImageDownloaderPtr& mojo_image_downloader =
3157 GetMainFrame()->GetMojoImageDownloader(); 3176 GetMainFrame()->GetMojoImageDownloader();
3158 const int download_id = ++next_image_download_id; 3177 const int download_id = ++next_image_download_id;
3159 if (!mojo_image_downloader) { 3178 if (!mojo_image_downloader) {
3160 // If the renderer process is dead (i.e. crash, or memory pressure on 3179 // If the renderer process is dead (i.e. crash, or memory pressure on
3161 // Android), the downloader service will be invalid. Pre-Mojo, this would 3180 // Android), the downloader service will be invalid. Pre-Mojo, this would
3162 // hang the callback indefinetly since the IPC would be dropped. Now, 3181 // hang the callback indefinetly since the IPC would be dropped. Now,
3163 // respond with a 400 HTTP error code to indicate that something went wrong. 3182 // respond with a 400 HTTP error code to indicate that something went wrong.
3164 BrowserThread::PostTask( 3183 BrowserThread::PostTask(
3165 BrowserThread::UI, FROM_HERE, 3184 BrowserThread::UI, FROM_HERE,
3166 base::Bind(&WebContentsImpl::OnDidDownloadImage, 3185 base::Bind(&WebContentsImpl::OnDidDownloadImage,
(...skipping 2231 matching lines...) Expand 10 before | Expand all | Expand 10 after
5398 view->FocusedNodeTouched(location_dips_screen, editable); 5417 view->FocusedNodeTouched(location_dips_screen, editable);
5399 #endif 5418 #endif
5400 } 5419 }
5401 5420
5402 void WebContentsImpl::ShowInsecureLocalhostWarningIfNeeded() { 5421 void WebContentsImpl::ShowInsecureLocalhostWarningIfNeeded() {
5403 bool allow_localhost = base::CommandLine::ForCurrentProcess()->HasSwitch( 5422 bool allow_localhost = base::CommandLine::ForCurrentProcess()->HasSwitch(
5404 switches::kAllowInsecureLocalhost); 5423 switches::kAllowInsecureLocalhost);
5405 if (!allow_localhost) 5424 if (!allow_localhost)
5406 return; 5425 return;
5407 5426
5408 content::NavigationEntry* entry = GetController().GetLastCommittedEntry(); 5427 NavigationEntry* entry = GetController().GetLastCommittedEntry();
5409 if (!entry || !net::IsLocalhost(entry->GetURL().host())) 5428 if (!entry || !net::IsLocalhost(entry->GetURL().host()))
5410 return; 5429 return;
5411 5430
5412 content::SSLStatus ssl_status = entry->GetSSL(); 5431 SSLStatus ssl_status = entry->GetSSL();
5413 bool is_cert_error = net::IsCertStatusError(ssl_status.cert_status) && 5432 bool is_cert_error = net::IsCertStatusError(ssl_status.cert_status) &&
5414 !net::IsCertStatusMinorError(ssl_status.cert_status); 5433 !net::IsCertStatusMinorError(ssl_status.cert_status);
5415 if (!is_cert_error) 5434 if (!is_cert_error)
5416 return; 5435 return;
5417 5436
5418 GetMainFrame()->AddMessageToConsole( 5437 GetMainFrame()->AddMessageToConsole(
5419 content::CONSOLE_MESSAGE_LEVEL_WARNING, 5438 CONSOLE_MESSAGE_LEVEL_WARNING,
5420 base::StringPrintf("This site does not have a valid SSL " 5439 base::StringPrintf("This site does not have a valid SSL "
5421 "certificate! Without SSL, your site's and " 5440 "certificate! Without SSL, your site's and "
5422 "visitors' data is vulnerable to theft and " 5441 "visitors' data is vulnerable to theft and "
5423 "tampering. Get a valid SSL certificate before" 5442 "tampering. Get a valid SSL certificate before"
5424 " releasing your website to the public.")); 5443 " releasing your website to the public."));
5425 } 5444 }
5426 5445
5427 } // namespace content 5446 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698