| 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/containers/scoped_ptr_hash_map.h" | 13 #include "base/containers/scoped_ptr_hash_map.h" |
| 14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 17 #include "base/process/process.h" | 17 #include "base/process/process.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "content/browser/frame_host/frame_tree.h" | 19 #include "content/browser/frame_host/frame_tree.h" |
| 20 #include "content/browser/frame_host/navigation_controller_delegate.h" | 20 #include "content/browser/frame_host/navigation_controller_delegate.h" |
| 21 #include "content/browser/frame_host/navigation_controller_impl.h" | 21 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 22 #include "content/browser/frame_host/navigator_delegate.h" | 22 #include "content/browser/frame_host/navigator_delegate.h" |
| 23 #include "content/browser/frame_host/render_frame_host_delegate.h" | 23 #include "content/browser/frame_host/render_frame_host_delegate.h" |
| 24 #include "content/browser/frame_host/render_frame_host_manager.h" | 24 #include "content/browser/frame_host/render_frame_host_manager.h" |
| 25 #include "content/browser/media/audio_stream_monitor.h" | |
| 26 #include "content/browser/renderer_host/render_view_host_delegate.h" | 25 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 27 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 26 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 28 #include "content/common/accessibility_mode_enums.h" | 27 #include "content/common/accessibility_mode_enums.h" |
| 29 #include "content/common/content_export.h" | 28 #include "content/common/content_export.h" |
| 30 #include "content/public/browser/color_chooser.h" | 29 #include "content/public/browser/color_chooser.h" |
| 31 #include "content/public/browser/notification_observer.h" | 30 #include "content/public/browser/notification_observer.h" |
| 32 #include "content/public/browser/notification_registrar.h" | 31 #include "content/public/browser/notification_registrar.h" |
| 33 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
| 34 #include "content/public/common/page_transition_types.h" | 33 #include "content/public/common/page_transition_types.h" |
| 35 #include "content/public/common/renderer_preferences.h" | 34 #include "content/public/common/renderer_preferences.h" |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 virtual int DownloadImage(const GURL& url, | 322 virtual int DownloadImage(const GURL& url, |
| 324 bool is_favicon, | 323 bool is_favicon, |
| 325 uint32_t max_bitmap_size, | 324 uint32_t max_bitmap_size, |
| 326 const ImageDownloadCallback& callback) OVERRIDE; | 325 const ImageDownloadCallback& callback) OVERRIDE; |
| 327 virtual bool IsSubframe() const OVERRIDE; | 326 virtual bool IsSubframe() const OVERRIDE; |
| 328 virtual void Find(int request_id, | 327 virtual void Find(int request_id, |
| 329 const base::string16& search_text, | 328 const base::string16& search_text, |
| 330 const blink::WebFindOptions& options) OVERRIDE; | 329 const blink::WebFindOptions& options) OVERRIDE; |
| 331 virtual void StopFinding(StopFindAction action) OVERRIDE; | 330 virtual void StopFinding(StopFindAction action) OVERRIDE; |
| 332 virtual void InsertCSS(const std::string& css) OVERRIDE; | 331 virtual void InsertCSS(const std::string& css) OVERRIDE; |
| 333 virtual bool WasRecentlyAudible() OVERRIDE; | |
| 334 #if defined(OS_ANDROID) | 332 #if defined(OS_ANDROID) |
| 335 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents() | 333 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents() |
| 336 OVERRIDE; | 334 OVERRIDE; |
| 337 virtual WebContentsAndroid* GetWebContentsAndroid(); | 335 virtual WebContentsAndroid* GetWebContentsAndroid(); |
| 338 #elif defined(OS_MACOSX) | 336 #elif defined(OS_MACOSX) |
| 339 virtual void SetAllowOtherViews(bool allow) OVERRIDE; | 337 virtual void SetAllowOtherViews(bool allow) OVERRIDE; |
| 340 virtual bool GetAllowOtherViews() OVERRIDE; | 338 virtual bool GetAllowOtherViews() OVERRIDE; |
| 341 #endif | 339 #endif |
| 342 | 340 |
| 343 // Implementation of PageNavigator. | 341 // Implementation of PageNavigator. |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 // currently focused frame. | 662 // currently focused frame. |
| 665 void SelectRange(const gfx::Point& start, const gfx::Point& end); | 663 void SelectRange(const gfx::Point& start, const gfx::Point& end); |
| 666 | 664 |
| 667 // Notifies the main frame that it can continue navigation (if it was deferred | 665 // Notifies the main frame that it can continue navigation (if it was deferred |
| 668 // immediately at first response). | 666 // immediately at first response). |
| 669 void ResumeResponseDeferredAtStart(); | 667 void ResumeResponseDeferredAtStart(); |
| 670 | 668 |
| 671 // Forces overscroll to be disabled (used by touch emulation). | 669 // Forces overscroll to be disabled (used by touch emulation). |
| 672 void SetForceDisableOverscrollContent(bool force_disable); | 670 void SetForceDisableOverscrollContent(bool force_disable); |
| 673 | 671 |
| 674 AudioStreamMonitor* audio_stream_monitor() { | |
| 675 return &audio_stream_monitor_; | |
| 676 } | |
| 677 | |
| 678 bool has_audio_power_save_blocker_for_testing() const { | |
| 679 return audio_power_save_blocker_; | |
| 680 } | |
| 681 | |
| 682 bool has_video_power_save_blocker_for_testing() const { | |
| 683 return video_power_save_blocker_; | |
| 684 } | |
| 685 | |
| 686 private: | 672 private: |
| 687 friend class TestNavigationObserver; | 673 friend class TestNavigationObserver; |
| 688 friend class WebContentsAddedObserver; | 674 friend class WebContentsAddedObserver; |
| 689 friend class WebContentsObserver; | 675 friend class WebContentsObserver; |
| 690 friend class WebContents; // To implement factory methods. | 676 friend class WebContents; // To implement factory methods. |
| 691 | 677 |
| 692 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials); | 678 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials); |
| 693 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle); | 679 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle); |
| 694 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, FindOpenerRVHWhenPending); | 680 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, FindOpenerRVHWhenPending); |
| 695 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, | 681 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 | 897 |
| 912 // TODO(creis): This should take in a FrameTreeNode to know which node's | 898 // TODO(creis): This should take in a FrameTreeNode to know which node's |
| 913 // render manager to return. For now, we just return the root's. | 899 // render manager to return. For now, we just return the root's. |
| 914 RenderFrameHostManager* GetRenderManager() const; | 900 RenderFrameHostManager* GetRenderManager() const; |
| 915 | 901 |
| 916 RenderViewHostImpl* GetRenderViewHostImpl(); | 902 RenderViewHostImpl* GetRenderViewHostImpl(); |
| 917 | 903 |
| 918 // Removes browser plugin embedder if there is one. | 904 // Removes browser plugin embedder if there is one. |
| 919 void RemoveBrowserPluginEmbedder(); | 905 void RemoveBrowserPluginEmbedder(); |
| 920 | 906 |
| 921 // Clear |render_frame_host|'s tracking entry for its power save blockers. | 907 // Clear |render_frame_host|'s PowerSaveBlockers. |
| 922 void ClearPowerSaveBlockers(RenderFrameHost* render_frame_host); | 908 void ClearPowerSaveBlockers(RenderFrameHost* render_frame_host); |
| 923 | 909 |
| 924 // Clear tracking entries for all RenderFrameHosts, clears | 910 // Clear all PowerSaveBlockers, leave |power_save_blocker_| empty. |
| 925 // |audio_power_save_blocker_| and |video_power_save_blocker_|. | |
| 926 void ClearAllPowerSaveBlockers(); | 911 void ClearAllPowerSaveBlockers(); |
| 927 | 912 |
| 928 // Creates an audio or video power save blocker respectively. | |
| 929 void CreateAudioPowerSaveBlocker(); | |
| 930 void CreateVideoPowerSaveBlocker(); | |
| 931 | |
| 932 // Releases the audio power save blockers if |active_audio_players_| is empty. | |
| 933 // Likewise, releases the video power save blockers if |active_video_players_| | |
| 934 // is empty. | |
| 935 void MaybeReleasePowerSaveBlockers(); | |
| 936 | |
| 937 // Helper function to invoke WebContentsDelegate::GetSizeForNewRenderView(). | 913 // Helper function to invoke WebContentsDelegate::GetSizeForNewRenderView(). |
| 938 gfx::Size GetSizeForNewRenderView(); | 914 gfx::Size GetSizeForNewRenderView(); |
| 939 | 915 |
| 940 void OnFrameRemoved(RenderFrameHost* render_frame_host); | 916 void OnFrameRemoved(RenderFrameHost* render_frame_host); |
| 941 | 917 |
| 942 // Helper method that's called whenever |preferred_size_| or | 918 // Helper method that's called whenever |preferred_size_| or |
| 943 // |preferred_size_for_capture_| changes, to propagate the new value to the | 919 // |preferred_size_for_capture_| changes, to propagate the new value to the |
| 944 // |delegate_|. | 920 // |delegate_|. |
| 945 void OnPreferredSizeChanged(const gfx::Size& old_size); | 921 void OnPreferredSizeChanged(const gfx::Size& old_size); |
| 946 | 922 |
| 947 // Helper methods for adding or removing player entries in |player_map| under | |
| 948 // the key |render_frame_message_source_|. | |
| 949 typedef std::vector<int64> PlayerList; | |
| 950 typedef std::map<uintptr_t, PlayerList> ActiveMediaPlayerMap; | |
| 951 void AddMediaPlayerEntry(int64 player_cookie, | |
| 952 ActiveMediaPlayerMap* player_map); | |
| 953 void RemoveMediaPlayerEntry(int64 player_cookie, | |
| 954 ActiveMediaPlayerMap* player_map); | |
| 955 // Removes all entries from |player_map| for |render_frame_host|. | |
| 956 void RemoveAllMediaPlayerEntries(RenderFrameHost* render_frame_host, | |
| 957 ActiveMediaPlayerMap* player_map); | |
| 958 | |
| 959 // Adds/removes a callback called on creation of each new WebContents. | 923 // Adds/removes a callback called on creation of each new WebContents. |
| 960 // Deprecated, about to remove. | 924 // Deprecated, about to remove. |
| 961 static void AddCreatedCallback(const CreatedCallback& callback); | 925 static void AddCreatedCallback(const CreatedCallback& callback); |
| 962 static void RemoveCreatedCallback(const CreatedCallback& callback); | 926 static void RemoveCreatedCallback(const CreatedCallback& callback); |
| 963 | 927 |
| 964 // Data for core operation --------------------------------------------------- | 928 // Data for core operation --------------------------------------------------- |
| 965 | 929 |
| 966 // Delegate for notifying our owner about stuff. Not owned by us. | 930 // Delegate for notifying our owner about stuff. Not owned by us. |
| 967 WebContentsDelegate* delegate_; | 931 WebContentsDelegate* delegate_; |
| 968 | 932 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 // True if this tab was opened by another tab. This is not unset if the opener | 967 // True if this tab was opened by another tab. This is not unset if the opener |
| 1004 // is closed. | 968 // is closed. |
| 1005 bool created_with_opener_; | 969 bool created_with_opener_; |
| 1006 | 970 |
| 1007 #if defined(OS_WIN) | 971 #if defined(OS_WIN) |
| 1008 gfx::NativeViewAccessible accessible_parent_; | 972 gfx::NativeViewAccessible accessible_parent_; |
| 1009 #endif | 973 #endif |
| 1010 | 974 |
| 1011 // Helper classes ------------------------------------------------------------ | 975 // Helper classes ------------------------------------------------------------ |
| 1012 | 976 |
| 1013 // Tracking variables and associated power save blockers for media playback. | 977 #if !defined(OS_CHROMEOS) |
| 1014 ActiveMediaPlayerMap active_audio_players_; | 978 // Maps the RenderFrameHost to its media_player_cookie and PowerSaveBlocker |
| 1015 ActiveMediaPlayerMap active_video_players_; | 979 // pairs. Key is the RenderFrameHost, value is the map which maps |
| 1016 scoped_ptr<PowerSaveBlocker> audio_power_save_blocker_; | 980 // player_cookie on to PowerSaveBlocker. |
| 1017 scoped_ptr<PowerSaveBlocker> video_power_save_blocker_; | 981 // |
| 982 // ChromeOS does its own detection of audio and video. |
| 983 typedef base::ScopedPtrHashMap<int64, PowerSaveBlocker> |
| 984 PowerSaveBlockerMapEntry; |
| 985 typedef base::ScopedPtrHashMap<uintptr_t, PowerSaveBlockerMapEntry> |
| 986 PowerSaveBlockerMap; |
| 987 PowerSaveBlockerMap power_save_blockers_; |
| 988 #endif |
| 1018 | 989 |
| 1019 // Manages the frame tree of the page and process swaps in each node. | 990 // Manages the frame tree of the page and process swaps in each node. |
| 1020 FrameTree frame_tree_; | 991 FrameTree frame_tree_; |
| 1021 | 992 |
| 1022 // SavePackage, lazily created. | 993 // SavePackage, lazily created. |
| 1023 scoped_refptr<SavePackage> save_package_; | 994 scoped_refptr<SavePackage> save_package_; |
| 1024 | 995 |
| 1025 // Data for loading state ---------------------------------------------------- | 996 // Data for loading state ---------------------------------------------------- |
| 1026 | 997 |
| 1027 // Indicates whether we're currently loading a resource. | 998 // Indicates whether we're currently loading a resource. |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1225 | 1196 |
| 1226 scoped_ptr<MidiDispatcherHost> midi_dispatcher_host_; | 1197 scoped_ptr<MidiDispatcherHost> midi_dispatcher_host_; |
| 1227 | 1198 |
| 1228 scoped_ptr<ScreenOrientationDispatcherHost> | 1199 scoped_ptr<ScreenOrientationDispatcherHost> |
| 1229 screen_orientation_dispatcher_host_; | 1200 screen_orientation_dispatcher_host_; |
| 1230 | 1201 |
| 1231 // The accessibility mode for all frames. This is queried when each frame | 1202 // The accessibility mode for all frames. This is queried when each frame |
| 1232 // is created, and broadcast to all frames when it changes. | 1203 // is created, and broadcast to all frames when it changes. |
| 1233 AccessibilityMode accessibility_mode_; | 1204 AccessibilityMode accessibility_mode_; |
| 1234 | 1205 |
| 1235 // Monitors power levels for audio streams associated with this WebContents. | |
| 1236 AudioStreamMonitor audio_stream_monitor_; | |
| 1237 | |
| 1238 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl); | 1206 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl); |
| 1239 }; | 1207 }; |
| 1240 | 1208 |
| 1241 } // namespace content | 1209 } // namespace content |
| 1242 | 1210 |
| 1243 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ | 1211 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
| OLD | NEW |