OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 2558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2569 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_STALE_OK); | 2569 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_STALE_OK); |
2570 break; | 2570 break; |
2571 case WebURLRequest::ReturnCacheDataDontLoad: // Don't re-post. | 2571 case WebURLRequest::ReturnCacheDataDontLoad: // Don't re-post. |
2572 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_ONLY); | 2572 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_ONLY); |
2573 break; | 2573 break; |
2574 default: | 2574 default: |
2575 NOTREACHED(); | 2575 NOTREACHED(); |
2576 } | 2576 } |
2577 } | 2577 } |
2578 | 2578 |
2579 // Create the serviceworker's per-document network observing object if it | 2579 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
2580 // does not exist (When navigation happens within a page, the provider already | 2580 switches::kEnableBrowserSideNavigation)) { |
2581 // exists). | 2581 // PlzNavigate |
2582 if (!ServiceWorkerNetworkProvider::FromDocumentState( | 2582 // Create a new ServiceWorker's network observing object for every |
2583 // navigation. | |
2584 if (!content_initiated) { | |
2585 ServiceWorkerProviderType provider_type = | |
clamy
2015/10/01 12:41:27
There's a lot of repeated code here. How about:
bo
Fabrice (no longer in Chrome)
2015/10/01 18:29:56
I reworked the whole part here.
| |
2586 SERVICE_WORKER_PROVIDER_FOR_WINDOW; | |
2587 if ((frame->effectiveSandboxFlags() & blink::WebSandboxFlags::Origin) == | |
2588 blink::WebSandboxFlags::Origin) { | |
2589 provider_type = SERVICE_WORKER_PROVIDER_FOR_SANDBOXED_FRAME; | |
michaeln
2015/10/01 01:42:16
Are the effectiveSandboxFlags() sent as part of th
Fabrice (no longer in Chrome)
2015/10/01 18:29:56
That's my mistake. I'm setting the provider_id to
| |
2590 } | |
2591 | |
2592 NavigationStateImpl* navigation_state = | |
2593 static_cast<NavigationStateImpl*>( | |
2594 DocumentState::FromDataSource(datasource)->navigation_state()); | |
2595 int service_worker_provider_id = | |
2596 navigation_state->request_params().service_worker_provider_id; | |
2597 scoped_ptr<ServiceWorkerNetworkProvider> network_provider( | |
2598 new ServiceWorkerNetworkProvider(routing_id_, provider_type, | |
2599 service_worker_provider_id)); | |
2600 | |
2601 ServiceWorkerNetworkProvider::AttachToDocumentState( | |
2602 DocumentState::FromDataSource(datasource), | |
2603 network_provider.Pass()); | |
2604 } | |
2605 } else { | |
2606 // Create the ServiceWorker's per-document network observing object if it | |
2607 // does not exist (When navigation happens within a page, the provider | |
2608 // already exists). | |
2609 if (!ServiceWorkerNetworkProvider::FromDocumentState( | |
2583 DocumentState::FromDataSource(datasource))) { | 2610 DocumentState::FromDataSource(datasource))) { |
2584 ServiceWorkerProviderType provider_type = | 2611 ServiceWorkerProviderType provider_type = |
2585 SERVICE_WORKER_PROVIDER_FOR_WINDOW; | 2612 SERVICE_WORKER_PROVIDER_FOR_WINDOW; |
2586 if ((frame->effectiveSandboxFlags() & blink::WebSandboxFlags::Origin) == | 2613 if ((frame->effectiveSandboxFlags() & blink::WebSandboxFlags::Origin) == |
2587 blink::WebSandboxFlags::Origin) { | 2614 blink::WebSandboxFlags::Origin) { |
2588 provider_type = SERVICE_WORKER_PROVIDER_FOR_SANDBOXED_FRAME; | 2615 provider_type = SERVICE_WORKER_PROVIDER_FOR_SANDBOXED_FRAME; |
2616 } | |
2617 | |
2618 scoped_ptr<ServiceWorkerNetworkProvider> network_provider( | |
2619 new ServiceWorkerNetworkProvider(routing_id_, provider_type, | |
2620 kInvalidServiceWorkerProviderId)); | |
2621 | |
2622 ServiceWorkerNetworkProvider::AttachToDocumentState( | |
2623 DocumentState::FromDataSource(datasource), | |
2624 network_provider.Pass()); | |
2589 } | 2625 } |
2590 scoped_ptr<ServiceWorkerNetworkProvider> network_provider( | |
2591 new ServiceWorkerNetworkProvider(routing_id_, provider_type)); | |
2592 ServiceWorkerNetworkProvider::AttachToDocumentState( | |
2593 DocumentState::FromDataSource(datasource), | |
2594 network_provider.Pass()); | |
2595 } | 2626 } |
2596 } | 2627 } |
2597 | 2628 |
2598 void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame, | 2629 void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame, |
2599 double triggering_event_time) { | 2630 double triggering_event_time) { |
2600 DCHECK(!frame_ || frame_ == frame); | 2631 DCHECK(!frame_ || frame_ == frame); |
2601 WebDataSource* ds = frame->provisionalDataSource(); | 2632 WebDataSource* ds = frame->provisionalDataSource(); |
2602 | 2633 |
2603 // In fast/loader/stop-provisional-loads.html, we abort the load before this | 2634 // In fast/loader/stop-provisional-loads.html, we abort the load before this |
2604 // callback is invoked. | 2635 // callback is invoked. |
(...skipping 2291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4896 WebDataSource* provisional_data_source = frame_->provisionalDataSource(); | 4927 WebDataSource* provisional_data_source = frame_->provisionalDataSource(); |
4897 WebDataSource* current_data_source = frame_->dataSource(); | 4928 WebDataSource* current_data_source = frame_->dataSource(); |
4898 WebDataSource* data_source = | 4929 WebDataSource* data_source = |
4899 provisional_data_source ? provisional_data_source : current_data_source; | 4930 provisional_data_source ? provisional_data_source : current_data_source; |
4900 | 4931 |
4901 // The current entry can only be replaced if there already is an entry in the | 4932 // The current entry can only be replaced if there already is an entry in the |
4902 // history list. | 4933 // history list. |
4903 if (data_source && render_view_->history_list_length_ > 0) { | 4934 if (data_source && render_view_->history_list_length_ > 0) { |
4904 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); | 4935 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); |
4905 } | 4936 } |
4937 | |
4938 DCHECK_EQ(FETCH_REQUEST_MODE_SAME_ORIGIN, | |
4939 GetFetchRequestModeForWebURLRequest(*request)); | |
4940 DCHECK_EQ(FETCH_CREDENTIALS_MODE_INCLUDE, | |
4941 GetFetchCredentialsModeForWebURLRequest(*request)); | |
4942 DCHECK(GetFetchRedirectModeForWebURLRequest(*request) == | |
4943 FetchRedirectMode::MANUAL_MODE); | |
4944 DCHECK_IMPLIES(!frame_->parent(), | |
4945 GetRequestContextFrameTypeForWebURLRequest(*request) == | |
4946 REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL); | |
4947 DCHECK_IMPLIES(frame_->parent(), | |
4948 GetRequestContextFrameTypeForWebURLRequest(*request) == | |
4949 REQUEST_CONTEXT_FRAME_TYPE_NESTED); | |
4950 | |
4906 Send(new FrameHostMsg_BeginNavigation( | 4951 Send(new FrameHostMsg_BeginNavigation( |
4907 routing_id_, | 4952 routing_id_, |
4908 MakeCommonNavigationParams(request, should_replace_current_entry), | 4953 MakeCommonNavigationParams(request, should_replace_current_entry), |
4909 BeginNavigationParams( | 4954 BeginNavigationParams( |
4910 request->httpMethod().latin1(), GetWebURLRequestHeaders(*request), | 4955 request->httpMethod().latin1(), |
4911 GetLoadFlagsForWebURLRequest(*request), request->hasUserGesture()), | 4956 GetWebURLRequestHeaders(*request), |
4957 GetLoadFlagsForWebURLRequest(*request), | |
4958 request->hasUserGesture(), | |
4959 request->skipServiceWorker(), | |
4960 GetRequestContextTypeForWebURLRequest(*request)), | |
4912 GetRequestBodyForWebURLRequest(*request))); | 4961 GetRequestBodyForWebURLRequest(*request))); |
4913 } | 4962 } |
4914 | 4963 |
4915 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params, | 4964 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params, |
4916 WebFrame* frame) { | 4965 WebFrame* frame) { |
4917 // A loadData request with a specified base URL. | 4966 // A loadData request with a specified base URL. |
4918 std::string mime_type, charset, data; | 4967 std::string mime_type, charset, data; |
4919 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { | 4968 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { |
4920 const GURL base_url = params.base_url_for_data_url.is_empty() ? | 4969 const GURL base_url = params.base_url_for_data_url.is_empty() ? |
4921 params.url : params.base_url_for_data_url; | 4970 params.url : params.base_url_for_data_url; |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5173 mojo::ServiceProviderPtr service_provider; | 5222 mojo::ServiceProviderPtr service_provider; |
5174 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 5223 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
5175 request->url = mojo::String::From(url); | 5224 request->url = mojo::String::From(url); |
5176 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), | 5225 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), |
5177 nullptr, nullptr, | 5226 nullptr, nullptr, |
5178 base::Bind(&OnGotContentHandlerID)); | 5227 base::Bind(&OnGotContentHandlerID)); |
5179 return service_provider.Pass(); | 5228 return service_provider.Pass(); |
5180 } | 5229 } |
5181 | 5230 |
5182 } // namespace content | 5231 } // namespace content |
OLD | NEW |