| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 prefs.fixed_position_creates_stacking_context = !command_line.HasSwitch( | 616 prefs.fixed_position_creates_stacking_context = !command_line.HasSwitch( |
| 620 switches::kDisableFixedPositionCreatesStackingContext); | 617 switches::kDisableFixedPositionCreatesStackingContext); |
| 621 | 618 |
| 622 prefs.number_of_cpu_cores = base::SysInfo::NumberOfProcessors(); | 619 prefs.number_of_cpu_cores = base::SysInfo::NumberOfProcessors(); |
| 623 | 620 |
| 624 content::GetContentClient()->browser()->OverrideWebkitPrefs(rvh, url, &prefs); | 621 content::GetContentClient()->browser()->OverrideWebkitPrefs(rvh, url, &prefs); |
| 625 | 622 |
| 626 return prefs; | 623 return prefs; |
| 627 } | 624 } |
| 628 | 625 |
| 629 NavigationControllerImpl& WebContentsImpl::GetControllerImpl() { | |
| 630 return controller_; | |
| 631 } | |
| 632 | |
| 633 RenderViewHostManager* WebContentsImpl::GetRenderManagerForTesting() { | 626 RenderViewHostManager* WebContentsImpl::GetRenderManagerForTesting() { |
| 634 return &render_manager_; | 627 return &render_manager_; |
| 635 } | 628 } |
| 636 | 629 |
| 637 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, | 630 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, |
| 638 const IPC::Message& message) { | 631 const IPC::Message& message) { |
| 639 if (GetWebUI() && | 632 if (GetWebUI() && |
| 640 static_cast<WebUIImpl*>(GetWebUI())->OnMessageReceived(message)) { | 633 static_cast<WebUIImpl*>(GetWebUI())->OnMessageReceived(message)) { |
| 641 return true; | 634 return true; |
| 642 } | 635 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 return handled; | 691 return handled; |
| 699 } | 692 } |
| 700 | 693 |
| 701 void WebContentsImpl::RunFileChooser( | 694 void WebContentsImpl::RunFileChooser( |
| 702 RenderViewHost* render_view_host, | 695 RenderViewHost* render_view_host, |
| 703 const content::FileChooserParams& params) { | 696 const content::FileChooserParams& params) { |
| 704 if (delegate_) | 697 if (delegate_) |
| 705 delegate_->RunFileChooser(this, params); | 698 delegate_->RunFileChooser(this, params); |
| 706 } | 699 } |
| 707 | 700 |
| 708 NavigationController& WebContentsImpl::GetController() { | 701 NavigationControllerImpl& WebContentsImpl::GetController() { |
| 709 return controller_; | 702 return controller_; |
| 710 } | 703 } |
| 711 | 704 |
| 712 const NavigationController& WebContentsImpl::GetController() const { | 705 const NavigationControllerImpl& WebContentsImpl::GetController() const { |
| 713 return controller_; | 706 return controller_; |
| 714 } | 707 } |
| 715 | 708 |
| 716 content::BrowserContext* WebContentsImpl::GetBrowserContext() const { | 709 content::BrowserContext* WebContentsImpl::GetBrowserContext() const { |
| 717 return controller_.GetBrowserContext(); | 710 return controller_.GetBrowserContext(); |
| 718 } | 711 } |
| 719 | 712 |
| 720 const GURL& WebContentsImpl::GetURL() const { | 713 const GURL& WebContentsImpl::GetURL() const { |
| 721 // We may not have a navigation entry yet | 714 // We may not have a navigation entry yet |
| 722 NavigationEntry* entry = controller_.GetActiveEntry(); | 715 NavigationEntry* entry = controller_.GetActiveEntry(); |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 | 1009 |
| 1017 void WebContentsImpl::Stop() { | 1010 void WebContentsImpl::Stop() { |
| 1018 render_manager_.Stop(); | 1011 render_manager_.Stop(); |
| 1019 FOR_EACH_OBSERVER(WebContentsObserver, observers_, StopNavigation()); | 1012 FOR_EACH_OBSERVER(WebContentsObserver, observers_, StopNavigation()); |
| 1020 } | 1013 } |
| 1021 | 1014 |
| 1022 WebContents* WebContentsImpl::Clone() { | 1015 WebContents* WebContentsImpl::Clone() { |
| 1023 // We use our current SiteInstance since the cloned entry will use it anyway. | 1016 // We use our current SiteInstance since the cloned entry will use it anyway. |
| 1024 // We pass |this| for the |base_web_contents| to size the view correctly, and | 1017 // We pass |this| for the |base_web_contents| to size the view correctly, and |
| 1025 // our own opener so that the cloned page can access it if it was before. | 1018 // our own opener so that the cloned page can access it if it was before. |
| 1026 WebContentsImpl* tc = new WebContentsImpl( | 1019 WebContentsImpl* tc = CreateWithOpener(GetBrowserContext(), |
| 1027 GetBrowserContext(), GetSiteInstance(), | 1020 GetSiteInstance(), MSG_ROUTING_NONE, |
| 1028 MSG_ROUTING_NONE, this, opener_, NULL); | 1021 this, opener_); |
| 1029 tc->GetControllerImpl().CopyStateFrom(controller_); | 1022 tc->GetController().CopyStateFrom(controller_); |
| 1030 return tc; | 1023 return tc; |
| 1031 } | 1024 } |
| 1032 | 1025 |
| 1033 void WebContentsImpl::AddNewContents(WebContents* new_contents, | 1026 void WebContentsImpl::AddNewContents(WebContents* new_contents, |
| 1034 WindowOpenDisposition disposition, | 1027 WindowOpenDisposition disposition, |
| 1035 const gfx::Rect& initial_pos, | 1028 const gfx::Rect& initial_pos, |
| 1036 bool user_gesture) { | 1029 bool user_gesture) { |
| 1037 if (!delegate_) | 1030 if (!delegate_) |
| 1038 return; | 1031 return; |
| 1039 | 1032 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 break; | 1067 break; |
| 1075 } | 1068 } |
| 1076 } | 1069 } |
| 1077 break; | 1070 break; |
| 1078 } | 1071 } |
| 1079 default: | 1072 default: |
| 1080 NOTREACHED(); | 1073 NOTREACHED(); |
| 1081 } | 1074 } |
| 1082 } | 1075 } |
| 1083 | 1076 |
| 1077 void WebContentsImpl::Init(BrowserContext* browser_context, |
| 1078 SiteInstance* site_instance, |
| 1079 int routing_id, |
| 1080 const WebContents* base_web_contents) { |
| 1081 render_manager_.Init(browser_context, site_instance, routing_id); |
| 1082 |
| 1083 view_.reset(content::GetContentClient()->browser()-> |
| 1084 OverrideCreateWebContentsView(this, &render_view_host_delegate_view_)); |
| 1085 if (view_.get()) { |
| 1086 CHECK(render_view_host_delegate_view_); |
| 1087 } else { |
| 1088 content::WebContentsViewDelegate* delegate = |
| 1089 content::GetContentClient()->browser()->GetWebContentsViewDelegate( |
| 1090 this); |
| 1091 view_.reset(CreateWebContentsView( |
| 1092 this, delegate, &render_view_host_delegate_view_)); |
| 1093 CHECK(render_view_host_delegate_view_); |
| 1094 } |
| 1095 CHECK(view_.get()); |
| 1096 |
| 1097 // We have the initial size of the view be based on the size of the view of |
| 1098 // the passed in WebContents. |
| 1099 view_->CreateView(base_web_contents ? |
| 1100 base_web_contents->GetView()->GetContainerSize() : gfx::Size()); |
| 1101 |
| 1102 // Listen for whether our opener gets destroyed. |
| 1103 if (opener_) { |
| 1104 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 1105 content::Source<WebContents>(opener_)); |
| 1106 } |
| 1107 |
| 1108 registrar_.Add(this, |
| 1109 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
| 1110 content::NotificationService::AllBrowserContextsAndSources()); |
| 1111 #if defined(ENABLE_JAVA_BRIDGE) |
| 1112 java_bridge_dispatcher_host_manager_.reset( |
| 1113 new JavaBridgeDispatcherHostManager(this)); |
| 1114 #endif |
| 1115 |
| 1116 old_browser_plugin_host_.reset(new content::old::BrowserPluginHost(this)); |
| 1117 } |
| 1118 |
| 1084 void WebContentsImpl::OnWebContentsDestroyed(WebContents* web_contents) { | 1119 void WebContentsImpl::OnWebContentsDestroyed(WebContents* web_contents) { |
| 1085 // Clear the opener if it has been closed. | 1120 // Clear the opener if it has been closed. |
| 1086 if (web_contents == opener_) { | 1121 if (web_contents == opener_) { |
| 1087 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 1122 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 1088 content::Source<WebContents>(opener_)); | 1123 content::Source<WebContents>(opener_)); |
| 1089 opener_ = NULL; | 1124 opener_ = NULL; |
| 1090 } | 1125 } |
| 1091 } | 1126 } |
| 1092 | 1127 |
| 1093 void WebContentsImpl::AddObserver(WebContentsObserver* observer) { | 1128 void WebContentsImpl::AddObserver(WebContentsObserver* observer) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 // script-related windows), by passing in the current SiteInstance. However, | 1223 // script-related windows), by passing in the current SiteInstance. However, |
| 1189 // if the opener is being suppressed, we create a new SiteInstance in its own | 1224 // if the opener is being suppressed, we create a new SiteInstance in its own |
| 1190 // BrowsingInstance. | 1225 // BrowsingInstance. |
| 1191 scoped_refptr<SiteInstance> site_instance = | 1226 scoped_refptr<SiteInstance> site_instance = |
| 1192 params.opener_suppressed ? | 1227 params.opener_suppressed ? |
| 1193 SiteInstance::Create(GetBrowserContext()) : | 1228 SiteInstance::Create(GetBrowserContext()) : |
| 1194 GetSiteInstance(); | 1229 GetSiteInstance(); |
| 1195 | 1230 |
| 1196 // Create the new web contents. This will automatically create the new | 1231 // Create the new web contents. This will automatically create the new |
| 1197 // WebContentsView. In the future, we may want to create the view separately. | 1232 // WebContentsView. In the future, we may want to create the view separately. |
| 1198 WebContentsImpl* new_contents = new WebContentsImpl( | 1233 WebContentsImpl* new_contents = |
| 1199 GetBrowserContext(), | 1234 new WebContentsImpl(GetBrowserContext(), |
| 1200 site_instance, | 1235 params.opener_suppressed ? NULL : this); |
| 1201 route_id, | 1236 |
| 1202 this, | 1237 // We must assign the SessionStorageNamespace before calling Init(). |
| 1203 params.opener_suppressed ? NULL : this, | 1238 const std::string& partition_id = |
| 1204 static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace)); | 1239 content::GetContentClient()->browser()-> |
| 1240 GetStoragePartitionIdForSiteInstance(GetBrowserContext(), |
| 1241 site_instance); |
| 1242 DOMStorageContextImpl* dom_storage_context = |
| 1243 static_cast<DOMStorageContextImpl*>( |
| 1244 BrowserContext::GetDOMStorageContextByPartitionId( |
| 1245 GetBrowserContext(), partition_id)); |
| 1246 SessionStorageNamespaceImpl* session_storage_namespace_impl = |
| 1247 static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace); |
| 1248 CHECK(session_storage_namespace_impl->IsFromContext(dom_storage_context)); |
| 1249 new_contents->GetController().SetSessionStorageNamespace( |
| 1250 partition_id, |
| 1251 session_storage_namespace); |
| 1252 new_contents->Init(GetBrowserContext(), site_instance, route_id, this); |
| 1253 |
| 1205 new_contents->set_opener_web_ui_type(GetWebUITypeForCurrentState()); | 1254 new_contents->set_opener_web_ui_type(GetWebUITypeForCurrentState()); |
| 1206 | 1255 |
| 1207 if (!params.opener_suppressed) { | 1256 if (!params.opener_suppressed) { |
| 1208 content::WebContentsView* new_view = new_contents->GetView(); | 1257 content::WebContentsView* new_view = new_contents->GetView(); |
| 1209 | 1258 |
| 1210 // TODO(brettw): It seems bogus that we have to call this function on the | 1259 // TODO(brettw): It seems bogus that we have to call this function on the |
| 1211 // newly created object and give it one of its own member variables. | 1260 // newly created object and give it one of its own member variables. |
| 1212 new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); | 1261 new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); |
| 1213 | 1262 |
| 1214 // Save the created window associated with the route so we can show it | 1263 // 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... |
| 1988 | 2037 |
| 1989 content::NotificationService::current()->Notify( | 2038 content::NotificationService::current()->Notify( |
| 1990 content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE, | 2039 content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE, |
| 1991 content::Source<NavigationController>(&controller_), | 2040 content::Source<NavigationController>(&controller_), |
| 1992 content::Details<content::LoadFromMemoryCacheDetails>(&details)); | 2041 content::Details<content::LoadFromMemoryCacheDetails>(&details)); |
| 1993 } | 2042 } |
| 1994 | 2043 |
| 1995 void WebContentsImpl::OnDidDisplayInsecureContent() { | 2044 void WebContentsImpl::OnDidDisplayInsecureContent() { |
| 1996 content::RecordAction(UserMetricsAction("SSL.DisplayedInsecureContent")); | 2045 content::RecordAction(UserMetricsAction("SSL.DisplayedInsecureContent")); |
| 1997 displayed_insecure_content_ = true; | 2046 displayed_insecure_content_ = true; |
| 1998 SSLManager::NotifySSLInternalStateChanged(&GetControllerImpl()); | 2047 SSLManager::NotifySSLInternalStateChanged(&GetController()); |
| 1999 } | 2048 } |
| 2000 | 2049 |
| 2001 void WebContentsImpl::OnDidRunInsecureContent( | 2050 void WebContentsImpl::OnDidRunInsecureContent( |
| 2002 const std::string& security_origin, const GURL& target_url) { | 2051 const std::string& security_origin, const GURL& target_url) { |
| 2003 LOG(INFO) << security_origin << " ran insecure content from " | 2052 LOG(INFO) << security_origin << " ran insecure content from " |
| 2004 << target_url.possibly_invalid_spec(); | 2053 << target_url.possibly_invalid_spec(); |
| 2005 content::RecordAction(UserMetricsAction("SSL.RanInsecureContent")); | 2054 content::RecordAction(UserMetricsAction("SSL.RanInsecureContent")); |
| 2006 if (EndsWith(security_origin, kDotGoogleDotCom, false)) | 2055 if (EndsWith(security_origin, kDotGoogleDotCom, false)) |
| 2007 content::RecordAction(UserMetricsAction("SSL.RanInsecureContentGoogle")); | 2056 content::RecordAction(UserMetricsAction("SSL.RanInsecureContentGoogle")); |
| 2008 controller_.ssl_manager()->DidRunInsecureContent(security_origin); | 2057 controller_.ssl_manager()->DidRunInsecureContent(security_origin); |
| 2009 displayed_insecure_content_ = true; | 2058 displayed_insecure_content_ = true; |
| 2010 SSLManager::NotifySSLInternalStateChanged(&GetControllerImpl()); | 2059 SSLManager::NotifySSLInternalStateChanged(&GetController()); |
| 2011 } | 2060 } |
| 2012 | 2061 |
| 2013 void WebContentsImpl::OnDocumentLoadedInFrame(int64 frame_id) { | 2062 void WebContentsImpl::OnDocumentLoadedInFrame(int64 frame_id) { |
| 2014 controller_.DocumentLoadedInFrame(); | 2063 controller_.DocumentLoadedInFrame(); |
| 2015 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2064 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2016 DocumentLoadedInFrame(frame_id, message_source_)); | 2065 DocumentLoadedInFrame(frame_id, message_source_)); |
| 2017 } | 2066 } |
| 2018 | 2067 |
| 2019 void WebContentsImpl::OnDidFinishLoad( | 2068 void WebContentsImpl::OnDidFinishLoad( |
| 2020 int64 frame_id, | 2069 int64 frame_id, |
| (...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3025 // SiteInstance as well. | 3074 // SiteInstance as well. |
| 3026 if (opener_) | 3075 if (opener_) |
| 3027 opener_route_id = opener_->CreateOpenerRenderViews(instance); | 3076 opener_route_id = opener_->CreateOpenerRenderViews(instance); |
| 3028 | 3077 |
| 3029 // Create a swapped out RenderView in the given SiteInstance if none exists, | 3078 // Create a swapped out RenderView in the given SiteInstance if none exists, |
| 3030 // setting its opener to the given route_id. Return the new view's route_id. | 3079 // setting its opener to the given route_id. Return the new view's route_id. |
| 3031 return render_manager_.CreateRenderView(instance, opener_route_id, true); | 3080 return render_manager_.CreateRenderView(instance, opener_route_id, true); |
| 3032 } | 3081 } |
| 3033 | 3082 |
| 3034 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { | 3083 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { |
| 3035 return GetControllerImpl(); | 3084 return GetController(); |
| 3036 } | 3085 } |
| 3037 | 3086 |
| 3038 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { | 3087 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { |
| 3039 return static_cast<WebUIImpl*>(CreateWebUI(url)); | 3088 return static_cast<WebUIImpl*>(CreateWebUI(url)); |
| 3040 } | 3089 } |
| 3041 | 3090 |
| 3042 NavigationEntry* | 3091 NavigationEntry* |
| 3043 WebContentsImpl::GetLastCommittedNavigationEntryForRenderManager() { | 3092 WebContentsImpl::GetLastCommittedNavigationEntryForRenderManager() { |
| 3044 return controller_.GetLastCommittedEntry(); | 3093 return controller_.GetLastCommittedEntry(); |
| 3045 } | 3094 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3150 old_browser_plugin_host()->embedder_render_process_host(); | 3199 old_browser_plugin_host()->embedder_render_process_host(); |
| 3151 *embedder_container_id = old_browser_plugin_host()->instance_id(); | 3200 *embedder_container_id = old_browser_plugin_host()->instance_id(); |
| 3152 int embedder_process_id = | 3201 int embedder_process_id = |
| 3153 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; | 3202 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; |
| 3154 if (embedder_process_id != -1) { | 3203 if (embedder_process_id != -1) { |
| 3155 *embedder_channel_name = | 3204 *embedder_channel_name = |
| 3156 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), | 3205 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), |
| 3157 embedder_process_id); | 3206 embedder_process_id); |
| 3158 } | 3207 } |
| 3159 } | 3208 } |
| OLD | NEW |