| 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 | 7 | 
| 8 #include <map> | 8 #include <map> | 
| 9 #include <string> | 9 #include <string> | 
| 10 #include <vector> | 10 #include <vector> | 
| 11 | 11 | 
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" | 
| 13 #include "base/string16.h" | 13 #include "base/string16.h" | 
| 14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" | 
| 15 #include "content/public/browser/global_request_id.h" | 15 #include "content/public/browser/global_request_id.h" | 
| 16 #include "content/public/common/page_transition_types.h" | 16 #include "content/public/common/page_transition_types.h" | 
|  | 17 #include "content/public/common/referrer.h" | 
|  | 18 #include "googleurl/src/gurl.h" | 
| 17 | 19 | 
| 18 class GURL; | 20 namespace base { | 
|  | 21 | 
|  | 22 class RefCountedMemory; | 
|  | 23 | 
|  | 24 }  // namespace base | 
| 19 | 25 | 
| 20 namespace content { | 26 namespace content { | 
| 21 | 27 | 
| 22 class BrowserContext; | 28 class BrowserContext; | 
| 23 class NavigationEntry; | 29 class NavigationEntry; | 
| 24 class SessionStorageNamespace; | 30 class SessionStorageNamespace; | 
| 25 class WebContents; | 31 class WebContents; | 
| 26 struct Referrer; |  | 
| 27 | 32 | 
| 28 // Used to store the mapping of a StoragePartition id to | 33 // Used to store the mapping of a StoragePartition id to | 
| 29 // SessionStorageNamespace. | 34 // SessionStorageNamespace. | 
| 30 typedef std::map<std::string, scoped_refptr<SessionStorageNamespace> > | 35 typedef std::map<std::string, scoped_refptr<SessionStorageNamespace> > | 
| 31     SessionStorageNamespaceMap; | 36     SessionStorageNamespaceMap; | 
| 32 | 37 | 
| 33 // A NavigationController maintains the back-forward list for a WebContents and | 38 // A NavigationController maintains the back-forward list for a WebContents and | 
| 34 // manages all navigation within that list. | 39 // manages all navigation within that list. | 
| 35 // | 40 // | 
| 36 // Each NavigationController belongs to one WebContents; each WebContents has | 41 // Each NavigationController belongs to one WebContents; each WebContents has | 
| 37 // exactly one NavigationController. | 42 // exactly one NavigationController. | 
| 38 class NavigationController { | 43 class NavigationController { | 
| 39  public: | 44  public: | 
| 40   enum ReloadType { | 45   enum ReloadType { | 
| 41     NO_RELOAD,                   // Normal load. | 46     NO_RELOAD,                   // Normal load. | 
| 42     RELOAD,                      // Normal (cache-validating) reload. | 47     RELOAD,                      // Normal (cache-validating) reload. | 
| 43     RELOAD_IGNORING_CACHE,       // Reload bypassing the cache (shift-reload). | 48     RELOAD_IGNORING_CACHE,       // Reload bypassing the cache (shift-reload). | 
| 44     RELOAD_ORIGINAL_REQUEST_URL  // Reload using the original request URL. | 49     RELOAD_ORIGINAL_REQUEST_URL  // Reload using the original request URL. | 
| 45   }; | 50   }; | 
| 46 | 51 | 
|  | 52   // Load type used in LoadURLParams. | 
|  | 53   enum LoadURLType { | 
|  | 54     // For loads that do not fall into any types below. | 
|  | 55     LOAD_TYPE_DEFAULT, | 
|  | 56 | 
|  | 57     // An http post load request initiated from browser side. | 
|  | 58     // The post data is passed in |browser_initiated_post_data|. | 
|  | 59     LOAD_TYPE_BROWSER_INITIATED_HTTP_POST, | 
|  | 60 | 
|  | 61     // Loads a 'data:' scheme URL with specified base URL and a history entry | 
|  | 62     // URL. This is only safe to be used for browser-initiated data: URL | 
|  | 63     // navigations, since it shows arbitrary content as if it comes from | 
|  | 64     // |virtual_url_for_data_url|. | 
|  | 65     LOAD_TYPE_DATA | 
|  | 66   }; | 
|  | 67 | 
|  | 68   // User agent override type used in LoadURLParams. | 
|  | 69   enum UserAgentOverrideOption { | 
|  | 70     // Use the override value from the previous NavigationEntry in the | 
|  | 71     // NavigationController. | 
|  | 72     UA_OVERRIDE_INHERIT, | 
|  | 73 | 
|  | 74     // Use the default user agent. | 
|  | 75     UA_OVERRIDE_FALSE, | 
|  | 76 | 
|  | 77     // Use the user agent override, if it's available. | 
|  | 78     UA_OVERRIDE_TRUE | 
|  | 79   }; | 
|  | 80 | 
| 47   // Creates a navigation entry and translates the virtual url to a real one. | 81   // Creates a navigation entry and translates the virtual url to a real one. | 
| 48   // This is a general call; prefer LoadURL[FromRenderer]/TransferURL below. | 82   // This is a general call; prefer LoadURL[FromRenderer]/TransferURL below. | 
| 49   // Extra headers are separated by \n. | 83   // Extra headers are separated by \n. | 
| 50   CONTENT_EXPORT static NavigationEntry* CreateNavigationEntry( | 84   CONTENT_EXPORT static NavigationEntry* CreateNavigationEntry( | 
| 51       const GURL& url, | 85       const GURL& url, | 
| 52       const Referrer& referrer, | 86       const Referrer& referrer, | 
| 53       PageTransition transition, | 87       PageTransition transition, | 
| 54       bool is_renderer_initiated, | 88       bool is_renderer_initiated, | 
| 55       const std::string& extra_headers, | 89       const std::string& extra_headers, | 
| 56       BrowserContext* browser_context); | 90       BrowserContext* browser_context); | 
| 57 | 91 | 
|  | 92   // Extra optional parameters for LoadURLWithParams. | 
|  | 93   struct CONTENT_EXPORT LoadURLParams { | 
|  | 94     // The url to load. This field is required. | 
|  | 95     GURL url; | 
|  | 96 | 
|  | 97     // See LoadURLType comments above. | 
|  | 98     LoadURLType load_type; | 
|  | 99 | 
|  | 100     // PageTransition for this load. See PageTransition for details. | 
|  | 101     // Note the default value in constructor below. | 
|  | 102     PageTransition transition_type; | 
|  | 103 | 
|  | 104     // Referrer for this load. Empty if none. | 
|  | 105     Referrer referrer; | 
|  | 106 | 
|  | 107     // Extra headers for this load, separated by \n. | 
|  | 108     std::string extra_headers; | 
|  | 109 | 
|  | 110     // True for renderer-initiated navigations. This is | 
|  | 111     // important for tracking whether to display pending URLs. | 
|  | 112     bool is_renderer_initiated; | 
|  | 113 | 
|  | 114     // User agent override for this load. See comments in | 
|  | 115     // UserAgentOverrideOption definition. | 
|  | 116     UserAgentOverrideOption override_user_agent; | 
|  | 117 | 
|  | 118     // Marks the new navigation as being transferred from one RVH to another. | 
|  | 119     // In this case the browser can recycle the old request once the new | 
|  | 120     // renderer wants to navigate. Identifies the request ID of the old request. | 
|  | 121     GlobalRequestID transferred_global_request_id; | 
|  | 122 | 
|  | 123     // Used in LOAD_TYPE_DATA loads only. Used for specifying a base URL | 
|  | 124     // for pages loaded via data URLs. | 
|  | 125     GURL base_url_for_data_url; | 
|  | 126 | 
|  | 127     // Used in LOAD_TYPE_DATA loads only. URL displayed to the user for | 
|  | 128     // data loads. | 
|  | 129     GURL virtual_url_for_data_url; | 
|  | 130 | 
|  | 131     // Used in LOAD_TYPE_BROWSER_INITIATED_HTTP_POST loads only. Carries the | 
|  | 132     // post data of the load. Ownership is transferred to NavigationController | 
|  | 133     // after LoadURLWithParams call. | 
|  | 134     scoped_refptr<base::RefCountedMemory> browser_initiated_post_data; | 
|  | 135 | 
|  | 136     explicit LoadURLParams(const GURL& url); | 
|  | 137     ~LoadURLParams(); | 
|  | 138 | 
|  | 139     // Allows copying of LoadURLParams struct. | 
|  | 140     LoadURLParams(const LoadURLParams& other); | 
|  | 141     LoadURLParams& operator=(const LoadURLParams& other); | 
|  | 142   }; | 
|  | 143 | 
| 58   // Disables checking for a repost and prompting the user. This is used during | 144   // Disables checking for a repost and prompting the user. This is used during | 
| 59   // testing. | 145   // testing. | 
| 60   CONTENT_EXPORT static void DisablePromptOnRepost(); | 146   CONTENT_EXPORT static void DisablePromptOnRepost(); | 
| 61 | 147 | 
| 62   virtual ~NavigationController() {} | 148   virtual ~NavigationController() {} | 
| 63 | 149 | 
| 64   // Returns the web contents associated with this controller. It can never be | 150   // Returns the web contents associated with this controller. It can never be | 
| 65   // NULL. | 151   // NULL. | 
| 66   virtual WebContents* GetWebContents() const = 0; | 152   virtual WebContents* GetWebContents() const = 0; | 
| 67 | 153 | 
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 160 | 246 | 
| 161   // New navigations ----------------------------------------------------------- | 247   // New navigations ----------------------------------------------------------- | 
| 162 | 248 | 
| 163   // Loads the specified URL, specifying extra http headers to add to the | 249   // Loads the specified URL, specifying extra http headers to add to the | 
| 164   // request.  Extra headers are separated by \n. | 250   // request.  Extra headers are separated by \n. | 
| 165   virtual void LoadURL(const GURL& url, | 251   virtual void LoadURL(const GURL& url, | 
| 166                        const Referrer& referrer, | 252                        const Referrer& referrer, | 
| 167                        PageTransition type, | 253                        PageTransition type, | 
| 168                        const std::string& extra_headers) = 0; | 254                        const std::string& extra_headers) = 0; | 
| 169 | 255 | 
| 170   // Same as LoadURL, but for renderer-initiated navigations.  This state is | 256   // More general version of LoadURL. See comments in LoadURLParams for | 
| 171   // important for tracking whether to display pending URLs. | 257   // using |params|. | 
| 172   virtual void LoadURLFromRenderer(const GURL& url, | 258   virtual void LoadURLWithParams(const LoadURLParams& params) = 0; | 
| 173                                    const Referrer& referrer, |  | 
| 174                                    PageTransition type, |  | 
| 175                                    const std::string& extra_headers) = 0; |  | 
| 176 |  | 
| 177   // Same as LoadURL, but allows overriding the user agent of the |  | 
| 178   // NavigationEntry before it loads. |  | 
| 179   // TODO(dfalcantara): Consolidate the LoadURL* interfaces. |  | 
| 180   virtual void LoadURLWithUserAgentOverride(const GURL& url, |  | 
| 181                                             const Referrer& referrer, |  | 
| 182                                             PageTransition type, |  | 
| 183                                             bool is_renderer_initiated, |  | 
| 184                                             const std::string& extra_headers, |  | 
| 185                                             bool is_overriding_user_agent) = 0; |  | 
| 186 |  | 
| 187   // Behaves like LoadURL() and LoadURLFromRenderer() but marks the new |  | 
| 188   // navigation as being transferred from one RVH to another. In this case the |  | 
| 189   // browser can recycle the old request once the new renderer wants to |  | 
| 190   // navigate. |  | 
| 191   // |transferred_global_request_id| identifies the request ID of the old |  | 
| 192   // request. |  | 
| 193   virtual void TransferURL( |  | 
| 194       const GURL& url, |  | 
| 195       const Referrer& referrer, |  | 
| 196       PageTransition transition, |  | 
| 197       const std::string& extra_headers, |  | 
| 198       const GlobalRequestID& transferred_global_request_id, |  | 
| 199       bool is_renderer_initiated) = 0; |  | 
| 200 | 259 | 
| 201   // Loads the current page if this NavigationController was restored from | 260   // Loads the current page if this NavigationController was restored from | 
| 202   // history and the current page has not loaded yet. | 261   // history and the current page has not loaded yet. | 
| 203   virtual void LoadIfNecessary() = 0; | 262   virtual void LoadIfNecessary() = 0; | 
| 204 | 263 | 
| 205   // Renavigation -------------------------------------------------------------- | 264   // Renavigation -------------------------------------------------------------- | 
| 206 | 265 | 
| 207   // Navigation relative to the "current entry" | 266   // Navigation relative to the "current entry" | 
| 208   virtual bool CanGoBack() const = 0; | 267   virtual bool CanGoBack() const = 0; | 
| 209   virtual bool CanGoForward() const = 0; | 268   virtual bool CanGoForward() const = 0; | 
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 284   virtual void CopyStateFromAndPrune(NavigationController* source) = 0; | 343   virtual void CopyStateFromAndPrune(NavigationController* source) = 0; | 
| 285 | 344 | 
| 286   // Removes all the entries except the active entry. If there is a new pending | 345   // Removes all the entries except the active entry. If there is a new pending | 
| 287   // navigation it is preserved. | 346   // navigation it is preserved. | 
| 288   virtual void PruneAllButActive() = 0; | 347   virtual void PruneAllButActive() = 0; | 
| 289 }; | 348 }; | 
| 290 | 349 | 
| 291 }  // namespace content | 350 }  // namespace content | 
| 292 | 351 | 
| 293 #endif  // CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ | 352 #endif  // CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ | 
| OLD | NEW | 
|---|