diff options
author | aurimas@chromium.org <aurimas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-19 08:38:12 +0000 |
---|---|---|
committer | aurimas@chromium.org <aurimas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-19 08:38:12 +0000 |
commit | f2c9f3fc6714915444f9d55f18f4b4f7e0b52bac (patch) | |
tree | 30b84c6577b91fd31deaef5f15a808542ac40941 | |
parent | ad81ae41a88cd603c260e5aa6ec7b24a60d650ea (diff) | |
download | chromium_src-f2c9f3fc6714915444f9d55f18f4b4f7e0b52bac.zip chromium_src-f2c9f3fc6714915444f9d55f18f4b4f7e0b52bac.tar.gz chromium_src-f2c9f3fc6714915444f9d55f18f4b4f7e0b52bac.tar.bz2 |
[Android] Rename NativeWindow to WindowAndroid.
Renaming NativeWindow to WindowAndroid for consistency with C++ name of window_android.
Also removing AwNativeWindow as according to joth@ it is no longer isued in WebView.
BUG=233064
Review URL: https://chromiumcodereview.appspot.com/14169011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195101 0039d316-1c4b-4281-b951-d872f2087c98
33 files changed, 170 insertions, 254 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java index bbf7101..1d8651c 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java @@ -43,7 +43,6 @@ import org.chromium.components.navigation_interception.InterceptNavigationDelega import org.chromium.components.navigation_interception.NavigationParams; import org.chromium.net.GURLUtils; import org.chromium.ui.gfx.DeviceDisplayInfo; -import org.chromium.ui.gfx.NativeWindow; import java.io.File; import java.lang.annotation.Annotation; @@ -284,10 +283,8 @@ public class AwContents { mCleanupReference = new CleanupReference(this, new DestroyRunnable(mNativeAwContents)); int nativeWebContents = nativeGetWebContents(mNativeAwContents); - mContentViewCore.initialize(containerView, internalAccessAdapter, - nativeWebContents, - new AwNativeWindow(mContainerView.getContext()), - isAccessFromFileURLsGrantedByDefault); + mContentViewCore.initialize(containerView, internalAccessAdapter, nativeWebContents, + null, isAccessFromFileURLsGrantedByDefault); mContentViewCore.setContentViewClient(mContentsClient); mLayoutSizer = new AwLayoutSizer(new AwLayoutSizerDelegate()); mContentViewCore.setContentSizeChangeListener(new AwContentStateChangeListener()); @@ -531,8 +528,7 @@ public class AwContents { // set it correctly when when we copy the settings from the old ContentViewCore // into the new one. newCore.initialize(mContainerView, mInternalAccessAdapter, - newWebContentsPtr, new AwNativeWindow(mContainerView.getContext()), - false); + newWebContentsPtr, null, false); newCore.setContentViewClient(mContentsClient); mContentsClient.installWebContentsObserver(newCore); diff --git a/android_webview/java/src/org/chromium/android_webview/AwNativeWindow.java b/android_webview/java/src/org/chromium/android_webview/AwNativeWindow.java deleted file mode 100644 index 31f77dc..0000000 --- a/android_webview/java/src/org/chromium/android_webview/AwNativeWindow.java +++ /dev/null @@ -1,28 +0,0 @@ -// 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.android_webview; - -import android.content.Context; -import android.content.Intent; - -import org.chromium.ui.gfx.NativeWindow; - -public class AwNativeWindow extends NativeWindow { - public AwNativeWindow(Context context) { - super(context); - } - - // The following stubs are required for displaying a file picker which is - // unsupported in the WebView. - public void sendBroadcast(Intent intent) { - } - - public boolean showIntent(Intent intent, IntentCallback callback, String error) { - return false; - } - - public void showError(String error) { - } -} diff --git a/chrome/android/java/src/org/chromium/chrome/browser/JavascriptAppModalDialog.java b/chrome/android/java/src/org/chromium/chrome/browser/JavascriptAppModalDialog.java index 7d064ab..171e5d8 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/JavascriptAppModalDialog.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/JavascriptAppModalDialog.java @@ -20,7 +20,7 @@ import com.google.common.annotations.VisibleForTesting; import org.chromium.base.CalledByNative; import org.chromium.chrome.R; -import org.chromium.ui.gfx.NativeWindow; +import org.chromium.ui.WindowAndroid; public class JavascriptAppModalDialog implements DialogInterface.OnClickListener { private static final String TAG = JavascriptAppModalDialog.class.getName(); @@ -67,7 +67,7 @@ public class JavascriptAppModalDialog implements DialogInterface.OnClickListener } @CalledByNative - void showJavascriptAppModalDialog(NativeWindow window, int nativeDialogPointer) { + void showJavascriptAppModalDialog(WindowAndroid window, int nativeDialogPointer) { assert window != null; Context context = window.getContext(); diff --git a/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java b/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java index 891d11f..972af11 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java @@ -6,7 +6,7 @@ package org.chromium.chrome.browser; import org.chromium.base.CalledByNative; import org.chromium.content.browser.ContentView; -import org.chromium.ui.gfx.NativeWindow; +import org.chromium.ui.WindowAndroid; /** * The basic Java representation of a tab. Contains and manages a {@link ContentView}. @@ -20,11 +20,11 @@ import org.chromium.ui.gfx.NativeWindow; * parent classes. */ public abstract class TabBase { - private final NativeWindow mNativeWindow; + private final WindowAndroid mWindowAndroid; private int mNativeTabAndroid; - protected TabBase(NativeWindow window) { - mNativeWindow = window; + protected TabBase(WindowAndroid window) { + mWindowAndroid = window; } @CalledByNative @@ -39,7 +39,7 @@ public abstract class TabBase { mNativeTabAndroid = nativePtr; } - protected NativeWindow getNativeWindow() { - return mNativeWindow; + protected WindowAndroid getWindowAndroid() { + return mWindowAndroid; } } diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogGlue.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogGlue.java index 3a65d7b..7423e3f 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogGlue.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillDialogGlue.java @@ -9,7 +9,7 @@ import android.graphics.Bitmap; import org.chromium.base.CalledByNative; import org.chromium.base.JNINamespace; import org.chromium.chrome.browser.autofill.AutofillDialog.AutofillDialogDelegate; -import org.chromium.ui.gfx.NativeWindow; +import org.chromium.ui.WindowAndroid; /** * JNI call glue for AutofillDialog C++ and Java objects. @@ -22,7 +22,7 @@ public class AutofillDialogGlue implements AutofillDialogDelegate, private final AutofillDialog mAutofillDialog; private final AutofillDialogAccountHelper mAccountHelper; - public AutofillDialogGlue(int nativeAutofillDialogViewAndroid, NativeWindow nativeWindow, + public AutofillDialogGlue(int nativeAutofillDialogViewAndroid, WindowAndroid nativeWindow, String useBillingForShippingText, String saveLocallyText) { mNativeDialogPopup = nativeAutofillDialogViewAndroid; mAccountHelper = new AutofillDialogAccountHelper(this, nativeWindow.getContext()); @@ -34,7 +34,7 @@ public class AutofillDialogGlue implements AutofillDialogDelegate, @CalledByNative private static AutofillDialogGlue create(int nativeAutofillDialogViewAndroid, - NativeWindow nativeWindow, + WindowAndroid nativeWindow, String useBillingForShippingText, String saveLocallyText) { return new AutofillDialogGlue(nativeAutofillDialogViewAndroid, nativeWindow, useBillingForShippingText, saveLocallyText); diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillPopup.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillPopup.java index 0a256fb..b5cd39b 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillPopup.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillPopup.java @@ -10,13 +10,11 @@ import android.graphics.Paint; import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.Drawable; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; import android.widget.AdapterView; import android.widget.FrameLayout; -import android.widget.ListAdapter; import android.widget.ListPopupWindow; import android.widget.TextView; @@ -25,7 +23,7 @@ import java.util.ArrayList; import org.chromium.chrome.R; import org.chromium.content.browser.ContainerViewDelegate; import org.chromium.ui.gfx.DeviceDisplayInfo; -import org.chromium.ui.gfx.NativeWindow; +import org.chromium.ui.WindowAndroid; /** * The Autofill suggestion popup that lists relevant suggestions. @@ -46,7 +44,7 @@ public class AutofillPopup extends ListPopupWindow implements AdapterView.OnItem private static final int TEXT_PADDING_DP = 30; private final AutofillPopupDelegate mAutofillCallback; - private final NativeWindow mNativeWindow; + private final Context mContext; private final ContainerViewDelegate mContainerViewDelegate; private AnchorView mAnchorView; private Rect mAnchorRect; @@ -124,20 +122,20 @@ public class AutofillPopup extends ListPopupWindow implements AdapterView.OnItem /** * Creates an AutofillWindow with specified parameters. - * @param nativeWindow NativeWindow used to get application context. + * @param context Application context. * @param containerViewDelegate View delegate used to add and remove views. * @param autofillCallback A object that handles the calls to the native AutofillPopupView. */ - public AutofillPopup(NativeWindow nativeWindow, ContainerViewDelegate containerViewDelegate, + public AutofillPopup(Context context, ContainerViewDelegate containerViewDelegate, AutofillPopupDelegate autofillCallback) { - super(nativeWindow.getContext()); - mNativeWindow = nativeWindow; + super(context); + mContext = context; mContainerViewDelegate = containerViewDelegate; mAutofillCallback = autofillCallback; setOnItemClickListener(this); - mAnchorView = new AnchorView(mNativeWindow.getContext(), this); + mAnchorView = new AnchorView(context, this); mContainerViewDelegate.addViewToContainerView(mAnchorView); setAnchorView(mAnchorView); } @@ -151,7 +149,7 @@ public class AutofillPopup extends ListPopupWindow implements AdapterView.OnItem * @param height The height of the anchor view. */ public void setAnchorRect(float x, float y, float width, float height) { - float scale = (float) DeviceDisplayInfo.create(mNativeWindow.getContext()).getDIPScale(); + float scale = (float) DeviceDisplayInfo.create(mContext).getDIPScale(); mAnchorRect = new Rect(Math.round(x * scale), Math.round(y * scale), Math.round((x + width) * scale), Math.round((y + height) * scale)); mAnchorRect.offset(0, mContainerViewDelegate.getChildViewOffsetYPix()); @@ -171,7 +169,7 @@ public class AutofillPopup extends ListPopupWindow implements AdapterView.OnItem cleanedData.add(suggestions[i]); } } - setAdapter(new AutofillListAdapter(mNativeWindow.getContext(), cleanedData)); + setAdapter(new AutofillListAdapter(mContext, cleanedData)); // Once the mAnchorRect is resized and placed correctly, it will show the Autofill popup. mAnchorView.setSize(mAnchorRect, getDesiredWidth(suggestions)); } @@ -201,8 +199,7 @@ public class AutofillPopup extends ListPopupWindow implements AdapterView.OnItem private int getDesiredWidth(AutofillSuggestion[] data) { if (mNameViewPaint == null || mLabelViewPaint == null) { LayoutInflater inflater = - (LayoutInflater) mNativeWindow.getContext().getSystemService( - Context.LAYOUT_INFLATER_SERVICE); + (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.autofill_text, null); TextView nameView = (TextView) layout.findViewById(R.id.autofill_name); mNameViewPaint = nameView.getPaint(); @@ -227,7 +224,7 @@ public class AutofillPopup extends ListPopupWindow implements AdapterView.OnItem } // Adding padding. return maxTextWidth + (int) (TEXT_PADDING_DP * - mNativeWindow.getContext().getResources().getDisplayMetrics().density); + mContext.getResources().getDisplayMetrics().density); } @Override diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillPopupGlue.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillPopupGlue.java index 34dca60..d5c7af0 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillPopupGlue.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillPopupGlue.java @@ -8,7 +8,7 @@ import org.chromium.base.CalledByNative; import org.chromium.base.JNINamespace; import org.chromium.chrome.browser.autofill.AutofillPopup.AutofillPopupDelegate; import org.chromium.content.browser.ContainerViewDelegate; -import org.chromium.ui.gfx.NativeWindow; +import org.chromium.ui.WindowAndroid; /** * JNI call glue for AutofillExternalDelagate C++ and Java objects. @@ -18,15 +18,15 @@ public class AutofillPopupGlue implements AutofillPopupDelegate{ private final int mNativeAutofillPopup; private final AutofillPopup mAutofillPopup; - public AutofillPopupGlue(int nativeAutofillPopupViewAndroid, NativeWindow nativeWindow, + public AutofillPopupGlue(int nativeAutofillPopupViewAndroid, WindowAndroid nativeWindow, ContainerViewDelegate containerViewDelegate) { mNativeAutofillPopup = nativeAutofillPopupViewAndroid; - mAutofillPopup = new AutofillPopup(nativeWindow, containerViewDelegate, this); + mAutofillPopup = new AutofillPopup(nativeWindow.getContext(), containerViewDelegate, this); } @CalledByNative private static AutofillPopupGlue create(int nativeAutofillPopupViewAndroid, - NativeWindow nativeWindow, ContainerViewDelegate containerViewDelegate) { + WindowAndroid nativeWindow, ContainerViewDelegate containerViewDelegate) { return new AutofillPopupGlue(nativeAutofillPopupViewAndroid, nativeWindow, containerViewDelegate); } diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillTest.java index 54d15d3..0482237 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillTest.java @@ -17,7 +17,7 @@ import org.chromium.content.browser.test.util.TouchCommon; import org.chromium.content.browser.test.util.UiUtils; import org.chromium.content.browser.test.util.Criteria; import org.chromium.content.browser.test.util.CriteriaHelper; -import org.chromium.ui.gfx.ActivityNativeWindow; +import org.chromium.ui.WindowAndroid; import java.util.concurrent.atomic.AtomicBoolean; @@ -28,7 +28,7 @@ import java.util.concurrent.atomic.AtomicBoolean; public class AutofillTest extends ChromiumTestShellTestBase { private AutofillPopup mAutofillPopup; - private ActivityNativeWindow mNativeWindow; + private WindowAndroid mWindowAndroid; private MockAutofillCallback mMockAutofillCallback; @Override @@ -39,14 +39,14 @@ public class AutofillTest extends ChromiumTestShellTestBase { waitForActiveShellToBeDoneLoading(); mMockAutofillCallback = new MockAutofillCallback(); - mNativeWindow = new ActivityNativeWindow(activity); + mWindowAndroid = new WindowAndroid(activity); final ContainerViewDelegate viewDelegate = activity.getActiveContentView().getContentViewCore().getContainerViewDelegate(); UiUtils.runOnUiThread(getActivity(), new Runnable() { @Override public void run() { - mAutofillPopup = new AutofillPopup(mNativeWindow, + mAutofillPopup = new AutofillPopup(mWindowAndroid.getContext(), viewDelegate, mMockAutofillCallback); mAutofillPopup.setAnchorRect(50, 500, 500, 50); diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/input/SelectPopupOtherContentViewTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/input/SelectPopupOtherContentViewTest.java index d09c682..6d2a71a 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/input/SelectPopupOtherContentViewTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/input/SelectPopupOtherContentViewTest.java @@ -18,7 +18,7 @@ import org.chromium.content.browser.test.util.TestCallbackHelperContainer; import org.chromium.content.browser.test.util.UiUtils; import org.chromium.chrome.browser.ContentViewUtil; import org.chromium.chrome.testshell.ChromiumTestShellTestBase; -import org.chromium.ui.gfx.ActivityNativeWindow; +import org.chromium.ui.WindowAndroid; import java.util.concurrent.TimeUnit; @@ -77,7 +77,7 @@ public class SelectPopupOtherContentViewTest extends ChromiumTestShellTestBase { @Override public void run() { int nativeWebContents = ContentViewUtil.createNativeWebContents(false); - ActivityNativeWindow nativeWindow = new ActivityNativeWindow(getActivity()); + WindowAndroid nativeWindow = new WindowAndroid(getActivity()); ContentView contentView = ContentView.newInstance( getActivity(), nativeWebContents, nativeWindow, ContentView.PERSONALITY_CHROME); diff --git a/chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellActivity.java b/chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellActivity.java index 527a4ed..2558246 100644 --- a/chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellActivity.java +++ b/chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellActivity.java @@ -13,7 +13,6 @@ import android.view.KeyEvent; import org.chromium.base.ChromiumActivity; import org.chromium.chrome.browser.DevToolsServer; -import org.chromium.content.app.LibraryLoader; import org.chromium.content.browser.ActivityContentVideoViewDelegate; import org.chromium.content.browser.AndroidBrowserProcess; import org.chromium.content.browser.ContentVideoView; @@ -21,7 +20,7 @@ import org.chromium.content.browser.ContentView; import org.chromium.content.browser.DeviceUtils; import org.chromium.content.common.CommandLine; import org.chromium.content.common.ProcessInitException; -import org.chromium.ui.gfx.ActivityNativeWindow; +import org.chromium.ui.WindowAndroid; /** * The {@link Activity} component of a basic test shell to test Chrome features. @@ -31,7 +30,7 @@ public class ChromiumTestShellActivity extends ChromiumActivity { private static final String COMMAND_LINE_FILE = "/data/local/tmp/chromium-testshell-command-line"; - private ActivityNativeWindow mWindow; + private WindowAndroid mWindow; private TabManager mTabManager; private DevToolsServer mDevToolsServer; @@ -56,7 +55,7 @@ public class ChromiumTestShellActivity extends ChromiumActivity { mTabManager.setStartupUrl(startupUrl); } - mWindow = new ActivityNativeWindow(this); + mWindow = new WindowAndroid(this); mWindow.restoreInstanceState(savedInstanceState); mTabManager.setWindow(mWindow); diff --git a/chrome/android/testshell/java/src/org/chromium/chrome/testshell/TabManager.java b/chrome/android/testshell/java/src/org/chromium/chrome/testshell/TabManager.java index cc8852e..5b67539 100644 --- a/chrome/android/testshell/java/src/org/chromium/chrome/testshell/TabManager.java +++ b/chrome/android/testshell/java/src/org/chromium/chrome/testshell/TabManager.java @@ -12,7 +12,7 @@ import android.widget.FrameLayout; import android.widget.LinearLayout; import org.chromium.content.browser.ContentViewRenderView; -import org.chromium.ui.gfx.NativeWindow; +import org.chromium.ui.WindowAndroid; /** * The TabManager hooks together all of the related {@link View}s that are used to represent @@ -22,7 +22,7 @@ import org.chromium.ui.gfx.NativeWindow; public class TabManager extends LinearLayout { private static final String DEFAULT_URL = "http://www.google.com"; - private NativeWindow mWindow; + private WindowAndroid mWindow; private ViewGroup mContentViewHolder; private ContentViewRenderView mContentViewRenderView; private TestShellToolbar mToolbar; @@ -60,7 +60,7 @@ public class TabManager extends LinearLayout { /** * @param window The window used to generate all ContentViews. */ - public void setWindow(NativeWindow window) { + public void setWindow(WindowAndroid window) { mWindow = window; } diff --git a/chrome/android/testshell/java/src/org/chromium/chrome/testshell/TestShellTab.java b/chrome/android/testshell/java/src/org/chromium/chrome/testshell/TestShellTab.java index 17d314a..ac01e6f 100644 --- a/chrome/android/testshell/java/src/org/chromium/chrome/testshell/TestShellTab.java +++ b/chrome/android/testshell/java/src/org/chromium/chrome/testshell/TestShellTab.java @@ -14,7 +14,7 @@ import org.chromium.chrome.browser.TabBase; import org.chromium.content.browser.ContentView; import org.chromium.content.browser.LoadUrlParams; import org.chromium.content.common.CleanupReference; -import org.chromium.ui.gfx.NativeWindow; +import org.chromium.ui.WindowAndroid; /** * TestShell's implementation of a tab. This mirrors how Chrome for Android subclasses @@ -35,9 +35,9 @@ public class TestShellTab extends TabBase { /** * @param context The Context the view is running in. * @param url The URL to start this tab with. - * @param window The NativeWindow should represent this tab. + * @param window The WindowAndroid should represent this tab. */ - public TestShellTab(Context context, String url, NativeWindow window) { + public TestShellTab(Context context, String url, WindowAndroid window) { super(window); init(context); loadUrlWithSanitization(url); @@ -49,10 +49,10 @@ public class TestShellTab extends TabBase { private void init(Context context) { // Build the WebContents and the ContentView/ContentViewCore int nativeWebContentsPtr = ContentViewUtil.createNativeWebContents(false); - mContentView = ContentView.newInstance(context, nativeWebContentsPtr, getNativeWindow(), + mContentView = ContentView.newInstance(context, nativeWebContentsPtr, getWindowAndroid(), ContentView.PERSONALITY_CHROME); mNativeTestShellTab = nativeInit(nativeWebContentsPtr, - getNativeWindow().getNativePointer()); + getWindowAndroid().getNativePointer()); // Build the WebContentsDelegate mWebContentsDelegate = new TabBaseChromeWebContentsDelegateAndroid(); diff --git a/chrome/android/testshell/testshell_tab.cc b/chrome/android/testshell/testshell_tab.cc index ad78e04..aec9720 100644 --- a/chrome/android/testshell/testshell_tab.cc +++ b/chrome/android/testshell/testshell_tab.cc @@ -13,7 +13,7 @@ #include "content/public/browser/web_contents.h" #include "googleurl/src/gurl.h" #include "jni/TestShellTab_jni.h" -#include "ui/gfx/android/window_android.h" +#include "ui/android/window_android.h" using base::android::ConvertJavaStringToUTF8; using base::android::ConvertUTF8ToJavaString; diff --git a/chrome/browser/ui/android/autofill/autofill_dialog_view_android.cc b/chrome/browser/ui/android/autofill/autofill_dialog_view_android.cc index 0d2ed04..f7d5aa6 100644 --- a/chrome/browser/ui/android/autofill/autofill_dialog_view_android.cc +++ b/chrome/browser/ui/android/autofill/autofill_dialog_view_android.cc @@ -11,11 +11,11 @@ #include "chrome/browser/ui/android/window_android_helper.h" #include "content/public/browser/web_contents.h" #include "jni/AutofillDialogGlue_jni.h" +#include "ui/android/window_android.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/models/combobox_model.h" #include "ui/base/models/menu_model.h" #include "ui/gfx/android/java_bitmap.h" -#include "ui/gfx/android/window_android.h" namespace autofill { diff --git a/chrome/browser/ui/android/autofill/autofill_popup_view_android.cc b/chrome/browser/ui/android/autofill/autofill_popup_view_android.cc index 3abf444..29f92ae 100644 --- a/chrome/browser/ui/android/autofill/autofill_popup_view_android.cc +++ b/chrome/browser/ui/android/autofill/autofill_popup_view_android.cc @@ -10,7 +10,7 @@ #include "chrome/browser/ui/autofill/autofill_popup_controller.h" #include "content/public/browser/android/content_view_core.h" #include "jni/AutofillPopupGlue_jni.h" -#include "ui/gfx/android/window_android.h" +#include "ui/android/window_android.h" #include "ui/gfx/rect.h" using base::android::MethodID; diff --git a/chrome/browser/ui/android/javascript_app_modal_dialog_android.cc b/chrome/browser/ui/android/javascript_app_modal_dialog_android.cc index dd58dec..d023691 100644 --- a/chrome/browser/ui/android/javascript_app_modal_dialog_android.cc +++ b/chrome/browser/ui/android/javascript_app_modal_dialog_android.cc @@ -15,7 +15,7 @@ #include "content/public/browser/web_contents.h" #include "content/public/common/javascript_message_type.h" #include "jni/JavascriptAppModalDialog_jni.h" -#include "ui/gfx/android/window_android.h" +#include "ui/android/window_android.h" using base::android::AttachCurrentThread; using base::android::ConvertUTF16ToJavaString; diff --git a/chrome/browser/ui/android/window_android_helper.cc b/chrome/browser/ui/android/window_android_helper.cc index 31856d0..9a6c0b9 100644 --- a/chrome/browser/ui/android/window_android_helper.cc +++ b/chrome/browser/ui/android/window_android_helper.cc @@ -5,7 +5,7 @@ #include "chrome/browser/ui/android/window_android_helper.h" #include "content/public/browser/web_contents.h" -#include "ui/gfx/android/window_android.h" +#include "ui/android/window_android.h" DEFINE_WEB_CONTENTS_USER_DATA_KEY(WindowAndroidHelper); diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc index bacbec9..0fc1f10 100644 --- a/content/browser/android/content_view_core_impl.cc +++ b/content/browser/android/content_view_core_impl.cc @@ -45,8 +45,8 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" #include "third_party/WebKit/Source/WebKit/chromium/public/android/WebInputEventFactory.h" +#include "ui/android/window_android.h" #include "ui/gfx/android/java_bitmap.h" -#include "ui/gfx/android/window_android.h" #include "ui/gfx/screen.h" #include "ui/gfx/size_conversions.h" #include "ui/gfx/size_f.h" @@ -683,6 +683,8 @@ void ContentViewCoreImpl::LoadUrl( } ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const { + // This should never be NULL for Chrome, but will be NULL for WebView. + DCHECK(window_android_); return window_android_; } 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 24f2ffe..be4ba33 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 @@ -24,7 +24,7 @@ import android.widget.FrameLayout; import com.google.common.annotations.VisibleForTesting; import org.chromium.content.common.TraceEvent; -import org.chromium.ui.gfx.NativeWindow; +import org.chromium.ui.WindowAndroid; /** * The containing view for {@link ContentViewCore} that exists in the Android UI hierarchy and @@ -49,13 +49,13 @@ 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 windowAndroid An instance of the WindowAndroid. * @param personality One of {@link #PERSONALITY_CHROME} or {@link #PERSONALITY_VIEW}. * @return A ContentView instance. */ public static ContentView newInstance(Context context, int nativeWebContents, - NativeWindow nativeWindow, int personality) { - return newInstance(context, nativeWebContents, nativeWindow, null, + WindowAndroid windowAndroid, int personality) { + return newInstance(context, nativeWebContents, windowAndroid, null, android.R.attr.webViewStyle, personality); } @@ -64,15 +64,15 @@ 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 windowAndroid An instance of the WindowAndroid. * @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, - NativeWindow nativeWindow, AttributeSet attrs) { + WindowAndroid windowAndroid, 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, nativeWindow, attrs, + return newInstance(context, nativeWebContents, windowAndroid, attrs, android.R.attr.webViewStyle); } @@ -81,34 +81,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 windowAndroid An instance of the WindowAndroid. * @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, - NativeWindow nativeWindow, AttributeSet attrs, int defStyle) { - return newInstance(context, nativeWebContents, nativeWindow, attrs, defStyle, + WindowAndroid windowAndroid, AttributeSet attrs, int defStyle) { + return newInstance(context, nativeWebContents, windowAndroid, attrs, defStyle, PERSONALITY_VIEW); } private static ContentView newInstance(Context context, int nativeWebContents, - NativeWindow nativeWindow, AttributeSet attrs, int defStyle, int personality) { + WindowAndroid windowAndroid, AttributeSet attrs, int defStyle, int personality) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { - return new ContentView(context, nativeWebContents, nativeWindow, attrs, defStyle, + return new ContentView(context, nativeWebContents, windowAndroid, attrs, defStyle, personality); } else { - return new JellyBeanContentView(context, nativeWebContents, nativeWindow, attrs, + return new JellyBeanContentView(context, nativeWebContents, windowAndroid, attrs, defStyle, personality); } } - protected ContentView(Context context, int nativeWebContents, NativeWindow nativeWindow, + protected ContentView(Context context, int nativeWebContents, WindowAndroid windowAndroid, AttributeSet attrs, int defStyle, int personality) { super(context, attrs, defStyle); mContentViewCore = new ContentViewCore(context, personality); - mContentViewCore.initialize(this, this, nativeWebContents, nativeWindow, false); + mContentViewCore.initialize(this, this, nativeWebContents, windowAndroid, 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 24900f2..60a7619 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 @@ -51,7 +51,7 @@ import org.chromium.content.browser.input.InsertionHandleController; import org.chromium.content.browser.input.SelectPopupDialog; import org.chromium.content.browser.input.SelectionHandleController; import org.chromium.content.common.TraceEvent; -import org.chromium.ui.gfx.NativeWindow; +import org.chromium.ui.WindowAndroid; import java.lang.annotation.Annotation; import java.util.HashMap; @@ -454,7 +454,7 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient { * @param internalDispatcher Handles dispatching all hidden or super methods to the * containerView. * @param nativeWebContents A pointer to the native web contents. - * @param nativeWindow An instance of the NativeWindow. + * @param windowAndroid An instance of the WindowAndroid. * @param isAccessFromFileURLsGrantedByDefault Default WebSettings configuration. */ // Perform important post-construction set up of the ContentViewCore. @@ -467,7 +467,7 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient { // Note that the caller remains the owner of the nativeWebContents and is responsible for // deleting it after destroying the ContentViewCore. public void initialize(ViewGroup containerView, InternalAccessDelegate internalDispatcher, - int nativeWebContents, NativeWindow nativeWindow, + int nativeWebContents, WindowAndroid windowAndroid, boolean isAccessFromFileURLsGrantedByDefault) { // Check whether to use hardware acceleration. This is a bit hacky, and // only works if the Context is actually an Activity (as it is in the @@ -489,8 +489,11 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient { (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN); mContainerView = containerView; + + int windowNativePointer = windowAndroid != null ? windowAndroid.getNativePointer() : 0; + mNativeContentViewCore = nativeInit(mHardwareAccelerated, inputEventsDeliveredAtVSync, - nativeWebContents, nativeWindow.getNativePointer()); + nativeWebContents, windowNativePointer); mContentSettings = new ContentSettings( this, mNativeContentViewCore, isAccessFromFileURLsGrantedByDefault); initializeContainerView(internalDispatcher); 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 1bc2fae..cc51bd9 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,13 @@ import android.util.AttributeSet; import android.view.View; import android.view.accessibility.AccessibilityNodeInfo; -import org.chromium.ui.gfx.NativeWindow; +import org.chromium.ui.WindowAndroid; /** * A version of {@link ContentView} that supports JellyBean features. */ class JellyBeanContentView extends ContentView { - JellyBeanContentView(Context context, int nativeWebContents, NativeWindow nativeWindow, + JellyBeanContentView(Context context, int nativeWebContents, WindowAndroid nativeWindow, AttributeSet attrs, int defStyle, int personality) { super(context, nativeWebContents, nativeWindow, attrs, defStyle, personality); } diff --git a/content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsActivity.java b/content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsActivity.java index 249baf6..3f25e68 100644 --- a/content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsActivity.java +++ b/content/shell/android/browsertests_apk/src/org/chromium/content_browsertests_apk/ContentBrowserTestsActivity.java @@ -15,15 +15,15 @@ import org.chromium.base.JNINamespace; import org.chromium.content.app.LibraryLoader; import org.chromium.content.browser.AndroidBrowserProcess; import org.chromium.content.common.ProcessInitException; -import org.chromium.ui.gfx.ActivityNativeWindow; import org.chromium.content_shell.ShellManager; +import org.chromium.ui.WindowAndroid; @JNINamespace("content") public class ContentBrowserTestsActivity extends Activity { private static final String TAG = "ChromeBrowserTestsActivity"; private ShellManager mShellManager; - private ActivityNativeWindow mActivityNativeWindow; + private WindowAndroid mWindowAndroid; @Override public void onCreate(Bundle savedInstanceState) { @@ -40,8 +40,8 @@ public class ContentBrowserTestsActivity extends Activity { (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.test_activity, null); mShellManager = (ShellManager) view.findViewById(R.id.shell_container); - mActivityNativeWindow = new ActivityNativeWindow(this); - mShellManager.setWindow(mActivityNativeWindow); + mWindowAndroid = new WindowAndroid(this); + mShellManager.setWindow(mWindowAndroid); Log.i(TAG, "Running tests"); runTests(); 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 7a11022..064e312 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 @@ -24,7 +24,7 @@ import org.chromium.base.JNINamespace; import org.chromium.content.browser.ContentView; import org.chromium.content.browser.ContentViewRenderView; import org.chromium.content.browser.LoadUrlParams; -import org.chromium.ui.gfx.NativeWindow; +import org.chromium.ui.WindowAndroid; /** * Container for the various UI components that make up a shell window. @@ -50,7 +50,7 @@ public class Shell extends LinearLayout { private ClipDrawable mProgressDrawable; private ContentViewRenderView mContentViewRenderView; - private NativeWindow mWindow; + private WindowAndroid mWindow; private boolean mLoading = false; @@ -82,7 +82,7 @@ public class Shell extends LinearLayout { /** * @param window The owning window for this shell. */ - public void setWindow(NativeWindow window) { + public void setWindow(WindowAndroid window) { mWindow = window; } 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 7cf962d..b3fd950 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 @@ -13,7 +13,7 @@ import org.chromium.base.CalledByNative; import org.chromium.base.JNINamespace; import org.chromium.content.browser.ContentView; import org.chromium.content.browser.ContentViewRenderView; -import org.chromium.ui.gfx.NativeWindow; +import org.chromium.ui.WindowAndroid; /** * Container and generator of ShellViews. @@ -23,7 +23,7 @@ public class ShellManager extends FrameLayout { public static final String DEFAULT_SHELL_URL = "http://www.google.com"; private static boolean sStartup = true; - private NativeWindow mWindow; + private WindowAndroid mWindow; private Shell mActiveShell; private String mStartupUrl = DEFAULT_SHELL_URL; @@ -51,14 +51,14 @@ public class ShellManager extends FrameLayout { /** * @param window The window used to generate all shells. */ - public void setWindow(NativeWindow window) { + public void setWindow(WindowAndroid window) { mWindow = window; } /** * @return The window used to generate all shells. */ - public NativeWindow getWindow() { + public WindowAndroid getWindow() { return mWindow; } diff --git a/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellActivity.java b/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellActivity.java index f72d1fb..9dc2bce 100644 --- a/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellActivity.java +++ b/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellActivity.java @@ -4,7 +4,6 @@ package org.chromium.content_shell_apk; -import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -26,7 +25,7 @@ import org.chromium.content.common.CommandLine; import org.chromium.content.common.ProcessInitException; import org.chromium.content_shell.Shell; import org.chromium.content_shell.ShellManager; -import org.chromium.ui.gfx.ActivityNativeWindow; +import org.chromium.ui.WindowAndroid; /** * Activity for managing the Content Shell. @@ -44,7 +43,7 @@ public class ContentShellActivity extends ChromiumActivity { public static final String COMMAND_LINE_ARGS_KEY = "commandLineArgs"; private ShellManager mShellManager; - private ActivityNativeWindow mActivityNativeWindow; + private WindowAndroid mWindowAndroid; private BroadcastReceiver mReceiver; @Override @@ -67,9 +66,9 @@ public class ContentShellActivity extends ChromiumActivity { setContentView(R.layout.content_shell_activity); mShellManager = (ShellManager) findViewById(R.id.shell_container); - mActivityNativeWindow = new ActivityNativeWindow(this); - mActivityNativeWindow.restoreInstanceState(savedInstanceState); - mShellManager.setWindow(mActivityNativeWindow); + mWindowAndroid = new WindowAndroid(this); + mWindowAndroid.restoreInstanceState(savedInstanceState); + mShellManager.setWindow(mWindowAndroid); ContentVideoView.registerContentVideoViewContextDelegate( new ActivityContentVideoViewDelegate(this)); @@ -99,7 +98,7 @@ public class ContentShellActivity extends ChromiumActivity { outState.putString(ACTIVE_SHELL_URL_KEY, activeShell.getContentView().getUrl()); } - mActivityNativeWindow.saveInstanceState(outState); + mWindowAndroid.saveInstanceState(outState); } private void waitForDebuggerIfNeeded() { @@ -179,7 +178,7 @@ public class ContentShellActivity extends ChromiumActivity { @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); - mActivityNativeWindow.onActivityResult(requestCode, resultCode, data); + mWindowAndroid.onActivityResult(requestCode, resultCode, data); } private static String getUrlFromIntent(Intent intent) { diff --git a/ui/android/java/src/org/chromium/ui/SelectFileDialog.java b/ui/android/java/src/org/chromium/ui/SelectFileDialog.java index a50a257..a9b117b 100644 --- a/ui/android/java/src/org/chromium/ui/SelectFileDialog.java +++ b/ui/android/java/src/org/chromium/ui/SelectFileDialog.java @@ -19,14 +19,14 @@ import java.util.List; import org.chromium.base.CalledByNative; import org.chromium.base.JNINamespace; -import org.chromium.ui.gfx.NativeWindow; +import org.chromium.ui.WindowAndroid; /** * A dialog that is triggered from a file input field that allows a user to select a file based on * a set of accepted file types. The path of the selected file is passed to the native dialog. */ @JNINamespace("ui") -class SelectFileDialog implements NativeWindow.IntentCallback{ +class SelectFileDialog implements WindowAndroid.IntentCallback{ private static final String IMAGE_TYPE = "image/"; private static final String VIDEO_TYPE = "video/"; private static final String AUDIO_TYPE = "audio/"; @@ -53,10 +53,10 @@ class SelectFileDialog implements NativeWindow.IntentCallback{ * Creates and starts an intent based on the passed fileTypes and capture value. * @param fileTypes MIME types requested (i.e. "image/*") * @param capture The capture value as described in http://www.w3.org/TR/html-media-capture/ - * @param window The NativeWindow that can show intents + * @param window The WindowAndroid that can show intents */ @CalledByNative - private void selectFile(String[] fileTypes, String capture, NativeWindow window) { + private void selectFile(String[] fileTypes, String capture, WindowAndroid window) { mFileTypes = new ArrayList<String>(Arrays.asList(fileTypes)); mCapture = capture; @@ -140,7 +140,7 @@ class SelectFileDialog implements NativeWindow.IntentCallback{ * @param results The results of the requested intent. */ @Override - public void onIntentCompleted(NativeWindow window, int resultCode, + public void onIntentCompleted(WindowAndroid window, int resultCode, ContentResolver contentResolver, Intent results) { if (resultCode != Activity.RESULT_OK) { onFileNotSelected(); diff --git a/ui/android/java/src/org/chromium/ui/gfx/ActivityNativeWindow.java b/ui/android/java/src/org/chromium/ui/WindowAndroid.java index 821a8a8..58716d8 100644 --- a/ui/android/java/src/org/chromium/ui/gfx/ActivityNativeWindow.java +++ b/ui/android/java/src/org/chromium/ui/WindowAndroid.java @@ -2,10 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -package org.chromium.ui.gfx; +package org.chromium.ui; import android.app.Activity; import android.content.ActivityNotFoundException; +import android.content.ContentResolver; +import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.util.SparseArray; @@ -13,11 +15,16 @@ import android.widget.Toast; import java.util.HashMap; +import org.chromium.base.JNINamespace; + /** - * The window that has access to the main activity and is able to create and receive intents, - * and show error messages. + * The window base class that has the minimum functionality. */ -public class ActivityNativeWindow extends NativeWindow { +@JNINamespace("ui") +public class WindowAndroid { + + // Native pointer to the c++ WindowAndroid object. + private int mNativeWindowAndroid = 0; // Constants used for intent request code bounding. private static final int REQUEST_CODE_PREFIX = 1000; @@ -33,8 +40,7 @@ public class ActivityNativeWindow extends NativeWindow { /** * @param activity */ - public ActivityNativeWindow(Activity activity) { - super(activity); + public WindowAndroid(Activity activity) { mActivity = activity; mOutstandingIntents = new SparseArray<IntentCallback>(); mIntentErrors = new HashMap<Integer, String>(); @@ -48,7 +54,6 @@ public class ActivityNativeWindow extends NativeWindow { * @param error The error string to be show if activity is paused before intent results. * @return Whether the intent was shown. */ - @Override public boolean showIntent(Intent intent, IntentCallback callback, String error) { int requestCode = REQUEST_CODE_PREFIX + mNextRequestCode; mNextRequestCode = (mNextRequestCode + 1) % REQUEST_CODE_RANGE_SIZE; @@ -69,7 +74,6 @@ public class ActivityNativeWindow extends NativeWindow { * Displays an error message with a provided error message string. * @param error The error message string to be displayed. */ - @Override public void showError(String error) { if (error != null) { Toast.makeText(mActivity, error, Toast.LENGTH_SHORT).show(); @@ -87,15 +91,15 @@ public class ActivityNativeWindow extends NativeWindow { /** * Broadcasts the given intent to all interested BroadcastReceivers. */ - @Override public void sendBroadcast(Intent intent) { mActivity.sendBroadcast(intent); } /** - * @return Application activity. + * TODO(nileshagrawal): Stop returning Activity Context crbug.com/233440. + * @return Activity context. */ - public Activity getActivity() { + public Context getContext() { return mActivity; } @@ -149,4 +153,44 @@ public class ActivityNativeWindow extends NativeWindow { return false; } + /** + * An interface that intent callback objects have to implement. + */ + public interface IntentCallback { + /** + * Handles the data returned by the requested intent. + * @param window A window reference. + * @param resultCode Result code of the requested intent. + * @param contentResolver An instance of ContentResolver class for accessing returned data. + * @param data The data returned by the intent. + */ + public void onIntentCompleted(WindowAndroid window, int resultCode, + ContentResolver contentResolver, Intent data); + } + + /** + * Destroys the c++ WindowAndroid object if one has been created. + */ + public void destroy() { + if (mNativeWindowAndroid != 0) { + nativeDestroy(mNativeWindowAndroid); + mNativeWindowAndroid = 0; + } + } + + /** + * Returns a pointer to the c++ AndroidWindow object and calls the initializer if + * the object has not been previously initialized. + * @return A pointer to the c++ AndroidWindow. + */ + public int getNativePointer() { + if (mNativeWindowAndroid == 0) { + mNativeWindowAndroid = nativeInit(); + } + return mNativeWindowAndroid; + } + + private native int nativeInit(); + private native void nativeDestroy(int nativeWindowAndroid); + } diff --git a/ui/android/java/src/org/chromium/ui/gfx/NativeWindow.java b/ui/android/java/src/org/chromium/ui/gfx/NativeWindow.java deleted file mode 100644 index 3782d30..0000000 --- a/ui/android/java/src/org/chromium/ui/gfx/NativeWindow.java +++ /dev/null @@ -1,95 +0,0 @@ -// 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.ui.gfx; - -import android.content.ContentResolver; -import android.content.Context; -import android.content.Intent; - -import org.chromium.base.JNINamespace; - -/** - * The window base class that has the minimum functionality. - */ -@JNINamespace("ui") -public abstract class NativeWindow { - - // Native pointer to the c++ WindowAndroid object. - private int mNativeWindowAndroid = 0; - - private Context mContext; - - /** - * An interface that intent callback objects have to implement. - */ - public interface IntentCallback { - /** - * Handles the data returned by the requested intent. - * @param window A window reference. - * @param resultCode Result code of the requested intent. - * @param contentResolver An instance of ContentResolver class for accessing returned data. - * @param data The data returned by the intent. - */ - public void onIntentCompleted(NativeWindow window, int resultCode, - ContentResolver contentResolver, Intent data); - } - - /** - * Constructs a Window object, saves a reference to the context. - * @param context - */ - public NativeWindow(Context context) { - mNativeWindowAndroid = 0; - mContext = context; - } - - /** - * Stub overridden by extending class. - */ - abstract public void sendBroadcast(Intent intent); - - /** - * Stub overridden by extending class. - */ - abstract public boolean showIntent(Intent intent, IntentCallback callback, String error); - - /** - * Stub overridden by extending class. - */ - abstract public void showError(String error); - - /** - * @return context. - */ - public Context getContext() { - return mContext; - } - - /** - * Destroys the c++ WindowAndroid object if one has been created. - */ - public void destroy() { - if (mNativeWindowAndroid != 0) { - nativeDestroy(mNativeWindowAndroid); - mNativeWindowAndroid = 0; - } - } - - /** - * Returns a pointer to the c++ AndroidWindow object and calls the initializer if - * the object has not been previously initialized. - * @return A pointer to the c++ AndroidWindow. - */ - public int getNativePointer() { - if (mNativeWindowAndroid == 0) { - mNativeWindowAndroid = nativeInit(); - } - return mNativeWindowAndroid; - } - - private native int nativeInit(); - private native void nativeDestroy(int nativeWindowAndroid); - -} diff --git a/ui/android/ui_jni_registrar.cc b/ui/android/ui_jni_registrar.cc index e2ddac1..5a0149b 100644 --- a/ui/android/ui_jni_registrar.cc +++ b/ui/android/ui_jni_registrar.cc @@ -6,21 +6,21 @@ #include "base/android/jni_android.h" #include "base/android/jni_registrar.h" +#include "ui/android/window_android.h" #include "ui/base/clipboard/clipboard_android_initialization.h" #include "ui/base/l10n/l10n_util_android.h" #include "ui/gfx/android/device_display_info.h" #include "ui/gfx/android/java_bitmap.h" -#include "ui/gfx/android/window_android.h" namespace ui { namespace android { static base::android::RegistrationMethod kUiRegisteredMethods[] = { + { "Clipboard", ui::RegisterClipboardAndroid }, { "DeviceDisplayInfo", gfx::DeviceDisplayInfo::RegisterDeviceDisplayInfo }, { "JavaBitmap", gfx::JavaBitmap::RegisterJavaBitmap }, { "LocalizationUtils", l10n_util::RegisterLocalizationUtil }, - { "NativeWindow", ui::WindowAndroid::RegisterWindowAndroid }, - { "Clipboard", ui::RegisterClipboardAndroid }, + { "WindowAndroid", ui::WindowAndroid::RegisterWindowAndroid }, }; bool RegisterJni(JNIEnv* env) { diff --git a/ui/gfx/android/window_android.cc b/ui/android/window_android.cc index 9ade2bb..1f2ccb2f9 100644 --- a/ui/gfx/android/window_android.cc +++ b/ui/android/window_android.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "window_android.h" +#include "ui/android/window_android.h" #include "base/android/jni_android.h" #include "base/android/jni_helper.h" #include "base/android/scoped_java_ref.h" -#include "jni/NativeWindow_jni.h" +#include "jni/WindowAndroid_jni.h" namespace ui { @@ -23,8 +23,7 @@ void WindowAndroid::Destroy(JNIEnv* env, jobject obj) { } ScopedJavaLocalRef<jobject> WindowAndroid::GetJavaObject() { - JNIEnv* env = AttachCurrentThread(); - return weak_java_window_.get(env); + return weak_java_window_.get(AttachCurrentThread()); } bool WindowAndroid::RegisterWindowAndroid(JNIEnv* env) { diff --git a/ui/gfx/android/window_android.h b/ui/android/window_android.h index 12d541d..c1c5c44 100644 --- a/ui/gfx/android/window_android.h +++ b/ui/android/window_android.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef UI_GFX_ANDROID_WINDOW_ANDROID_H_ -#define UI_GFX_ANDROID_WINDOW_ANDROID_H_ +#ifndef UI_ANDROID_WINDOW_ANDROID_H_ +#define UI_ANDROID_WINDOW_ANDROID_H_ #include <jni.h> #include "base/android/jni_helper.h" @@ -33,4 +33,4 @@ class UI_EXPORT WindowAndroid { } // namespace ui -#endif // UI_GFX_ANDROID_WINDOW_ANDROID_H_ +#endif // UI_ANDROID_WINDOW_ANDROID_H_ diff --git a/ui/shell_dialogs/select_file_dialog_android.cc b/ui/shell_dialogs/select_file_dialog_android.cc index 740939f..2aa4007 100644 --- a/ui/shell_dialogs/select_file_dialog_android.cc +++ b/ui/shell_dialogs/select_file_dialog_android.cc @@ -13,7 +13,7 @@ #include "base/strings/string_split.h" #include "base/utf_string_conversions.h" #include "jni/SelectFileDialog_jni.h" -#include "ui/gfx/android/window_android.h" +#include "ui/android/window_android.h" namespace ui { @@ -41,6 +41,8 @@ 'sources' : [ 'android/ui_jni_registrar.cc', 'android/ui_jni_registrar.h', + 'android/window_android.cc', + 'android/window_android.h', 'base/accelerators/accelerator.cc', 'base/accelerators/accelerator.h', 'base/accelerators/platform_accelerator.h', @@ -361,8 +363,6 @@ 'gfx/android/device_display_info.h', 'gfx/android/java_bitmap.cc', 'gfx/android/java_bitmap.h', - 'gfx/android/window_android.cc', - 'gfx/android/window_android.h', 'gfx/blit.cc', 'gfx/blit.h', 'gfx/break_list.h', @@ -884,12 +884,12 @@ 'target_name': 'ui_jni_headers', 'type': 'none', 'sources': [ + 'android/java/src/org/chromium/ui/Clipboard.java', 'android/java/src/org/chromium/ui/gfx/BitmapHelper.java', 'android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java', - 'android/java/src/org/chromium/ui/gfx/NativeWindow.java', 'android/java/src/org/chromium/ui/LocalizationUtils.java', 'android/java/src/org/chromium/ui/SelectFileDialog.java', - 'android/java/src/org/chromium/ui/Clipboard.java', + 'android/java/src/org/chromium/ui/WindowAndroid.java', ], 'variables': { 'jni_gen_package': 'ui', |