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 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 break; | 1190 break; |
1191 } | 1191 } |
1192 default: | 1192 default: |
1193 NOTREACHED(); | 1193 NOTREACHED(); |
1194 } | 1194 } |
1195 } | 1195 } |
1196 | 1196 |
1197 void WebContentsImpl::Init(const WebContents::CreateParams& params) { | 1197 void WebContentsImpl::Init(const WebContents::CreateParams& params) { |
1198 render_manager_.Init( | 1198 render_manager_.Init( |
1199 params.browser_context, params.site_instance, params.routing_id, | 1199 params.browser_context, params.site_instance, params.routing_id, |
1200 params.main_frame_routing_id); | 1200 params.main_frame_routing_id, params.initially_hidden); |
1201 | 1201 |
1202 view_.reset(GetContentClient()->browser()-> | 1202 view_.reset(GetContentClient()->browser()-> |
1203 OverrideCreateWebContentsView(this, &render_view_host_delegate_view_)); | 1203 OverrideCreateWebContentsView(this, &render_view_host_delegate_view_)); |
1204 if (view_) { | 1204 if (view_) { |
1205 CHECK(render_view_host_delegate_view_); | 1205 CHECK(render_view_host_delegate_view_); |
1206 } else { | 1206 } else { |
1207 WebContentsViewDelegate* delegate = | 1207 WebContentsViewDelegate* delegate = |
1208 GetContentClient()->browser()->GetWebContentsViewDelegate(this); | 1208 GetContentClient()->browser()->GetWebContentsViewDelegate(this); |
1209 | 1209 |
1210 if (browser_plugin_guest_) { | 1210 if (browser_plugin_guest_) { |
(...skipping 268 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 = !should_normally_be_visible_; |
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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1758 bool WebContentsImpl::NavigateToEntry( | 1761 bool WebContentsImpl::NavigateToEntry( |
1759 const NavigationEntryImpl& entry, | 1762 const NavigationEntryImpl& entry, |
1760 NavigationController::ReloadType reload_type) { | 1763 NavigationController::ReloadType reload_type) { |
1761 TRACE_EVENT0("browser", "WebContentsImpl::NavigateToEntry"); | 1764 TRACE_EVENT0("browser", "WebContentsImpl::NavigateToEntry"); |
1762 | 1765 |
1763 // The renderer will reject IPC messages with URLs longer than | 1766 // The renderer will reject IPC messages with URLs longer than |
1764 // this limit, so don't attempt to navigate with a longer URL. | 1767 // this limit, so don't attempt to navigate with a longer URL. |
1765 if (entry.GetURL().spec().size() > kMaxURLChars) | 1768 if (entry.GetURL().spec().size() > kMaxURLChars) |
1766 return false; | 1769 return false; |
1767 | 1770 |
| 1771 bool hidden = !should_normally_be_visible_; |
1768 RenderViewHostImpl* dest_render_view_host = | 1772 RenderViewHostImpl* dest_render_view_host = |
1769 static_cast<RenderViewHostImpl*>(render_manager_.Navigate(entry)); | 1773 static_cast<RenderViewHostImpl*>(render_manager_.Navigate(entry, hidden)); |
1770 if (!dest_render_view_host) | 1774 if (!dest_render_view_host) |
1771 return false; // Unable to create the desired render view host. | 1775 return false; // Unable to create the desired render view host. |
1772 | 1776 |
1773 // For security, we should never send non-Web-UI URLs to a Web UI renderer. | 1777 // For security, we should never send non-Web-UI URLs to a Web UI renderer. |
1774 // Double check that here. | 1778 // Double check that here. |
1775 int enabled_bindings = dest_render_view_host->GetEnabledBindings(); | 1779 int enabled_bindings = dest_render_view_host->GetEnabledBindings(); |
1776 bool data_urls_allowed = delegate_ && delegate_->CanLoadDataURLsInWebUI(); | 1780 bool data_urls_allowed = delegate_ && delegate_->CanLoadDataURLsInWebUI(); |
1777 bool is_allowed_in_web_ui_renderer = | 1781 bool is_allowed_in_web_ui_renderer = |
1778 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( | 1782 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( |
1779 GetBrowserContext(), entry.GetURL(), data_urls_allowed); | 1783 GetBrowserContext(), entry.GetURL(), data_urls_allowed); |
(...skipping 1645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3425 WebPreferences WebContentsImpl::GetWebkitPrefs() { | 3429 WebPreferences WebContentsImpl::GetWebkitPrefs() { |
3426 // We want to base the page config off of the real URL, rather than the | 3430 // We want to base the page config off of the real URL, rather than the |
3427 // display URL. | 3431 // display URL. |
3428 GURL url = controller_.GetActiveEntry() | 3432 GURL url = controller_.GetActiveEntry() |
3429 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); | 3433 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); |
3430 return GetWebkitPrefs(GetRenderViewHost(), url); | 3434 return GetWebkitPrefs(GetRenderViewHost(), url); |
3431 } | 3435 } |
3432 | 3436 |
3433 int WebContentsImpl::CreateSwappedOutRenderView( | 3437 int WebContentsImpl::CreateSwappedOutRenderView( |
3434 SiteInstance* instance) { | 3438 SiteInstance* instance) { |
3435 return render_manager_.CreateRenderView(instance, MSG_ROUTING_NONE, true); | 3439 return render_manager_.CreateRenderView(instance, MSG_ROUTING_NONE, |
| 3440 true, true); |
3436 } | 3441 } |
3437 | 3442 |
3438 void WebContentsImpl::OnUserGesture() { | 3443 void WebContentsImpl::OnUserGesture() { |
3439 // Notify observers. | 3444 // Notify observers. |
3440 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); | 3445 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); |
3441 | 3446 |
3442 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); | 3447 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
3443 if (rdh) // NULL in unittests. | 3448 if (rdh) // NULL in unittests. |
3444 rdh->OnUserGesture(this); | 3449 rdh->OnUserGesture(this); |
3445 } | 3450 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3595 render_manager_.pending_render_view_host()->GetSiteInstance() == instance) | 3600 render_manager_.pending_render_view_host()->GetSiteInstance() == instance) |
3596 return render_manager_.pending_render_view_host()->GetRoutingID(); | 3601 return render_manager_.pending_render_view_host()->GetRoutingID(); |
3597 | 3602 |
3598 RenderViewHostImpl* rvh = render_manager_.GetSwappedOutRenderViewHost( | 3603 RenderViewHostImpl* rvh = render_manager_.GetSwappedOutRenderViewHost( |
3599 instance); | 3604 instance); |
3600 if (rvh) | 3605 if (rvh) |
3601 return rvh->GetRoutingID(); | 3606 return rvh->GetRoutingID(); |
3602 | 3607 |
3603 // Create a swapped out RenderView in the given SiteInstance if none exists, | 3608 // 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. | 3609 // 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); | 3610 return render_manager_.CreateRenderView(instance, opener_route_id, |
| 3611 true, true); |
3606 } | 3612 } |
3607 | 3613 |
3608 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { | 3614 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { |
3609 return GetController(); | 3615 return GetController(); |
3610 } | 3616 } |
3611 | 3617 |
3612 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { | 3618 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { |
3613 return static_cast<WebUIImpl*>(CreateWebUI(url)); | 3619 return static_cast<WebUIImpl*>(CreateWebUI(url)); |
3614 } | 3620 } |
3615 | 3621 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |