OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <functional> | 10 #include <functional> |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 class FriendWrapper; | 125 class FriendWrapper; |
126 | 126 |
127 ~WebContentsImpl() override; | 127 ~WebContentsImpl() override; |
128 | 128 |
129 static WebContentsImpl* CreateWithOpener( | 129 static WebContentsImpl* CreateWithOpener( |
130 const WebContents::CreateParams& params, | 130 const WebContents::CreateParams& params, |
131 FrameTreeNode* opener); | 131 FrameTreeNode* opener); |
132 | 132 |
133 static std::vector<WebContentsImpl*> GetAllWebContents(); | 133 static std::vector<WebContentsImpl*> GetAllWebContents(); |
134 | 134 |
135 static WebContentsImpl* FromFrameTreeNode( | 135 static WebContentsImpl* FromFrameTreeNode(FrameTreeNode* frame_tree_node); |
136 const FrameTreeNode* frame_tree_node); | |
137 static WebContents* FromRenderFrameHostID(int render_process_host_id, | 136 static WebContents* FromRenderFrameHostID(int render_process_host_id, |
138 int render_frame_host_id); | 137 int render_frame_host_id); |
139 static WebContents* FromFrameTreeNodeId(int frame_tree_node_id); | 138 static WebContents* FromFrameTreeNodeId(int frame_tree_node_id); |
140 static WebContentsImpl* FromOuterFrameTreeNode( | |
141 const FrameTreeNode* frame_tree_node); | |
142 | 139 |
143 // Complex initialization here. Specifically needed to avoid having | 140 // Complex initialization here. Specifically needed to avoid having |
144 // members call back into our virtual functions in the constructor. | 141 // members call back into our virtual functions in the constructor. |
145 virtual void Init(const WebContents::CreateParams& params); | 142 virtual void Init(const WebContents::CreateParams& params); |
146 | 143 |
147 // Returns the SavePackage which manages the page saving job. May be NULL. | 144 // Returns the SavePackage which manages the page saving job. May be NULL. |
148 SavePackage* save_package() const { return save_package_.get(); } | 145 SavePackage* save_package() const { return save_package_.get(); } |
149 | 146 |
150 #if defined(OS_ANDROID) | 147 #if defined(OS_ANDROID) |
151 // In Android WebView, the RenderView needs created even there is no | 148 // In Android WebView, the RenderView needs created even there is no |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 // |binding_set| is not owned and must either outlive this WebContents or be | 261 // |binding_set| is not owned and must either outlive this WebContents or be |
265 // explicitly removed before being destroyed. | 262 // explicitly removed before being destroyed. |
266 base::Closure AddBindingSet(const std::string& interface_name, | 263 base::Closure AddBindingSet(const std::string& interface_name, |
267 WebContentsBindingSet* binding_set); | 264 WebContentsBindingSet* binding_set); |
268 | 265 |
269 // Accesses a WebContentsBindingSet for a specific interface on this | 266 // Accesses a WebContentsBindingSet for a specific interface on this |
270 // WebContents. Returns null of there is no registered binder for the | 267 // WebContents. Returns null of there is no registered binder for the |
271 // interface. | 268 // interface. |
272 WebContentsBindingSet* GetBindingSet(const std::string& interface_name); | 269 WebContentsBindingSet* GetBindingSet(const std::string& interface_name); |
273 | 270 |
274 // Returns the focused WebContents. | |
275 // If there are multiple inner/outer WebContents (when embedding <webview>, | |
276 // <guestview>, ...) returns the single one containing the currently focused | |
277 // frame. Otherwise, returns this WebContents. | |
278 WebContentsImpl* GetFocusedWebContents(); | |
279 | |
280 // TODO(paulmeyer): Once GuestViews are no longer implemented as | |
281 // BrowserPluginGuests, frame traversal across WebContents should be moved to | |
282 // be handled by FrameTreeNode, and |GetInnerWebContents| and | |
283 // |GetWebContentsAndAllInner| can be removed. | |
284 | |
285 // Returns a vector to the inner WebContents within this WebContents. | |
286 std::vector<WebContentsImpl*> GetInnerWebContents(); | |
287 | |
288 // Returns a vector containing this WebContents and all inner WebContents | |
289 // within it (recursively). | |
290 std::vector<WebContentsImpl*> GetWebContentsAndAllInner(); | |
291 | |
292 // WebContents ------------------------------------------------------ | 271 // WebContents ------------------------------------------------------ |
293 WebContentsDelegate* GetDelegate() override; | 272 WebContentsDelegate* GetDelegate() override; |
294 void SetDelegate(WebContentsDelegate* delegate) override; | 273 void SetDelegate(WebContentsDelegate* delegate) override; |
295 NavigationControllerImpl& GetController() override; | 274 NavigationControllerImpl& GetController() override; |
296 const NavigationControllerImpl& GetController() const override; | 275 const NavigationControllerImpl& GetController() const override; |
297 BrowserContext* GetBrowserContext() const override; | 276 BrowserContext* GetBrowserContext() const override; |
298 const GURL& GetURL() const override; | 277 const GURL& GetURL() const override; |
299 const GURL& GetVisibleURL() const override; | 278 const GURL& GetVisibleURL() const override; |
300 const GURL& GetLastCommittedURL() const override; | 279 const GURL& GetLastCommittedURL() const override; |
301 RenderProcessHost* GetRenderProcessHost() const override; | 280 RenderProcessHost* GetRenderProcessHost() const override; |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 // Called when the WebContents gains or loses a persistent video. | 805 // Called when the WebContents gains or loses a persistent video. |
827 void SetHasPersistentVideo(bool has_persistent_video); | 806 void SetHasPersistentVideo(bool has_persistent_video); |
828 | 807 |
829 // Whether the WebContents has an active player is effectively fullscreen. | 808 // Whether the WebContents has an active player is effectively fullscreen. |
830 // That means that the video is either fullscreen or it is the content of | 809 // That means that the video is either fullscreen or it is the content of |
831 // a fullscreen page (in other words, a fullscreen video with custom | 810 // a fullscreen page (in other words, a fullscreen video with custom |
832 // controls). | 811 // controls). |
833 // |IsFullscreen| must return |true| when this method is called. | 812 // |IsFullscreen| must return |true| when this method is called. |
834 bool HasActiveEffectivelyFullscreenVideo() const; | 813 bool HasActiveEffectivelyFullscreenVideo() const; |
835 | 814 |
836 // Called by this WebContents's BrowserPluginGuest (if one exists) to indicate | |
837 // that the guest will be destroyed. | |
838 void BrowserPluginGuestWillDestroy(); | |
839 | |
840 #if defined(OS_ANDROID) | 815 #if defined(OS_ANDROID) |
841 // Called by FindRequestManager when all of the find match rects are in. | 816 // Called by FindRequestManager when all of the find match rects are in. |
842 void NotifyFindMatchRectsReply(int version, | 817 void NotifyFindMatchRectsReply(int version, |
843 const std::vector<gfx::RectF>& rects, | 818 const std::vector<gfx::RectF>& rects, |
844 const gfx::RectF& active_rect); | 819 const gfx::RectF& active_rect); |
845 #endif | 820 #endif |
846 | 821 |
847 private: | 822 private: |
848 friend class WebContentsObserver; | 823 friend class WebContentsObserver; |
849 friend class WebContents; // To implement factory methods. | 824 friend class WebContents; // To implement factory methods. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 | 880 |
906 WebContentsImpl* outer_web_contents() const { return outer_web_contents_; } | 881 WebContentsImpl* outer_web_contents() const { return outer_web_contents_; } |
907 int outer_contents_frame_tree_node_id() const { | 882 int outer_contents_frame_tree_node_id() const { |
908 return outer_contents_frame_tree_node_id_; | 883 return outer_contents_frame_tree_node_id_; |
909 } | 884 } |
910 FrameTreeNode* OuterContentsFrameTreeNode() const; | 885 FrameTreeNode* OuterContentsFrameTreeNode() const; |
911 | 886 |
912 WebContentsImpl* focused_web_contents() { return focused_web_contents_; } | 887 WebContentsImpl* focused_web_contents() { return focused_web_contents_; } |
913 void SetFocusedWebContents(WebContentsImpl* web_contents); | 888 void SetFocusedWebContents(WebContentsImpl* web_contents); |
914 | 889 |
915 // Returns the inner WebContents within |frame|, if one exists, or nullptr | |
916 // otherwise. | |
917 WebContentsImpl* GetInnerWebContentsInFrame(const FrameTreeNode* frame); | |
918 | |
919 const std::vector<WebContentsImpl*>& inner_web_contents() const; | |
920 | |
921 private: | 890 private: |
922 void AttachInnerWebContents(WebContentsImpl* inner_web_contents); | |
923 void DetachInnerWebContents(WebContentsImpl* inner_web_contents); | |
924 | |
925 // FrameTreeNode::Observer implementation. | 891 // FrameTreeNode::Observer implementation. |
926 void OnFrameTreeNodeDestroyed(FrameTreeNode* node) final; | 892 void OnFrameTreeNodeDestroyed(FrameTreeNode* node) final; |
927 | 893 |
928 // The WebContents that owns this WebContentsTreeNode. | 894 // The WebContents that owns this WebContentsTreeNode. |
929 WebContentsImpl* const current_web_contents_; | 895 WebContentsImpl* const current_web_contents_; |
930 | 896 |
931 // The outer WebContents of |current_web_contents_|, or nullptr if | 897 // The outer WebContents of |current_web_contents_|, or nullptr if |
932 // |current_web_contents_| is the outermost WebContents. | 898 // |current_web_contents_| is the outermost WebContents. |
933 WebContentsImpl* outer_web_contents_; | 899 WebContentsImpl* outer_web_contents_; |
934 | 900 |
935 // The ID of the FrameTreeNode in the |outer_web_contents_| that hosts | 901 // The ID of the FrameTreeNode in the |outer_web_contents_| that hosts |
936 // |current_web_contents_| as an inner WebContents. | 902 // |current_web_contents_| as an inner WebContents. |
937 int outer_contents_frame_tree_node_id_; | 903 int outer_contents_frame_tree_node_id_; |
938 | 904 |
939 // List of inner WebContents that we host. | |
940 std::vector<WebContentsImpl*> inner_web_contents_; | |
941 | |
942 // Only the root node should have this set. This indicates the WebContents | 905 // Only the root node should have this set. This indicates the WebContents |
943 // whose frame tree has the focused frame. The WebContents tree could be | 906 // whose frame tree has the focused frame. The WebContents tree could be |
944 // arbitrarily deep. | 907 // arbitrarily deep. |
945 WebContentsImpl* focused_web_contents_; | 908 WebContentsImpl* focused_web_contents_; |
946 }; | 909 }; |
947 | 910 |
948 // See WebContents::Create for a description of these parameters. | 911 // See WebContents::Create for a description of these parameters. |
949 WebContentsImpl(BrowserContext* browser_context); | 912 WebContentsImpl(BrowserContext* browser_context); |
950 | 913 |
951 // Add and remove observers for page navigation notifications. The order in | 914 // Add and remove observers for page navigation notifications. The order in |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 // | 1072 // |
1110 // These functions are helpers in managing a hierarchy of WebContents | 1073 // These functions are helpers in managing a hierarchy of WebContents |
1111 // involved in rendering inner WebContents. | 1074 // involved in rendering inner WebContents. |
1112 | 1075 |
1113 // When multiple WebContents are present within a tab or window, a single one | 1076 // When multiple WebContents are present within a tab or window, a single one |
1114 // is focused and will route keyboard events in most cases to a RenderWidget | 1077 // is focused and will route keyboard events in most cases to a RenderWidget |
1115 // contained within it. |GetFocusedWebContents()|'s main frame widget will | 1078 // contained within it. |GetFocusedWebContents()|'s main frame widget will |
1116 // receive page focus and blur events when the containing window changes focus | 1079 // receive page focus and blur events when the containing window changes focus |
1117 // state. | 1080 // state. |
1118 | 1081 |
| 1082 // Returns the focused WebContents. |
| 1083 // If there are multiple inner/outer WebContents (when embedding <webview>, |
| 1084 // <guestview>, ...) returns the single one containing the currently focused |
| 1085 // frame. Otherwise, returns this WebContents. |
| 1086 WebContentsImpl* GetFocusedWebContents(); |
| 1087 |
1119 // Returns true if |this| is the focused WebContents or an ancestor of the | 1088 // Returns true if |this| is the focused WebContents or an ancestor of the |
1120 // focused WebContents. | 1089 // focused WebContents. |
1121 bool ContainsOrIsFocusedWebContents(); | 1090 bool ContainsOrIsFocusedWebContents(); |
1122 | 1091 |
1123 // When inner or outer WebContents are present, become the focused | 1092 // When inner or outer WebContents are present, become the focused |
1124 // WebContentsImpl. This will activate this content's main frame RenderWidget | 1093 // WebContentsImpl. This will activate this content's main frame RenderWidget |
1125 // and indirectly all its subframe widgets. GetFocusedRenderWidgetHost will | 1094 // and indirectly all its subframe widgets. GetFocusedRenderWidgetHost will |
1126 // search this WebContentsImpl for a focused RenderWidgetHost. The previously | 1095 // search this WebContentsImpl for a focused RenderWidgetHost. The previously |
1127 // focused WebContentsImpl, if any, will have its RenderWidgetHosts | 1096 // focused WebContentsImpl, if any, will have its RenderWidgetHosts |
1128 // deactivated. | 1097 // deactivated. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 // Internal helper to create WebUI objects associated with |this|. |url| is | 1186 // Internal helper to create WebUI objects associated with |this|. |url| is |
1218 // used to determine which WebUI should be created (if any). |frame_name| | 1187 // used to determine which WebUI should be created (if any). |frame_name| |
1219 // corresponds to the name of a frame that the WebUI should be created for (or | 1188 // corresponds to the name of a frame that the WebUI should be created for (or |
1220 // the main frame if empty). | 1189 // the main frame if empty). |
1221 std::unique_ptr<WebUIImpl> CreateWebUI(const GURL& url, | 1190 std::unique_ptr<WebUIImpl> CreateWebUI(const GURL& url, |
1222 const std::string& frame_name); | 1191 const std::string& frame_name); |
1223 | 1192 |
1224 void SetJavaScriptDialogManagerForTesting( | 1193 void SetJavaScriptDialogManagerForTesting( |
1225 JavaScriptDialogManager* dialog_manager); | 1194 JavaScriptDialogManager* dialog_manager); |
1226 | 1195 |
1227 // Returns the FindRequestManager, which may be found in an outer WebContents. | 1196 // Returns the FindRequestManager, or creates one if it doesn't already exist. |
1228 FindRequestManager* GetFindRequestManager(); | |
1229 | |
1230 // Returns the FindRequestManager, or creates one if it doesn't already | |
1231 // exist. The FindRequestManager may be found in an outer WebContents. | |
1232 FindRequestManager* GetOrCreateFindRequestManager(); | 1197 FindRequestManager* GetOrCreateFindRequestManager(); |
1233 | 1198 |
1234 // Removes a registered WebContentsBindingSet by interface name. | 1199 // Removes a registered WebContentsBindingSet by interface name. |
1235 void RemoveBindingSet(const std::string& interface_name); | 1200 void RemoveBindingSet(const std::string& interface_name); |
1236 | 1201 |
1237 // Prints a console warning when visiting a localhost site with a bad | 1202 // Prints a console warning when visiting a localhost site with a bad |
1238 // certificate via --allow-insecure-localhost. | 1203 // certificate via --allow-insecure-localhost. |
1239 void ShowInsecureLocalhostWarningIfNeeded(); | 1204 void ShowInsecureLocalhostWarningIfNeeded(); |
1240 | 1205 |
1241 // Notify this WebContents that the preferences have changed. This will send | 1206 // Notify this WebContents that the preferences have changed. This will send |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1592 // Adds/removes a callback called on creation of each new WebContents. | 1557 // Adds/removes a callback called on creation of each new WebContents. |
1593 static void AddCreatedCallbackForTesting(const CreatedCallback& callback); | 1558 static void AddCreatedCallbackForTesting(const CreatedCallback& callback); |
1594 static void RemoveCreatedCallbackForTesting(const CreatedCallback& callback); | 1559 static void RemoveCreatedCallbackForTesting(const CreatedCallback& callback); |
1595 | 1560 |
1596 DISALLOW_COPY_AND_ASSIGN(FriendWrapper); | 1561 DISALLOW_COPY_AND_ASSIGN(FriendWrapper); |
1597 }; | 1562 }; |
1598 | 1563 |
1599 } // namespace content | 1564 } // namespace content |
1600 | 1565 |
1601 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ | 1566 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
OLD | NEW |