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 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1098 is_using_lofi_(false), | 1098 is_using_lofi_(false), |
1099 effective_connection_type_( | 1099 effective_connection_type_( |
1100 blink::WebEffectiveConnectionType::TypeUnknown), | 1100 blink::WebEffectiveConnectionType::TypeUnknown), |
1101 is_pasting_(false), | 1101 is_pasting_(false), |
1102 suppress_further_dialogs_(false), | 1102 suppress_further_dialogs_(false), |
1103 blame_context_(nullptr), | 1103 blame_context_(nullptr), |
1104 #if BUILDFLAG(ENABLE_PLUGINS) | 1104 #if BUILDFLAG(ENABLE_PLUGINS) |
1105 focused_pepper_plugin_(nullptr), | 1105 focused_pepper_plugin_(nullptr), |
1106 pepper_last_mouse_event_target_(nullptr), | 1106 pepper_last_mouse_event_target_(nullptr), |
1107 #endif | 1107 #endif |
1108 engagement_binding_(this), | |
1108 frame_binding_(this), | 1109 frame_binding_(this), |
1109 host_zoom_binding_(this), | 1110 host_zoom_binding_(this), |
1110 has_accessed_initial_document_(false), | 1111 has_accessed_initial_document_(false), |
1111 weak_factory_(this) { | 1112 weak_factory_(this) { |
1112 // 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 |
1113 // identity/specs. | 1114 // identity/specs. |
1114 // 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 |
1115 // interfaces get exposed. | 1116 // interfaces get exposed. |
1116 interface_registry_ = base::MakeUnique<service_manager::InterfaceRegistry>( | 1117 interface_registry_ = base::MakeUnique<service_manager::InterfaceRegistry>( |
1117 mojom::kNavigation_FrameSpec); | 1118 mojom::kNavigation_FrameSpec); |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1622 // Can be NULL in tests. | 1623 // Can be NULL in tests. |
1623 if (render_thread_impl) | 1624 if (render_thread_impl) |
1624 render_thread_impl->GetRendererScheduler()->OnNavigationStarted(); | 1625 render_thread_impl->GetRendererScheduler()->OnNavigationStarted(); |
1625 DCHECK(!IsBrowserSideNavigationEnabled()); | 1626 DCHECK(!IsBrowserSideNavigationEnabled()); |
1626 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::OnNavigate", "id", | 1627 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::OnNavigate", "id", |
1627 routing_id_, "url", common_params.url.possibly_invalid_spec()); | 1628 routing_id_, "url", common_params.url.possibly_invalid_spec()); |
1628 NavigateInternal(common_params, start_params, request_params, | 1629 NavigateInternal(common_params, start_params, request_params, |
1629 std::unique_ptr<StreamOverrideParameters>()); | 1630 std::unique_ptr<StreamOverrideParameters>()); |
1630 } | 1631 } |
1631 | 1632 |
1632 void RenderFrameImpl::Bind(mojom::FrameRequest request, | 1633 void RenderFrameImpl::BindEngagement( |
1633 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) { | |
1634 frame_binding_.Bind(std::move(request)); | 1640 frame_binding_.Bind(std::move(request)); |
1635 frame_host_ = std::move(host); | 1641 frame_host_ = std::move(host); |
1636 frame_host_->GetInterfaceProvider( | 1642 frame_host_->GetInterfaceProvider( |
1637 std::move(pending_remote_interface_provider_request_)); | 1643 std::move(pending_remote_interface_provider_request_)); |
1638 } | 1644 } |
1639 | 1645 |
1640 ManifestManager* RenderFrameImpl::manifest_manager() { | 1646 ManifestManager* RenderFrameImpl::manifest_manager() { |
1641 return manifest_manager_; | 1647 return manifest_manager_; |
1642 } | 1648 } |
1643 | 1649 |
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2639 } | 2645 } |
2640 | 2646 |
2641 bool RenderFrameImpl::IsUsingLoFi() const { | 2647 bool RenderFrameImpl::IsUsingLoFi() const { |
2642 return is_using_lofi_; | 2648 return is_using_lofi_; |
2643 } | 2649 } |
2644 | 2650 |
2645 bool RenderFrameImpl::IsPasting() const { | 2651 bool RenderFrameImpl::IsPasting() const { |
2646 return is_pasting_; | 2652 return is_pasting_; |
2647 } | 2653 } |
2648 | 2654 |
2655 // blink::mojom::EngagementClient implementation ------------------------------- | |
2656 | |
2657 void RenderFrameImpl::SetEngagementLevel(const url::Origin& origin, | |
2658 blink::mojom::EngagementLevel level) { | |
2659 // Set the engagement level on |frame_| if we have committed the current | |
2660 // navigation. Otherwise, it will be set in didCommitProvisionalLoad. | |
2661 if (frame_ && frame_->dataSource()) { | |
2662 NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>( | |
2663 DocumentState::FromDataSource(frame_->dataSource()) | |
2664 ->navigation_state()); | |
2665 if (navigation_state->request_committed() && | |
2666 url::Origin(frame_->getSecurityOrigin()) == origin) { | |
2667 frame_->setEngagementLevel(level); | |
2668 return; | |
2669 } | |
nasko
2016/11/30 18:00:25
This seems like lots of complex logic. Why can't w
dominickn
2016/11/30 23:46:33
I'm definitely not an expert on this (hence the co
| |
2670 } | |
2671 | |
2672 engagement_levels_[origin] = level; | |
nasko
2016/11/30 18:00:25
Do we need to store the level in the map if it was
dominickn
2016/11/30 23:46:33
I don't think so - that's why it returns immediate
| |
2673 } | |
2674 | |
2649 // mojom::Frame implementation ------------------------------------------------- | 2675 // mojom::Frame implementation ------------------------------------------------- |
2650 | 2676 |
2651 void RenderFrameImpl::GetInterfaceProvider( | 2677 void RenderFrameImpl::GetInterfaceProvider( |
2652 service_manager::mojom::InterfaceProviderRequest request) { | 2678 service_manager::mojom::InterfaceProviderRequest request) { |
2653 service_manager::ServiceInfo child_info = | 2679 service_manager::ServiceInfo child_info = |
2654 ChildThreadImpl::current()->GetChildServiceInfo(); | 2680 ChildThreadImpl::current()->GetChildServiceInfo(); |
2655 service_manager::ServiceInfo browser_info = | 2681 service_manager::ServiceInfo browser_info = |
2656 ChildThreadImpl::current()->GetBrowserServiceInfo(); | 2682 ChildThreadImpl::current()->GetBrowserServiceInfo(); |
2657 | 2683 |
2658 service_manager::InterfaceProviderSpec child_spec, browser_spec; | 2684 service_manager::InterfaceProviderSpec child_spec, browser_spec; |
(...skipping 2066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4725 | 4751 |
4726 const WebURLRequest& request = ds->request(); | 4752 const WebURLRequest& request = ds->request(); |
4727 const WebURLResponse& response = ds->response(); | 4753 const WebURLResponse& response = ds->response(); |
4728 | 4754 |
4729 DocumentState* document_state = DocumentState::FromDataSource(ds); | 4755 DocumentState* document_state = DocumentState::FromDataSource(ds); |
4730 NavigationStateImpl* navigation_state = | 4756 NavigationStateImpl* navigation_state = |
4731 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 4757 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
4732 InternalDocumentStateData* internal_data = | 4758 InternalDocumentStateData* internal_data = |
4733 InternalDocumentStateData::FromDocumentState(document_state); | 4759 InternalDocumentStateData::FromDocumentState(document_state); |
4734 | 4760 |
4761 // Set the correct engagement level on the frame. | |
4762 EngagementLevels::iterator engagement_level = | |
4763 engagement_levels_.find(url::Origin(GURL(request.url()))); | |
nasko
2016/11/30 18:00:25
Can't we use the frame's origin at this point? Why
dominickn
2016/11/30 23:46:33
Done.
| |
4764 | |
4765 if (engagement_level != engagement_levels_.end()) { | |
4766 frame_->setEngagementLevel(engagement_level->second); | |
4767 engagement_levels_.erase(engagement_level); | |
nasko
2016/11/30 18:00:25
The map should never grow big, right? Maybe add so
dominickn
2016/11/30 23:46:33
Done - instead of erasing, I just cleared the map
| |
4768 } | |
4769 | |
4735 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 4770 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
4736 params.http_status_code = response.httpStatusCode(); | 4771 params.http_status_code = response.httpStatusCode(); |
4737 params.url_is_unreachable = ds->hasUnreachableURL(); | 4772 params.url_is_unreachable = ds->hasUnreachableURL(); |
4738 params.method = "GET"; | 4773 params.method = "GET"; |
4739 params.intended_as_new_entry = | 4774 params.intended_as_new_entry = |
4740 navigation_state->request_params().intended_as_new_entry; | 4775 navigation_state->request_params().intended_as_new_entry; |
4741 params.did_create_new_entry = commit_type == blink::WebStandardCommit; | 4776 params.did_create_new_entry = commit_type == blink::WebStandardCommit; |
4742 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); | 4777 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); |
4743 params.post_id = -1; | 4778 params.post_id = -1; |
4744 params.nav_entry_id = navigation_state->request_params().nav_entry_id; | 4779 params.nav_entry_id = navigation_state->request_params().nav_entry_id; |
(...skipping 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6477 // Mimics the order of events sent by WebKit. | 6512 // Mimics the order of events sent by WebKit. |
6478 // See WebCore::Editor::setComposition() for the corresponding code. | 6513 // See WebCore::Editor::setComposition() for the corresponding code. |
6479 focused_pepper_plugin_->HandleCompositionEnd(text); | 6514 focused_pepper_plugin_->HandleCompositionEnd(text); |
6480 focused_pepper_plugin_->HandleTextInput(text); | 6515 focused_pepper_plugin_->HandleTextInput(text); |
6481 } | 6516 } |
6482 pepper_composition_text_.clear(); | 6517 pepper_composition_text_.clear(); |
6483 } | 6518 } |
6484 #endif // ENABLE_PLUGINS | 6519 #endif // ENABLE_PLUGINS |
6485 | 6520 |
6486 void RenderFrameImpl::RegisterMojoInterfaces() { | 6521 void RenderFrameImpl::RegisterMojoInterfaces() { |
6522 GetAssociatedInterfaceRegistry()->AddInterface( | |
6523 base::Bind(&RenderFrameImpl::BindEngagement, weak_factory_.GetWeakPtr())); | |
6524 | |
6487 if (!frame_->parent()) { | 6525 if (!frame_->parent()) { |
6488 // Only main frame have ImageDownloader service. | 6526 // Only main frame have ImageDownloader service. |
6489 GetInterfaceRegistry()->AddInterface(base::Bind( | 6527 GetInterfaceRegistry()->AddInterface(base::Bind( |
6490 &ImageDownloaderImpl::CreateMojoService, base::Unretained(this))); | 6528 &ImageDownloaderImpl::CreateMojoService, base::Unretained(this))); |
6491 | 6529 |
6492 // Host zoom is per-page, so only added on the main frame. | 6530 // Host zoom is per-page, so only added on the main frame. |
6493 GetAssociatedInterfaceRegistry()->AddInterface(base::Bind( | 6531 GetAssociatedInterfaceRegistry()->AddInterface(base::Bind( |
6494 &RenderFrameImpl::OnHostZoomClientRequest, weak_factory_.GetWeakPtr())); | 6532 &RenderFrameImpl::OnHostZoomClientRequest, weak_factory_.GetWeakPtr())); |
6495 } | 6533 } |
6496 } | 6534 } |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6667 // event target. Potentially a Pepper plugin will receive the event. | 6705 // event target. Potentially a Pepper plugin will receive the event. |
6668 // In order to tell whether a plugin gets the last mouse event and which it | 6706 // In order to tell whether a plugin gets the last mouse event and which it |
6669 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6707 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6670 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6708 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6671 // |pepper_last_mouse_event_target_|. | 6709 // |pepper_last_mouse_event_target_|. |
6672 pepper_last_mouse_event_target_ = nullptr; | 6710 pepper_last_mouse_event_target_ = nullptr; |
6673 #endif | 6711 #endif |
6674 } | 6712 } |
6675 | 6713 |
6676 } // namespace content | 6714 } // namespace content |
OLD | NEW |