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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 #include "content/public/browser/color_chooser.h" | 40 #include "content/public/browser/color_chooser.h" |
41 #include "content/public/browser/content_browser_client.h" | 41 #include "content/public/browser/content_browser_client.h" |
42 #include "content/public/browser/devtools_agent_host_registry.h" | 42 #include "content/public/browser/devtools_agent_host_registry.h" |
43 #include "content/public/browser/download_manager.h" | 43 #include "content/public/browser/download_manager.h" |
44 #include "content/public/browser/download_url_parameters.h" | 44 #include "content/public/browser/download_url_parameters.h" |
45 #include "content/public/browser/invalidate_type.h" | 45 #include "content/public/browser/invalidate_type.h" |
46 #include "content/public/browser/javascript_dialogs.h" | 46 #include "content/public/browser/javascript_dialogs.h" |
47 #include "content/public/browser/load_notification_details.h" | 47 #include "content/public/browser/load_notification_details.h" |
48 #include "content/public/browser/navigation_details.h" | 48 #include "content/public/browser/navigation_details.h" |
49 #include "content/public/browser/notification_service.h" | 49 #include "content/public/browser/notification_service.h" |
| 50 #include "content/public/browser/notification_details.h" |
50 #include "content/public/browser/resource_request_details.h" | 51 #include "content/public/browser/resource_request_details.h" |
51 #include "content/public/browser/user_metrics.h" | 52 #include "content/public/browser/user_metrics.h" |
52 #include "content/public/browser/web_contents_delegate.h" | 53 #include "content/public/browser/web_contents_delegate.h" |
53 #include "content/public/browser/web_contents_observer.h" | 54 #include "content/public/browser/web_contents_observer.h" |
54 #include "content/public/browser/web_contents_view.h" | 55 #include "content/public/browser/web_contents_view.h" |
55 #include "content/public/browser/web_ui_controller_factory.h" | 56 #include "content/public/browser/web_ui_controller_factory.h" |
56 #include "content/public/common/bindings_policy.h" | 57 #include "content/public/common/bindings_policy.h" |
57 #include "content/public/common/content_constants.h" | 58 #include "content/public/common/content_constants.h" |
58 #include "content/public/common/content_restriction.h" | 59 #include "content/public/common/content_restriction.h" |
59 #include "content/public/common/content_switches.h" | 60 #include "content/public/common/content_switches.h" |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 // This is because closing the tab calls WebContentsImpl::Destroy(), which | 895 // This is because closing the tab calls WebContentsImpl::Destroy(), which |
895 // removes the |GetRenderViewHost()|; then when we actually destroy the | 896 // removes the |GetRenderViewHost()|; then when we actually destroy the |
896 // window, OnWindowPosChanged() notices and calls HideContents() (which | 897 // window, OnWindowPosChanged() notices and calls HideContents() (which |
897 // calls us). | 898 // calls us). |
898 RenderWidgetHostViewPort* rwhv = | 899 RenderWidgetHostViewPort* rwhv = |
899 RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); | 900 RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); |
900 if (rwhv) | 901 if (rwhv) |
901 rwhv->WasHidden(); | 902 rwhv->WasHidden(); |
902 } | 903 } |
903 | 904 |
| 905 bool is_visible = false; |
904 content::NotificationService::current()->Notify( | 906 content::NotificationService::current()->Notify( |
905 content::NOTIFICATION_WEB_CONTENTS_HIDDEN, | 907 content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, |
906 content::Source<WebContents>(this), | 908 content::Source<WebContents>(this), |
907 content::NotificationService::NoDetails()); | 909 content::Details<bool>(&is_visible)); |
| 910 } |
| 911 |
| 912 void WebContentsImpl::WasRestored() { |
| 913 bool is_visible = true; |
| 914 content::NotificationService::current()->Notify( |
| 915 content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, |
| 916 content::Source<WebContents>(this), |
| 917 content::Details<bool>(&is_visible)); |
908 } | 918 } |
909 | 919 |
910 void WebContentsImpl::ShowContents() { | 920 void WebContentsImpl::ShowContents() { |
911 RenderWidgetHostViewPort* rwhv = | 921 RenderWidgetHostViewPort* rwhv = |
912 RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); | 922 RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); |
913 if (rwhv) | 923 if (rwhv) |
914 rwhv->DidBecomeSelected(); | 924 rwhv->DidBecomeSelected(); |
| 925 WasRestored(); |
915 } | 926 } |
916 | 927 |
917 void WebContentsImpl::HideContents() { | 928 void WebContentsImpl::HideContents() { |
918 // TODO(pkasting): http://b/1239839 Right now we purposefully don't call | 929 // TODO(pkasting): http://b/1239839 Right now we purposefully don't call |
919 // our superclass HideContents(), because some callers want to be very picky | 930 // our superclass HideContents(), because some callers want to be very picky |
920 // about the order in which these get called. In addition to making the code | 931 // about the order in which these get called. In addition to making the code |
921 // here practically impossible to understand, this also means we end up | 932 // here practically impossible to understand, this also means we end up |
922 // calling WebContentsImpl::WasHidden() twice if callers call both versions of | 933 // calling WebContentsImpl::WasHidden() twice if callers call both versions of |
923 // HideContents() on a WebContentsImpl. | 934 // HideContents() on a WebContentsImpl. |
924 WasHidden(); | 935 WasHidden(); |
(...skipping 1863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2788 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2799 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2789 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); | 2800 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); |
2790 // Can be NULL during tests. | 2801 // Can be NULL during tests. |
2791 if (rwh_view) | 2802 if (rwh_view) |
2792 rwh_view->SetSize(GetView()->GetContainerSize()); | 2803 rwh_view->SetSize(GetView()->GetContainerSize()); |
2793 } | 2804 } |
2794 | 2805 |
2795 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { | 2806 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { |
2796 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); | 2807 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); |
2797 } | 2808 } |
OLD | NEW |