OLD | NEW |
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 #ifndef CONTENT_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ |
6 #define CONTENT_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ | 6 #define CONTENT_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "content/browser/renderer_host/render_view_host_delegate.h" | 12 #include "content/browser/renderer_host/render_view_host_delegate.h" |
13 #include "content/common/notification_registrar.h" | 13 #include "content/common/notification_registrar.h" |
| 14 #include "content/browser/site_instance.h" |
14 | 15 |
15 class WebUI; | 16 class WebUI; |
16 class InterstitialPage; | 17 class InterstitialPage; |
17 class NavigationController; | 18 class NavigationController; |
18 class NavigationEntry; | 19 class NavigationEntry; |
19 class Profile; | 20 class Profile; |
20 class RenderWidgetHostView; | 21 class RenderWidgetHostView; |
21 class RenderViewHost; | 22 class RenderViewHost; |
22 class SiteInstance; | |
23 | 23 |
24 // Manages RenderViewHosts for a TabContents. Normally there is only one and | 24 // Manages RenderViewHosts for a TabContents. Normally there is only one and |
25 // it is easy to do. But we can also have transitions of processes (and hence | 25 // it is easy to do. But we can also have transitions of processes (and hence |
26 // RenderViewHosts) that can get complex. | 26 // RenderViewHosts) that can get complex. |
27 class RenderViewHostManager | 27 class RenderViewHostManager |
28 : public RenderViewHostDelegate::RendererManagement { | 28 : public RenderViewHostDelegate::RendererManagement { |
29 public: | 29 public: |
30 // Functions implemented by our owner that we need. | 30 // Functions implemented by our owner that we need. |
31 // | 31 // |
32 // TODO(brettw) Clean this up! These are all the functions in TabContents that | 32 // TODO(brettw) Clean this up! These are all the functions in TabContents that |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 void DidNavigateMainFrame(RenderViewHost* render_view_host); | 137 void DidNavigateMainFrame(RenderViewHost* render_view_host); |
138 | 138 |
139 // Set the WebUI after committing a page load. This is useful for navigations | 139 // Set the WebUI after committing a page load. This is useful for navigations |
140 // initiated from a renderer, where we want to give the new renderer WebUI | 140 // initiated from a renderer, where we want to give the new renderer WebUI |
141 // privileges from the originating renderer. | 141 // privileges from the originating renderer. |
142 void SetWebUIPostCommit(WebUI* web_ui); | 142 void SetWebUIPostCommit(WebUI* web_ui); |
143 | 143 |
144 // Called when a provisional load on the given renderer is aborted. | 144 // Called when a provisional load on the given renderer is aborted. |
145 void RendererAbortedProvisionalLoad(RenderViewHost* render_view_host); | 145 void RendererAbortedProvisionalLoad(RenderViewHost* render_view_host); |
146 | 146 |
| 147 // Called when a renderer process is starting to close. We should not |
| 148 // schedule new navigations in its swapped out RenderViewHosts after this. |
| 149 void RendererProcessClosing(RenderProcessHost* render_process_host); |
| 150 |
147 // Sets the passed passed interstitial as the currently showing interstitial. | 151 // Sets the passed passed interstitial as the currently showing interstitial. |
148 // |interstitial_page| should be non NULL (use the remove_interstitial_page | 152 // |interstitial_page| should be non NULL (use the remove_interstitial_page |
149 // method to unset the interstitial) and no interstitial page should be set | 153 // method to unset the interstitial) and no interstitial page should be set |
150 // when there is already a non NULL interstitial page set. | 154 // when there is already a non NULL interstitial page set. |
151 void set_interstitial_page(InterstitialPage* interstitial_page) { | 155 void set_interstitial_page(InterstitialPage* interstitial_page) { |
152 DCHECK(!interstitial_page_ && interstitial_page); | 156 DCHECK(!interstitial_page_ && interstitial_page); |
153 interstitial_page_ = interstitial_page; | 157 interstitial_page_ = interstitial_page; |
154 } | 158 } |
155 | 159 |
156 // Unsets the currently showing interstitial. | 160 // Unsets the currently showing interstitial. |
(...skipping 15 matching lines...) Expand all Loading... |
172 virtual void OnCrossSiteNavigationCanceled(); | 176 virtual void OnCrossSiteNavigationCanceled(); |
173 | 177 |
174 // Called when a RenderViewHost is about to be deleted. | 178 // Called when a RenderViewHost is about to be deleted. |
175 void RenderViewDeleted(RenderViewHost* rvh); | 179 void RenderViewDeleted(RenderViewHost* rvh); |
176 | 180 |
177 // Allows a caller to swap in a provided RenderViewHost to replace the | 181 // Allows a caller to swap in a provided RenderViewHost to replace the |
178 // current RenderViewHost. The current RVH will be shutdown and ultimately | 182 // current RenderViewHost. The current RVH will be shutdown and ultimately |
179 // deleted. | 183 // deleted. |
180 void SwapInRenderViewHost(RenderViewHost* rvh); | 184 void SwapInRenderViewHost(RenderViewHost* rvh); |
181 | 185 |
| 186 // Returns whether the given RenderViewHost is on the list of swapped out |
| 187 // RenderViewHosts. |
| 188 bool IsSwappedOut(RenderViewHost* rvh); |
| 189 |
182 private: | 190 private: |
183 friend class TestTabContents; | 191 friend class TestTabContents; |
184 friend class RenderViewHostManagerTest; | 192 friend class RenderViewHostManagerTest; |
185 | 193 |
186 // Returns whether this tab should transition to a new renderer for | 194 // Returns whether this tab should transition to a new renderer for |
187 // cross-site URLs. Enabled unless we see the --process-per-tab command line | 195 // cross-site URLs. Enabled unless we see the --process-per-tab command line |
188 // switch. Can be overridden in unit tests. | 196 // switch. Can be overridden in unit tests. |
189 bool ShouldTransitionCrossSite(); | 197 bool ShouldTransitionCrossSite(); |
190 | 198 |
191 // Returns true if the two navigation entries are incompatible in some way | 199 // Returns true if the two navigation entries are incompatible in some way |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 // have an associated Web UI, in which case the Web UI pointer will be non- | 255 // have an associated Web UI, in which case the Web UI pointer will be non- |
248 // NULL. | 256 // NULL. |
249 // | 257 // |
250 // The pending_web_ui may be non-NULL even when the pending_render_view_host_ | 258 // The pending_web_ui may be non-NULL even when the pending_render_view_host_ |
251 // is. This will happen when we're transitioning between two Web UI pages: | 259 // is. This will happen when we're transitioning between two Web UI pages: |
252 // the RVH won't be swapped, so the pending pointer will be unused, but there | 260 // the RVH won't be swapped, so the pending pointer will be unused, but there |
253 // will be a pending Web UI associated with the navigation. | 261 // will be a pending Web UI associated with the navigation. |
254 RenderViewHost* pending_render_view_host_; | 262 RenderViewHost* pending_render_view_host_; |
255 scoped_ptr<WebUI> pending_web_ui_; | 263 scoped_ptr<WebUI> pending_web_ui_; |
256 | 264 |
| 265 // A map of site instance ID to swapped out RenderViewHosts. |
| 266 typedef base::hash_map<int32, RenderViewHost*> RenderViewHostMap; |
| 267 RenderViewHostMap swapped_out_hosts_; |
| 268 |
257 // The intersitial page currently shown if any, not own by this class | 269 // The intersitial page currently shown if any, not own by this class |
258 // (the InterstitialPage is self-owned, it deletes itself when hidden). | 270 // (the InterstitialPage is self-owned, it deletes itself when hidden). |
259 InterstitialPage* interstitial_page_; | 271 InterstitialPage* interstitial_page_; |
260 | 272 |
261 NotificationRegistrar registrar_; | 273 NotificationRegistrar registrar_; |
262 | 274 |
263 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManager); | 275 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManager); |
264 }; | 276 }; |
265 | 277 |
266 // The "details" for a NOTIFY_RENDER_VIEW_HOST_CHANGED notification. The old | 278 // The "details" for a NOTIFY_RENDER_VIEW_HOST_CHANGED notification. The old |
267 // host can be NULL when the first RenderViewHost is set. | 279 // host can be NULL when the first RenderViewHost is set. |
268 struct RenderViewHostSwitchedDetails { | 280 struct RenderViewHostSwitchedDetails { |
269 RenderViewHost* old_host; | 281 RenderViewHost* old_host; |
270 RenderViewHost* new_host; | 282 RenderViewHost* new_host; |
271 }; | 283 }; |
272 | 284 |
273 #endif // CONTENT_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ | 285 #endif // CONTENT_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ |
OLD | NEW |