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 #include "content/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/metrics/stats_counters.h" | 11 #include "base/metrics/stats_counters.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/sys_info.h" | 15 #include "base/sys_info.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
18 #include "content/browser/browser_plugin/old/old_browser_plugin_host.h" | 18 #include "content/browser/browser_plugin/old/old_browser_plugin_host.h" |
19 #include "content/browser/child_process_security_policy_impl.h" | 19 #include "content/browser/child_process_security_policy_impl.h" |
20 #include "content/browser/debugger/devtools_manager_impl.h" | 20 #include "content/browser/debugger/devtools_manager_impl.h" |
| 21 #include "content/browser/dom_storage/dom_storage_context_impl.h" |
21 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 22 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
22 #include "content/browser/download/download_stats.h" | 23 #include "content/browser/download/download_stats.h" |
23 #include "content/browser/download/mhtml_generation_manager.h" | 24 #include "content/browser/download/mhtml_generation_manager.h" |
24 #include "content/browser/download/save_package.h" | 25 #include "content/browser/download/save_package.h" |
25 #include "content/browser/gpu/gpu_data_manager_impl.h" | 26 #include "content/browser/gpu/gpu_data_manager_impl.h" |
26 #include "content/browser/gpu/gpu_process_host.h" | 27 #include "content/browser/gpu/gpu_process_host.h" |
27 #include "content/browser/host_zoom_map_impl.h" | 28 #include "content/browser/host_zoom_map_impl.h" |
28 #include "content/browser/intents/web_intents_dispatcher_impl.h" | 29 #include "content/browser/intents/web_intents_dispatcher_impl.h" |
29 #include "content/browser/renderer_host/render_process_host_impl.h" | 30 #include "content/browser/renderer_host/render_process_host_impl.h" |
30 #include "content/browser/renderer_host/render_view_host_impl.h" | 31 #include "content/browser/renderer_host/render_view_host_impl.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 } | 276 } |
276 | 277 |
277 } // namespace | 278 } // namespace |
278 | 279 |
279 namespace content { | 280 namespace content { |
280 | 281 |
281 WebContents* WebContents::Create( | 282 WebContents* WebContents::Create( |
282 BrowserContext* browser_context, | 283 BrowserContext* browser_context, |
283 SiteInstance* site_instance, | 284 SiteInstance* site_instance, |
284 int routing_id, | 285 int routing_id, |
| 286 const WebContents* base_web_contents) { |
| 287 return WebContentsImpl::Create( |
| 288 browser_context, site_instance, routing_id, |
| 289 static_cast<const WebContentsImpl*>(base_web_contents)); |
| 290 } |
| 291 |
| 292 WebContents* WebContents::CreateWithSessionStorage( |
| 293 BrowserContext* browser_context, |
| 294 SiteInstance* site_instance, |
| 295 int routing_id, |
285 const WebContents* base_web_contents, | 296 const WebContents* base_web_contents, |
286 SessionStorageNamespace* session_storage_namespace) { | 297 const SessionStorageNamespaceMap& session_storage_namespace_map) { |
287 return new WebContentsImpl( | 298 WebContentsImpl* new_contents = new WebContentsImpl(browser_context, NULL); |
288 browser_context, | 299 |
289 site_instance, | 300 for (SessionStorageNamespaceMap::const_iterator it = |
290 routing_id, | 301 session_storage_namespace_map.begin(); |
291 static_cast<const WebContentsImpl*>(base_web_contents), | 302 it != session_storage_namespace_map.end(); |
292 NULL, | 303 ++it) { |
293 static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace)); | 304 new_contents->GetController().SetSessionStorageNamespace(it->first, |
| 305 it->second); |
| 306 } |
| 307 |
| 308 new_contents->Init(browser_context, site_instance, routing_id, |
| 309 static_cast<const WebContentsImpl*>(base_web_contents)); |
| 310 return new_contents; |
294 } | 311 } |
295 | 312 |
296 WebContents* WebContents::FromRenderViewHost(const RenderViewHost* rvh) { | 313 WebContents* WebContents::FromRenderViewHost(const RenderViewHost* rvh) { |
297 return rvh->GetDelegate()->GetAsWebContents(); | 314 return rvh->GetDelegate()->GetAsWebContents(); |
298 } | 315 } |
299 | 316 |
300 } | 317 } |
301 | 318 |
302 // WebContentsImpl ------------------------------------------------------------- | 319 // WebContentsImpl ------------------------------------------------------------- |
303 | 320 |
304 WebContentsImpl::WebContentsImpl( | 321 WebContentsImpl::WebContentsImpl( |
305 content::BrowserContext* browser_context, | 322 content::BrowserContext* browser_context, |
306 SiteInstance* site_instance, | 323 WebContentsImpl* opener) |
307 int routing_id, | |
308 const WebContentsImpl* base_web_contents, | |
309 WebContentsImpl* opener, | |
310 SessionStorageNamespaceImpl* session_storage_namespace) | |
311 : delegate_(NULL), | 324 : delegate_(NULL), |
312 ALLOW_THIS_IN_INITIALIZER_LIST(controller_( | 325 ALLOW_THIS_IN_INITIALIZER_LIST(controller_(this, browser_context)), |
313 this, browser_context, session_storage_namespace)), | |
314 render_view_host_delegate_view_(NULL), | 326 render_view_host_delegate_view_(NULL), |
315 opener_(opener), | 327 opener_(opener), |
316 ALLOW_THIS_IN_INITIALIZER_LIST(render_manager_(this, this, this)), | 328 ALLOW_THIS_IN_INITIALIZER_LIST(render_manager_(this, this, this)), |
317 is_loading_(false), | 329 is_loading_(false), |
318 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 330 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
319 crashed_error_code_(0), | 331 crashed_error_code_(0), |
320 waiting_for_response_(false), | 332 waiting_for_response_(false), |
321 load_state_(net::LOAD_STATE_IDLE, string16()), | 333 load_state_(net::LOAD_STATE_IDLE, string16()), |
322 upload_size_(0), | 334 upload_size_(0), |
323 upload_position_(0), | 335 upload_position_(0), |
324 displayed_insecure_content_(false), | 336 displayed_insecure_content_(false), |
325 capturing_contents_(false), | 337 capturing_contents_(false), |
326 is_being_destroyed_(false), | 338 is_being_destroyed_(false), |
327 notify_disconnection_(false), | 339 notify_disconnection_(false), |
328 dialog_creator_(NULL), | 340 dialog_creator_(NULL), |
329 #if defined(OS_WIN) | 341 #if defined(OS_WIN) |
330 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)), | 342 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)), |
331 #endif | 343 #endif |
332 is_showing_before_unload_dialog_(false), | 344 is_showing_before_unload_dialog_(false), |
333 opener_web_ui_type_(WebUI::kNoWebUI), | 345 opener_web_ui_type_(WebUI::kNoWebUI), |
334 closed_by_user_gesture_(false), | 346 closed_by_user_gesture_(false), |
335 minimum_zoom_percent_( | 347 minimum_zoom_percent_( |
336 static_cast<int>(content::kMinimumZoomFactor * 100)), | 348 static_cast<int>(content::kMinimumZoomFactor * 100)), |
337 maximum_zoom_percent_( | 349 maximum_zoom_percent_( |
338 static_cast<int>(content::kMaximumZoomFactor * 100)), | 350 static_cast<int>(content::kMaximumZoomFactor * 100)), |
339 temporary_zoom_settings_(false), | 351 temporary_zoom_settings_(false), |
340 content_restrictions_(0), | 352 content_restrictions_(0), |
341 color_chooser_(NULL) { | 353 color_chooser_(NULL) { |
342 render_manager_.Init(browser_context, site_instance, routing_id); | |
343 | |
344 view_.reset(content::GetContentClient()->browser()-> | |
345 OverrideCreateWebContentsView(this, &render_view_host_delegate_view_)); | |
346 if (view_.get()) { | |
347 CHECK(render_view_host_delegate_view_); | |
348 } else { | |
349 content::WebContentsViewDelegate* delegate = | |
350 content::GetContentClient()->browser()->GetWebContentsViewDelegate( | |
351 this); | |
352 view_.reset(CreateWebContentsView( | |
353 this, delegate, &render_view_host_delegate_view_)); | |
354 CHECK(render_view_host_delegate_view_); | |
355 } | |
356 CHECK(view_.get()); | |
357 | |
358 // We have the initial size of the view be based on the size of the view of | |
359 // the passed in WebContents. | |
360 view_->CreateView(base_web_contents ? | |
361 base_web_contents->GetView()->GetContainerSize() : gfx::Size()); | |
362 | |
363 // Listen for whether our opener gets destroyed. | |
364 if (opener_) { | |
365 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | |
366 content::Source<WebContents>(opener_)); | |
367 } | |
368 | |
369 registrar_.Add(this, | |
370 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, | |
371 content::NotificationService::AllBrowserContextsAndSources()); | |
372 | |
373 #if defined(ENABLE_JAVA_BRIDGE) | |
374 java_bridge_dispatcher_host_manager_.reset( | |
375 new JavaBridgeDispatcherHostManager(this)); | |
376 #endif | |
377 | |
378 old_browser_plugin_host_.reset(new content::old::BrowserPluginHost(this)); | |
379 } | 354 } |
380 | 355 |
381 WebContentsImpl::~WebContentsImpl() { | 356 WebContentsImpl::~WebContentsImpl() { |
382 is_being_destroyed_ = true; | 357 is_being_destroyed_ = true; |
383 | 358 |
384 // Clear out any JavaScript state. | 359 // Clear out any JavaScript state. |
385 if (dialog_creator_) | 360 if (dialog_creator_) |
386 dialog_creator_->ResetJavaScriptState(this); | 361 dialog_creator_->ResetJavaScriptState(this); |
387 | 362 |
388 if (color_chooser_) | 363 if (color_chooser_) |
(...skipping 24 matching lines...) Expand all Loading... |
413 base::TimeTicks::Now() - close_start_time_); | 388 base::TimeTicks::Now() - close_start_time_); |
414 } | 389 } |
415 | 390 |
416 FOR_EACH_OBSERVER(WebContentsObserver, | 391 FOR_EACH_OBSERVER(WebContentsObserver, |
417 observers_, | 392 observers_, |
418 WebContentsImplDestroyed()); | 393 WebContentsImplDestroyed()); |
419 | 394 |
420 SetDelegate(NULL); | 395 SetDelegate(NULL); |
421 } | 396 } |
422 | 397 |
| 398 WebContentsImpl* WebContentsImpl::Create( |
| 399 BrowserContext* browser_context, |
| 400 SiteInstance* site_instance, |
| 401 int routing_id, |
| 402 const WebContentsImpl* base_web_contents) { |
| 403 return CreateWithOpener(browser_context, site_instance, routing_id, |
| 404 base_web_contents, NULL); |
| 405 } |
| 406 |
| 407 WebContentsImpl* WebContentsImpl::CreateWithOpener( |
| 408 BrowserContext* browser_context, |
| 409 SiteInstance* site_instance, |
| 410 int routing_id, |
| 411 const WebContentsImpl* base_web_contents, |
| 412 WebContentsImpl* opener) { |
| 413 WebContentsImpl* new_contents = new WebContentsImpl(browser_context, opener); |
| 414 |
| 415 new_contents->Init(browser_context, site_instance, routing_id, |
| 416 static_cast<const WebContentsImpl*>(base_web_contents)); |
| 417 return new_contents; |
| 418 } |
| 419 |
423 WebPreferences WebContentsImpl::GetWebkitPrefs(RenderViewHost* rvh, | 420 WebPreferences WebContentsImpl::GetWebkitPrefs(RenderViewHost* rvh, |
424 const GURL& url) { | 421 const GURL& url) { |
425 WebPreferences prefs; | 422 WebPreferences prefs; |
426 | 423 |
427 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 424 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
428 | 425 |
429 prefs.developer_extras_enabled = true; | 426 prefs.developer_extras_enabled = true; |
430 prefs.javascript_enabled = | 427 prefs.javascript_enabled = |
431 !command_line.HasSwitch(switches::kDisableJavaScript); | 428 !command_line.HasSwitch(switches::kDisableJavaScript); |
432 prefs.web_security_enabled = | 429 prefs.web_security_enabled = |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 prefs.fixed_position_creates_stacking_context = !command_line.HasSwitch( | 620 prefs.fixed_position_creates_stacking_context = !command_line.HasSwitch( |
624 switches::kDisableFixedPositionCreatesStackingContext); | 621 switches::kDisableFixedPositionCreatesStackingContext); |
625 | 622 |
626 prefs.number_of_cpu_cores = base::SysInfo::NumberOfProcessors(); | 623 prefs.number_of_cpu_cores = base::SysInfo::NumberOfProcessors(); |
627 | 624 |
628 content::GetContentClient()->browser()->OverrideWebkitPrefs(rvh, url, &prefs); | 625 content::GetContentClient()->browser()->OverrideWebkitPrefs(rvh, url, &prefs); |
629 | 626 |
630 return prefs; | 627 return prefs; |
631 } | 628 } |
632 | 629 |
633 NavigationControllerImpl& WebContentsImpl::GetControllerImpl() { | |
634 return controller_; | |
635 } | |
636 | |
637 RenderViewHostManager* WebContentsImpl::GetRenderManagerForTesting() { | 630 RenderViewHostManager* WebContentsImpl::GetRenderManagerForTesting() { |
638 return &render_manager_; | 631 return &render_manager_; |
639 } | 632 } |
640 | 633 |
641 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, | 634 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, |
642 const IPC::Message& message) { | 635 const IPC::Message& message) { |
643 if (GetWebUI() && | 636 if (GetWebUI() && |
644 static_cast<WebUIImpl*>(GetWebUI())->OnMessageReceived(message)) { | 637 static_cast<WebUIImpl*>(GetWebUI())->OnMessageReceived(message)) { |
645 return true; | 638 return true; |
646 } | 639 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 return handled; | 695 return handled; |
703 } | 696 } |
704 | 697 |
705 void WebContentsImpl::RunFileChooser( | 698 void WebContentsImpl::RunFileChooser( |
706 RenderViewHost* render_view_host, | 699 RenderViewHost* render_view_host, |
707 const content::FileChooserParams& params) { | 700 const content::FileChooserParams& params) { |
708 if (delegate_) | 701 if (delegate_) |
709 delegate_->RunFileChooser(this, params); | 702 delegate_->RunFileChooser(this, params); |
710 } | 703 } |
711 | 704 |
712 NavigationController& WebContentsImpl::GetController() { | 705 NavigationControllerImpl& WebContentsImpl::GetController() { |
713 return controller_; | 706 return controller_; |
714 } | 707 } |
715 | 708 |
716 const NavigationController& WebContentsImpl::GetController() const { | 709 const NavigationControllerImpl& WebContentsImpl::GetController() const { |
717 return controller_; | 710 return controller_; |
718 } | 711 } |
719 | 712 |
720 content::BrowserContext* WebContentsImpl::GetBrowserContext() const { | 713 content::BrowserContext* WebContentsImpl::GetBrowserContext() const { |
721 return controller_.GetBrowserContext(); | 714 return controller_.GetBrowserContext(); |
722 } | 715 } |
723 | 716 |
724 const GURL& WebContentsImpl::GetURL() const { | 717 const GURL& WebContentsImpl::GetURL() const { |
725 // We may not have a navigation entry yet | 718 // We may not have a navigation entry yet |
726 NavigationEntry* entry = controller_.GetActiveEntry(); | 719 NavigationEntry* entry = controller_.GetActiveEntry(); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 | 1013 |
1021 void WebContentsImpl::Stop() { | 1014 void WebContentsImpl::Stop() { |
1022 render_manager_.Stop(); | 1015 render_manager_.Stop(); |
1023 FOR_EACH_OBSERVER(WebContentsObserver, observers_, StopNavigation()); | 1016 FOR_EACH_OBSERVER(WebContentsObserver, observers_, StopNavigation()); |
1024 } | 1017 } |
1025 | 1018 |
1026 WebContents* WebContentsImpl::Clone() { | 1019 WebContents* WebContentsImpl::Clone() { |
1027 // We use our current SiteInstance since the cloned entry will use it anyway. | 1020 // We use our current SiteInstance since the cloned entry will use it anyway. |
1028 // We pass |this| for the |base_web_contents| to size the view correctly, and | 1021 // We pass |this| for the |base_web_contents| to size the view correctly, and |
1029 // our own opener so that the cloned page can access it if it was before. | 1022 // our own opener so that the cloned page can access it if it was before. |
1030 WebContentsImpl* tc = new WebContentsImpl( | 1023 WebContentsImpl* tc = CreateWithOpener(GetBrowserContext(), |
1031 GetBrowserContext(), GetSiteInstance(), | 1024 GetSiteInstance(), MSG_ROUTING_NONE, |
1032 MSG_ROUTING_NONE, this, opener_, NULL); | 1025 this, opener_); |
1033 tc->GetControllerImpl().CopyStateFrom(controller_); | 1026 tc->GetController().CopyStateFrom(controller_); |
1034 return tc; | 1027 return tc; |
1035 } | 1028 } |
1036 | 1029 |
1037 void WebContentsImpl::AddNewContents(WebContents* new_contents, | 1030 void WebContentsImpl::AddNewContents(WebContents* new_contents, |
1038 WindowOpenDisposition disposition, | 1031 WindowOpenDisposition disposition, |
1039 const gfx::Rect& initial_pos, | 1032 const gfx::Rect& initial_pos, |
1040 bool user_gesture) { | 1033 bool user_gesture) { |
1041 if (!delegate_) | 1034 if (!delegate_) |
1042 return; | 1035 return; |
1043 | 1036 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 break; | 1071 break; |
1079 } | 1072 } |
1080 } | 1073 } |
1081 break; | 1074 break; |
1082 } | 1075 } |
1083 default: | 1076 default: |
1084 NOTREACHED(); | 1077 NOTREACHED(); |
1085 } | 1078 } |
1086 } | 1079 } |
1087 | 1080 |
| 1081 void WebContentsImpl::Init(BrowserContext* browser_context, |
| 1082 SiteInstance* site_instance, |
| 1083 int routing_id, |
| 1084 const WebContents* base_web_contents) { |
| 1085 render_manager_.Init(browser_context, site_instance, routing_id); |
| 1086 |
| 1087 view_.reset(content::GetContentClient()->browser()-> |
| 1088 OverrideCreateWebContentsView(this, &render_view_host_delegate_view_)); |
| 1089 if (view_.get()) { |
| 1090 CHECK(render_view_host_delegate_view_); |
| 1091 } else { |
| 1092 content::WebContentsViewDelegate* delegate = |
| 1093 content::GetContentClient()->browser()->GetWebContentsViewDelegate( |
| 1094 this); |
| 1095 view_.reset(CreateWebContentsView( |
| 1096 this, delegate, &render_view_host_delegate_view_)); |
| 1097 CHECK(render_view_host_delegate_view_); |
| 1098 } |
| 1099 CHECK(view_.get()); |
| 1100 |
| 1101 // We have the initial size of the view be based on the size of the view of |
| 1102 // the passed in WebContents. |
| 1103 view_->CreateView(base_web_contents ? |
| 1104 base_web_contents->GetView()->GetContainerSize() : gfx::Size()); |
| 1105 |
| 1106 // Listen for whether our opener gets destroyed. |
| 1107 if (opener_) { |
| 1108 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 1109 content::Source<WebContents>(opener_)); |
| 1110 } |
| 1111 |
| 1112 registrar_.Add(this, |
| 1113 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
| 1114 content::NotificationService::AllBrowserContextsAndSources()); |
| 1115 #if defined(ENABLE_JAVA_BRIDGE) |
| 1116 java_bridge_dispatcher_host_manager_.reset( |
| 1117 new JavaBridgeDispatcherHostManager(this)); |
| 1118 #endif |
| 1119 |
| 1120 old_browser_plugin_host_.reset(new content::old::BrowserPluginHost(this)); |
| 1121 } |
| 1122 |
1088 void WebContentsImpl::OnWebContentsDestroyed(WebContents* web_contents) { | 1123 void WebContentsImpl::OnWebContentsDestroyed(WebContents* web_contents) { |
1089 // Clear the opener if it has been closed. | 1124 // Clear the opener if it has been closed. |
1090 if (web_contents == opener_) { | 1125 if (web_contents == opener_) { |
1091 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 1126 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
1092 content::Source<WebContents>(opener_)); | 1127 content::Source<WebContents>(opener_)); |
1093 opener_ = NULL; | 1128 opener_ = NULL; |
1094 } | 1129 } |
1095 } | 1130 } |
1096 | 1131 |
1097 void WebContentsImpl::AddObserver(WebContentsObserver* observer) { | 1132 void WebContentsImpl::AddObserver(WebContentsObserver* observer) { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 // script-related windows), by passing in the current SiteInstance. However, | 1227 // script-related windows), by passing in the current SiteInstance. However, |
1193 // if the opener is being suppressed, we create a new SiteInstance in its own | 1228 // if the opener is being suppressed, we create a new SiteInstance in its own |
1194 // BrowsingInstance. | 1229 // BrowsingInstance. |
1195 scoped_refptr<SiteInstance> site_instance = | 1230 scoped_refptr<SiteInstance> site_instance = |
1196 params.opener_suppressed ? | 1231 params.opener_suppressed ? |
1197 SiteInstance::Create(GetBrowserContext()) : | 1232 SiteInstance::Create(GetBrowserContext()) : |
1198 GetSiteInstance(); | 1233 GetSiteInstance(); |
1199 | 1234 |
1200 // Create the new web contents. This will automatically create the new | 1235 // Create the new web contents. This will automatically create the new |
1201 // WebContentsView. In the future, we may want to create the view separately. | 1236 // WebContentsView. In the future, we may want to create the view separately. |
1202 WebContentsImpl* new_contents = new WebContentsImpl( | 1237 WebContentsImpl* new_contents = |
1203 GetBrowserContext(), | 1238 new WebContentsImpl(GetBrowserContext(), |
1204 site_instance, | 1239 params.opener_suppressed ? NULL : this); |
1205 route_id, | 1240 |
1206 this, | 1241 // We must assign the SessionStorageNamespace before calling Init(). |
1207 params.opener_suppressed ? NULL : this, | 1242 const std::string& partition_id = |
1208 static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace)); | 1243 content::GetContentClient()->browser()-> |
| 1244 GetStoragePartitionIdForSiteInstance(GetBrowserContext(), |
| 1245 site_instance); |
| 1246 DOMStorageContextImpl* dom_storage_context = |
| 1247 static_cast<DOMStorageContextImpl*>( |
| 1248 BrowserContext::GetDOMStorageContextByPartitionId( |
| 1249 GetBrowserContext(), partition_id)); |
| 1250 SessionStorageNamespaceImpl* session_storage_namespace_impl = |
| 1251 static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace); |
| 1252 CHECK(session_storage_namespace_impl->IsFromContext(dom_storage_context)); |
| 1253 new_contents->GetController().SetSessionStorageNamespace( |
| 1254 partition_id, |
| 1255 session_storage_namespace); |
| 1256 new_contents->Init(GetBrowserContext(), site_instance, route_id, this); |
| 1257 |
1209 new_contents->set_opener_web_ui_type(GetWebUITypeForCurrentState()); | 1258 new_contents->set_opener_web_ui_type(GetWebUITypeForCurrentState()); |
1210 | 1259 |
1211 if (!params.opener_suppressed) { | 1260 if (!params.opener_suppressed) { |
1212 content::WebContentsView* new_view = new_contents->GetView(); | 1261 content::WebContentsView* new_view = new_contents->GetView(); |
1213 | 1262 |
1214 // TODO(brettw): It seems bogus that we have to call this function on the | 1263 // TODO(brettw): It seems bogus that we have to call this function on the |
1215 // newly created object and give it one of its own member variables. | 1264 // newly created object and give it one of its own member variables. |
1216 new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); | 1265 new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); |
1217 | 1266 |
1218 // Save the created window associated with the route so we can show it | 1267 // Save the created window associated with the route so we can show it |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1992 | 2041 |
1993 content::NotificationService::current()->Notify( | 2042 content::NotificationService::current()->Notify( |
1994 content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE, | 2043 content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE, |
1995 content::Source<NavigationController>(&controller_), | 2044 content::Source<NavigationController>(&controller_), |
1996 content::Details<content::LoadFromMemoryCacheDetails>(&details)); | 2045 content::Details<content::LoadFromMemoryCacheDetails>(&details)); |
1997 } | 2046 } |
1998 | 2047 |
1999 void WebContentsImpl::OnDidDisplayInsecureContent() { | 2048 void WebContentsImpl::OnDidDisplayInsecureContent() { |
2000 content::RecordAction(UserMetricsAction("SSL.DisplayedInsecureContent")); | 2049 content::RecordAction(UserMetricsAction("SSL.DisplayedInsecureContent")); |
2001 displayed_insecure_content_ = true; | 2050 displayed_insecure_content_ = true; |
2002 SSLManager::NotifySSLInternalStateChanged(&GetControllerImpl()); | 2051 SSLManager::NotifySSLInternalStateChanged(&GetController()); |
2003 } | 2052 } |
2004 | 2053 |
2005 void WebContentsImpl::OnDidRunInsecureContent( | 2054 void WebContentsImpl::OnDidRunInsecureContent( |
2006 const std::string& security_origin, const GURL& target_url) { | 2055 const std::string& security_origin, const GURL& target_url) { |
2007 LOG(INFO) << security_origin << " ran insecure content from " | 2056 LOG(INFO) << security_origin << " ran insecure content from " |
2008 << target_url.possibly_invalid_spec(); | 2057 << target_url.possibly_invalid_spec(); |
2009 content::RecordAction(UserMetricsAction("SSL.RanInsecureContent")); | 2058 content::RecordAction(UserMetricsAction("SSL.RanInsecureContent")); |
2010 if (EndsWith(security_origin, kDotGoogleDotCom, false)) | 2059 if (EndsWith(security_origin, kDotGoogleDotCom, false)) |
2011 content::RecordAction(UserMetricsAction("SSL.RanInsecureContentGoogle")); | 2060 content::RecordAction(UserMetricsAction("SSL.RanInsecureContentGoogle")); |
2012 controller_.ssl_manager()->DidRunInsecureContent(security_origin); | 2061 controller_.ssl_manager()->DidRunInsecureContent(security_origin); |
2013 displayed_insecure_content_ = true; | 2062 displayed_insecure_content_ = true; |
2014 SSLManager::NotifySSLInternalStateChanged(&GetControllerImpl()); | 2063 SSLManager::NotifySSLInternalStateChanged(&GetController()); |
2015 } | 2064 } |
2016 | 2065 |
2017 void WebContentsImpl::OnDocumentLoadedInFrame(int64 frame_id) { | 2066 void WebContentsImpl::OnDocumentLoadedInFrame(int64 frame_id) { |
2018 controller_.DocumentLoadedInFrame(); | 2067 controller_.DocumentLoadedInFrame(); |
2019 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2068 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
2020 DocumentLoadedInFrame(frame_id, message_source_)); | 2069 DocumentLoadedInFrame(frame_id, message_source_)); |
2021 } | 2070 } |
2022 | 2071 |
2023 void WebContentsImpl::OnDidFinishLoad( | 2072 void WebContentsImpl::OnDidFinishLoad( |
2024 int64 frame_id, | 2073 int64 frame_id, |
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3029 // SiteInstance as well. | 3078 // SiteInstance as well. |
3030 if (opener_) | 3079 if (opener_) |
3031 opener_route_id = opener_->CreateOpenerRenderViews(instance); | 3080 opener_route_id = opener_->CreateOpenerRenderViews(instance); |
3032 | 3081 |
3033 // Create a swapped out RenderView in the given SiteInstance if none exists, | 3082 // Create a swapped out RenderView in the given SiteInstance if none exists, |
3034 // setting its opener to the given route_id. Return the new view's route_id. | 3083 // setting its opener to the given route_id. Return the new view's route_id. |
3035 return render_manager_.CreateRenderView(instance, opener_route_id, true); | 3084 return render_manager_.CreateRenderView(instance, opener_route_id, true); |
3036 } | 3085 } |
3037 | 3086 |
3038 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { | 3087 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { |
3039 return GetControllerImpl(); | 3088 return GetController(); |
3040 } | 3089 } |
3041 | 3090 |
3042 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { | 3091 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { |
3043 return static_cast<WebUIImpl*>(CreateWebUI(url)); | 3092 return static_cast<WebUIImpl*>(CreateWebUI(url)); |
3044 } | 3093 } |
3045 | 3094 |
3046 NavigationEntry* | 3095 NavigationEntry* |
3047 WebContentsImpl::GetLastCommittedNavigationEntryForRenderManager() { | 3096 WebContentsImpl::GetLastCommittedNavigationEntryForRenderManager() { |
3048 return controller_.GetLastCommittedEntry(); | 3097 return controller_.GetLastCommittedEntry(); |
3049 } | 3098 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3154 old_browser_plugin_host()->embedder_render_process_host(); | 3203 old_browser_plugin_host()->embedder_render_process_host(); |
3155 *embedder_container_id = old_browser_plugin_host()->instance_id(); | 3204 *embedder_container_id = old_browser_plugin_host()->instance_id(); |
3156 int embedder_process_id = | 3205 int embedder_process_id = |
3157 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; | 3206 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; |
3158 if (embedder_process_id != -1) { | 3207 if (embedder_process_id != -1) { |
3159 *embedder_channel_name = | 3208 *embedder_channel_name = |
3160 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), | 3209 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), |
3161 embedder_process_id); | 3210 embedder_process_id); |
3162 } | 3211 } |
3163 } | 3212 } |
OLD | NEW |