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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 } | 275 } |
275 | 276 |
276 } // namespace | 277 } // namespace |
277 | 278 |
278 namespace content { | 279 namespace content { |
279 | 280 |
280 WebContents* WebContents::Create( | 281 WebContents* WebContents::Create( |
281 BrowserContext* browser_context, | 282 BrowserContext* browser_context, |
282 SiteInstance* site_instance, | 283 SiteInstance* site_instance, |
283 int routing_id, | 284 int routing_id, |
| 285 const WebContents* base_web_contents) { |
| 286 return WebContentsImpl::Create( |
| 287 browser_context, site_instance, routing_id, |
| 288 static_cast<const WebContentsImpl*>(base_web_contents)); |
| 289 } |
| 290 |
| 291 WebContents* WebContents::CreateWithSessionStorage( |
| 292 BrowserContext* browser_context, |
| 293 SiteInstance* site_instance, |
| 294 int routing_id, |
284 const WebContents* base_web_contents, | 295 const WebContents* base_web_contents, |
285 SessionStorageNamespace* session_storage_namespace) { | 296 const SessionStorageNamespaceMap& session_storage_namespace_map) { |
286 return new WebContentsImpl( | 297 WebContentsImpl* new_contents = new WebContentsImpl(browser_context, NULL); |
287 browser_context, | 298 |
288 site_instance, | 299 for (SessionStorageNamespaceMap::const_iterator it = |
289 routing_id, | 300 session_storage_namespace_map.begin(); |
290 static_cast<const WebContentsImpl*>(base_web_contents), | 301 it != session_storage_namespace_map.end(); |
291 NULL, | 302 ++it) { |
292 static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace)); | 303 new_contents->GetController().SetSessionStorageNamespace(it->first, |
| 304 it->second); |
| 305 } |
| 306 |
| 307 new_contents->Init(browser_context, site_instance, routing_id, |
| 308 static_cast<const WebContentsImpl*>(base_web_contents)); |
| 309 return new_contents; |
293 } | 310 } |
294 | 311 |
295 WebContents* WebContents::FromRenderViewHost(const RenderViewHost* rvh) { | 312 WebContents* WebContents::FromRenderViewHost(const RenderViewHost* rvh) { |
296 return rvh->GetDelegate()->GetAsWebContents(); | 313 return rvh->GetDelegate()->GetAsWebContents(); |
297 } | 314 } |
298 | 315 |
299 } | 316 } |
300 | 317 |
301 // WebContentsImpl ------------------------------------------------------------- | 318 // WebContentsImpl ------------------------------------------------------------- |
302 | 319 |
303 WebContentsImpl::WebContentsImpl( | 320 WebContentsImpl::WebContentsImpl( |
304 content::BrowserContext* browser_context, | 321 content::BrowserContext* browser_context, |
305 SiteInstance* site_instance, | 322 WebContentsImpl* opener) |
306 int routing_id, | |
307 const WebContentsImpl* base_web_contents, | |
308 WebContentsImpl* opener, | |
309 SessionStorageNamespaceImpl* session_storage_namespace) | |
310 : delegate_(NULL), | 323 : delegate_(NULL), |
311 ALLOW_THIS_IN_INITIALIZER_LIST(controller_( | 324 ALLOW_THIS_IN_INITIALIZER_LIST(controller_(this, browser_context)), |
312 this, browser_context, session_storage_namespace)), | |
313 render_view_host_delegate_view_(NULL), | 325 render_view_host_delegate_view_(NULL), |
314 opener_(opener), | 326 opener_(opener), |
315 ALLOW_THIS_IN_INITIALIZER_LIST(render_manager_(this, this, this)), | 327 ALLOW_THIS_IN_INITIALIZER_LIST(render_manager_(this, this, this)), |
316 is_loading_(false), | 328 is_loading_(false), |
317 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 329 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
318 crashed_error_code_(0), | 330 crashed_error_code_(0), |
319 waiting_for_response_(false), | 331 waiting_for_response_(false), |
320 load_state_(net::LOAD_STATE_IDLE, string16()), | 332 load_state_(net::LOAD_STATE_IDLE, string16()), |
321 upload_size_(0), | 333 upload_size_(0), |
322 upload_position_(0), | 334 upload_position_(0), |
323 displayed_insecure_content_(false), | 335 displayed_insecure_content_(false), |
324 capturing_contents_(false), | 336 capturing_contents_(false), |
325 is_being_destroyed_(false), | 337 is_being_destroyed_(false), |
326 notify_disconnection_(false), | 338 notify_disconnection_(false), |
327 dialog_creator_(NULL), | 339 dialog_creator_(NULL), |
328 #if defined(OS_WIN) | 340 #if defined(OS_WIN) |
329 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)), | 341 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)), |
330 #endif | 342 #endif |
331 is_showing_before_unload_dialog_(false), | 343 is_showing_before_unload_dialog_(false), |
332 opener_web_ui_type_(WebUI::kNoWebUI), | 344 opener_web_ui_type_(WebUI::kNoWebUI), |
333 closed_by_user_gesture_(false), | 345 closed_by_user_gesture_(false), |
334 minimum_zoom_percent_( | 346 minimum_zoom_percent_( |
335 static_cast<int>(content::kMinimumZoomFactor * 100)), | 347 static_cast<int>(content::kMinimumZoomFactor * 100)), |
336 maximum_zoom_percent_( | 348 maximum_zoom_percent_( |
337 static_cast<int>(content::kMaximumZoomFactor * 100)), | 349 static_cast<int>(content::kMaximumZoomFactor * 100)), |
338 temporary_zoom_settings_(false), | 350 temporary_zoom_settings_(false), |
339 content_restrictions_(0), | 351 content_restrictions_(0), |
340 color_chooser_(NULL) { | 352 color_chooser_(NULL) { |
341 render_manager_.Init(browser_context, site_instance, routing_id); | |
342 | |
343 view_.reset(content::GetContentClient()->browser()-> | |
344 OverrideCreateWebContentsView(this, &render_view_host_delegate_view_)); | |
345 if (view_.get()) { | |
346 CHECK(render_view_host_delegate_view_); | |
347 } else { | |
348 content::WebContentsViewDelegate* delegate = | |
349 content::GetContentClient()->browser()->GetWebContentsViewDelegate( | |
350 this); | |
351 view_.reset(CreateWebContentsView( | |
352 this, delegate, &render_view_host_delegate_view_)); | |
353 CHECK(render_view_host_delegate_view_); | |
354 } | |
355 CHECK(view_.get()); | |
356 | |
357 // We have the initial size of the view be based on the size of the view of | |
358 // the passed in WebContents. | |
359 view_->CreateView(base_web_contents ? | |
360 base_web_contents->GetView()->GetContainerSize() : gfx::Size()); | |
361 | |
362 // Listen for whether our opener gets destroyed. | |
363 if (opener_) { | |
364 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | |
365 content::Source<WebContents>(opener_)); | |
366 } | |
367 | |
368 registrar_.Add(this, | |
369 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, | |
370 content::NotificationService::AllBrowserContextsAndSources()); | |
371 | |
372 #if defined(ENABLE_JAVA_BRIDGE) | |
373 java_bridge_dispatcher_host_manager_.reset( | |
374 new JavaBridgeDispatcherHostManager(this)); | |
375 #endif | |
376 | |
377 old_browser_plugin_host_.reset(new content::old::BrowserPluginHost(this)); | |
378 } | 353 } |
379 | 354 |
380 WebContentsImpl::~WebContentsImpl() { | 355 WebContentsImpl::~WebContentsImpl() { |
381 is_being_destroyed_ = true; | 356 is_being_destroyed_ = true; |
382 | 357 |
383 // Clear out any JavaScript state. | 358 // Clear out any JavaScript state. |
384 if (dialog_creator_) | 359 if (dialog_creator_) |
385 dialog_creator_->ResetJavaScriptState(this); | 360 dialog_creator_->ResetJavaScriptState(this); |
386 | 361 |
387 if (color_chooser_) | 362 if (color_chooser_) |
(...skipping 24 matching lines...) Expand all Loading... |
412 base::TimeTicks::Now() - close_start_time_); | 387 base::TimeTicks::Now() - close_start_time_); |
413 } | 388 } |
414 | 389 |
415 FOR_EACH_OBSERVER(WebContentsObserver, | 390 FOR_EACH_OBSERVER(WebContentsObserver, |
416 observers_, | 391 observers_, |
417 WebContentsImplDestroyed()); | 392 WebContentsImplDestroyed()); |
418 | 393 |
419 SetDelegate(NULL); | 394 SetDelegate(NULL); |
420 } | 395 } |
421 | 396 |
| 397 WebContentsImpl* WebContentsImpl::Create( |
| 398 BrowserContext* browser_context, |
| 399 SiteInstance* site_instance, |
| 400 int routing_id, |
| 401 const WebContentsImpl* base_web_contents) { |
| 402 return CreateWithOpener(browser_context, site_instance, routing_id, |
| 403 base_web_contents, NULL); |
| 404 } |
| 405 |
| 406 WebContentsImpl* WebContentsImpl::CreateWithOpener( |
| 407 BrowserContext* browser_context, |
| 408 SiteInstance* site_instance, |
| 409 int routing_id, |
| 410 const WebContentsImpl* base_web_contents, |
| 411 WebContentsImpl* opener) { |
| 412 WebContentsImpl* new_contents = new WebContentsImpl(browser_context, opener); |
| 413 |
| 414 new_contents->Init(browser_context, site_instance, routing_id, |
| 415 static_cast<const WebContentsImpl*>(base_web_contents)); |
| 416 return new_contents; |
| 417 } |
| 418 |
422 WebPreferences WebContentsImpl::GetWebkitPrefs(RenderViewHost* rvh, | 419 WebPreferences WebContentsImpl::GetWebkitPrefs(RenderViewHost* rvh, |
423 const GURL& url) { | 420 const GURL& url) { |
424 WebPreferences prefs; | 421 WebPreferences prefs; |
425 | 422 |
426 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 423 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
427 | 424 |
428 prefs.developer_extras_enabled = true; | 425 prefs.developer_extras_enabled = true; |
429 prefs.javascript_enabled = | 426 prefs.javascript_enabled = |
430 !command_line.HasSwitch(switches::kDisableJavaScript); | 427 !command_line.HasSwitch(switches::kDisableJavaScript); |
431 prefs.web_security_enabled = | 428 prefs.web_security_enabled = |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 prefs.fixed_position_creates_stacking_context = !command_line.HasSwitch( | 610 prefs.fixed_position_creates_stacking_context = !command_line.HasSwitch( |
614 switches::kDisableFixedPositionCreatesStackingContext); | 611 switches::kDisableFixedPositionCreatesStackingContext); |
615 | 612 |
616 prefs.number_of_cpu_cores = base::SysInfo::NumberOfProcessors(); | 613 prefs.number_of_cpu_cores = base::SysInfo::NumberOfProcessors(); |
617 | 614 |
618 content::GetContentClient()->browser()->OverrideWebkitPrefs(rvh, url, &prefs); | 615 content::GetContentClient()->browser()->OverrideWebkitPrefs(rvh, url, &prefs); |
619 | 616 |
620 return prefs; | 617 return prefs; |
621 } | 618 } |
622 | 619 |
623 NavigationControllerImpl& WebContentsImpl::GetControllerImpl() { | |
624 return controller_; | |
625 } | |
626 | |
627 RenderViewHostManager* WebContentsImpl::GetRenderManagerForTesting() { | 620 RenderViewHostManager* WebContentsImpl::GetRenderManagerForTesting() { |
628 return &render_manager_; | 621 return &render_manager_; |
629 } | 622 } |
630 | 623 |
631 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, | 624 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, |
632 const IPC::Message& message) { | 625 const IPC::Message& message) { |
633 if (GetWebUI() && | 626 if (GetWebUI() && |
634 static_cast<WebUIImpl*>(GetWebUI())->OnMessageReceived(message)) { | 627 static_cast<WebUIImpl*>(GetWebUI())->OnMessageReceived(message)) { |
635 return true; | 628 return true; |
636 } | 629 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 return handled; | 685 return handled; |
693 } | 686 } |
694 | 687 |
695 void WebContentsImpl::RunFileChooser( | 688 void WebContentsImpl::RunFileChooser( |
696 RenderViewHost* render_view_host, | 689 RenderViewHost* render_view_host, |
697 const content::FileChooserParams& params) { | 690 const content::FileChooserParams& params) { |
698 if (delegate_) | 691 if (delegate_) |
699 delegate_->RunFileChooser(this, params); | 692 delegate_->RunFileChooser(this, params); |
700 } | 693 } |
701 | 694 |
702 NavigationController& WebContentsImpl::GetController() { | 695 NavigationControllerImpl& WebContentsImpl::GetController() { |
703 return controller_; | 696 return controller_; |
704 } | 697 } |
705 | 698 |
706 const NavigationController& WebContentsImpl::GetController() const { | 699 const NavigationControllerImpl& WebContentsImpl::GetController() const { |
707 return controller_; | 700 return controller_; |
708 } | 701 } |
709 | 702 |
710 content::BrowserContext* WebContentsImpl::GetBrowserContext() const { | 703 content::BrowserContext* WebContentsImpl::GetBrowserContext() const { |
711 return controller_.GetBrowserContext(); | 704 return controller_.GetBrowserContext(); |
712 } | 705 } |
713 | 706 |
714 const GURL& WebContentsImpl::GetURL() const { | 707 const GURL& WebContentsImpl::GetURL() const { |
715 // We may not have a navigation entry yet | 708 // We may not have a navigation entry yet |
716 NavigationEntry* entry = controller_.GetActiveEntry(); | 709 NavigationEntry* entry = controller_.GetActiveEntry(); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 | 1003 |
1011 void WebContentsImpl::Stop() { | 1004 void WebContentsImpl::Stop() { |
1012 render_manager_.Stop(); | 1005 render_manager_.Stop(); |
1013 FOR_EACH_OBSERVER(WebContentsObserver, observers_, StopNavigation()); | 1006 FOR_EACH_OBSERVER(WebContentsObserver, observers_, StopNavigation()); |
1014 } | 1007 } |
1015 | 1008 |
1016 WebContents* WebContentsImpl::Clone() { | 1009 WebContents* WebContentsImpl::Clone() { |
1017 // We use our current SiteInstance since the cloned entry will use it anyway. | 1010 // We use our current SiteInstance since the cloned entry will use it anyway. |
1018 // We pass |this| for the |base_web_contents| to size the view correctly, and | 1011 // We pass |this| for the |base_web_contents| to size the view correctly, and |
1019 // our own opener so that the cloned page can access it if it was before. | 1012 // our own opener so that the cloned page can access it if it was before. |
1020 WebContentsImpl* tc = new WebContentsImpl( | 1013 WebContentsImpl* tc = CreateWithOpener(GetBrowserContext(), |
1021 GetBrowserContext(), GetSiteInstance(), | 1014 GetSiteInstance(), MSG_ROUTING_NONE, |
1022 MSG_ROUTING_NONE, this, opener_, NULL); | 1015 this, opener_); |
1023 tc->GetControllerImpl().CopyStateFrom(controller_); | 1016 tc->GetController().CopyStateFrom(controller_); |
1024 return tc; | 1017 return tc; |
1025 } | 1018 } |
1026 | 1019 |
1027 void WebContentsImpl::AddNewContents(WebContents* new_contents, | 1020 void WebContentsImpl::AddNewContents(WebContents* new_contents, |
1028 WindowOpenDisposition disposition, | 1021 WindowOpenDisposition disposition, |
1029 const gfx::Rect& initial_pos, | 1022 const gfx::Rect& initial_pos, |
1030 bool user_gesture) { | 1023 bool user_gesture) { |
1031 if (!delegate_) | 1024 if (!delegate_) |
1032 return; | 1025 return; |
1033 | 1026 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1068 break; | 1061 break; |
1069 } | 1062 } |
1070 } | 1063 } |
1071 break; | 1064 break; |
1072 } | 1065 } |
1073 default: | 1066 default: |
1074 NOTREACHED(); | 1067 NOTREACHED(); |
1075 } | 1068 } |
1076 } | 1069 } |
1077 | 1070 |
| 1071 void WebContentsImpl::Init(BrowserContext* browser_context, |
| 1072 SiteInstance* site_instance, |
| 1073 int routing_id, |
| 1074 const WebContents* base_web_contents) { |
| 1075 render_manager_.Init(browser_context, site_instance, routing_id); |
| 1076 |
| 1077 view_.reset(content::GetContentClient()->browser()-> |
| 1078 OverrideCreateWebContentsView(this, &render_view_host_delegate_view_)); |
| 1079 if (view_.get()) { |
| 1080 CHECK(render_view_host_delegate_view_); |
| 1081 } else { |
| 1082 content::WebContentsViewDelegate* delegate = |
| 1083 content::GetContentClient()->browser()->GetWebContentsViewDelegate( |
| 1084 this); |
| 1085 view_.reset(CreateWebContentsView( |
| 1086 this, delegate, &render_view_host_delegate_view_)); |
| 1087 CHECK(render_view_host_delegate_view_); |
| 1088 } |
| 1089 CHECK(view_.get()); |
| 1090 |
| 1091 // We have the initial size of the view be based on the size of the view of |
| 1092 // the passed in WebContents. |
| 1093 view_->CreateView(base_web_contents ? |
| 1094 base_web_contents->GetView()->GetContainerSize() : gfx::Size()); |
| 1095 |
| 1096 // Listen for whether our opener gets destroyed. |
| 1097 if (opener_) { |
| 1098 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 1099 content::Source<WebContents>(opener_)); |
| 1100 } |
| 1101 |
| 1102 registrar_.Add(this, |
| 1103 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
| 1104 content::NotificationService::AllBrowserContextsAndSources()); |
| 1105 #if defined(ENABLE_JAVA_BRIDGE) |
| 1106 java_bridge_dispatcher_host_manager_.reset( |
| 1107 new JavaBridgeDispatcherHostManager(this)); |
| 1108 #endif |
| 1109 |
| 1110 old_browser_plugin_host_.reset(new content::old::BrowserPluginHost(this)); |
| 1111 } |
| 1112 |
1078 void WebContentsImpl::OnWebContentsDestroyed(WebContents* web_contents) { | 1113 void WebContentsImpl::OnWebContentsDestroyed(WebContents* web_contents) { |
1079 // Clear the opener if it has been closed. | 1114 // Clear the opener if it has been closed. |
1080 if (web_contents == opener_) { | 1115 if (web_contents == opener_) { |
1081 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 1116 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
1082 content::Source<WebContents>(opener_)); | 1117 content::Source<WebContents>(opener_)); |
1083 opener_ = NULL; | 1118 opener_ = NULL; |
1084 } | 1119 } |
1085 } | 1120 } |
1086 | 1121 |
1087 void WebContentsImpl::AddObserver(WebContentsObserver* observer) { | 1122 void WebContentsImpl::AddObserver(WebContentsObserver* observer) { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 // script-related windows), by passing in the current SiteInstance. However, | 1217 // script-related windows), by passing in the current SiteInstance. However, |
1183 // if the opener is being suppressed, we create a new SiteInstance in its own | 1218 // if the opener is being suppressed, we create a new SiteInstance in its own |
1184 // BrowsingInstance. | 1219 // BrowsingInstance. |
1185 scoped_refptr<SiteInstance> site_instance = | 1220 scoped_refptr<SiteInstance> site_instance = |
1186 params.opener_suppressed ? | 1221 params.opener_suppressed ? |
1187 SiteInstance::Create(GetBrowserContext()) : | 1222 SiteInstance::Create(GetBrowserContext()) : |
1188 GetSiteInstance(); | 1223 GetSiteInstance(); |
1189 | 1224 |
1190 // Create the new web contents. This will automatically create the new | 1225 // Create the new web contents. This will automatically create the new |
1191 // WebContentsView. In the future, we may want to create the view separately. | 1226 // WebContentsView. In the future, we may want to create the view separately. |
1192 WebContentsImpl* new_contents = new WebContentsImpl( | 1227 WebContentsImpl* new_contents = |
1193 GetBrowserContext(), | 1228 new WebContentsImpl(GetBrowserContext(), |
1194 site_instance, | 1229 params.opener_suppressed ? NULL : this); |
1195 route_id, | 1230 |
1196 this, | 1231 // We must assign the SessionStorageNamespace before calling Init(). |
1197 params.opener_suppressed ? NULL : this, | 1232 const std::string& partition_id = |
1198 static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace)); | 1233 content::GetContentClient()->browser()-> |
| 1234 GetStoragePartitionIdForSiteInstance(GetBrowserContext(), |
| 1235 site_instance); |
| 1236 DOMStorageContextImpl* dom_storage_context = |
| 1237 static_cast<DOMStorageContextImpl*>( |
| 1238 BrowserContext::GetDOMStorageContextByPartitionId( |
| 1239 GetBrowserContext(), partition_id)); |
| 1240 SessionStorageNamespaceImpl* session_storage_namespace_impl = |
| 1241 static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace); |
| 1242 CHECK(session_storage_namespace_impl->IsFromContext(dom_storage_context)); |
| 1243 new_contents->GetController().SetSessionStorageNamespace( |
| 1244 partition_id, |
| 1245 session_storage_namespace); |
| 1246 new_contents->Init(GetBrowserContext(), site_instance, route_id, this); |
| 1247 |
1199 new_contents->set_opener_web_ui_type(GetWebUITypeForCurrentState()); | 1248 new_contents->set_opener_web_ui_type(GetWebUITypeForCurrentState()); |
1200 | 1249 |
1201 if (!params.opener_suppressed) { | 1250 if (!params.opener_suppressed) { |
1202 content::WebContentsView* new_view = new_contents->GetView(); | 1251 content::WebContentsView* new_view = new_contents->GetView(); |
1203 | 1252 |
1204 // TODO(brettw): It seems bogus that we have to call this function on the | 1253 // TODO(brettw): It seems bogus that we have to call this function on the |
1205 // newly created object and give it one of its own member variables. | 1254 // newly created object and give it one of its own member variables. |
1206 new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); | 1255 new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); |
1207 | 1256 |
1208 // Save the created window associated with the route so we can show it | 1257 // 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... |
1982 | 2031 |
1983 content::NotificationService::current()->Notify( | 2032 content::NotificationService::current()->Notify( |
1984 content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE, | 2033 content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE, |
1985 content::Source<NavigationController>(&controller_), | 2034 content::Source<NavigationController>(&controller_), |
1986 content::Details<content::LoadFromMemoryCacheDetails>(&details)); | 2035 content::Details<content::LoadFromMemoryCacheDetails>(&details)); |
1987 } | 2036 } |
1988 | 2037 |
1989 void WebContentsImpl::OnDidDisplayInsecureContent() { | 2038 void WebContentsImpl::OnDidDisplayInsecureContent() { |
1990 content::RecordAction(UserMetricsAction("SSL.DisplayedInsecureContent")); | 2039 content::RecordAction(UserMetricsAction("SSL.DisplayedInsecureContent")); |
1991 displayed_insecure_content_ = true; | 2040 displayed_insecure_content_ = true; |
1992 SSLManager::NotifySSLInternalStateChanged(&GetControllerImpl()); | 2041 SSLManager::NotifySSLInternalStateChanged(&GetController()); |
1993 } | 2042 } |
1994 | 2043 |
1995 void WebContentsImpl::OnDidRunInsecureContent( | 2044 void WebContentsImpl::OnDidRunInsecureContent( |
1996 const std::string& security_origin, const GURL& target_url) { | 2045 const std::string& security_origin, const GURL& target_url) { |
1997 LOG(INFO) << security_origin << " ran insecure content from " | 2046 LOG(INFO) << security_origin << " ran insecure content from " |
1998 << target_url.possibly_invalid_spec(); | 2047 << target_url.possibly_invalid_spec(); |
1999 content::RecordAction(UserMetricsAction("SSL.RanInsecureContent")); | 2048 content::RecordAction(UserMetricsAction("SSL.RanInsecureContent")); |
2000 if (EndsWith(security_origin, kDotGoogleDotCom, false)) | 2049 if (EndsWith(security_origin, kDotGoogleDotCom, false)) |
2001 content::RecordAction(UserMetricsAction("SSL.RanInsecureContentGoogle")); | 2050 content::RecordAction(UserMetricsAction("SSL.RanInsecureContentGoogle")); |
2002 controller_.ssl_manager()->DidRunInsecureContent(security_origin); | 2051 controller_.ssl_manager()->DidRunInsecureContent(security_origin); |
2003 displayed_insecure_content_ = true; | 2052 displayed_insecure_content_ = true; |
2004 SSLManager::NotifySSLInternalStateChanged(&GetControllerImpl()); | 2053 SSLManager::NotifySSLInternalStateChanged(&GetController()); |
2005 } | 2054 } |
2006 | 2055 |
2007 void WebContentsImpl::OnDocumentLoadedInFrame(int64 frame_id) { | 2056 void WebContentsImpl::OnDocumentLoadedInFrame(int64 frame_id) { |
2008 controller_.DocumentLoadedInFrame(); | 2057 controller_.DocumentLoadedInFrame(); |
2009 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2058 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
2010 DocumentLoadedInFrame(frame_id, message_source_)); | 2059 DocumentLoadedInFrame(frame_id, message_source_)); |
2011 } | 2060 } |
2012 | 2061 |
2013 void WebContentsImpl::OnDidFinishLoad( | 2062 void WebContentsImpl::OnDidFinishLoad( |
2014 int64 frame_id, | 2063 int64 frame_id, |
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3010 // SiteInstance as well. | 3059 // SiteInstance as well. |
3011 if (opener_) | 3060 if (opener_) |
3012 opener_route_id = opener_->CreateOpenerRenderViews(instance); | 3061 opener_route_id = opener_->CreateOpenerRenderViews(instance); |
3013 | 3062 |
3014 // Create a swapped out RenderView in the given SiteInstance if none exists, | 3063 // Create a swapped out RenderView in the given SiteInstance if none exists, |
3015 // setting its opener to the given route_id. Return the new view's route_id. | 3064 // setting its opener to the given route_id. Return the new view's route_id. |
3016 return render_manager_.CreateRenderView(instance, opener_route_id, true); | 3065 return render_manager_.CreateRenderView(instance, opener_route_id, true); |
3017 } | 3066 } |
3018 | 3067 |
3019 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { | 3068 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { |
3020 return GetControllerImpl(); | 3069 return GetController(); |
3021 } | 3070 } |
3022 | 3071 |
3023 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { | 3072 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { |
3024 return static_cast<WebUIImpl*>(CreateWebUI(url)); | 3073 return static_cast<WebUIImpl*>(CreateWebUI(url)); |
3025 } | 3074 } |
3026 | 3075 |
3027 NavigationEntry* | 3076 NavigationEntry* |
3028 WebContentsImpl::GetLastCommittedNavigationEntryForRenderManager() { | 3077 WebContentsImpl::GetLastCommittedNavigationEntryForRenderManager() { |
3029 return controller_.GetLastCommittedEntry(); | 3078 return controller_.GetLastCommittedEntry(); |
3030 } | 3079 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3135 old_browser_plugin_host()->embedder_render_process_host(); | 3184 old_browser_plugin_host()->embedder_render_process_host(); |
3136 *embedder_container_id = old_browser_plugin_host()->instance_id(); | 3185 *embedder_container_id = old_browser_plugin_host()->instance_id(); |
3137 int embedder_process_id = | 3186 int embedder_process_id = |
3138 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; | 3187 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; |
3139 if (embedder_process_id != -1) { | 3188 if (embedder_process_id != -1) { |
3140 *embedder_channel_name = | 3189 *embedder_channel_name = |
3141 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), | 3190 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), |
3142 embedder_process_id); | 3191 embedder_process_id); |
3143 } | 3192 } |
3144 } | 3193 } |
OLD | NEW |