| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_handle_impl.h" | 5 #include "content/browser/frame_host/navigation_handle_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" |
| 7 #include "content/browser/frame_host/frame_tree_node.h" | 8 #include "content/browser/frame_host/frame_tree_node.h" |
| 8 #include "content/browser/frame_host/navigator.h" | 9 #include "content/browser/frame_host/navigator.h" |
| 9 #include "content/browser/frame_host/navigator_delegate.h" | 10 #include "content/browser/frame_host/navigator_delegate.h" |
| 11 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 12 #include "content/browser/service_worker/service_worker_navigation_handle.h" |
| 13 #include "content/public/browser/browser_context.h" |
| 10 #include "content/public/browser/content_browser_client.h" | 14 #include "content/public/browser/content_browser_client.h" |
| 15 #include "content/public/browser/storage_partition.h" |
| 11 #include "content/public/common/content_client.h" | 16 #include "content/public/common/content_client.h" |
| 17 #include "content/public/common/content_switches.h" |
| 12 #include "net/url_request/redirect_info.h" | 18 #include "net/url_request/redirect_info.h" |
| 19 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
| 13 | 20 |
| 14 namespace content { | 21 namespace content { |
| 15 | 22 |
| 16 namespace { | 23 namespace { |
| 17 | 24 |
| 18 void UpdateThrottleCheckResult( | 25 void UpdateThrottleCheckResult( |
| 19 NavigationThrottle::ThrottleCheckResult* to_update, | 26 NavigationThrottle::ThrottleCheckResult* to_update, |
| 20 NavigationThrottle::ThrottleCheckResult result) { | 27 NavigationThrottle::ThrottleCheckResult result) { |
| 21 *to_update = result; | 28 *to_update = result; |
| 22 } | 29 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 38 has_user_gesture_(false), | 45 has_user_gesture_(false), |
| 39 transition_(ui::PAGE_TRANSITION_LINK), | 46 transition_(ui::PAGE_TRANSITION_LINK), |
| 40 is_external_protocol_(false), | 47 is_external_protocol_(false), |
| 41 net_error_code_(net::OK), | 48 net_error_code_(net::OK), |
| 42 render_frame_host_(nullptr), | 49 render_frame_host_(nullptr), |
| 43 is_same_page_(false), | 50 is_same_page_(false), |
| 44 state_(INITIAL), | 51 state_(INITIAL), |
| 45 is_transferring_(false), | 52 is_transferring_(false), |
| 46 frame_tree_node_(frame_tree_node), | 53 frame_tree_node_(frame_tree_node), |
| 47 next_index_(0) { | 54 next_index_(0) { |
| 55 // PlzNavigate |
| 56 // Initialize the ServiceWorkerNavigationHandle if it can be created for this |
| 57 // frame. |
| 58 bool can_create_service_worker = |
| 59 (frame_tree_node_->current_replication_state().sandbox_flags & |
| 60 blink::WebSandboxFlags::Origin) != blink::WebSandboxFlags::Origin; |
| 61 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 62 switches::kEnableBrowserSideNavigation) && |
| 63 can_create_service_worker) { |
| 64 BrowserContext* browser_context = |
| 65 frame_tree_node_->navigator()->GetController()->GetBrowserContext(); |
| 66 // TODO(clamy): Picking the partition based on the URL is incorrect. |
| 67 // See crbug.com/513539 |
| 68 StoragePartition* partition = |
| 69 BrowserContext::GetStoragePartitionForSite(browser_context, url_); |
| 70 DCHECK(partition); |
| 71 ServiceWorkerContextWrapper* service_worker_context = |
| 72 static_cast<ServiceWorkerContextWrapper*>( |
| 73 partition->GetServiceWorkerContext()); |
| 74 service_worker_handle_.reset( |
| 75 new ServiceWorkerNavigationHandle(service_worker_context)); |
| 76 } |
| 77 |
| 48 GetDelegate()->DidStartNavigation(this); | 78 GetDelegate()->DidStartNavigation(this); |
| 49 } | 79 } |
| 50 | 80 |
| 51 NavigationHandleImpl::~NavigationHandleImpl() { | 81 NavigationHandleImpl::~NavigationHandleImpl() { |
| 52 GetDelegate()->DidFinishNavigation(this); | 82 GetDelegate()->DidFinishNavigation(this); |
| 53 } | 83 } |
| 54 | 84 |
| 55 NavigatorDelegate* NavigationHandleImpl::GetDelegate() const { | 85 NavigatorDelegate* NavigationHandleImpl::GetDelegate() const { |
| 56 return frame_tree_node_->navigator()->GetDelegate(); | 86 return frame_tree_node_->navigator()->GetDelegate(); |
| 57 } | 87 } |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 default: | 336 default: |
| 307 NOTREACHED(); | 337 NOTREACHED(); |
| 308 } | 338 } |
| 309 } | 339 } |
| 310 next_index_ = 0; | 340 next_index_ = 0; |
| 311 state_ = WILL_REDIRECT_REQUEST; | 341 state_ = WILL_REDIRECT_REQUEST; |
| 312 return NavigationThrottle::PROCEED; | 342 return NavigationThrottle::PROCEED; |
| 313 } | 343 } |
| 314 | 344 |
| 315 } // namespace content | 345 } // namespace content |
| OLD | NEW |