| 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_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
| 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 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/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "base/process/process.h" | 16 #include "base/process/process.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "content/browser/renderer_host/frame_tree.h" |
| 18 #include "content/browser/renderer_host/render_view_host_delegate.h" | 19 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 19 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 20 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 20 #include "content/browser/web_contents/frame_tree_node.h" | |
| 21 #include "content/browser/web_contents/navigation_controller_impl.h" | 21 #include "content/browser/web_contents/navigation_controller_impl.h" |
| 22 #include "content/browser/web_contents/render_view_host_manager.h" | 22 #include "content/browser/web_contents/render_view_host_manager.h" |
| 23 #include "content/common/content_export.h" | 23 #include "content/common/content_export.h" |
| 24 #include "content/public/browser/notification_observer.h" | 24 #include "content/public/browser/notification_observer.h" |
| 25 #include "content/public/browser/notification_registrar.h" | 25 #include "content/public/browser/notification_registrar.h" |
| 26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 27 #include "content/public/common/renderer_preferences.h" | 27 #include "content/public/common/renderer_preferences.h" |
| 28 #include "content/public/common/three_d_api_types.h" | 28 #include "content/public/common/three_d_api_types.h" |
| 29 #include "net/base/load_states.h" | 29 #include "net/base/load_states.h" |
| 30 #include "third_party/WebKit/public/web/WebDragOperation.h" | 30 #include "third_party/WebKit/public/web/WebDragOperation.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // Informs the render view host and the BrowserPluginEmbedder, if present, of | 196 // Informs the render view host and the BrowserPluginEmbedder, if present, of |
| 197 // a Drag Source End. | 197 // a Drag Source End. |
| 198 void DragSourceEndedAt(int client_x, int client_y, int screen_x, | 198 void DragSourceEndedAt(int client_x, int client_y, int screen_x, |
| 199 int screen_y, WebKit::WebDragOperation operation); | 199 int screen_y, WebKit::WebDragOperation operation); |
| 200 | 200 |
| 201 // Informs the render view host and the BrowserPluginEmbedder, if present, of | 201 // Informs the render view host and the BrowserPluginEmbedder, if present, of |
| 202 // a Drag Source Move. | 202 // a Drag Source Move. |
| 203 void DragSourceMovedTo(int client_x, int client_y, | 203 void DragSourceMovedTo(int client_x, int client_y, |
| 204 int screen_x, int screen_y); | 204 int screen_x, int screen_y); |
| 205 | 205 |
| 206 FrameTreeNode* GetFrameTreeRootForTesting() { | |
| 207 return frame_tree_root_.get(); | |
| 208 } | |
| 209 | |
| 210 // WebContents ------------------------------------------------------ | 206 // WebContents ------------------------------------------------------ |
| 211 virtual WebContentsDelegate* GetDelegate() OVERRIDE; | 207 virtual WebContentsDelegate* GetDelegate() OVERRIDE; |
| 212 virtual void SetDelegate(WebContentsDelegate* delegate) OVERRIDE; | 208 virtual void SetDelegate(WebContentsDelegate* delegate) OVERRIDE; |
| 213 virtual NavigationControllerImpl& GetController() OVERRIDE; | 209 virtual NavigationControllerImpl& GetController() OVERRIDE; |
| 214 virtual const NavigationControllerImpl& GetController() const OVERRIDE; | 210 virtual const NavigationControllerImpl& GetController() const OVERRIDE; |
| 215 virtual BrowserContext* GetBrowserContext() const OVERRIDE; | 211 virtual BrowserContext* GetBrowserContext() const OVERRIDE; |
| 216 virtual RenderProcessHost* GetRenderProcessHost() const OVERRIDE; | 212 virtual RenderProcessHost* GetRenderProcessHost() const OVERRIDE; |
| 217 virtual RenderViewHost* GetRenderViewHost() const OVERRIDE; | 213 virtual RenderViewHost* GetRenderViewHost() const OVERRIDE; |
| 218 virtual void GetRenderViewHostAtPosition( | 214 virtual void GetRenderViewHostAtPosition( |
| 219 int x, | 215 int x, |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 bool user_gesture) OVERRIDE; | 455 bool user_gesture) OVERRIDE; |
| 460 virtual void ShowCreatedWidget(int route_id, | 456 virtual void ShowCreatedWidget(int route_id, |
| 461 const gfx::Rect& initial_pos) OVERRIDE; | 457 const gfx::Rect& initial_pos) OVERRIDE; |
| 462 virtual void ShowCreatedFullscreenWidget(int route_id) OVERRIDE; | 458 virtual void ShowCreatedFullscreenWidget(int route_id) OVERRIDE; |
| 463 virtual void ShowContextMenu(const ContextMenuParams& params) OVERRIDE; | 459 virtual void ShowContextMenu(const ContextMenuParams& params) OVERRIDE; |
| 464 virtual void RequestMediaAccessPermission( | 460 virtual void RequestMediaAccessPermission( |
| 465 const MediaStreamRequest& request, | 461 const MediaStreamRequest& request, |
| 466 const MediaResponseCallback& callback) OVERRIDE; | 462 const MediaResponseCallback& callback) OVERRIDE; |
| 467 virtual SessionStorageNamespace* GetSessionStorageNamespace( | 463 virtual SessionStorageNamespace* GetSessionStorageNamespace( |
| 468 SiteInstance* instance) OVERRIDE; | 464 SiteInstance* instance) OVERRIDE; |
| 465 virtual FrameTree* GetFrameTree() OVERRIDE; |
| 469 | 466 |
| 470 // RenderWidgetHostDelegate -------------------------------------------------- | 467 // RenderWidgetHostDelegate -------------------------------------------------- |
| 471 | 468 |
| 472 virtual void RenderWidgetDeleted( | 469 virtual void RenderWidgetDeleted( |
| 473 RenderWidgetHostImpl* render_widget_host) OVERRIDE; | 470 RenderWidgetHostImpl* render_widget_host) OVERRIDE; |
| 474 virtual bool PreHandleKeyboardEvent( | 471 virtual bool PreHandleKeyboardEvent( |
| 475 const NativeWebKeyboardEvent& event, | 472 const NativeWebKeyboardEvent& event, |
| 476 bool* is_keyboard_shortcut) OVERRIDE; | 473 bool* is_keyboard_shortcut) OVERRIDE; |
| 477 virtual void HandleKeyboardEvent( | 474 virtual void HandleKeyboardEvent( |
| 478 const NativeWebKeyboardEvent& event) OVERRIDE; | 475 const NativeWebKeyboardEvent& event) OVERRIDE; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 const GURL& url, | 627 const GURL& url, |
| 631 const base::FilePath& plugin_path); | 628 const base::FilePath& plugin_path); |
| 632 void OnBrowserPluginMessage(const IPC::Message& message); | 629 void OnBrowserPluginMessage(const IPC::Message& message); |
| 633 void OnDidDownloadImage(int id, | 630 void OnDidDownloadImage(int id, |
| 634 int http_status_code, | 631 int http_status_code, |
| 635 const GURL& image_url, | 632 const GURL& image_url, |
| 636 const std::vector<SkBitmap>& bitmaps, | 633 const std::vector<SkBitmap>& bitmaps, |
| 637 const std::vector<gfx::Size>& original_bitmap_sizes); | 634 const std::vector<gfx::Size>& original_bitmap_sizes); |
| 638 void OnUpdateFaviconURL(int32 page_id, | 635 void OnUpdateFaviconURL(int32 page_id, |
| 639 const std::vector<FaviconURL>& candidates); | 636 const std::vector<FaviconURL>& candidates); |
| 640 void OnFrameAttached(int64 parent_frame_id, | |
| 641 int64 frame_id, | |
| 642 const std::string& frame_name); | |
| 643 void OnFrameDetached(int64 parent_frame_id, int64 frame_id); | |
| 644 | 637 |
| 645 void OnMediaNotification(int64 player_cookie, | 638 void OnMediaNotification(int64 player_cookie, |
| 646 bool has_video, | 639 bool has_video, |
| 647 bool has_audio, | 640 bool has_audio, |
| 648 bool is_playing); | 641 bool is_playing); |
| 649 | 642 |
| 650 // Changes the IsLoading state and notifies delegate as needed | 643 // Changes the IsLoading state and notifies delegate as needed |
| 651 // |details| is used to provide details on the load that just finished | 644 // |details| is used to provide details on the load that just finished |
| 652 // (but can be null if not applicable). Can be overridden. | 645 // (but can be null if not applicable). Can be overridden. |
| 653 void SetIsLoading(bool is_loading, | 646 void SetIsLoading(bool is_loading, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 | 739 |
| 747 // Helper functions for sending notifications. | 740 // Helper functions for sending notifications. |
| 748 void NotifySwapped(RenderViewHost* old_host, RenderViewHost* new_host); | 741 void NotifySwapped(RenderViewHost* old_host, RenderViewHost* new_host); |
| 749 void NotifyDisconnected(); | 742 void NotifyDisconnected(); |
| 750 void NotifyNavigationEntryCommitted(const LoadCommittedDetails& load_details); | 743 void NotifyNavigationEntryCommitted(const LoadCommittedDetails& load_details); |
| 751 | 744 |
| 752 void SetEncoding(const std::string& encoding); | 745 void SetEncoding(const std::string& encoding); |
| 753 | 746 |
| 754 RenderViewHostImpl* GetRenderViewHostImpl(); | 747 RenderViewHostImpl* GetRenderViewHostImpl(); |
| 755 | 748 |
| 756 FrameTreeNode* FindFrameTreeNodeByID(int64 frame_id); | |
| 757 | |
| 758 // Removes browser plugin embedder if there is one. | 749 // Removes browser plugin embedder if there is one. |
| 759 void RemoveBrowserPluginEmbedder(); | 750 void RemoveBrowserPluginEmbedder(); |
| 760 | 751 |
| 761 // Clear |render_view_host|'s PowerSaveBlockers. | 752 // Clear |render_view_host|'s PowerSaveBlockers. |
| 762 void ClearPowerSaveBlockers(RenderViewHost* render_view_host); | 753 void ClearPowerSaveBlockers(RenderViewHost* render_view_host); |
| 763 | 754 |
| 764 // Clear all PowerSaveBlockers, leave power_save_blocker_ empty. | 755 // Clear all PowerSaveBlockers, leave power_save_blocker_ empty. |
| 765 void ClearAllPowerSaveBlockers(); | 756 void ClearAllPowerSaveBlockers(); |
| 766 | 757 |
| 767 // Helper function to invoke WebContentsDelegate::GetSizeForNewRenderView(). | 758 // Helper function to invoke WebContentsDelegate::GetSizeForNewRenderView(). |
| 768 gfx::Size GetSizeForNewRenderView() const; | 759 gfx::Size GetSizeForNewRenderView() const; |
| 769 | 760 |
| 761 void OnFrameRemoved(RenderViewHostImpl* render_view_host, int64 frame_id); |
| 762 |
| 770 // Data for core operation --------------------------------------------------- | 763 // Data for core operation --------------------------------------------------- |
| 771 | 764 |
| 772 // Delegate for notifying our owner about stuff. Not owned by us. | 765 // Delegate for notifying our owner about stuff. Not owned by us. |
| 773 WebContentsDelegate* delegate_; | 766 WebContentsDelegate* delegate_; |
| 774 | 767 |
| 775 // Handles the back/forward list and loading. | 768 // Handles the back/forward list and loading. |
| 776 NavigationControllerImpl controller_; | 769 NavigationControllerImpl controller_; |
| 777 | 770 |
| 778 // The corresponding view. | 771 // The corresponding view. |
| 779 scoped_ptr<WebContentsViewPort> view_; | 772 scoped_ptr<WebContentsViewPort> view_; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 // Maps the RenderViewHost to its media_player_cookie and PowerSaveBlocker | 808 // Maps the RenderViewHost to its media_player_cookie and PowerSaveBlocker |
| 816 // pairs. Key is the RenderViewHost, value is the map which maps player_cookie | 809 // pairs. Key is the RenderViewHost, value is the map which maps player_cookie |
| 817 // on to PowerSaveBlocker. | 810 // on to PowerSaveBlocker. |
| 818 typedef std::map<RenderViewHost*, std::map<int64, PowerSaveBlocker*> > | 811 typedef std::map<RenderViewHost*, std::map<int64, PowerSaveBlocker*> > |
| 819 PowerSaveBlockerMap; | 812 PowerSaveBlockerMap; |
| 820 PowerSaveBlockerMap power_save_blockers_; | 813 PowerSaveBlockerMap power_save_blockers_; |
| 821 | 814 |
| 822 // Manages creation and swapping of render views. | 815 // Manages creation and swapping of render views. |
| 823 RenderViewHostManager render_manager_; | 816 RenderViewHostManager render_manager_; |
| 824 | 817 |
| 818 // The frame tree structure of the current page. |
| 819 FrameTree frame_tree_; |
| 820 |
| 825 #if defined(OS_ANDROID) | 821 #if defined(OS_ANDROID) |
| 826 // Manages injecting Java objects into all RenderViewHosts associated with | 822 // Manages injecting Java objects into all RenderViewHosts associated with |
| 827 // this WebContentsImpl. | 823 // this WebContentsImpl. |
| 828 scoped_ptr<JavaBridgeDispatcherHostManager> | 824 scoped_ptr<JavaBridgeDispatcherHostManager> |
| 829 java_bridge_dispatcher_host_manager_; | 825 java_bridge_dispatcher_host_manager_; |
| 830 #endif | 826 #endif |
| 831 | 827 |
| 832 // SavePackage, lazily created. | 828 // SavePackage, lazily created. |
| 833 scoped_refptr<SavePackage> save_package_; | 829 scoped_refptr<SavePackage> save_package_; |
| 834 | 830 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 // When a navigation occurs, we record its contents MIME type. It can be | 866 // When a navigation occurs, we record its contents MIME type. It can be |
| 871 // used to check whether we can do something for some special contents. | 867 // used to check whether we can do something for some special contents. |
| 872 std::string contents_mime_type_; | 868 std::string contents_mime_type_; |
| 873 | 869 |
| 874 // Character encoding. | 870 // Character encoding. |
| 875 std::string encoding_; | 871 std::string encoding_; |
| 876 | 872 |
| 877 // True if this is a secure page which displayed insecure content. | 873 // True if this is a secure page which displayed insecure content. |
| 878 bool displayed_insecure_content_; | 874 bool displayed_insecure_content_; |
| 879 | 875 |
| 880 // The frame tree structure of the current page. | |
| 881 scoped_ptr<FrameTreeNode> frame_tree_root_; | |
| 882 | |
| 883 // Data for misc internal state ---------------------------------------------- | 876 // Data for misc internal state ---------------------------------------------- |
| 884 | 877 |
| 885 // When > 0, the WebContents is currently being captured (e.g., for | 878 // When > 0, the WebContents is currently being captured (e.g., for |
| 886 // screenshots or mirroring); and the underlying RenderWidgetHost should not | 879 // screenshots or mirroring); and the underlying RenderWidgetHost should not |
| 887 // be told it is hidden. | 880 // be told it is hidden. |
| 888 int capturer_count_; | 881 int capturer_count_; |
| 889 | 882 |
| 890 // Tracks whether RWHV should be visible once capturer_count_ becomes zero. | 883 // Tracks whether RWHV should be visible once capturer_count_ becomes zero. |
| 891 bool should_normally_be_visible_; | 884 bool should_normally_be_visible_; |
| 892 | 885 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 // Maps the ids of pending image downloads to their callbacks | 964 // Maps the ids of pending image downloads to their callbacks |
| 972 typedef std::map<int, ImageDownloadCallback> ImageDownloadMap; | 965 typedef std::map<int, ImageDownloadCallback> ImageDownloadMap; |
| 973 ImageDownloadMap image_download_map_; | 966 ImageDownloadMap image_download_map_; |
| 974 | 967 |
| 975 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl); | 968 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl); |
| 976 }; | 969 }; |
| 977 | 970 |
| 978 } // namespace content | 971 } // namespace content |
| 979 | 972 |
| 980 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ | 973 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
| OLD | NEW |