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 2777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2788 Details<std::pair<NavigationEntry*, bool> >(&details)); | 2788 Details<std::pair<NavigationEntry*, bool> >(&details)); |
2789 | 2789 |
2790 return true; | 2790 return true; |
2791 } | 2791 } |
2792 | 2792 |
2793 void WebContentsImpl::NotifySwapped(RenderViewHost* old_render_view_host) { | 2793 void WebContentsImpl::NotifySwapped(RenderViewHost* old_render_view_host) { |
2794 // After sending out a swap notification, we need to send a disconnect | 2794 // After sending out a swap notification, we need to send a disconnect |
2795 // notification so that clients that pick up a pointer to |this| can NULL the | 2795 // notification so that clients that pick up a pointer to |this| can NULL the |
2796 // pointer. See Bug 1230284. | 2796 // pointer. See Bug 1230284. |
2797 notify_disconnection_ = true; | 2797 notify_disconnection_ = true; |
| 2798 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2799 RenderViewHostSwapped(old_render_view_host)); |
| 2800 |
| 2801 // TODO(avi): Remove. http://crbug.com/170921 |
2798 NotificationService::current()->Notify( | 2802 NotificationService::current()->Notify( |
2799 NOTIFICATION_WEB_CONTENTS_SWAPPED, | 2803 NOTIFICATION_WEB_CONTENTS_SWAPPED, |
2800 Source<WebContents>(this), | 2804 Source<WebContents>(this), |
2801 Details<RenderViewHost>(old_render_view_host)); | 2805 Details<RenderViewHost>(old_render_view_host)); |
2802 | 2806 |
2803 // Ensure that the associated embedder gets cleared after a RenderViewHost | 2807 // Ensure that the associated embedder gets cleared after a RenderViewHost |
2804 // gets swapped, so we don't reuse the same embedder next time a | 2808 // gets swapped, so we don't reuse the same embedder next time a |
2805 // RenderViewHost is attached to this WebContents. | 2809 // RenderViewHost is attached to this WebContents. |
2806 RemoveBrowserPluginEmbedder(); | 2810 RemoveBrowserPluginEmbedder(); |
2807 } | 2811 } |
2808 | 2812 |
2809 void WebContentsImpl::NotifyConnected() { | 2813 // TODO(avi): Remove this entire function because this notification is already |
2810 notify_disconnection_ = true; | 2814 // covered by two observer functions. http://crbug.com/170921 |
2811 NotificationService::current()->Notify( | |
2812 NOTIFICATION_WEB_CONTENTS_CONNECTED, | |
2813 Source<WebContents>(this), | |
2814 NotificationService::NoDetails()); | |
2815 } | |
2816 | |
2817 void WebContentsImpl::NotifyDisconnected() { | 2815 void WebContentsImpl::NotifyDisconnected() { |
2818 if (!notify_disconnection_) | 2816 if (!notify_disconnection_) |
2819 return; | 2817 return; |
2820 | 2818 |
2821 notify_disconnection_ = false; | 2819 notify_disconnection_ = false; |
2822 NotificationService::current()->Notify( | 2820 NotificationService::current()->Notify( |
2823 NOTIFICATION_WEB_CONTENTS_DISCONNECTED, | 2821 NOTIFICATION_WEB_CONTENTS_DISCONNECTED, |
2824 Source<WebContents>(this), | 2822 Source<WebContents>(this), |
2825 NotificationService::NoDetails()); | 2823 NotificationService::NoDetails()); |
2826 } | 2824 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2893 WebContentsObserver, observers_, RenderViewCreated(render_view_host)); | 2891 WebContentsObserver, observers_, RenderViewCreated(render_view_host)); |
2894 } | 2892 } |
2895 | 2893 |
2896 void WebContentsImpl::RenderViewReady(RenderViewHost* rvh) { | 2894 void WebContentsImpl::RenderViewReady(RenderViewHost* rvh) { |
2897 if (rvh != GetRenderViewHost()) { | 2895 if (rvh != GetRenderViewHost()) { |
2898 // Don't notify the world, since this came from a renderer in the | 2896 // Don't notify the world, since this came from a renderer in the |
2899 // background. | 2897 // background. |
2900 return; | 2898 return; |
2901 } | 2899 } |
2902 | 2900 |
2903 NotifyConnected(); | 2901 notify_disconnection_ = true; |
| 2902 // TODO(avi): Remove. http://crbug.com/170921 |
| 2903 NotificationService::current()->Notify( |
| 2904 NOTIFICATION_WEB_CONTENTS_CONNECTED, |
| 2905 Source<WebContents>(this), |
| 2906 NotificationService::NoDetails()); |
| 2907 |
2904 bool was_crashed = IsCrashed(); | 2908 bool was_crashed = IsCrashed(); |
2905 SetIsCrashed(base::TERMINATION_STATUS_STILL_RUNNING, 0); | 2909 SetIsCrashed(base::TERMINATION_STATUS_STILL_RUNNING, 0); |
2906 | 2910 |
2907 // Restore the focus to the tab (otherwise the focus will be on the top | 2911 // Restore the focus to the tab (otherwise the focus will be on the top |
2908 // window). | 2912 // window). |
2909 if (was_crashed && !FocusLocationBarByDefault() && | 2913 if (was_crashed && !FocusLocationBarByDefault() && |
2910 (!delegate_ || delegate_->ShouldFocusPageAfterCrash())) { | 2914 (!delegate_ || delegate_->ShouldFocusPageAfterCrash())) { |
2911 view_->Focus(); | 2915 view_->Focus(); |
2912 } | 2916 } |
2913 | 2917 |
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3754 gfx::Size WebContentsImpl::GetSizeForNewRenderView() const { | 3758 gfx::Size WebContentsImpl::GetSizeForNewRenderView() const { |
3755 gfx::Size size; | 3759 gfx::Size size; |
3756 if (delegate_) | 3760 if (delegate_) |
3757 size = delegate_->GetSizeForNewRenderView(this); | 3761 size = delegate_->GetSizeForNewRenderView(this); |
3758 if (size.IsEmpty()) | 3762 if (size.IsEmpty()) |
3759 size = view_->GetContainerSize(); | 3763 size = view_->GetContainerSize(); |
3760 return size; | 3764 return size; |
3761 } | 3765 } |
3762 | 3766 |
3763 } // namespace content | 3767 } // namespace content |
OLD | NEW |