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

Side by Side Diff: content/common/navigation_params.cc

Issue 2760463005: Fix handling of external protocols with PlzNavigate. (Closed)
Patch Set: without PlzNavigate Created 3 years, 9 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 "content/common/navigation_params.h" 5 #include "content/common/navigation_params.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "content/common/service_worker/service_worker_types.h" 9 #include "content/common/service_worker/service_worker_types.h"
10 #include "content/public/common/appcache_info.h" 10 #include "content/public/common/appcache_info.h"
11 #include "content/public/common/browser_side_navigation_policy.h" 11 #include "content/public/common/browser_side_navigation_policy.h"
12 #include "content/public/common/url_constants.h" 12 #include "content/public/common/url_constants.h"
13 #include "url/gurl.h" 13 #include "url/gurl.h"
14 #include "url/url_constants.h" 14 #include "url/url_constants.h"
15 #include "url/url_util.h"
15 16
16 namespace content { 17 namespace content {
17 18
18 // PlzNavigate 19 // PlzNavigate
19 bool ShouldMakeNetworkRequestForURL(const GURL& url) { 20 bool ShouldMakeNetworkRequestForURL(const GURL& url) {
20 CHECK(IsBrowserSideNavigationEnabled()); 21 CHECK(IsBrowserSideNavigationEnabled());
21 22
22 // Javascript URLs, about:blank, srcdoc should not send a request 23 // Javascript URLs, srcdoc, schemes that don't load data should not send a
23 // to the network stack. 24 // request to the network stack.
24 return !url.IsAboutBlank() && !url.SchemeIs(url::kJavaScriptScheme) && 25 bool rv =
25 !url.is_empty() && !url.SchemeIs(url::kContentIDScheme) && 26 !url.SchemeIs(url::kJavaScriptScheme) &&
26 url != content::kAboutSrcDocURL; 27 !url.is_empty() && !url.SchemeIs(url::kContentIDScheme) &&
28 url != content::kAboutSrcDocURL;
29 if (rv) {
30 for (const auto& scheme : url::GetEmptyDocumentSchemes()) {
31 if (url.SchemeIs(scheme)) {
32 rv = false;
33 break;
dcheng 2017/03/23 21:07:15 Nit: maybe slightly shorter to just return false d
jam 2017/03/23 21:43:21 rewrote this to make it simpler
34 }
35 }
36 }
37 return rv;
27 } 38 }
28 39
29 SourceLocation::SourceLocation() : line_number(0), column_number(0) {} 40 SourceLocation::SourceLocation() : line_number(0), column_number(0) {}
30 41
31 SourceLocation::SourceLocation(const std::string& url, 42 SourceLocation::SourceLocation(const std::string& url,
32 unsigned int line_number, 43 unsigned int line_number,
33 unsigned int column_number) 44 unsigned int column_number)
34 : url(url), line_number(line_number), column_number(column_number) {} 45 : url(url), line_number(line_number), column_number(column_number) {}
35 46
36 SourceLocation::~SourceLocation() {} 47 SourceLocation::~SourceLocation() {}
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 const RequestNavigationParams& request_params) 223 const RequestNavigationParams& request_params)
213 : common_params(common_params), 224 : common_params(common_params),
214 start_params(start_params), 225 start_params(start_params),
215 request_params(request_params) { 226 request_params(request_params) {
216 } 227 }
217 228
218 NavigationParams::~NavigationParams() { 229 NavigationParams::~NavigationParams() {
219 } 230 }
220 231
221 } // namespace content 232 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698