Chromium Code Reviews| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted_memory.h" | |
| 11 #include "base/string16.h" | 12 #include "base/string16.h" |
| 12 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 13 #include "content/public/browser/global_request_id.h" | 14 #include "content/public/browser/global_request_id.h" |
| 14 #include "content/public/common/page_transition_types.h" | 15 #include "content/public/common/page_transition_types.h" |
| 15 | 16 #include "content/public/common/referrer.h" |
| 16 class GURL; | 17 #include "googleurl/src/gurl.h" |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 | 20 |
| 20 class BrowserContext; | 21 class BrowserContext; |
| 21 class NavigationEntry; | 22 class NavigationEntry; |
| 22 class SessionStorageNamespace; | 23 class SessionStorageNamespace; |
| 23 class WebContents; | 24 class WebContents; |
| 24 struct Referrer; | |
| 25 | 25 |
| 26 // A NavigationController maintains the back-forward list for a WebContents and | 26 // A NavigationController maintains the back-forward list for a WebContents and |
| 27 // manages all navigation within that list. | 27 // manages all navigation within that list. |
| 28 // | 28 // |
| 29 // Each NavigationController belongs to one WebContents; each WebContents has | 29 // Each NavigationController belongs to one WebContents; each WebContents has |
| 30 // exactly one NavigationController. | 30 // exactly one NavigationController. |
| 31 class NavigationController { | 31 class NavigationController { |
| 32 public: | 32 public: |
| 33 enum ReloadType { | 33 enum ReloadType { |
| 34 NO_RELOAD, // Normal load. | 34 NO_RELOAD, // Normal load. |
| 35 RELOAD, // Normal (cache-validating) reload. | 35 RELOAD, // Normal (cache-validating) reload. |
| 36 RELOAD_IGNORING_CACHE // Reload bypassing the cache, aka shift-reload. | 36 RELOAD_IGNORING_CACHE // Reload bypassing the cache, aka shift-reload. |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 // Load type used in LoadURLParams. | |
| 40 enum LoadURLType { | |
| 41 // For loads that do not fall into any types below. | |
| 42 LOAD_TYPE_DEFAULT, | |
| 43 | |
| 44 // An http post load request initiated from browser side. | |
| 45 // The post data is passed in |browser_initiated_post_data|. | |
| 46 LOAD_TYPE_BROWSER_INITIATED_HTTP_POST, | |
| 47 | |
| 48 // Loads a 'data:' scheme URL with specified base URL and a history entry | |
| 49 // URL. This is only safe to be used for browser-initiated data: URL | |
| 50 // navigations, since it shows arbitrary content as if it comes from | |
| 51 // |virtual_url_for_data_url|. | |
| 52 LOAD_TYPE_DATA | |
| 53 }; | |
| 54 | |
| 55 // User agent override type used in LoadURLParams. | |
| 56 enum UserAgentOverrideOption { | |
| 57 // Use the override value from the previous NavigationEntry in the | |
| 58 // NavigationController. | |
| 59 UA_OVERRIDE_INHERIT, | |
| 60 | |
| 61 // Use the default user agent. | |
| 62 UA_OVERRIDE_FALSE, | |
| 63 | |
| 64 // Use the user agent override, if it's available. | |
| 65 UA_OVERRIDE_TRUE | |
| 66 }; | |
| 67 | |
| 39 // Creates a navigation entry and translates the virtual url to a real one. | 68 // Creates a navigation entry and translates the virtual url to a real one. |
| 40 // This is a general call; prefer LoadURL[FromRenderer]/TransferURL below. | 69 // This is a general call; prefer LoadURL[FromRenderer]/TransferURL below. |
| 41 // Extra headers are separated by \n. | 70 // Extra headers are separated by \n. |
| 42 CONTENT_EXPORT static NavigationEntry* CreateNavigationEntry( | 71 CONTENT_EXPORT static NavigationEntry* CreateNavigationEntry( |
| 43 const GURL& url, | 72 const GURL& url, |
| 44 const Referrer& referrer, | 73 const Referrer& referrer, |
| 45 PageTransition transition, | 74 PageTransition transition, |
| 46 bool is_renderer_initiated, | 75 bool is_renderer_initiated, |
| 47 const std::string& extra_headers, | 76 const std::string& extra_headers, |
| 48 BrowserContext* browser_context); | 77 BrowserContext* browser_context); |
| 49 | 78 |
| 79 // Extra optional parameters for LoadURLWithParams. | |
| 80 CONTENT_EXPORT struct LoadURLParams { | |
| 81 // The url to load. This field is required. | |
| 82 const GURL url; | |
| 83 | |
| 84 // See LoadURLType comments above. | |
| 85 LoadURLType load_type; | |
| 86 | |
| 87 // PageTransition for this load. See PageTransition for details. | |
| 88 // Note the default value in constructor below. | |
| 89 PageTransition transition_type; | |
| 90 | |
| 91 // Referrer for this load. Empty if none. | |
| 92 Referrer referrer; | |
| 93 | |
| 94 // Extra headers for this load, separated by \n. | |
| 95 std::string extra_headers; | |
| 96 | |
| 97 // True for renderer-initiated navigations. This is | |
| 98 // important for tracking whether to display pending URLs. | |
| 99 bool is_renderer_initiated; | |
| 100 | |
| 101 // User agent override for this load. See comments in | |
| 102 // UserAgentOverrideOption definition. | |
| 103 UserAgentOverrideOption override_user_agent; | |
| 104 | |
| 105 // Marks the new navigation as being transferred from one RVH to another. | |
| 106 // In this case the browser can recycle the old request once the new | |
| 107 // renderer wants to navigate. Identifies the request ID of the old request. | |
| 108 GlobalRequestID transferred_global_request_id; | |
| 109 | |
| 110 // Used in LOAD_TYPE_DATA loads only. Used for specifying a base URL | |
| 111 // for pages loaded via data URLs. | |
| 112 GURL base_url_for_data_url; | |
| 113 | |
| 114 // Used in LOAD_TYPE_DATA loads only. URL displayed to the user for | |
| 115 // data loads. | |
| 116 GURL virtual_url_for_data_url; | |
| 117 | |
| 118 // Used in LOAD_TYPE_BROWSER_INITIATED_HTTP_POST loads only. Carries the | |
| 119 // post data of the load. | |
| 120 base::RefCountedMemory* browser_initiated_post_data; | |
|
boliu
2012/08/03 22:42:08
I thought about commenting about ownership of this
Charlie Reis
2012/08/03 23:12:48
I'd recommend the "ownership transferred to Naviga
boliu
2012/08/03 23:31:39
Done.
| |
| 121 | |
| 122 LoadURLParams(const GURL& url) | |
| 123 : url(url), | |
| 124 load_type(LOAD_TYPE_DEFAULT), | |
| 125 transition_type(PAGE_TRANSITION_LINK), | |
| 126 is_renderer_initiated(false), | |
| 127 override_user_agent(UA_OVERRIDE_INHERIT), | |
| 128 browser_initiated_post_data(NULL) { | |
| 129 } | |
| 130 }; | |
| 131 | |
| 50 // Disables checking for a repost and prompting the user. This is used during | 132 // Disables checking for a repost and prompting the user. This is used during |
| 51 // testing. | 133 // testing. |
| 52 CONTENT_EXPORT static void DisablePromptOnRepost(); | 134 CONTENT_EXPORT static void DisablePromptOnRepost(); |
| 53 | 135 |
| 54 virtual ~NavigationController() {} | 136 virtual ~NavigationController() {} |
| 55 | 137 |
| 56 // Returns the web contents associated with this controller. It can never be | 138 // Returns the web contents associated with this controller. It can never be |
| 57 // NULL. | 139 // NULL. |
| 58 virtual WebContents* GetWebContents() const = 0; | 140 virtual WebContents* GetWebContents() const = 0; |
| 59 | 141 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 | 234 |
| 153 // New navigations ----------------------------------------------------------- | 235 // New navigations ----------------------------------------------------------- |
| 154 | 236 |
| 155 // Loads the specified URL, specifying extra http headers to add to the | 237 // Loads the specified URL, specifying extra http headers to add to the |
| 156 // request. Extra headers are separated by \n. | 238 // request. Extra headers are separated by \n. |
| 157 virtual void LoadURL(const GURL& url, | 239 virtual void LoadURL(const GURL& url, |
| 158 const Referrer& referrer, | 240 const Referrer& referrer, |
| 159 PageTransition type, | 241 PageTransition type, |
| 160 const std::string& extra_headers) = 0; | 242 const std::string& extra_headers) = 0; |
| 161 | 243 |
| 162 // Same as LoadURL, but for renderer-initiated navigations. This state is | 244 // More general version of LoadURL. See comments in LoadURLParams for |
| 163 // important for tracking whether to display pending URLs. | 245 // using |params|. |
| 164 virtual void LoadURLFromRenderer(const GURL& url, | 246 virtual void LoadURLWithParams(LoadURLParams& params) = 0; |
| 165 const Referrer& referrer, | |
| 166 PageTransition type, | |
| 167 const std::string& extra_headers) = 0; | |
| 168 | |
| 169 // Same as LoadURL, but allows overriding the user agent of the | |
| 170 // NavigationEntry before it loads. | |
| 171 // TODO(dfalcantara): Consolidate the LoadURL* interfaces. | |
| 172 virtual void LoadURLWithUserAgentOverride(const GURL& url, | |
| 173 const Referrer& referrer, | |
| 174 PageTransition type, | |
| 175 bool is_renderer_initiated, | |
| 176 const std::string& extra_headers, | |
| 177 bool is_overriding_user_agent) = 0; | |
| 178 | |
| 179 // Behaves like LoadURL() and LoadURLFromRenderer() but marks the new | |
| 180 // navigation as being transferred from one RVH to another. In this case the | |
| 181 // browser can recycle the old request once the new renderer wants to | |
| 182 // navigate. | |
| 183 // |transferred_global_request_id| identifies the request ID of the old | |
| 184 // request. | |
| 185 virtual void TransferURL( | |
| 186 const GURL& url, | |
| 187 const Referrer& referrer, | |
| 188 PageTransition transition, | |
| 189 const std::string& extra_headers, | |
| 190 const GlobalRequestID& transferred_global_request_id, | |
| 191 bool is_renderer_initiated) = 0; | |
| 192 | 247 |
| 193 // Loads the current page if this NavigationController was restored from | 248 // Loads the current page if this NavigationController was restored from |
| 194 // history and the current page has not loaded yet. | 249 // history and the current page has not loaded yet. |
| 195 virtual void LoadIfNecessary() = 0; | 250 virtual void LoadIfNecessary() = 0; |
| 196 | 251 |
| 197 // Renavigation -------------------------------------------------------------- | 252 // Renavigation -------------------------------------------------------------- |
| 198 | 253 |
| 199 // Navigation relative to the "current entry" | 254 // Navigation relative to the "current entry" |
| 200 virtual bool CanGoBack() const = 0; | 255 virtual bool CanGoBack() const = 0; |
| 201 virtual bool CanGoForward() const = 0; | 256 virtual bool CanGoForward() const = 0; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 virtual void CopyStateFromAndPrune(NavigationController* source) = 0; | 325 virtual void CopyStateFromAndPrune(NavigationController* source) = 0; |
| 271 | 326 |
| 272 // Removes all the entries except the active entry. If there is a new pending | 327 // Removes all the entries except the active entry. If there is a new pending |
| 273 // navigation it is preserved. | 328 // navigation it is preserved. |
| 274 virtual void PruneAllButActive() = 0; | 329 virtual void PruneAllButActive() = 0; |
| 275 }; | 330 }; |
| 276 | 331 |
| 277 } // namespace content | 332 } // namespace content |
| 278 | 333 |
| 279 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ | 334 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ |
| OLD | NEW |