Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Side by Side Diff: content/browser/web_contents/web_contents_impl.h

Issue 2836973002: Enable find-in-page across GuestViews. (Closed)
Patch Set: Small fix. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 bool HasActiveEffectivelyFullscreenVideo() const; 834 bool HasActiveEffectivelyFullscreenVideo() const;
814 835
815 // When inner or outer WebContents are present, become the focused 836 // When inner or outer WebContents are present, become the focused
816 // WebContentsImpl. This will activate this content's main frame RenderWidget 837 // WebContentsImpl. This will activate this content's main frame RenderWidget
817 // and indirectly all its subframe widgets. GetFocusedRenderWidgetHost will 838 // and indirectly all its subframe widgets. GetFocusedRenderWidgetHost will
818 // search this WebContentsImpl for a focused RenderWidgetHost. The previously 839 // search this WebContentsImpl for a focused RenderWidgetHost. The previously
819 // focused WebContentsImpl, if any, will have its RenderWidgetHosts 840 // focused WebContentsImpl, if any, will have its RenderWidgetHosts
820 // deactivated. 841 // deactivated.
821 void SetAsFocusedWebContentsIfNecessary(); 842 void SetAsFocusedWebContentsIfNecessary();
822 843
844 // Called by this WebContents's BrowserPluginGuest (if one exists) to indicate
845 // that the guest will be detached.
846 void BrowserPluginGuestWillDetach();
847
823 #if defined(OS_ANDROID) 848 #if defined(OS_ANDROID)
824 // Called by FindRequestManager when all of the find match rects are in. 849 // Called by FindRequestManager when all of the find match rects are in.
825 void NotifyFindMatchRectsReply(int version, 850 void NotifyFindMatchRectsReply(int version,
826 const std::vector<gfx::RectF>& rects, 851 const std::vector<gfx::RectF>& rects,
827 const gfx::RectF& active_rect); 852 const gfx::RectF& active_rect);
828 #endif 853 #endif
829 854
830 private: 855 private:
831 friend class WebContentsObserver; 856 friend class WebContentsObserver;
832 friend class WebContents; // To implement factory methods. 857 friend class WebContents; // To implement factory methods.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 913
889 WebContentsImpl* outer_web_contents() const { return outer_web_contents_; } 914 WebContentsImpl* outer_web_contents() const { return outer_web_contents_; }
890 int outer_contents_frame_tree_node_id() const { 915 int outer_contents_frame_tree_node_id() const {
891 return outer_contents_frame_tree_node_id_; 916 return outer_contents_frame_tree_node_id_;
892 } 917 }
893 FrameTreeNode* OuterContentsFrameTreeNode() const; 918 FrameTreeNode* OuterContentsFrameTreeNode() const;
894 919
895 WebContentsImpl* focused_web_contents() { return focused_web_contents_; } 920 WebContentsImpl* focused_web_contents() { return focused_web_contents_; }
896 void SetFocusedWebContents(WebContentsImpl* web_contents); 921 void SetFocusedWebContents(WebContentsImpl* web_contents);
897 922
923 // Returns the inner WebContents within |frame|, if one exists, or nullptr
924 // otherwise.
925 WebContentsImpl* GetInnerWebContentsInFrame(const FrameTreeNode* frame);
926
927 const std::vector<WebContentsImpl*>& inner_web_contents() const;
928
898 private: 929 private:
930 void AttachInnerWebContents(WebContentsImpl* inner_web_contents);
931 void DetachInnerWebContents(WebContentsImpl* inner_web_contents);
932
899 // FrameTreeNode::Observer implementation. 933 // FrameTreeNode::Observer implementation.
900 void OnFrameTreeNodeDestroyed(FrameTreeNode* node) final; 934 void OnFrameTreeNodeDestroyed(FrameTreeNode* node) final;
901 935
902 // The WebContents that owns this WebContentsTreeNode. 936 // The WebContents that owns this WebContentsTreeNode.
903 WebContentsImpl* const current_web_contents_; 937 WebContentsImpl* const current_web_contents_;
904 938
905 // The outer WebContents of |current_web_contents_|, or nullptr if 939 // The outer WebContents of |current_web_contents_|, or nullptr if
906 // |current_web_contents_| is the outermost WebContents. 940 // |current_web_contents_| is the outermost WebContents.
907 WebContentsImpl* outer_web_contents_; 941 WebContentsImpl* outer_web_contents_;
908 942
909 // The ID of the FrameTreeNode in the |outer_web_contents_| that hosts 943 // The ID of the FrameTreeNode in the |outer_web_contents_| that hosts
910 // |current_web_contents_| as an inner WebContents. 944 // |current_web_contents_| as an inner WebContents.
911 int outer_contents_frame_tree_node_id_; 945 int outer_contents_frame_tree_node_id_;
912 946
947 // List of inner WebContents that we host.
948 std::vector<WebContentsImpl*> inner_web_contents_;
949
913 // Only the root node should have this set. This indicates the WebContents 950 // Only the root node should have this set. This indicates the WebContents
914 // whose frame tree has the focused frame. The WebContents tree could be 951 // whose frame tree has the focused frame. The WebContents tree could be
915 // arbitrarily deep. 952 // arbitrarily deep.
916 WebContentsImpl* focused_web_contents_; 953 WebContentsImpl* focused_web_contents_;
917 }; 954 };
918 955
919 // See WebContents::Create for a description of these parameters. 956 // See WebContents::Create for a description of these parameters.
920 WebContentsImpl(BrowserContext* browser_context); 957 WebContentsImpl(BrowserContext* browser_context);
921 958
922 // Add and remove observers for page navigation notifications. The order in 959 // Add and remove observers for page navigation notifications. The order in
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 // 1117 //
1081 // These functions are helpers in managing a hierarchy of WebContents 1118 // These functions are helpers in managing a hierarchy of WebContents
1082 // involved in rendering inner WebContents. 1119 // involved in rendering inner WebContents.
1083 1120
1084 // When multiple WebContents are present within a tab or window, a single one 1121 // When multiple WebContents are present within a tab or window, a single one
1085 // is focused and will route keyboard events in most cases to a RenderWidget 1122 // is focused and will route keyboard events in most cases to a RenderWidget
1086 // contained within it. |GetFocusedWebContents()|'s main frame widget will 1123 // contained within it. |GetFocusedWebContents()|'s main frame widget will
1087 // receive page focus and blur events when the containing window changes focus 1124 // receive page focus and blur events when the containing window changes focus
1088 // state. 1125 // state.
1089 1126
1090 // Returns the focused WebContents.
1091 // If there are multiple inner/outer WebContents (when embedding <webview>,
1092 // <guestview>, ...) returns the single one containing the currently focused
1093 // frame. Otherwise, returns this WebContents.
1094 WebContentsImpl* GetFocusedWebContents();
1095
1096 // Returns true if |this| is the focused WebContents or an ancestor of the 1127 // Returns true if |this| is the focused WebContents or an ancestor of the
1097 // focused WebContents. 1128 // focused WebContents.
1098 bool ContainsOrIsFocusedWebContents(); 1129 bool ContainsOrIsFocusedWebContents();
1099 1130
1100 // Returns the root of the WebContents tree. 1131 // Returns the root of the WebContents tree.
1101 WebContentsImpl* GetOutermostWebContents(); 1132 WebContentsImpl* GetOutermostWebContents();
1102 1133
1103 // Navigation helpers -------------------------------------------------------- 1134 // Navigation helpers --------------------------------------------------------
1104 // 1135 //
1105 // These functions are helpers for Navigate() and DidNavigate(). 1136 // These functions are helpers for Navigate() and DidNavigate().
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 // Internal helper to create WebUI objects associated with |this|. |url| is 1217 // Internal helper to create WebUI objects associated with |this|. |url| is
1187 // used to determine which WebUI should be created (if any). |frame_name| 1218 // used to determine which WebUI should be created (if any). |frame_name|
1188 // corresponds to the name of a frame that the WebUI should be created for (or 1219 // corresponds to the name of a frame that the WebUI should be created for (or
1189 // the main frame if empty). 1220 // the main frame if empty).
1190 std::unique_ptr<WebUIImpl> CreateWebUI(const GURL& url, 1221 std::unique_ptr<WebUIImpl> CreateWebUI(const GURL& url,
1191 const std::string& frame_name); 1222 const std::string& frame_name);
1192 1223
1193 void SetJavaScriptDialogManagerForTesting( 1224 void SetJavaScriptDialogManagerForTesting(
1194 JavaScriptDialogManager* dialog_manager); 1225 JavaScriptDialogManager* dialog_manager);
1195 1226
1196 // Returns the FindRequestManager, or creates one if it doesn't already exist. 1227 // Returns the FindRequestManager, which may be found in an outer WebContents.
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.
1197 FindRequestManager* GetOrCreateFindRequestManager(); 1232 FindRequestManager* GetOrCreateFindRequestManager();
1198 1233
1199 // Removes a registered WebContentsBindingSet by interface name. 1234 // Removes a registered WebContentsBindingSet by interface name.
1200 void RemoveBindingSet(const std::string& interface_name); 1235 void RemoveBindingSet(const std::string& interface_name);
1201 1236
1202 // Prints a console warning when visiting a localhost site with a bad 1237 // Prints a console warning when visiting a localhost site with a bad
1203 // certificate via --allow-insecure-localhost. 1238 // certificate via --allow-insecure-localhost.
1204 void ShowInsecureLocalhostWarningIfNeeded(); 1239 void ShowInsecureLocalhostWarningIfNeeded();
1205 1240
1206 // Notify this WebContents that the preferences have changed. This will send 1241 // Notify this WebContents that the preferences have changed. This will send
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 // Adds/removes a callback called on creation of each new WebContents. 1592 // Adds/removes a callback called on creation of each new WebContents.
1558 static void AddCreatedCallbackForTesting(const CreatedCallback& callback); 1593 static void AddCreatedCallbackForTesting(const CreatedCallback& callback);
1559 static void RemoveCreatedCallbackForTesting(const CreatedCallback& callback); 1594 static void RemoveCreatedCallbackForTesting(const CreatedCallback& callback);
1560 1595
1561 DISALLOW_COPY_AND_ASSIGN(FriendWrapper); 1596 DISALLOW_COPY_AND_ASSIGN(FriendWrapper);
1562 }; 1597 };
1563 1598
1564 } // namespace content 1599 } // namespace content
1565 1600
1566 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ 1601 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/find_request_manager.cc ('k') | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698