summaryrefslogtreecommitdiffstats
path: root/content/public
diff options
context:
space:
mode:
authorleandrogracia@chromium.org <leandrogracia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-25 15:06:46 +0000
committerleandrogracia@chromium.org <leandrogracia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-25 15:06:46 +0000
commit538db3cf7defc837cfde1dd75321e469baf19db2 (patch)
tree4b32af76d493396cbab154a63464468f2082fdb3 /content/public
parent36b0335c48e8d62fa745a2a3c3d7a81eb626a437 (diff)
downloadchromium_src-538db3cf7defc837cfde1dd75321e469baf19db2.zip
chromium_src-538db3cf7defc837cfde1dd75321e469baf19db2.tar.gz
chromium_src-538db3cf7defc837cfde1dd75321e469baf19db2.tar.bz2
Provide a common interface for all Android app resources.
BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/10626017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143909 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/public')
-rw-r--r--content/public/android/java/org/chromium/content/app/AppResource.java40
-rw-r--r--content/public/android/java/org/chromium/content/browser/AndroidBrowserProcess.java19
-rw-r--r--content/public/android/java/org/chromium/content/browser/ContentView.java19
3 files changed, 60 insertions, 18 deletions
diff --git a/content/public/android/java/org/chromium/content/app/AppResource.java b/content/public/android/java/org/chromium/content/app/AppResource.java
new file mode 100644
index 0000000..4178702
--- /dev/null
+++ b/content/public/android/java/org/chromium/content/app/AppResource.java
@@ -0,0 +1,40 @@
+// 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.app;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+
+/**
+ * Interface to list and expose any required Android app resources.
+ * All resources must be registered before instantiating ContentView objects.
+ */
+public class AppResource {
+ /** Array resource containing the official command line arguments. */
+ public static int ARRAY_OFFICIAL_COMMAND_LINE;
+
+ /** Dimension of the radius used in the link preview overlay. */
+ public static int DIMENSION_LINK_PREVIEW_OVERLAY_RADIUS;
+
+ /** Drawable resource for the link preview popup overlay. */
+ public static int DRAWABLE_LINK_PREVIEW_POPUP_OVERLAY;
+
+ /**
+ * Iterates through all the resources ids and verifies they have values other than zero.
+ * @return true if all the resources have been registered.
+ */
+ public static boolean verifyResourceRegistration() {
+ Field[] fields = AppResource.class.getDeclaredFields();
+ for (Field field : fields) {
+ try {
+ if (field.getType().equals(int.class) && Modifier.isStatic(field.getModifiers())) {
+ if (field.getInt(null) == 0) return false;
+ }
+ } catch (IllegalAccessException e) {
+ }
+ }
+ return true;
+ }
+}
diff --git a/content/public/android/java/org/chromium/content/browser/AndroidBrowserProcess.java b/content/public/android/java/org/chromium/content/browser/AndroidBrowserProcess.java
index f848e17..b3ddb81 100644
--- a/content/public/android/java/org/chromium/content/browser/AndroidBrowserProcess.java
+++ b/content/public/android/java/org/chromium/content/browser/AndroidBrowserProcess.java
@@ -9,9 +9,11 @@ import android.content.Context;
import android.content.res.Resources;
import android.util.Log;
+import org.chromium.content.app.AppResource;
import org.chromium.content.app.ContentMain;
import org.chromium.content.app.LibraryLoader;
import org.chromium.content.browser.ContentView;
+import org.chromium.content.common.CommandLine;
// NOTE: This file hasn't been fully upstreamed, please don't merge to downstream.
public class AndroidBrowserProcess {
@@ -89,6 +91,23 @@ public class AndroidBrowserProcess {
Context appContext = context.getApplicationContext();
+ // This block is inside genericChromiumProcessInit() instead
+ // of initChromiumBrowserProcess() to make sure we do it once.
+ // In here it is protected with the sInitialized.
+ if (hostIsChrome) {
+ if (nativeIsOfficialBuild() ||
+ CommandLine.getInstance().hasSwitch(CommandLine.ADD_OFFICIAL_COMMAND_LINE)) {
+ Resources res = context.getResources();
+ try {
+ String[] switches = res.getStringArray(AppResource.ARRAY_OFFICIAL_COMMAND_LINE);
+ CommandLine.getInstance().appendSwitchesAndArguments(switches);
+ } catch (Resources.NotFoundException e) {
+ // Do nothing. It is fine to have no command line
+ // additions for an official build.
+ }
+ }
+ }
+
int maxRenderers = normalizeMaxRendererProcesses(appContext, maxRendererProcesses);
Log.i(TAG, "Initializing chromium process, renderers=" + maxRenderers +
" hostIsChrome=" + hostIsChrome);
diff --git a/content/public/android/java/org/chromium/content/browser/ContentView.java b/content/public/android/java/org/chromium/content/browser/ContentView.java
index 8db0a9a..10b636a 100644
--- a/content/public/android/java/org/chromium/content/browser/ContentView.java
+++ b/content/public/android/java/org/chromium/content/browser/ContentView.java
@@ -12,6 +12,7 @@ import android.webkit.DownloadListener;
import android.widget.FrameLayout;
import org.chromium.base.WeakContext;
+import org.chromium.content.app.AppResource;
import org.chromium.content.common.TraceEvent;
public class ContentView extends FrameLayout {
@@ -95,24 +96,6 @@ public class ContentView extends FrameLayout {
AndroidBrowserProcess.initContentViewProcess(context, maxRendererProcesses);
}
- /**
- * Registers the drawable to be used for overlaying the popup zoomer contents. The drawable
- * should be transparent in the middle to allow the zoomed content to show.
- *
- * @param id The id of the drawable to be used to overlay the popup zoomer contents.
- */
- public static void registerPopupOverlayResourceId(int id) {
- // TODO(tedchoc): Implement.
- }
-
- /**
- * Sets how much to round the corners of the popup contents.
- * @param r The radius of the rounded corners of the popup overlay drawable.
- */
- public static void registerPopupOverlayCornerRadius(float r) {
- // TODO(tedchoc): Implement.
- }
-
public ContentView(Context context, int nativeWebContents, int personality) {
this(context, nativeWebContents, null, android.R.attr.webViewStyle, personality);
}