| 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/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1637 delegate_->WebContentsCreated( | 1637 delegate_->WebContentsCreated( |
| 1638 this, params.opener_render_frame_id, params.frame_name, | 1638 this, params.opener_render_frame_id, params.frame_name, |
| 1639 params.target_url, new_contents); | 1639 params.target_url, new_contents); |
| 1640 } | 1640 } |
| 1641 | 1641 |
| 1642 if (params.opener_suppressed) { | 1642 if (params.opener_suppressed) { |
| 1643 // When the opener is suppressed, the original renderer cannot access the | 1643 // When the opener is suppressed, the original renderer cannot access the |
| 1644 // new window. As a result, we need to show and navigate the window here. | 1644 // new window. As a result, we need to show and navigate the window here. |
| 1645 bool was_blocked = false; | 1645 bool was_blocked = false; |
| 1646 if (delegate_) { | 1646 if (delegate_) { |
| 1647 gfx::Rect initial_pos; | 1647 gfx::Rect initial_rect; |
| 1648 delegate_->AddNewContents( | 1648 delegate_->AddNewContents( |
| 1649 this, new_contents, params.disposition, initial_pos, | 1649 this, new_contents, params.disposition, initial_rect, |
| 1650 params.user_gesture, &was_blocked); | 1650 params.user_gesture, &was_blocked); |
| 1651 } | 1651 } |
| 1652 if (!was_blocked) { | 1652 if (!was_blocked) { |
| 1653 OpenURLParams open_params(params.target_url, | 1653 OpenURLParams open_params(params.target_url, |
| 1654 Referrer(), | 1654 Referrer(), |
| 1655 CURRENT_TAB, | 1655 CURRENT_TAB, |
| 1656 ui::PAGE_TRANSITION_LINK, | 1656 ui::PAGE_TRANSITION_LINK, |
| 1657 true /* is_renderer_initiated */); | 1657 true /* is_renderer_initiated */); |
| 1658 open_params.user_gesture = params.user_gesture; | 1658 open_params.user_gesture = params.user_gesture; |
| 1659 new_contents->OpenURL(open_params); | 1659 new_contents->OpenURL(open_params); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1709 | 1709 |
| 1710 #if defined(OS_MACOSX) | 1710 #if defined(OS_MACOSX) |
| 1711 // A RenderWidgetHostViewMac has lifetime scoped to the view. We'll retain it | 1711 // A RenderWidgetHostViewMac has lifetime scoped to the view. We'll retain it |
| 1712 // to allow it to survive the trip without being hosted. | 1712 // to allow it to survive the trip without being hosted. |
| 1713 base::mac::NSObjectRetain(widget_view->GetNativeView()); | 1713 base::mac::NSObjectRetain(widget_view->GetNativeView()); |
| 1714 #endif | 1714 #endif |
| 1715 } | 1715 } |
| 1716 | 1716 |
| 1717 void WebContentsImpl::ShowCreatedWindow(int route_id, | 1717 void WebContentsImpl::ShowCreatedWindow(int route_id, |
| 1718 WindowOpenDisposition disposition, | 1718 WindowOpenDisposition disposition, |
| 1719 const gfx::Rect& initial_pos, | 1719 const gfx::Rect& initial_rect, |
| 1720 bool user_gesture) { | 1720 bool user_gesture) { |
| 1721 WebContentsImpl* contents = GetCreatedWindow(route_id); | 1721 WebContentsImpl* contents = GetCreatedWindow(route_id); |
| 1722 if (contents) { | 1722 if (contents) { |
| 1723 WebContentsDelegate* delegate = GetDelegate(); | 1723 WebContentsDelegate* delegate = GetDelegate(); |
| 1724 if (delegate) { | 1724 if (delegate) { |
| 1725 delegate->AddNewContents( | 1725 delegate->AddNewContents( |
| 1726 this, contents, disposition, initial_pos, user_gesture, NULL); | 1726 this, contents, disposition, initial_rect, user_gesture, NULL); |
| 1727 } | 1727 } |
| 1728 } | 1728 } |
| 1729 } | 1729 } |
| 1730 | 1730 |
| 1731 void WebContentsImpl::ShowCreatedWidget(int route_id, | 1731 void WebContentsImpl::ShowCreatedWidget(int route_id, |
| 1732 const gfx::Rect& initial_pos) { | 1732 const gfx::Rect& initial_rect) { |
| 1733 ShowCreatedWidget(route_id, false, initial_pos); | 1733 ShowCreatedWidget(route_id, false, initial_rect); |
| 1734 } | 1734 } |
| 1735 | 1735 |
| 1736 void WebContentsImpl::ShowCreatedFullscreenWidget(int route_id) { | 1736 void WebContentsImpl::ShowCreatedFullscreenWidget(int route_id) { |
| 1737 ShowCreatedWidget(route_id, true, gfx::Rect()); | 1737 ShowCreatedWidget(route_id, true, gfx::Rect()); |
| 1738 } | 1738 } |
| 1739 | 1739 |
| 1740 void WebContentsImpl::ShowCreatedWidget(int route_id, | 1740 void WebContentsImpl::ShowCreatedWidget(int route_id, |
| 1741 bool is_fullscreen, | 1741 bool is_fullscreen, |
| 1742 const gfx::Rect& initial_pos) { | 1742 const gfx::Rect& initial_rect) { |
| 1743 RenderWidgetHostViewBase* widget_host_view = | 1743 RenderWidgetHostViewBase* widget_host_view = |
| 1744 static_cast<RenderWidgetHostViewBase*>(GetCreatedWidget(route_id)); | 1744 static_cast<RenderWidgetHostViewBase*>(GetCreatedWidget(route_id)); |
| 1745 if (!widget_host_view) | 1745 if (!widget_host_view) |
| 1746 return; | 1746 return; |
| 1747 | 1747 |
| 1748 RenderWidgetHostView* view = NULL; | 1748 RenderWidgetHostView* view = NULL; |
| 1749 BrowserPluginGuest* guest = GetBrowserPluginGuest(); | 1749 BrowserPluginGuest* guest = GetBrowserPluginGuest(); |
| 1750 if (guest && guest->embedder_web_contents()) { | 1750 if (guest && guest->embedder_web_contents()) { |
| 1751 view = guest->embedder_web_contents()->GetRenderWidgetHostView(); | 1751 view = guest->embedder_web_contents()->GetRenderWidgetHostView(); |
| 1752 } else { | 1752 } else { |
| 1753 view = GetRenderWidgetHostView(); | 1753 view = GetRenderWidgetHostView(); |
| 1754 } | 1754 } |
| 1755 | 1755 |
| 1756 if (is_fullscreen) { | 1756 if (is_fullscreen) { |
| 1757 DCHECK_EQ(MSG_ROUTING_NONE, fullscreen_widget_routing_id_); | 1757 DCHECK_EQ(MSG_ROUTING_NONE, fullscreen_widget_routing_id_); |
| 1758 view_->StoreFocus(); | 1758 view_->StoreFocus(); |
| 1759 fullscreen_widget_routing_id_ = route_id; | 1759 fullscreen_widget_routing_id_ = route_id; |
| 1760 if (delegate_ && delegate_->EmbedsFullscreenWidget()) { | 1760 if (delegate_ && delegate_->EmbedsFullscreenWidget()) { |
| 1761 widget_host_view->InitAsChild(GetRenderWidgetHostView()->GetNativeView()); | 1761 widget_host_view->InitAsChild(GetRenderWidgetHostView()->GetNativeView()); |
| 1762 delegate_->EnterFullscreenModeForTab(this, GURL()); | 1762 delegate_->EnterFullscreenModeForTab(this, GURL()); |
| 1763 } else { | 1763 } else { |
| 1764 widget_host_view->InitAsFullscreen(view); | 1764 widget_host_view->InitAsFullscreen(view); |
| 1765 } | 1765 } |
| 1766 FOR_EACH_OBSERVER(WebContentsObserver, | 1766 FOR_EACH_OBSERVER(WebContentsObserver, |
| 1767 observers_, | 1767 observers_, |
| 1768 DidShowFullscreenWidget(route_id)); | 1768 DidShowFullscreenWidget(route_id)); |
| 1769 if (!widget_host_view->HasFocus()) | 1769 if (!widget_host_view->HasFocus()) |
| 1770 widget_host_view->Focus(); | 1770 widget_host_view->Focus(); |
| 1771 } else { | 1771 } else { |
| 1772 widget_host_view->InitAsPopup(view, initial_pos); | 1772 widget_host_view->InitAsPopup(view, initial_rect); |
| 1773 } | 1773 } |
| 1774 | 1774 |
| 1775 RenderWidgetHostImpl* render_widget_host_impl = | 1775 RenderWidgetHostImpl* render_widget_host_impl = |
| 1776 RenderWidgetHostImpl::From(widget_host_view->GetRenderWidgetHost()); | 1776 RenderWidgetHostImpl::From(widget_host_view->GetRenderWidgetHost()); |
| 1777 render_widget_host_impl->Init(); | 1777 render_widget_host_impl->Init(); |
| 1778 // Only allow privileged mouse lock for fullscreen render widget, which is | 1778 // Only allow privileged mouse lock for fullscreen render widget, which is |
| 1779 // used to implement Pepper Flash fullscreen. | 1779 // used to implement Pepper Flash fullscreen. |
| 1780 render_widget_host_impl->set_allow_privileged_mouse_lock(is_fullscreen); | 1780 render_widget_host_impl->set_allow_privileged_mouse_lock(is_fullscreen); |
| 1781 | 1781 |
| 1782 #if defined(OS_MACOSX) | 1782 #if defined(OS_MACOSX) |
| (...skipping 2700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4483 node->render_manager()->ResumeResponseDeferredAtStart(); | 4483 node->render_manager()->ResumeResponseDeferredAtStart(); |
| 4484 } | 4484 } |
| 4485 | 4485 |
| 4486 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4486 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
| 4487 force_disable_overscroll_content_ = force_disable; | 4487 force_disable_overscroll_content_ = force_disable; |
| 4488 if (view_) | 4488 if (view_) |
| 4489 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4489 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 4490 } | 4490 } |
| 4491 | 4491 |
| 4492 } // namespace content | 4492 } // namespace content |
| OLD | NEW |