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 // Initializes the first WebUI of the RenderFrameHost, if one is required by | |
481 // |dest_url|. No WebUI must have been set before and it must be called only | |
482 // once. If this is a history navigation to an existing NavigationEntry, | |
483 // providing its |entry_bindings| will allow verifying that bindings are not | |
484 // being set differently this time around. | |
485 void InitializeWebUI(const GURL& dest_url, int entry_bindings); | |
carlosk
2015/10/15 16:34:08
As the WebUIImpl::RenderView(Created|Reused) calls
| |
486 | |
487 // Updates the pending WebUI data of this RenderFrameHost based on the | |
488 // provided |dest_url|, setting to either none, a new instance or to reuse the | |
489 // current active one. The WebUI chosen here will be made active upon the next | |
490 // call to CommitPendingWebUI. | |
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. | |
495 void UpdatePendingWebUI(const GURL& dest_url, int entry_bindings); | |
496 | |
497 // Updates the active WebUI with the pending one set by the last call to | |
498 // UpdatePendingWebUI and then clears any pending data. If UpdatePendingWebUI | |
499 // was not called the active WebUI will simply be cleared. | |
500 void CommitPendingWebUI(); | |
501 | |
502 // Destroys the pending WebUI and cleans up any related data. | |
503 void DiscardPendingWebUI(); | |
504 | |
471 // Returns the Mojo ImageDownloader service. | 505 // Returns the Mojo ImageDownloader service. |
472 const image_downloader::ImageDownloaderPtr& GetMojoImageDownloader(); | 506 const image_downloader::ImageDownloaderPtr& GetMojoImageDownloader(); |
473 | 507 |
474 protected: | 508 protected: |
475 friend class RenderFrameHostFactory; | 509 friend class RenderFrameHostFactory; |
476 | 510 |
477 // |flags| is a combination of CreateRenderFrameFlags. | 511 // |flags| is a combination of CreateRenderFrameFlags. |
478 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost | 512 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost |
479 // should be the abstraction needed here, but we need RenderViewHost to pass | 513 // should be the abstraction needed here, but we need RenderViewHost to pass |
480 // into WebContentsObserver::FrameDetached for now. | 514 // into WebContentsObserver::FrameDetached for now. |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
615 RenderWidgetHostViewBase* GetViewForAccessibility(); | 649 RenderWidgetHostViewBase* GetViewForAccessibility(); |
616 | 650 |
617 // Sends a navigate message to the RenderFrame and notifies DevTools about | 651 // Sends a navigate message to the RenderFrame and notifies DevTools about |
618 // navigation happening. Should be used instead of sending the message | 652 // navigation happening. Should be used instead of sending the message |
619 // directly. | 653 // directly. |
620 void SendNavigateMessage( | 654 void SendNavigateMessage( |
621 const content::CommonNavigationParams& common_params, | 655 const content::CommonNavigationParams& common_params, |
622 const content::StartNavigationParams& start_params, | 656 const content::StartNavigationParams& start_params, |
623 const content::RequestNavigationParams& request_params); | 657 const content::RequestNavigationParams& request_params); |
624 | 658 |
659 // Creates a WebUI object for the given URL if one applies and sets | |
660 // |web_ui_type| to its type, also ensuring that its bindings match | |
661 // |entry_bindings|. If no WebUI applies, returns null and resets web_ui_type | |
662 // to WebUI::kNoWebUI. | |
663 scoped_ptr<WebUIImpl> CreateWebUI(const GURL& dest_url, | |
664 int entry_bindings, | |
665 WebUI::TypeID* web_ui_type); | |
666 | |
625 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a | 667 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a |
626 // refcount that calls Shutdown when it reaches zero. This allows each | 668 // refcount that calls Shutdown when it reaches zero. This allows each |
627 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring | 669 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring |
628 // we have a RenderViewHost for each RenderFrameHost. | 670 // we have a RenderViewHost for each RenderFrameHost. |
629 // TODO(creis): RenderViewHost will eventually go away and be replaced with | 671 // TODO(creis): RenderViewHost will eventually go away and be replaced with |
630 // some form of page context. | 672 // some form of page context. |
631 RenderViewHostImpl* render_view_host_; | 673 RenderViewHostImpl* render_view_host_; |
632 | 674 |
633 RenderFrameHostDelegate* delegate_; | 675 RenderFrameHostDelegate* delegate_; |
634 | 676 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
783 // Holder of Mojo connection with ImageDownloader service in RenderFrame. | 825 // Holder of Mojo connection with ImageDownloader service in RenderFrame. |
784 image_downloader::ImageDownloaderPtr mojo_image_downloader_; | 826 image_downloader::ImageDownloaderPtr mojo_image_downloader_; |
785 | 827 |
786 // Tracks a navigation happening in this frame. Note that while there can be | 828 // 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 | 829 // two navigations in the same FrameTreeNode, there can only be one |
788 // navigation per RenderFrameHost. | 830 // navigation per RenderFrameHost. |
789 // PlzNavigate: before the navigation is ready to be committed, the | 831 // PlzNavigate: before the navigation is ready to be committed, the |
790 // NavigationHandle for it is owned by the NavigationRequest. | 832 // NavigationHandle for it is owned by the NavigationRequest. |
791 scoped_ptr<NavigationHandleImpl> navigation_handle_; | 833 scoped_ptr<NavigationHandleImpl> navigation_handle_; |
792 | 834 |
835 // The associated WebUIImpl and its type. They will be set if the current | |
836 // document is from WebUI source. Otherwise they will be null and | |
837 // WebUI::kNoWebUI, respectively. | |
838 scoped_ptr<WebUIImpl> web_ui_; | |
839 WebUI::TypeID web_ui_type_; | |
840 | |
841 // Stores a pending WebUIImpl and its type. These will only be set during a | |
842 // same-site navigation to a WebUI page (reusing this RenderFrameHost). | |
843 scoped_ptr<WebUIImpl> pending_web_ui_; | |
844 WebUI::TypeID pending_web_ui_type_; | |
845 | |
846 // If true at commit time the current WebUI will simply be reused (no pending | |
847 // one will exist to be committed). | |
848 bool should_reuse_web_ui_; | |
849 | |
793 // NOTE: This must be the last member. | 850 // NOTE: This must be the last member. |
794 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; | 851 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; |
795 | 852 |
796 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); | 853 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); |
797 }; | 854 }; |
798 | 855 |
799 } // namespace content | 856 } // namespace content |
800 | 857 |
801 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 858 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
OLD | NEW |