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

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.h

Issue 1426403006: Reland #1 of: Move WebUI ownership from the RenderFrameHostManager to the RenderFrameHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 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 <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "content/browser/accessibility/browser_accessibility_manager.h" 17 #include "content/browser/accessibility/browser_accessibility_manager.h"
18 #include "content/browser/bad_message.h" 18 #include "content/browser/bad_message.h"
19 #include "content/browser/site_instance_impl.h" 19 #include "content/browser/site_instance_impl.h"
20 #include "content/browser/webui/web_ui_impl.h"
20 #include "content/common/accessibility_mode_enums.h" 21 #include "content/common/accessibility_mode_enums.h"
21 #include "content/common/ax_content_node_data.h" 22 #include "content/common/ax_content_node_data.h"
22 #include "content/common/content_export.h" 23 #include "content/common/content_export.h"
23 #include "content/common/frame_message_enums.h" 24 #include "content/common/frame_message_enums.h"
24 #include "content/common/frame_replication_state.h" 25 #include "content/common/frame_replication_state.h"
25 #include "content/common/image_downloader/image_downloader.mojom.h" 26 #include "content/common/image_downloader/image_downloader.mojom.h"
26 #include "content/common/mojo/service_registry_impl.h" 27 #include "content/common/mojo/service_registry_impl.h"
27 #include "content/common/navigation_params.h" 28 #include "content/common/navigation_params.h"
28 #include "content/public/browser/render_frame_host.h" 29 #include "content/public/browser/render_frame_host.h"
29 #include "content/public/common/javascript_message_type.h" 30 #include "content/public/common/javascript_message_type.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 int new_routing_id, 212 int new_routing_id,
212 blink::WebTreeScopeType scope, 213 blink::WebTreeScopeType scope,
213 const std::string& frame_name, 214 const std::string& frame_name,
214 blink::WebSandboxFlags sandbox_flags, 215 blink::WebSandboxFlags sandbox_flags,
215 const blink::WebFrameOwnerProperties& frame_owner_properties); 216 const blink::WebFrameOwnerProperties& frame_owner_properties);
216 217
217 RenderViewHostImpl* render_view_host() { return render_view_host_; } 218 RenderViewHostImpl* render_view_host() { return render_view_host_; }
218 RenderFrameHostDelegate* delegate() { return delegate_; } 219 RenderFrameHostDelegate* delegate() { return delegate_; }
219 FrameTreeNode* frame_tree_node() { return frame_tree_node_; } 220 FrameTreeNode* frame_tree_node() { return frame_tree_node_; }
220 221
222 // Returns the associated WebUI or null if none applies.
223 WebUIImpl* web_ui() const { return web_ui_.get(); }
224
225 // Returns the associated WebUI type.
226 WebUI::TypeID web_ui_type() const { return web_ui_type_; }
227
221 // Returns this RenderFrameHost's loading state. This method is only used by 228 // Returns this RenderFrameHost's loading state. This method is only used by
222 // FrameTreeNode. The proper way to check whether a frame is loading is to 229 // FrameTreeNode. The proper way to check whether a frame is loading is to
223 // call FrameTreeNode::IsLoading. 230 // call FrameTreeNode::IsLoading.
224 bool is_loading() const { return is_loading_; } 231 bool is_loading() const { return is_loading_; }
225 232
226 // This returns the RenderFrameHost's owned RenderWidgetHost if it has one, 233 // This returns the RenderFrameHost's owned RenderWidgetHost if it has one,
227 // or else it returns nullptr. 234 // or else it returns nullptr.
228 // If the RenderFrameHost is the page's main frame, this returns instead a 235 // If the RenderFrameHost is the page's main frame, this returns instead a
229 // pointer to the RenderViewHost (which inherits RenderWidgetHost). 236 // pointer to the RenderViewHost (which inherits RenderWidgetHost).
230 RenderWidgetHostImpl* GetRenderWidgetHost(); 237 RenderWidgetHostImpl* GetRenderWidgetHost();
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 478
472 // Tears down the browser-side state relating to the Mojo connection between 479 // Tears down the browser-side state relating to the Mojo connection between
473 // this instance and its associated render frame. 480 // this instance and its associated render frame.
474 void InvalidateMojoConnection(); 481 void InvalidateMojoConnection();
475 482
476 // Returns whether the frame is focused. A frame is considered focused when it 483 // Returns whether the frame is focused. A frame is considered focused when it
477 // is the parent chain of the focused frame within the frame tree. In 484 // is the parent chain of the focused frame within the frame tree. In
478 // addition, its associated RenderWidgetHost has to be focused. 485 // addition, its associated RenderWidgetHost has to be focused.
479 bool IsFocused(); 486 bool IsFocused();
480 487
488 // Updates the WebUI of this RenderFrameHost based on the provided |dest_url|,
489 // setting it to either none, a new instance or simply reuses the currently
Charlie Reis 2015/11/09 07:01:00 This sounds like it's stale, or it should be. A R
carlosk 2015/11/10 15:02:30 Changing this method so that it works like that is
Charlie Reis 2015/11/11 01:11:00 From the perspective of security, we shouldn't be
carlosk 2015/11/13 16:43:53 Acknowledged x2.
490 // existing one. Returns true if a WebUI change occurred.
491 // If this is a history navigation its NavigationEntry bindings should be
492 // provided through |entry_bindings| to allow verifying that they are not
493 // being set differently this time around. Otherwise |entry_bindings| should
494 // be set to NavigationEntryImpl::kInvalidBindings so that no checks are done.
495 bool UpdateWebUI(const GURL& dest_url, int entry_bindings);
496
481 // Returns the Mojo ImageDownloader service. 497 // Returns the Mojo ImageDownloader service.
482 const image_downloader::ImageDownloaderPtr& GetMojoImageDownloader(); 498 const image_downloader::ImageDownloaderPtr& GetMojoImageDownloader();
483 499
484 protected: 500 protected:
485 friend class RenderFrameHostFactory; 501 friend class RenderFrameHostFactory;
486 502
487 // |flags| is a combination of CreateRenderFrameFlags. 503 // |flags| is a combination of CreateRenderFrameFlags.
488 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost 504 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost
489 // should be the abstraction needed here, but we need RenderViewHost to pass 505 // should be the abstraction needed here, but we need RenderViewHost to pass
490 // into WebContentsObserver::FrameDetached for now. 506 // into WebContentsObserver::FrameDetached for now.
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 const content::StartNavigationParams& start_params, 657 const content::StartNavigationParams& start_params,
642 const content::RequestNavigationParams& request_params); 658 const content::RequestNavigationParams& request_params);
643 659
644 // Returns the child FrameTreeNode if |child_frame_routing_id| is an 660 // Returns the child FrameTreeNode if |child_frame_routing_id| is an
645 // immediate child of this FrameTreeNode. |child_frame_routing_id| is 661 // immediate child of this FrameTreeNode. |child_frame_routing_id| is
646 // considered untrusted, so the renderer process is killed if it refers to a 662 // considered untrusted, so the renderer process is killed if it refers to a
647 // FrameTreeNode that is not a child of this node. 663 // FrameTreeNode that is not a child of this node.
648 FrameTreeNode* FindAndVerifyChild( 664 FrameTreeNode* FindAndVerifyChild(
649 int32 child_frame_routing_id, bad_message::BadMessageReason reason); 665 int32 child_frame_routing_id, bad_message::BadMessageReason reason);
650 666
667 // Resets all WebUI related fields.
668 void ResetWebUI();
669
651 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a 670 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a
652 // refcount that calls Shutdown when it reaches zero. This allows each 671 // refcount that calls Shutdown when it reaches zero. This allows each
653 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring 672 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring
654 // we have a RenderViewHost for each RenderFrameHost. 673 // we have a RenderViewHost for each RenderFrameHost.
655 // TODO(creis): RenderViewHost will eventually go away and be replaced with 674 // TODO(creis): RenderViewHost will eventually go away and be replaced with
656 // some form of page context. 675 // some form of page context.
657 RenderViewHostImpl* render_view_host_; 676 RenderViewHostImpl* render_view_host_;
658 677
659 RenderFrameHostDelegate* delegate_; 678 RenderFrameHostDelegate* delegate_;
660 679
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 // Holder of Mojo connection with ImageDownloader service in RenderFrame. 835 // Holder of Mojo connection with ImageDownloader service in RenderFrame.
817 image_downloader::ImageDownloaderPtr mojo_image_downloader_; 836 image_downloader::ImageDownloaderPtr mojo_image_downloader_;
818 837
819 // Tracks a navigation happening in this frame. Note that while there can be 838 // Tracks a navigation happening in this frame. Note that while there can be
820 // two navigations in the same FrameTreeNode, there can only be one 839 // two navigations in the same FrameTreeNode, there can only be one
821 // navigation per RenderFrameHost. 840 // navigation per RenderFrameHost.
822 // PlzNavigate: before the navigation is ready to be committed, the 841 // PlzNavigate: before the navigation is ready to be committed, the
823 // NavigationHandle for it is owned by the NavigationRequest. 842 // NavigationHandle for it is owned by the NavigationRequest.
824 scoped_ptr<NavigationHandleImpl> navigation_handle_; 843 scoped_ptr<NavigationHandleImpl> navigation_handle_;
825 844
845 // The associated WebUIImpl and its type. They will be set if the current
846 // document or the one being navigated to is from WebUI source. Otherwise they
847 // will be null and WebUI::kNoWebUI, respectively.
848 scoped_ptr<WebUIImpl> web_ui_;
849 WebUI::TypeID web_ui_type_;
850
826 // NOTE: This must be the last member. 851 // NOTE: This must be the last member.
827 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; 852 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_;
828 853
829 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); 854 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl);
830 }; 855 };
831 856
832 } // namespace content 857 } // namespace content
833 858
834 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ 859 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698