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

Unified 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: address comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/browser/android/navigation_controller_webview.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/browser/navigation_controller.h
diff --git a/content/public/browser/navigation_controller.h b/content/public/browser/navigation_controller.h
index 4932ba0f0a155612446fe43ad9f53fcccf95a4bf..2731569686a09137be7f160b5d82a2594cfad181 100644
--- a/content/public/browser/navigation_controller.h
+++ b/content/public/browser/navigation_controller.h
@@ -8,12 +8,13 @@
#include <string>
#include <vector>
+#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
#include "base/string16.h"
#include "content/common/content_export.h"
#include "content/public/browser/global_request_id.h"
#include "content/public/common/page_transition_types.h"
-
-class GURL;
+#include "content/public/common/referrer.h"
+#include "googleurl/src/gurl.h"
namespace content {
@@ -21,7 +22,6 @@ class BrowserContext;
class NavigationEntry;
class SessionStorageNamespace;
class WebContents;
-struct Referrer;
// A NavigationController maintains the back-forward list for a WebContents and
// manages all navigation within that list.
@@ -36,6 +36,35 @@ class NavigationController {
RELOAD_IGNORING_CACHE // Reload bypassing the cache, aka shift-reload.
};
+ // Load type used in LoadURLParams.
+ enum LoadURLType {
+ // For loads that do not fall into any types below.
+ LOAD_TYPE_DEFAULT,
+
+ // An http post load request initiated from browser side.
+ // The post data is passed in |browser_initiated_post_data|.
+ LOAD_TYPE_BROWSER_INITIATED_HTTP_POST,
+
+ // Loads a 'data:' scheme URL with specified base URL and a history entry
+ // URL. This is only safe to be used for browser-initiated data: URL
+ // navigations, since it shows arbitrary content as if it comes from
+ // |virtual_url_for_data_url|.
+ LOAD_TYPE_DATA
+ };
+
+ // User agent override type used in LoadURLParams.
+ enum UserAgentOverrideOption {
+ // Use the override value from the previous NavigationEntry in the
+ // NavigationController.
+ UA_OVERRIDE_INHERIT,
+
+ // Use the default user agent.
+ UA_OVERRIDE_FALSE,
+
+ // Use the user agent override, if it's available.
+ UA_OVERRIDE_TRUE
+ };
+
// Creates a navigation entry and translates the virtual url to a real one.
// This is a general call; prefer LoadURL[FromRenderer]/TransferURL below.
// Extra headers are separated by \n.
@@ -47,6 +76,60 @@ class NavigationController {
const std::string& extra_headers,
BrowserContext* browser_context);
+ // Extra optional parameters for LoadURLWithParams.
+ CONTENT_EXPORT struct LoadURLParams {
+ // The url to load. This field is required.
+ const GURL url;
+
+ // See LoadURLType comments above.
+ LoadURLType load_type;
+
+ // PageTransition for this load. See PageTransition for details.
+ // Note the default value in constructor below.
+ PageTransition transition_type;
+
+ // Referrer for this load. Empty if none.
+ Referrer referrer;
+
+ // Extra headers for this load, separated by \n.
+ std::string extra_headers;
+
+ // True for renderer-initiated navigations. This is
+ // important for tracking whether to display pending URLs.
+ bool is_renderer_initiated;
+
+ // User agent override for this load. See comments in
+ // UserAgentOverrideOption definition.
+ UserAgentOverrideOption override_user_agent;
+
+ // Marks the new navigation as being transferred from one RVH to another.
+ // In this case the browser can recycle the old request once the new
+ // renderer wants to navigate. Identifies the request ID of the old request.
+ GlobalRequestID transferred_global_request_id;
+
+ // Used in LOAD_TYPE_DATA loads only. Used for specifying a base URL
+ // for pages loaded via data URLs.
+ GURL base_url_for_data_url;
+
+ // Used in LOAD_TYPE_DATA loads only. URL displayed to the user for
+ // data loads.
+ GURL virtual_url_for_data_url;
+
+ // Used in LOAD_TYPE_BROWSER_INITIATED_HTTP_POST loads only. Carries the
+ // post data of the load. Ownership is transferred to NavigationController
+ // after LoadURLWithParams call.
+ 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.
+
+ 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
+ : url(url),
+ load_type(LOAD_TYPE_DEFAULT),
+ transition_type(PAGE_TRANSITION_LINK),
+ is_renderer_initiated(false),
+ override_user_agent(UA_OVERRIDE_INHERIT),
+ browser_initiated_post_data(NULL) {
+ }
+ };
+
// Disables checking for a repost and prompting the user. This is used during
// testing.
CONTENT_EXPORT static void DisablePromptOnRepost();
@@ -159,36 +242,9 @@ class NavigationController {
PageTransition type,
const std::string& extra_headers) = 0;
- // Same as LoadURL, but for renderer-initiated navigations. This state is
- // important for tracking whether to display pending URLs.
- virtual void LoadURLFromRenderer(const GURL& url,
- const Referrer& referrer,
- PageTransition type,
- const std::string& extra_headers) = 0;
-
- // Same as LoadURL, but allows overriding the user agent of the
- // NavigationEntry before it loads.
- // TODO(dfalcantara): Consolidate the LoadURL* interfaces.
- virtual void LoadURLWithUserAgentOverride(const GURL& url,
- const Referrer& referrer,
- PageTransition type,
- bool is_renderer_initiated,
- const std::string& extra_headers,
- bool is_overriding_user_agent) = 0;
-
- // Behaves like LoadURL() and LoadURLFromRenderer() but marks the new
- // navigation as being transferred from one RVH to another. In this case the
- // browser can recycle the old request once the new renderer wants to
- // navigate.
- // |transferred_global_request_id| identifies the request ID of the old
- // request.
- virtual void TransferURL(
- const GURL& url,
- const Referrer& referrer,
- PageTransition transition,
- const std::string& extra_headers,
- const GlobalRequestID& transferred_global_request_id,
- bool is_renderer_initiated) = 0;
+ // More general version of LoadURL. See comments in LoadURLParams for
+ // using |params|.
+ 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.
// Loads the current page if this NavigationController was restored from
// history and the current page has not loaded yet.
« no previous file with comments | « content/public/browser/android/navigation_controller_webview.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698