summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authoraurimas@chromium.org <aurimas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-18 21:47:56 +0000
committeraurimas@chromium.org <aurimas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-18 21:47:56 +0000
commit2d02a200c2f156c8e80b2396f80b87756cdc425b (patch)
tree0faeb5881c32ce8bae5be35e6c042b7eeaf8b48c /content
parent41a8da1d1c970c0c7b7076beccb549592b4f60f8 (diff)
downloadchromium_src-2d02a200c2f156c8e80b2396f80b87756cdc425b.zip
chromium_src-2d02a200c2f156c8e80b2396f80b87756cdc425b.tar.gz
chromium_src-2d02a200c2f156c8e80b2396f80b87756cdc425b.tar.bz2
Upstreaming SelectFileDialog for Android
Upstreaming the Select File Dialog and its dependencies needed for Chrome on Android BUG=116131 Review URL: https://chromiumcodereview.appspot.com/10916160 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157424 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/DEPS1
-rw-r--r--content/app/android/library_loader_hooks.cc4
-rw-r--r--content/browser/android/content_view_core_impl.cc17
-rw-r--r--content/browser/android/content_view_core_impl.h11
-rw-r--r--content/browser/web_contents/web_contents_view_android.cc2
-rw-r--r--content/content.gyp2
-rw-r--r--content/content_shell.gypi1
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentView.java36
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java8
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/JellyBeanContentView.java8
-rw-r--r--content/public/browser/android/content_view_core.h6
-rw-r--r--content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java2
-rw-r--r--content/shell/android/java/src/org/chromium/content_shell/Shell.java11
-rw-r--r--content/shell/android/java/src/org/chromium/content_shell/ShellManager.java10
14 files changed, 92 insertions, 27 deletions
diff --git a/content/DEPS b/content/DEPS
index 24d5b0c..a79d9c67b 100644
--- a/content/DEPS
+++ b/content/DEPS
@@ -46,6 +46,7 @@ include_rules = [
"+third_party/WebKit/Source/Platform/chromium",
"+third_party/WebKit/Source/WebKit/chromium",
+ "+ui/android",
# Aura is analogous to Win32 or a Gtk, so it is allowed.
"+ui/aura",
"+ui/base",
diff --git a/content/app/android/library_loader_hooks.cc b/content/app/android/library_loader_hooks.cc
index 65b3b24..a60155f 100644
--- a/content/app/android/library_loader_hooks.cc
+++ b/content/app/android/library_loader_hooks.cc
@@ -24,6 +24,7 @@
#include "content/public/common/content_switches.h"
#include "media/base/android/media_jni_registrar.h"
#include "net/android/net_jni_registrar.h"
+#include "ui/android/ui_jni_registrar.h"
#include "jni/LibraryLoader_jni.h"
#include "ui/gfx/android/gfx_jni_registrar.h"
@@ -66,6 +67,9 @@ static jboolean LibraryLoadedOnMainThread(JNIEnv* env, jclass clazz,
if (!net::android::RegisterJni(env))
return JNI_FALSE;
+ if (!ui::RegisterJni(env))
+ return JNI_FALSE;
+
if (!content::android::RegisterCommonJni(env))
return JNI_FALSE;
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index b79b4ad..4e8d88f 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -35,6 +35,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/android/WebInputEventFactory.h"
#include "ui/gfx/android/java_bitmap.h"
+#include "ui/gfx/android/window_android.h"
#include "webkit/glue/webmenuitem.h"
#include "webkit/user_agent/user_agent_util.h"
@@ -79,11 +80,13 @@ ContentViewCore* ContentViewCore::GetNativeContentViewCore(JNIEnv* env,
ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj,
bool hardware_accelerated,
bool take_ownership_of_web_contents,
- WebContents* web_contents)
+ WebContents* web_contents,
+ ui::WindowAndroid* window_android)
: java_ref_(env, obj),
web_contents_(static_cast<WebContentsImpl*>(web_contents)),
owns_web_contents_(take_ownership_of_web_contents),
- tab_crashed_(false) {
+ tab_crashed_(false),
+ window_android_(window_android) {
DCHECK(web_contents) <<
"A ContentViewCoreImpl should be created with a valid WebContents.";
@@ -539,6 +542,10 @@ void ContentViewCoreImpl::LoadUrl(
tab_crashed_ = false;
}
+ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() {
+ return window_android_;
+}
+
// ----------------------------------------------------------------------------
// Native JNI methods
// ----------------------------------------------------------------------------
@@ -547,10 +554,12 @@ void ContentViewCoreImpl::LoadUrl(
jint Init(JNIEnv* env, jobject obj,
jboolean hardware_accelerated,
jboolean take_ownership_of_web_contents,
- jint native_web_contents) {
+ jint native_web_contents,
+ jint native_window) {
ContentViewCoreImpl* view = new ContentViewCoreImpl(
env, obj, hardware_accelerated, take_ownership_of_web_contents,
- reinterpret_cast<WebContents*>(native_web_contents));
+ reinterpret_cast<WebContents*>(native_web_contents),
+ reinterpret_cast<ui::WindowAndroid*>(native_window));
return reinterpret_cast<jint>(view);
}
diff --git a/content/browser/android/content_view_core_impl.h b/content/browser/android/content_view_core_impl.h
index 1884c3a..9ddc242 100644
--- a/content/browser/android/content_view_core_impl.h
+++ b/content/browser/android/content_view_core_impl.h
@@ -24,6 +24,10 @@
struct WebMenuItem;
+namespace ui {
+class WindowAndroid;
+}
+
namespace content {
class ContentViewClient;
class RenderWidgetHostViewAndroid;
@@ -36,7 +40,8 @@ class ContentViewCoreImpl : public ContentViewCore,
jobject obj,
bool hardware_accelerated,
bool take_ownership_of_web_contents,
- WebContents* web_contents);
+ WebContents* web_contents,
+ ui::WindowAndroid* window_android);
// ContentViewCore overrides
virtual void Destroy(JNIEnv* env, jobject obj) OVERRIDE;
@@ -172,6 +177,7 @@ class ContentViewCoreImpl : public ContentViewCore,
WebContents* web_contents() const { return web_contents_; }
virtual void LoadUrl(NavigationController::LoadURLParams& params) OVERRIDE;
+ virtual ui::WindowAndroid* GetWindowAndroid() OVERRIDE;
private:
// NotificationObserver implementation.
@@ -218,6 +224,9 @@ class ContentViewCoreImpl : public ContentViewCore,
// Whether the renderer backing this ContentViewCore has crashed.
bool tab_crashed_;
+ // The owning window that has a hold of main application activity.
+ ui::WindowAndroid* window_android_;
+
DISALLOW_COPY_AND_ASSIGN(ContentViewCoreImpl);
};
diff --git a/content/browser/web_contents/web_contents_view_android.cc b/content/browser/web_contents/web_contents_view_android.cc
index 57edaf3..bebc663 100644
--- a/content/browser/web_contents/web_contents_view_android.cc
+++ b/content/browser/web_contents/web_contents_view_android.cc
@@ -79,7 +79,7 @@ gfx::NativeView WebContentsViewAndroid::GetContentNativeView() const {
}
gfx::NativeWindow WebContentsViewAndroid::GetTopLevelNativeWindow() const {
- return content_view_core_;
+ return content_view_core_->GetWindowAndroid();
}
void WebContentsViewAndroid::GetContainerBounds(gfx::Rect* out) const {
diff --git a/content/content.gyp b/content/content.gyp
index 168089b..510faeb 100644
--- a/content/content.gyp
+++ b/content/content.gyp
@@ -282,12 +282,14 @@
'dependencies': [
'../base/base.gyp:base',
'../net/net.gyp:net',
+ '../ui/ui.gyp:ui_java',
'common_aidl',
'content_common',
],
'export_dependent_settings': [
'../base/base.gyp:base',
'../net/net.gyp:net',
+ '../ui/ui.gyp:ui_java',
],
'variables': {
'package_name': 'content',
diff --git a/content/content_shell.gypi b/content/content_shell.gypi
index 17d9698..2143ed2 100644
--- a/content/content_shell.gypi
+++ b/content/content_shell.gypi
@@ -603,6 +603,7 @@
'../base/base.gyp:base_java',
'../media/media.gyp:media_java',
'../net/net.gyp:net_java',
+ '../ui/ui.gyp:ui_java',
],
'actions': [
{
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentView.java b/content/public/android/java/src/org/chromium/content/browser/ContentView.java
index 669e546..bc36612 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentView.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentView.java
@@ -20,6 +20,7 @@ import android.webkit.DownloadListener;
import android.widget.FrameLayout;
import org.chromium.content.browser.ContentViewCore;
+import org.chromium.ui.gfx.NativeWindow;
/**
* The containing view for {@link ContentViewCore} that exists in the Android UI hierarchy and
@@ -96,12 +97,14 @@ public class ContentView extends FrameLayout implements ContentViewCore.Internal
* @param context The Context the view is running in, through which it can
* access the current theme, resources, etc.
* @param nativeWebContents A pointer to the native web contents.
+ * @param nativeWindow An instance of the NativeWindow.
* @param personality One of {@link #PERSONALITY_CHROME} or {@link #PERSONALITY_VIEW}.
* @return A ContentView instance.
*/
- public static ContentView newInstance(Context context, int nativeWebContents, int personality) {
- return newInstance(context, nativeWebContents, null, android.R.attr.webViewStyle,
- personality);
+ public static ContentView newInstance(Context context, int nativeWebContents,
+ NativeWindow nativeWindow, int personality) {
+ return newInstance(context, nativeWebContents, nativeWindow, null,
+ android.R.attr.webViewStyle, personality);
}
/**
@@ -109,14 +112,16 @@ public class ContentView extends FrameLayout implements ContentViewCore.Internal
* @param context The Context the view is running in, through which it can
* access the current theme, resources, etc.
* @param nativeWebContents A pointer to the native web contents.
+ * @param nativeWindow An instance of the NativeWindow.
* @param attrs The attributes of the XML tag that is inflating the view.
* @return A ContentView instance.
*/
public static ContentView newInstance(Context context, int nativeWebContents,
- AttributeSet attrs) {
+ NativeWindow nativeWindow, AttributeSet attrs) {
// TODO(klobag): use the WebViewStyle as the default style for now. It enables scrollbar.
// When ContentView is moved to framework, we can define its own style in the res.
- return newInstance(context, nativeWebContents, attrs, android.R.attr.webViewStyle);
+ return newInstance(context, nativeWebContents, nativeWindow, attrs,
+ android.R.attr.webViewStyle);
}
/**
@@ -124,31 +129,34 @@ public class ContentView extends FrameLayout implements ContentViewCore.Internal
* @param context The Context the view is running in, through which it can
* access the current theme, resources, etc.
* @param nativeWebContents A pointer to the native web contents.
+ * @param nativeWindow An instance of the NativeWindow.
* @param attrs The attributes of the XML tag that is inflating the view.
* @param defStyle The default style to apply to this view.
* @return A ContentView instance.
*/
public static ContentView newInstance(Context context, int nativeWebContents,
- AttributeSet attrs, int defStyle) {
- return newInstance(context, nativeWebContents, attrs, defStyle, PERSONALITY_VIEW);
+ NativeWindow nativeWindow, AttributeSet attrs, int defStyle) {
+ return newInstance(context, nativeWebContents, nativeWindow, attrs, defStyle,
+ PERSONALITY_VIEW);
}
private static ContentView newInstance(Context context, int nativeWebContents,
- AttributeSet attrs, int defStyle, int personality) {
+ NativeWindow nativeWindow, AttributeSet attrs, int defStyle, int personality) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
- return new ContentView(context, nativeWebContents, attrs, defStyle, personality);
- } else {
- return new JellyBeanContentView(context, nativeWebContents, attrs, defStyle,
+ return new ContentView(context, nativeWebContents, nativeWindow, attrs, defStyle,
personality);
+ } else {
+ return new JellyBeanContentView(context, nativeWebContents, nativeWindow, attrs,
+ defStyle, personality);
}
}
- protected ContentView(Context context, int nativeWebContents, AttributeSet attrs, int defStyle,
- int personality) {
+ protected ContentView(Context context, int nativeWebContents, NativeWindow nativeWindow,
+ AttributeSet attrs, int defStyle, int personality) {
super(context, attrs, defStyle);
mContentViewCore = new ContentViewCore(context, personality);
- mContentViewCore.initialize(this, this, true, nativeWebContents, false);
+ mContentViewCore.initialize(this, this, true, nativeWebContents, nativeWindow, false);
}
/**
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index 41b9a73..72404b2 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -35,6 +35,7 @@ import org.chromium.content.browser.TouchPoint;
import org.chromium.content.browser.ZoomManager;
import org.chromium.content.common.CleanupReference;
import org.chromium.content.common.TraceEvent;
+import org.chromium.ui.gfx.NativeWindow;
/**
* Provides a Java-side 'wrapper' around a WebContent (native) instance.
@@ -311,6 +312,7 @@ public class ContentViewCore implements MotionEventDelegate {
* @param takeOwnershipOfWebContents Whether this object will take ownership of
* nativeWebContents over on its native side.
* @param nativeWebContents A pointer to the native web contents.
+ * @param nativeWindow An instance of the NativeWindow.
* @param isAccessFromFileURLsGrantedByDefault Default WebSettings configuration.
*/
// Perform important post-construction set up of the ContentViewCore.
@@ -321,11 +323,11 @@ public class ContentViewCore implements MotionEventDelegate {
// We supply the nativeWebContents pointer here rather than in the constructor to allow us
// to set the private browsing mode at a later point for the WebView implementation.
public void initialize(ViewGroup containerView, InternalAccessDelegate internalDispatcher,
- boolean takeOwnershipOfWebContents, int nativeWebContents,
+ boolean takeOwnershipOfWebContents, int nativeWebContents, NativeWindow nativeWindow,
boolean isAccessFromFileURLsGrantedByDefault) {
mContainerView = containerView;
mNativeContentViewCore = nativeInit(mHardwareAccelerated, takeOwnershipOfWebContents,
- nativeWebContents);
+ nativeWebContents, nativeWindow.getNativePointer());
mCleanupReference = new CleanupReference(
this, new DestroyRunnable(mNativeContentViewCore));
mContentSettings = new ContentSettings(
@@ -1327,7 +1329,7 @@ public class ContentViewCore implements MotionEventDelegate {
// The following methods are implemented at native side.
private native int nativeInit(boolean hardwareAccelerated, boolean takeOwnershipOfWebContents,
- int webContentsPtr);
+ int webContentsPtr, int windowAndroidPtr);
private static native void nativeDestroy(int nativeContentViewCore);
diff --git a/content/public/android/java/src/org/chromium/content/browser/JellyBeanContentView.java b/content/public/android/java/src/org/chromium/content/browser/JellyBeanContentView.java
index 289f869..1bc2fae 100644
--- a/content/public/android/java/src/org/chromium/content/browser/JellyBeanContentView.java
+++ b/content/public/android/java/src/org/chromium/content/browser/JellyBeanContentView.java
@@ -10,13 +10,15 @@ import android.util.AttributeSet;
import android.view.View;
import android.view.accessibility.AccessibilityNodeInfo;
+import org.chromium.ui.gfx.NativeWindow;
+
/**
* A version of {@link ContentView} that supports JellyBean features.
*/
class JellyBeanContentView extends ContentView {
- JellyBeanContentView(Context context, int nativeWebContents, AttributeSet attrs, int defStyle,
- int personality) {
- super(context, nativeWebContents, attrs, defStyle, personality);
+ JellyBeanContentView(Context context, int nativeWebContents, NativeWindow nativeWindow,
+ AttributeSet attrs, int defStyle, int personality) {
+ super(context, nativeWebContents, nativeWindow, attrs, defStyle, personality);
}
@Override
diff --git a/content/public/browser/android/content_view_core.h b/content/public/browser/android/content_view_core.h
index 0c38fb1..2c82ab1 100644
--- a/content/public/browser/android/content_view_core.h
+++ b/content/public/browser/android/content_view_core.h
@@ -5,10 +5,15 @@
#ifndef CONTENT_PUBLIC_BROWSER_ANDROID_CONTENT_VIEW_CORE_H_
#define CONTENT_PUBLIC_BROWSER_ANDROID_CONTENT_VIEW_CORE_H_
+#include "base/android/scoped_java_ref.h"
#include <jni.h>
class GURL;
+namespace ui {
+class WindowAndroid;
+}
+
namespace content {
class WebContents;
@@ -49,6 +54,7 @@ class ContentViewCore {
virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() = 0;
+ virtual ui::WindowAndroid* GetWindowAndroid() = 0;
protected:
virtual ~ContentViewCore() {};
};
diff --git a/content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java b/content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java
index 8542a41..2edf7a2 100644
--- a/content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java
+++ b/content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java
@@ -15,6 +15,7 @@ import org.chromium.content.app.AppResource;
import org.chromium.content.app.LibraryLoader;
import org.chromium.content.browser.ContentView;
import org.chromium.content.common.CommandLine;
+import org.chromium.ui.gfx.NativeWindow;
/**
* Activity for managing the Content Shell.
@@ -42,6 +43,7 @@ public class ContentShellActivity extends Activity {
setContentView(R.layout.content_shell_activity);
mShellManager = (ShellManager) findViewById(R.id.shell_container);
+ mShellManager.setWindow(new NativeWindow(this));
String startupUrl = getUrlFromIntent(getIntent());
if (!TextUtils.isEmpty(startupUrl)) {
diff --git a/content/shell/android/java/src/org/chromium/content_shell/Shell.java b/content/shell/android/java/src/org/chromium/content_shell/Shell.java
index aa34181..21ce108 100644
--- a/content/shell/android/java/src/org/chromium/content_shell/Shell.java
+++ b/content/shell/android/java/src/org/chromium/content_shell/Shell.java
@@ -23,6 +23,7 @@ import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.content.browser.ContentView;
import org.chromium.content.browser.LoadUrlParams;
+import org.chromium.ui.gfx.NativeWindow;
/**
* Container for the various UI components that make up a shell window.
@@ -48,6 +49,7 @@ public class Shell extends LinearLayout {
private ClipDrawable mProgressDrawable;
private View mSurfaceView;
+ private NativeWindow mWindow;
/**
* Constructor for inflating via XML.
@@ -67,6 +69,13 @@ public class Shell extends LinearLayout {
FrameLayout.LayoutParams.MATCH_PARENT));
}
+ /**
+ * @param window The owning window for this shell.
+ */
+ public void setWindow(NativeWindow window) {
+ mWindow = window;
+ }
+
@Override
protected void onFinishInflate() {
super.onFinishInflate();
@@ -173,7 +182,7 @@ public class Shell extends LinearLayout {
@CalledByNative
private void initFromNativeTabContents(int nativeTabContents) {
mContentView = ContentView.newInstance(
- getContext(), nativeTabContents, ContentView.PERSONALITY_CHROME);
+ getContext(), nativeTabContents, mWindow, ContentView.PERSONALITY_CHROME);
if (mContentView.getUrl() != null) mUrlTextView.setText(mContentView.getUrl());
((FrameLayout) findViewById(R.id.contentview_holder)).addView(mContentView,
new FrameLayout.LayoutParams(
diff --git a/content/shell/android/java/src/org/chromium/content_shell/ShellManager.java b/content/shell/android/java/src/org/chromium/content_shell/ShellManager.java
index 3aba276..f4bb2d6 100644
--- a/content/shell/android/java/src/org/chromium/content_shell/ShellManager.java
+++ b/content/shell/android/java/src/org/chromium/content_shell/ShellManager.java
@@ -14,6 +14,7 @@ import android.widget.FrameLayout;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
+import org.chromium.ui.gfx.NativeWindow;
/**
* Container and generator of ShellViews.
@@ -21,6 +22,7 @@ import org.chromium.base.JNINamespace;
@JNINamespace("content")
public class ShellManager extends FrameLayout {
+ private NativeWindow mWindow;
private Shell mActiveShell;
private String mStartupUrl = ContentShellActivity.DEFAULT_SHELL_URL;
@@ -56,6 +58,13 @@ public class ShellManager extends FrameLayout {
}
/**
+ * @param window The window used to generate all shells.
+ */
+ public void setWindow(NativeWindow window) {
+ mWindow = window;
+ }
+
+ /**
* Sets the startup URL for new shell windows.
*/
public void setStartupUrl(String url) {
@@ -84,6 +93,7 @@ public class ShellManager extends FrameLayout {
(LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Shell shellView = (Shell) inflater.inflate(R.layout.shell_view, null);
shellView.setSurfaceView(mSurfaceView);
+ shellView.setWindow(mWindow);
removeAllViews();
if (mActiveShell != null && mActiveShell.getContentView() != null) {