Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(806)

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.h

Issue 1352813006: Move WebUI ownership from the RenderFrameHostManager to the RenderFrameHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed ChromeOS errors caused by improper timing of RenderView(Created|Reused) calls. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 for a recently created RenderFrameHost, if one
nasko 2015/10/14 23:54:14 Does the "recently created" bit matter?
carlosk 2015/10/15 16:34:07 Removed it. It was not really true and the text th
481 // is required by |dest_url|. No WebUI must have been set before and it must
482 // be called only once. If this is a history navigation to an existing
483 // NavigationEntry, providing its |entry_bindings| will allow verifying that
484 // bindings are not being set differently this time around.
485 void InitializeWebUI(const GURL& dest_url, int entry_bindings);
486
487 // Updates the pending WebUI data of this RenderFrameHost based on the
488 // provided |dest_url|. If it doesn't require a WebUI, the pending one is
489 // cleared. If a new WebUI is required and its type matches the existing
490 // pending one it will be reused. If the type matches the active one then the
491 // pending is cleared and the current one is set to be reused. Otherwise a new
492 // pending WebUI instance is set.
nasko 2015/10/14 23:54:14 As before, this comment seems to describe the impl
carlosk 2015/10/15 16:34:07 Simplified the comment.
nasko 2015/10/15 17:40:09 This now is an awesome comment! Thank you!
493 // The WebUI chosen here will be made active upon the next call to
494 // CommitPendingWebUI.
495 // If this is a history navigation its bindings from the NavigationEntry
496 // should be provided through |entry_bindings|. It will allow verifying that
497 // bindings are not being set differently this time around. Otherwise
498 // |entry_bindings| should be set to NavigationEntryImpl::kInvalidBindings.
499 void UpdatePendingWebUI(const GURL& dest_url, int entry_bindings);
500
501 // Updates the active WebUI with the pending one set by the last call to
502 // UpdatePendingWebUI and then clears any pending data. If UpdatePendingWebUI
503 // was not called the active WebUI will simply be cleared.
504 void CommitPendingWebUI();
505
506 // Destroys the pending WebUI and cleans up any related data.
507 void DiscardPendingWebUI();
508
471 // Returns the Mojo ImageDownloader service. 509 // Returns the Mojo ImageDownloader service.
472 const image_downloader::ImageDownloaderPtr& GetMojoImageDownloader(); 510 const image_downloader::ImageDownloaderPtr& GetMojoImageDownloader();
473 511
474 protected: 512 protected:
475 friend class RenderFrameHostFactory; 513 friend class RenderFrameHostFactory;
476 514
477 // |flags| is a combination of CreateRenderFrameFlags. 515 // |flags| is a combination of CreateRenderFrameFlags.
478 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost 516 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost
479 // should be the abstraction needed here, but we need RenderViewHost to pass 517 // should be the abstraction needed here, but we need RenderViewHost to pass
480 // into WebContentsObserver::FrameDetached for now. 518 // into WebContentsObserver::FrameDetached for now.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 RenderWidgetHostViewBase* GetViewForAccessibility(); 653 RenderWidgetHostViewBase* GetViewForAccessibility();
616 654
617 // Sends a navigate message to the RenderFrame and notifies DevTools about 655 // Sends a navigate message to the RenderFrame and notifies DevTools about
618 // navigation happening. Should be used instead of sending the message 656 // navigation happening. Should be used instead of sending the message
619 // directly. 657 // directly.
620 void SendNavigateMessage( 658 void SendNavigateMessage(
621 const content::CommonNavigationParams& common_params, 659 const content::CommonNavigationParams& common_params,
622 const content::StartNavigationParams& start_params, 660 const content::StartNavigationParams& start_params,
623 const content::RequestNavigationParams& request_params); 661 const content::RequestNavigationParams& request_params);
624 662
663 // Creates a WebUI object for the given URL if one applies and sets
664 // |web_ui_type| to its type, also ensuring that its bindings match
665 // |entry_bindings| (if provided and different than
666 // NavigationEntryImpl::kInvalidBindings). If no WebUI applies, returns
nasko 2015/10/14 23:54:14 Again, no need to include the text in (). This is
carlosk 2015/10/15 16:34:07 Done.
667 // null and resets web_ui_type to WebUI::kNoWebUI.
668 scoped_ptr<WebUIImpl> CreateWebUI(const GURL& dest_url,
669 int entry_bindings,
670 WebUI::TypeID* web_ui_type);
671
625 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a 672 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a
626 // refcount that calls Shutdown when it reaches zero. This allows each 673 // refcount that calls Shutdown when it reaches zero. This allows each
627 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring 674 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring
628 // we have a RenderViewHost for each RenderFrameHost. 675 // we have a RenderViewHost for each RenderFrameHost.
629 // TODO(creis): RenderViewHost will eventually go away and be replaced with 676 // TODO(creis): RenderViewHost will eventually go away and be replaced with
630 // some form of page context. 677 // some form of page context.
631 RenderViewHostImpl* render_view_host_; 678 RenderViewHostImpl* render_view_host_;
632 679
633 RenderFrameHostDelegate* delegate_; 680 RenderFrameHostDelegate* delegate_;
634 681
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 // Holder of Mojo connection with ImageDownloader service in RenderFrame. 830 // Holder of Mojo connection with ImageDownloader service in RenderFrame.
784 image_downloader::ImageDownloaderPtr mojo_image_downloader_; 831 image_downloader::ImageDownloaderPtr mojo_image_downloader_;
785 832
786 // Tracks a navigation happening in this frame. Note that while there can be 833 // 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 834 // two navigations in the same FrameTreeNode, there can only be one
788 // navigation per RenderFrameHost. 835 // navigation per RenderFrameHost.
789 // PlzNavigate: before the navigation is ready to be committed, the 836 // PlzNavigate: before the navigation is ready to be committed, the
790 // NavigationHandle for it is owned by the NavigationRequest. 837 // NavigationHandle for it is owned by the NavigationRequest.
791 scoped_ptr<NavigationHandleImpl> navigation_handle_; 838 scoped_ptr<NavigationHandleImpl> navigation_handle_;
792 839
840 // The associated WebUIImpl and its type. They will be set if the current page
nasko 2015/10/14 23:54:14 This is RenderFrameHost, it cannot have a page : )
carlosk 2015/10/15 16:34:07 Done.
841 // is a WebUI page. Otherwise they will be null and WebUI::kNoWebUI,
842 // respectively.
843 scoped_ptr<WebUIImpl> web_ui_;
844 WebUI::TypeID web_ui_type_;
845
846 // Stores a pending WebUIImpl and its type. These will only be set during a
847 // same-site navigation to a WebUI page (reusing this RenderFrameHost).
848 scoped_ptr<WebUIImpl> pending_web_ui_;
849 WebUI::TypeID pending_web_ui_type_;
850
851 // If true at commit time the current WebUI will simply be reused (no pending
852 // one will exist to be committed).
853 bool should_reuse_web_ui_;
854
793 // NOTE: This must be the last member. 855 // NOTE: This must be the last member.
794 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; 856 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_;
795 857
796 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); 858 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl);
797 }; 859 };
798 860
799 } // namespace content 861 } // namespace content
800 862
801 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ 863 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698