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

Unified Diff: ui/android/java/src/org/chromium/ui/WindowAndroid.java

Issue 14169011: [Android] Rename NativeWindow to WindowAndroid. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Finish Renaming Created 7 years, 8 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: ui/android/java/src/org/chromium/ui/WindowAndroid.java
diff --git a/ui/android/java/src/org/chromium/ui/gfx/ActivityNativeWindow.java b/ui/android/java/src/org/chromium/ui/WindowAndroid.java
similarity index 72%
rename from ui/android/java/src/org/chromium/ui/gfx/ActivityNativeWindow.java
rename to ui/android/java/src/org/chromium/ui/WindowAndroid.java
index 821a8a8cb500e522dce0401622dad09c68b8c23d..f13046b6783c906108d06e44e03ff4810ea3da4e 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,7 +91,6 @@ public class ActivityNativeWindow extends NativeWindow {
/**
* Broadcasts the given intent to all interested BroadcastReceivers.
*/
- @Override
public void sendBroadcast(Intent intent) {
mActivity.sendBroadcast(intent);
}
@@ -149,4 +152,52 @@ 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);
+ }
+
+ /**
+ * @return context.
+ */
+ public Context getContext() {
nilesh 2013/04/18 16:50:06 Do we need to give away the activity context? Plea
aurimas (slooooooooow) 2013/04/18 20:46:16 Done.
+ return mActivity;
+ }
+
+ /**
+ * 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);
+
}

Powered by Google App Engine
This is Rietveld 408576698