| 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_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 14 #include "content/public/browser/global_request_id.h" | 14 #include "content/public/browser/global_request_id.h" |
| 15 #include "content/public/common/page_transition_types.h" | 15 #include "content/public/common/page_transition_types.h" |
| 16 | 16 |
| 17 class GURL; | 17 class GURL; |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 | 20 |
| 21 class BrowserContext; | 21 class BrowserContext; |
| 22 class NavigationEntry; | 22 class NavigationEntry; |
| 23 class SessionStorageNamespace; | 23 class SessionStorageNamespace; |
| 24 class WebContents; | 24 class WebContents; |
| 25 struct Referrer; | 25 struct Referrer; |
| 26 | 26 |
| 27 // A NavigationController maintains the back-forward list for a single tab and | 27 // A NavigationController maintains the back-forward list for a WebContents and |
| 28 // manages all navigation within that list. | 28 // manages all navigation within that list. |
| 29 // | 29 // |
| 30 // The NavigationController also owns all WebContents for the tab. This is to | 30 // Each NavigationController belongs to one WebContents; each WebContents has |
| 31 // make sure that we have at most one WebContents instance per type. | 31 // exactly one NavigationController. |
| 32 class NavigationController { | 32 class NavigationController { |
| 33 public: | 33 public: |
| 34 enum ReloadType { | 34 enum ReloadType { |
| 35 NO_RELOAD, // Normal load. | 35 NO_RELOAD, // Normal load. |
| 36 RELOAD, // Normal (cache-validating) reload. | 36 RELOAD, // Normal (cache-validating) reload. |
| 37 RELOAD_IGNORING_CACHE // Reload bypassing the cache, aka shift-reload. | 37 RELOAD_IGNORING_CACHE // Reload bypassing the cache, aka shift-reload. |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 // Creates navigation entry and translates the virtual url to a real one. | 40 // Creates a navigation entry and translates the virtual url to a real one. |
| 41 // Used when navigating to a new URL using LoadURL. Extra headers are | 41 // This is a general call; prefer LoadURL[FromRenderer]/TransferURL below. |
| 42 // separated by \n. | 42 // Extra headers are separated by \n. |
| 43 CONTENT_EXPORT static NavigationEntry* CreateNavigationEntry( | 43 CONTENT_EXPORT static NavigationEntry* CreateNavigationEntry( |
| 44 const GURL& url, | 44 const GURL& url, |
| 45 const Referrer& referrer, | 45 const Referrer& referrer, |
| 46 PageTransition transition, | 46 PageTransition transition, |
| 47 bool is_renderer_initiated, | 47 bool is_renderer_initiated, |
| 48 const std::string& extra_headers, | 48 const std::string& extra_headers, |
| 49 BrowserContext* browser_context); | 49 BrowserContext* browser_context); |
| 50 | 50 |
| 51 // Disables checking for a repost and prompting the user. This is used during | 51 // Disables checking for a repost and prompting the user. This is used during |
| 52 // testing. | 52 // testing. |
| 53 CONTENT_EXPORT static void DisablePromptOnRepost(); | 53 CONTENT_EXPORT static void DisablePromptOnRepost(); |
| 54 | 54 |
| 55 virtual ~NavigationController() {} | 55 virtual ~NavigationController() {} |
| 56 | 56 |
| 57 // Returns the web contents associated with this controller. Non-NULL except | 57 // Returns the web contents associated with this controller. It can never be |
| 58 // during set-up of the tab. | 58 // NULL. |
| 59 virtual WebContents* GetWebContents() const = 0; | 59 virtual WebContents* GetWebContents() const = 0; |
| 60 | 60 |
| 61 // Get/set the browser context for this controller. It can never be NULL. | 61 // Get/set the browser context for this controller. It can never be NULL. |
| 62 virtual BrowserContext* GetBrowserContext() const = 0; | 62 virtual BrowserContext* GetBrowserContext() const = 0; |
| 63 virtual void SetBrowserContext(BrowserContext* browser_context) = 0; | 63 virtual void SetBrowserContext(BrowserContext* browser_context) = 0; |
| 64 | 64 |
| 65 // Initializes this NavigationController with the given saved navigations, | 65 // Initializes this NavigationController with the given saved navigations, |
| 66 // using selected_navigation as the currently loaded entry. Before this call | 66 // using selected_navigation as the currently loaded entry. Before this call |
| 67 // the controller should be unused (there should be no current entry). If | 67 // the controller should be unused (there should be no current entry). If |
| 68 // from_last_session is true, navigations are from the previous session, | 68 // from_last_session is true, navigations are from the previous session, |
| 69 // otherwise they are from the current session (undo tab close). This takes | 69 // otherwise they are from the current session (undo tab close). This takes |
| 70 // ownership of the NavigationEntrys in |entries| and clears it out. | 70 // ownership of the NavigationEntrys in |entries| and clears it out. |
| 71 // This is used for session restore. | 71 // This is used for session restore. |
| 72 virtual void Restore(int selected_navigation, | 72 virtual void Restore(int selected_navigation, |
| 73 bool from_last_session, | 73 bool from_last_session, |
| 74 std::vector<NavigationEntry*>* entries) = 0; | 74 std::vector<NavigationEntry*>* entries) = 0; |
| 75 | 75 |
| 76 // Entries ------------------------------------------------------------------- |
| 77 |
| 78 // There are two basic states for entries: pending and committed. When an |
| 79 // entry is navigated to, a request is sent to the server. While that request |
| 80 // has not been responded to, the NavigationEntry is pending. Once data is |
| 81 // received for that entry, that NavigationEntry is committed. |
| 82 |
| 83 // A transient entry is an entry that, when the user navigates away, is |
| 84 // removed and discarded rather than being added to the back-forward list. |
| 85 // Transient entries are useful for interstitial pages and the like. |
| 86 |
| 76 // Active entry -------------------------------------------------------------- | 87 // Active entry -------------------------------------------------------------- |
| 77 | 88 |
| 78 // Returns the active entry, which is the transient entry if any, the pending | 89 // Returns the active entry, which is the transient entry if any, the pending |
| 79 // entry if a navigation is in progress or the last committed entry otherwise. | 90 // entry if a navigation is in progress or the last committed entry otherwise. |
| 80 // NOTE: This can be NULL!! | 91 // NOTE: This can be NULL!! |
| 81 // | 92 // |
| 82 // If you are trying to get the current state of the NavigationController, | 93 // If you are trying to get the current state of the NavigationController, |
| 83 // this is the method you will typically want to call. If you want to display | 94 // this is the method you will typically want to call. If you want to display |
| 84 // the active entry to the user (e.g., in the location bar), use | 95 // the active entry to the user (e.g., in the location bar), use |
| 85 // GetVisibleEntry instead. | 96 // GetVisibleEntry instead. |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 virtual void CopyStateFromAndPrune(NavigationController* source) = 0; | 260 virtual void CopyStateFromAndPrune(NavigationController* source) = 0; |
| 250 | 261 |
| 251 // Removes all the entries except the active entry. If there is a new pending | 262 // Removes all the entries except the active entry. If there is a new pending |
| 252 // navigation it is preserved. | 263 // navigation it is preserved. |
| 253 virtual void PruneAllButActive() = 0; | 264 virtual void PruneAllButActive() = 0; |
| 254 }; | 265 }; |
| 255 | 266 |
| 256 } // namespace content | 267 } // namespace content |
| 257 | 268 |
| 258 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ | 269 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ |
| OLD | NEW |