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" | |
|
brettw
2012/08/10 22:25:18
You should be able to remove this and forward decl
boliu
2012/08/11 00:53:35
Removed ref_counted_memory.h but added ref_counted
| |
| 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. Ownership is transferred to NavigationController | |
| 120 // after LoadURLWithParams call. | |
| 121 base::RefCountedMemory* browser_initiated_post_data; | |
|
brettw
2012/08/10 22:25:18
It seems like the memory management would be clear
boliu
2012/08/11 00:53:35
Done.
| |
| 122 | |
| 123 LoadURLParams(const GURL& url) | |
|
brettw
2012/08/10 22:25:18
This should be explicit.
I don't think we want th
boliu
2012/08/11 00:53:35
Done.
New cc file is content/browser/web_contents
| |
| 124 : url(url), | |
| 125 load_type(LOAD_TYPE_DEFAULT), | |
| 126 transition_type(PAGE_TRANSITION_LINK), | |
| 127 is_renderer_initiated(false), | |
| 128 override_user_agent(UA_OVERRIDE_INHERIT), | |
| 129 browser_initiated_post_data(NULL) { | |
| 130 } | |
| 131 }; | |
| 132 | |
| 50 // Disables checking for a repost and prompting the user. This is used during | 133 // Disables checking for a repost and prompting the user. This is used during |
| 51 // testing. | 134 // testing. |
| 52 CONTENT_EXPORT static void DisablePromptOnRepost(); | 135 CONTENT_EXPORT static void DisablePromptOnRepost(); |
| 53 | 136 |
| 54 virtual ~NavigationController() {} | 137 virtual ~NavigationController() {} |
| 55 | 138 |
| 56 // Returns the web contents associated with this controller. It can never be | 139 // Returns the web contents associated with this controller. It can never be |
| 57 // NULL. | 140 // NULL. |
| 58 virtual WebContents* GetWebContents() const = 0; | 141 virtual WebContents* GetWebContents() const = 0; |
| 59 | 142 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 | 235 |
| 153 // New navigations ----------------------------------------------------------- | 236 // New navigations ----------------------------------------------------------- |
| 154 | 237 |
| 155 // Loads the specified URL, specifying extra http headers to add to the | 238 // Loads the specified URL, specifying extra http headers to add to the |
| 156 // request. Extra headers are separated by \n. | 239 // request. Extra headers are separated by \n. |
| 157 virtual void LoadURL(const GURL& url, | 240 virtual void LoadURL(const GURL& url, |
| 158 const Referrer& referrer, | 241 const Referrer& referrer, |
| 159 PageTransition type, | 242 PageTransition type, |
| 160 const std::string& extra_headers) = 0; | 243 const std::string& extra_headers) = 0; |
| 161 | 244 |
| 162 // Same as LoadURL, but for renderer-initiated navigations. This state is | 245 // More general version of LoadURL. See comments in LoadURLParams for |
| 163 // important for tracking whether to display pending URLs. | 246 // using |params|. |
| 164 virtual void LoadURLFromRenderer(const GURL& url, | 247 virtual void LoadURLWithParams(LoadURLParams& params) = 0; |
|
brettw
2012/08/10 22:25:18
Shouldn't this be a const ref?
boliu
2012/08/11 00:53:35
Done.
| |
| 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 | 248 |
| 193 // Loads the current page if this NavigationController was restored from | 249 // Loads the current page if this NavigationController was restored from |
| 194 // history and the current page has not loaded yet. | 250 // history and the current page has not loaded yet. |
| 195 virtual void LoadIfNecessary() = 0; | 251 virtual void LoadIfNecessary() = 0; |
| 196 | 252 |
| 197 // Renavigation -------------------------------------------------------------- | 253 // Renavigation -------------------------------------------------------------- |
| 198 | 254 |
| 199 // Navigation relative to the "current entry" | 255 // Navigation relative to the "current entry" |
| 200 virtual bool CanGoBack() const = 0; | 256 virtual bool CanGoBack() const = 0; |
| 201 virtual bool CanGoForward() const = 0; | 257 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; | 326 virtual void CopyStateFromAndPrune(NavigationController* source) = 0; |
| 271 | 327 |
| 272 // Removes all the entries except the active entry. If there is a new pending | 328 // Removes all the entries except the active entry. If there is a new pending |
| 273 // navigation it is preserved. | 329 // navigation it is preserved. |
| 274 virtual void PruneAllButActive() = 0; | 330 virtual void PruneAllButActive() = 0; |
| 275 }; | 331 }; |
| 276 | 332 |
| 277 } // namespace content | 333 } // namespace content |
| 278 | 334 |
| 279 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ | 335 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ |
| OLD | NEW |