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 // Updates the pending WebUI of this RenderFrameHost depending on the provided | |
477 // |dest_url|. If it doesn't demand a Web, the pending will be cleared. If the | |
nasko
2015/10/01 20:05:16
"Web"? Did you mean "WebUI"?
carlosk
2015/10/05 16:59:57
Done.
| |
478 // a new WebUI is required and its type matches an existing pending one it | |
nasko
2015/10/01 20:05:16
nit: s/an existing/the existing/
carlosk
2015/10/05 16:59:57
Done.
| |
479 // will be reused. If the type matches the active one then the pending is | |
480 // cleared. Otherwise a new WebUI instance is created and replaces the | |
nasko
2015/10/01 20:05:16
If there is no pending, there is nothing to replac
carlosk
2015/10/05 16:59:57
Done.
| |
481 // pending. | |
482 // If this is a history navigation its bindings from the NavigationEntry | |
483 // should be provided through |past_bindings|. It will allow verifying that | |
nasko
2015/10/01 20:05:16
nit: past implies that the history entry is prior
carlosk
2015/10/05 16:59:57
Changing to |entry_bindings| here and everywhere e
| |
484 // bindings are not being set differently this time around. Otherwise | |
485 // |past_bindings| should be set to NavigationEntryImpl::kInvalidBindings. | |
486 // If a WebUI is created and this RenderFrameHost is live, | |
nasko
2015/10/01 20:05:16
Does that last sentence bring any information the
carlosk
2015/10/05 16:59:58
Indeed. Moved it to inside the method implementati
| |
487 // WebUIImpl::RenderViewReused will be called with the associated | |
488 // RenderViewHost. | |
489 void UpdatePendingWebUI(const GURL& dest_url, int past_bindings); | |
490 | |
491 // Replaces the active WebUI with the pending one if one exists. If the last | |
492 // call to UpdatePendingWebUI triggered the reusing of the current active one, | |
493 // it will simply be kept as is. If the pending is nullptr then the active | |
494 // will be cleared. | |
nasko
2015/10/01 20:05:16
Overall the comment on a method should be describi
clamy
2015/10/02 14:20:01
Also as mentioned in the other patchset, we may wa
carlosk
2015/10/05 16:59:57
Updated the comment.
As discussed offline the cha
| |
495 void CommitPendingWebUI(); | |
496 | |
497 // Destroys the pending WebUI and cleans up any related data. | |
nasko
2015/10/01 20:05:16
Ah! This is awesome comment! : )
carlosk
2015/10/05 16:59:57
Acknowledged. :)
| |
498 void DiscardPendingWebUI(); | |
499 | |
467 // Returns the Mojo ImageDownloader service. | 500 // Returns the Mojo ImageDownloader service. |
468 const image_downloader::ImageDownloaderPtr& GetMojoImageDownloader(); | 501 const image_downloader::ImageDownloaderPtr& GetMojoImageDownloader(); |
469 | 502 |
470 protected: | 503 protected: |
471 friend class RenderFrameHostFactory; | 504 friend class RenderFrameHostFactory; |
472 | 505 |
473 // |flags| is a combination of CreateRenderFrameFlags. | 506 // |flags| is a combination of CreateRenderFrameFlags. The |dest_url| and |
507 // |past_bindings| parameters are used to create an associated WebUI if one is | |
508 // required (see UpdatePendingWebUI for further details). | |
509 // If a WebUI is created and this RenderFrameHost is for the main frame, it is | |
510 // assumed that the associated RenderViewHost has also just been created and | |
511 // WebUIImpl::RenderViewCreated will be called with it. | |
474 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost | 512 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost |
475 // 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 |
476 // into WebContentsObserver::FrameDetached for now. | 514 // into WebContentsObserver::FrameDetached for now. |
477 RenderFrameHostImpl(SiteInstance* site_instance, | 515 RenderFrameHostImpl(SiteInstance* site_instance, |
478 RenderViewHostImpl* render_view_host, | 516 RenderViewHostImpl* render_view_host, |
479 RenderFrameHostDelegate* delegate, | 517 RenderFrameHostDelegate* delegate, |
480 RenderWidgetHostDelegate* rwh_delegate, | 518 RenderWidgetHostDelegate* rwh_delegate, |
481 FrameTree* frame_tree, | 519 FrameTree* frame_tree, |
482 FrameTreeNode* frame_tree_node, | 520 FrameTreeNode* frame_tree_node, |
483 int32 routing_id, | 521 int32 routing_id, |
484 int32 widget_routing_id, | 522 int32 widget_routing_id, |
485 int flags); | 523 int flags, |
524 const GURL& dest_url, | |
525 int past_bindings); | |
486 | 526 |
487 private: | 527 private: |
488 friend class TestRenderFrameHost; | 528 friend class TestRenderFrameHost; |
489 friend class TestRenderViewHost; | 529 friend class TestRenderViewHost; |
490 | 530 |
491 FRIEND_TEST_ALL_PREFIXES(SitePerProcessBrowserTest, CrashSubframe); | 531 FRIEND_TEST_ALL_PREFIXES(SitePerProcessBrowserTest, CrashSubframe); |
492 | 532 |
493 // IPC Message handlers. | 533 // IPC Message handlers. |
494 void OnAddMessageToConsole(int32 level, | 534 void OnAddMessageToConsole(int32 level, |
495 const base::string16& message, | 535 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 | 643 // Convert the content-layer-specific AXContentNodeData to a general-purpose |
604 // AXNodeData structure. | 644 // AXNodeData structure. |
605 void AXContentNodeDataToAXNodeData(const AXContentNodeData& src, | 645 void AXContentNodeDataToAXNodeData(const AXContentNodeData& src, |
606 ui::AXNodeData* dst); | 646 ui::AXNodeData* dst); |
607 | 647 |
608 // Returns the RenderWidgetHostView used for accessibility. For subframes, | 648 // Returns the RenderWidgetHostView used for accessibility. For subframes, |
609 // this function will return the platform view on the main frame; for main | 649 // this function will return the platform view on the main frame; for main |
610 // frames, it will return the current frame's view. | 650 // frames, it will return the current frame's view. |
611 RenderWidgetHostViewBase* GetViewForAccessibility(); | 651 RenderWidgetHostViewBase* GetViewForAccessibility(); |
612 | 652 |
653 // Creates a WebUI object for the given URL if one applies and sets | |
654 // |web_ui_type| to its type, also ensuring that its bindings match | |
655 // |past_bindings| (if provided and different than | |
656 // NavigationEntryImpl::kInvalidBindings). If no WebUI applies, returns | |
657 // nullptr and resets web_ui_type to WebUI::kNoWebUI. . | |
658 scoped_ptr<WebUIImpl> CreateWebUI(const GURL& dest_url, | |
659 int past_bindings, | |
660 WebUI::TypeID* web_ui_type); | |
661 | |
613 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a | 662 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a |
614 // refcount that calls Shutdown when it reaches zero. This allows each | 663 // refcount that calls Shutdown when it reaches zero. This allows each |
615 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring | 664 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring |
616 // we have a RenderViewHost for each RenderFrameHost. | 665 // we have a RenderViewHost for each RenderFrameHost. |
617 // TODO(creis): RenderViewHost will eventually go away and be replaced with | 666 // TODO(creis): RenderViewHost will eventually go away and be replaced with |
618 // some form of page context. | 667 // some form of page context. |
619 RenderViewHostImpl* render_view_host_; | 668 RenderViewHostImpl* render_view_host_; |
620 | 669 |
621 RenderFrameHostDelegate* delegate_; | 670 RenderFrameHostDelegate* delegate_; |
622 | 671 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
771 // Holder of Mojo connection with ImageDownloader service in RenderFrame. | 820 // Holder of Mojo connection with ImageDownloader service in RenderFrame. |
772 image_downloader::ImageDownloaderPtr mojo_image_downloader_; | 821 image_downloader::ImageDownloaderPtr mojo_image_downloader_; |
773 | 822 |
774 // Tracks a navigation happening in this frame. Note that while there can be | 823 // 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 | 824 // two navigations in the same FrameTreeNode, there can only be one |
776 // navigation per RenderFrameHost. | 825 // navigation per RenderFrameHost. |
777 // PlzNavigate: before the navigation is ready to be committed, the | 826 // PlzNavigate: before the navigation is ready to be committed, the |
778 // NavigationHandle for it is owned by the NavigationRequest. | 827 // NavigationHandle for it is owned by the NavigationRequest. |
779 scoped_ptr<NavigationHandleImpl> navigation_handle_; | 828 scoped_ptr<NavigationHandleImpl> navigation_handle_; |
780 | 829 |
830 // The associated WebUIImpl and its type. They will be set if the current page | |
831 // is a Web UI page. Otherwise they will be nullptr and WebUI::kNoWebUI, | |
nasko
2015/10/01 20:05:16
nit: s/Web UI/WebUI/
carlosk
2015/10/05 16:59:57
Fixed this here and in a few other places. But the
| |
832 // respectively. | |
833 scoped_ptr<WebUIImpl> web_ui_; | |
clamy
2015/10/02 14:20:01
@nasko: we were wondering about introducing a func
carlosk
2015/10/05 16:59:57
We talked offline about this and for now I'll keep
| |
834 WebUI::TypeID web_ui_type_; | |
835 | |
836 // Stores a pending WebUIImpl and its type. These will only be set during a | |
837 // same-site navigation to a WebUI page (reusing this RenderFrameHost). | |
838 scoped_ptr<WebUIImpl> pending_web_ui_; | |
839 WebUI::TypeID pending_web_ui_type_; | |
840 | |
841 // If true at commit time the current WebUI will simply be reused (no pending | |
842 // one will exist to be committed). | |
843 bool should_reuse_web_ui_; | |
844 | |
781 // NOTE: This must be the last member. | 845 // NOTE: This must be the last member. |
782 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; | 846 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; |
783 | 847 |
784 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); | 848 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); |
785 }; | 849 }; |
786 | 850 |
787 } // namespace content | 851 } // namespace content |
788 | 852 |
789 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 853 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
OLD | NEW |