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 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1097 is_using_lofi_(false), | 1097 is_using_lofi_(false), |
1098 effective_connection_type_( | 1098 effective_connection_type_( |
1099 blink::WebEffectiveConnectionType::TypeUnknown), | 1099 blink::WebEffectiveConnectionType::TypeUnknown), |
1100 is_pasting_(false), | 1100 is_pasting_(false), |
1101 suppress_further_dialogs_(false), | 1101 suppress_further_dialogs_(false), |
1102 blame_context_(nullptr), | 1102 blame_context_(nullptr), |
1103 #if BUILDFLAG(ENABLE_PLUGINS) | 1103 #if BUILDFLAG(ENABLE_PLUGINS) |
1104 focused_pepper_plugin_(nullptr), | 1104 focused_pepper_plugin_(nullptr), |
1105 pepper_last_mouse_event_target_(nullptr), | 1105 pepper_last_mouse_event_target_(nullptr), |
1106 #endif | 1106 #endif |
1107 engagement_binding_(this), | |
1107 frame_binding_(this), | 1108 frame_binding_(this), |
1108 host_zoom_binding_(this), | 1109 host_zoom_binding_(this), |
1110 engagement_level_(blink::mojom::EngagementLevel::NONE), | |
1109 has_accessed_initial_document_(false), | 1111 has_accessed_initial_document_(false), |
1110 weak_factory_(this) { | 1112 weak_factory_(this) { |
1111 // We don't have a service_manager::Connection at this point, so use empty | 1113 // We don't have a service_manager::Connection at this point, so use empty |
1112 // identity/specs. | 1114 // identity/specs. |
1113 // TODO(beng): We should fix this, so we can apply policy about which | 1115 // TODO(beng): We should fix this, so we can apply policy about which |
1114 // interfaces get exposed. | 1116 // interfaces get exposed. |
1115 interface_registry_ = base::MakeUnique<service_manager::InterfaceRegistry>( | 1117 interface_registry_ = base::MakeUnique<service_manager::InterfaceRegistry>( |
1116 mojom::kNavigation_FrameSpec); | 1118 mojom::kNavigation_FrameSpec); |
1117 service_manager::mojom::InterfaceProviderPtr remote_interfaces; | 1119 service_manager::mojom::InterfaceProviderPtr remote_interfaces; |
1118 pending_remote_interface_provider_request_ = GetProxy(&remote_interfaces); | 1120 pending_remote_interface_provider_request_ = GetProxy(&remote_interfaces); |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1621 // Can be NULL in tests. | 1623 // Can be NULL in tests. |
1622 if (render_thread_impl) | 1624 if (render_thread_impl) |
1623 render_thread_impl->GetRendererScheduler()->OnNavigationStarted(); | 1625 render_thread_impl->GetRendererScheduler()->OnNavigationStarted(); |
1624 DCHECK(!IsBrowserSideNavigationEnabled()); | 1626 DCHECK(!IsBrowserSideNavigationEnabled()); |
1625 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::OnNavigate", "id", | 1627 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::OnNavigate", "id", |
1626 routing_id_, "url", common_params.url.possibly_invalid_spec()); | 1628 routing_id_, "url", common_params.url.possibly_invalid_spec()); |
1627 NavigateInternal(common_params, start_params, request_params, | 1629 NavigateInternal(common_params, start_params, request_params, |
1628 std::unique_ptr<StreamOverrideParameters>()); | 1630 std::unique_ptr<StreamOverrideParameters>()); |
1629 } | 1631 } |
1630 | 1632 |
1631 void RenderFrameImpl::Bind(mojom::FrameRequest request, | 1633 void RenderFrameImpl::BindEngagement( |
1632 mojom::FrameHostPtr host) { | 1634 blink::mojom::EngagementClientAssociatedRequest request) { |
1635 engagement_binding_.Bind(std::move(request)); | |
1636 } | |
1637 | |
1638 void RenderFrameImpl::BindFrame(mojom::FrameRequest request, | |
1639 mojom::FrameHostPtr host) { | |
1633 frame_binding_.Bind(std::move(request)); | 1640 frame_binding_.Bind(std::move(request)); |
1634 frame_host_ = std::move(host); | 1641 frame_host_ = std::move(host); |
1635 frame_host_->GetInterfaceProvider( | 1642 frame_host_->GetInterfaceProvider( |
1636 std::move(pending_remote_interface_provider_request_)); | 1643 std::move(pending_remote_interface_provider_request_)); |
1637 } | 1644 } |
1638 | 1645 |
1639 ManifestManager* RenderFrameImpl::manifest_manager() { | 1646 ManifestManager* RenderFrameImpl::manifest_manager() { |
1640 return manifest_manager_; | 1647 return manifest_manager_; |
1641 } | 1648 } |
1642 | 1649 |
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2638 } | 2645 } |
2639 | 2646 |
2640 bool RenderFrameImpl::IsUsingLoFi() const { | 2647 bool RenderFrameImpl::IsUsingLoFi() const { |
2641 return is_using_lofi_; | 2648 return is_using_lofi_; |
2642 } | 2649 } |
2643 | 2650 |
2644 bool RenderFrameImpl::IsPasting() const { | 2651 bool RenderFrameImpl::IsPasting() const { |
2645 return is_pasting_; | 2652 return is_pasting_; |
2646 } | 2653 } |
2647 | 2654 |
2655 // blink::mojom::EngagementClient implementation ------------------------------- | |
2656 | |
2657 void RenderFrameImpl::SetEngagementLevel(blink::mojom::EngagementLevel level) { | |
2658 engagement_level_ = level; | |
2659 | |
2660 // Set the engagement level on |frame_| if we have committed the current | |
2661 // navigation. Otherwise, it will be set in didCommitProvisionalLoad. | |
2662 if (!frame_ || !frame_->dataSource()) | |
2663 return; | |
2664 | |
2665 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>( | |
2666 DocumentState::FromDataSource(frame_->dataSource())->navigation_state()); | |
2667 if (navigation_state->request_committed()) | |
2668 frame_->setEngagementLevel(level); | |
2669 } | |
2670 | |
2648 // mojom::Frame implementation ------------------------------------------------- | 2671 // mojom::Frame implementation ------------------------------------------------- |
2649 | 2672 |
2650 void RenderFrameImpl::GetInterfaceProvider( | 2673 void RenderFrameImpl::GetInterfaceProvider( |
2651 service_manager::mojom::InterfaceProviderRequest request) { | 2674 service_manager::mojom::InterfaceProviderRequest request) { |
2652 service_manager::ServiceInfo child_info = | 2675 service_manager::ServiceInfo child_info = |
2653 ChildThreadImpl::current()->GetChildServiceInfo(); | 2676 ChildThreadImpl::current()->GetChildServiceInfo(); |
2654 service_manager::ServiceInfo browser_info = | 2677 service_manager::ServiceInfo browser_info = |
2655 ChildThreadImpl::current()->GetBrowserServiceInfo(); | 2678 ChildThreadImpl::current()->GetBrowserServiceInfo(); |
2656 | 2679 |
2657 service_manager::InterfaceProviderSpec child_spec, browser_spec; | 2680 service_manager::InterfaceProviderSpec child_spec, browser_spec; |
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3563 base::IntToString( | 3586 base::IntToString( |
3564 render_view_->main_render_frame_->GetRoutingID())); | 3587 render_view_->main_render_frame_->GetRoutingID())); |
3565 } | 3588 } |
3566 CHECK(!render_view_->main_render_frame_); | 3589 CHECK(!render_view_->main_render_frame_); |
3567 render_view_->main_render_frame_ = this; | 3590 render_view_->main_render_frame_ = this; |
3568 if (render_view_->is_swapped_out()) | 3591 if (render_view_->is_swapped_out()) |
3569 render_view_->SetSwappedOut(false); | 3592 render_view_->SetSwappedOut(false); |
3570 } | 3593 } |
3571 } | 3594 } |
3572 | 3595 |
3596 // Ensure the frame has the correct engagement level before the load begins. | |
3597 frame_->setEngagementLevel(engagement_level_); | |
nasko
2016/11/28 19:18:08
I would feel more comfortable if this is only set
dominickn
2016/11/29 07:41:22
Done.
| |
3598 | |
3573 // For new page navigations, the browser process needs to be notified of the | 3599 // For new page navigations, the browser process needs to be notified of the |
3574 // first paint of that page, so it can cancel the timer that waits for it. | 3600 // first paint of that page, so it can cancel the timer that waits for it. |
3575 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { | 3601 if (is_main_frame_ && !navigation_state->WasWithinSamePage()) { |
3576 render_view_->QueueMessage( | 3602 render_view_->QueueMessage( |
3577 new ViewHostMsg_DidFirstPaintAfterLoad(render_view_->routing_id_), | 3603 new ViewHostMsg_DidFirstPaintAfterLoad(render_view_->routing_id_), |
3578 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); | 3604 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); |
3579 } | 3605 } |
3580 | 3606 |
3581 // When we perform a new navigation, we need to update the last committed | 3607 // When we perform a new navigation, we need to update the last committed |
3582 // session history entry with state for the page we are leaving. Do this | 3608 // session history entry with state for the page we are leaving. Do this |
(...skipping 2891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6474 // Mimics the order of events sent by WebKit. | 6500 // Mimics the order of events sent by WebKit. |
6475 // See WebCore::Editor::setComposition() for the corresponding code. | 6501 // See WebCore::Editor::setComposition() for the corresponding code. |
6476 focused_pepper_plugin_->HandleCompositionEnd(text); | 6502 focused_pepper_plugin_->HandleCompositionEnd(text); |
6477 focused_pepper_plugin_->HandleTextInput(text); | 6503 focused_pepper_plugin_->HandleTextInput(text); |
6478 } | 6504 } |
6479 pepper_composition_text_.clear(); | 6505 pepper_composition_text_.clear(); |
6480 } | 6506 } |
6481 #endif // ENABLE_PLUGINS | 6507 #endif // ENABLE_PLUGINS |
6482 | 6508 |
6483 void RenderFrameImpl::RegisterMojoInterfaces() { | 6509 void RenderFrameImpl::RegisterMojoInterfaces() { |
6510 GetAssociatedInterfaceRegistry()->AddInterface( | |
6511 base::Bind(&RenderFrameImpl::BindEngagement, weak_factory_.GetWeakPtr())); | |
6512 | |
6484 if (!frame_->parent()) { | 6513 if (!frame_->parent()) { |
6485 // Only main frame have ImageDownloader service. | 6514 // Only main frame have ImageDownloader service. |
6486 GetInterfaceRegistry()->AddInterface(base::Bind( | 6515 GetInterfaceRegistry()->AddInterface(base::Bind( |
6487 &ImageDownloaderImpl::CreateMojoService, base::Unretained(this))); | 6516 &ImageDownloaderImpl::CreateMojoService, base::Unretained(this))); |
6488 | 6517 |
6489 // Host zoom is per-page, so only added on the main frame. | 6518 // Host zoom is per-page, so only added on the main frame. |
6490 GetAssociatedInterfaceRegistry()->AddInterface(base::Bind( | 6519 GetAssociatedInterfaceRegistry()->AddInterface(base::Bind( |
6491 &RenderFrameImpl::OnHostZoomClientRequest, weak_factory_.GetWeakPtr())); | 6520 &RenderFrameImpl::OnHostZoomClientRequest, weak_factory_.GetWeakPtr())); |
6492 } | 6521 } |
6493 } | 6522 } |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6664 // event target. Potentially a Pepper plugin will receive the event. | 6693 // event target. Potentially a Pepper plugin will receive the event. |
6665 // In order to tell whether a plugin gets the last mouse event and which it | 6694 // In order to tell whether a plugin gets the last mouse event and which it |
6666 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6695 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6667 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6696 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6668 // |pepper_last_mouse_event_target_|. | 6697 // |pepper_last_mouse_event_target_|. |
6669 pepper_last_mouse_event_target_ = nullptr; | 6698 pepper_last_mouse_event_target_ = nullptr; |
6670 #endif | 6699 #endif |
6671 } | 6700 } |
6672 | 6701 |
6673 } // namespace content | 6702 } // namespace content |
OLD | NEW |