Chromium Code Reviews| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 class FriendWrapper; | 124 class FriendWrapper; |
| 125 | 125 |
| 126 ~WebContentsImpl() override; | 126 ~WebContentsImpl() override; |
| 127 | 127 |
| 128 static WebContentsImpl* CreateWithOpener( | 128 static WebContentsImpl* CreateWithOpener( |
| 129 const WebContents::CreateParams& params, | 129 const WebContents::CreateParams& params, |
| 130 FrameTreeNode* opener); | 130 FrameTreeNode* opener); |
| 131 | 131 |
| 132 static std::vector<WebContentsImpl*> GetAllWebContents(); | 132 static std::vector<WebContentsImpl*> GetAllWebContents(); |
| 133 | 133 |
| 134 static WebContentsImpl* FromFrameTreeNode(FrameTreeNode* frame_tree_node); | 134 static WebContentsImpl* FromFrameTreeNode( |
| 135 const FrameTreeNode* frame_tree_node); | |
| 135 static WebContents* FromRenderFrameHostID(int render_process_host_id, | 136 static WebContents* FromRenderFrameHostID(int render_process_host_id, |
| 136 int render_frame_host_id); | 137 int render_frame_host_id); |
| 137 static WebContents* FromFrameTreeNodeId(int frame_tree_node_id); | 138 static WebContents* FromFrameTreeNodeId(int frame_tree_node_id); |
| 139 static WebContentsImpl* FromOuterFrameTreeNode( | |
| 140 const FrameTreeNode* frame_tree_node); | |
| 138 | 141 |
| 139 // Complex initialization here. Specifically needed to avoid having | 142 // Complex initialization here. Specifically needed to avoid having |
| 140 // members call back into our virtual functions in the constructor. | 143 // members call back into our virtual functions in the constructor. |
| 141 virtual void Init(const WebContents::CreateParams& params); | 144 virtual void Init(const WebContents::CreateParams& params); |
| 142 | 145 |
| 143 // Returns the SavePackage which manages the page saving job. May be NULL. | 146 // Returns the SavePackage which manages the page saving job. May be NULL. |
| 144 SavePackage* save_package() const { return save_package_.get(); } | 147 SavePackage* save_package() const { return save_package_.get(); } |
| 145 | 148 |
| 146 #if defined(OS_ANDROID) | 149 #if defined(OS_ANDROID) |
| 147 // In Android WebView, the RenderView needs created even there is no | 150 // In Android WebView, the RenderView needs created even there is no |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 // |binding_set| is not owned and must either outlive this WebContents or be | 263 // |binding_set| is not owned and must either outlive this WebContents or be |
| 261 // explicitly removed before being destroyed. | 264 // explicitly removed before being destroyed. |
| 262 base::Closure AddBindingSet(const std::string& interface_name, | 265 base::Closure AddBindingSet(const std::string& interface_name, |
| 263 WebContentsBindingSet* binding_set); | 266 WebContentsBindingSet* binding_set); |
| 264 | 267 |
| 265 // Accesses a WebContentsBindingSet for a specific interface on this | 268 // Accesses a WebContentsBindingSet for a specific interface on this |
| 266 // WebContents. Returns null of there is no registered binder for the | 269 // WebContents. Returns null of there is no registered binder for the |
| 267 // interface. | 270 // interface. |
| 268 WebContentsBindingSet* GetBindingSet(const std::string& interface_name); | 271 WebContentsBindingSet* GetBindingSet(const std::string& interface_name); |
| 269 | 272 |
| 273 // Returns the focused WebContents. | |
| 274 // If there are multiple inner/outer WebContents (when embedding <webview>, | |
| 275 // <guestview>, ...) returns the single one containing the currently focused | |
| 276 // frame. Otherwise, returns this WebContents. | |
| 277 WebContentsImpl* GetFocusedWebContents(); | |
| 278 | |
| 279 // Returns a vector of all WebContentses within (and including) this one. | |
| 280 std::vector<WebContentsImpl*> GetWebContentsAndAllInner(); | |
| 281 | |
| 270 // WebContents ------------------------------------------------------ | 282 // WebContents ------------------------------------------------------ |
| 271 WebContentsDelegate* GetDelegate() override; | 283 WebContentsDelegate* GetDelegate() override; |
| 272 void SetDelegate(WebContentsDelegate* delegate) override; | 284 void SetDelegate(WebContentsDelegate* delegate) override; |
| 273 NavigationControllerImpl& GetController() override; | 285 NavigationControllerImpl& GetController() override; |
| 274 const NavigationControllerImpl& GetController() const override; | 286 const NavigationControllerImpl& GetController() const override; |
| 275 BrowserContext* GetBrowserContext() const override; | 287 BrowserContext* GetBrowserContext() const override; |
| 276 const GURL& GetURL() const override; | 288 const GURL& GetURL() const override; |
| 277 const GURL& GetVisibleURL() const override; | 289 const GURL& GetVisibleURL() const override; |
| 278 const GURL& GetLastCommittedURL() const override; | 290 const GURL& GetLastCommittedURL() const override; |
| 279 RenderProcessHost* GetRenderProcessHost() const override; | 291 RenderProcessHost* GetRenderProcessHost() const override; |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 802 // Called when the WebContents gains or loses a persistent video. | 814 // Called when the WebContents gains or loses a persistent video. |
| 803 void SetHasPersistentVideo(bool has_persistent_video); | 815 void SetHasPersistentVideo(bool has_persistent_video); |
| 804 | 816 |
| 805 // Whether the WebContents has an active player is effectively fullscreen. | 817 // Whether the WebContents has an active player is effectively fullscreen. |
| 806 // That means that the video is either fullscreen or it is the content of | 818 // That means that the video is either fullscreen or it is the content of |
| 807 // a fullscreen page (in other words, a fullscreen video with custom | 819 // a fullscreen page (in other words, a fullscreen video with custom |
| 808 // controls). | 820 // controls). |
| 809 // |IsFullscreen| must return |true| when this method is called. | 821 // |IsFullscreen| must return |true| when this method is called. |
| 810 bool HasActiveEffectivelyFullscreenVideo() const; | 822 bool HasActiveEffectivelyFullscreenVideo() const; |
| 811 | 823 |
| 824 // Called by this WebContents's BrowserPluginGuest (if one exists) to indicate | |
| 825 // that the guest will be destroyed. | |
| 826 void BrowserPluginGuestWillDestroy(); | |
| 827 | |
| 812 #if defined(OS_ANDROID) | 828 #if defined(OS_ANDROID) |
| 813 // Called by FindRequestManager when all of the find match rects are in. | 829 // Called by FindRequestManager when all of the find match rects are in. |
| 814 void NotifyFindMatchRectsReply(int version, | 830 void NotifyFindMatchRectsReply(int version, |
| 815 const std::vector<gfx::RectF>& rects, | 831 const std::vector<gfx::RectF>& rects, |
| 816 const gfx::RectF& active_rect); | 832 const gfx::RectF& active_rect); |
| 817 #endif | 833 #endif |
| 818 | 834 |
| 819 private: | 835 private: |
| 820 friend class WebContentsObserver; | 836 friend class WebContentsObserver; |
| 821 friend class WebContents; // To implement factory methods. | 837 friend class WebContents; // To implement factory methods. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 865 // still remain disjoint. | 881 // still remain disjoint. |
| 866 // The parent is referred to as "outer WebContents" and the descendents are | 882 // The parent is referred to as "outer WebContents" and the descendents are |
| 867 // referred to as "inner WebContents". | 883 // referred to as "inner WebContents". |
| 868 // For each inner WebContents, the outer WebContents will have a | 884 // For each inner WebContents, the outer WebContents will have a |
| 869 // corresponding FrameTreeNode. | 885 // corresponding FrameTreeNode. |
| 870 class WebContentsTreeNode final : public FrameTreeNode::Observer { | 886 class WebContentsTreeNode final : public FrameTreeNode::Observer { |
| 871 public: | 887 public: |
| 872 explicit WebContentsTreeNode(WebContentsImpl* current_web_contents); | 888 explicit WebContentsTreeNode(WebContentsImpl* current_web_contents); |
| 873 ~WebContentsTreeNode() final; | 889 ~WebContentsTreeNode() final; |
| 874 | 890 |
| 891 typedef std::unordered_map<int, WebContentsTreeNode*> ChildrenMap; | |
|
ncarter (slow)
2017/03/27 23:21:37
This looks unused.
paulmeyer
2017/03/31 18:31:16
Yes, it is. Removed.
| |
| 892 | |
| 875 void ConnectToOuterWebContents(WebContentsImpl* outer_web_contents, | 893 void ConnectToOuterWebContents(WebContentsImpl* outer_web_contents, |
| 876 RenderFrameHostImpl* outer_contents_frame); | 894 RenderFrameHostImpl* outer_contents_frame); |
| 877 | 895 |
| 878 WebContentsImpl* outer_web_contents() const { return outer_web_contents_; } | 896 WebContentsImpl* outer_web_contents() const { return outer_web_contents_; } |
| 879 int outer_contents_frame_tree_node_id() const { | 897 int outer_contents_frame_tree_node_id() const { |
| 880 return outer_contents_frame_tree_node_id_; | 898 return outer_contents_frame_tree_node_id_; |
| 881 } | 899 } |
| 882 FrameTreeNode* OuterContentsFrameTreeNode() const; | 900 FrameTreeNode* OuterContentsFrameTreeNode() const; |
| 883 | 901 |
| 884 WebContentsImpl* focused_web_contents() { return focused_web_contents_; } | 902 WebContentsImpl* focused_web_contents() { return focused_web_contents_; } |
| 885 void SetFocusedWebContents(WebContentsImpl* web_contents); | 903 void SetFocusedWebContents(WebContentsImpl* web_contents); |
| 886 | 904 |
| 905 // Returns the inner WebContents within |frame|, if one exists, or nullptr | |
| 906 // otherwise. | |
| 907 WebContentsImpl* GetInnerWebContentsInFrame(const FrameTreeNode* frame); | |
| 908 | |
| 909 // Fills |all_contents| with all inner WebContentsTreeNodes' WebContentses. | |
|
ncarter (slow)
2017/03/27 23:21:37
With this class comment, I would not expect that t
paulmeyer
2017/03/31 18:31:16
I agree that the use in FindRequestManager::GetChi
| |
| 910 void GetAllInnerWebContents(std::vector<WebContentsImpl*>* all_contents); | |
| 911 | |
| 887 private: | 912 private: |
| 913 void AttachInnerWebContents(WebContentsImpl* inner_web_contents); | |
| 914 void DetachInnerWebContents(WebContentsImpl* inner_web_contents); | |
| 915 | |
| 888 // FrameTreeNode::Observer implementation. | 916 // FrameTreeNode::Observer implementation. |
| 889 void OnFrameTreeNodeDestroyed(FrameTreeNode* node) final; | 917 void OnFrameTreeNodeDestroyed(FrameTreeNode* node) final; |
| 890 | 918 |
| 891 // The WebContents that owns this WebContentsTreeNode. | 919 // The WebContents that owns this WebContentsTreeNode. |
| 892 WebContentsImpl* const current_web_contents_; | 920 WebContentsImpl* const current_web_contents_; |
| 893 | 921 |
| 894 // The outer WebContents of |current_web_contents_|, or nullptr if | 922 // The outer WebContents of |current_web_contents_|, or nullptr if |
| 895 // |current_web_contents_| is the outermost WebContents. | 923 // |current_web_contents_| is the outermost WebContents. |
| 896 WebContentsImpl* outer_web_contents_; | 924 WebContentsImpl* outer_web_contents_; |
| 897 | 925 |
| 898 // The ID of the FrameTreeNode in the |outer_web_contents_| that hosts | 926 // The ID of the FrameTreeNode in the |outer_web_contents_| that hosts |
| 899 // |current_web_contents_| as an inner WebContents. | 927 // |current_web_contents_| as an inner WebContents. |
| 900 int outer_contents_frame_tree_node_id_; | 928 int outer_contents_frame_tree_node_id_; |
| 901 | 929 |
| 930 // List of inner WebContents that we host. | |
| 931 std::vector<WebContentsImpl*> inner_web_contents_; | |
| 932 | |
| 902 // Only the root node should have this set. This indicates the WebContents | 933 // Only the root node should have this set. This indicates the WebContents |
| 903 // whose frame tree has the focused frame. The WebContents tree could be | 934 // whose frame tree has the focused frame. The WebContents tree could be |
| 904 // arbitrarily deep. | 935 // arbitrarily deep. |
| 905 WebContentsImpl* focused_web_contents_; | 936 WebContentsImpl* focused_web_contents_; |
| 906 }; | 937 }; |
| 907 | 938 |
| 908 // See WebContents::Create for a description of these parameters. | 939 // See WebContents::Create for a description of these parameters. |
| 909 WebContentsImpl(BrowserContext* browser_context); | 940 WebContentsImpl(BrowserContext* browser_context); |
| 910 | 941 |
| 911 // Add and remove observers for page navigation notifications. The order in | 942 // Add and remove observers for page navigation notifications. The order in |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1068 // | 1099 // |
| 1069 // These functions are helpers in managing a hierarchy of WebContents | 1100 // These functions are helpers in managing a hierarchy of WebContents |
| 1070 // involved in rendering inner WebContents. | 1101 // involved in rendering inner WebContents. |
| 1071 | 1102 |
| 1072 // When multiple WebContents are present within a tab or window, a single one | 1103 // When multiple WebContents are present within a tab or window, a single one |
| 1073 // is focused and will route keyboard events in most cases to a RenderWidget | 1104 // is focused and will route keyboard events in most cases to a RenderWidget |
| 1074 // contained within it. |GetFocusedWebContents()|'s main frame widget will | 1105 // contained within it. |GetFocusedWebContents()|'s main frame widget will |
| 1075 // receive page focus and blur events when the containing window changes focus | 1106 // receive page focus and blur events when the containing window changes focus |
| 1076 // state. | 1107 // state. |
| 1077 | 1108 |
| 1078 // Returns the focused WebContents. | |
| 1079 // If there are multiple inner/outer WebContents (when embedding <webview>, | |
| 1080 // <guestview>, ...) returns the single one containing the currently focused | |
| 1081 // frame. Otherwise, returns this WebContents. | |
| 1082 WebContentsImpl* GetFocusedWebContents(); | |
| 1083 | |
| 1084 // Returns true if |this| is the focused WebContents or an ancestor of the | 1109 // Returns true if |this| is the focused WebContents or an ancestor of the |
| 1085 // focused WebContents. | 1110 // focused WebContents. |
| 1086 bool ContainsOrIsFocusedWebContents(); | 1111 bool ContainsOrIsFocusedWebContents(); |
| 1087 | 1112 |
| 1088 // When inner or outer WebContents are present, become the focused | 1113 // When inner or outer WebContents are present, become the focused |
| 1089 // WebContentsImpl. This will activate this content's main frame RenderWidget | 1114 // WebContentsImpl. This will activate this content's main frame RenderWidget |
| 1090 // and indirectly all its subframe widgets. GetFocusedRenderWidgetHost will | 1115 // and indirectly all its subframe widgets. GetFocusedRenderWidgetHost will |
| 1091 // search this WebContentsImpl for a focused RenderWidgetHost. The previously | 1116 // search this WebContentsImpl for a focused RenderWidgetHost. The previously |
| 1092 // focused WebContentsImpl, if any, will have its RenderWidgetHosts | 1117 // focused WebContentsImpl, if any, will have its RenderWidgetHosts |
| 1093 // deactivated. | 1118 // deactivated. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1182 // Internal helper to create WebUI objects associated with |this|. |url| is | 1207 // Internal helper to create WebUI objects associated with |this|. |url| is |
| 1183 // used to determine which WebUI should be created (if any). |frame_name| | 1208 // used to determine which WebUI should be created (if any). |frame_name| |
| 1184 // corresponds to the name of a frame that the WebUI should be created for (or | 1209 // corresponds to the name of a frame that the WebUI should be created for (or |
| 1185 // the main frame if empty). | 1210 // the main frame if empty). |
| 1186 std::unique_ptr<WebUIImpl> CreateWebUI(const GURL& url, | 1211 std::unique_ptr<WebUIImpl> CreateWebUI(const GURL& url, |
| 1187 const std::string& frame_name); | 1212 const std::string& frame_name); |
| 1188 | 1213 |
| 1189 void SetJavaScriptDialogManagerForTesting( | 1214 void SetJavaScriptDialogManagerForTesting( |
| 1190 JavaScriptDialogManager* dialog_manager); | 1215 JavaScriptDialogManager* dialog_manager); |
| 1191 | 1216 |
| 1192 // Returns the FindRequestManager, or creates one if it doesn't already exist. | 1217 // Returns the FindRequestManager, which may be found in an outer WebContents. |
| 1218 FindRequestManager* GetFindRequestManager(); | |
| 1219 | |
| 1220 // Returns the FindRequestManager, or creates one if it doesn't already | |
| 1221 // exist. The FindRequestManager may be found in an outer WebContents. | |
| 1193 FindRequestManager* GetOrCreateFindRequestManager(); | 1222 FindRequestManager* GetOrCreateFindRequestManager(); |
| 1194 | 1223 |
| 1195 // Removes a registered WebContentsBindingSet by interface name. | 1224 // Removes a registered WebContentsBindingSet by interface name. |
| 1196 void RemoveBindingSet(const std::string& interface_name); | 1225 void RemoveBindingSet(const std::string& interface_name); |
| 1197 | 1226 |
| 1198 // Prints a console warning when visiting a localhost site with a bad | 1227 // Prints a console warning when visiting a localhost site with a bad |
| 1199 // certificate via --allow-insecure-localhost. | 1228 // certificate via --allow-insecure-localhost. |
| 1200 void ShowInsecureLocalhostWarningIfNeeded(); | 1229 void ShowInsecureLocalhostWarningIfNeeded(); |
| 1201 | 1230 |
| 1202 // Notify this WebContents that the preferences have changed. This will send | 1231 // Notify this WebContents that the preferences have changed. This will send |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1553 // Adds/removes a callback called on creation of each new WebContents. | 1582 // Adds/removes a callback called on creation of each new WebContents. |
| 1554 static void AddCreatedCallbackForTesting(const CreatedCallback& callback); | 1583 static void AddCreatedCallbackForTesting(const CreatedCallback& callback); |
| 1555 static void RemoveCreatedCallbackForTesting(const CreatedCallback& callback); | 1584 static void RemoveCreatedCallbackForTesting(const CreatedCallback& callback); |
| 1556 | 1585 |
| 1557 DISALLOW_COPY_AND_ASSIGN(FriendWrapper); | 1586 DISALLOW_COPY_AND_ASSIGN(FriendWrapper); |
| 1558 }; | 1587 }; |
| 1559 | 1588 |
| 1560 } // namespace content | 1589 } // namespace content |
| 1561 | 1590 |
| 1562 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ | 1591 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
| OLD | NEW |