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