| 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 MediaStoppedPlaying(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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 | 897 |
| 903 // Callback function when requesting permission to access the PPAPI broker. | 898 // Callback function when requesting permission to access the PPAPI broker. |
| 904 // |result| is true if permission was granted. | 899 // |result| is true if permission was granted. |
| 905 void OnPpapiBrokerPermissionResult(int routing_id, bool result); | 900 void OnPpapiBrokerPermissionResult(int routing_id, bool result); |
| 906 | 901 |
| 907 void OnBrowserPluginMessage(RenderFrameHost* render_frame_host, | 902 void OnBrowserPluginMessage(RenderFrameHost* render_frame_host, |
| 908 const IPC::Message& message); | 903 const IPC::Message& message); |
| 909 #endif // defined(ENABLE_PLUGINS) | 904 #endif // defined(ENABLE_PLUGINS) |
| 910 void OnUpdateFaviconURL(const std::vector<FaviconURL>& candidates); | 905 void OnUpdateFaviconURL(const std::vector<FaviconURL>& candidates); |
| 911 void OnFirstVisuallyNonEmptyPaint(); | 906 void OnFirstVisuallyNonEmptyPaint(); |
| 912 void OnMediaPlayingNotification(int64 player_cookie, | |
| 913 bool has_video, | |
| 914 bool has_audio, | |
| 915 bool is_remote); | |
| 916 void OnMediaPausedNotification(int64 player_cookie); | |
| 917 void OnShowValidationMessage(const gfx::Rect& anchor_in_root_view, | 907 void OnShowValidationMessage(const gfx::Rect& anchor_in_root_view, |
| 918 const base::string16& main_text, | 908 const base::string16& main_text, |
| 919 const base::string16& sub_text); | 909 const base::string16& sub_text); |
| 920 void OnHideValidationMessage(); | 910 void OnHideValidationMessage(); |
| 921 void OnMoveValidationMessage(const gfx::Rect& anchor_in_root_view); | 911 void OnMoveValidationMessage(const gfx::Rect& anchor_in_root_view); |
| 922 | 912 |
| 923 // Called by derived classes to indicate that we're no longer waiting for a | 913 // Called by derived classes to indicate that we're no longer waiting for a |
| 924 // response. This won't actually update the throbber, but it will get picked | 914 // response. This won't actually update the throbber, but it will get picked |
| 925 // up at the next animation step if the throbber is going. | 915 // up at the next animation step if the throbber is going. |
| 926 void SetNotWaitingForResponse() { waiting_for_response_ = false; } | 916 void SetNotWaitingForResponse() { waiting_for_response_ = false; } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 | 984 |
| 995 void SetEncoding(const std::string& encoding); | 985 void SetEncoding(const std::string& encoding); |
| 996 | 986 |
| 997 // TODO(creis): This should take in a FrameTreeNode to know which node's | 987 // TODO(creis): This should take in a FrameTreeNode to know which node's |
| 998 // render manager to return. For now, we just return the root's. | 988 // render manager to return. For now, we just return the root's. |
| 999 RenderFrameHostManager* GetRenderManager() const; | 989 RenderFrameHostManager* GetRenderManager() const; |
| 1000 | 990 |
| 1001 // Removes browser plugin embedder if there is one. | 991 // Removes browser plugin embedder if there is one. |
| 1002 void RemoveBrowserPluginEmbedder(); | 992 void RemoveBrowserPluginEmbedder(); |
| 1003 | 993 |
| 1004 // Clear |render_frame_host|'s tracking entry for its power save blockers. | |
| 1005 void ClearPowerSaveBlockers(RenderFrameHost* render_frame_host); | |
| 1006 | |
| 1007 // Clear tracking entries for all RenderFrameHosts, clears | |
| 1008 // |audio_power_save_blocker_| and |video_power_save_blocker_|. | |
| 1009 void ClearAllPowerSaveBlockers(); | |
| 1010 | |
| 1011 // Creates an audio or video power save blocker respectively. | |
| 1012 void CreateAudioPowerSaveBlocker(); | |
| 1013 void CreateVideoPowerSaveBlocker(); | |
| 1014 | |
| 1015 // Releases the audio power save blockers if |active_audio_players_| is empty. | |
| 1016 // Likewise, releases the video power save blockers if |active_video_players_| | |
| 1017 // is empty. | |
| 1018 void MaybeReleasePowerSaveBlockers(); | |
| 1019 | |
| 1020 // Helper function to invoke WebContentsDelegate::GetSizeForNewRenderView(). | 994 // Helper function to invoke WebContentsDelegate::GetSizeForNewRenderView(). |
| 1021 gfx::Size GetSizeForNewRenderView(); | 995 gfx::Size GetSizeForNewRenderView(); |
| 1022 | 996 |
| 1023 void OnFrameRemoved(RenderFrameHost* render_frame_host); | 997 void OnFrameRemoved(RenderFrameHost* render_frame_host); |
| 1024 | 998 |
| 1025 // Helper method that's called whenever |preferred_size_| or | 999 // Helper method that's called whenever |preferred_size_| or |
| 1026 // |preferred_size_for_capture_| changes, to propagate the new value to the | 1000 // |preferred_size_for_capture_| changes, to propagate the new value to the |
| 1027 // |delegate_|. | 1001 // |delegate_|. |
| 1028 void OnPreferredSizeChanged(const gfx::Size& old_size); | 1002 void OnPreferredSizeChanged(const gfx::Size& old_size); |
| 1029 | 1003 |
| 1030 // Helper methods for adding or removing player entries in |player_map| under | |
| 1031 // the key |render_frame_message_source_|. | |
| 1032 typedef std::vector<int64> PlayerList; | |
| 1033 typedef std::map<uintptr_t, PlayerList> ActiveMediaPlayerMap; | |
| 1034 void AddMediaPlayerEntry(int64 player_cookie, | |
| 1035 ActiveMediaPlayerMap* player_map); | |
| 1036 void RemoveMediaPlayerEntry(int64 player_cookie, | |
| 1037 ActiveMediaPlayerMap* player_map); | |
| 1038 // Removes all entries from |player_map| for |render_frame_host|. | |
| 1039 void RemoveAllMediaPlayerEntries(RenderFrameHost* render_frame_host, | |
| 1040 ActiveMediaPlayerMap* player_map); | |
| 1041 | |
| 1042 // Internal helper to create WebUI objects associated with |this|. |url| is | 1004 // Internal helper to create WebUI objects associated with |this|. |url| is |
| 1043 // used to determine which WebUI should be created (if any). |frame_name| | 1005 // used to determine which WebUI should be created (if any). |frame_name| |
| 1044 // corresponds to the name of a frame that the WebUI should be created for (or | 1006 // corresponds to the name of a frame that the WebUI should be created for (or |
| 1045 // the main frame if empty). | 1007 // the main frame if empty). |
| 1046 WebUI* CreateWebUI(const GURL& url, const std::string& frame_name); | 1008 WebUI* CreateWebUI(const GURL& url, const std::string& frame_name); |
| 1047 | 1009 |
| 1048 // Data for core operation --------------------------------------------------- | 1010 // Data for core operation --------------------------------------------------- |
| 1049 | 1011 |
| 1050 // Delegate for notifying our owner about stuff. Not owned by us. | 1012 // Delegate for notifying our owner about stuff. Not owned by us. |
| 1051 WebContentsDelegate* delegate_; | 1013 WebContentsDelegate* delegate_; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 // True if this tab was opened by another tab. This is not unset if the opener | 1045 // True if this tab was opened by another tab. This is not unset if the opener |
| 1084 // is closed. | 1046 // is closed. |
| 1085 bool created_with_opener_; | 1047 bool created_with_opener_; |
| 1086 | 1048 |
| 1087 #if defined(OS_WIN) | 1049 #if defined(OS_WIN) |
| 1088 gfx::NativeViewAccessible accessible_parent_; | 1050 gfx::NativeViewAccessible accessible_parent_; |
| 1089 #endif | 1051 #endif |
| 1090 | 1052 |
| 1091 // Helper classes ------------------------------------------------------------ | 1053 // Helper classes ------------------------------------------------------------ |
| 1092 | 1054 |
| 1093 // Tracking variables and associated power save blockers for media playback. | |
| 1094 ActiveMediaPlayerMap active_audio_players_; | |
| 1095 ActiveMediaPlayerMap active_video_players_; | |
| 1096 scoped_ptr<PowerSaveBlocker> audio_power_save_blocker_; | |
| 1097 scoped_ptr<PowerSaveBlocker> video_power_save_blocker_; | |
| 1098 | |
| 1099 // Manages the frame tree of the page and process swaps in each node. | 1055 // Manages the frame tree of the page and process swaps in each node. |
| 1100 FrameTree frame_tree_; | 1056 FrameTree frame_tree_; |
| 1101 | 1057 |
| 1102 // If this WebContents is part of a "tree of WebContents", then this contains | 1058 // If this WebContents is part of a "tree of WebContents", then this contains |
| 1103 // information about the structure. | 1059 // information about the structure. |
| 1104 scoped_ptr<WebContentsTreeNode> node_; | 1060 scoped_ptr<WebContentsTreeNode> node_; |
| 1105 | 1061 |
| 1106 // SavePackage, lazily created. | 1062 // SavePackage, lazily created. |
| 1107 scoped_refptr<SavePackage> save_package_; | 1063 scoped_refptr<SavePackage> save_package_; |
| 1108 | 1064 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1321 AccessibilityMode accessibility_mode_; | 1277 AccessibilityMode accessibility_mode_; |
| 1322 | 1278 |
| 1323 // Monitors power levels for audio streams associated with this WebContents. | 1279 // Monitors power levels for audio streams associated with this WebContents. |
| 1324 AudioStreamMonitor audio_stream_monitor_; | 1280 AudioStreamMonitor audio_stream_monitor_; |
| 1325 | 1281 |
| 1326 // Created on-demand to mute all audio output from this WebContents. | 1282 // Created on-demand to mute all audio output from this WebContents. |
| 1327 scoped_ptr<WebContentsAudioMuter> audio_muter_; | 1283 scoped_ptr<WebContentsAudioMuter> audio_muter_; |
| 1328 | 1284 |
| 1329 bool virtual_keyboard_requested_; | 1285 bool virtual_keyboard_requested_; |
| 1330 | 1286 |
| 1331 #if defined(ENABLE_BROWSER_CDMS) | 1287 // Manages media players, CDMs, and power save blockers for media. |
| 1332 // Manages all the media player and CDM managers and forwards IPCs to them. | |
| 1333 scoped_ptr<MediaWebContentsObserver> media_web_contents_observer_; | 1288 scoped_ptr<MediaWebContentsObserver> media_web_contents_observer_; |
| 1334 #endif | |
| 1335 | 1289 |
| 1336 scoped_ptr<RenderWidgetHostInputEventRouter> rwh_input_event_router_; | 1290 scoped_ptr<RenderWidgetHostInputEventRouter> rwh_input_event_router_; |
| 1337 | 1291 |
| 1338 PageImportanceSignals page_importance_signals_; | 1292 PageImportanceSignals page_importance_signals_; |
| 1339 | 1293 |
| 1340 bool page_scale_factor_is_one_; | 1294 bool page_scale_factor_is_one_; |
| 1341 | 1295 |
| 1342 base::WeakPtrFactory<WebContentsImpl> loading_weak_factory_; | 1296 base::WeakPtrFactory<WebContentsImpl> loading_weak_factory_; |
| 1343 | 1297 |
| 1344 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl); | 1298 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1357 // Adds/removes a callback called on creation of each new WebContents. | 1311 // Adds/removes a callback called on creation of each new WebContents. |
| 1358 static void AddCreatedCallbackForTesting(const CreatedCallback& callback); | 1312 static void AddCreatedCallbackForTesting(const CreatedCallback& callback); |
| 1359 static void RemoveCreatedCallbackForTesting(const CreatedCallback& callback); | 1313 static void RemoveCreatedCallbackForTesting(const CreatedCallback& callback); |
| 1360 | 1314 |
| 1361 DISALLOW_COPY_AND_ASSIGN(FriendZone); | 1315 DISALLOW_COPY_AND_ASSIGN(FriendZone); |
| 1362 }; | 1316 }; |
| 1363 | 1317 |
| 1364 } // namespace content | 1318 } // namespace content |
| 1365 | 1319 |
| 1366 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ | 1320 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
| OLD | NEW |