| 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> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/process/kill.h" | 15 #include "base/process/kill.h" |
| 16 #include "content/browser/frame_host/render_frame_host_impl.h" | 16 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 17 #include "content/browser/renderer_host/render_widget_host_impl.h" | 17 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 18 #include "content/browser/site_instance_impl.h" | 18 #include "content/browser/site_instance_impl.h" |
| 19 #include "content/common/accessibility_node_data.h" | 19 #include "content/common/accessibility_node_data.h" |
| 20 #include "content/common/drag_event_source_info.h" | 20 #include "content/common/drag_event_source_info.h" |
| 21 #include "content/public/browser/notification_observer.h" | 21 #include "content/public/browser/notification_observer.h" |
| 22 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
| 23 #include "content/public/common/javascript_message_type.h" | 23 #include "content/public/common/javascript_message_type.h" |
| 24 #include "content/public/common/page_transition_types.h" |
| 24 #include "content/public/common/window_container_type.h" | 25 #include "content/public/common/window_container_type.h" |
| 25 #include "net/base/load_states.h" | 26 #include "net/base/load_states.h" |
| 26 #include "third_party/WebKit/public/web/WebAXEnums.h" | 27 #include "third_party/WebKit/public/web/WebAXEnums.h" |
| 27 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 28 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
| 28 #include "third_party/WebKit/public/web/WebPopupType.h" | 29 #include "third_party/WebKit/public/web/WebPopupType.h" |
| 29 #include "third_party/WebKit/public/web/WebTextDirection.h" | 30 #include "third_party/WebKit/public/web/WebTextDirection.h" |
| 30 #include "third_party/skia/include/core/SkColor.h" | 31 #include "third_party/skia/include/core/SkColor.h" |
| 31 #include "ui/base/window_open_disposition.h" | 32 #include "ui/base/window_open_disposition.h" |
| 32 | 33 |
| 33 class SkBitmap; | 34 class SkBitmap; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 53 | 54 |
| 54 namespace ui { | 55 namespace ui { |
| 55 struct SelectedFileInfo; | 56 struct SelectedFileInfo; |
| 56 } | 57 } |
| 57 | 58 |
| 58 namespace content { | 59 namespace content { |
| 59 | 60 |
| 60 class BrowserMediaPlayerManager; | 61 class BrowserMediaPlayerManager; |
| 61 class ChildProcessSecurityPolicyImpl; | 62 class ChildProcessSecurityPolicyImpl; |
| 62 class PageState; | 63 class PageState; |
| 63 class RenderFrameHostImpl; | |
| 64 class RenderWidgetHostDelegate; | 64 class RenderWidgetHostDelegate; |
| 65 class SessionStorageNamespace; | 65 class SessionStorageNamespace; |
| 66 class SessionStorageNamespaceImpl; | 66 class SessionStorageNamespaceImpl; |
| 67 class TestRenderViewHost; | 67 class TestRenderViewHost; |
| 68 struct ContextMenuParams; | 68 struct ContextMenuParams; |
| 69 struct FileChooserParams; | 69 struct FileChooserParams; |
| 70 struct Referrer; | 70 struct Referrer; |
| 71 struct ShowDesktopNotificationHostMsgParams; | 71 struct ShowDesktopNotificationHostMsgParams; |
| 72 | 72 |
| 73 #if defined(COMPILER_MSVC) | 73 #if defined(COMPILER_MSVC) |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 float y) OVERRIDE; | 219 float y) OVERRIDE; |
| 220 virtual void RequestFindMatchRects(int current_version) OVERRIDE; | 220 virtual void RequestFindMatchRects(int current_version) OVERRIDE; |
| 221 virtual void DisableFullscreenEncryptedMediaPlayback() OVERRIDE; | 221 virtual void DisableFullscreenEncryptedMediaPlayback() OVERRIDE; |
| 222 #endif | 222 #endif |
| 223 | 223 |
| 224 void set_delegate(RenderViewHostDelegate* d) { | 224 void set_delegate(RenderViewHostDelegate* d) { |
| 225 CHECK(d); // http://crbug.com/82827 | 225 CHECK(d); // http://crbug.com/82827 |
| 226 delegate_ = d; | 226 delegate_ = d; |
| 227 } | 227 } |
| 228 | 228 |
| 229 // Map renderer-specific frame IDs to browser-global FrameTreeNode IDs. |
| 230 // TODO(creis): Unregister as well. Think about where this map belongs. |
| 231 void RegisterFrameTreeNodeID(int64 frame_id, int64 frame_tree_node_id); |
| 232 bool HasFrameTreeNodeID(int64 frame_id) const; |
| 233 int64 GetFrameTreeNodeID(int64 frame_id); |
| 234 |
| 229 // Set up the RenderView child process. Virtual because it is overridden by | 235 // Set up the RenderView child process. Virtual because it is overridden by |
| 230 // TestRenderViewHost. If the |frame_name| parameter is non-empty, it is used | 236 // TestRenderViewHost. If the |frame_name| parameter is non-empty, it is used |
| 231 // as the name of the new top-level frame. | 237 // as the name of the new top-level frame. |
| 232 // The |opener_route_id| parameter indicates which RenderView created this | 238 // The |opener_route_id| parameter indicates which RenderView created this |
| 233 // (MSG_ROUTING_NONE if none). If |max_page_id| is larger than -1, the | 239 // (MSG_ROUTING_NONE if none). If |max_page_id| is larger than -1, the |
| 234 // RenderView is told to start issuing page IDs at |max_page_id| + 1. | 240 // RenderView is told to start issuing page IDs at |max_page_id| + 1. |
| 235 virtual bool CreateRenderView(const string16& frame_name, | 241 virtual bool CreateRenderView(const string16& frame_name, |
| 236 int opener_route_id, | 242 int opener_route_id, |
| 237 int32 max_page_id); | 243 int32 max_page_id); |
| 238 | 244 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 // page, making it unsafe to show the pending URL. Always false after the | 289 // page, making it unsafe to show the pending URL. Always false after the |
| 284 // first commit. | 290 // first commit. |
| 285 bool has_accessed_initial_document() { | 291 bool has_accessed_initial_document() { |
| 286 return has_accessed_initial_document_; | 292 return has_accessed_initial_document_; |
| 287 } | 293 } |
| 288 | 294 |
| 289 // Whether this RenderViewHost has been swapped out to be displayed by a | 295 // Whether this RenderViewHost has been swapped out to be displayed by a |
| 290 // different process. | 296 // different process. |
| 291 bool is_swapped_out() const { return is_swapped_out_; } | 297 bool is_swapped_out() const { return is_swapped_out_; } |
| 292 | 298 |
| 299 // Called on the pending RenderViewHost when the network response is ready to |
| 300 // commit. We should ensure that the old RenderViewHost runs its unload |
| 301 // handler and determine whether a transfer to a different RenderViewHost is |
| 302 // needed. |
| 303 // TODO(creis): This should happen on RenderFrameHost. |
| 304 void OnCrossSiteResponse( |
| 305 const GlobalRequestID& global_request_id, |
| 306 bool is_transfer, |
| 307 const std::vector<GURL>& transfer_url_chain, |
| 308 const Referrer& referrer, |
| 309 PageTransition page_transition, |
| 310 int64 frame_id); |
| 311 |
| 293 // Tells the renderer that this RenderView is being swapped out for one in a | 312 // Tells the renderer that this RenderView is being swapped out for one in a |
| 294 // different renderer process. It should run its unload handler and move to | 313 // different renderer process. It should run its unload handler and move to |
| 295 // a blank document. The renderer should preserve the Frame object until it | 314 // a blank document. The renderer should preserve the Frame object until it |
| 296 // exits, in case we come back. The renderer can exit if it has no other | 315 // exits, in case we come back. The renderer can exit if it has no other |
| 297 // active RenderViews, but not until WasSwappedOut is called (when it is no | 316 // active RenderViews, but not until WasSwappedOut is called (when it is no |
| 298 // longer visible). | 317 // longer visible). |
| 299 void SwapOut(); | 318 void SwapOut(); |
| 300 | 319 |
| 301 // Called when either the SwapOut request has been acknowledged or has timed | 320 // Called when either the SwapOut request has been acknowledged or has timed |
| 302 // out. | 321 // out. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 | 421 |
| 403 // User rotated the screen. Calls the "onorientationchange" Javascript hook. | 422 // User rotated the screen. Calls the "onorientationchange" Javascript hook. |
| 404 void SendOrientationChangeEvent(int orientation); | 423 void SendOrientationChangeEvent(int orientation); |
| 405 | 424 |
| 406 // Sets a bit indicating whether the RenderView is responsible for displaying | 425 // Sets a bit indicating whether the RenderView is responsible for displaying |
| 407 // a subframe in a different process from its parent page. | 426 // a subframe in a different process from its parent page. |
| 408 void set_is_subframe(bool is_subframe) { | 427 void set_is_subframe(bool is_subframe) { |
| 409 is_subframe_ = is_subframe; | 428 is_subframe_ = is_subframe; |
| 410 } | 429 } |
| 411 | 430 |
| 412 int64 main_frame_id() const { | |
| 413 return main_frame_id_; | |
| 414 } | |
| 415 | |
| 416 // Set the opener to null in the renderer process. | 431 // Set the opener to null in the renderer process. |
| 417 void DisownOpener(); | 432 void DisownOpener(); |
| 418 | 433 |
| 419 // Turn on accessibility testing. The given callback will be run | 434 // Turn on accessibility testing. The given callback will be run |
| 420 // every time an accessibility notification is received from the | 435 // every time an accessibility notification is received from the |
| 421 // renderer process, and the accessibility tree it sent can be | 436 // renderer process, and the accessibility tree it sent can be |
| 422 // retrieved using accessibility_tree_for_testing(). | 437 // retrieved using accessibility_tree_for_testing(). |
| 423 void SetAccessibilityCallbackForTesting( | 438 void SetAccessibilityCallbackForTesting( |
| 424 const base::Callback<void(WebKit::WebAXEvent)>& callback); | 439 const base::Callback<void(WebKit::WebAXEvent)>& callback); |
| 425 | 440 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 453 bool CanCommitURL(const GURL& url); | 468 bool CanCommitURL(const GURL& url); |
| 454 | 469 |
| 455 // Checks that the given renderer can request |url|, if not it sets it to | 470 // Checks that the given renderer can request |url|, if not it sets it to |
| 456 // about:blank. | 471 // about:blank. |
| 457 // empty_allowed must be set to false for navigations for security reasons. | 472 // empty_allowed must be set to false for navigations for security reasons. |
| 458 static void FilterURL(ChildProcessSecurityPolicyImpl* policy, | 473 static void FilterURL(ChildProcessSecurityPolicyImpl* policy, |
| 459 const RenderProcessHost* process, | 474 const RenderProcessHost* process, |
| 460 bool empty_allowed, | 475 bool empty_allowed, |
| 461 GURL* url); | 476 GURL* url); |
| 462 | 477 |
| 463 // Update the FrameTree to use this RenderViewHost's main frame | |
| 464 // RenderFrameHost. Called when the RenderViewHost is committed. | |
| 465 // | |
| 466 // TODO(ajwong): Remove once RenderViewHost no longer owns the main frame | |
| 467 // RenderFrameHost. | |
| 468 void AttachToFrameTree(); | |
| 469 | |
| 470 // The following IPC handlers are public so RenderFrameHost can call them, | 478 // The following IPC handlers are public so RenderFrameHost can call them, |
| 471 // while we transition the code to not use RenderViewHost. | 479 // while we transition the code to not use RenderViewHost. |
| 472 // | 480 // |
| 473 // TODO(nasko): Remove those methods once we are done moving navigation | 481 // TODO(nasko): Remove those methods once we are done moving navigation |
| 474 // into RenderFrameHost. | 482 // into RenderFrameHost. |
| 475 void OnDidStartProvisionalLoadForFrame(int64 frame_id, | 483 void OnDidStartProvisionalLoadForFrame(int64 frame_id, |
| 476 int64 parent_frame_id, | 484 int64 parent_frame_id, |
| 477 bool main_frame, | 485 bool main_frame, |
| 478 const GURL& url); | 486 const GURL& url); |
| 479 | 487 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 void OnCancelDesktopNotification(int notification_id); | 591 void OnCancelDesktopNotification(int notification_id); |
| 584 void OnRunFileChooser(const FileChooserParams& params); | 592 void OnRunFileChooser(const FileChooserParams& params); |
| 585 void OnDidAccessInitialDocument(); | 593 void OnDidAccessInitialDocument(); |
| 586 void OnDomOperationResponse(const std::string& json_string, | 594 void OnDomOperationResponse(const std::string& json_string, |
| 587 int automation_id); | 595 int automation_id); |
| 588 | 596 |
| 589 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 597 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
| 590 void OnShowPopup(const ViewHostMsg_ShowPopup_Params& params); | 598 void OnShowPopup(const ViewHostMsg_ShowPopup_Params& params); |
| 591 #endif | 599 #endif |
| 592 | 600 |
| 593 // TODO(nasko): Remove this accessor once RenderFrameHost moves into the frame | |
| 594 // tree. | |
| 595 RenderFrameHostImpl* main_render_frame_host() const { | |
| 596 return main_render_frame_host_.get(); | |
| 597 } | |
| 598 | |
| 599 private: | 601 private: |
| 600 friend class TestRenderViewHost; | 602 friend class TestRenderViewHost; |
| 601 FRIEND_TEST_ALL_PREFIXES(RenderViewHostTest, BasicRenderFrameHost); | 603 FRIEND_TEST_ALL_PREFIXES(RenderViewHostTest, BasicRenderFrameHost); |
| 602 FRIEND_TEST_ALL_PREFIXES(RenderViewHostTest, RoutingIdSane); | 604 FRIEND_TEST_ALL_PREFIXES(RenderViewHostTest, RoutingIdSane); |
| 603 | 605 |
| 606 typedef base::hash_map<int64, int64> FrameIDMap; |
| 607 |
| 604 // Sets whether this RenderViewHost is swapped out in favor of another, | 608 // Sets whether this RenderViewHost is swapped out in favor of another, |
| 605 // and clears any waiting state that is no longer relevant. | 609 // and clears any waiting state that is no longer relevant. |
| 606 void SetSwappedOut(bool is_swapped_out); | 610 void SetSwappedOut(bool is_swapped_out); |
| 607 | 611 |
| 608 bool CanAccessFilesOfPageState(const PageState& state) const; | 612 bool CanAccessFilesOfPageState(const PageState& state) const; |
| 609 | 613 |
| 610 // All RenderViewHosts must have a RenderFrameHost for its main frame. | |
| 611 // Currently the RenderFrameHost is created in lock step on construction | |
| 612 // and a pointer to the main frame is given to the FrameTreeNode | |
| 613 // when the RenderViewHost commits (see AttachToFrameTree()). | |
| 614 // | |
| 615 // TODO(ajwong): Make this reference non-owning. The root FrameTreeNode of | |
| 616 // the FrameTree should be responsible for owning the main frame's | |
| 617 // RenderFrameHost. | |
| 618 scoped_ptr<RenderFrameHostImpl> main_render_frame_host_; | |
| 619 | |
| 620 // Our delegate, which wants to know about changes in the RenderView. | 614 // Our delegate, which wants to know about changes in the RenderView. |
| 621 RenderViewHostDelegate* delegate_; | 615 RenderViewHostDelegate* delegate_; |
| 622 | 616 |
| 623 // The SiteInstance associated with this RenderViewHost. All pages drawn | 617 // The SiteInstance associated with this RenderViewHost. All pages drawn |
| 624 // in this RenderViewHost are part of this SiteInstance. Should not change | 618 // in this RenderViewHost are part of this SiteInstance. Should not change |
| 625 // over time. | 619 // over time. |
| 626 scoped_refptr<SiteInstanceImpl> instance_; | 620 scoped_refptr<SiteInstanceImpl> instance_; |
| 627 | 621 |
| 622 // Map of renderer-specific frame IDs to browser-global FrameTreeNode IDs. |
| 623 FrameIDMap frame_id_map_; |
| 624 |
| 628 // true if we are currently waiting for a response for drag context | 625 // true if we are currently waiting for a response for drag context |
| 629 // information. | 626 // information. |
| 630 bool waiting_for_drag_context_response_; | 627 bool waiting_for_drag_context_response_; |
| 631 | 628 |
| 632 // A bitwise OR of bindings types that have been enabled for this RenderView. | 629 // A bitwise OR of bindings types that have been enabled for this RenderView. |
| 633 // See BindingsPolicy for details. | 630 // See BindingsPolicy for details. |
| 634 int enabled_bindings_; | 631 int enabled_bindings_; |
| 635 | 632 |
| 636 // Whether we should buffer outgoing Navigate messages rather than sending | 633 // Whether we should buffer outgoing Navigate messages rather than sending |
| 637 // them. This will be true when a RenderViewHost is created for a cross-site | 634 // them. This will be true when a RenderViewHost is created for a cross-site |
| (...skipping 14 matching lines...) Expand all Loading... |
| 652 bool has_accessed_initial_document_; | 649 bool has_accessed_initial_document_; |
| 653 | 650 |
| 654 // Whether this RenderViewHost is currently swapped out, such that the view is | 651 // Whether this RenderViewHost is currently swapped out, such that the view is |
| 655 // being rendered by another process. | 652 // being rendered by another process. |
| 656 bool is_swapped_out_; | 653 bool is_swapped_out_; |
| 657 | 654 |
| 658 // Whether this RenderView is responsible for displaying a subframe in a | 655 // Whether this RenderView is responsible for displaying a subframe in a |
| 659 // different process from its parent page. | 656 // different process from its parent page. |
| 660 bool is_subframe_; | 657 bool is_subframe_; |
| 661 | 658 |
| 662 // The frame id of the main (top level) frame. This value is set on the | 659 // Routing ID for the main frame's RenderFrameHost. |
| 663 // initial navigation of a RenderView and reset when the RenderView's | 660 // TODO(creis): Does this need to be updated on a crash? |
| 664 // process is terminated (in RenderProcessGone). | 661 int main_frame_routing_id_; |
| 665 int64 main_frame_id_; | |
| 666 | 662 |
| 667 // If we were asked to RunModal, then this will hold the reply_msg that we | 663 // If we were asked to RunModal, then this will hold the reply_msg that we |
| 668 // must return to the renderer to unblock it. | 664 // must return to the renderer to unblock it. |
| 669 IPC::Message* run_modal_reply_msg_; | 665 IPC::Message* run_modal_reply_msg_; |
| 670 // This will hold the routing id of the RenderView that opened us. | 666 // This will hold the routing id of the RenderView that opened us. |
| 671 int run_modal_opener_id_; | 667 int run_modal_opener_id_; |
| 672 | 668 |
| 673 // Set to true when there is a pending ViewMsg_ShouldClose message. This | 669 // Set to true when there is a pending ViewMsg_ShouldClose message. This |
| 674 // ensures we don't spam the renderer with multiple beforeunload requests. | 670 // ensures we don't spam the renderer with multiple beforeunload requests. |
| 675 // When either this value or is_waiting_for_unload_ack_ is true, the value of | 671 // 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... |
| 720 DISALLOW_COPY_AND_ASSIGN(RenderViewHostImpl); | 716 DISALLOW_COPY_AND_ASSIGN(RenderViewHostImpl); |
| 721 }; | 717 }; |
| 722 | 718 |
| 723 #if defined(COMPILER_MSVC) | 719 #if defined(COMPILER_MSVC) |
| 724 #pragma warning(pop) | 720 #pragma warning(pop) |
| 725 #endif | 721 #endif |
| 726 | 722 |
| 727 } // namespace content | 723 } // namespace content |
| 728 | 724 |
| 729 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_IMPL_H_ | 725 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_IMPL_H_ |
| OLD | NEW |