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