| 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> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "content/browser/media/audio_stream_monitor.h" | 25 #include "content/browser/media/audio_stream_monitor.h" |
| 26 #include "content/browser/renderer_host/render_view_host_delegate.h" | 26 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 27 #include "content/browser/renderer_host/render_view_host_impl.h" | 27 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 28 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 28 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 29 #include "content/common/accessibility_mode_enums.h" | 29 #include "content/common/accessibility_mode_enums.h" |
| 30 #include "content/common/content_export.h" | 30 #include "content/common/content_export.h" |
| 31 #include "content/public/browser/color_chooser.h" | 31 #include "content/public/browser/color_chooser.h" |
| 32 #include "content/public/browser/notification_observer.h" | 32 #include "content/public/browser/notification_observer.h" |
| 33 #include "content/public/browser/notification_registrar.h" | 33 #include "content/public/browser/notification_registrar.h" |
| 34 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
| 35 #include "content/public/browser/web_contents_observer.h" |
| 35 #include "content/public/common/page_importance_signals.h" | 36 #include "content/public/common/page_importance_signals.h" |
| 36 #include "content/public/common/renderer_preferences.h" | 37 #include "content/public/common/renderer_preferences.h" |
| 37 #include "content/public/common/resource_type.h" | 38 #include "content/public/common/resource_type.h" |
| 38 #include "content/public/common/three_d_api_types.h" | 39 #include "content/public/common/three_d_api_types.h" |
| 39 #include "net/base/load_states.h" | 40 #include "net/base/load_states.h" |
| 40 #include "net/http/http_response_headers.h" | 41 #include "net/http/http_response_headers.h" |
| 41 #include "third_party/WebKit/public/web/WebDragOperation.h" | 42 #include "third_party/WebKit/public/web/WebDragOperation.h" |
| 42 #include "ui/base/page_transition_types.h" | 43 #include "ui/base/page_transition_types.h" |
| 43 #include "ui/gfx/geometry/rect_f.h" | 44 #include "ui/gfx/geometry/rect_f.h" |
| 44 #include "ui/gfx/geometry/size.h" | 45 #include "ui/gfx/geometry/size.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 62 class RenderWidgetHostImpl; | 63 class RenderWidgetHostImpl; |
| 63 class RenderWidgetHostInputEventRouter; | 64 class RenderWidgetHostInputEventRouter; |
| 64 class SavePackage; | 65 class SavePackage; |
| 65 class ScreenOrientationDispatcherHost; | 66 class ScreenOrientationDispatcherHost; |
| 66 class SiteInstance; | 67 class SiteInstance; |
| 67 class TestWebContents; | 68 class TestWebContents; |
| 68 class WakeLockServiceContext; | 69 class WakeLockServiceContext; |
| 69 class WebContentsAudioMuter; | 70 class WebContentsAudioMuter; |
| 70 class WebContentsDelegate; | 71 class WebContentsDelegate; |
| 71 class WebContentsImpl; | 72 class WebContentsImpl; |
| 72 class WebContentsObserver; | |
| 73 class WebContentsView; | 73 class WebContentsView; |
| 74 class WebContentsViewDelegate; | 74 class WebContentsViewDelegate; |
| 75 struct AXEventNotificationDetails; | 75 struct AXEventNotificationDetails; |
| 76 struct ColorSuggestion; | 76 struct ColorSuggestion; |
| 77 struct FaviconURL; | 77 struct FaviconURL; |
| 78 struct LoadNotificationDetails; | 78 struct LoadNotificationDetails; |
| 79 struct ResourceRedirectDetails; | 79 struct ResourceRedirectDetails; |
| 80 struct ResourceRequestDetails; | 80 struct ResourceRequestDetails; |
| 81 | 81 |
| 82 #if defined(OS_ANDROID) && !defined(USE_AURA) | 82 #if defined(OS_ANDROID) && !defined(USE_AURA) |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 | 706 |
| 707 typedef base::Callback<void(WebContents*)> CreatedCallback; | 707 typedef base::Callback<void(WebContents*)> CreatedCallback; |
| 708 | 708 |
| 709 // Forces overscroll to be disabled (used by touch emulation). | 709 // Forces overscroll to be disabled (used by touch emulation). |
| 710 void SetForceDisableOverscrollContent(bool force_disable); | 710 void SetForceDisableOverscrollContent(bool force_disable); |
| 711 | 711 |
| 712 AudioStreamMonitor* audio_stream_monitor() { | 712 AudioStreamMonitor* audio_stream_monitor() { |
| 713 return &audio_stream_monitor_; | 713 return &audio_stream_monitor_; |
| 714 } | 714 } |
| 715 | 715 |
| 716 bool has_audio_power_save_blocker_for_testing() const { | 716 // Called by MediaWebContentsObserver when playback starts or stops. See the |
| 717 return audio_power_save_blocker_; | 717 // WebContentsObserver function stubs for more details. |
| 718 } | 718 void MediaStartedPlaying(const WebContentsObserver::MediaPlayerId& id); |
| 719 void MediaPaused(const WebContentsObserver::MediaPlayerId& id); |
| 719 | 720 |
| 720 bool has_video_power_save_blocker_for_testing() const { | |
| 721 return video_power_save_blocker_; | |
| 722 } | |
| 723 | |
| 724 #if defined(ENABLE_BROWSER_CDMS) | |
| 725 MediaWebContentsObserver* media_web_contents_observer() { | 721 MediaWebContentsObserver* media_web_contents_observer() { |
| 726 return media_web_contents_observer_.get(); | 722 return media_web_contents_observer_.get(); |
| 727 } | 723 } |
| 728 #endif | |
| 729 | 724 |
| 730 private: | 725 private: |
| 731 friend class WebContentsObserver; | 726 friend class WebContentsObserver; |
| 732 friend class WebContents; // To implement factory methods. | 727 friend class WebContents; // To implement factory methods. |
| 733 | 728 |
| 734 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials); | 729 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials); |
| 735 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle); | 730 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle); |
| 736 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, FindOpenerRVHWhenPending); | 731 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, FindOpenerRVHWhenPending); |
| 737 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, | 732 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, |
| 738 CrossSiteCantPreemptAfterUnload); | 733 CrossSiteCantPreemptAfterUnload); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 | 891 |
| 897 // Callback function when requesting permission to access the PPAPI broker. | 892 // Callback function when requesting permission to access the PPAPI broker. |
| 898 // |result| is true if permission was granted. | 893 // |result| is true if permission was granted. |
| 899 void OnPpapiBrokerPermissionResult(int routing_id, bool result); | 894 void OnPpapiBrokerPermissionResult(int routing_id, bool result); |
| 900 | 895 |
| 901 void OnBrowserPluginMessage(RenderFrameHost* render_frame_host, | 896 void OnBrowserPluginMessage(RenderFrameHost* render_frame_host, |
| 902 const IPC::Message& message); | 897 const IPC::Message& message); |
| 903 #endif // defined(ENABLE_PLUGINS) | 898 #endif // defined(ENABLE_PLUGINS) |
| 904 void OnUpdateFaviconURL(const std::vector<FaviconURL>& candidates); | 899 void OnUpdateFaviconURL(const std::vector<FaviconURL>& candidates); |
| 905 void OnFirstVisuallyNonEmptyPaint(); | 900 void OnFirstVisuallyNonEmptyPaint(); |
| 906 void OnMediaPlayingNotification(int64 player_cookie, | |
| 907 bool has_video, | |
| 908 bool has_audio, | |
| 909 bool is_remote); | |
| 910 void OnMediaPausedNotification(int64 player_cookie); | |
| 911 void OnShowValidationMessage(const gfx::Rect& anchor_in_root_view, | 901 void OnShowValidationMessage(const gfx::Rect& anchor_in_root_view, |
| 912 const base::string16& main_text, | 902 const base::string16& main_text, |
| 913 const base::string16& sub_text); | 903 const base::string16& sub_text); |
| 914 void OnHideValidationMessage(); | 904 void OnHideValidationMessage(); |
| 915 void OnMoveValidationMessage(const gfx::Rect& anchor_in_root_view); | 905 void OnMoveValidationMessage(const gfx::Rect& anchor_in_root_view); |
| 916 | 906 |
| 917 // Called by derived classes to indicate that we're no longer waiting for a | 907 // Called by derived classes to indicate that we're no longer waiting for a |
| 918 // response. This won't actually update the throbber, but it will get picked | 908 // response. This won't actually update the throbber, but it will get picked |
| 919 // up at the next animation step if the throbber is going. | 909 // up at the next animation step if the throbber is going. |
| 920 void SetNotWaitingForResponse() { waiting_for_response_ = false; } | 910 void SetNotWaitingForResponse() { waiting_for_response_ = false; } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 | 978 |
| 989 void SetEncoding(const std::string& encoding); | 979 void SetEncoding(const std::string& encoding); |
| 990 | 980 |
| 991 // TODO(creis): This should take in a FrameTreeNode to know which node's | 981 // TODO(creis): This should take in a FrameTreeNode to know which node's |
| 992 // render manager to return. For now, we just return the root's. | 982 // render manager to return. For now, we just return the root's. |
| 993 RenderFrameHostManager* GetRenderManager() const; | 983 RenderFrameHostManager* GetRenderManager() const; |
| 994 | 984 |
| 995 // Removes browser plugin embedder if there is one. | 985 // Removes browser plugin embedder if there is one. |
| 996 void RemoveBrowserPluginEmbedder(); | 986 void RemoveBrowserPluginEmbedder(); |
| 997 | 987 |
| 998 // Clear |render_frame_host|'s tracking entry for its power save blockers. | |
| 999 void ClearPowerSaveBlockers(RenderFrameHost* render_frame_host); | |
| 1000 | |
| 1001 // Clear tracking entries for all RenderFrameHosts, clears | |
| 1002 // |audio_power_save_blocker_| and |video_power_save_blocker_|. | |
| 1003 void ClearAllPowerSaveBlockers(); | |
| 1004 | |
| 1005 // Creates an audio or video power save blocker respectively. | |
| 1006 void CreateAudioPowerSaveBlocker(); | |
| 1007 void CreateVideoPowerSaveBlocker(); | |
| 1008 | |
| 1009 // Releases the audio power save blockers if |active_audio_players_| is empty. | |
| 1010 // Likewise, releases the video power save blockers if |active_video_players_| | |
| 1011 // is empty. | |
| 1012 void MaybeReleasePowerSaveBlockers(); | |
| 1013 | |
| 1014 // Helper function to invoke WebContentsDelegate::GetSizeForNewRenderView(). | 988 // Helper function to invoke WebContentsDelegate::GetSizeForNewRenderView(). |
| 1015 gfx::Size GetSizeForNewRenderView(); | 989 gfx::Size GetSizeForNewRenderView(); |
| 1016 | 990 |
| 1017 void OnFrameRemoved(RenderFrameHost* render_frame_host); | 991 void OnFrameRemoved(RenderFrameHost* render_frame_host); |
| 1018 | 992 |
| 1019 // Helper method that's called whenever |preferred_size_| or | 993 // Helper method that's called whenever |preferred_size_| or |
| 1020 // |preferred_size_for_capture_| changes, to propagate the new value to the | 994 // |preferred_size_for_capture_| changes, to propagate the new value to the |
| 1021 // |delegate_|. | 995 // |delegate_|. |
| 1022 void OnPreferredSizeChanged(const gfx::Size& old_size); | 996 void OnPreferredSizeChanged(const gfx::Size& old_size); |
| 1023 | 997 |
| 1024 // Helper methods for adding or removing player entries in |player_map| under | |
| 1025 // the key |render_frame_message_source_|. | |
| 1026 typedef std::vector<int64> PlayerList; | |
| 1027 typedef std::map<uintptr_t, PlayerList> ActiveMediaPlayerMap; | |
| 1028 void AddMediaPlayerEntry(int64 player_cookie, | |
| 1029 ActiveMediaPlayerMap* player_map); | |
| 1030 void RemoveMediaPlayerEntry(int64 player_cookie, | |
| 1031 ActiveMediaPlayerMap* player_map); | |
| 1032 // Removes all entries from |player_map| for |render_frame_host|. | |
| 1033 void RemoveAllMediaPlayerEntries(RenderFrameHost* render_frame_host, | |
| 1034 ActiveMediaPlayerMap* player_map); | |
| 1035 | |
| 1036 // Internal helper to create WebUI objects associated with |this|. |url| is | 998 // Internal helper to create WebUI objects associated with |this|. |url| is |
| 1037 // used to determine which WebUI should be created (if any). |frame_name| | 999 // used to determine which WebUI should be created (if any). |frame_name| |
| 1038 // corresponds to the name of a frame that the WebUI should be created for (or | 1000 // corresponds to the name of a frame that the WebUI should be created for (or |
| 1039 // the main frame if empty). | 1001 // the main frame if empty). |
| 1040 WebUI* CreateWebUI(const GURL& url, const std::string& frame_name); | 1002 WebUI* CreateWebUI(const GURL& url, const std::string& frame_name); |
| 1041 | 1003 |
| 1042 // Data for core operation --------------------------------------------------- | 1004 // Data for core operation --------------------------------------------------- |
| 1043 | 1005 |
| 1044 // Delegate for notifying our owner about stuff. Not owned by us. | 1006 // Delegate for notifying our owner about stuff. Not owned by us. |
| 1045 WebContentsDelegate* delegate_; | 1007 WebContentsDelegate* delegate_; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 // True if this tab was opened by another tab. This is not unset if the opener | 1039 // True if this tab was opened by another tab. This is not unset if the opener |
| 1078 // is closed. | 1040 // is closed. |
| 1079 bool created_with_opener_; | 1041 bool created_with_opener_; |
| 1080 | 1042 |
| 1081 #if defined(OS_WIN) | 1043 #if defined(OS_WIN) |
| 1082 gfx::NativeViewAccessible accessible_parent_; | 1044 gfx::NativeViewAccessible accessible_parent_; |
| 1083 #endif | 1045 #endif |
| 1084 | 1046 |
| 1085 // Helper classes ------------------------------------------------------------ | 1047 // Helper classes ------------------------------------------------------------ |
| 1086 | 1048 |
| 1087 // Tracking variables and associated power save blockers for media playback. | |
| 1088 ActiveMediaPlayerMap active_audio_players_; | |
| 1089 ActiveMediaPlayerMap active_video_players_; | |
| 1090 scoped_ptr<PowerSaveBlocker> audio_power_save_blocker_; | |
| 1091 scoped_ptr<PowerSaveBlocker> video_power_save_blocker_; | |
| 1092 | |
| 1093 // Manages the frame tree of the page and process swaps in each node. | 1049 // Manages the frame tree of the page and process swaps in each node. |
| 1094 FrameTree frame_tree_; | 1050 FrameTree frame_tree_; |
| 1095 | 1051 |
| 1096 // If this WebContents is part of a "tree of WebContents", then this contains | 1052 // If this WebContents is part of a "tree of WebContents", then this contains |
| 1097 // information about the structure. | 1053 // information about the structure. |
| 1098 scoped_ptr<WebContentsTreeNode> node_; | 1054 scoped_ptr<WebContentsTreeNode> node_; |
| 1099 | 1055 |
| 1100 // SavePackage, lazily created. | 1056 // SavePackage, lazily created. |
| 1101 scoped_refptr<SavePackage> save_package_; | 1057 scoped_refptr<SavePackage> save_package_; |
| 1102 | 1058 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1315 AccessibilityMode accessibility_mode_; | 1271 AccessibilityMode accessibility_mode_; |
| 1316 | 1272 |
| 1317 // Monitors power levels for audio streams associated with this WebContents. | 1273 // Monitors power levels for audio streams associated with this WebContents. |
| 1318 AudioStreamMonitor audio_stream_monitor_; | 1274 AudioStreamMonitor audio_stream_monitor_; |
| 1319 | 1275 |
| 1320 // Created on-demand to mute all audio output from this WebContents. | 1276 // Created on-demand to mute all audio output from this WebContents. |
| 1321 scoped_ptr<WebContentsAudioMuter> audio_muter_; | 1277 scoped_ptr<WebContentsAudioMuter> audio_muter_; |
| 1322 | 1278 |
| 1323 bool virtual_keyboard_requested_; | 1279 bool virtual_keyboard_requested_; |
| 1324 | 1280 |
| 1325 #if defined(ENABLE_BROWSER_CDMS) | 1281 // Manages media players, CDMs, and power save blockers for media. |
| 1326 // Manages all the media player and CDM managers and forwards IPCs to them. | |
| 1327 scoped_ptr<MediaWebContentsObserver> media_web_contents_observer_; | 1282 scoped_ptr<MediaWebContentsObserver> media_web_contents_observer_; |
| 1328 #endif | |
| 1329 | 1283 |
| 1330 scoped_ptr<RenderWidgetHostInputEventRouter> rwh_input_event_router_; | 1284 scoped_ptr<RenderWidgetHostInputEventRouter> rwh_input_event_router_; |
| 1331 | 1285 |
| 1332 PageImportanceSignals page_importance_signals_; | 1286 PageImportanceSignals page_importance_signals_; |
| 1333 | 1287 |
| 1334 bool page_scale_factor_is_one_; | 1288 bool page_scale_factor_is_one_; |
| 1335 | 1289 |
| 1336 base::WeakPtrFactory<WebContentsImpl> loading_weak_factory_; | 1290 base::WeakPtrFactory<WebContentsImpl> loading_weak_factory_; |
| 1337 | 1291 |
| 1338 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl); | 1292 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1351 // Adds/removes a callback called on creation of each new WebContents. | 1305 // Adds/removes a callback called on creation of each new WebContents. |
| 1352 static void AddCreatedCallbackForTesting(const CreatedCallback& callback); | 1306 static void AddCreatedCallbackForTesting(const CreatedCallback& callback); |
| 1353 static void RemoveCreatedCallbackForTesting(const CreatedCallback& callback); | 1307 static void RemoveCreatedCallbackForTesting(const CreatedCallback& callback); |
| 1354 | 1308 |
| 1355 DISALLOW_COPY_AND_ASSIGN(FriendZone); | 1309 DISALLOW_COPY_AND_ASSIGN(FriendZone); |
| 1356 }; | 1310 }; |
| 1357 | 1311 |
| 1358 } // namespace content | 1312 } // namespace content |
| 1359 | 1313 |
| 1360 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ | 1314 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
| OLD | NEW |