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

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: Created 5 years, 3 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 { return pending_web_ui_.get(); }
221
215 // Returns this RenderFrameHost's loading state. This method is only used by 222 // 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 223 // FrameTreeNode. The proper way to check whether a frame is loading is to
217 // call FrameTreeNode::IsLoading. 224 // call FrameTreeNode::IsLoading.
218 bool is_loading() const { return is_loading_; } 225 bool is_loading() const { return is_loading_; }
219 226
220 // This returns the RenderFrameHost's owned RenderWidgetHost if it has one, 227 // This returns the RenderFrameHost's owned RenderWidgetHost if it has one,
221 // or else it returns nullptr. 228 // or else it returns nullptr.
222 // If the RenderFrameHost is the page's main frame, this returns instead a 229 // If the RenderFrameHost is the page's main frame, this returns instead a
223 // pointer to the RenderViewHost (which inherits RenderWidgetHost). 230 // pointer to the RenderViewHost (which inherits RenderWidgetHost).
224 RenderWidgetHostImpl* GetRenderWidgetHost(); 231 RenderWidgetHostImpl* GetRenderWidgetHost();
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 464
458 // Tears down the browser-side state relating to the Mojo connection between 465 // Tears down the browser-side state relating to the Mojo connection between
459 // this instance and its associated render frame. 466 // this instance and its associated render frame.
460 void InvalidateMojoConnection(); 467 void InvalidateMojoConnection();
461 468
462 // Returns whether the frame is focused. A frame is considered focused when it 469 // 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 470 // is the parent chain of the focused frame within the frame tree. In
464 // addition, its associated RenderWidgetHost has to be focused. 471 // addition, its associated RenderWidgetHost has to be focused.
465 bool IsFocused(); 472 bool IsFocused();
466 473
474 void InitializeWebUI(const GURL& dest_url, int past_bindings);
475
476 void UpdatePendingWebUI(const GURL& dest_url, int past_bindings);
477
478 void CommitPendingWebUI();
479
480 void DiscardPendingWebUI();
481
467 // Returns the Mojo ImageDownloader service. 482 // Returns the Mojo ImageDownloader service.
468 const image_downloader::ImageDownloaderPtr& GetMojoImageDownloader(); 483 const image_downloader::ImageDownloaderPtr& GetMojoImageDownloader();
469 484
470 protected: 485 protected:
471 friend class RenderFrameHostFactory; 486 friend class RenderFrameHostFactory;
472 487
473 // |flags| is a combination of CreateRenderFrameFlags. 488 // |flags| is a combination of CreateRenderFrameFlags.
474 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost 489 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost
475 // should be the abstraction needed here, but we need RenderViewHost to pass 490 // should be the abstraction needed here, but we need RenderViewHost to pass
476 // into WebContentsObserver::FrameDetached for now. 491 // into WebContentsObserver::FrameDetached for now.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 614
600 // Map a browser plugin instance ID to the AXTreeID of the plugin's 615 // Map a browser plugin instance ID to the AXTreeID of the plugin's
601 // main frame. 616 // main frame.
602 AXTreeIDRegistry::AXTreeID BrowserPluginInstanceIDToAXTreeID(int routing_id); 617 AXTreeIDRegistry::AXTreeID BrowserPluginInstanceIDToAXTreeID(int routing_id);
603 618
604 // Convert the content-layer-specific AXContentNodeData to a general-purpose 619 // Convert the content-layer-specific AXContentNodeData to a general-purpose
605 // AXNodeData structure. 620 // AXNodeData structure.
606 void AXContentNodeDataToAXNodeData(const AXContentNodeData& src, 621 void AXContentNodeDataToAXNodeData(const AXContentNodeData& src,
607 ui::AXNodeData* dst); 622 ui::AXNodeData* dst);
608 623
624 // Creates a WebUI object for the given URL if one applies and sets
625 // |web_ui_type| to its type, also ensuring that its bindings match
626 // |past_bindings| (if provided and different than
627 // NavigationEntryImpl::kInvalidBindings). If no WebUI applies, returns
628 // nullptr and resets web_ui_type to WebUI::kNoWebUI. .
629 scoped_ptr<WebUIImpl> CreateWebUI(const GURL& dest_url,
630 int past_bindings,
631 WebUI::TypeID* web_ui_type);
632
609 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a 633 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a
610 // refcount that calls Shutdown when it reaches zero. This allows each 634 // refcount that calls Shutdown when it reaches zero. This allows each
611 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring 635 // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring
612 // we have a RenderViewHost for each RenderFrameHost. 636 // we have a RenderViewHost for each RenderFrameHost.
613 // TODO(creis): RenderViewHost will eventually go away and be replaced with 637 // TODO(creis): RenderViewHost will eventually go away and be replaced with
614 // some form of page context. 638 // some form of page context.
615 RenderViewHostImpl* render_view_host_; 639 RenderViewHostImpl* render_view_host_;
616 640
617 RenderFrameHostDelegate* delegate_; 641 RenderFrameHostDelegate* delegate_;
618 642
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 // Holder of Mojo connection with ImageDownloader service in RenderFrame. 791 // Holder of Mojo connection with ImageDownloader service in RenderFrame.
768 image_downloader::ImageDownloaderPtr mojo_image_downloader_; 792 image_downloader::ImageDownloaderPtr mojo_image_downloader_;
769 793
770 // Tracks a navigation happening in this frame. Note that while there can be 794 // Tracks a navigation happening in this frame. Note that while there can be
771 // two navigations in the same FrameTreeNode, there can only be one 795 // two navigations in the same FrameTreeNode, there can only be one
772 // navigation per RenderFrameHost. 796 // navigation per RenderFrameHost.
773 // PlzNavigate: before the navigation is ready to be committed, the 797 // PlzNavigate: before the navigation is ready to be committed, the
774 // NavigationHandle for it is owned by the NavigationRequest. 798 // NavigationHandle for it is owned by the NavigationRequest.
775 scoped_ptr<NavigationHandleImpl> navigation_handle_; 799 scoped_ptr<NavigationHandleImpl> navigation_handle_;
776 800
801 // The associated WebUIImpl and its type. They will be set if the current page
802 // is a Web UI page. Otherwise they will be nullptr and WebUI::kNoWebUI,
803 // respectively.
804 scoped_ptr<WebUIImpl> web_ui_;
805 WebUI::TypeID web_ui_type_;
806
807 // If either of these is non-NULL, the pending navigation is to a chrome:
808 // page. The scoped_ptr is used if pending_web_ui_ != web_ui_, the WeakPtr is
809 // used for when they reference the same object. If either is non-NULL, the
810 // other should be NULL.
811 // Note: These are not used in PlzNavigate.
clamy 2015/09/17 17:04:37 Which case would warrant having this in the curren
carlosk 2015/09/30 19:37:27 The comment wasn't yet updated after copy/pasting
812 scoped_ptr<WebUIImpl> pending_web_ui_;
813 WebUI::TypeID pending_web_ui_type_;
814
815 // If true at navigation commit time the current WebUI will be kept instead of
816 // creating a new one.
817 bool should_reuse_web_ui_;
818
777 // NOTE: This must be the last member. 819 // NOTE: This must be the last member.
778 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_; 820 base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_;
779 821
780 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); 822 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl);
781 }; 823 };
782 824
783 } // namespace content 825 } // namespace content
784 826
785 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ 827 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698