Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: content/browser/tab_contents/render_view_host_manager.cc

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/tab_contents/render_view_host_manager.h" 5 #include "content/browser/tab_contents/render_view_host_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "content/browser/content_browser_client.h" 9 #include "content/browser/content_browser_client.h"
10 #include "content/browser/renderer_host/render_view_host.h" 10 #include "content/browser/renderer_host/render_view_host.h"
11 #include "content/browser/renderer_host/render_view_host_delegate.h" 11 #include "content/browser/renderer_host/render_view_host_delegate.h"
12 #include "content/browser/renderer_host/render_view_host_factory.h" 12 #include "content/browser/renderer_host/render_view_host_factory.h"
13 #include "content/browser/renderer_host/render_widget_host_view.h" 13 #include "content/browser/renderer_host/render_widget_host_view.h"
14 #include "content/browser/site_instance.h" 14 #include "content/browser/site_instance.h"
15 #include "content/browser/tab_contents/navigation_controller.h" 15 #include "content/browser/tab_contents/navigation_controller.h"
16 #include "content/browser/tab_contents/navigation_entry.h" 16 #include "content/browser/tab_contents/navigation_entry.h"
17 #include "content/browser/tab_contents/tab_contents_view.h" 17 #include "content/browser/tab_contents/tab_contents_view.h"
18 #include "content/browser/webui/web_ui.h" 18 #include "content/browser/webui/web_ui.h"
19 #include "content/browser/webui/web_ui_factory.h" 19 #include "content/browser/webui/web_ui_factory.h"
20 #include "content/common/content_client.h" 20 #include "content/common/content_client.h"
21 #include "content/common/content_switches.h" 21 #include "content/common/content_switches.h"
22 #include "content/common/notification_service.h" 22 #include "content/common/notification_service.h"
23 #include "content/common/notification_type.h" 23 #include "content/common/content_notification_types.h"
24 #include "content/common/url_constants.h" 24 #include "content/common/url_constants.h"
25 #include "content/common/view_messages.h" 25 #include "content/common/view_messages.h"
26 26
27 namespace base { 27 namespace base {
28 class WaitableEvent; 28 class WaitableEvent;
29 } 29 }
30 30
31 RenderViewHostManager::RenderViewHostManager( 31 RenderViewHostManager::RenderViewHostManager(
32 RenderViewHostDelegate* render_view_delegate, 32 RenderViewHostDelegate* render_view_delegate,
33 Delegate* delegate) 33 Delegate* delegate)
(...skipping 28 matching lines...) Expand all
62 // Create a RenderViewHost, once we have an instance. It is important to 62 // Create a RenderViewHost, once we have an instance. It is important to
63 // immediately give this SiteInstance to a RenderViewHost so that it is 63 // immediately give this SiteInstance to a RenderViewHost so that it is
64 // ref counted. 64 // ref counted.
65 if (!site_instance) 65 if (!site_instance)
66 site_instance = SiteInstance::CreateSiteInstance(profile); 66 site_instance = SiteInstance::CreateSiteInstance(profile);
67 render_view_host_ = RenderViewHostFactory::Create( 67 render_view_host_ = RenderViewHostFactory::Create(
68 site_instance, render_view_delegate_, routing_id, delegate_-> 68 site_instance, render_view_delegate_, routing_id, delegate_->
69 GetControllerForRenderManager().session_storage_namespace()); 69 GetControllerForRenderManager().session_storage_namespace());
70 70
71 // Keep track of renderer processes as they start to shut down. 71 // Keep track of renderer processes as they start to shut down.
72 registrar_.Add(this, NotificationType::RENDERER_PROCESS_CLOSING, 72 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSING,
73 NotificationService::AllSources()); 73 NotificationService::AllSources());
74 } 74 }
75 75
76 RenderWidgetHostView* RenderViewHostManager::GetRenderWidgetHostView() const { 76 RenderWidgetHostView* RenderViewHostManager::GetRenderWidgetHostView() const {
77 if (!render_view_host_) 77 if (!render_view_host_)
78 return NULL; 78 return NULL;
79 return render_view_host_->view(); 79 return render_view_host_->view();
80 } 80 }
81 81
82 RenderViewHost* RenderViewHostManager::Navigate(const NavigationEntry& entry) { 82 RenderViewHost* RenderViewHostManager::Navigate(const NavigationEntry& entry) {
(...skipping 24 matching lines...) Expand all
107 if (dest_render_view_host != render_view_host_ && 107 if (dest_render_view_host != render_view_host_ &&
108 dest_render_view_host->view()) { 108 dest_render_view_host->view()) {
109 dest_render_view_host->view()->Hide(); 109 dest_render_view_host->view()->Hide();
110 } else { 110 } else {
111 // This is our primary renderer, notify here as we won't be calling 111 // This is our primary renderer, notify here as we won't be calling
112 // CommitPending (which does the notify). 112 // CommitPending (which does the notify).
113 RenderViewHostSwitchedDetails details; 113 RenderViewHostSwitchedDetails details;
114 details.new_host = render_view_host_; 114 details.new_host = render_view_host_;
115 details.old_host = NULL; 115 details.old_host = NULL;
116 NotificationService::current()->Notify( 116 NotificationService::current()->Notify(
117 NotificationType::RENDER_VIEW_HOST_CHANGED, 117 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
118 Source<NavigationController>( 118 Source<NavigationController>(
119 &delegate_->GetControllerForRenderManager()), 119 &delegate_->GetControllerForRenderManager()),
120 Details<RenderViewHostSwitchedDetails>(&details)); 120 Details<RenderViewHostSwitchedDetails>(&details));
121 } 121 }
122 } 122 }
123 123
124 return dest_render_view_host; 124 return dest_render_view_host;
125 } 125 }
126 126
127 void RenderViewHostManager::Stop() { 127 void RenderViewHostManager::Stop() {
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 new_request_id); 307 new_request_id);
308 } 308 }
309 309
310 void RenderViewHostManager::OnCrossSiteNavigationCanceled() { 310 void RenderViewHostManager::OnCrossSiteNavigationCanceled() {
311 DCHECK(cross_navigation_pending_); 311 DCHECK(cross_navigation_pending_);
312 cross_navigation_pending_ = false; 312 cross_navigation_pending_ = false;
313 if (pending_render_view_host_) 313 if (pending_render_view_host_)
314 CancelPending(); 314 CancelPending();
315 } 315 }
316 316
317 void RenderViewHostManager::Observe(NotificationType type, 317 void RenderViewHostManager::Observe(int type,
318 const NotificationSource& source, 318 const NotificationSource& source,
319 const NotificationDetails& details) { 319 const NotificationDetails& details) {
320 switch (type.value) { 320 switch (type) {
321 case NotificationType::RENDERER_PROCESS_CLOSING: 321 case content::NOTIFICATION_RENDERER_PROCESS_CLOSING:
322 RendererProcessClosing(Source<RenderProcessHost>(source).ptr()); 322 RendererProcessClosing(Source<RenderProcessHost>(source).ptr());
323 break; 323 break;
324 324
325 default: 325 default:
326 NOTREACHED(); 326 NOTREACHED();
327 } 327 }
328 } 328 }
329 329
330 bool RenderViewHostManager::ShouldTransitionCrossSite() { 330 bool RenderViewHostManager::ShouldTransitionCrossSite() {
331 // True if we are using process-per-site-instance (default) or 331 // True if we are using process-per-site-instance (default) or
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 614
615 if (will_focus_location_bar) 615 if (will_focus_location_bar)
616 delegate_->SetFocusToLocationBar(false); 616 delegate_->SetFocusToLocationBar(false);
617 else if (focus_render_view && render_view_host_->view()) 617 else if (focus_render_view && render_view_host_->view())
618 render_view_host_->view()->Focus(); 618 render_view_host_->view()->Focus();
619 619
620 RenderViewHostSwitchedDetails details; 620 RenderViewHostSwitchedDetails details;
621 details.new_host = render_view_host_; 621 details.new_host = render_view_host_;
622 details.old_host = old_render_view_host; 622 details.old_host = old_render_view_host;
623 NotificationService::current()->Notify( 623 NotificationService::current()->Notify(
624 NotificationType::RENDER_VIEW_HOST_CHANGED, 624 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
625 Source<NavigationController>(&delegate_->GetControllerForRenderManager()), 625 Source<NavigationController>(&delegate_->GetControllerForRenderManager()),
626 Details<RenderViewHostSwitchedDetails>(&details)); 626 Details<RenderViewHostSwitchedDetails>(&details));
627 627
628 // If the pending view was on the swapped out list, we can remove it. 628 // If the pending view was on the swapped out list, we can remove it.
629 swapped_out_hosts_.erase(render_view_host_->site_instance()->id()); 629 swapped_out_hosts_.erase(render_view_host_->site_instance()->id());
630 630
631 // If the old RVH is live, we are swapping it out and should keep track of it 631 // If the old RVH is live, we are swapping it out and should keep track of it
632 // in case we navigate back to it. 632 // in case we navigate back to it.
633 if (old_render_view_host->IsRenderViewLive()) { 633 if (old_render_view_host->IsRenderViewLive()) {
634 DCHECK(old_render_view_host->is_swapped_out()); 634 DCHECK(old_render_view_host->is_swapped_out());
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 old_render_view_host->view()->Hide(); 835 old_render_view_host->view()->Hide();
836 old_render_view_host->WasSwappedOut(); 836 old_render_view_host->WasSwappedOut();
837 } 837 }
838 838
839 delegate_->UpdateRenderViewSizeForRenderManager(); 839 delegate_->UpdateRenderViewSizeForRenderManager();
840 840
841 RenderViewHostSwitchedDetails details; 841 RenderViewHostSwitchedDetails details;
842 details.new_host = render_view_host_; 842 details.new_host = render_view_host_;
843 details.old_host = old_render_view_host; 843 details.old_host = old_render_view_host;
844 NotificationService::current()->Notify( 844 NotificationService::current()->Notify(
845 NotificationType::RENDER_VIEW_HOST_CHANGED, 845 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
846 Source<NavigationController>(&delegate_->GetControllerForRenderManager()), 846 Source<NavigationController>(&delegate_->GetControllerForRenderManager()),
847 Details<RenderViewHostSwitchedDetails>(&details)); 847 Details<RenderViewHostSwitchedDetails>(&details));
848 848
849 // If the given RVH was on the swapped out list, we can remove it. 849 // If the given RVH was on the swapped out list, we can remove it.
850 swapped_out_hosts_.erase(render_view_host_->site_instance()->id()); 850 swapped_out_hosts_.erase(render_view_host_->site_instance()->id());
851 851
852 // If the old RVH is live, we are swapping it out and should keep track of it 852 // If the old RVH is live, we are swapping it out and should keep track of it
853 // in case we navigate back to it. 853 // in case we navigate back to it.
854 if (old_render_view_host->IsRenderViewLive()) { 854 if (old_render_view_host->IsRenderViewLive()) {
855 DCHECK(old_render_view_host->is_swapped_out()); 855 DCHECK(old_render_view_host->is_swapped_out());
856 swapped_out_hosts_[old_render_view_host->site_instance()->id()] = 856 swapped_out_hosts_[old_render_view_host->site_instance()->id()] =
857 old_render_view_host; 857 old_render_view_host;
858 } else { 858 } else {
859 old_render_view_host->Shutdown(); 859 old_render_view_host->Shutdown();
860 } 860 }
861 861
862 // Let the task manager know that we've swapped RenderViewHosts, since it 862 // Let the task manager know that we've swapped RenderViewHosts, since it
863 // might need to update its process groupings. 863 // might need to update its process groupings.
864 delegate_->NotifySwappedFromRenderManager(); 864 delegate_->NotifySwappedFromRenderManager();
865 } 865 }
866 866
867 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { 867 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) {
868 if (!rvh->site_instance()) 868 if (!rvh->site_instance())
869 return false; 869 return false;
870 870
871 return swapped_out_hosts_.find(rvh->site_instance()->id()) != 871 return swapped_out_hosts_.find(rvh->site_instance()->id()) !=
872 swapped_out_hosts_.end(); 872 swapped_out_hosts_.end();
873 } 873 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698