| 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_WEB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_WEB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ | 6 #define CONTENT_BROWSER_WEB_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" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 public: | 50 public: |
| 51 // Initializes the given renderer if necessary and creates the view ID | 51 // Initializes the given renderer if necessary and creates the view ID |
| 52 // corresponding to this view host. If this method is not called and the | 52 // corresponding to this view host. If this method is not called and the |
| 53 // process is not shared, then the WebContentsImpl will act as though the | 53 // process is not shared, then the WebContentsImpl will act as though the |
| 54 // renderer is not running (i.e., it will render "sad tab"). This method is | 54 // renderer is not running (i.e., it will render "sad tab"). This method is |
| 55 // automatically called from LoadURL. | 55 // automatically called from LoadURL. |
| 56 // | 56 // |
| 57 // If you are attaching to an already-existing RenderView, you should call | 57 // If you are attaching to an already-existing RenderView, you should call |
| 58 // InitWithExistingID. | 58 // InitWithExistingID. |
| 59 virtual bool CreateRenderViewForRenderManager( | 59 virtual bool CreateRenderViewForRenderManager( |
| 60 content::RenderViewHost* render_view_host) = 0; | 60 content::RenderViewHost* render_view_host, int opener_route_id) = 0; |
| 61 virtual void BeforeUnloadFiredFromRenderManager( | 61 virtual void BeforeUnloadFiredFromRenderManager( |
| 62 bool proceed, bool* proceed_to_fire_unload) = 0; | 62 bool proceed, bool* proceed_to_fire_unload) = 0; |
| 63 virtual void DidStartLoadingFromRenderManager( | 63 virtual void DidStartLoadingFromRenderManager( |
| 64 content::RenderViewHost* render_view_host) = 0; | 64 content::RenderViewHost* render_view_host) = 0; |
| 65 virtual void RenderViewGoneFromRenderManager( | 65 virtual void RenderViewGoneFromRenderManager( |
| 66 content::RenderViewHost* render_view_host) = 0; | 66 content::RenderViewHost* render_view_host) = 0; |
| 67 virtual void UpdateRenderViewSizeForRenderManager() = 0; | 67 virtual void UpdateRenderViewSizeForRenderManager() = 0; |
| 68 virtual void NotifySwappedFromRenderManager() = 0; | 68 virtual void NotifySwappedFromRenderManager() = 0; |
| 69 virtual NavigationControllerImpl& GetControllerForRenderManager() = 0; | 69 virtual NavigationControllerImpl& GetControllerForRenderManager() = 0; |
| 70 | 70 |
| 71 // Create swapped out RenderViews in the given SiteInstance for each tab in |
| 72 // the opener chain of this tab, if any. This allows the current tab to |
| 73 // make cross-process script calls to its opener(s). Returns the route ID |
| 74 // of the immediate opener, if one exists (otherwise MSG_ROUTING_NONE). |
| 75 virtual int CreateOpenerRenderViewsForRenderManager( |
| 76 content::SiteInstance* instance) = 0; |
| 77 |
| 71 // Creates a WebUI object for the given URL if one applies. Ownership of the | 78 // Creates a WebUI object for the given URL if one applies. Ownership of the |
| 72 // returned pointer will be passed to the caller. If no WebUI applies, | 79 // returned pointer will be passed to the caller. If no WebUI applies, |
| 73 // returns NULL. | 80 // returns NULL. |
| 74 virtual WebUIImpl* CreateWebUIForRenderManager(const GURL& url) = 0; | 81 virtual WebUIImpl* CreateWebUIForRenderManager(const GURL& url) = 0; |
| 75 | 82 |
| 76 // Returns the navigation entry of the current navigation, or NULL if there | 83 // Returns the navigation entry of the current navigation, or NULL if there |
| 77 // is none. | 84 // is none. |
| 78 virtual content::NavigationEntry* | 85 virtual content::NavigationEntry* |
| 79 GetLastCommittedNavigationEntryForRenderManager() = 0; | 86 GetLastCommittedNavigationEntryForRenderManager() = 0; |
| 80 | 87 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 void SetIsLoading(bool is_loading); | 154 void SetIsLoading(bool is_loading); |
| 148 | 155 |
| 149 // Whether to close the tab or not when there is a hang during an unload | 156 // Whether to close the tab or not when there is a hang during an unload |
| 150 // handler. If we are mid-crosssite navigation, then we should proceed | 157 // handler. If we are mid-crosssite navigation, then we should proceed |
| 151 // with the navigation instead of closing the tab. | 158 // with the navigation instead of closing the tab. |
| 152 bool ShouldCloseTabOnUnresponsiveRenderer(); | 159 bool ShouldCloseTabOnUnresponsiveRenderer(); |
| 153 | 160 |
| 154 // Called when a renderer's main frame navigates. | 161 // Called when a renderer's main frame navigates. |
| 155 void DidNavigateMainFrame(content::RenderViewHost* render_view_host); | 162 void DidNavigateMainFrame(content::RenderViewHost* render_view_host); |
| 156 | 163 |
| 164 // Helper method to create a RenderViewHost. If |swapped_out| is true, it |
| 165 // will be initially placed on the swapped out hosts list. Otherwise, it |
| 166 // will be used for a pending cross-site navigation. |
| 167 int CreateRenderView(content::SiteInstance* instance, |
| 168 int opener_route_id, |
| 169 bool swapped_out); |
| 170 |
| 157 // Set the WebUI after committing a page load. This is useful for navigations | 171 // Set the WebUI after committing a page load. This is useful for navigations |
| 158 // initiated from a renderer, where we want to give the new renderer WebUI | 172 // initiated from a renderer, where we want to give the new renderer WebUI |
| 159 // privileges from the originating renderer. | 173 // privileges from the originating renderer. |
| 160 void SetWebUIPostCommit(WebUIImpl* web_ui); | 174 void SetWebUIPostCommit(WebUIImpl* web_ui); |
| 161 | 175 |
| 162 // Called when a provisional load on the given renderer is aborted. | 176 // Called when a provisional load on the given renderer is aborted. |
| 163 void RendererAbortedProvisionalLoad( | 177 void RendererAbortedProvisionalLoad( |
| 164 content::RenderViewHost* render_view_host); | 178 content::RenderViewHost* render_view_host); |
| 165 | 179 |
| 166 // Sets the passed passed interstitial as the currently showing interstitial. | 180 // Sets the passed passed interstitial as the currently showing interstitial. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 197 const content::NotificationSource& source, | 211 const content::NotificationSource& source, |
| 198 const content::NotificationDetails& details) OVERRIDE; | 212 const content::NotificationDetails& details) OVERRIDE; |
| 199 | 213 |
| 200 // Called when a RenderViewHost is about to be deleted. | 214 // Called when a RenderViewHost is about to be deleted. |
| 201 void RenderViewDeleted(content::RenderViewHost* rvh); | 215 void RenderViewDeleted(content::RenderViewHost* rvh); |
| 202 | 216 |
| 203 // Returns whether the given RenderViewHost is on the list of swapped out | 217 // Returns whether the given RenderViewHost is on the list of swapped out |
| 204 // RenderViewHosts. | 218 // RenderViewHosts. |
| 205 bool IsSwappedOut(content::RenderViewHost* rvh); | 219 bool IsSwappedOut(content::RenderViewHost* rvh); |
| 206 | 220 |
| 221 // Returns the swapped out RenderViewHost for the given SiteInstance, if any. |
| 222 content::RenderViewHost* GetSwappedOutRenderViewHost( |
| 223 content::SiteInstance* instance); |
| 224 |
| 207 private: | 225 private: |
| 208 friend class content::TestWebContents; | 226 friend class content::TestWebContents; |
| 209 friend class RenderViewHostManagerTest; | 227 friend class RenderViewHostManagerTest; |
| 210 | 228 |
| 211 // Returns whether this tab should transition to a new renderer for | 229 // Returns whether this tab should transition to a new renderer for |
| 212 // cross-site URLs. Enabled unless we see the --process-per-tab command line | 230 // cross-site URLs. Enabled unless we see the --process-per-tab command line |
| 213 // switch. Can be overridden in unit tests. | 231 // switch. Can be overridden in unit tests. |
| 214 bool ShouldTransitionCrossSite(); | 232 bool ShouldTransitionCrossSite(); |
| 215 | 233 |
| 216 // Returns true if the two navigation entries are incompatible in some way | 234 // Returns true if the two navigation entries are incompatible in some way |
| (...skipping 10 matching lines...) Expand all Loading... |
| 227 const content::NavigationEntry* curr_entry, | 245 const content::NavigationEntry* curr_entry, |
| 228 const content::NavigationEntryImpl* new_entry) const; | 246 const content::NavigationEntryImpl* new_entry) const; |
| 229 | 247 |
| 230 // Returns an appropriate SiteInstance object for the given NavigationEntry, | 248 // Returns an appropriate SiteInstance object for the given NavigationEntry, |
| 231 // possibly reusing the current SiteInstance. | 249 // possibly reusing the current SiteInstance. |
| 232 // Never called if --process-per-tab is used. | 250 // Never called if --process-per-tab is used. |
| 233 content::SiteInstance* GetSiteInstanceForEntry( | 251 content::SiteInstance* GetSiteInstanceForEntry( |
| 234 const content::NavigationEntryImpl& entry, | 252 const content::NavigationEntryImpl& entry, |
| 235 content::SiteInstance* curr_instance); | 253 content::SiteInstance* curr_instance); |
| 236 | 254 |
| 237 // Helper method to create a pending RenderViewHost for a cross-site | 255 // Sets up the necessary state for a new RenderViewHost with the given opener. |
| 238 // navigation. | |
| 239 bool CreatePendingRenderView(const content::NavigationEntryImpl& entry, | |
| 240 content::SiteInstance* instance); | |
| 241 | |
| 242 // Sets up the necessary state for a new RenderViewHost navigating to the | |
| 243 // given entry. | |
| 244 bool InitRenderView(content::RenderViewHost* render_view_host, | 256 bool InitRenderView(content::RenderViewHost* render_view_host, |
| 245 const content::NavigationEntryImpl& entry); | 257 int opener_route_id); |
| 246 | 258 |
| 247 // Sets the pending RenderViewHost/WebUI to be the active one. Note that this | 259 // Sets the pending RenderViewHost/WebUI to be the active one. Note that this |
| 248 // doesn't require the pending render_view_host_ pointer to be non-NULL, since | 260 // doesn't require the pending render_view_host_ pointer to be non-NULL, since |
| 249 // there could be Web UI switching as well. Call this for every commit. | 261 // there could be Web UI switching as well. Call this for every commit. |
| 250 void CommitPending(); | 262 void CommitPending(); |
| 251 | 263 |
| 252 // Helper method to terminate the pending RenderViewHost. | 264 // Helper method to terminate the pending RenderViewHost. |
| 253 void CancelPending(); | 265 void CancelPending(); |
| 254 | 266 |
| 255 content::RenderViewHostImpl* UpdateRendererStateForNavigate( | 267 content::RenderViewHostImpl* UpdateRendererStateForNavigate( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 // The intersitial page currently shown if any, not own by this class | 315 // The intersitial page currently shown if any, not own by this class |
| 304 // (the InterstitialPage is self-owned, it deletes itself when hidden). | 316 // (the InterstitialPage is self-owned, it deletes itself when hidden). |
| 305 InterstitialPageImpl* interstitial_page_; | 317 InterstitialPageImpl* interstitial_page_; |
| 306 | 318 |
| 307 content::NotificationRegistrar registrar_; | 319 content::NotificationRegistrar registrar_; |
| 308 | 320 |
| 309 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManager); | 321 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManager); |
| 310 }; | 322 }; |
| 311 | 323 |
| 312 #endif // CONTENT_BROWSER_WEB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ | 324 #endif // CONTENT_BROWSER_WEB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ |
| OLD | NEW |