Chromium Code Reviews| 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/navigator_delegate.h" | 8 #include "content/browser/frame_host/navigator_delegate.h" |
| 9 #include "content/browser/service_worker/service_worker_context_wrapper.h" | |
| 10 #include "content/public/browser/browser_context.h" | |
| 11 #include "content/public/browser/browser_thread.h" | |
| 8 #include "content/public/browser/content_browser_client.h" | 12 #include "content/public/browser/content_browser_client.h" |
| 13 #include "content/public/browser/storage_partition.h" | |
| 9 #include "content/public/common/content_client.h" | 14 #include "content/public/common/content_client.h" |
| 15 #include "content/public/common/content_switches.h" | |
| 10 #include "net/url_request/redirect_info.h" | 16 #include "net/url_request/redirect_info.h" |
| 11 | 17 |
| 12 namespace content { | 18 namespace content { |
| 13 | 19 |
| 14 // static | 20 // static |
| 15 scoped_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( | 21 scoped_ptr<NavigationHandleImpl> NavigationHandleImpl::Create( |
| 16 const GURL& url, | 22 const GURL& url, |
| 17 bool is_main_frame, | 23 bool is_main_frame, |
| 18 NavigatorDelegate* delegate) { | 24 NavigatorDelegate* delegate, |
| 19 return scoped_ptr<NavigationHandleImpl>( | 25 int service_worker_provider_id) { |
| 20 new NavigationHandleImpl(url, is_main_frame, delegate)); | 26 return scoped_ptr<NavigationHandleImpl>(new NavigationHandleImpl( |
| 27 url, is_main_frame, delegate, service_worker_provider_id)); | |
| 21 } | 28 } |
| 22 | 29 |
| 23 NavigationHandleImpl::NavigationHandleImpl(const GURL& url, | 30 |
| 24 const bool is_main_frame, | 31 NavigationHandleImpl::NavigationHandleImpl( |
| 25 NavigatorDelegate* delegate) | 32 const GURL& url, |
| 33 bool is_main_frame, | |
| 34 NavigatorDelegate* delegate, | |
| 35 int service_worker_provider_id) | |
| 26 : url_(url), | 36 : url_(url), |
| 27 is_main_frame_(is_main_frame), | 37 is_main_frame_(is_main_frame), |
| 28 is_post_(false), | 38 is_post_(false), |
| 29 has_user_gesture_(false), | 39 has_user_gesture_(false), |
| 30 transition_(ui::PAGE_TRANSITION_LINK), | 40 transition_(ui::PAGE_TRANSITION_LINK), |
| 31 is_external_protocol_(false), | 41 is_external_protocol_(false), |
| 32 net_error_code_(net::OK), | 42 net_error_code_(net::OK), |
| 33 render_frame_host_(nullptr), | 43 render_frame_host_(nullptr), |
| 34 is_same_page_(false), | 44 is_same_page_(false), |
| 35 state_(INITIAL), | 45 state_(INITIAL), |
| 36 is_transferring_(false), | 46 is_transferring_(false), |
| 37 delegate_(delegate) { | 47 delegate_(delegate), |
| 48 service_worker_provider_id_(service_worker_provider_id) { | |
| 49 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 50 switches::kEnableBrowserSideNavigation)) { | |
| 51 BrowserContext* browser_context = delegate_->GetBrowserContext(); | |
| 52 DCHECK(browser_context); | |
| 53 StoragePartition* partition = BrowserContext::GetStoragePartitionForSite( | |
|
michaeln
2015/10/01 01:42:15
picking the partition based on the url is actually
Fabrice (no longer in Chrome)
2015/10/01 18:29:54
Done.
| |
| 54 browser_context, url); | |
| 55 DCHECK(partition); | |
| 56 service_worker_context_ = scoped_refptr<ServiceWorkerContextWrapper>( | |
| 57 static_cast<ServiceWorkerContextWrapper*>( | |
| 58 partition->GetServiceWorkerContext())); | |
| 59 } | |
| 38 delegate_->DidStartNavigation(this); | 60 delegate_->DidStartNavigation(this); |
| 39 } | 61 } |
| 40 | 62 |
| 41 NavigationHandleImpl::~NavigationHandleImpl() { | 63 NavigationHandleImpl::~NavigationHandleImpl() { |
| 64 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 65 switches::kEnableBrowserSideNavigation)) { | |
| 66 // PlzNavigate | |
|
clamy
2015/10/01 12:41:26
nit: I would put this comment above the if conditi
Fabrice (no longer in Chrome)
2015/10/01 18:29:54
Done.
| |
| 67 // Post task to IO thread to destroy the Host. | |
| 68 BrowserThread::PostTask( | |
| 69 BrowserThread::IO, | |
| 70 FROM_HERE, | |
| 71 base::Bind(&ServiceWorkerContextWrapper::RemoveNavigationProviderHost, | |
| 72 service_worker_context_, | |
| 73 service_worker_provider_id_)); | |
| 74 } | |
| 42 delegate_->DidFinishNavigation(this); | 75 delegate_->DidFinishNavigation(this); |
| 43 } | 76 } |
| 44 | 77 |
| 45 const GURL& NavigationHandleImpl::GetURL() { | 78 const GURL& NavigationHandleImpl::GetURL() { |
| 46 return url_; | 79 return url_; |
| 47 } | 80 } |
| 48 | 81 |
| 49 bool NavigationHandleImpl::IsInMainFrame() { | 82 bool NavigationHandleImpl::IsInMainFrame() { |
| 50 return is_main_frame_; | 83 return is_main_frame_; |
| 51 } | 84 } |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 void NavigationHandleImpl::DidCommitNavigation( | 240 void NavigationHandleImpl::DidCommitNavigation( |
| 208 bool same_page, | 241 bool same_page, |
| 209 RenderFrameHostImpl* render_frame_host) { | 242 RenderFrameHostImpl* render_frame_host) { |
| 210 CHECK_IMPLIES(render_frame_host_, render_frame_host_ == render_frame_host); | 243 CHECK_IMPLIES(render_frame_host_, render_frame_host_ == render_frame_host); |
| 211 is_same_page_ = same_page; | 244 is_same_page_ = same_page; |
| 212 render_frame_host_ = render_frame_host; | 245 render_frame_host_ = render_frame_host; |
| 213 state_ = net_error_code_ == net::OK ? DID_COMMIT : DID_COMMIT_ERROR_PAGE; | 246 state_ = net_error_code_ == net::OK ? DID_COMMIT : DID_COMMIT_ERROR_PAGE; |
| 214 } | 247 } |
| 215 | 248 |
| 216 } // namespace content | 249 } // namespace content |
| OLD | NEW |