Chromium Code Reviews| 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) | 356 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) |
| 357 g_created_callbacks.Get().at(i).Run(this); | 357 g_created_callbacks.Get().at(i).Run(this); |
| 358 frame_tree_.SetFrameRemoveListener( | 358 frame_tree_.SetFrameRemoveListener( |
| 359 base::Bind(&WebContentsImpl::OnFrameRemoved, | 359 base::Bind(&WebContentsImpl::OnFrameRemoved, |
| 360 base::Unretained(this))); | 360 base::Unretained(this))); |
| 361 } | 361 } |
| 362 | 362 |
| 363 WebContentsImpl::~WebContentsImpl() { | 363 WebContentsImpl::~WebContentsImpl() { |
| 364 is_being_destroyed_ = true; | 364 is_being_destroyed_ = true; |
| 365 | 365 |
| 366 // Update SiteInstance reference counts. | |
| 367 static_cast<SiteInstanceImpl*>(GetSiteInstance())-> | |
| 368 DecrementRelatedActiveContentsCount(); | |
| 369 | |
| 366 // Delete all RFH pending shutdown, which will lead the corresponding RVH to | 370 // Delete all RFH pending shutdown, which will lead the corresponding RVH to |
| 367 // shutdown and be deleted as well. | 371 // shutdown and be deleted as well. |
| 368 frame_tree_.ForEach( | 372 frame_tree_.ForEach( |
| 369 base::Bind(&RenderFrameHostManager::ClearRFHsPendingShutdown)); | 373 base::Bind(&RenderFrameHostManager::ClearRFHsPendingShutdown)); |
| 370 | 374 |
| 371 ClearAllPowerSaveBlockers(); | 375 ClearAllPowerSaveBlockers(); |
| 372 | 376 |
| 373 for (std::set<RenderWidgetHostImpl*>::iterator iter = | 377 for (std::set<RenderWidgetHostImpl*>::iterator iter = |
| 374 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) { | 378 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) { |
| 375 (*iter)->DetachDelegate(); | 379 (*iter)->DetachDelegate(); |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1063 void WebContentsImpl::Init(const WebContents::CreateParams& params) { | 1067 void WebContentsImpl::Init(const WebContents::CreateParams& params) { |
| 1064 // This is set before initializing the render manager since | 1068 // This is set before initializing the render manager since |
| 1065 // RenderFrameHostManager::Init calls back into us via its delegate to ask if | 1069 // RenderFrameHostManager::Init calls back into us via its delegate to ask if |
| 1066 // it should be hidden. | 1070 // it should be hidden. |
| 1067 should_normally_be_visible_ = !params.initially_hidden; | 1071 should_normally_be_visible_ = !params.initially_hidden; |
| 1068 | 1072 |
| 1069 GetRenderManager()->Init( | 1073 GetRenderManager()->Init( |
| 1070 params.browser_context, params.site_instance, params.routing_id, | 1074 params.browser_context, params.site_instance, params.routing_id, |
| 1071 params.main_frame_routing_id); | 1075 params.main_frame_routing_id); |
| 1072 | 1076 |
| 1077 // Update SiteInstance reference counts. | |
|
Charlie Reis
2014/04/29 22:13:51
It feels strange to do this in WebContents rather
davidben
2014/04/29 23:02:26
Moved it to RFHM. It's much much cleaner this way.
| |
| 1078 static_cast<SiteInstanceImpl*>(GetSiteInstance())-> | |
| 1079 IncrementRelatedActiveContentsCount(); | |
| 1080 | |
| 1073 view_.reset(GetContentClient()->browser()-> | 1081 view_.reset(GetContentClient()->browser()-> |
| 1074 OverrideCreateWebContentsView(this, &render_view_host_delegate_view_)); | 1082 OverrideCreateWebContentsView(this, &render_view_host_delegate_view_)); |
| 1075 if (view_) { | 1083 if (view_) { |
| 1076 CHECK(render_view_host_delegate_view_); | 1084 CHECK(render_view_host_delegate_view_); |
| 1077 } else { | 1085 } else { |
| 1078 WebContentsViewDelegate* delegate = | 1086 WebContentsViewDelegate* delegate = |
| 1079 GetContentClient()->browser()->GetWebContentsViewDelegate(this); | 1087 GetContentClient()->browser()->GetWebContentsViewDelegate(this); |
| 1080 | 1088 |
| 1081 if (browser_plugin_guest_) { | 1089 if (browser_plugin_guest_) { |
| 1082 scoped_ptr<WebContentsViewPort> platform_view(CreateWebContentsView( | 1090 scoped_ptr<WebContentsViewPort> platform_view(CreateWebContentsView( |
| (...skipping 1891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2974 NotificationService::current()->Notify( | 2982 NotificationService::current()->Notify( |
| 2975 NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, | 2983 NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, |
| 2976 Source<WebContents>(this), | 2984 Source<WebContents>(this), |
| 2977 Details<std::pair<NavigationEntry*, bool> >(&details)); | 2985 Details<std::pair<NavigationEntry*, bool> >(&details)); |
| 2978 | 2986 |
| 2979 return true; | 2987 return true; |
| 2980 } | 2988 } |
| 2981 | 2989 |
| 2982 void WebContentsImpl::NotifySwapped(RenderViewHost* old_host, | 2990 void WebContentsImpl::NotifySwapped(RenderViewHost* old_host, |
| 2983 RenderViewHost* new_host) { | 2991 RenderViewHost* new_host) { |
| 2992 if (old_host) { | |
| 2993 // Update BrowsingInstance active contents counts. If |old_host| is NULL, | |
| 2994 // this is a "swap" for a crashed RVH and shouldn't be counted. This should | |
| 2995 // be a no-op unless this contents swapped browsing instances due to WebUI | |
| 2996 // or so. | |
| 2997 static_cast<SiteInstanceImpl*>(new_host->GetSiteInstance())-> | |
| 2998 IncrementRelatedActiveContentsCount(); | |
| 2999 static_cast<SiteInstanceImpl*>(old_host->GetSiteInstance())-> | |
| 3000 DecrementRelatedActiveContentsCount(); | |
| 3001 } | |
| 3002 | |
| 2984 // After sending out a swap notification, we need to send a disconnect | 3003 // After sending out a swap notification, we need to send a disconnect |
| 2985 // notification so that clients that pick up a pointer to |this| can NULL the | 3004 // notification so that clients that pick up a pointer to |this| can NULL the |
| 2986 // pointer. See Bug 1230284. | 3005 // pointer. See Bug 1230284. |
| 2987 notify_disconnection_ = true; | 3006 notify_disconnection_ = true; |
| 2988 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3007 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2989 RenderViewHostChanged(old_host, new_host)); | 3008 RenderViewHostChanged(old_host, new_host)); |
| 2990 | 3009 |
| 2991 // TODO(avi): Remove. http://crbug.com/170921 | 3010 // TODO(avi): Remove. http://crbug.com/170921 |
| 2992 std::pair<RenderViewHost*, RenderViewHost*> details = | 3011 std::pair<RenderViewHost*, RenderViewHost*> details = |
| 2993 std::make_pair(old_host, new_host); | 3012 std::make_pair(old_host, new_host); |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3904 | 3923 |
| 3905 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { | 3924 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { |
| 3906 if (!delegate_) | 3925 if (!delegate_) |
| 3907 return; | 3926 return; |
| 3908 const gfx::Size new_size = GetPreferredSize(); | 3927 const gfx::Size new_size = GetPreferredSize(); |
| 3909 if (new_size != old_size) | 3928 if (new_size != old_size) |
| 3910 delegate_->UpdatePreferredSize(this, new_size); | 3929 delegate_->UpdatePreferredSize(this, new_size); |
| 3911 } | 3930 } |
| 3912 | 3931 |
| 3913 } // namespace content | 3932 } // namespace content |
| OLD | NEW |