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