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

Side by Side Diff: content/browser/frame_host/navigation_request.cc

Issue 2765213003: PlzNavigate: treat intent:// as external scheme (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | 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 "content/browser/frame_host/navigation_request.h" 5 #include "content/browser/frame_host/navigation_request.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "content/browser/appcache/appcache_navigation_handle.h" 10 #include "content/browser/appcache/appcache_navigation_handle.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 } else if ((frame_tree_node->effective_sandbox_flags() & 176 } else if ((frame_tree_node->effective_sandbox_flags() &
177 blink::WebSandboxFlags::Origin) == blink::WebSandboxFlags::None) { 177 blink::WebSandboxFlags::Origin) == blink::WebSandboxFlags::None) {
178 // The origin should be the origin of the root, except for sandboxed 178 // The origin should be the origin of the root, except for sandboxed
179 // frames which have a unique origin. 179 // frames which have a unique origin.
180 origin = frame_tree_node->frame_tree()->root()->current_origin(); 180 origin = frame_tree_node->frame_tree()->root()->current_origin();
181 } 181 }
182 182
183 headers->SetHeader(net::HttpRequestHeaders::kOrigin, origin.Serialize()); 183 headers->SetHeader(net::HttpRequestHeaders::kOrigin, origin.Serialize());
184 } 184 }
185 185
186 bool IsExternalProtocol(const std::string& scheme) {
187 // The following alternative rule also passes all tests, but checking for
188 // "intent://" is simpler.
189 // !ProfileIOData::IsHandledProtocol(scheme) &&
190 // !(scheme == "chrome-native")
191 const char kIntentScheme[] = "intent";
192 return base::LowerCaseEqualsASCII(scheme, kIntentScheme);
193 }
194
186 } // namespace 195 } // namespace
187 196
188 // static 197 // static
189 std::unique_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( 198 std::unique_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated(
190 FrameTreeNode* frame_tree_node, 199 FrameTreeNode* frame_tree_node,
191 const GURL& dest_url, 200 const GURL& dest_url,
192 const Referrer& dest_referrer, 201 const Referrer& dest_referrer,
193 const FrameNavigationEntry& frame_entry, 202 const FrameNavigationEntry& frame_entry,
194 const NavigationEntryImpl& entry, 203 const NavigationEntryImpl& entry,
195 FrameMsg_Navigate_Type::Value navigation_type, 204 FrameMsg_Navigate_Type::Value navigation_type,
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 void NavigationRequest::BeginNavigation() { 358 void NavigationRequest::BeginNavigation() {
350 DCHECK(!loader_); 359 DCHECK(!loader_);
351 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE); 360 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE);
352 state_ = STARTED; 361 state_ = STARTED;
353 RenderFrameDevToolsAgentHost::OnBeforeNavigation(navigation_handle_.get()); 362 RenderFrameDevToolsAgentHost::OnBeforeNavigation(navigation_handle_.get());
354 363
355 if (ShouldMakeNetworkRequestForURL(common_params_.url) && 364 if (ShouldMakeNetworkRequestForURL(common_params_.url) &&
356 !navigation_handle_->IsSameDocument()) { 365 !navigation_handle_->IsSameDocument()) {
357 // It's safe to use base::Unretained because this NavigationRequest owns 366 // It's safe to use base::Unretained because this NavigationRequest owns
358 // the NavigationHandle where the callback will be stored. 367 // the NavigationHandle where the callback will be stored.
359 // TODO(clamy): pass the real value for |is_external_protocol| if needed.
360 // TODO(clamy): pass the method to the NavigationHandle instead of a 368 // TODO(clamy): pass the method to the NavigationHandle instead of a
361 // boolean. 369 // boolean.
370 bool is_external_protocol = IsExternalProtocol(common_params_.url.scheme());
371
362 navigation_handle_->WillStartRequest( 372 navigation_handle_->WillStartRequest(
363 common_params_.method, common_params_.post_data, 373 common_params_.method, common_params_.post_data,
364 Referrer::SanitizeForRequest(common_params_.url, 374 Referrer::SanitizeForRequest(common_params_.url,
365 common_params_.referrer), 375 common_params_.referrer),
366 begin_params_.has_user_gesture, common_params_.transition, false, 376 begin_params_.has_user_gesture, common_params_.transition,
367 begin_params_.request_context_type, 377 is_external_protocol, begin_params_.request_context_type,
368 begin_params_.mixed_content_context_type, 378 begin_params_.mixed_content_context_type,
369 base::Bind(&NavigationRequest::OnStartChecksComplete, 379 base::Bind(&NavigationRequest::OnStartChecksComplete,
370 base::Unretained(this))); 380 base::Unretained(this)));
371 return; 381 return;
372 } 382 }
373 383
374 // There is no need to make a network request for this navigation, so commit 384 // There is no need to make a network request for this navigation, so commit
375 // it immediately. 385 // it immediately.
376 state_ = RESPONSE_STARTED; 386 state_ = RESPONSE_STARTED;
377 387
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 GURL url = common_params_.url; 468 GURL url = common_params_.url;
459 if (!browser_initiated_ && source_site_instance()) { 469 if (!browser_initiated_ && source_site_instance()) {
460 source_site_instance()->GetProcess()->FilterURL(false, &url); 470 source_site_instance()->GetProcess()->FilterURL(false, &url);
461 // FilterURL sets the URL to about:blank if the CSP checks prevent the 471 // FilterURL sets the URL to about:blank if the CSP checks prevent the
462 // renderer from accessing it. 472 // renderer from accessing it.
463 if ((url == url::kAboutBlankURL) && (url != common_params_.url)) { 473 if ((url == url::kAboutBlankURL) && (url != common_params_.url)) {
464 frame_tree_node_->ResetNavigationRequest(false); 474 frame_tree_node_->ResetNavigationRequest(false);
465 return; 475 return;
466 } 476 }
467 } 477 }
478 bool is_external_protocol = IsExternalProtocol(common_params_.url.scheme());
468 479
469 // It's safe to use base::Unretained because this NavigationRequest owns the 480 // It's safe to use base::Unretained because this NavigationRequest owns the
470 // NavigationHandle where the callback will be stored. 481 // NavigationHandle where the callback will be stored.
471 // TODO(clamy): pass the real value for |is_external_protocol| if needed.
472 navigation_handle_->WillRedirectRequest( 482 navigation_handle_->WillRedirectRequest(
473 common_params_.url, common_params_.method, common_params_.referrer.url, 483 common_params_.url, common_params_.method, common_params_.referrer.url,
474 false, response->head.headers, response->head.connection_info, 484 is_external_protocol, response->head.headers,
485 response->head.connection_info,
475 base::Bind(&NavigationRequest::OnRedirectChecksComplete, 486 base::Bind(&NavigationRequest::OnRedirectChecksComplete,
476 base::Unretained(this))); 487 base::Unretained(this)));
477 } 488 }
478 489
479 void NavigationRequest::OnResponseStarted( 490 void NavigationRequest::OnResponseStarted(
480 const scoped_refptr<ResourceResponse>& response, 491 const scoped_refptr<ResourceResponse>& response,
481 std::unique_ptr<StreamHandle> body, 492 std::unique_ptr<StreamHandle> body,
482 const SSLStatus& ssl_status, 493 const SSLStatus& ssl_status,
483 std::unique_ptr<NavigationData> navigation_data, 494 std::unique_ptr<NavigationData> navigation_data,
484 const GlobalRequestID& request_id, 495 const GlobalRequestID& request_id,
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); 822 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture);
812 823
813 render_frame_host->CommitNavigation(response_.get(), std::move(body_), 824 render_frame_host->CommitNavigation(response_.get(), std::move(body_),
814 common_params_, request_params_, 825 common_params_, request_params_,
815 is_view_source_); 826 is_view_source_);
816 827
817 frame_tree_node_->ResetNavigationRequest(true); 828 frame_tree_node_->ResetNavigationRequest(true);
818 } 829 }
819 830
820 } // namespace content 831 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698