Chromium Code Reviews| 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 24 matching lines...) Expand all Loading... | |
| 35 #include "content/child/webmessageportchannel_impl.h" | 35 #include "content/child/webmessageportchannel_impl.h" |
| 36 #include "content/child/websocket_bridge.h" | 36 #include "content/child/websocket_bridge.h" |
| 37 #include "content/child/weburlresponse_extradata_impl.h" | 37 #include "content/child/weburlresponse_extradata_impl.h" |
| 38 #include "content/common/accessibility_messages.h" | 38 #include "content/common/accessibility_messages.h" |
| 39 #include "content/common/clipboard_messages.h" | 39 #include "content/common/clipboard_messages.h" |
| 40 #include "content/common/frame_messages.h" | 40 #include "content/common/frame_messages.h" |
| 41 #include "content/common/frame_replication_state.h" | 41 #include "content/common/frame_replication_state.h" |
| 42 #include "content/common/input_messages.h" | 42 #include "content/common/input_messages.h" |
| 43 #include "content/common/navigation_params.h" | 43 #include "content/common/navigation_params.h" |
| 44 #include "content/common/service_worker/service_worker_types.h" | 44 #include "content/common/service_worker/service_worker_types.h" |
| 45 #include "content/common/service_worker/service_worker_utils.h" | |
| 45 #include "content/common/site_isolation_policy.h" | 46 #include "content/common/site_isolation_policy.h" |
| 46 #include "content/common/swapped_out_messages.h" | 47 #include "content/common/swapped_out_messages.h" |
| 47 #include "content/common/view_messages.h" | 48 #include "content/common/view_messages.h" |
| 48 #include "content/public/common/bindings_policy.h" | 49 #include "content/public/common/bindings_policy.h" |
| 49 #include "content/public/common/content_constants.h" | 50 #include "content/public/common/content_constants.h" |
| 50 #include "content/public/common/content_switches.h" | 51 #include "content/public/common/content_switches.h" |
| 51 #include "content/public/common/context_menu_params.h" | 52 #include "content/public/common/context_menu_params.h" |
| 52 #include "content/public/common/isolated_world_ids.h" | 53 #include "content/public/common/isolated_world_ids.h" |
| 53 #include "content/public/common/page_state.h" | 54 #include "content/public/common/page_state.h" |
| 54 #include "content/public/common/resource_response.h" | 55 #include "content/public/common/resource_response.h" |
| (...skipping 2522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2577 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_ONLY); | 2578 document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_ONLY); |
| 2578 break; | 2579 break; |
| 2579 default: | 2580 default: |
| 2580 NOTREACHED(); | 2581 NOTREACHED(); |
| 2581 } | 2582 } |
| 2582 } | 2583 } |
| 2583 | 2584 |
| 2584 // Create the serviceworker's per-document network observing object if it | 2585 // Create the serviceworker's per-document network observing object if it |
| 2585 // does not exist (When navigation happens within a page, the provider already | 2586 // does not exist (When navigation happens within a page, the provider already |
| 2586 // exists). | 2587 // exists). |
| 2587 if (!ServiceWorkerNetworkProvider::FromDocumentState( | 2588 if (ServiceWorkerNetworkProvider::FromDocumentState( |
| 2588 DocumentState::FromDataSource(datasource))) { | 2589 DocumentState::FromDataSource(datasource))) |
| 2589 ServiceWorkerProviderType provider_type = | 2590 return; |
| 2590 SERVICE_WORKER_PROVIDER_FOR_WINDOW; | 2591 |
| 2592 bool browser_side_navigation = | |
| 2593 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 2594 switches::kEnableBrowserSideNavigation); | |
| 2595 scoped_ptr<ServiceWorkerNetworkProvider> network_provider; | |
| 2596 | |
| 2597 if (browser_side_navigation && content_initiated) { | |
|
michaeln
2015/10/08 02:18:51
thnx for restructuring this code, the different ca
| |
| 2598 // PlzNavigate | |
| 2599 // Initialize an empty ServiceWorkerNetworkProvider. | |
|
michaeln
2015/10/08 02:18:51
nit: this comment isn't needed, it states the obvi
| |
| 2600 network_provider = scoped_ptr<ServiceWorkerNetworkProvider>( | |
| 2601 new ServiceWorkerNetworkProvider()); | |
| 2602 } else if (browser_side_navigation && !content_initiated) { | |
| 2603 // PlzNavigate | |
| 2604 // Retrieve the service_worker_provider_id from the RequestNavigationParams. | |
|
michaeln
2015/10/08 02:18:51
nit: also stating the obvious
| |
| 2605 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>( | |
| 2606 DocumentState::FromDataSource(datasource)->navigation_state()); | |
| 2607 int service_worker_provider_id = | |
| 2608 navigation_state->request_params().service_worker_provider_id; | |
| 2609 | |
| 2610 // The browser sets service_worker_provider_id to | |
| 2611 // kInvalidServiceWorkerProviderId for sandboxed frames. | |
| 2612 if (service_worker_provider_id == kInvalidServiceWorkerProviderId) { | |
| 2613 network_provider = scoped_ptr<ServiceWorkerNetworkProvider>( | |
| 2614 new ServiceWorkerNetworkProvider()); | |
| 2615 } else { | |
| 2616 DCHECK(ServiceWorkerUtils::IsBrowserAssignedProviderId( | |
| 2617 service_worker_provider_id)); | |
| 2618 network_provider = scoped_ptr<ServiceWorkerNetworkProvider>( | |
| 2619 new ServiceWorkerNetworkProvider( | |
| 2620 routing_id_, SERVICE_WORKER_PROVIDER_FOR_WINDOW, | |
| 2621 service_worker_provider_id)); | |
| 2622 } | |
| 2623 } else { | |
| 2591 if ((frame->effectiveSandboxFlags() & blink::WebSandboxFlags::Origin) == | 2624 if ((frame->effectiveSandboxFlags() & blink::WebSandboxFlags::Origin) == |
| 2592 blink::WebSandboxFlags::Origin) { | 2625 blink::WebSandboxFlags::Origin) { |
| 2593 provider_type = SERVICE_WORKER_PROVIDER_FOR_SANDBOXED_FRAME; | 2626 network_provider = scoped_ptr<ServiceWorkerNetworkProvider>( |
| 2627 new ServiceWorkerNetworkProvider( | |
| 2628 routing_id_, SERVICE_WORKER_PROVIDER_FOR_SANDBOXED_FRAME)); | |
|
michaeln
2015/10/08 02:18:51
nit: could use the empty ctor here too so its clea
| |
| 2629 } else { | |
| 2630 network_provider = scoped_ptr<ServiceWorkerNetworkProvider>( | |
| 2631 new ServiceWorkerNetworkProvider( | |
| 2632 routing_id_, SERVICE_WORKER_PROVIDER_FOR_WINDOW)); | |
| 2594 } | 2633 } |
| 2595 scoped_ptr<ServiceWorkerNetworkProvider> network_provider( | |
| 2596 new ServiceWorkerNetworkProvider(routing_id_, provider_type)); | |
| 2597 ServiceWorkerNetworkProvider::AttachToDocumentState( | |
| 2598 DocumentState::FromDataSource(datasource), | |
| 2599 network_provider.Pass()); | |
| 2600 } | 2634 } |
| 2635 | |
| 2636 ServiceWorkerNetworkProvider::AttachToDocumentState( | |
| 2637 DocumentState::FromDataSource(datasource), network_provider.Pass()); | |
| 2601 } | 2638 } |
| 2602 | 2639 |
| 2603 void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame, | 2640 void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame, |
| 2604 double triggering_event_time) { | 2641 double triggering_event_time) { |
| 2605 DCHECK(!frame_ || frame_ == frame); | 2642 DCHECK(!frame_ || frame_ == frame); |
| 2606 WebDataSource* ds = frame->provisionalDataSource(); | 2643 WebDataSource* ds = frame->provisionalDataSource(); |
| 2607 | 2644 |
| 2608 // In fast/loader/stop-provisional-loads.html, we abort the load before this | 2645 // In fast/loader/stop-provisional-loads.html, we abort the load before this |
| 2609 // callback is invoked. | 2646 // callback is invoked. |
| 2610 if (!ds) | 2647 if (!ds) |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3338 | 3375 |
| 3339 int provider_id = kInvalidServiceWorkerProviderId; | 3376 int provider_id = kInvalidServiceWorkerProviderId; |
| 3340 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel || | 3377 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel || |
| 3341 request.frameType() == blink::WebURLRequest::FrameTypeNested) { | 3378 request.frameType() == blink::WebURLRequest::FrameTypeNested) { |
| 3342 // |provisionalDataSource| may be null in some content::ResourceFetcher | 3379 // |provisionalDataSource| may be null in some content::ResourceFetcher |
| 3343 // use cases, we don't hook those requests. | 3380 // use cases, we don't hook those requests. |
| 3344 if (frame->provisionalDataSource()) { | 3381 if (frame->provisionalDataSource()) { |
| 3345 ServiceWorkerNetworkProvider* provider = | 3382 ServiceWorkerNetworkProvider* provider = |
| 3346 ServiceWorkerNetworkProvider::FromDocumentState( | 3383 ServiceWorkerNetworkProvider::FromDocumentState( |
| 3347 DocumentState::FromDataSource(frame->provisionalDataSource())); | 3384 DocumentState::FromDataSource(frame->provisionalDataSource())); |
| 3385 DCHECK(provider); | |
| 3348 provider_id = provider->provider_id(); | 3386 provider_id = provider->provider_id(); |
| 3349 } | 3387 } |
| 3350 } else if (frame->dataSource()) { | 3388 } else if (frame->dataSource()) { |
| 3351 ServiceWorkerNetworkProvider* provider = | 3389 ServiceWorkerNetworkProvider* provider = |
| 3352 ServiceWorkerNetworkProvider::FromDocumentState( | 3390 ServiceWorkerNetworkProvider::FromDocumentState( |
| 3353 DocumentState::FromDataSource(frame->dataSource())); | 3391 DocumentState::FromDataSource(frame->dataSource())); |
| 3392 DCHECK(provider); | |
| 3354 provider_id = provider->provider_id(); | 3393 provider_id = provider->provider_id(); |
| 3355 // Explicitly set the SkipServiceWorker flag here if the renderer process | 3394 // Explicitly set the SkipServiceWorker flag here if the renderer process |
| 3356 // hasn't received SetControllerServiceWorker message. | 3395 // hasn't received SetControllerServiceWorker message. |
| 3357 if (!provider->IsControlledByServiceWorker()) | 3396 if (!provider->IsControlledByServiceWorker()) |
| 3358 request.setSkipServiceWorker(true); | 3397 request.setSkipServiceWorker(true); |
| 3359 } | 3398 } |
| 3360 | 3399 |
| 3361 WebFrame* parent = frame->parent(); | 3400 WebFrame* parent = frame->parent(); |
| 3362 int parent_routing_id = MSG_ROUTING_NONE; | 3401 int parent_routing_id = MSG_ROUTING_NONE; |
| 3363 if (!parent) { | 3402 if (!parent) { |
| (...skipping 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5214 mojo::ServiceProviderPtr service_provider(21); | 5253 mojo::ServiceProviderPtr service_provider(21); |
| 5215 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 5254 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 5216 request->url = mojo::String::From(url); | 5255 request->url = mojo::String::From(url); |
| 5217 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), | 5256 mojo_shell_->ConnectToApplication(request.Pass(), GetProxy(&service_provider), |
| 5218 nullptr, nullptr, | 5257 nullptr, nullptr, |
| 5219 base::Bind(&OnGotContentHandlerID)); | 5258 base::Bind(&OnGotContentHandlerID)); |
| 5220 return service_provider.Pass(); | 5259 return service_provider.Pass(); |
| 5221 } | 5260 } |
| 5222 | 5261 |
| 5223 } // namespace content | 5262 } // namespace content |
| OLD | NEW |