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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/LoadUrlParams.java

Issue 10823207: Consolidate ContentViewCore::Load* functions (Closed) Base URL: http://git.chromium.org/chromium/src.git@cleanup_load
Patch Set: Fix #include. Fix #ifndef guard. Add java doc. 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
Index: content/public/android/java/src/org/chromium/content/browser/LoadUrlParams.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/LoadUrlParams.java b/content/public/android/java/src/org/chromium/content/browser/LoadUrlParams.java
new file mode 100644
index 0000000000000000000000000000000000000000..84cd968031ef1c0cdde017b77e8916b8a7fadaa6
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/browser/LoadUrlParams.java
@@ -0,0 +1,121 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.content.browser;
+
+import org.chromium.base.CalledByNative;
+
+/**
+ * Holds parameters for ContentViewCore.LoadUrl. Parameters should match
+ * counterparts in NavigationController::LoadURLParams, including default
+ * values.
+ */
+public class LoadUrlParams {
Yaron 2012/08/09 21:32:31 Add @JNINamespace("content")
boliu 2012/08/10 01:17:19 Done.
+ // Should match NavigationController::LoadUrlType exactly. See comments
+ // there for proper usage. Values are initialized in initializeConstants.
+ public static int LOAD_TYPE_DEFAULT;
+ public static int LOAD_TYPE_BROWSER_INITIATED_HTTP_POST;
+ public static int LOAD_TYPE_DATA;
+
+ // Should match NavigationController::UserAgentOverrideOption exactly.
+ // See comments there for proper usage. Values are initialized in
+ // initializeConstants.
+ public static int UA_OVERRIDE_INHERIT;
+ public static int UA_OVERRIDE_FALSE;
+ public static int UA_OVERRIDE_TRUE;
+
+ // Fields with counterparts in NavigationController::LoadURLParams
+ // Package private so that ContentViewCore.loadUrl can pass them down to
+ // native code. Should not be accessed directly anywhere else outside of
+ // this class.
+ final String mUrl;
+ int mLoadUrlType;
+ int mTransitionType;
+ int mUaOverrideOption;
+ byte[] mPostData;
+ String mBaseUrlForDataUrl;
+ String mVirtualUrlForDataUrl;
+
+ public LoadUrlParams(String url) {
+ // Check initializeConstants was called.
+ assert LOAD_TYPE_DEFAULT != LOAD_TYPE_BROWSER_INITIATED_HTTP_POST;
+
+ mUrl = url;
+ mLoadUrlType = LOAD_TYPE_DEFAULT;
+ mTransitionType = ContentViewCore.PAGE_TRANSITION_LINK;
+ mUaOverrideOption = UA_OVERRIDE_INHERIT;
+ mPostData = null;
+ mBaseUrlForDataUrl = null;
+ mVirtualUrlForDataUrl = null;
+ }
+
+ /**
+ * Set load type of this load. Defaults to LOAD_TYPE_DEFAULT.
+ * @param loadType One of LOAD_TYPE static constants above.
+ */
+ public void setLoadType(int loadType) {
+ mLoadUrlType = loadType;
+ }
+
+ /**
+ * Set transition type of this load. Defaults to PAGE_TRANSITION_LINK.
+ * @param transitionType One of PAGE_TRANSITION static constants in ContentView.
+ */
+ public void setTransitionType(int transitionType) {
+ mTransitionType = transitionType;
+ }
+
+ /**
+ * Set user agent override option of this load. Defaults to UA_OVERRIDE_INHERIT.
+ * @param uaOption One of UA_OVERRIDE static constants above.
+ */
+ public void setOverrideUserAgent(int uaOption) {
+ mUaOverrideOption = uaOption;
+ }
+
+ /**
+ * Set the post data of this load. This field is ignored unless load type is
+ * LOAD_TYPE_BROWSER_INITIATED_HTTP_POST.
+ * @param postData Post data for this http post load.
+ */
+ public void setPostData(byte[] postData) {
+ mPostData = postData;
+ }
+
+ /**
+ * Set the base url for data load. It is used both to resolve relative URLs
+ * and when applying JavaScript's same origin policy. It is ignored unless
+ * load type is LOAD_TYPE_DATA.
+ * @param baseUrl The base url for this data load.
+ */
+ public void setBaseUrlForDataUrl(String baseUrl) {
+ mBaseUrlForDataUrl = baseUrl;
+ }
+
+ /**
+ * Set the virtual url for data load. It is the url displayed to the user.
+ * It is ignored unless load type is LOAD_TYPE_DATA.
+ * @param virtualUrl The virtual url for this data load.
+ */
+ public void setVirtualUrlForDataUrl(String virtualUrl) {
+ mVirtualUrlForDataUrl = virtualUrl;
+ }
+
+ @SuppressWarnings("unused")
+ @CalledByNative
+ private static void initializeConstants(
+ int load_type_default,
+ int load_type_browser_initiated_http_post,
+ int load_type_data,
+ int ua_override_inherit,
+ int ua_override_false,
+ int ua_override_true) {
+ LOAD_TYPE_DEFAULT = load_type_default;
+ LOAD_TYPE_BROWSER_INITIATED_HTTP_POST = load_type_browser_initiated_http_post;
+ LOAD_TYPE_DATA = load_type_data;
+ UA_OVERRIDE_INHERIT = ua_override_inherit;
+ UA_OVERRIDE_FALSE = ua_override_false;
+ UA_OVERRIDE_TRUE = ua_override_true;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698