| 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 2848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2859 std::pair<NavigationEntry*, bool> details = | 2859 std::pair<NavigationEntry*, bool> details = |
| 2860 std::make_pair(entry, explicit_set); | 2860 std::make_pair(entry, explicit_set); |
| 2861 NotificationService::current()->Notify( | 2861 NotificationService::current()->Notify( |
| 2862 NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, | 2862 NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, |
| 2863 Source<WebContents>(this), | 2863 Source<WebContents>(this), |
| 2864 Details<std::pair<NavigationEntry*, bool> >(&details)); | 2864 Details<std::pair<NavigationEntry*, bool> >(&details)); |
| 2865 | 2865 |
| 2866 return true; | 2866 return true; |
| 2867 } | 2867 } |
| 2868 | 2868 |
| 2869 void WebContentsImpl::NotifySwapped(RenderViewHost* old_render_view_host) { | 2869 void WebContentsImpl::NotifySwapped(RenderViewHost* old_host, |
| 2870 RenderViewHost* new_host) { |
| 2870 // After sending out a swap notification, we need to send a disconnect | 2871 // After sending out a swap notification, we need to send a disconnect |
| 2871 // notification so that clients that pick up a pointer to |this| can NULL the | 2872 // notification so that clients that pick up a pointer to |this| can NULL the |
| 2872 // pointer. See Bug 1230284. | 2873 // pointer. See Bug 1230284. |
| 2873 notify_disconnection_ = true; | 2874 notify_disconnection_ = true; |
| 2874 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2875 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2875 RenderViewHostSwapped(old_render_view_host)); | 2876 RenderViewHostChanged(old_host, new_host)); |
| 2876 | 2877 |
| 2877 // TODO(avi): Remove. http://crbug.com/170921 | 2878 // TODO(avi): Remove. http://crbug.com/170921 |
| 2879 std::pair<RenderViewHost*, RenderViewHost*> details = |
| 2880 std::make_pair(old_host, new_host); |
| 2878 NotificationService::current()->Notify( | 2881 NotificationService::current()->Notify( |
| 2879 NOTIFICATION_WEB_CONTENTS_SWAPPED, | 2882 NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 2880 Source<WebContents>(this), | 2883 Source<WebContents>(this), |
| 2881 Details<RenderViewHost>(old_render_view_host)); | 2884 Details<std::pair<RenderViewHost*, RenderViewHost*> >(&details)); |
| 2882 | 2885 |
| 2883 // Ensure that the associated embedder gets cleared after a RenderViewHost | 2886 // Ensure that the associated embedder gets cleared after a RenderViewHost |
| 2884 // gets swapped, so we don't reuse the same embedder next time a | 2887 // gets swapped, so we don't reuse the same embedder next time a |
| 2885 // RenderViewHost is attached to this WebContents. | 2888 // RenderViewHost is attached to this WebContents. |
| 2886 RemoveBrowserPluginEmbedder(); | 2889 RemoveBrowserPluginEmbedder(); |
| 2887 } | 2890 } |
| 2888 | 2891 |
| 2889 // TODO(avi): Remove this entire function because this notification is already | 2892 // TODO(avi): Remove this entire function because this notification is already |
| 2890 // covered by two observer functions. http://crbug.com/170921 | 2893 // covered by two observer functions. http://crbug.com/170921 |
| 2891 void WebContentsImpl::NotifyDisconnected() { | 2894 void WebContentsImpl::NotifyDisconnected() { |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3673 view_->SizeContents(size); | 3676 view_->SizeContents(size); |
| 3674 } | 3677 } |
| 3675 | 3678 |
| 3676 void WebContentsImpl::CancelModalDialogsForRenderManager() { | 3679 void WebContentsImpl::CancelModalDialogsForRenderManager() { |
| 3677 // We need to cancel modal dialogs when doing a process swap, since the load | 3680 // We need to cancel modal dialogs when doing a process swap, since the load |
| 3678 // deferrer would prevent us from swapping out. | 3681 // deferrer would prevent us from swapping out. |
| 3679 if (dialog_manager_) | 3682 if (dialog_manager_) |
| 3680 dialog_manager_->CancelActiveAndPendingDialogs(this); | 3683 dialog_manager_->CancelActiveAndPendingDialogs(this); |
| 3681 } | 3684 } |
| 3682 | 3685 |
| 3683 void WebContentsImpl::NotifySwappedFromRenderManager(RenderViewHost* rvh) { | 3686 void WebContentsImpl::NotifySwappedFromRenderManager(RenderViewHost* old_host, |
| 3684 NotifySwapped(rvh); | 3687 RenderViewHost* new_host) { |
| 3688 NotifySwapped(old_host, new_host); |
| 3685 | 3689 |
| 3686 // Make sure the visible RVH reflects the new delegate's preferences. | 3690 // Make sure the visible RVH reflects the new delegate's preferences. |
| 3687 if (delegate_) | 3691 if (delegate_) |
| 3688 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); | 3692 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); |
| 3689 | 3693 |
| 3690 view_->RenderViewSwappedIn(render_manager_.current_host()); | 3694 view_->RenderViewSwappedIn(new_host); |
| 3691 | 3695 |
| 3692 FrameTreeNode* root = NULL; | 3696 FrameTreeNode* root = NULL; |
| 3693 RenderViewHostImpl* new_rvh = static_cast<RenderViewHostImpl*>( | 3697 RenderViewHostImpl* new_rvh = static_cast<RenderViewHostImpl*>(new_host); |
| 3694 render_manager_.current_host()); | |
| 3695 | 3698 |
| 3696 // We are doing a cross-site navigation and swapping processes. Since frame | 3699 // We are doing a cross-site navigation and swapping processes. Since frame |
| 3697 // ids are unique to a process, we need to recreate the frame tree with the | 3700 // ids are unique to a process, we need to recreate the frame tree with the |
| 3698 // proper main frame id. | 3701 // proper main frame id. |
| 3699 // Note that it is possible for this method to be called before the new RVH | 3702 // Note that it is possible for this method to be called before the new RVH |
| 3700 // has committed a navigation (if RenderViewHostManager short-circuits the | 3703 // has committed a navigation (if RenderViewHostManager short-circuits the |
| 3701 // CommitPending call because the current RVH is dead). In that case, we | 3704 // CommitPending call because the current RVH is dead). In that case, we |
| 3702 // haven't heard a valid frame id to use to initialize the root node, so clear | 3705 // haven't heard a valid frame id to use to initialize the root node, so clear |
| 3703 // out the root node and the first subsequent navigation message will set it | 3706 // out the root node and the first subsequent navigation message will set it |
| 3704 // correctly. | 3707 // correctly. |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3873 gfx::Size WebContentsImpl::GetSizeForNewRenderView() const { | 3876 gfx::Size WebContentsImpl::GetSizeForNewRenderView() const { |
| 3874 gfx::Size size; | 3877 gfx::Size size; |
| 3875 if (delegate_) | 3878 if (delegate_) |
| 3876 size = delegate_->GetSizeForNewRenderView(this); | 3879 size = delegate_->GetSizeForNewRenderView(this); |
| 3877 if (size.IsEmpty()) | 3880 if (size.IsEmpty()) |
| 3878 size = view_->GetContainerSize(); | 3881 size = view_->GetContainerSize(); |
| 3879 return size; | 3882 return size; |
| 3880 } | 3883 } |
| 3881 | 3884 |
| 3882 } // namespace content | 3885 } // namespace content |
| OLD | NEW |