Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 23129015: Initialize RenderWidget(Host)(View)s with correct visibility state (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 1042
1043 void WebContentsImpl::DecrementCapturerCount() { 1043 void WebContentsImpl::DecrementCapturerCount() {
1044 --capturer_count_; 1044 --capturer_count_;
1045 DVLOG(1) << "There are now " << capturer_count_ 1045 DVLOG(1) << "There are now " << capturer_count_
1046 << " capturing(s) of WebContentsImpl@" << this; 1046 << " capturing(s) of WebContentsImpl@" << this;
1047 DCHECK_LE(0, capturer_count_); 1047 DCHECK_LE(0, capturer_count_);
1048 1048
1049 if (is_being_destroyed_) 1049 if (is_being_destroyed_)
1050 return; 1050 return;
1051 1051
1052 // While capturer_count_ was greater than zero, the WasHidden() calls to RWHV 1052 if (IsHidden()) {
1053 // were being prevented. If there are no more capturers, make the call now.
1054 if (capturer_count_ == 0 && !should_normally_be_visible_) {
1055 DVLOG(1) << "Executing delayed WasHidden()."; 1053 DVLOG(1) << "Executing delayed WasHidden().";
1056 WasHidden(); 1054 WasHidden();
1057 } 1055 }
1058 } 1056 }
1059 1057
1060 int WebContentsImpl::GetCapturerCount() const { 1058 int WebContentsImpl::GetCapturerCount() const {
1061 return capturer_count_; 1059 return capturer_count_;
1062 } 1060 }
1063 1061
1064 bool WebContentsImpl::IsCrashed() const { 1062 bool WebContentsImpl::IsCrashed() const {
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1479 create_params.initial_size = view_->GetContainerSize(); 1477 create_params.initial_size = view_->GetContainerSize();
1480 } else { 1478 } else {
1481 // This makes |new_contents| act as a guest. 1479 // This makes |new_contents| act as a guest.
1482 // For more info, see comment above class BrowserPluginGuest. 1480 // For more info, see comment above class BrowserPluginGuest.
1483 int instance_id = GetBrowserPluginGuestManager()->get_next_instance_id(); 1481 int instance_id = GetBrowserPluginGuestManager()->get_next_instance_id();
1484 WebContentsImpl* new_contents_impl = 1482 WebContentsImpl* new_contents_impl =
1485 static_cast<WebContentsImpl*>(new_contents); 1483 static_cast<WebContentsImpl*>(new_contents);
1486 BrowserPluginGuest::CreateWithOpener(instance_id, new_contents_impl, 1484 BrowserPluginGuest::CreateWithOpener(instance_id, new_contents_impl,
1487 GetBrowserPluginGuest(), !!new_contents_impl->opener()); 1485 GetBrowserPluginGuest(), !!new_contents_impl->opener());
1488 } 1486 }
1487 if (params.disposition == NEW_BACKGROUND_TAB)
1488 create_params.initially_hidden = true;
1489 new_contents->Init(create_params); 1489 new_contents->Init(create_params);
1490 1490
1491 // Save the window for later if we're not suppressing the opener (since it 1491 // Save the window for later if we're not suppressing the opener (since it
1492 // will be shown immediately). 1492 // will be shown immediately).
1493 if (!params.opener_suppressed) { 1493 if (!params.opener_suppressed) {
1494 if (!is_guest) { 1494 if (!is_guest) {
1495 WebContentsViewPort* new_view = new_contents->view_.get(); 1495 WebContentsViewPort* new_view = new_contents->view_.get();
1496 1496
1497 // TODO(brettw): It seems bogus that we have to call this function on the 1497 // 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. 1498 // newly created object and give it one of its own member variables.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 1540
1541 void WebContentsImpl::CreateNewFullscreenWidget(int route_id) { 1541 void WebContentsImpl::CreateNewFullscreenWidget(int route_id) {
1542 CreateNewWidget(route_id, true, WebKit::WebPopupTypeNone); 1542 CreateNewWidget(route_id, true, WebKit::WebPopupTypeNone);
1543 } 1543 }
1544 1544
1545 void WebContentsImpl::CreateNewWidget(int route_id, 1545 void WebContentsImpl::CreateNewWidget(int route_id,
1546 bool is_fullscreen, 1546 bool is_fullscreen,
1547 WebKit::WebPopupType popup_type) { 1547 WebKit::WebPopupType popup_type) {
1548 RenderProcessHost* process = GetRenderProcessHost(); 1548 RenderProcessHost* process = GetRenderProcessHost();
1549 RenderWidgetHostImpl* widget_host = 1549 RenderWidgetHostImpl* widget_host =
1550 new RenderWidgetHostImpl(this, process, route_id); 1550 new RenderWidgetHostImpl(this, process, route_id, IsHidden());
1551 created_widgets_.insert(widget_host); 1551 created_widgets_.insert(widget_host);
1552 1552
1553 RenderWidgetHostViewPort* widget_view = RenderWidgetHostViewPort::FromRWHV( 1553 RenderWidgetHostViewPort* widget_view = RenderWidgetHostViewPort::FromRWHV(
1554 view_->CreateViewForPopupWidget(widget_host)); 1554 view_->CreateViewForPopupWidget(widget_host));
1555 if (!widget_view) 1555 if (!widget_view)
1556 return; 1556 return;
1557 if (!is_fullscreen) { 1557 if (!is_fullscreen) {
1558 // Popups should not get activated. 1558 // Popups should not get activated.
1559 widget_view->SetPopupType(popup_type); 1559 widget_view->SetPopupType(popup_type);
1560 } 1560 }
(...skipping 1864 matching lines...) Expand 10 before | Expand all | Expand 10 after
3425 WebPreferences WebContentsImpl::GetWebkitPrefs() { 3425 WebPreferences WebContentsImpl::GetWebkitPrefs() {
3426 // We want to base the page config off of the real URL, rather than the 3426 // We want to base the page config off of the real URL, rather than the
3427 // display URL. 3427 // display URL.
3428 GURL url = controller_.GetActiveEntry() 3428 GURL url = controller_.GetActiveEntry()
3429 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); 3429 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL();
3430 return GetWebkitPrefs(GetRenderViewHost(), url); 3430 return GetWebkitPrefs(GetRenderViewHost(), url);
3431 } 3431 }
3432 3432
3433 int WebContentsImpl::CreateSwappedOutRenderView( 3433 int WebContentsImpl::CreateSwappedOutRenderView(
3434 SiteInstance* instance) { 3434 SiteInstance* instance) {
3435 return render_manager_.CreateRenderView(instance, MSG_ROUTING_NONE, true); 3435 return render_manager_.CreateRenderView(instance, MSG_ROUTING_NONE,
3436 true, true);
3436 } 3437 }
3437 3438
3438 void WebContentsImpl::OnUserGesture() { 3439 void WebContentsImpl::OnUserGesture() {
3439 // Notify observers. 3440 // Notify observers.
3440 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); 3441 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture());
3441 3442
3442 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); 3443 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get();
3443 if (rdh) // NULL in unittests. 3444 if (rdh) // NULL in unittests.
3444 rdh->OnUserGesture(this); 3445 rdh->OnUserGesture(this);
3445 } 3446 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
3595 render_manager_.pending_render_view_host()->GetSiteInstance() == instance) 3596 render_manager_.pending_render_view_host()->GetSiteInstance() == instance)
3596 return render_manager_.pending_render_view_host()->GetRoutingID(); 3597 return render_manager_.pending_render_view_host()->GetRoutingID();
3597 3598
3598 RenderViewHostImpl* rvh = render_manager_.GetSwappedOutRenderViewHost( 3599 RenderViewHostImpl* rvh = render_manager_.GetSwappedOutRenderViewHost(
3599 instance); 3600 instance);
3600 if (rvh) 3601 if (rvh)
3601 return rvh->GetRoutingID(); 3602 return rvh->GetRoutingID();
3602 3603
3603 // Create a swapped out RenderView in the given SiteInstance if none exists, 3604 // 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. 3605 // 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); 3606 return render_manager_.CreateRenderView(instance, opener_route_id,
3607 true, true);
3606 } 3608 }
3607 3609
3608 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { 3610 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() {
3609 return GetController(); 3611 return GetController();
3610 } 3612 }
3611 3613
3612 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { 3614 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) {
3613 return static_cast<WebUIImpl*>(CreateWebUI(url)); 3615 return static_cast<WebUIImpl*>(CreateWebUI(url));
3614 } 3616 }
3615 3617
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
3675 GetCanonicalEncodingNameByAliasName(encoding); 3677 GetCanonicalEncodingNameByAliasName(encoding);
3676 } 3678 }
3677 3679
3678 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { 3680 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) {
3679 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(rvh); 3681 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(rvh);
3680 // Can be NULL during tests. 3682 // Can be NULL during tests.
3681 if (rwh_view) 3683 if (rwh_view)
3682 rwh_view->SetSize(GetView()->GetContainerSize()); 3684 rwh_view->SetSize(GetView()->GetContainerSize());
3683 } 3685 }
3684 3686
3687 bool WebContentsImpl::IsHidden() {
3688 return capturer_count_ == 0 && !should_normally_be_visible_;
3689 }
3690
3685 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { 3691 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() {
3686 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); 3692 return static_cast<RenderViewHostImpl*>(GetRenderViewHost());
3687 } 3693 }
3688 3694
3689 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const { 3695 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const {
3690 return browser_plugin_guest_.get(); 3696 return browser_plugin_guest_.get();
3691 } 3697 }
3692 3698
3693 void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) { 3699 void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) {
3694 CHECK(!browser_plugin_guest_); 3700 CHECK(!browser_plugin_guest_);
(...skipping 18 matching lines...) Expand all
3713 } 3719 }
3714 3720
3715 void WebContentsImpl::ClearAllPowerSaveBlockers() { 3721 void WebContentsImpl::ClearAllPowerSaveBlockers() {
3716 for (PowerSaveBlockerMap::iterator i(power_save_blockers_.begin()); 3722 for (PowerSaveBlockerMap::iterator i(power_save_blockers_.begin());
3717 i != power_save_blockers_.end(); ++i) 3723 i != power_save_blockers_.end(); ++i)
3718 STLDeleteValues(&power_save_blockers_[i->first]); 3724 STLDeleteValues(&power_save_blockers_[i->first]);
3719 power_save_blockers_.clear(); 3725 power_save_blockers_.clear();
3720 } 3726 }
3721 3727
3722 } // namespace content 3728 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698