| 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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 virtual int DownloadImage(const GURL& url, | 322 virtual int DownloadImage(const GURL& url, |
| 323 bool is_favicon, | 323 bool is_favicon, |
| 324 uint32_t max_bitmap_size, | 324 uint32_t max_bitmap_size, |
| 325 const ImageDownloadCallback& callback) OVERRIDE; | 325 const ImageDownloadCallback& callback) OVERRIDE; |
| 326 virtual bool IsSubframe() const OVERRIDE; | 326 virtual bool IsSubframe() const OVERRIDE; |
| 327 virtual void Find(int request_id, | 327 virtual void Find(int request_id, |
| 328 const base::string16& search_text, | 328 const base::string16& search_text, |
| 329 const blink::WebFindOptions& options) OVERRIDE; | 329 const blink::WebFindOptions& options) OVERRIDE; |
| 330 virtual void StopFinding(StopFindAction action) OVERRIDE; | 330 virtual void StopFinding(StopFindAction action) OVERRIDE; |
| 331 virtual void InsertCSS(const std::string& css) OVERRIDE; | 331 virtual void InsertCSS(const std::string& css) OVERRIDE; |
| 332 virtual bool WasRecentlyAudible() OVERRIDE; |
| 332 #if defined(OS_ANDROID) | 333 #if defined(OS_ANDROID) |
| 333 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents() | 334 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents() |
| 334 OVERRIDE; | 335 OVERRIDE; |
| 335 virtual WebContentsAndroid* GetWebContentsAndroid(); | 336 virtual WebContentsAndroid* GetWebContentsAndroid(); |
| 336 #elif defined(OS_MACOSX) | 337 #elif defined(OS_MACOSX) |
| 337 virtual void SetAllowOtherViews(bool allow) OVERRIDE; | 338 virtual void SetAllowOtherViews(bool allow) OVERRIDE; |
| 338 virtual bool GetAllowOtherViews() OVERRIDE; | 339 virtual bool GetAllowOtherViews() OVERRIDE; |
| 339 #endif | 340 #endif |
| 340 | 341 |
| 341 // Implementation of PageNavigator. | 342 // Implementation of PageNavigator. |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 // currently focused frame. | 663 // currently focused frame. |
| 663 void SelectRange(const gfx::Point& start, const gfx::Point& end); | 664 void SelectRange(const gfx::Point& start, const gfx::Point& end); |
| 664 | 665 |
| 665 // Notifies the main frame that it can continue navigation (if it was deferred | 666 // Notifies the main frame that it can continue navigation (if it was deferred |
| 666 // immediately at first response). | 667 // immediately at first response). |
| 667 void ResumeResponseDeferredAtStart(); | 668 void ResumeResponseDeferredAtStart(); |
| 668 | 669 |
| 669 // Forces overscroll to be disabled (used by touch emulation). | 670 // Forces overscroll to be disabled (used by touch emulation). |
| 670 void SetForceDisableOverscrollContent(bool force_disable); | 671 void SetForceDisableOverscrollContent(bool force_disable); |
| 671 | 672 |
| 673 bool has_audio_power_save_blocker_for_testing() const { |
| 674 return audio_power_save_blocker_; |
| 675 } |
| 676 bool has_video_power_save_blocker_for_testing() const { |
| 677 return video_power_save_blocker_; |
| 678 } |
| 679 |
| 672 private: | 680 private: |
| 673 friend class TestNavigationObserver; | 681 friend class TestNavigationObserver; |
| 674 friend class WebContentsAddedObserver; | 682 friend class WebContentsAddedObserver; |
| 675 friend class WebContentsObserver; | 683 friend class WebContentsObserver; |
| 676 friend class WebContents; // To implement factory methods. | 684 friend class WebContents; // To implement factory methods. |
| 677 | 685 |
| 678 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials); | 686 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, NoJSMessageOnInterstitials); |
| 679 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle); | 687 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, UpdateTitle); |
| 680 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, FindOpenerRVHWhenPending); | 688 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, FindOpenerRVHWhenPending); |
| 681 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, | 689 FRIEND_TEST_ALL_PREFIXES(WebContentsImplTest, |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 | 903 |
| 896 // TODO(creis): This should take in a FrameTreeNode to know which node's | 904 // TODO(creis): This should take in a FrameTreeNode to know which node's |
| 897 // render manager to return. For now, we just return the root's. | 905 // render manager to return. For now, we just return the root's. |
| 898 RenderFrameHostManager* GetRenderManager() const; | 906 RenderFrameHostManager* GetRenderManager() const; |
| 899 | 907 |
| 900 RenderViewHostImpl* GetRenderViewHostImpl(); | 908 RenderViewHostImpl* GetRenderViewHostImpl(); |
| 901 | 909 |
| 902 // Removes browser plugin embedder if there is one. | 910 // Removes browser plugin embedder if there is one. |
| 903 void RemoveBrowserPluginEmbedder(); | 911 void RemoveBrowserPluginEmbedder(); |
| 904 | 912 |
| 905 // Clear |render_frame_host|'s PowerSaveBlockers. | 913 // Clear |render_frame_host|'s tracking entry for its power save blockers. |
| 906 void ClearPowerSaveBlockers(RenderFrameHost* render_frame_host); | 914 void ClearPowerSaveBlockers(RenderFrameHost* render_frame_host); |
| 907 | 915 |
| 908 // Clear all PowerSaveBlockers, leave |power_save_blocker_| empty. | 916 // Clear tracking entries for all RenderFrameHosts, clears |
| 917 // |audio_power_save_blocker_| and |video_power_save_blocker_|. |
| 909 void ClearAllPowerSaveBlockers(); | 918 void ClearAllPowerSaveBlockers(); |
| 910 | 919 |
| 920 // Creates an audio or video power save blocker respectively. |
| 921 void CreateAudioPowerSaveBlocker(); |
| 922 void CreateVideoPowerSaveBlocker(); |
| 923 |
| 924 // Releases the audio power save blockers if |active_audio_players_| is empty. |
| 925 // Likewise, releases the video power save blockers if |active_video_players_| |
| 926 // is empty. |
| 927 void MaybeReleasePowerSaveBlockers(); |
| 928 |
| 911 // Helper function to invoke WebContentsDelegate::GetSizeForNewRenderView(). | 929 // Helper function to invoke WebContentsDelegate::GetSizeForNewRenderView(). |
| 912 gfx::Size GetSizeForNewRenderView(); | 930 gfx::Size GetSizeForNewRenderView(); |
| 913 | 931 |
| 914 void OnFrameRemoved(RenderFrameHost* render_frame_host); | 932 void OnFrameRemoved(RenderFrameHost* render_frame_host); |
| 915 | 933 |
| 916 // Helper method that's called whenever |preferred_size_| or | 934 // Helper method that's called whenever |preferred_size_| or |
| 917 // |preferred_size_for_capture_| changes, to propagate the new value to the | 935 // |preferred_size_for_capture_| changes, to propagate the new value to the |
| 918 // |delegate_|. | 936 // |delegate_|. |
| 919 void OnPreferredSizeChanged(const gfx::Size& old_size); | 937 void OnPreferredSizeChanged(const gfx::Size& old_size); |
| 920 | 938 |
| 939 // Helper methods for adding or removing player entries in |player_map| under |
| 940 // the key |render_frame_message_source_|. |
| 941 typedef std::vector<int64> PlayerList; |
| 942 typedef std::map<uintptr_t, PlayerList> ActiveMediaPlayerMap; |
| 943 void AddMediaPlayerEntry(int64 player_cookie, |
| 944 ActiveMediaPlayerMap* player_map); |
| 945 void RemoveMediaPlayerEntry(int64 player_cookie, |
| 946 ActiveMediaPlayerMap* player_map); |
| 947 // Removes all entries from |player_map| for |render_frame_host|. |
| 948 void RemoveAllMediaPlayerEntries(RenderFrameHost* render_frame_host, |
| 949 ActiveMediaPlayerMap* player_map); |
| 950 |
| 921 // Adds/removes a callback called on creation of each new WebContents. | 951 // Adds/removes a callback called on creation of each new WebContents. |
| 922 // Deprecated, about to remove. | 952 // Deprecated, about to remove. |
| 923 static void AddCreatedCallback(const CreatedCallback& callback); | 953 static void AddCreatedCallback(const CreatedCallback& callback); |
| 924 static void RemoveCreatedCallback(const CreatedCallback& callback); | 954 static void RemoveCreatedCallback(const CreatedCallback& callback); |
| 925 | 955 |
| 926 // Data for core operation --------------------------------------------------- | 956 // Data for core operation --------------------------------------------------- |
| 927 | 957 |
| 928 // Delegate for notifying our owner about stuff. Not owned by us. | 958 // Delegate for notifying our owner about stuff. Not owned by us. |
| 929 WebContentsDelegate* delegate_; | 959 WebContentsDelegate* delegate_; |
| 930 | 960 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 // is closed. | 996 // is closed. |
| 967 bool created_with_opener_; | 997 bool created_with_opener_; |
| 968 | 998 |
| 969 #if defined(OS_WIN) | 999 #if defined(OS_WIN) |
| 970 gfx::NativeViewAccessible accessible_parent_; | 1000 gfx::NativeViewAccessible accessible_parent_; |
| 971 #endif | 1001 #endif |
| 972 | 1002 |
| 973 // Helper classes ------------------------------------------------------------ | 1003 // Helper classes ------------------------------------------------------------ |
| 974 | 1004 |
| 975 #if !defined(OS_CHROMEOS) | 1005 #if !defined(OS_CHROMEOS) |
| 976 // Maps the RenderFrameHost to its media_player_cookie and PowerSaveBlocker | 1006 ActiveMediaPlayerMap active_audio_players_; |
| 977 // pairs. Key is the RenderFrameHost, value is the map which maps | 1007 ActiveMediaPlayerMap active_video_players_; |
| 978 // player_cookie on to PowerSaveBlocker. | 1008 scoped_ptr<PowerSaveBlocker> audio_power_save_blocker_; |
| 979 // | 1009 scoped_ptr<PowerSaveBlocker> video_power_save_blocker_; |
| 980 // ChromeOS does its own detection of audio and video. | |
| 981 typedef base::ScopedPtrHashMap<int64, PowerSaveBlocker> | |
| 982 PowerSaveBlockerMapEntry; | |
| 983 typedef base::ScopedPtrHashMap<uintptr_t, PowerSaveBlockerMapEntry> | |
| 984 PowerSaveBlockerMap; | |
| 985 PowerSaveBlockerMap power_save_blockers_; | |
| 986 #endif | 1010 #endif |
| 987 | 1011 |
| 988 // Manages the frame tree of the page and process swaps in each node. | 1012 // Manages the frame tree of the page and process swaps in each node. |
| 989 FrameTree frame_tree_; | 1013 FrameTree frame_tree_; |
| 990 | 1014 |
| 991 // SavePackage, lazily created. | 1015 // SavePackage, lazily created. |
| 992 scoped_refptr<SavePackage> save_package_; | 1016 scoped_refptr<SavePackage> save_package_; |
| 993 | 1017 |
| 994 // Data for loading state ---------------------------------------------------- | 1018 // Data for loading state ---------------------------------------------------- |
| 995 | 1019 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 // The accessibility mode for all frames. This is queried when each frame | 1224 // The accessibility mode for all frames. This is queried when each frame |
| 1201 // is created, and broadcast to all frames when it changes. | 1225 // is created, and broadcast to all frames when it changes. |
| 1202 AccessibilityMode accessibility_mode_; | 1226 AccessibilityMode accessibility_mode_; |
| 1203 | 1227 |
| 1204 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl); | 1228 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl); |
| 1205 }; | 1229 }; |
| 1206 | 1230 |
| 1207 } // namespace content | 1231 } // namespace content |
| 1208 | 1232 |
| 1209 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ | 1233 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
| OLD | NEW |