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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1479 create_params.initial_size = view_->GetContainerSize(); | 1479 create_params.initial_size = view_->GetContainerSize(); |
1480 } else { | 1480 } else { |
1481 // This makes |new_contents| act as a guest. | 1481 // This makes |new_contents| act as a guest. |
1482 // For more info, see comment above class BrowserPluginGuest. | 1482 // For more info, see comment above class BrowserPluginGuest. |
1483 int instance_id = GetBrowserPluginGuestManager()->get_next_instance_id(); | 1483 int instance_id = GetBrowserPluginGuestManager()->get_next_instance_id(); |
1484 WebContentsImpl* new_contents_impl = | 1484 WebContentsImpl* new_contents_impl = |
1485 static_cast<WebContentsImpl*>(new_contents); | 1485 static_cast<WebContentsImpl*>(new_contents); |
1486 BrowserPluginGuest::CreateWithOpener(instance_id, new_contents_impl, | 1486 BrowserPluginGuest::CreateWithOpener(instance_id, new_contents_impl, |
1487 GetBrowserPluginGuest(), !!new_contents_impl->opener()); | 1487 GetBrowserPluginGuest(), !!new_contents_impl->opener()); |
1488 } | 1488 } |
1489 if (params.disposition == NEW_BACKGROUND_TAB) | |
1490 create_params.initially_hidden = true; | |
1489 new_contents->Init(create_params); | 1491 new_contents->Init(create_params); |
1490 | 1492 |
1491 // Save the window for later if we're not suppressing the opener (since it | 1493 // Save the window for later if we're not suppressing the opener (since it |
1492 // will be shown immediately). | 1494 // will be shown immediately). |
1493 if (!params.opener_suppressed) { | 1495 if (!params.opener_suppressed) { |
1494 if (!is_guest) { | 1496 if (!is_guest) { |
1495 WebContentsViewPort* new_view = new_contents->view_.get(); | 1497 WebContentsViewPort* new_view = new_contents->view_.get(); |
1496 | 1498 |
1497 // TODO(brettw): It seems bogus that we have to call this function on the | 1499 // TODO(brettw): It seems bogus that we have to call this function on the |
1498 // newly created object and give it one of its own member variables. | 1500 // newly created object and give it one of its own member variables. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1539 } | 1541 } |
1540 | 1542 |
1541 void WebContentsImpl::CreateNewFullscreenWidget(int route_id) { | 1543 void WebContentsImpl::CreateNewFullscreenWidget(int route_id) { |
1542 CreateNewWidget(route_id, true, WebKit::WebPopupTypeNone); | 1544 CreateNewWidget(route_id, true, WebKit::WebPopupTypeNone); |
1543 } | 1545 } |
1544 | 1546 |
1545 void WebContentsImpl::CreateNewWidget(int route_id, | 1547 void WebContentsImpl::CreateNewWidget(int route_id, |
1546 bool is_fullscreen, | 1548 bool is_fullscreen, |
1547 WebKit::WebPopupType popup_type) { | 1549 WebKit::WebPopupType popup_type) { |
1548 RenderProcessHost* process = GetRenderProcessHost(); | 1550 RenderProcessHost* process = GetRenderProcessHost(); |
1551 bool hidden = capturer_count_ == 0 && !should_normally_be_visible_; | |
Charlie Reis
2013/08/20 02:09:58
We should probably call IsHidden instead, in case
| |
1549 RenderWidgetHostImpl* widget_host = | 1552 RenderWidgetHostImpl* widget_host = |
1550 new RenderWidgetHostImpl(this, process, route_id); | 1553 new RenderWidgetHostImpl(this, process, route_id, hidden); |
1551 created_widgets_.insert(widget_host); | 1554 created_widgets_.insert(widget_host); |
1552 | 1555 |
1553 RenderWidgetHostViewPort* widget_view = RenderWidgetHostViewPort::FromRWHV( | 1556 RenderWidgetHostViewPort* widget_view = RenderWidgetHostViewPort::FromRWHV( |
1554 view_->CreateViewForPopupWidget(widget_host)); | 1557 view_->CreateViewForPopupWidget(widget_host)); |
1555 if (!widget_view) | 1558 if (!widget_view) |
1556 return; | 1559 return; |
1557 if (!is_fullscreen) { | 1560 if (!is_fullscreen) { |
1558 // Popups should not get activated. | 1561 // Popups should not get activated. |
1559 widget_view->SetPopupType(popup_type); | 1562 widget_view->SetPopupType(popup_type); |
1560 } | 1563 } |
(...skipping 1864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3425 WebPreferences WebContentsImpl::GetWebkitPrefs() { | 3428 WebPreferences WebContentsImpl::GetWebkitPrefs() { |
3426 // We want to base the page config off of the real URL, rather than the | 3429 // We want to base the page config off of the real URL, rather than the |
3427 // display URL. | 3430 // display URL. |
3428 GURL url = controller_.GetActiveEntry() | 3431 GURL url = controller_.GetActiveEntry() |
3429 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); | 3432 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); |
3430 return GetWebkitPrefs(GetRenderViewHost(), url); | 3433 return GetWebkitPrefs(GetRenderViewHost(), url); |
3431 } | 3434 } |
3432 | 3435 |
3433 int WebContentsImpl::CreateSwappedOutRenderView( | 3436 int WebContentsImpl::CreateSwappedOutRenderView( |
3434 SiteInstance* instance) { | 3437 SiteInstance* instance) { |
3435 return render_manager_.CreateRenderView(instance, MSG_ROUTING_NONE, true); | 3438 return render_manager_.CreateRenderView(instance, MSG_ROUTING_NONE, |
3439 true, true); | |
3436 } | 3440 } |
3437 | 3441 |
3438 void WebContentsImpl::OnUserGesture() { | 3442 void WebContentsImpl::OnUserGesture() { |
3439 // Notify observers. | 3443 // Notify observers. |
3440 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); | 3444 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); |
3441 | 3445 |
3442 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); | 3446 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
3443 if (rdh) // NULL in unittests. | 3447 if (rdh) // NULL in unittests. |
3444 rdh->OnUserGesture(this); | 3448 rdh->OnUserGesture(this); |
3445 } | 3449 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3595 render_manager_.pending_render_view_host()->GetSiteInstance() == instance) | 3599 render_manager_.pending_render_view_host()->GetSiteInstance() == instance) |
3596 return render_manager_.pending_render_view_host()->GetRoutingID(); | 3600 return render_manager_.pending_render_view_host()->GetRoutingID(); |
3597 | 3601 |
3598 RenderViewHostImpl* rvh = render_manager_.GetSwappedOutRenderViewHost( | 3602 RenderViewHostImpl* rvh = render_manager_.GetSwappedOutRenderViewHost( |
3599 instance); | 3603 instance); |
3600 if (rvh) | 3604 if (rvh) |
3601 return rvh->GetRoutingID(); | 3605 return rvh->GetRoutingID(); |
3602 | 3606 |
3603 // Create a swapped out RenderView in the given SiteInstance if none exists, | 3607 // Create a swapped out RenderView in the given SiteInstance if none exists, |
3604 // setting its opener to the given route_id. Return the new view's route_id. | 3608 // setting its opener to the given route_id. Return the new view's route_id. |
3605 return render_manager_.CreateRenderView(instance, opener_route_id, true); | 3609 return render_manager_.CreateRenderView(instance, opener_route_id, |
3610 true, true); | |
3606 } | 3611 } |
3607 | 3612 |
3608 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { | 3613 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { |
3609 return GetController(); | 3614 return GetController(); |
3610 } | 3615 } |
3611 | 3616 |
3612 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { | 3617 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { |
3613 return static_cast<WebUIImpl*>(CreateWebUI(url)); | 3618 return static_cast<WebUIImpl*>(CreateWebUI(url)); |
3614 } | 3619 } |
3615 | 3620 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3675 GetCanonicalEncodingNameByAliasName(encoding); | 3680 GetCanonicalEncodingNameByAliasName(encoding); |
3676 } | 3681 } |
3677 | 3682 |
3678 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 3683 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
3679 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(rvh); | 3684 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(rvh); |
3680 // Can be NULL during tests. | 3685 // Can be NULL during tests. |
3681 if (rwh_view) | 3686 if (rwh_view) |
3682 rwh_view->SetSize(GetView()->GetContainerSize()); | 3687 rwh_view->SetSize(GetView()->GetContainerSize()); |
3683 } | 3688 } |
3684 | 3689 |
3690 bool WebContentsImpl::IsHidden() { | |
3691 return capturer_count_ == 0 && !should_normally_be_visible_; | |
3692 } | |
3693 | |
3685 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { | 3694 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { |
3686 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); | 3695 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); |
3687 } | 3696 } |
3688 | 3697 |
3689 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const { | 3698 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const { |
3690 return browser_plugin_guest_.get(); | 3699 return browser_plugin_guest_.get(); |
3691 } | 3700 } |
3692 | 3701 |
3693 void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) { | 3702 void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) { |
3694 CHECK(!browser_plugin_guest_); | 3703 CHECK(!browser_plugin_guest_); |
(...skipping 18 matching lines...) Expand all Loading... | |
3713 } | 3722 } |
3714 | 3723 |
3715 void WebContentsImpl::ClearAllPowerSaveBlockers() { | 3724 void WebContentsImpl::ClearAllPowerSaveBlockers() { |
3716 for (PowerSaveBlockerMap::iterator i(power_save_blockers_.begin()); | 3725 for (PowerSaveBlockerMap::iterator i(power_save_blockers_.begin()); |
3717 i != power_save_blockers_.end(); ++i) | 3726 i != power_save_blockers_.end(); ++i) |
3718 STLDeleteValues(&power_save_blockers_[i->first]); | 3727 STLDeleteValues(&power_save_blockers_[i->first]); |
3719 power_save_blockers_.clear(); | 3728 power_save_blockers_.clear(); |
3720 } | 3729 } |
3721 | 3730 |
3722 } // namespace content | 3731 } // namespace content |
OLD | NEW |