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 Web UI or nullptr if none applies. | |
217 WebUIImpl* web_ui() const { return web_ui_.get(); } | |
218 | |
219 // Returns the pending associated Web UI, 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 // Initializes the first WebUI for a recently created RenderFrameHost, if one | |
477 // is required by |dest_url|. No WebUI must have been set before and it must | |
478 // be called only once. If this is a history navigation to an existing | |
479 // NavigationEntry, providing its |past_bindings| will allow verifying that | |
480 // bindings are not being set differently this time around. | |
clamy
2015/10/01 13:15:13
If it's not a history entry, what should the value
carlosk
2015/10/01 16:00:22
This method was removed.
| |
481 void InitializeWebUI(const GURL& dest_url, int past_bindings); | |
482 | |
483 // Creates or replaces the pending WebUI for this RFH. Same logic from | |
484 // InitializeWebUI applies for the provided parameters. If the new WebUI to be | |
485 // created matches the current active or existing existing ones, they will be | |
486 // reused. | |
clamy
2015/10/01 13:15:13
Should you also provide past bindings when navigat
carlosk
2015/10/01 16:00:22
I improved all WebUI methods comments to make them
| |
487 void UpdatePendingWebUI(const GURL& dest_url, int past_bindings); | |
488 | |
489 // Replaces the active WebUI with the pending one. | |
490 void CommitPendingWebUI(); | |
491 | |
492 // Destroy the pending WebUI and cleans up any related data. | |
493 void DiscardPendingWebUI(); | |
494 | |
467 // Returns the Mojo ImageDownloader service. | 495 // Returns the Mojo ImageDownloader service. |
468 const image_downloader::ImageDownloaderPtr& GetMojoImageDownloader(); | 496 const image_downloader::ImageDownloaderPtr& GetMojoImageDownloader(); |
469 | 497 |
470 protected: | 498 protected: |
471 friend class RenderFrameHostFactory; | 499 friend class RenderFrameHostFactory; |
472 | 500 |
473 // |flags| is a combination of CreateRenderFrameFlags. | 501 // |flags| is a combination of CreateRenderFrameFlags. |
474 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost | 502 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost |
475 // should be the abstraction needed here, but we need RenderViewHost to pass | 503 // should be the abstraction needed here, but we need RenderViewHost to pass |
476 // into WebContentsObserver::FrameDetached for now. | 504 // into WebContentsObserver::FrameDetached for now. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
603 // Convert the content-layer-specific AXContentNodeData to a general-purpose | 631 // Convert the content-layer-specific AXContentNodeData to a general-purpose |
604 // AXNodeData structure. | 632 // AXNodeData structure. |
605 void AXContentNodeDataToAXNodeData(const AXContentNodeData& src, | 633 void AXContentNodeDataToAXNodeData(const AXContentNodeData& src, |
606 ui::AXNodeData* dst); | 634 ui::AXNodeData* dst); |
607 | 635 |
608 // Returns the RenderWidgetHostView used for accessibility. For subframes, | 636 // Returns the RenderWidgetHostView used for accessibility. For subframes, |
609 // this function will return the platform view on the main frame; for main | 637 // this function will return the platform view on the main frame; for main |
610 // frames, it will return the current frame's view. | 638 // frames, it will return the current frame's view. |
611 RenderWidgetHostViewBase* GetViewForAccessibility(); | 639 RenderWidgetHostViewBase* GetViewForAccessibility(); |
612 | 640 |
641 // Creates a WebUI object for the given URL if one applies and sets | |
642 // |web_ui_type| to its type, also ensuring that its bindings match | |
643 // |past_bindings| (if provided and different than | |
644 // NavigationEntryImpl::kInvalidBindings). If no WebUI applies, returns | |
645 // nullptr and resets web_ui_type to WebUI::kNoWebUI. . | |
646 scoped_ptr<WebUIImpl> CreateWebUI(const GURL& dest_url, | |
647 int past_bindings, | |
648 WebUI::TypeID* web_ui_type); | |
649 | |
613 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a | 650 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a |
614 // refcount that calls Shutdown when it reaches zero. This allows each | 651 // refcount that calls Shutdown when it reaches zero. This allows each |
615 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring | 652 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring |
616 // we have a RenderViewHost for each RenderFrameHost. | 653 // we have a RenderViewHost for each RenderFrameHost. |
617 // TODO(creis): RenderViewHost will eventually go away and be replaced with | 654 // TODO(creis): RenderViewHost will eventually go away and be replaced with |
618 // some form of page context. | 655 // some form of page context. |
619 RenderViewHostImpl* render_view_host_; | 656 RenderViewHostImpl* render_view_host_; |
620 | 657 |
621 RenderFrameHostDelegate* delegate_; | 658 RenderFrameHostDelegate* delegate_; |
622 | 659 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
771 // Holder of Mojo connection with ImageDownloader service in RenderFrame. | 808 // Holder of Mojo connection with ImageDownloader service in RenderFrame. |
772 image_downloader::ImageDownloaderPtr mojo_image_downloader_; | 809 image_downloader::ImageDownloaderPtr mojo_image_downloader_; |
773 | 810 |
774 // Tracks a navigation happening in this frame. Note that while there can be | 811 // 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 | 812 // two navigations in the same FrameTreeNode, there can only be one |
776 // navigation per RenderFrameHost. | 813 // navigation per RenderFrameHost. |
777 // PlzNavigate: before the navigation is ready to be committed, the | 814 // PlzNavigate: before the navigation is ready to be committed, the |
778 // NavigationHandle for it is owned by the NavigationRequest. | 815 // NavigationHandle for it is owned by the NavigationRequest. |
779 scoped_ptr<NavigationHandleImpl> navigation_handle_; | 816 scoped_ptr<NavigationHandleImpl> navigation_handle_; |
780 | 817 |
818 // The associated WebUIImpl and its type. They will be set if the current page | |
819 // is a Web UI page. Otherwise they will be nullptr and WebUI::kNoWebUI, | |
820 // respectively. | |
821 scoped_ptr<WebUIImpl> web_ui_; | |
clamy
2015/10/01 13:15:13
Would it be possible to modify the WebUI so that i
carlosk
2015/10/01 16:00:22
I agree and it is possible. But nasko@ mentioning
| |
822 WebUI::TypeID web_ui_type_; | |
823 | |
824 // Stores a pending WebUIImpl and its type. These will only be set during a | |
825 // same-site navigation to a WebUI page (reusing this RenderFrameHost). | |
826 scoped_ptr<WebUIImpl> pending_web_ui_; | |
827 WebUI::TypeID pending_web_ui_type_; | |
828 | |
829 // If true at commit time the current WebUI will simply be reused (no pending | |
830 // one will exist to be committed). | |
clamy
2015/10/01 13:15:13
Then, is it equivalent to !pending_web_ui_?
carlosk
2015/10/01 16:00:22
No because if this is false and the pending WebUI
| |
831 bool should_reuse_web_ui_; | |
832 | |
781 // NOTE: This must be the last member. | 833 // NOTE: This must be the last member. |
782 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; | 834 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; |
783 | 835 |
784 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); | 836 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); |
785 }; | 837 }; |
786 | 838 |
787 } // namespace content | 839 } // namespace content |
788 | 840 |
789 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 841 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
OLD | NEW |