| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_RENDERER_HOST_RENDER_VIEW_HOST_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_IMPL_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_IMPL_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 namespace ui { | 55 namespace ui { |
| 56 struct SelectedFileInfo; | 56 struct SelectedFileInfo; |
| 57 } | 57 } |
| 58 | 58 |
| 59 namespace content { | 59 namespace content { |
| 60 | 60 |
| 61 class BrowserMediaPlayerManager; | 61 class BrowserMediaPlayerManager; |
| 62 class ChildProcessSecurityPolicyImpl; | 62 class ChildProcessSecurityPolicyImpl; |
| 63 class PageState; | 63 class PageState; |
| 64 class RenderFrameHostImpl; | |
| 65 class RenderWidgetHostDelegate; | 64 class RenderWidgetHostDelegate; |
| 66 class SessionStorageNamespace; | 65 class SessionStorageNamespace; |
| 67 class SessionStorageNamespaceImpl; | 66 class SessionStorageNamespaceImpl; |
| 68 class TestRenderViewHost; | 67 class TestRenderViewHost; |
| 69 struct ContextMenuParams; | 68 struct ContextMenuParams; |
| 70 struct FileChooserParams; | 69 struct FileChooserParams; |
| 71 struct Referrer; | 70 struct Referrer; |
| 72 struct ShowDesktopNotificationHostMsgParams; | 71 struct ShowDesktopNotificationHostMsgParams; |
| 73 | 72 |
| 74 #if defined(COMPILER_MSVC) | 73 #if defined(COMPILER_MSVC) |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 float y) OVERRIDE; | 219 float y) OVERRIDE; |
| 221 virtual void RequestFindMatchRects(int current_version) OVERRIDE; | 220 virtual void RequestFindMatchRects(int current_version) OVERRIDE; |
| 222 virtual void DisableFullscreenEncryptedMediaPlayback() OVERRIDE; | 221 virtual void DisableFullscreenEncryptedMediaPlayback() OVERRIDE; |
| 223 #endif | 222 #endif |
| 224 | 223 |
| 225 void set_delegate(RenderViewHostDelegate* d) { | 224 void set_delegate(RenderViewHostDelegate* d) { |
| 226 CHECK(d); // http://crbug.com/82827 | 225 CHECK(d); // http://crbug.com/82827 |
| 227 delegate_ = d; | 226 delegate_ = d; |
| 228 } | 227 } |
| 229 | 228 |
| 229 // Keep track of which RenderFrameHosts are using this RenderViewHost. When |
| 230 // the number drops to zero, we call Shutdown. This cannot use frame_ids, |
| 231 // since the RenderFrameHost may outlive the process (or may go away before |
| 232 // the process and frame_id are created). |
| 233 void RegisterRenderFrameHost(RenderFrameHostImpl* render_frame_host); |
| 234 void UnregisterRenderFrameHost(RenderFrameHostImpl* render_frame_host); |
| 235 |
| 236 // Map renderer-specific frame IDs to browser-global FrameTreeNode IDs. |
| 237 // TODO(creis): Call Unregister. |
| 238 void RegisterFrameID(int64 frame_id, int64 frame_tree_node_id); |
| 239 void UnregisterFrameID(int64 frame_id); |
| 240 bool HasFrameID(int64 frame_id) const; |
| 241 int64 GetFrameTreeNodeID(int64 frame_id); |
| 242 int64 GetFrameIDForTesting(int64 frame_tree_node_id) const; |
| 243 |
| 230 // Set up the RenderView child process. Virtual because it is overridden by | 244 // Set up the RenderView child process. Virtual because it is overridden by |
| 231 // TestRenderViewHost. If the |frame_name| parameter is non-empty, it is used | 245 // TestRenderViewHost. If the |frame_name| parameter is non-empty, it is used |
| 232 // as the name of the new top-level frame. | 246 // as the name of the new top-level frame. |
| 233 // The |opener_route_id| parameter indicates which RenderView created this | 247 // The |opener_route_id| parameter indicates which RenderView created this |
| 234 // (MSG_ROUTING_NONE if none). If |max_page_id| is larger than -1, the | 248 // (MSG_ROUTING_NONE if none). If |max_page_id| is larger than -1, the |
| 235 // RenderView is told to start issuing page IDs at |max_page_id| + 1. | 249 // RenderView is told to start issuing page IDs at |max_page_id| + 1. |
| 236 virtual bool CreateRenderView(const string16& frame_name, | 250 virtual bool CreateRenderView(const string16& frame_name, |
| 237 int opener_route_id, | 251 int opener_route_id, |
| 238 int32 max_page_id); | 252 int32 max_page_id); |
| 239 | 253 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 | 435 |
| 422 // User rotated the screen. Calls the "onorientationchange" Javascript hook. | 436 // User rotated the screen. Calls the "onorientationchange" Javascript hook. |
| 423 void SendOrientationChangeEvent(int orientation); | 437 void SendOrientationChangeEvent(int orientation); |
| 424 | 438 |
| 425 // Sets a bit indicating whether the RenderView is responsible for displaying | 439 // Sets a bit indicating whether the RenderView is responsible for displaying |
| 426 // a subframe in a different process from its parent page. | 440 // a subframe in a different process from its parent page. |
| 427 void set_is_subframe(bool is_subframe) { | 441 void set_is_subframe(bool is_subframe) { |
| 428 is_subframe_ = is_subframe; | 442 is_subframe_ = is_subframe; |
| 429 } | 443 } |
| 430 | 444 |
| 431 // TODO(creis): Remove this when we replace frame IDs with RenderFrameHost | |
| 432 // routing IDs. | |
| 433 int64 main_frame_id() const { | |
| 434 return main_frame_id_; | |
| 435 } | |
| 436 | |
| 437 // Set the opener to null in the renderer process. | 445 // Set the opener to null in the renderer process. |
| 438 void DisownOpener(); | 446 void DisownOpener(); |
| 439 | 447 |
| 440 // Turn on accessibility testing. The given callback will be run | 448 // Turn on accessibility testing. The given callback will be run |
| 441 // every time an accessibility notification is received from the | 449 // every time an accessibility notification is received from the |
| 442 // renderer process, and the accessibility tree it sent can be | 450 // renderer process, and the accessibility tree it sent can be |
| 443 // retrieved using accessibility_tree_for_testing(). | 451 // retrieved using accessibility_tree_for_testing(). |
| 444 void SetAccessibilityCallbackForTesting( | 452 void SetAccessibilityCallbackForTesting( |
| 445 const base::Callback<void(blink::WebAXEvent)>& callback); | 453 const base::Callback<void(blink::WebAXEvent)>& callback); |
| 446 | 454 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 474 bool CanCommitURL(const GURL& url); | 482 bool CanCommitURL(const GURL& url); |
| 475 | 483 |
| 476 // Checks that the given renderer can request |url|, if not it sets it to | 484 // Checks that the given renderer can request |url|, if not it sets it to |
| 477 // about:blank. | 485 // about:blank. |
| 478 // empty_allowed must be set to false for navigations for security reasons. | 486 // empty_allowed must be set to false for navigations for security reasons. |
| 479 static void FilterURL(ChildProcessSecurityPolicyImpl* policy, | 487 static void FilterURL(ChildProcessSecurityPolicyImpl* policy, |
| 480 const RenderProcessHost* process, | 488 const RenderProcessHost* process, |
| 481 bool empty_allowed, | 489 bool empty_allowed, |
| 482 GURL* url); | 490 GURL* url); |
| 483 | 491 |
| 484 // Update the FrameTree to use this RenderViewHost's main frame | |
| 485 // RenderFrameHost. Called when the RenderViewHost is committed. | |
| 486 // | |
| 487 // TODO(ajwong): Remove once RenderViewHost no longer owns the main frame | |
| 488 // RenderFrameHost. | |
| 489 void AttachToFrameTree(); | |
| 490 | |
| 491 // The following IPC handlers are public so RenderFrameHost can call them, | 492 // The following IPC handlers are public so RenderFrameHost can call them, |
| 492 // while we transition the code to not use RenderViewHost. | 493 // while we transition the code to not use RenderViewHost. |
| 493 // | 494 // |
| 494 // TODO(nasko): Remove those methods once we are done moving navigation | 495 // TODO(nasko): Remove those methods once we are done moving navigation |
| 495 // into RenderFrameHost. | 496 // into RenderFrameHost. |
| 496 void OnDidStartProvisionalLoadForFrame(int64 frame_id, | 497 void OnDidStartProvisionalLoadForFrame(int64 frame_id, |
| 497 int64 parent_frame_id, | 498 int64 parent_frame_id, |
| 498 bool main_frame, | 499 bool main_frame, |
| 499 const GURL& url); | 500 const GURL& url); |
| 500 | 501 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 void OnCancelDesktopNotification(int notification_id); | 605 void OnCancelDesktopNotification(int notification_id); |
| 605 void OnRunFileChooser(const FileChooserParams& params); | 606 void OnRunFileChooser(const FileChooserParams& params); |
| 606 void OnDidAccessInitialDocument(); | 607 void OnDidAccessInitialDocument(); |
| 607 void OnDomOperationResponse(const std::string& json_string, | 608 void OnDomOperationResponse(const std::string& json_string, |
| 608 int automation_id); | 609 int automation_id); |
| 609 | 610 |
| 610 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 611 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
| 611 void OnShowPopup(const ViewHostMsg_ShowPopup_Params& params); | 612 void OnShowPopup(const ViewHostMsg_ShowPopup_Params& params); |
| 612 #endif | 613 #endif |
| 613 | 614 |
| 614 // TODO(nasko): Remove this accessor once RenderFrameHost moves into the frame | |
| 615 // tree. | |
| 616 RenderFrameHostImpl* main_render_frame_host() const { | |
| 617 return main_render_frame_host_.get(); | |
| 618 } | |
| 619 | |
| 620 private: | 615 private: |
| 621 friend class TestRenderViewHost; | 616 friend class TestRenderViewHost; |
| 622 FRIEND_TEST_ALL_PREFIXES(RenderViewHostTest, BasicRenderFrameHost); | 617 FRIEND_TEST_ALL_PREFIXES(RenderViewHostTest, BasicRenderFrameHost); |
| 623 FRIEND_TEST_ALL_PREFIXES(RenderViewHostTest, RoutingIdSane); | 618 FRIEND_TEST_ALL_PREFIXES(RenderViewHostTest, RoutingIdSane); |
| 624 | 619 |
| 620 typedef base::hash_map<int64, int64> FrameIDMap; |
| 621 |
| 625 // Sets whether this RenderViewHost is swapped out in favor of another, | 622 // Sets whether this RenderViewHost is swapped out in favor of another, |
| 626 // and clears any waiting state that is no longer relevant. | 623 // and clears any waiting state that is no longer relevant. |
| 627 void SetSwappedOut(bool is_swapped_out); | 624 void SetSwappedOut(bool is_swapped_out); |
| 628 | 625 |
| 629 bool CanAccessFilesOfPageState(const PageState& state) const; | 626 bool CanAccessFilesOfPageState(const PageState& state) const; |
| 630 | 627 |
| 631 // All RenderViewHosts must have a RenderFrameHost for its main frame. | |
| 632 // Currently the RenderFrameHost is created in lock step on construction | |
| 633 // and a pointer to the main frame is given to the FrameTreeNode | |
| 634 // when the RenderViewHost commits (see AttachToFrameTree()). | |
| 635 // | |
| 636 // TODO(ajwong): Make this reference non-owning. The root FrameTreeNode of | |
| 637 // the FrameTree should be responsible for owning the main frame's | |
| 638 // RenderFrameHost. | |
| 639 scoped_ptr<RenderFrameHostImpl> main_render_frame_host_; | |
| 640 | |
| 641 // Our delegate, which wants to know about changes in the RenderView. | 628 // Our delegate, which wants to know about changes in the RenderView. |
| 642 RenderViewHostDelegate* delegate_; | 629 RenderViewHostDelegate* delegate_; |
| 643 | 630 |
| 644 // The SiteInstance associated with this RenderViewHost. All pages drawn | 631 // The SiteInstance associated with this RenderViewHost. All pages drawn |
| 645 // in this RenderViewHost are part of this SiteInstance. Should not change | 632 // in this RenderViewHost are part of this SiteInstance. Should not change |
| 646 // over time. | 633 // over time. |
| 647 scoped_refptr<SiteInstanceImpl> instance_; | 634 scoped_refptr<SiteInstanceImpl> instance_; |
| 648 | 635 |
| 636 // A list of RenderFrameHosts depending on this RenderViewHost. When the list |
| 637 // size goes to zero, this RenderViewHost is shut down. |
| 638 std::set<RenderFrameHostImpl*> rfh_list_; |
| 639 |
| 640 // Map of renderer-specific frame IDs to browser-global FrameTreeNode IDs. |
| 641 FrameIDMap frame_id_map_; |
| 642 |
| 649 // true if we are currently waiting for a response for drag context | 643 // true if we are currently waiting for a response for drag context |
| 650 // information. | 644 // information. |
| 651 bool waiting_for_drag_context_response_; | 645 bool waiting_for_drag_context_response_; |
| 652 | 646 |
| 653 // A bitwise OR of bindings types that have been enabled for this RenderView. | 647 // A bitwise OR of bindings types that have been enabled for this RenderView. |
| 654 // See BindingsPolicy for details. | 648 // See BindingsPolicy for details. |
| 655 int enabled_bindings_; | 649 int enabled_bindings_; |
| 656 | 650 |
| 657 // Whether we should buffer outgoing Navigate messages rather than sending | 651 // Whether we should buffer outgoing Navigate messages rather than sending |
| 658 // them. This will be true when a RenderViewHost is created for a cross-site | 652 // them. This will be true when a RenderViewHost is created for a cross-site |
| (...skipping 14 matching lines...) Expand all Loading... |
| 673 bool has_accessed_initial_document_; | 667 bool has_accessed_initial_document_; |
| 674 | 668 |
| 675 // Whether this RenderViewHost is currently swapped out, such that the view is | 669 // Whether this RenderViewHost is currently swapped out, such that the view is |
| 676 // being rendered by another process. | 670 // being rendered by another process. |
| 677 bool is_swapped_out_; | 671 bool is_swapped_out_; |
| 678 | 672 |
| 679 // Whether this RenderView is responsible for displaying a subframe in a | 673 // Whether this RenderView is responsible for displaying a subframe in a |
| 680 // different process from its parent page. | 674 // different process from its parent page. |
| 681 bool is_subframe_; | 675 bool is_subframe_; |
| 682 | 676 |
| 683 // The frame id of the main (top level) frame. This value is set on the | 677 // Routing ID for the main frame's RenderFrameHost. |
| 684 // initial navigation of a RenderView and reset when the RenderView's | 678 // TODO(creis): Does this need to be updated on a crash? |
| 685 // process is terminated (in RenderProcessGone). | 679 int main_frame_routing_id_; |
| 686 int64 main_frame_id_; | |
| 687 | 680 |
| 688 // If we were asked to RunModal, then this will hold the reply_msg that we | 681 // If we were asked to RunModal, then this will hold the reply_msg that we |
| 689 // must return to the renderer to unblock it. | 682 // must return to the renderer to unblock it. |
| 690 IPC::Message* run_modal_reply_msg_; | 683 IPC::Message* run_modal_reply_msg_; |
| 691 // This will hold the routing id of the RenderView that opened us. | 684 // This will hold the routing id of the RenderView that opened us. |
| 692 int run_modal_opener_id_; | 685 int run_modal_opener_id_; |
| 693 | 686 |
| 694 // Set to true when there is a pending ViewMsg_ShouldClose message. This | 687 // Set to true when there is a pending ViewMsg_ShouldClose message. This |
| 695 // ensures we don't spam the renderer with multiple beforeunload requests. | 688 // ensures we don't spam the renderer with multiple beforeunload requests. |
| 696 // When either this value or is_waiting_for_unload_ack_ is true, the value of | 689 // When either this value or is_waiting_for_unload_ack_ is true, the value of |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 DISALLOW_COPY_AND_ASSIGN(RenderViewHostImpl); | 734 DISALLOW_COPY_AND_ASSIGN(RenderViewHostImpl); |
| 742 }; | 735 }; |
| 743 | 736 |
| 744 #if defined(COMPILER_MSVC) | 737 #if defined(COMPILER_MSVC) |
| 745 #pragma warning(pop) | 738 #pragma warning(pop) |
| 746 #endif | 739 #endif |
| 747 | 740 |
| 748 } // namespace content | 741 } // namespace content |
| 749 | 742 |
| 750 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_IMPL_H_ | 743 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_IMPL_H_ |
| OLD | NEW |