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

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

Powered by Google App Engine
This is Rietveld 408576698