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

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

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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/renderer_host/render_view_host.h" 9 #include "content/browser/renderer_host/render_view_host.h"
10 #include "content/browser/renderer_host/render_view_host_delegate.h" 10 #include "content/browser/renderer_host/render_view_host_delegate.h"
11 #include "content/browser/renderer_host/render_view_host_factory.h" 11 #include "content/browser/renderer_host/render_view_host_factory.h"
12 #include "content/browser/renderer_host/render_widget_host_view.h" 12 #include "content/browser/renderer_host/render_widget_host_view.h"
13 #include "content/browser/site_instance.h" 13 #include "content/browser/site_instance.h"
14 #include "content/browser/tab_contents/navigation_controller.h" 14 #include "content/browser/tab_contents/navigation_controller.h"
15 #include "content/browser/tab_contents/navigation_entry.h" 15 #include "content/browser/tab_contents/navigation_entry.h"
16 #include "content/browser/tab_contents/tab_contents_view.h" 16 #include "content/browser/tab_contents/tab_contents_view.h"
17 #include "content/browser/webui/web_ui.h" 17 #include "content/browser/webui/web_ui.h"
18 #include "content/browser/webui/web_ui_factory.h" 18 #include "content/browser/webui/web_ui_factory.h"
19 #include "content/common/notification_service.h" 19 #include "content/public/browser/notification_service.h"
20 #include "content/common/view_messages.h" 20 #include "content/common/view_messages.h"
21 #include "content/public/browser/content_browser_client.h" 21 #include "content/public/browser/content_browser_client.h"
22 #include "content/public/browser/notification_types.h" 22 #include "content/public/browser/notification_types.h"
23 #include "content/public/common/content_switches.h" 23 #include "content/public/common/content_switches.h"
24 #include "content/public/common/url_constants.h" 24 #include "content/public/common/url_constants.h"
25 25
26 namespace base { 26 namespace base {
27 class WaitableEvent; 27 class WaitableEvent;
28 } 28 }
29 29
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // immediately give this SiteInstance to a RenderViewHost so that it is 62 // immediately give this SiteInstance to a RenderViewHost so that it is
63 // ref counted. 63 // ref counted.
64 if (!site_instance) 64 if (!site_instance)
65 site_instance = SiteInstance::CreateSiteInstance(browser_context); 65 site_instance = SiteInstance::CreateSiteInstance(browser_context);
66 render_view_host_ = RenderViewHostFactory::Create( 66 render_view_host_ = RenderViewHostFactory::Create(
67 site_instance, render_view_delegate_, routing_id, delegate_-> 67 site_instance, render_view_delegate_, routing_id, delegate_->
68 GetControllerForRenderManager().session_storage_namespace()); 68 GetControllerForRenderManager().session_storage_namespace());
69 69
70 // Keep track of renderer processes as they start to shut down. 70 // Keep track of renderer processes as they start to shut down.
71 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSING, 71 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSING,
72 NotificationService::AllSources()); 72 content::NotificationService::AllSources());
73 } 73 }
74 74
75 RenderWidgetHostView* RenderViewHostManager::GetRenderWidgetHostView() const { 75 RenderWidgetHostView* RenderViewHostManager::GetRenderWidgetHostView() const {
76 if (!render_view_host_) 76 if (!render_view_host_)
77 return NULL; 77 return NULL;
78 return render_view_host_->view(); 78 return render_view_host_->view();
79 } 79 }
80 80
81 RenderViewHost* RenderViewHostManager::Navigate(const NavigationEntry& entry) { 81 RenderViewHost* RenderViewHostManager::Navigate(const NavigationEntry& entry) {
82 // Create a pending RenderViewHost. It will give us the one we should use 82 // Create a pending RenderViewHost. It will give us the one we should use
(...skipping 22 matching lines...) Expand all
105 // on it later. 105 // on it later.
106 if (dest_render_view_host != render_view_host_ && 106 if (dest_render_view_host != render_view_host_ &&
107 dest_render_view_host->view()) { 107 dest_render_view_host->view()) {
108 dest_render_view_host->view()->Hide(); 108 dest_render_view_host->view()->Hide();
109 } else { 109 } else {
110 // This is our primary renderer, notify here as we won't be calling 110 // This is our primary renderer, notify here as we won't be calling
111 // CommitPending (which does the notify). 111 // CommitPending (which does the notify).
112 RenderViewHostSwitchedDetails details; 112 RenderViewHostSwitchedDetails details;
113 details.new_host = render_view_host_; 113 details.new_host = render_view_host_;
114 details.old_host = NULL; 114 details.old_host = NULL;
115 NotificationService::current()->Notify( 115 content::NotificationService::current()->Notify(
116 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 116 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
117 content::Source<NavigationController>( 117 content::Source<NavigationController>(
118 &delegate_->GetControllerForRenderManager()), 118 &delegate_->GetControllerForRenderManager()),
119 content::Details<RenderViewHostSwitchedDetails>(&details)); 119 content::Details<RenderViewHostSwitchedDetails>(&details));
120 } 120 }
121 } 121 }
122 122
123 return dest_render_view_host; 123 return dest_render_view_host;
124 } 124 }
125 125
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 delegate_->UpdateRenderViewSizeForRenderManager(); 606 delegate_->UpdateRenderViewSizeForRenderManager();
607 607
608 if (will_focus_location_bar) 608 if (will_focus_location_bar)
609 delegate_->SetFocusToLocationBar(false); 609 delegate_->SetFocusToLocationBar(false);
610 else if (focus_render_view && render_view_host_->view()) 610 else if (focus_render_view && render_view_host_->view())
611 render_view_host_->view()->Focus(); 611 render_view_host_->view()->Focus();
612 612
613 RenderViewHostSwitchedDetails details; 613 RenderViewHostSwitchedDetails details;
614 details.new_host = render_view_host_; 614 details.new_host = render_view_host_;
615 details.old_host = old_render_view_host; 615 details.old_host = old_render_view_host;
616 NotificationService::current()->Notify( 616 content::NotificationService::current()->Notify(
617 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 617 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
618 content::Source<NavigationController>( 618 content::Source<NavigationController>(
619 &delegate_->GetControllerForRenderManager()), 619 &delegate_->GetControllerForRenderManager()),
620 content::Details<RenderViewHostSwitchedDetails>(&details)); 620 content::Details<RenderViewHostSwitchedDetails>(&details));
621 621
622 // If the pending view was on the swapped out list, we can remove it. 622 // If the pending view was on the swapped out list, we can remove it.
623 swapped_out_hosts_.erase(render_view_host_->site_instance()->id()); 623 swapped_out_hosts_.erase(render_view_host_->site_instance()->id());
624 624
625 // If the old RVH is live, we are swapping it out and should keep track of it 625 // If the old RVH is live, we are swapping it out and should keep track of it
626 // in case we navigate back to it. 626 // in case we navigate back to it.
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 } 802 }
803 } 803 }
804 804
805 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { 805 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) {
806 if (!rvh->site_instance()) 806 if (!rvh->site_instance())
807 return false; 807 return false;
808 808
809 return swapped_out_hosts_.find(rvh->site_instance()->id()) != 809 return swapped_out_hosts_.find(rvh->site_instance()->id()) !=
810 swapped_out_hosts_.end(); 810 swapped_out_hosts_.end();
811 } 811 }
OLDNEW
« no previous file with comments | « content/browser/tab_contents/navigation_controller.cc ('k') | content/browser/tab_contents/tab_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698