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 #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/site_instance.h" | 12 #include "content/browser/site_instance.h" |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
14 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
16 #include "content/public/browser/render_view_host_delegate.h" | 16 #include "content/public/browser/render_view_host_delegate.h" |
17 | 17 |
18 class InterstitialPage; | 18 class InterstitialPage; |
19 class NavigationControllerImpl; | 19 class NavigationControllerImpl; |
20 class RenderViewHost; | 20 class RenderViewHost; |
21 class RenderWidgetHostView; | 21 class RenderWidgetHostView; |
22 class WebUI; | 22 class WebUIImpl; |
23 | 23 |
24 namespace content { | 24 namespace content { |
25 class BrowserContext; | 25 class BrowserContext; |
26 class NavigationEntry; | 26 class NavigationEntry; |
27 class NavigationEntryImpl; | 27 class NavigationEntryImpl; |
28 } | 28 } |
29 | 29 |
30 // Manages RenderViewHosts for a TabContents. Normally there is only one and | 30 // Manages RenderViewHosts for a TabContents. Normally there is only one and |
31 // it is easy to do. But we can also have transitions of processes (and hence | 31 // it is easy to do. But we can also have transitions of processes (and hence |
32 // RenderViewHosts) that can get complex. | 32 // RenderViewHosts) that can get complex. |
(...skipping 28 matching lines...) Expand all Loading... |
61 RenderViewHost* render_view_host) = 0; | 61 RenderViewHost* render_view_host) = 0; |
62 virtual void RenderViewGoneFromRenderManager( | 62 virtual void RenderViewGoneFromRenderManager( |
63 RenderViewHost* render_view_host) = 0; | 63 RenderViewHost* render_view_host) = 0; |
64 virtual void UpdateRenderViewSizeForRenderManager() = 0; | 64 virtual void UpdateRenderViewSizeForRenderManager() = 0; |
65 virtual void NotifySwappedFromRenderManager() = 0; | 65 virtual void NotifySwappedFromRenderManager() = 0; |
66 virtual NavigationControllerImpl& GetControllerForRenderManager() = 0; | 66 virtual NavigationControllerImpl& GetControllerForRenderManager() = 0; |
67 | 67 |
68 // Creates a WebUI object for the given URL if one applies. Ownership of the | 68 // Creates a WebUI object for the given URL if one applies. Ownership of the |
69 // returned pointer will be passed to the caller. If no WebUI applies, | 69 // returned pointer will be passed to the caller. If no WebUI applies, |
70 // returns NULL. | 70 // returns NULL. |
71 virtual WebUI* CreateWebUIForRenderManager(const GURL& url) = 0; | 71 virtual WebUIImpl* CreateWebUIForRenderManager(const GURL& url) = 0; |
72 | 72 |
73 // Returns the navigation entry of the current navigation, or NULL if there | 73 // Returns the navigation entry of the current navigation, or NULL if there |
74 // is none. | 74 // is none. |
75 virtual content::NavigationEntry* | 75 virtual content::NavigationEntry* |
76 GetLastCommittedNavigationEntryForRenderManager() = 0; | 76 GetLastCommittedNavigationEntryForRenderManager() = 0; |
77 | 77 |
78 // Returns true if the location bar should be focused by default rather than | 78 // Returns true if the location bar should be focused by default rather than |
79 // the page contents. The view calls this function when the tab is focused | 79 // the page contents. The view calls this function when the tab is focused |
80 // to see what it should do. | 80 // to see what it should do. |
81 virtual bool FocusLocationBarByDefault() = 0; | 81 virtual bool FocusLocationBarByDefault() = 0; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // Returns the view associated with the current RenderViewHost, or NULL if | 116 // Returns the view associated with the current RenderViewHost, or NULL if |
117 // there is no current one. | 117 // there is no current one. |
118 RenderWidgetHostView* GetRenderWidgetHostView() const; | 118 RenderWidgetHostView* GetRenderWidgetHostView() const; |
119 | 119 |
120 // Returns the pending render view host, or NULL if there is no pending one. | 120 // Returns the pending render view host, or NULL if there is no pending one. |
121 RenderViewHost* pending_render_view_host() const { | 121 RenderViewHost* pending_render_view_host() const { |
122 return pending_render_view_host_; | 122 return pending_render_view_host_; |
123 } | 123 } |
124 | 124 |
125 // Returns the current committed Web UI or NULL if none applies. | 125 // Returns the current committed Web UI or NULL if none applies. |
126 WebUI* web_ui() const { return web_ui_.get(); } | 126 WebUIImpl* web_ui() const { return web_ui_.get(); } |
127 | 127 |
128 // Returns the Web UI for the pending navigation, or NULL of none applies. | 128 // Returns the Web UI for the pending navigation, or NULL of none applies. |
129 WebUI* pending_web_ui() const { return pending_web_ui_.get(); } | 129 WebUIImpl* pending_web_ui() const { return pending_web_ui_.get(); } |
130 | 130 |
131 // Called when we want to instruct the renderer to navigate to the given | 131 // Called when we want to instruct the renderer to navigate to the given |
132 // navigation entry. It may create a new RenderViewHost or re-use an existing | 132 // navigation entry. It may create a new RenderViewHost or re-use an existing |
133 // one. The RenderViewHost to navigate will be returned. Returns NULL if one | 133 // one. The RenderViewHost to navigate will be returned. Returns NULL if one |
134 // could not be created. | 134 // could not be created. |
135 RenderViewHost* Navigate(const content::NavigationEntryImpl& entry); | 135 RenderViewHost* Navigate(const content::NavigationEntryImpl& entry); |
136 | 136 |
137 // Instructs the various live views to stop. Called when the user directed the | 137 // Instructs the various live views to stop. Called when the user directed the |
138 // page to stop loading. | 138 // page to stop loading. |
139 void Stop(); | 139 void Stop(); |
140 | 140 |
141 // Notifies the regular and pending RenderViewHosts that a load is or is not | 141 // Notifies the regular and pending RenderViewHosts that a load is or is not |
142 // happening. Even though the message is only for one of them, we don't know | 142 // happening. Even though the message is only for one of them, we don't know |
143 // which one so we tell both. | 143 // which one so we tell both. |
144 void SetIsLoading(bool is_loading); | 144 void SetIsLoading(bool is_loading); |
145 | 145 |
146 // Whether to close the tab or not when there is a hang during an unload | 146 // Whether to close the tab or not when there is a hang during an unload |
147 // handler. If we are mid-crosssite navigation, then we should proceed | 147 // handler. If we are mid-crosssite navigation, then we should proceed |
148 // with the navigation instead of closing the tab. | 148 // with the navigation instead of closing the tab. |
149 bool ShouldCloseTabOnUnresponsiveRenderer(); | 149 bool ShouldCloseTabOnUnresponsiveRenderer(); |
150 | 150 |
151 // Called when a renderer's main frame navigates. | 151 // Called when a renderer's main frame navigates. |
152 void DidNavigateMainFrame(RenderViewHost* render_view_host); | 152 void DidNavigateMainFrame(RenderViewHost* render_view_host); |
153 | 153 |
154 // Set the WebUI after committing a page load. This is useful for navigations | 154 // Set the WebUI after committing a page load. This is useful for navigations |
155 // initiated from a renderer, where we want to give the new renderer WebUI | 155 // initiated from a renderer, where we want to give the new renderer WebUI |
156 // privileges from the originating renderer. | 156 // privileges from the originating renderer. |
157 void SetWebUIPostCommit(WebUI* web_ui); | 157 void SetWebUIPostCommit(WebUIImpl* web_ui); |
158 | 158 |
159 // Called when a provisional load on the given renderer is aborted. | 159 // Called when a provisional load on the given renderer is aborted. |
160 void RendererAbortedProvisionalLoad(RenderViewHost* render_view_host); | 160 void RendererAbortedProvisionalLoad(RenderViewHost* render_view_host); |
161 | 161 |
162 // Sets the passed passed interstitial as the currently showing interstitial. | 162 // Sets the passed passed interstitial as the currently showing interstitial. |
163 // |interstitial_page| should be non NULL (use the remove_interstitial_page | 163 // |interstitial_page| should be non NULL (use the remove_interstitial_page |
164 // method to unset the interstitial) and no interstitial page should be set | 164 // method to unset the interstitial) and no interstitial page should be set |
165 // when there is already a non NULL interstitial page set. | 165 // when there is already a non NULL interstitial page set. |
166 void set_interstitial_page(InterstitialPage* interstitial_page) { | 166 void set_interstitial_page(InterstitialPage* interstitial_page) { |
167 DCHECK(!interstitial_page_ && interstitial_page); | 167 DCHECK(!interstitial_page_ && interstitial_page); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 bool cross_navigation_pending_; | 258 bool cross_navigation_pending_; |
259 | 259 |
260 // Implemented by the owner of this class, this delegate is installed into all | 260 // Implemented by the owner of this class, this delegate is installed into all |
261 // the RenderViewHosts that we create. | 261 // the RenderViewHosts that we create. |
262 content::RenderViewHostDelegate* render_view_delegate_; | 262 content::RenderViewHostDelegate* render_view_delegate_; |
263 | 263 |
264 // Our RenderView host and its associated Web UI (if any, will be NULL for | 264 // Our RenderView host and its associated Web UI (if any, will be NULL for |
265 // non-DOM-UI pages). This object is responsible for all communication with | 265 // non-DOM-UI pages). This object is responsible for all communication with |
266 // a child RenderView instance. | 266 // a child RenderView instance. |
267 RenderViewHost* render_view_host_; | 267 RenderViewHost* render_view_host_; |
268 scoped_ptr<WebUI> web_ui_; | 268 scoped_ptr<WebUIImpl> web_ui_; |
269 | 269 |
270 // A RenderViewHost used to load a cross-site page. This remains hidden | 270 // A RenderViewHost used to load a cross-site page. This remains hidden |
271 // while a cross-site request is pending until it calls DidNavigate. It may | 271 // while a cross-site request is pending until it calls DidNavigate. It may |
272 // have an associated Web UI, in which case the Web UI pointer will be non- | 272 // have an associated Web UI, in which case the Web UI pointer will be non- |
273 // NULL. | 273 // NULL. |
274 // | 274 // |
275 // The pending_web_ui may be non-NULL even when the pending_render_view_host_ | 275 // The pending_web_ui may be non-NULL even when the pending_render_view_host_ |
276 // is. This will happen when we're transitioning between two Web UI pages: | 276 // is. This will happen when we're transitioning between two Web UI pages: |
277 // the RVH won't be swapped, so the pending pointer will be unused, but there | 277 // the RVH won't be swapped, so the pending pointer will be unused, but there |
278 // will be a pending Web UI associated with the navigation. | 278 // will be a pending Web UI associated with the navigation. |
279 RenderViewHost* pending_render_view_host_; | 279 RenderViewHost* pending_render_view_host_; |
280 scoped_ptr<WebUI> pending_web_ui_; | 280 scoped_ptr<WebUIImpl> pending_web_ui_; |
281 | 281 |
282 // A map of site instance ID to swapped out RenderViewHosts. | 282 // A map of site instance ID to swapped out RenderViewHosts. |
283 typedef base::hash_map<int32, RenderViewHost*> RenderViewHostMap; | 283 typedef base::hash_map<int32, RenderViewHost*> RenderViewHostMap; |
284 RenderViewHostMap swapped_out_hosts_; | 284 RenderViewHostMap swapped_out_hosts_; |
285 | 285 |
286 // The intersitial page currently shown if any, not own by this class | 286 // The intersitial page currently shown if any, not own by this class |
287 // (the InterstitialPage is self-owned, it deletes itself when hidden). | 287 // (the InterstitialPage is self-owned, it deletes itself when hidden). |
288 InterstitialPage* interstitial_page_; | 288 InterstitialPage* interstitial_page_; |
289 | 289 |
290 content::NotificationRegistrar registrar_; | 290 content::NotificationRegistrar registrar_; |
291 | 291 |
292 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManager); | 292 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManager); |
293 }; | 293 }; |
294 | 294 |
295 #endif // CONTENT_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ | 295 #endif // CONTENT_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ |
OLD | NEW |