| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <functional> | 10 #include <functional> |
| 11 #include <map> | 11 #include <map> |
| 12 #include <memory> |
| 12 #include <set> | 13 #include <set> |
| 13 #include <string> | 14 #include <string> |
| 14 | 15 |
| 15 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 16 #include "base/containers/scoped_ptr_hash_map.h" | 17 #include "base/containers/scoped_ptr_hash_map.h" |
| 17 #include "base/gtest_prod_util.h" | 18 #include "base/gtest_prod_util.h" |
| 18 #include "base/macros.h" | 19 #include "base/macros.h" |
| 19 #include "base/memory/scoped_ptr.h" | |
| 20 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
| 21 #include "base/process/process.h" | 21 #include "base/process/process.h" |
| 22 #include "base/values.h" | 22 #include "base/values.h" |
| 23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
| 24 #include "content/browser/frame_host/frame_tree.h" | 24 #include "content/browser/frame_host/frame_tree.h" |
| 25 #include "content/browser/frame_host/navigation_controller_delegate.h" | 25 #include "content/browser/frame_host/navigation_controller_delegate.h" |
| 26 #include "content/browser/frame_host/navigation_controller_impl.h" | 26 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 27 #include "content/browser/frame_host/navigator_delegate.h" | 27 #include "content/browser/frame_host/navigator_delegate.h" |
| 28 #include "content/browser/frame_host/render_frame_host_delegate.h" | 28 #include "content/browser/frame_host/render_frame_host_delegate.h" |
| 29 #include "content/browser/frame_host/render_frame_host_manager.h" | 29 #include "content/browser/frame_host/render_frame_host_manager.h" |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 RenderFrameHost* render_frame_host, | 435 RenderFrameHost* render_frame_host, |
| 436 int browser_plugin_instance_id) override; | 436 int browser_plugin_instance_id) override; |
| 437 GeolocationServiceContext* GetGeolocationServiceContext() override; | 437 GeolocationServiceContext* GetGeolocationServiceContext() override; |
| 438 WakeLockServiceContext* GetWakeLockServiceContext() override; | 438 WakeLockServiceContext* GetWakeLockServiceContext() override; |
| 439 void EnterFullscreenMode(const GURL& origin) override; | 439 void EnterFullscreenMode(const GURL& origin) override; |
| 440 void ExitFullscreenMode(bool will_cause_resize) override; | 440 void ExitFullscreenMode(bool will_cause_resize) override; |
| 441 bool ShouldRouteMessageEvent( | 441 bool ShouldRouteMessageEvent( |
| 442 RenderFrameHost* target_rfh, | 442 RenderFrameHost* target_rfh, |
| 443 SiteInstance* source_site_instance) const override; | 443 SiteInstance* source_site_instance) const override; |
| 444 void EnsureOpenerProxiesExist(RenderFrameHost* source_rfh) override; | 444 void EnsureOpenerProxiesExist(RenderFrameHost* source_rfh) override; |
| 445 scoped_ptr<WebUIImpl> CreateWebUIForRenderFrameHost(const GURL& url) override; | 445 std::unique_ptr<WebUIImpl> CreateWebUIForRenderFrameHost( |
| 446 const GURL& url) override; |
| 446 | 447 |
| 447 // RenderViewHostDelegate ---------------------------------------------------- | 448 // RenderViewHostDelegate ---------------------------------------------------- |
| 448 RenderViewHostDelegateView* GetDelegateView() override; | 449 RenderViewHostDelegateView* GetDelegateView() override; |
| 449 bool OnMessageReceived(RenderViewHost* render_view_host, | 450 bool OnMessageReceived(RenderViewHost* render_view_host, |
| 450 const IPC::Message& message) override; | 451 const IPC::Message& message) override; |
| 451 // RenderFrameHostDelegate has the same method, so list it there because this | 452 // RenderFrameHostDelegate has the same method, so list it there because this |
| 452 // interface is going away. | 453 // interface is going away. |
| 453 // WebContents* GetAsWebContents() override; | 454 // WebContents* GetAsWebContents() override; |
| 454 void RenderViewCreated(RenderViewHost* render_view_host) override; | 455 void RenderViewCreated(RenderViewHost* render_view_host) override; |
| 455 void RenderViewReady(RenderViewHost* render_view_host) override; | 456 void RenderViewReady(RenderViewHost* render_view_host) override; |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 | 1040 |
| 1040 // Data for core operation --------------------------------------------------- | 1041 // Data for core operation --------------------------------------------------- |
| 1041 | 1042 |
| 1042 // Delegate for notifying our owner about stuff. Not owned by us. | 1043 // Delegate for notifying our owner about stuff. Not owned by us. |
| 1043 WebContentsDelegate* delegate_; | 1044 WebContentsDelegate* delegate_; |
| 1044 | 1045 |
| 1045 // Handles the back/forward list and loading. | 1046 // Handles the back/forward list and loading. |
| 1046 NavigationControllerImpl controller_; | 1047 NavigationControllerImpl controller_; |
| 1047 | 1048 |
| 1048 // The corresponding view. | 1049 // The corresponding view. |
| 1049 scoped_ptr<WebContentsView> view_; | 1050 std::unique_ptr<WebContentsView> view_; |
| 1050 | 1051 |
| 1051 // The view of the RVHD. Usually this is our WebContentsView implementation, | 1052 // The view of the RVHD. Usually this is our WebContentsView implementation, |
| 1052 // but if an embedder uses a different WebContentsView, they'll need to | 1053 // but if an embedder uses a different WebContentsView, they'll need to |
| 1053 // provide this. | 1054 // provide this. |
| 1054 RenderViewHostDelegateView* render_view_host_delegate_view_; | 1055 RenderViewHostDelegateView* render_view_host_delegate_view_; |
| 1055 | 1056 |
| 1056 // Tracks created WebContentsImpl objects that have not been shown yet. They | 1057 // Tracks created WebContentsImpl objects that have not been shown yet. They |
| 1057 // are identified by the route ID passed to CreateNewWindow. | 1058 // are identified by the route ID passed to CreateNewWindow. |
| 1058 typedef std::map<int, WebContentsImpl*> PendingContents; | 1059 typedef std::map<int, WebContentsImpl*> PendingContents; |
| 1059 PendingContents pending_contents_; | 1060 PendingContents pending_contents_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1076 // is closed. | 1077 // is closed. |
| 1077 bool created_with_opener_; | 1078 bool created_with_opener_; |
| 1078 | 1079 |
| 1079 // Helper classes ------------------------------------------------------------ | 1080 // Helper classes ------------------------------------------------------------ |
| 1080 | 1081 |
| 1081 // Manages the frame tree of the page and process swaps in each node. | 1082 // Manages the frame tree of the page and process swaps in each node. |
| 1082 FrameTree frame_tree_; | 1083 FrameTree frame_tree_; |
| 1083 | 1084 |
| 1084 // If this WebContents is part of a "tree of WebContents", then this contains | 1085 // If this WebContents is part of a "tree of WebContents", then this contains |
| 1085 // information about the structure. | 1086 // information about the structure. |
| 1086 scoped_ptr<WebContentsTreeNode> node_; | 1087 std::unique_ptr<WebContentsTreeNode> node_; |
| 1087 | 1088 |
| 1088 // SavePackage, lazily created. | 1089 // SavePackage, lazily created. |
| 1089 scoped_refptr<SavePackage> save_package_; | 1090 scoped_refptr<SavePackage> save_package_; |
| 1090 | 1091 |
| 1091 // Data for loading state ---------------------------------------------------- | 1092 // Data for loading state ---------------------------------------------------- |
| 1092 | 1093 |
| 1093 // Indicates whether the current load is to a different document. Only valid | 1094 // Indicates whether the current load is to a different document. Only valid |
| 1094 // if is_loading_ is true. | 1095 // if is_loading_ is true. |
| 1095 bool is_load_to_different_document_; | 1096 bool is_load_to_different_document_; |
| 1096 | 1097 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 // The intrinsic size of the page. | 1211 // The intrinsic size of the page. |
| 1211 gfx::Size preferred_size_; | 1212 gfx::Size preferred_size_; |
| 1212 | 1213 |
| 1213 // The preferred size for content screen capture. When |capturer_count_| > 0, | 1214 // The preferred size for content screen capture. When |capturer_count_| > 0, |
| 1214 // this overrides |preferred_size_|. | 1215 // this overrides |preferred_size_|. |
| 1215 gfx::Size preferred_size_for_capture_; | 1216 gfx::Size preferred_size_for_capture_; |
| 1216 | 1217 |
| 1217 #if defined(OS_ANDROID) | 1218 #if defined(OS_ANDROID) |
| 1218 // Date time chooser opened by this tab. | 1219 // Date time chooser opened by this tab. |
| 1219 // Only used in Android since all other platforms use a multi field UI. | 1220 // Only used in Android since all other platforms use a multi field UI. |
| 1220 scoped_ptr<DateTimeChooserAndroid> date_time_chooser_; | 1221 std::unique_ptr<DateTimeChooserAndroid> date_time_chooser_; |
| 1221 #endif | 1222 #endif |
| 1222 | 1223 |
| 1223 // Holds information about a current color chooser dialog, if one is visible. | 1224 // Holds information about a current color chooser dialog, if one is visible. |
| 1224 struct ColorChooserInfo { | 1225 struct ColorChooserInfo { |
| 1225 ColorChooserInfo(int render_process_id, | 1226 ColorChooserInfo(int render_process_id, |
| 1226 int render_frame_id, | 1227 int render_frame_id, |
| 1227 ColorChooser* chooser, | 1228 ColorChooser* chooser, |
| 1228 int identifier); | 1229 int identifier); |
| 1229 ~ColorChooserInfo(); | 1230 ~ColorChooserInfo(); |
| 1230 | 1231 |
| 1231 int render_process_id; | 1232 int render_process_id; |
| 1232 int render_frame_id; | 1233 int render_frame_id; |
| 1233 | 1234 |
| 1234 // Color chooser that was opened by this tab. | 1235 // Color chooser that was opened by this tab. |
| 1235 scoped_ptr<ColorChooser> chooser; | 1236 std::unique_ptr<ColorChooser> chooser; |
| 1236 | 1237 |
| 1237 // A unique identifier for the current color chooser. Identifiers are | 1238 // A unique identifier for the current color chooser. Identifiers are |
| 1238 // unique across a renderer process. This avoids race conditions in | 1239 // unique across a renderer process. This avoids race conditions in |
| 1239 // synchronizing the browser and renderer processes. For example, if a | 1240 // synchronizing the browser and renderer processes. For example, if a |
| 1240 // renderer closes one chooser and opens another, and simultaneously the | 1241 // renderer closes one chooser and opens another, and simultaneously the |
| 1241 // user picks a color in the first chooser, the IDs can be used to drop the | 1242 // user picks a color in the first chooser, the IDs can be used to drop the |
| 1242 // "chose a color" message rather than erroneously tell the renderer that | 1243 // "chose a color" message rather than erroneously tell the renderer that |
| 1243 // the user picked a color in the second chooser. | 1244 // the user picked a color in the second chooser. |
| 1244 int identifier; | 1245 int identifier; |
| 1245 }; | 1246 }; |
| 1246 | 1247 |
| 1247 scoped_ptr<ColorChooserInfo> color_chooser_info_; | 1248 std::unique_ptr<ColorChooserInfo> color_chooser_info_; |
| 1248 | 1249 |
| 1249 // Manages the embedder state for browser plugins, if this WebContents is an | 1250 // Manages the embedder state for browser plugins, if this WebContents is an |
| 1250 // embedder; NULL otherwise. | 1251 // embedder; NULL otherwise. |
| 1251 scoped_ptr<BrowserPluginEmbedder> browser_plugin_embedder_; | 1252 std::unique_ptr<BrowserPluginEmbedder> browser_plugin_embedder_; |
| 1252 // Manages the guest state for browser plugin, if this WebContents is a guest; | 1253 // Manages the guest state for browser plugin, if this WebContents is a guest; |
| 1253 // NULL otherwise. | 1254 // NULL otherwise. |
| 1254 scoped_ptr<BrowserPluginGuest> browser_plugin_guest_; | 1255 std::unique_ptr<BrowserPluginGuest> browser_plugin_guest_; |
| 1255 | 1256 |
| 1256 #if defined(ENABLE_PLUGINS) | 1257 #if defined(ENABLE_PLUGINS) |
| 1257 // Manages the whitelist of plugin content origins exempt from power saving. | 1258 // Manages the whitelist of plugin content origins exempt from power saving. |
| 1258 scoped_ptr<PluginContentOriginWhitelist> plugin_content_origin_whitelist_; | 1259 std::unique_ptr<PluginContentOriginWhitelist> |
| 1260 plugin_content_origin_whitelist_; |
| 1259 #endif | 1261 #endif |
| 1260 | 1262 |
| 1261 // This must be at the end, or else we might get notifications and use other | 1263 // This must be at the end, or else we might get notifications and use other |
| 1262 // member variables that are gone. | 1264 // member variables that are gone. |
| 1263 NotificationRegistrar registrar_; | 1265 NotificationRegistrar registrar_; |
| 1264 | 1266 |
| 1265 // Used during IPC message dispatching from the RenderView/RenderFrame so that | 1267 // Used during IPC message dispatching from the RenderView/RenderFrame so that |
| 1266 // the handlers can get a pointer to the RVH through which the message was | 1268 // the handlers can get a pointer to the RVH through which the message was |
| 1267 // received. | 1269 // received. |
| 1268 RenderViewHost* render_view_message_source_; | 1270 RenderViewHost* render_view_message_source_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1280 // fullscreen widget is destroyed, and 2) the WebContentsDelegate has | 1282 // fullscreen widget is destroyed, and 2) the WebContentsDelegate has |
| 1281 // completed making layout changes to effect an exit from fullscreen mode. | 1283 // completed making layout changes to effect an exit from fullscreen mode. |
| 1282 bool fullscreen_widget_had_focus_at_shutdown_; | 1284 bool fullscreen_widget_had_focus_at_shutdown_; |
| 1283 | 1285 |
| 1284 // Whether this WebContents is responsible for displaying a subframe in a | 1286 // Whether this WebContents is responsible for displaying a subframe in a |
| 1285 // different process from its parent page. | 1287 // different process from its parent page. |
| 1286 bool is_subframe_; | 1288 bool is_subframe_; |
| 1287 | 1289 |
| 1288 // When a new tab is created asynchronously, stores the OpenURLParams needed | 1290 // When a new tab is created asynchronously, stores the OpenURLParams needed |
| 1289 // to continue loading the page once the tab is ready. | 1291 // to continue loading the page once the tab is ready. |
| 1290 scoped_ptr<OpenURLParams> delayed_open_url_params_; | 1292 std::unique_ptr<OpenURLParams> delayed_open_url_params_; |
| 1291 | 1293 |
| 1292 // Whether overscroll should be unconditionally disabled. | 1294 // Whether overscroll should be unconditionally disabled. |
| 1293 bool force_disable_overscroll_content_; | 1295 bool force_disable_overscroll_content_; |
| 1294 | 1296 |
| 1295 // Whether the last JavaScript dialog shown was suppressed. Used for testing. | 1297 // Whether the last JavaScript dialog shown was suppressed. Used for testing. |
| 1296 bool last_dialog_suppressed_; | 1298 bool last_dialog_suppressed_; |
| 1297 | 1299 |
| 1298 scoped_ptr<GeolocationServiceContext> geolocation_service_context_; | 1300 std::unique_ptr<GeolocationServiceContext> geolocation_service_context_; |
| 1299 | 1301 |
| 1300 scoped_ptr<WakeLockServiceContext> wake_lock_service_context_; | 1302 std::unique_ptr<WakeLockServiceContext> wake_lock_service_context_; |
| 1301 | 1303 |
| 1302 scoped_ptr<ScreenOrientationDispatcherHost> | 1304 std::unique_ptr<ScreenOrientationDispatcherHost> |
| 1303 screen_orientation_dispatcher_host_; | 1305 screen_orientation_dispatcher_host_; |
| 1304 | 1306 |
| 1305 scoped_ptr<ManifestManagerHost> manifest_manager_host_; | 1307 std::unique_ptr<ManifestManagerHost> manifest_manager_host_; |
| 1306 | 1308 |
| 1307 // The accessibility mode for all frames. This is queried when each frame | 1309 // The accessibility mode for all frames. This is queried when each frame |
| 1308 // is created, and broadcast to all frames when it changes. | 1310 // is created, and broadcast to all frames when it changes. |
| 1309 AccessibilityMode accessibility_mode_; | 1311 AccessibilityMode accessibility_mode_; |
| 1310 | 1312 |
| 1311 // Monitors power levels for audio streams associated with this WebContents. | 1313 // Monitors power levels for audio streams associated with this WebContents. |
| 1312 AudioStreamMonitor audio_stream_monitor_; | 1314 AudioStreamMonitor audio_stream_monitor_; |
| 1313 | 1315 |
| 1314 // Created on-demand to mute all audio output from this WebContents. | 1316 // Created on-demand to mute all audio output from this WebContents. |
| 1315 scoped_ptr<WebContentsAudioMuter> audio_muter_; | 1317 std::unique_ptr<WebContentsAudioMuter> audio_muter_; |
| 1316 | 1318 |
| 1317 size_t bluetooth_connected_device_count_; | 1319 size_t bluetooth_connected_device_count_; |
| 1318 | 1320 |
| 1319 bool virtual_keyboard_requested_; | 1321 bool virtual_keyboard_requested_; |
| 1320 | 1322 |
| 1321 // Notifies ResourceDispatcherHostImpl of various events related to loading. | 1323 // Notifies ResourceDispatcherHostImpl of various events related to loading. |
| 1322 scoped_ptr<LoaderIOThreadNotifier> loader_io_thread_notifier_; | 1324 std::unique_ptr<LoaderIOThreadNotifier> loader_io_thread_notifier_; |
| 1323 | 1325 |
| 1324 // Manages media players, CDMs, and power save blockers for media. | 1326 // Manages media players, CDMs, and power save blockers for media. |
| 1325 scoped_ptr<MediaWebContentsObserver> media_web_contents_observer_; | 1327 std::unique_ptr<MediaWebContentsObserver> media_web_contents_observer_; |
| 1326 | 1328 |
| 1327 scoped_ptr<RenderWidgetHostInputEventRouter> rwh_input_event_router_; | 1329 std::unique_ptr<RenderWidgetHostInputEventRouter> rwh_input_event_router_; |
| 1328 | 1330 |
| 1329 PageImportanceSignals page_importance_signals_; | 1331 PageImportanceSignals page_importance_signals_; |
| 1330 | 1332 |
| 1331 bool page_scale_factor_is_one_; | 1333 bool page_scale_factor_is_one_; |
| 1332 | 1334 |
| 1333 // The RWHV which is currently focused. | 1335 // The RWHV which is currently focused. |
| 1334 base::WeakPtr<RenderWidgetHostViewBase> view_with_active_text_input_; | 1336 base::WeakPtr<RenderWidgetHostViewBase> view_with_active_text_input_; |
| 1335 | 1337 |
| 1336 // A copy of the text input state from |view_with_active_text_input_| when | 1338 // A copy of the text input state from |view_with_active_text_input_| when |
| 1337 // there exists one, or empty (type == ui::TEXT_INPUT_TYPE_NONE) if otherwise. | 1339 // there exists one, or empty (type == ui::TEXT_INPUT_TYPE_NONE) if otherwise. |
| 1338 scoped_ptr<TextInputState> text_input_state_; | 1340 std::unique_ptr<TextInputState> text_input_state_; |
| 1339 | 1341 |
| 1340 base::WeakPtrFactory<WebContentsImpl> loading_weak_factory_; | 1342 base::WeakPtrFactory<WebContentsImpl> loading_weak_factory_; |
| 1341 base::WeakPtrFactory<WebContentsImpl> weak_factory_; | 1343 base::WeakPtrFactory<WebContentsImpl> weak_factory_; |
| 1342 | 1344 |
| 1343 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl); | 1345 DISALLOW_COPY_AND_ASSIGN(WebContentsImpl); |
| 1344 }; | 1346 }; |
| 1345 | 1347 |
| 1346 // Dangerous methods which should never be made part of the public API, so we | 1348 // Dangerous methods which should never be made part of the public API, so we |
| 1347 // grant their use only to an explicit friend list (c++ attorney/client idiom). | 1349 // grant their use only to an explicit friend list (c++ attorney/client idiom). |
| 1348 class CONTENT_EXPORT WebContentsImpl::FriendZone { | 1350 class CONTENT_EXPORT WebContentsImpl::FriendZone { |
| 1349 private: | 1351 private: |
| 1350 friend class TestNavigationObserver; | 1352 friend class TestNavigationObserver; |
| 1351 friend class WebContentsAddedObserver; | 1353 friend class WebContentsAddedObserver; |
| 1352 friend class ContentBrowserSanityChecker; | 1354 friend class ContentBrowserSanityChecker; |
| 1353 | 1355 |
| 1354 FriendZone(); // Not instantiable. | 1356 FriendZone(); // Not instantiable. |
| 1355 | 1357 |
| 1356 // Adds/removes a callback called on creation of each new WebContents. | 1358 // Adds/removes a callback called on creation of each new WebContents. |
| 1357 static void AddCreatedCallbackForTesting(const CreatedCallback& callback); | 1359 static void AddCreatedCallbackForTesting(const CreatedCallback& callback); |
| 1358 static void RemoveCreatedCallbackForTesting(const CreatedCallback& callback); | 1360 static void RemoveCreatedCallbackForTesting(const CreatedCallback& callback); |
| 1359 | 1361 |
| 1360 DISALLOW_COPY_AND_ASSIGN(FriendZone); | 1362 DISALLOW_COPY_AND_ASSIGN(FriendZone); |
| 1361 }; | 1363 }; |
| 1362 | 1364 |
| 1363 } // namespace content | 1365 } // namespace content |
| 1364 | 1366 |
| 1365 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ | 1367 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_IMPL_H_ |
| OLD | NEW |