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 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <list> | 11 #include <list> |
12 #include <map> | 12 #include <map> |
13 #include <set> | 13 #include <set> |
14 #include <string> | 14 #include <string> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/callback.h" | 17 #include "base/callback.h" |
18 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
19 #include "base/gtest_prod_util.h" | 19 #include "base/gtest_prod_util.h" |
20 #include "base/macros.h" | 20 #include "base/macros.h" |
21 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
| 22 #include "base/optional.h" |
22 #include "base/strings/string16.h" | 23 #include "base/strings/string16.h" |
23 #include "base/supports_user_data.h" | 24 #include "base/supports_user_data.h" |
24 #include "base/time/time.h" | 25 #include "base/time/time.h" |
25 #include "build/build_config.h" | 26 #include "build/build_config.h" |
26 #include "content/browser/accessibility/browser_accessibility_manager.h" | 27 #include "content/browser/accessibility/browser_accessibility_manager.h" |
27 #include "content/browser/bad_message.h" | 28 #include "content/browser/bad_message.h" |
28 #include "content/browser/loader/global_routing_id.h" | 29 #include "content/browser/loader/global_routing_id.h" |
29 #include "content/browser/site_instance_impl.h" | 30 #include "content/browser/site_instance_impl.h" |
30 #include "content/browser/webui/web_ui_impl.h" | 31 #include "content/browser/webui/web_ui_impl.h" |
31 #include "content/common/accessibility_mode.h" | 32 #include "content/common/accessibility_mode.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 const base::string16& html)>; | 129 const base::string16& html)>; |
129 | 130 |
130 // An accessibility reset is only allowed to prevent very rare corner cases | 131 // An accessibility reset is only allowed to prevent very rare corner cases |
131 // or race conditions where the browser and renderer get out of sync. If | 132 // or race conditions where the browser and renderer get out of sync. If |
132 // this happens more than this many times, kill the renderer. | 133 // this happens more than this many times, kill the renderer. |
133 static const int kMaxAccessibilityResets = 5; | 134 static const int kMaxAccessibilityResets = 5; |
134 | 135 |
135 static RenderFrameHostImpl* FromID(int process_id, int routing_id); | 136 static RenderFrameHostImpl* FromID(int process_id, int routing_id); |
136 static RenderFrameHostImpl* FromAXTreeID( | 137 static RenderFrameHostImpl* FromAXTreeID( |
137 ui::AXTreeIDRegistry::AXTreeID ax_tree_id); | 138 ui::AXTreeIDRegistry::AXTreeID ax_tree_id); |
| 139 #if defined(OS_ANDROID) |
| 140 static RenderFrameHostImpl* FromOverlayRoutingToken( |
| 141 const base::UnguessableToken& token); |
| 142 #endif |
138 | 143 |
139 ~RenderFrameHostImpl() override; | 144 ~RenderFrameHostImpl() override; |
140 | 145 |
141 // RenderFrameHost | 146 // RenderFrameHost |
142 int GetRoutingID() override; | 147 int GetRoutingID() override; |
143 ui::AXTreeIDRegistry::AXTreeID GetAXTreeID() override; | 148 ui::AXTreeIDRegistry::AXTreeID GetAXTreeID() override; |
144 SiteInstanceImpl* GetSiteInstance() override; | 149 SiteInstanceImpl* GetSiteInstance() override; |
145 RenderProcessHost* GetProcess() override; | 150 RenderProcessHost* GetProcess() override; |
146 RenderWidgetHostView* GetView() override; | 151 RenderWidgetHostView* GetView() override; |
147 RenderFrameHostImpl* GetParent() override; | 152 RenderFrameHostImpl* GetParent() override; |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 bool has_focused_editable_element() const { | 631 bool has_focused_editable_element() const { |
627 return has_focused_editable_element_; | 632 return has_focused_editable_element_; |
628 } | 633 } |
629 | 634 |
630 // Cancels any blocked request for the frame and its subframes. | 635 // Cancels any blocked request for the frame and its subframes. |
631 void CancelBlockedRequestsForFrame(); | 636 void CancelBlockedRequestsForFrame(); |
632 | 637 |
633 #if defined(OS_ANDROID) | 638 #if defined(OS_ANDROID) |
634 base::android::ScopedJavaLocalRef<jobject> GetJavaRenderFrameHost(); | 639 base::android::ScopedJavaLocalRef<jobject> GetJavaRenderFrameHost(); |
635 service_manager::InterfaceProvider* GetJavaInterfaces() override; | 640 service_manager::InterfaceProvider* GetJavaInterfaces() override; |
| 641 |
| 642 // Returns an unguessable token for this RFHI. This provides a temporary way |
| 643 // to identify a RenderFrameHost that's compatible with IPC. Else, one needs |
| 644 // to send pid + RoutingID, but one cannot send pid. One can get it from the |
| 645 // channel, but this makes it much harder to get wrong. |
| 646 // Once media switches to mojo, we should be able to remove this in favor of |
| 647 // sending a mojo overlay factory. |
| 648 const base::UnguessableToken& GetOverlayRoutingToken(); |
636 #endif | 649 #endif |
637 | 650 |
638 protected: | 651 protected: |
639 friend class RenderFrameHostFactory; | 652 friend class RenderFrameHostFactory; |
640 | 653 |
641 // |flags| is a combination of CreateRenderFrameFlags. | 654 // |flags| is a combination of CreateRenderFrameFlags. |
642 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost | 655 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost |
643 // should be the abstraction needed here, but we need RenderViewHost to pass | 656 // should be the abstraction needed here, but we need RenderViewHost to pass |
644 // into WebContentsObserver::FrameDetached for now. | 657 // into WebContentsObserver::FrameDetached for now. |
645 RenderFrameHostImpl(SiteInstance* site_instance, | 658 RenderFrameHostImpl(SiteInstance* site_instance, |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 void OnSetHasReceivedUserGesture(); | 797 void OnSetHasReceivedUserGesture(); |
785 | 798 |
786 #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) | 799 #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) |
787 void OnShowPopup(const FrameHostMsg_ShowPopup_Params& params); | 800 void OnShowPopup(const FrameHostMsg_ShowPopup_Params& params); |
788 void OnHidePopup(); | 801 void OnHidePopup(); |
789 #endif | 802 #endif |
790 #if defined(OS_ANDROID) | 803 #if defined(OS_ANDROID) |
791 void OnNavigationHandledByEmbedder(); | 804 void OnNavigationHandledByEmbedder(); |
792 void ForwardGetInterfaceToRenderFrame(const std::string& interface_name, | 805 void ForwardGetInterfaceToRenderFrame(const std::string& interface_name, |
793 mojo::ScopedMessagePipeHandle pipe); | 806 mojo::ScopedMessagePipeHandle pipe); |
| 807 |
| 808 // Called when the frame would like an overlay routing token. This will |
| 809 // create one if needed. Either way, it will send it to the frame. |
| 810 void OnRequestOverlayRoutingToken(); |
794 #endif | 811 #endif |
795 void OnShowCreatedWindow(int pending_widget_routing_id, | 812 void OnShowCreatedWindow(int pending_widget_routing_id, |
796 WindowOpenDisposition disposition, | 813 WindowOpenDisposition disposition, |
797 const gfx::Rect& initial_rect, | 814 const gfx::Rect& initial_rect, |
798 bool user_gesture); | 815 bool user_gesture); |
799 | 816 |
800 // Registers Mojo interfaces that this frame host makes available. | 817 // Registers Mojo interfaces that this frame host makes available. |
801 void RegisterMojoInterfaces(); | 818 void RegisterMojoInterfaces(); |
802 | 819 |
803 // Resets any waiting state of this RenderFrameHost that is no longer | 820 // Resets any waiting state of this RenderFrameHost that is no longer |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 #if defined(OS_ANDROID) | 1187 #if defined(OS_ANDROID) |
1171 // An InterfaceProvider for Java-implemented interfaces that are scoped to | 1188 // An InterfaceProvider for Java-implemented interfaces that are scoped to |
1172 // this RenderFrameHost. This provides access to interfaces implemented in | 1189 // this RenderFrameHost. This provides access to interfaces implemented in |
1173 // Java in the browser process to C++ code in the browser process. | 1190 // Java in the browser process to C++ code in the browser process. |
1174 std::unique_ptr<service_manager::InterfaceProvider> java_interfaces_; | 1191 std::unique_ptr<service_manager::InterfaceProvider> java_interfaces_; |
1175 | 1192 |
1176 // An InterfaceRegistry that forwards interface requests from Java to the | 1193 // An InterfaceRegistry that forwards interface requests from Java to the |
1177 // RenderFrame. This provides access to interfaces implemented in the renderer | 1194 // RenderFrame. This provides access to interfaces implemented in the renderer |
1178 // to Java code in the browser process. | 1195 // to Java code in the browser process. |
1179 std::unique_ptr<service_manager::InterfaceRegistry> java_interface_registry_; | 1196 std::unique_ptr<service_manager::InterfaceRegistry> java_interface_registry_; |
| 1197 |
| 1198 // IPC-friendly token that represents this host for AndroidOverlays, if we |
| 1199 // have created one yet. |
| 1200 base::Optional<base::UnguessableToken> overlay_routing_token_; |
1180 #endif | 1201 #endif |
1181 | 1202 |
1182 // NOTE: This must be the last member. | 1203 // NOTE: This must be the last member. |
1183 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; | 1204 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; |
1184 | 1205 |
1185 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); | 1206 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); |
1186 }; | 1207 }; |
1187 | 1208 |
1188 } // namespace content | 1209 } // namespace content |
1189 | 1210 |
1190 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 1211 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
OLD | NEW |