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/time.h" | 15 #include "base/time.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "content/browser/browser_plugin/browser_plugin_web_contents_observer.h" | |
18 #include "content/browser/child_process_security_policy_impl.h" | 17 #include "content/browser/child_process_security_policy_impl.h" |
19 #include "content/browser/debugger/devtools_manager_impl.h" | 18 #include "content/browser/debugger/devtools_manager_impl.h" |
20 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 19 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
21 #include "content/browser/download/download_stats.h" | 20 #include "content/browser/download/download_stats.h" |
22 #include "content/browser/download/mhtml_generation_manager.h" | 21 #include "content/browser/download/mhtml_generation_manager.h" |
23 #include "content/browser/download/save_package.h" | 22 #include "content/browser/download/save_package.h" |
24 #include "content/browser/gpu/gpu_data_manager_impl.h" | 23 #include "content/browser/gpu/gpu_data_manager_impl.h" |
25 #include "content/browser/gpu/gpu_process_host.h" | 24 #include "content/browser/gpu/gpu_process_host.h" |
26 #include "content/browser/host_zoom_map_impl.h" | 25 #include "content/browser/host_zoom_map_impl.h" |
27 #include "content/browser/intents/web_intents_dispatcher_impl.h" | 26 #include "content/browser/intents/web_intents_dispatcher_impl.h" |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 // Listen for whether our opener gets destroyed. | 318 // Listen for whether our opener gets destroyed. |
320 if (opener_) { | 319 if (opener_) { |
321 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 320 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
322 content::Source<WebContents>(opener_)); | 321 content::Source<WebContents>(opener_)); |
323 } | 322 } |
324 | 323 |
325 #if defined(ENABLE_JAVA_BRIDGE) | 324 #if defined(ENABLE_JAVA_BRIDGE) |
326 java_bridge_dispatcher_host_manager_.reset( | 325 java_bridge_dispatcher_host_manager_.reset( |
327 new JavaBridgeDispatcherHostManager(this)); | 326 new JavaBridgeDispatcherHostManager(this)); |
328 #endif | 327 #endif |
329 | |
330 browser_plugin_web_contents_observer_.reset( | |
331 new content::BrowserPluginWebContentsObserver(this)); | |
332 } | 328 } |
333 | 329 |
334 WebContentsImpl::~WebContentsImpl() { | 330 WebContentsImpl::~WebContentsImpl() { |
335 is_being_destroyed_ = true; | 331 is_being_destroyed_ = true; |
336 | 332 |
337 // Clear out any JavaScript state. | 333 // Clear out any JavaScript state. |
338 if (dialog_creator_) | 334 if (dialog_creator_) |
339 dialog_creator_->ResetJavaScriptState(this); | 335 dialog_creator_->ResetJavaScriptState(this); |
340 | 336 |
341 if (color_chooser_) | 337 if (color_chooser_) |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 delegate_ = delegate; | 658 delegate_ = delegate; |
663 if (delegate_) | 659 if (delegate_) |
664 delegate_->Attach(this); | 660 delegate_->Attach(this); |
665 } | 661 } |
666 | 662 |
667 content::RenderProcessHost* WebContentsImpl::GetRenderProcessHost() const { | 663 content::RenderProcessHost* WebContentsImpl::GetRenderProcessHost() const { |
668 RenderViewHostImpl* host = render_manager_.current_host(); | 664 RenderViewHostImpl* host = render_manager_.current_host(); |
669 return host ? host->GetProcess() : NULL; | 665 return host ? host->GetProcess() : NULL; |
670 } | 666 } |
671 | 667 |
| 668 content::RenderProcessHost* |
| 669 WebContentsImpl::GetPendingRenderProcessHost() const { |
| 670 RenderViewHostImpl* host = render_manager_.pending_render_view_host(); |
| 671 return host ? host->GetProcess() : NULL; |
| 672 } |
| 673 |
672 RenderViewHost* WebContentsImpl::GetRenderViewHost() const { | 674 RenderViewHost* WebContentsImpl::GetRenderViewHost() const { |
673 return render_manager_.current_host(); | 675 return render_manager_.current_host(); |
674 } | 676 } |
675 | 677 |
| 678 RenderViewHost* WebContentsImpl::GetPendingRenderViewHost() const { |
| 679 return render_manager_.pending_render_view_host(); |
| 680 } |
| 681 |
676 RenderWidgetHostView* WebContentsImpl::GetRenderWidgetHostView() const { | 682 RenderWidgetHostView* WebContentsImpl::GetRenderWidgetHostView() const { |
677 return render_manager_.GetRenderWidgetHostView(); | 683 return render_manager_.GetRenderWidgetHostView(); |
678 } | 684 } |
679 | 685 |
680 content::WebContentsView* WebContentsImpl::GetView() const { | 686 content::WebContentsView* WebContentsImpl::GetView() const { |
681 return view_.get(); | 687 return view_.get(); |
682 } | 688 } |
683 | 689 |
684 content::WebUI* WebContentsImpl::CreateWebUI(const GURL& url) { | 690 content::WebUI* WebContentsImpl::CreateWebUI(const GURL& url) { |
685 WebUIControllerFactory* factory = | 691 WebUIControllerFactory* factory = |
(...skipping 1971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2657 // Now that the RenderView has been created, we need to tell it its size. | 2663 // Now that the RenderView has been created, we need to tell it its size. |
2658 if (rwh_view) | 2664 if (rwh_view) |
2659 rwh_view->SetSize(view_->GetContainerSize()); | 2665 rwh_view->SetSize(view_->GetContainerSize()); |
2660 | 2666 |
2661 // Make sure we use the correct starting page_id in the new RenderView. | 2667 // Make sure we use the correct starting page_id in the new RenderView. |
2662 UpdateMaxPageIDIfNecessary(render_view_host); | 2668 UpdateMaxPageIDIfNecessary(render_view_host); |
2663 int32 max_page_id = | 2669 int32 max_page_id = |
2664 GetMaxPageIDForSiteInstance(render_view_host->GetSiteInstance()); | 2670 GetMaxPageIDForSiteInstance(render_view_host->GetSiteInstance()); |
2665 | 2671 |
2666 if (!static_cast<RenderViewHostImpl*>( | 2672 if (!static_cast<RenderViewHostImpl*>( |
2667 render_view_host)->CreateRenderView(string16(), opener_route_id, | 2673 render_view_host)->CreateRenderView(string16(), |
2668 max_page_id)) { | 2674 opener_route_id, |
| 2675 max_page_id, |
| 2676 0, 0)) { |
2669 return false; | 2677 return false; |
2670 } | 2678 } |
2671 | 2679 |
2672 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 2680 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
2673 // Force a ViewMsg_Resize to be sent, needed to make plugins show up on | 2681 // Force a ViewMsg_Resize to be sent, needed to make plugins show up on |
2674 // linux. See crbug.com/83941. | 2682 // linux. See crbug.com/83941. |
2675 if (rwh_view) { | 2683 if (rwh_view) { |
2676 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost()) | 2684 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost()) |
2677 render_widget_host->WasResized(); | 2685 render_widget_host->WasResized(); |
2678 } | 2686 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2729 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2737 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2730 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); | 2738 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); |
2731 // Can be NULL during tests. | 2739 // Can be NULL during tests. |
2732 if (rwh_view) | 2740 if (rwh_view) |
2733 rwh_view->SetSize(GetView()->GetContainerSize()); | 2741 rwh_view->SetSize(GetView()->GetContainerSize()); |
2734 } | 2742 } |
2735 | 2743 |
2736 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { | 2744 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { |
2737 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); | 2745 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); |
2738 } | 2746 } |
OLD | NEW |