Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: content/public/browser/navigation_controller.h

Issue 10830144: Consolidate all NavigationController::LoadURL and family functions (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: NOTREACHED checks for post/data loads. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // Creates a navigation entry and translates the virtual url to a real one. 39 // Creates a navigation entry and translates the virtual url to a real one.
40 // This is a general call; prefer LoadURL[FromRenderer]/TransferURL below. 40 // This is a general call; prefer LoadURL[FromRenderer]/TransferURL below.
41 // Extra headers are separated by \n. 41 // Extra headers are separated by \n.
42 CONTENT_EXPORT static NavigationEntry* CreateNavigationEntry( 42 CONTENT_EXPORT static NavigationEntry* CreateNavigationEntry(
43 const GURL& url, 43 const GURL& url,
44 const Referrer& referrer, 44 const Referrer& referrer,
45 PageTransition transition, 45 PageTransition transition,
46 bool is_renderer_initiated, 46 bool is_renderer_initiated,
47 const std::string& extra_headers, 47 const std::string& extra_headers,
48 BrowserContext* browser_context); 48 BrowserContext* browser_context);
49 49
50 // Load type used in LoadURLParams.
51 enum LoadURLType {
Charlie Reis 2012/08/03 21:28:36 enums and structs belong above the static CreateNa
boliu 2012/08/03 22:42:08 Done. Placed new UserAgentOverrideOption enum here
52 // For loads that does not fall into any types below.
Charlie Reis 2012/08/03 21:28:36 nit: do not
boliu 2012/08/03 22:42:08 Done.
53 LOAD_TYPE_DEFAULT,
54
55 // An http post load request initiated from browser side.
56 // The post data is passed in |browser_initiated_post_data|.
57 // Used in Android WebView.postUrl implementation.
Charlie Reis 2012/08/03 21:28:36 I don't think we should talk about Android WebView
boliu 2012/08/03 22:42:08 Removed mentions of webview usage. I originally ad
58 LOAD_TYPE_BROWSER_INITIATED_HTTP_POST,
59
60 // Loads a 'data:' scheme URL with specified base URL and a history entry
61 // URL. This is only safe to be used for browser-initiated data: URL
62 // navigations, since it shows arbitrary content as if it comes from
63 // |virtual_url|. Used in Android WebView.loadDataWithBaseURL
64 // implementation.
65 LOAD_TYPE_DATA
66 };
67
68 // Extra optional parameters for LoadURLWithParams.
69 CONTENT_EXPORT struct LoadURLParams {
70 // The url to load. This field is required.
71 const GURL url;
72
73 // See LoadURLType comments above.
74 LoadURLType load_type;
75
76 // PageTransition for this load. See PageTransition for details.
77 // Note the default value in constructor below.
78 PageTransition transition_type;
79
80 // Referrer for this load. Empty if none.
81 Referrer referrer;
82
83 // Extra headers for this load, separated by \n.
84 std::string extra_headers;
85
86 // True for renderer-initiated navigations. This is
87 // important for tracking whether to display pending URLs.
88 bool is_renderer_initiated;
89
90 // If true, then |is_overriding_user_agent| is ignored and the user agent
91 // override boolean is inherited from previous navigations.
92 // Note the default value of this is true.
93 bool should_inherit_user_agent_override;
94
95 // Ignored if |should_inherit_user_agent_override| is true. Otherwise,
96 // sets the user agent override boolean of the load to this value.
97 bool is_overriding_user_agent;
98
99 // Marks the new navigation as being transferred from one RVH to another.
100 // In this case the browser can recycle the old request once the new
101 // renderer wants to navigate. Identifies the request ID of the old request.
102 GlobalRequestID transferred_global_request_id;
103
104 // Used in LOAD_TYPE_DATA loads only. Used for specifying a base URL
105 // for pages loaded via data URLs.
106 GURL base_url_for_data_url;
107
108 // Used in LOAD_TYPE_DATA loads only. URL displayed to the user for
109 // data loads.
110 GURL virtual_url;
Charlie Reis 2012/08/03 21:28:36 virtual_url has a different meaning in NavigationE
boliu 2012/08/03 22:42:08 Renamed to virtual_url_for_data_url.
111
112 // Used in LOAD_TYPE_BROWSER_INITIATED_HTTP_POST loads only. Carrys the
gone 2012/08/03 20:17:37 nit: Carrys -> Carries
boliu 2012/08/03 22:42:08 Done.
113 // post data of the load.
114 base::RefCountedMemory* browser_initiated_post_data;
115
116 LoadURLParams(const GURL& url)
117 : url(url),
118 load_type(LOAD_TYPE_DEFAULT),
119 transition_type(PAGE_TRANSITION_LINK),
120 is_renderer_initiated(false),
121 should_inherit_user_agent_override(true),
122 is_overriding_user_agent(false),
123 browser_initiated_post_data(NULL) {
124 }
125 };
126
50 // Disables checking for a repost and prompting the user. This is used during 127 // Disables checking for a repost and prompting the user. This is used during
51 // testing. 128 // testing.
52 CONTENT_EXPORT static void DisablePromptOnRepost(); 129 CONTENT_EXPORT static void DisablePromptOnRepost();
53 130
54 virtual ~NavigationController() {} 131 virtual ~NavigationController() {}
55 132
56 // Returns the web contents associated with this controller. It can never be 133 // Returns the web contents associated with this controller. It can never be
57 // NULL. 134 // NULL.
58 virtual WebContents* GetWebContents() const = 0; 135 virtual WebContents* GetWebContents() const = 0;
59 136
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 229
153 // New navigations ----------------------------------------------------------- 230 // New navigations -----------------------------------------------------------
154 231
155 // Loads the specified URL, specifying extra http headers to add to the 232 // Loads the specified URL, specifying extra http headers to add to the
156 // request. Extra headers are separated by \n. 233 // request. Extra headers are separated by \n.
157 virtual void LoadURL(const GURL& url, 234 virtual void LoadURL(const GURL& url,
158 const Referrer& referrer, 235 const Referrer& referrer,
159 PageTransition type, 236 PageTransition type,
160 const std::string& extra_headers) = 0; 237 const std::string& extra_headers) = 0;
161 238
162 // Same as LoadURL, but for renderer-initiated navigations. This state is 239 // More general version of LoadURL. See comments in LoadURLParams for
163 // important for tracking whether to display pending URLs. 240 // using |extra_params|.
Charlie Reis 2012/08/03 21:28:36 nit: |params|
boliu 2012/08/03 22:42:08 Done.
164 virtual void LoadURLFromRenderer(const GURL& url, 241 virtual void LoadURLWithParams(LoadURLParams& params) = 0;
gone 2012/08/03 20:17:37 Feels like the LoadURLParams struct should only ca
boliu 2012/08/03 20:46:27 I was debating about this. And previous Patch Set
Charlie Reis 2012/08/03 21:28:36 I'm ok with it as is.
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 242
193 // Loads the current page if this NavigationController was restored from 243 // Loads the current page if this NavigationController was restored from
194 // history and the current page has not loaded yet. 244 // history and the current page has not loaded yet.
195 virtual void LoadIfNecessary() = 0; 245 virtual void LoadIfNecessary() = 0;
196 246
197 // Renavigation -------------------------------------------------------------- 247 // Renavigation --------------------------------------------------------------
198 248
199 // Navigation relative to the "current entry" 249 // Navigation relative to the "current entry"
200 virtual bool CanGoBack() const = 0; 250 virtual bool CanGoBack() const = 0;
201 virtual bool CanGoForward() const = 0; 251 virtual bool CanGoForward() const = 0;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 virtual void CopyStateFromAndPrune(NavigationController* source) = 0; 320 virtual void CopyStateFromAndPrune(NavigationController* source) = 0;
271 321
272 // Removes all the entries except the active entry. If there is a new pending 322 // Removes all the entries except the active entry. If there is a new pending
273 // navigation it is preserved. 323 // navigation it is preserved.
274 virtual void PruneAllButActive() = 0; 324 virtual void PruneAllButActive() = 0;
275 }; 325 };
276 326
277 } // namespace content 327 } // namespace content
278 328
279 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_ 329 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698