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, | |
esprehn
2016/12/06 00:31:34
Why do you need to pass an origin? If you connect
dominickn
2016/12/06 00:49:57
nasko suggested passing the origin here like the H
nasko
2016/12/06 00:50:30
Because a single frame can render multiple origins
esprehn
2016/12/06 00:58:44
Right, but that's true of all things using the Ser
dominickn
2016/12/08 02:37:10
USB doesn't need to request a permission prior to
nasko
2016/12/08 22:26:48
If your Mojo interface is bound to the lifetime of
| |
2658 blink::mojom::EngagementLevel level) { | |
2659 // Set the engagement level on |frame_| if its origin matches the one we have | |
2660 // been provided with. | |
2661 if (frame_ && url::Origin(frame_->getSecurityOrigin()) == origin) { | |
2662 frame_->setEngagementLevel(level); | |
2663 return; | |
2664 } | |
2665 | |
2666 engagement_levels_[origin] = level; | |
2667 } | |
2668 | |
2649 // mojom::Frame implementation ------------------------------------------------- | 2669 // mojom::Frame implementation ------------------------------------------------- |
2650 | 2670 |
2651 void RenderFrameImpl::GetInterfaceProvider( | 2671 void RenderFrameImpl::GetInterfaceProvider( |
2652 service_manager::mojom::InterfaceProviderRequest request) { | 2672 service_manager::mojom::InterfaceProviderRequest request) { |
2653 service_manager::ServiceInfo child_info = | 2673 service_manager::ServiceInfo child_info = |
2654 ChildThreadImpl::current()->GetChildServiceInfo(); | 2674 ChildThreadImpl::current()->GetChildServiceInfo(); |
2655 service_manager::ServiceInfo browser_info = | 2675 service_manager::ServiceInfo browser_info = |
2656 ChildThreadImpl::current()->GetBrowserServiceInfo(); | 2676 ChildThreadImpl::current()->GetBrowserServiceInfo(); |
2657 | 2677 |
2658 service_manager::InterfaceProviderSpec child_spec, browser_spec; | 2678 service_manager::InterfaceProviderSpec child_spec, browser_spec; |
(...skipping 2066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4725 | 4745 |
4726 const WebURLRequest& request = ds->request(); | 4746 const WebURLRequest& request = ds->request(); |
4727 const WebURLResponse& response = ds->response(); | 4747 const WebURLResponse& response = ds->response(); |
4728 | 4748 |
4729 DocumentState* document_state = DocumentState::FromDataSource(ds); | 4749 DocumentState* document_state = DocumentState::FromDataSource(ds); |
4730 NavigationStateImpl* navigation_state = | 4750 NavigationStateImpl* navigation_state = |
4731 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 4751 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
4732 InternalDocumentStateData* internal_data = | 4752 InternalDocumentStateData* internal_data = |
4733 InternalDocumentStateData::FromDocumentState(document_state); | 4753 InternalDocumentStateData::FromDocumentState(document_state); |
4734 | 4754 |
4755 // Set the correct engagement level on the frame. | |
4756 EngagementLevels::iterator engagement_level = | |
4757 engagement_levels_.find(url::Origin(frame_->getSecurityOrigin())); | |
4758 | |
4759 if (engagement_level != engagement_levels_.end()) | |
4760 frame_->setEngagementLevel(engagement_level->second); | |
esprehn
2016/12/06 00:31:34
This seems like something we should be able to man
dominickn
2016/12/06 00:49:57
See comment below regarding this being sent pre-co
| |
4761 engagement_levels_.clear(); | |
dcheng
2016/12/08 08:14:07
Out of curiosity... why do we need to maintain a m
dominickn
2016/12/08 09:02:47
I implemented it analogously to the HostZoom featu
| |
4762 | |
4735 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 4763 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
4736 params.http_status_code = response.httpStatusCode(); | 4764 params.http_status_code = response.httpStatusCode(); |
4737 params.url_is_unreachable = ds->hasUnreachableURL(); | 4765 params.url_is_unreachable = ds->hasUnreachableURL(); |
4738 params.method = "GET"; | 4766 params.method = "GET"; |
4739 params.intended_as_new_entry = | 4767 params.intended_as_new_entry = |
4740 navigation_state->request_params().intended_as_new_entry; | 4768 navigation_state->request_params().intended_as_new_entry; |
4741 params.did_create_new_entry = commit_type == blink::WebStandardCommit; | 4769 params.did_create_new_entry = commit_type == blink::WebStandardCommit; |
4742 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); | 4770 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); |
4743 params.post_id = -1; | 4771 params.post_id = -1; |
4744 params.nav_entry_id = navigation_state->request_params().nav_entry_id; | 4772 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. | 6505 // Mimics the order of events sent by WebKit. |
6478 // See WebCore::Editor::setComposition() for the corresponding code. | 6506 // See WebCore::Editor::setComposition() for the corresponding code. |
6479 focused_pepper_plugin_->HandleCompositionEnd(text); | 6507 focused_pepper_plugin_->HandleCompositionEnd(text); |
6480 focused_pepper_plugin_->HandleTextInput(text); | 6508 focused_pepper_plugin_->HandleTextInput(text); |
6481 } | 6509 } |
6482 pepper_composition_text_.clear(); | 6510 pepper_composition_text_.clear(); |
6483 } | 6511 } |
6484 #endif // ENABLE_PLUGINS | 6512 #endif // ENABLE_PLUGINS |
6485 | 6513 |
6486 void RenderFrameImpl::RegisterMojoInterfaces() { | 6514 void RenderFrameImpl::RegisterMojoInterfaces() { |
6515 GetAssociatedInterfaceRegistry()->AddInterface( | |
6516 base::Bind(&RenderFrameImpl::BindEngagement, weak_factory_.GetWeakPtr())); | |
esprehn
2016/12/06 00:31:34
You should be able to connect to this interface di
dominickn
2016/12/06 00:49:57
I'm not sure what you mean. The IPC from the brows
nasko
2016/12/08 22:26:48
It doesn't strictly need to be a map, but it needs
| |
6517 | |
6487 if (!frame_->parent()) { | 6518 if (!frame_->parent()) { |
6488 // Only main frame have ImageDownloader service. | 6519 // Only main frame have ImageDownloader service. |
6489 GetInterfaceRegistry()->AddInterface(base::Bind( | 6520 GetInterfaceRegistry()->AddInterface(base::Bind( |
6490 &ImageDownloaderImpl::CreateMojoService, base::Unretained(this))); | 6521 &ImageDownloaderImpl::CreateMojoService, base::Unretained(this))); |
6491 | 6522 |
6492 // Host zoom is per-page, so only added on the main frame. | 6523 // Host zoom is per-page, so only added on the main frame. |
6493 GetAssociatedInterfaceRegistry()->AddInterface(base::Bind( | 6524 GetAssociatedInterfaceRegistry()->AddInterface(base::Bind( |
6494 &RenderFrameImpl::OnHostZoomClientRequest, weak_factory_.GetWeakPtr())); | 6525 &RenderFrameImpl::OnHostZoomClientRequest, weak_factory_.GetWeakPtr())); |
6495 } | 6526 } |
6496 } | 6527 } |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6667 // event target. Potentially a Pepper plugin will receive the event. | 6698 // 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 | 6699 // 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 | 6700 // 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 | 6701 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6671 // |pepper_last_mouse_event_target_|. | 6702 // |pepper_last_mouse_event_target_|. |
6672 pepper_last_mouse_event_target_ = nullptr; | 6703 pepper_last_mouse_event_target_ = nullptr; |
6673 #endif | 6704 #endif |
6674 } | 6705 } |
6675 | 6706 |
6676 } // namespace content | 6707 } // namespace content |
OLD | NEW |