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 2778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2789 std::make_pair(entry, explicit_set); | 2789 std::make_pair(entry, explicit_set); |
2790 | 2790 |
2791 NotificationService::current()->Notify( | 2791 NotificationService::current()->Notify( |
2792 NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, | 2792 NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, |
2793 Source<WebContents>(this), | 2793 Source<WebContents>(this), |
2794 Details<std::pair<NavigationEntry*, bool> >(&details)); | 2794 Details<std::pair<NavigationEntry*, bool> >(&details)); |
2795 | 2795 |
2796 return true; | 2796 return true; |
2797 } | 2797 } |
2798 | 2798 |
2799 void WebContentsImpl::NotifySwapped(RenderViewHost* old_render_view_host) { | 2799 void WebContentsImpl::NotifySwapped(RenderViewHost* old_host, |
| 2800 RenderViewHost* new_host) { |
2800 // After sending out a swap notification, we need to send a disconnect | 2801 // After sending out a swap notification, we need to send a disconnect |
2801 // notification so that clients that pick up a pointer to |this| can NULL the | 2802 // notification so that clients that pick up a pointer to |this| can NULL the |
2802 // pointer. See Bug 1230284. | 2803 // pointer. See Bug 1230284. |
2803 notify_disconnection_ = true; | 2804 notify_disconnection_ = true; |
2804 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2805 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
2805 RenderViewHostSwapped(old_render_view_host)); | 2806 RenderViewHostSwapped(old_host, new_host)); |
2806 | 2807 |
2807 // TODO(avi): Remove. http://crbug.com/170921 | 2808 // TODO(avi): Remove. http://crbug.com/170921 |
| 2809 std::pair<RenderViewHost*, RenderViewHost*> details = |
| 2810 std::make_pair(old_host, new_host); |
2808 NotificationService::current()->Notify( | 2811 NotificationService::current()->Notify( |
2809 NOTIFICATION_WEB_CONTENTS_SWAPPED, | 2812 NOTIFICATION_WEB_CONTENTS_SWAPPED, |
2810 Source<WebContents>(this), | 2813 Source<WebContents>(this), |
2811 Details<RenderViewHost>(old_render_view_host)); | 2814 Details<std::pair<RenderViewHost*, RenderViewHost*> >(&details)); |
2812 | 2815 |
2813 // Ensure that the associated embedder gets cleared after a RenderViewHost | 2816 // Ensure that the associated embedder gets cleared after a RenderViewHost |
2814 // gets swapped, so we don't reuse the same embedder next time a | 2817 // gets swapped, so we don't reuse the same embedder next time a |
2815 // RenderViewHost is attached to this WebContents. | 2818 // RenderViewHost is attached to this WebContents. |
2816 RemoveBrowserPluginEmbedder(); | 2819 RemoveBrowserPluginEmbedder(); |
2817 } | 2820 } |
2818 | 2821 |
2819 // TODO(avi): Remove this entire function because this notification is already | 2822 // TODO(avi): Remove this entire function because this notification is already |
2820 // covered by two observer functions. http://crbug.com/170921 | 2823 // covered by two observer functions. http://crbug.com/170921 |
2821 void WebContentsImpl::NotifyDisconnected() { | 2824 void WebContentsImpl::NotifyDisconnected() { |
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3590 // TODO(brettw) this is a hack. See WebContentsView::SizeContents. | 3593 // TODO(brettw) this is a hack. See WebContentsView::SizeContents. |
3591 gfx::Size size = GetSizeForNewRenderView(); | 3594 gfx::Size size = GetSizeForNewRenderView(); |
3592 // 0x0 isn't a valid window size (minimal window size is 1x1) but it may be | 3595 // 0x0 isn't a valid window size (minimal window size is 1x1) but it may be |
3593 // here during container initialization and normal window size will be set | 3596 // here during container initialization and normal window size will be set |
3594 // later. In case of tab duplication this resizing to 0x0 prevents setting | 3597 // later. In case of tab duplication this resizing to 0x0 prevents setting |
3595 // normal size later so just ignore it. | 3598 // normal size later so just ignore it. |
3596 if (!size.IsEmpty()) | 3599 if (!size.IsEmpty()) |
3597 view_->SizeContents(size); | 3600 view_->SizeContents(size); |
3598 } | 3601 } |
3599 | 3602 |
3600 void WebContentsImpl::NotifySwappedFromRenderManager(RenderViewHost* rvh) { | 3603 void WebContentsImpl::NotifySwappedFromRenderManager(RenderViewHost* old_host, |
3601 NotifySwapped(rvh); | 3604 RenderViewHost* new_host) { |
| 3605 NotifySwapped(old_host, new_host); |
3602 | 3606 |
3603 // Make sure the visible RVH reflects the new delegate's preferences. | 3607 // Make sure the visible RVH reflects the new delegate's preferences. |
3604 if (delegate_) | 3608 if (delegate_) |
3605 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); | 3609 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); |
3606 | 3610 |
3607 view_->RenderViewSwappedIn(render_manager_.current_host()); | 3611 view_->RenderViewSwappedIn(new_host); |
3608 | 3612 |
3609 FrameTreeNode* root = NULL; | 3613 FrameTreeNode* root = NULL; |
3610 RenderViewHostImpl* new_rvh = static_cast<RenderViewHostImpl*>( | 3614 RenderViewHostImpl* new_rvh = static_cast<RenderViewHostImpl*>(new_host); |
3611 render_manager_.current_host()); | |
3612 | 3615 |
3613 // We are doing a cross-site navigation and swapping processes. Since frame | 3616 // We are doing a cross-site navigation and swapping processes. Since frame |
3614 // ids are unique to a process, we need to recreate the frame tree with the | 3617 // ids are unique to a process, we need to recreate the frame tree with the |
3615 // proper main frame id. | 3618 // proper main frame id. |
3616 // Note that it is possible for this method to be called before the new RVH | 3619 // Note that it is possible for this method to be called before the new RVH |
3617 // has committed a navigation (if RenderViewHostManager short-circuits the | 3620 // has committed a navigation (if RenderViewHostManager short-circuits the |
3618 // CommitPending call because the current RVH is dead). In that case, we | 3621 // CommitPending call because the current RVH is dead). In that case, we |
3619 // haven't heard a valid frame id to use to initialize the root node, so clear | 3622 // haven't heard a valid frame id to use to initialize the root node, so clear |
3620 // out the root node and the first subsequent navigation message will set it | 3623 // out the root node and the first subsequent navigation message will set it |
3621 // correctly. | 3624 // correctly. |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3790 gfx::Size WebContentsImpl::GetSizeForNewRenderView() const { | 3793 gfx::Size WebContentsImpl::GetSizeForNewRenderView() const { |
3791 gfx::Size size; | 3794 gfx::Size size; |
3792 if (delegate_) | 3795 if (delegate_) |
3793 size = delegate_->GetSizeForNewRenderView(this); | 3796 size = delegate_->GetSizeForNewRenderView(this); |
3794 if (size.IsEmpty()) | 3797 if (size.IsEmpty()) |
3795 size = view_->GetContainerSize(); | 3798 size = view_->GetContainerSize(); |
3796 return size; | 3799 return size; |
3797 } | 3800 } |
3798 | 3801 |
3799 } // namespace content | 3802 } // namespace content |
OLD | NEW |