| OLD | NEW |
| 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/site_instance_impl.h" | 18 #include "content/browser/site_instance_impl.h" |
| 19 #include "content/browser/webui/web_ui_impl.h" |
| 19 #include "content/common/accessibility_mode_enums.h" | 20 #include "content/common/accessibility_mode_enums.h" |
| 20 #include "content/common/ax_content_node_data.h" | 21 #include "content/common/ax_content_node_data.h" |
| 21 #include "content/common/content_export.h" | 22 #include "content/common/content_export.h" |
| 22 #include "content/common/frame_message_enums.h" | 23 #include "content/common/frame_message_enums.h" |
| 23 #include "content/common/frame_replication_state.h" | 24 #include "content/common/frame_replication_state.h" |
| 24 #include "content/common/image_downloader/image_downloader.mojom.h" | 25 #include "content/common/image_downloader/image_downloader.mojom.h" |
| 25 #include "content/common/mojo/service_registry_impl.h" | 26 #include "content/common/mojo/service_registry_impl.h" |
| 26 #include "content/common/navigation_params.h" | 27 #include "content/common/navigation_params.h" |
| 27 #include "content/public/browser/render_frame_host.h" | 28 #include "content/public/browser/render_frame_host.h" |
| 28 #include "content/public/common/javascript_message_type.h" | 29 #include "content/public/common/javascript_message_type.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 int routing_id() const { return routing_id_; } | 206 int routing_id() const { return routing_id_; } |
| 206 void OnCreateChildFrame(int new_routing_id, | 207 void OnCreateChildFrame(int new_routing_id, |
| 207 blink::WebTreeScopeType scope, | 208 blink::WebTreeScopeType scope, |
| 208 const std::string& frame_name, | 209 const std::string& frame_name, |
| 209 blink::WebSandboxFlags sandbox_flags); | 210 blink::WebSandboxFlags sandbox_flags); |
| 210 | 211 |
| 211 RenderViewHostImpl* render_view_host() { return render_view_host_; } | 212 RenderViewHostImpl* render_view_host() { return render_view_host_; } |
| 212 RenderFrameHostDelegate* delegate() { return delegate_; } | 213 RenderFrameHostDelegate* delegate() { return delegate_; } |
| 213 FrameTreeNode* frame_tree_node() { return frame_tree_node_; } | 214 FrameTreeNode* frame_tree_node() { return frame_tree_node_; } |
| 214 | 215 |
| 216 // Returns the associated active WebUI or nullptr if none applies. |
| 217 WebUIImpl* web_ui() const { return web_ui_.get(); } |
| 218 |
| 219 // Returns the pending WebUI, or nullptr of none applies. |
| 220 WebUIImpl* pending_web_ui() const { |
| 221 return should_reuse_web_ui_ ? web_ui_.get() : pending_web_ui_.get(); |
| 222 } |
| 223 |
| 215 // Returns this RenderFrameHost's loading state. This method is only used by | 224 // Returns this RenderFrameHost's loading state. This method is only used by |
| 216 // FrameTreeNode. The proper way to check whether a frame is loading is to | 225 // FrameTreeNode. The proper way to check whether a frame is loading is to |
| 217 // call FrameTreeNode::IsLoading. | 226 // call FrameTreeNode::IsLoading. |
| 218 bool is_loading() const { return is_loading_; } | 227 bool is_loading() const { return is_loading_; } |
| 219 | 228 |
| 220 // This returns the RenderFrameHost's owned RenderWidgetHost if it has one, | 229 // This returns the RenderFrameHost's owned RenderWidgetHost if it has one, |
| 221 // or else it returns nullptr. | 230 // or else it returns nullptr. |
| 222 // If the RenderFrameHost is the page's main frame, this returns instead a | 231 // If the RenderFrameHost is the page's main frame, this returns instead a |
| 223 // pointer to the RenderViewHost (which inherits RenderWidgetHost). | 232 // pointer to the RenderViewHost (which inherits RenderWidgetHost). |
| 224 RenderWidgetHostImpl* GetRenderWidgetHost(); | 233 RenderWidgetHostImpl* GetRenderWidgetHost(); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 | 466 |
| 458 // Tears down the browser-side state relating to the Mojo connection between | 467 // Tears down the browser-side state relating to the Mojo connection between |
| 459 // this instance and its associated render frame. | 468 // this instance and its associated render frame. |
| 460 void InvalidateMojoConnection(); | 469 void InvalidateMojoConnection(); |
| 461 | 470 |
| 462 // Returns whether the frame is focused. A frame is considered focused when it | 471 // Returns whether the frame is focused. A frame is considered focused when it |
| 463 // is the parent chain of the focused frame within the frame tree. In | 472 // is the parent chain of the focused frame within the frame tree. In |
| 464 // addition, its associated RenderWidgetHost has to be focused. | 473 // addition, its associated RenderWidgetHost has to be focused. |
| 465 bool IsFocused(); | 474 bool IsFocused(); |
| 466 | 475 |
| 476 // Updates the pending WebUI data of this RenderFrameHost depending on the |
| 477 // provided |dest_url|. If it doesn't demand a WebUI, the pending one is |
| 478 // cleared. If a new WebUI is required and its type matches the existing |
| 479 // pending one it will be reused. If the type matches the active one then the |
| 480 // pending is cleared and the current one is set to be reused. Otherwise a new |
| 481 // pending WebUI instance is set. |
| 482 // If this is a history navigation its bindings from the NavigationEntry |
| 483 // should be provided through |entry_bindings|. It will allow verifying that |
| 484 // bindings are not being set differently this time around. Otherwise |
| 485 // |entry_bindings| should be set to NavigationEntryImpl::kInvalidBindings. |
| 486 void UpdatePendingWebUI(const GURL& dest_url, int entry_bindings); |
| 487 |
| 488 // Updates the active WebUI with the pending data set by the last call to |
| 489 // UpdatePendingWebUI and then clears any pending data. If UpdatePendingWebUI |
| 490 // was not called the active WebUI will simply be cleared. |
| 491 void CommitPendingWebUI(); |
| 492 |
| 493 // Destroys the pending WebUI and cleans up any related data. |
| 494 void DiscardPendingWebUI(); |
| 495 |
| 467 // Returns the Mojo ImageDownloader service. | 496 // Returns the Mojo ImageDownloader service. |
| 468 const image_downloader::ImageDownloaderPtr& GetMojoImageDownloader(); | 497 const image_downloader::ImageDownloaderPtr& GetMojoImageDownloader(); |
| 469 | 498 |
| 470 protected: | 499 protected: |
| 471 friend class RenderFrameHostFactory; | 500 friend class RenderFrameHostFactory; |
| 472 | 501 |
| 473 // |flags| is a combination of CreateRenderFrameFlags. | 502 // |flags| is a combination of CreateRenderFrameFlags. The |dest_url| and |
| 503 // |entry_bindings| parameters are used to create an associated WebUI if one |
| 504 // is required (see UpdatePendingWebUI for further details). |
| 474 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost | 505 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost |
| 475 // should be the abstraction needed here, but we need RenderViewHost to pass | 506 // should be the abstraction needed here, but we need RenderViewHost to pass |
| 476 // into WebContentsObserver::FrameDetached for now. | 507 // into WebContentsObserver::FrameDetached for now. |
| 477 RenderFrameHostImpl(SiteInstance* site_instance, | 508 RenderFrameHostImpl(SiteInstance* site_instance, |
| 478 RenderViewHostImpl* render_view_host, | 509 RenderViewHostImpl* render_view_host, |
| 479 RenderFrameHostDelegate* delegate, | 510 RenderFrameHostDelegate* delegate, |
| 480 RenderWidgetHostDelegate* rwh_delegate, | 511 RenderWidgetHostDelegate* rwh_delegate, |
| 481 FrameTree* frame_tree, | 512 FrameTree* frame_tree, |
| 482 FrameTreeNode* frame_tree_node, | 513 FrameTreeNode* frame_tree_node, |
| 483 int32 routing_id, | 514 int32 routing_id, |
| 484 int32 widget_routing_id, | 515 int32 widget_routing_id, |
| 485 int flags); | 516 int flags, |
| 517 const GURL& dest_url, |
| 518 int entry_bindings); |
| 486 | 519 |
| 487 private: | 520 private: |
| 488 friend class TestRenderFrameHost; | 521 friend class TestRenderFrameHost; |
| 489 friend class TestRenderViewHost; | 522 friend class TestRenderViewHost; |
| 490 | 523 |
| 491 FRIEND_TEST_ALL_PREFIXES(SitePerProcessBrowserTest, CrashSubframe); | 524 FRIEND_TEST_ALL_PREFIXES(SitePerProcessBrowserTest, CrashSubframe); |
| 492 | 525 |
| 493 // IPC Message handlers. | 526 // IPC Message handlers. |
| 494 void OnAddMessageToConsole(int32 level, | 527 void OnAddMessageToConsole(int32 level, |
| 495 const base::string16& message, | 528 const base::string16& message, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 // Convert the content-layer-specific AXContentNodeData to a general-purpose | 636 // Convert the content-layer-specific AXContentNodeData to a general-purpose |
| 604 // AXNodeData structure. | 637 // AXNodeData structure. |
| 605 void AXContentNodeDataToAXNodeData(const AXContentNodeData& src, | 638 void AXContentNodeDataToAXNodeData(const AXContentNodeData& src, |
| 606 ui::AXNodeData* dst); | 639 ui::AXNodeData* dst); |
| 607 | 640 |
| 608 // Returns the RenderWidgetHostView used for accessibility. For subframes, | 641 // Returns the RenderWidgetHostView used for accessibility. For subframes, |
| 609 // this function will return the platform view on the main frame; for main | 642 // this function will return the platform view on the main frame; for main |
| 610 // frames, it will return the current frame's view. | 643 // frames, it will return the current frame's view. |
| 611 RenderWidgetHostViewBase* GetViewForAccessibility(); | 644 RenderWidgetHostViewBase* GetViewForAccessibility(); |
| 612 | 645 |
| 646 // Creates a WebUI object for the given URL if one applies and sets |
| 647 // |web_ui_type| to its type, also ensuring that its bindings match |
| 648 // |entry_bindings| (if provided and different than |
| 649 // NavigationEntryImpl::kInvalidBindings). If no WebUI applies, returns |
| 650 // nullptr and resets web_ui_type to WebUI::kNoWebUI. . |
| 651 scoped_ptr<WebUIImpl> CreateWebUI(const GURL& dest_url, |
| 652 int entry_bindings, |
| 653 WebUI::TypeID* web_ui_type); |
| 654 |
| 613 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a | 655 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a |
| 614 // refcount that calls Shutdown when it reaches zero. This allows each | 656 // refcount that calls Shutdown when it reaches zero. This allows each |
| 615 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring | 657 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring |
| 616 // we have a RenderViewHost for each RenderFrameHost. | 658 // we have a RenderViewHost for each RenderFrameHost. |
| 617 // TODO(creis): RenderViewHost will eventually go away and be replaced with | 659 // TODO(creis): RenderViewHost will eventually go away and be replaced with |
| 618 // some form of page context. | 660 // some form of page context. |
| 619 RenderViewHostImpl* render_view_host_; | 661 RenderViewHostImpl* render_view_host_; |
| 620 | 662 |
| 621 RenderFrameHostDelegate* delegate_; | 663 RenderFrameHostDelegate* delegate_; |
| 622 | 664 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 // Holder of Mojo connection with ImageDownloader service in RenderFrame. | 813 // Holder of Mojo connection with ImageDownloader service in RenderFrame. |
| 772 image_downloader::ImageDownloaderPtr mojo_image_downloader_; | 814 image_downloader::ImageDownloaderPtr mojo_image_downloader_; |
| 773 | 815 |
| 774 // Tracks a navigation happening in this frame. Note that while there can be | 816 // Tracks a navigation happening in this frame. Note that while there can be |
| 775 // two navigations in the same FrameTreeNode, there can only be one | 817 // two navigations in the same FrameTreeNode, there can only be one |
| 776 // navigation per RenderFrameHost. | 818 // navigation per RenderFrameHost. |
| 777 // PlzNavigate: before the navigation is ready to be committed, the | 819 // PlzNavigate: before the navigation is ready to be committed, the |
| 778 // NavigationHandle for it is owned by the NavigationRequest. | 820 // NavigationHandle for it is owned by the NavigationRequest. |
| 779 scoped_ptr<NavigationHandleImpl> navigation_handle_; | 821 scoped_ptr<NavigationHandleImpl> navigation_handle_; |
| 780 | 822 |
| 823 // The associated WebUIImpl and its type. They will be set if the current page |
| 824 // is a WebUI page. Otherwise they will be nullptr and WebUI::kNoWebUI, |
| 825 // respectively. |
| 826 scoped_ptr<WebUIImpl> web_ui_; |
| 827 WebUI::TypeID web_ui_type_; |
| 828 |
| 829 // Stores a pending WebUIImpl and its type. These will only be set during a |
| 830 // same-site navigation to a WebUI page (reusing this RenderFrameHost). |
| 831 scoped_ptr<WebUIImpl> pending_web_ui_; |
| 832 WebUI::TypeID pending_web_ui_type_; |
| 833 |
| 834 // If true at commit time the current WebUI will simply be reused (no pending |
| 835 // one will exist to be committed). |
| 836 bool should_reuse_web_ui_; |
| 837 |
| 781 // NOTE: This must be the last member. | 838 // NOTE: This must be the last member. |
| 782 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; | 839 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; |
| 783 | 840 |
| 784 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); | 841 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); |
| 785 }; | 842 }; |
| 786 | 843 |
| 787 } // namespace content | 844 } // namespace content |
| 788 | 845 |
| 789 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 846 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
| OLD | NEW |