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/browser/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 #include "content/public/browser/browser_thread.h" | 74 #include "content/public/browser/browser_thread.h" |
| 75 #include "content/public/browser/content_browser_client.h" | 75 #include "content/public/browser/content_browser_client.h" |
| 76 #include "content/public/browser/permission_manager.h" | 76 #include "content/public/browser/permission_manager.h" |
| 77 #include "content/public/browser/permission_type.h" | 77 #include "content/public/browser/permission_type.h" |
| 78 #include "content/public/browser/render_process_host.h" | 78 #include "content/public/browser/render_process_host.h" |
| 79 #include "content/public/browser/render_widget_host_view.h" | 79 #include "content/public/browser/render_widget_host_view.h" |
| 80 #include "content/public/browser/resource_context.h" | 80 #include "content/public/browser/resource_context.h" |
| 81 #include "content/public/browser/storage_partition.h" | 81 #include "content/public/browser/storage_partition.h" |
| 82 #include "content/public/browser/stream_handle.h" | 82 #include "content/public/browser/stream_handle.h" |
| 83 #include "content/public/browser/user_metrics.h" | 83 #include "content/public/browser/user_metrics.h" |
| 84 #include "content/public/common/bindings_policy.h" | |
| 84 #include "content/public/common/browser_side_navigation_policy.h" | 85 #include "content/public/common/browser_side_navigation_policy.h" |
| 85 #include "content/public/common/content_constants.h" | 86 #include "content/public/common/content_constants.h" |
| 86 #include "content/public/common/content_features.h" | 87 #include "content/public/common/content_features.h" |
| 87 #include "content/public/common/content_switches.h" | 88 #include "content/public/common/content_switches.h" |
| 88 #include "content/public/common/file_chooser_file_info.h" | 89 #include "content/public/common/file_chooser_file_info.h" |
| 89 #include "content/public/common/file_chooser_params.h" | 90 #include "content/public/common/file_chooser_params.h" |
| 90 #include "content/public/common/form_field_data.h" | 91 #include "content/public/common/form_field_data.h" |
| 91 #include "content/public/common/isolated_world_ids.h" | 92 #include "content/public/common/isolated_world_ids.h" |
| 92 #include "content/public/common/service_manager_connection.h" | 93 #include "content/public/common/service_manager_connection.h" |
| 93 #include "content/public/common/service_names.mojom.h" | 94 #include "content/public/common/service_names.mojom.h" |
| (...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1307 } | 1308 } |
| 1308 | 1309 |
| 1309 RenderWidgetHostView* RenderFrameHostImpl::GetView() { | 1310 RenderWidgetHostView* RenderFrameHostImpl::GetView() { |
| 1310 return GetRenderWidgetHost()->GetView(); | 1311 return GetRenderWidgetHost()->GetView(); |
| 1311 } | 1312 } |
| 1312 | 1313 |
| 1313 GlobalFrameRoutingId RenderFrameHostImpl::GetGlobalFrameRoutingId() { | 1314 GlobalFrameRoutingId RenderFrameHostImpl::GetGlobalFrameRoutingId() { |
| 1314 return GlobalFrameRoutingId(GetProcess()->GetID(), GetRoutingID()); | 1315 return GlobalFrameRoutingId(GetProcess()->GetID(), GetRoutingID()); |
| 1315 } | 1316 } |
| 1316 | 1317 |
| 1317 int RenderFrameHostImpl::GetEnabledBindings() { | |
| 1318 return render_view_host_->GetEnabledBindings(); | |
| 1319 } | |
| 1320 | |
| 1321 void RenderFrameHostImpl::SetNavigationHandle( | 1318 void RenderFrameHostImpl::SetNavigationHandle( |
| 1322 std::unique_ptr<NavigationHandleImpl> navigation_handle) { | 1319 std::unique_ptr<NavigationHandleImpl> navigation_handle) { |
| 1323 navigation_handle_ = std::move(navigation_handle); | 1320 navigation_handle_ = std::move(navigation_handle); |
| 1324 | 1321 |
| 1325 // TODO(clamy): Remove this debug code once we understand better how we get to | 1322 // TODO(clamy): Remove this debug code once we understand better how we get to |
| 1326 // the point of attempting to transfer a navigation from a RFH that is no | 1323 // the point of attempting to transfer a navigation from a RFH that is no |
| 1327 // longer active. | 1324 // longer active. |
| 1328 if (navigation_handle_ && !is_active()) | 1325 if (navigation_handle_ && !is_active()) |
| 1329 base::debug::DumpWithoutCrashing(); | 1326 base::debug::DumpWithoutCrashing(); |
| 1330 } | 1327 } |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1702 } | 1699 } |
| 1703 | 1700 |
| 1704 void RenderFrameHostImpl::RequestFocusedFormFieldData( | 1701 void RenderFrameHostImpl::RequestFocusedFormFieldData( |
| 1705 FormFieldDataCallback& callback) { | 1702 FormFieldDataCallback& callback) { |
| 1706 static int next_id = 1; | 1703 static int next_id = 1; |
| 1707 int request_id = ++next_id; | 1704 int request_id = ++next_id; |
| 1708 form_field_data_callbacks_[request_id] = callback; | 1705 form_field_data_callbacks_[request_id] = callback; |
| 1709 Send(new FrameMsg_FocusedFormFieldDataRequest(GetRoutingID(), request_id)); | 1706 Send(new FrameMsg_FocusedFormFieldDataRequest(GetRoutingID(), request_id)); |
| 1710 } | 1707 } |
| 1711 | 1708 |
| 1709 void RenderFrameHostImpl::AllowBindings(int bindings_flags) { | |
|
Charlie Reis
2016/12/16 01:01:52
Do we ever need frames to have different bindings
Sam McNally
2017/01/12 09:27:08
Done.
| |
| 1710 // Never grant any bindings to browser plugin guests. | |
| 1711 if (GetProcess()->IsForGuestsOnly()) { | |
| 1712 NOTREACHED() << "Never grant bindings to a guest process."; | |
| 1713 return; | |
| 1714 } | |
| 1715 | |
| 1716 // Ensure we aren't granting WebUI bindings to a process that has already | |
| 1717 // been used for non-privileged views. | |
| 1718 if (bindings_flags & BINDINGS_POLICY_WEB_UI && | |
| 1719 GetProcess()->HasConnection() && | |
| 1720 !ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( | |
| 1721 GetProcess()->GetID())) { | |
| 1722 // This process has no bindings yet. Make sure it does not have more | |
| 1723 // than this single active view. | |
| 1724 // --single-process only has one renderer. | |
| 1725 if (GetProcess()->GetActiveViewCount() > 1 && | |
| 1726 !base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 1727 switches::kSingleProcess)) | |
| 1728 return; | |
| 1729 } | |
| 1730 | |
| 1731 if (bindings_flags & BINDINGS_POLICY_WEB_UI) { | |
| 1732 ChildProcessSecurityPolicyImpl::GetInstance()->GrantWebUIBindings( | |
| 1733 GetProcess()->GetID()); | |
| 1734 } | |
| 1735 | |
| 1736 enabled_bindings_ |= bindings_flags; | |
| 1737 // |frame_| may be disconnected in tests. | |
| 1738 if (frame_) | |
| 1739 frame_->AllowBindings(enabled_bindings_); | |
| 1740 } | |
| 1741 | |
| 1742 int RenderFrameHostImpl::GetEnabledBindings() const { | |
| 1743 return enabled_bindings_; | |
| 1744 } | |
| 1745 | |
| 1712 void RenderFrameHostImpl::OnFocusedFormFieldDataResponse( | 1746 void RenderFrameHostImpl::OnFocusedFormFieldDataResponse( |
| 1713 int request_id, | 1747 int request_id, |
| 1714 const FormFieldData& field_data) { | 1748 const FormFieldData& field_data) { |
| 1715 auto it = form_field_data_callbacks_.find(request_id); | 1749 auto it = form_field_data_callbacks_.find(request_id); |
| 1716 if (it != form_field_data_callbacks_.end()) { | 1750 if (it != form_field_data_callbacks_.end()) { |
| 1717 it->second.Run(field_data); | 1751 it->second.Run(field_data); |
| 1718 form_field_data_callbacks_.erase(it); | 1752 form_field_data_callbacks_.erase(it); |
| 1719 } | 1753 } |
| 1720 } | 1754 } |
| 1721 | 1755 |
| (...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2655 GetProcess()->GetRemoteInterfaces()->GetInterface(&frame_factory); | 2689 GetProcess()->GetRemoteInterfaces()->GetInterface(&frame_factory); |
| 2656 frame_factory->CreateFrame(routing_id_, GetProxy(&frame_), | 2690 frame_factory->CreateFrame(routing_id_, GetProxy(&frame_), |
| 2657 frame_host_binding_.CreateInterfacePtrAndBind()); | 2691 frame_host_binding_.CreateInterfacePtrAndBind()); |
| 2658 | 2692 |
| 2659 service_manager::mojom::InterfaceProviderPtr remote_interfaces; | 2693 service_manager::mojom::InterfaceProviderPtr remote_interfaces; |
| 2660 service_manager::mojom::InterfaceProviderRequest remote_interfaces_request = | 2694 service_manager::mojom::InterfaceProviderRequest remote_interfaces_request = |
| 2661 GetProxy(&remote_interfaces); | 2695 GetProxy(&remote_interfaces); |
| 2662 remote_interfaces_.reset(new service_manager::InterfaceProvider); | 2696 remote_interfaces_.reset(new service_manager::InterfaceProvider); |
| 2663 remote_interfaces_->Bind(std::move(remote_interfaces)); | 2697 remote_interfaces_->Bind(std::move(remote_interfaces)); |
| 2664 frame_->GetInterfaceProvider(std::move(remote_interfaces_request)); | 2698 frame_->GetInterfaceProvider(std::move(remote_interfaces_request)); |
| 2699 if (enabled_bindings_) | |
| 2700 frame_->AllowBindings(enabled_bindings_); | |
| 2665 } | 2701 } |
| 2666 | 2702 |
| 2667 void RenderFrameHostImpl::InvalidateMojoConnection() { | 2703 void RenderFrameHostImpl::InvalidateMojoConnection() { |
| 2668 interface_registry_.reset(); | 2704 interface_registry_.reset(); |
| 2669 | 2705 |
| 2670 ServiceManagerConnection* service_manager_connection = | 2706 ServiceManagerConnection* service_manager_connection = |
| 2671 BrowserContext::GetServiceManagerConnectionFor( | 2707 BrowserContext::GetServiceManagerConnectionFor( |
| 2672 GetProcess()->GetBrowserContext()); | 2708 GetProcess()->GetBrowserContext()); |
| 2673 // |service_manager_connection| may be null in tests using TestBrowserContext. | 2709 // |service_manager_connection| may be null in tests using TestBrowserContext. |
| 2674 if (service_manager_connection) { | 2710 if (service_manager_connection) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2731 } | 2767 } |
| 2732 } | 2768 } |
| 2733 } | 2769 } |
| 2734 DCHECK_EQ(!pending_web_ui_, pending_web_ui_type_ == WebUI::kNoWebUI); | 2770 DCHECK_EQ(!pending_web_ui_, pending_web_ui_type_ == WebUI::kNoWebUI); |
| 2735 | 2771 |
| 2736 // Either grant or check the RenderViewHost with/for proper bindings. | 2772 // Either grant or check the RenderViewHost with/for proper bindings. |
| 2737 if (pending_web_ui_ && !render_view_host_->GetProcess()->IsForGuestsOnly()) { | 2773 if (pending_web_ui_ && !render_view_host_->GetProcess()->IsForGuestsOnly()) { |
| 2738 // If a WebUI was created for the URL and the RenderView is not in a guest | 2774 // If a WebUI was created for the URL and the RenderView is not in a guest |
| 2739 // process, then enable missing bindings with the RenderViewHost. | 2775 // process, then enable missing bindings with the RenderViewHost. |
| 2740 int new_bindings = pending_web_ui_->GetBindings(); | 2776 int new_bindings = pending_web_ui_->GetBindings(); |
| 2741 if ((render_view_host_->GetEnabledBindings() & new_bindings) != | 2777 if ((GetEnabledBindings() & new_bindings) != new_bindings) { |
| 2742 new_bindings) { | 2778 AllowBindings(new_bindings); |
| 2743 render_view_host_->AllowBindings(new_bindings); | |
| 2744 } | 2779 } |
| 2745 } else if (render_view_host_->is_active()) { | 2780 } else if (render_view_host_->is_active()) { |
| 2746 // If the ongoing navigation is not to a WebUI or the RenderView is in a | 2781 // If the ongoing navigation is not to a WebUI or the RenderView is in a |
| 2747 // guest process, ensure that we don't create an unprivileged RenderView in | 2782 // guest process, ensure that we don't create an unprivileged RenderView in |
| 2748 // a WebUI-enabled process unless it's swapped out. | 2783 // a WebUI-enabled process unless it's swapped out. |
| 2749 bool url_acceptable_for_webui = | 2784 bool url_acceptable_for_webui = |
| 2750 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( | 2785 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( |
| 2751 GetSiteInstance()->GetBrowserContext(), dest_url); | 2786 GetSiteInstance()->GetBrowserContext(), dest_url); |
| 2752 if (!url_acceptable_for_webui) { | 2787 if (!url_acceptable_for_webui) { |
| 2753 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( | 2788 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3330 // pending_nav_entry_id. If the previous handle was a prematurely aborted | 3365 // pending_nav_entry_id. If the previous handle was a prematurely aborted |
| 3331 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. | 3366 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. |
| 3332 return NavigationHandleImpl::Create( | 3367 return NavigationHandleImpl::Create( |
| 3333 params.url, frame_tree_node_, is_renderer_initiated, | 3368 params.url, frame_tree_node_, is_renderer_initiated, |
| 3334 params.was_within_same_page, base::TimeTicks::Now(), | 3369 params.was_within_same_page, base::TimeTicks::Now(), |
| 3335 entry_id_for_data_nav, params.gesture, | 3370 entry_id_for_data_nav, params.gesture, |
| 3336 false); // started_from_context_menu | 3371 false); // started_from_context_menu |
| 3337 } | 3372 } |
| 3338 | 3373 |
| 3339 } // namespace content | 3374 } // namespace content |
| OLD | NEW |