| 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 int routing_id() const { return routing_id_; } | 207 int routing_id() const { return routing_id_; } |
| 207 void OnCreateChildFrame(int new_routing_id, | 208 void OnCreateChildFrame(int new_routing_id, |
| 208 blink::WebTreeScopeType scope, | 209 blink::WebTreeScopeType scope, |
| 209 const std::string& frame_name, | 210 const std::string& frame_name, |
| 210 blink::WebSandboxFlags sandbox_flags); | 211 blink::WebSandboxFlags sandbox_flags); |
| 211 | 212 |
| 212 RenderViewHostImpl* render_view_host() { return render_view_host_; } | 213 RenderViewHostImpl* render_view_host() { return render_view_host_; } |
| 213 RenderFrameHostDelegate* delegate() { return delegate_; } | 214 RenderFrameHostDelegate* delegate() { return delegate_; } |
| 214 FrameTreeNode* frame_tree_node() { return frame_tree_node_; } | 215 FrameTreeNode* frame_tree_node() { return frame_tree_node_; } |
| 215 | 216 |
| 217 // Returns the associated active WebUI or null if none applies. |
| 218 WebUIImpl* web_ui() const { return web_ui_.get(); } |
| 219 |
| 220 // Returns the pending WebUI, or null of none applies. |
| 221 WebUIImpl* pending_web_ui() const { |
| 222 return should_reuse_web_ui_ ? web_ui_.get() : pending_web_ui_.get(); |
| 223 } |
| 224 |
| 216 // Returns this RenderFrameHost's loading state. This method is only used by | 225 // Returns this RenderFrameHost's loading state. This method is only used by |
| 217 // FrameTreeNode. The proper way to check whether a frame is loading is to | 226 // FrameTreeNode. The proper way to check whether a frame is loading is to |
| 218 // call FrameTreeNode::IsLoading. | 227 // call FrameTreeNode::IsLoading. |
| 219 bool is_loading() const { return is_loading_; } | 228 bool is_loading() const { return is_loading_; } |
| 220 | 229 |
| 221 // This returns the RenderFrameHost's owned RenderWidgetHost if it has one, | 230 // This returns the RenderFrameHost's owned RenderWidgetHost if it has one, |
| 222 // or else it returns nullptr. | 231 // or else it returns nullptr. |
| 223 // If the RenderFrameHost is the page's main frame, this returns instead a | 232 // If the RenderFrameHost is the page's main frame, this returns instead a |
| 224 // pointer to the RenderViewHost (which inherits RenderWidgetHost). | 233 // pointer to the RenderViewHost (which inherits RenderWidgetHost). |
| 225 RenderWidgetHostImpl* GetRenderWidgetHost(); | 234 RenderWidgetHostImpl* GetRenderWidgetHost(); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 | 470 |
| 462 // Tears down the browser-side state relating to the Mojo connection between | 471 // Tears down the browser-side state relating to the Mojo connection between |
| 463 // this instance and its associated render frame. | 472 // this instance and its associated render frame. |
| 464 void InvalidateMojoConnection(); | 473 void InvalidateMojoConnection(); |
| 465 | 474 |
| 466 // Returns whether the frame is focused. A frame is considered focused when it | 475 // Returns whether the frame is focused. A frame is considered focused when it |
| 467 // is the parent chain of the focused frame within the frame tree. In | 476 // is the parent chain of the focused frame within the frame tree. In |
| 468 // addition, its associated RenderWidgetHost has to be focused. | 477 // addition, its associated RenderWidgetHost has to be focused. |
| 469 bool IsFocused(); | 478 bool IsFocused(); |
| 470 | 479 |
| 480 // Updates the pending WebUI data of this RenderFrameHost based on the |
| 481 // provided |dest_url|, setting to either none, a new instance or to reuse the |
| 482 // current active one. The WebUI chosen here will be made active upon the next |
| 483 // call to CommitPendingWebUI. |
| 484 // If this is a history navigation its NavigationEntry bindings should be |
| 485 // provided through |entry_bindings| to allow verifying that they are not |
| 486 // being set differently this time around. Otherwise |entry_bindings| should |
| 487 // be set to NavigationEntryImpl::kInvalidBindings. |
| 488 void UpdatePendingWebUI(const GURL& dest_url, int entry_bindings); |
| 489 |
| 490 // Updates the active WebUI with the pending one set by the last call to |
| 491 // UpdatePendingWebUI and then clears any pending data. If UpdatePendingWebUI |
| 492 // was not called the active WebUI will simply be cleared. |
| 493 void CommitPendingWebUI(); |
| 494 |
| 495 // Destroys the pending WebUI and cleans up any related data. |
| 496 void DiscardPendingWebUI(); |
| 497 |
| 471 // Returns the Mojo ImageDownloader service. | 498 // Returns the Mojo ImageDownloader service. |
| 472 const image_downloader::ImageDownloaderPtr& GetMojoImageDownloader(); | 499 const image_downloader::ImageDownloaderPtr& GetMojoImageDownloader(); |
| 473 | 500 |
| 474 protected: | 501 protected: |
| 475 friend class RenderFrameHostFactory; | 502 friend class RenderFrameHostFactory; |
| 476 | 503 |
| 477 // |flags| is a combination of CreateRenderFrameFlags. | 504 // |flags| is a combination of CreateRenderFrameFlags. |
| 478 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost | 505 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost |
| 479 // 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 |
| 480 // into WebContentsObserver::FrameDetached for now. | 507 // into WebContentsObserver::FrameDetached for now. |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 RenderWidgetHostViewBase* GetViewForAccessibility(); | 642 RenderWidgetHostViewBase* GetViewForAccessibility(); |
| 616 | 643 |
| 617 // Sends a navigate message to the RenderFrame and notifies DevTools about | 644 // Sends a navigate message to the RenderFrame and notifies DevTools about |
| 618 // navigation happening. Should be used instead of sending the message | 645 // navigation happening. Should be used instead of sending the message |
| 619 // directly. | 646 // directly. |
| 620 void SendNavigateMessage( | 647 void SendNavigateMessage( |
| 621 const content::CommonNavigationParams& common_params, | 648 const content::CommonNavigationParams& common_params, |
| 622 const content::StartNavigationParams& start_params, | 649 const content::StartNavigationParams& start_params, |
| 623 const content::RequestNavigationParams& request_params); | 650 const content::RequestNavigationParams& request_params); |
| 624 | 651 |
| 652 // Creates a WebUI object for the given URL if one applies and sets |
| 653 // |web_ui_type| to its type, also ensuring that its bindings match |
| 654 // |entry_bindings|. If no WebUI applies, returns null and resets web_ui_type |
| 655 // to WebUI::kNoWebUI. |
| 656 scoped_ptr<WebUIImpl> CreateWebUI(const GURL& dest_url, |
| 657 int entry_bindings, |
| 658 WebUI::TypeID* web_ui_type); |
| 659 |
| 625 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a | 660 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a |
| 626 // refcount that calls Shutdown when it reaches zero. This allows each | 661 // refcount that calls Shutdown when it reaches zero. This allows each |
| 627 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring | 662 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring |
| 628 // we have a RenderViewHost for each RenderFrameHost. | 663 // we have a RenderViewHost for each RenderFrameHost. |
| 629 // TODO(creis): RenderViewHost will eventually go away and be replaced with | 664 // TODO(creis): RenderViewHost will eventually go away and be replaced with |
| 630 // some form of page context. | 665 // some form of page context. |
| 631 RenderViewHostImpl* render_view_host_; | 666 RenderViewHostImpl* render_view_host_; |
| 632 | 667 |
| 633 RenderFrameHostDelegate* delegate_; | 668 RenderFrameHostDelegate* delegate_; |
| 634 | 669 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 // Holder of Mojo connection with ImageDownloader service in RenderFrame. | 818 // Holder of Mojo connection with ImageDownloader service in RenderFrame. |
| 784 image_downloader::ImageDownloaderPtr mojo_image_downloader_; | 819 image_downloader::ImageDownloaderPtr mojo_image_downloader_; |
| 785 | 820 |
| 786 // Tracks a navigation happening in this frame. Note that while there can be | 821 // Tracks a navigation happening in this frame. Note that while there can be |
| 787 // two navigations in the same FrameTreeNode, there can only be one | 822 // two navigations in the same FrameTreeNode, there can only be one |
| 788 // navigation per RenderFrameHost. | 823 // navigation per RenderFrameHost. |
| 789 // PlzNavigate: before the navigation is ready to be committed, the | 824 // PlzNavigate: before the navigation is ready to be committed, the |
| 790 // NavigationHandle for it is owned by the NavigationRequest. | 825 // NavigationHandle for it is owned by the NavigationRequest. |
| 791 scoped_ptr<NavigationHandleImpl> navigation_handle_; | 826 scoped_ptr<NavigationHandleImpl> navigation_handle_; |
| 792 | 827 |
| 828 // The associated WebUIImpl and its type. They will be set if the current |
| 829 // document is from WebUI source. Otherwise they will be null and |
| 830 // WebUI::kNoWebUI, respectively. |
| 831 scoped_ptr<WebUIImpl> web_ui_; |
| 832 WebUI::TypeID web_ui_type_; |
| 833 |
| 834 // Stores a pending WebUIImpl and its type. These will only be set during a |
| 835 // same-site navigation to a WebUI page (reusing this RenderFrameHost). |
| 836 scoped_ptr<WebUIImpl> pending_web_ui_; |
| 837 WebUI::TypeID pending_web_ui_type_; |
| 838 |
| 839 // If true at commit time the current WebUI will simply be reused (no pending |
| 840 // one will exist to be committed). |
| 841 bool should_reuse_web_ui_; |
| 842 |
| 793 // NOTE: This must be the last member. | 843 // NOTE: This must be the last member. |
| 794 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; | 844 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; |
| 795 | 845 |
| 796 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); | 846 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); |
| 797 }; | 847 }; |
| 798 | 848 |
| 799 } // namespace content | 849 } // namespace content |
| 800 | 850 |
| 801 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 851 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
| OLD | NEW |