| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.ui.gfx; | 5 package org.chromium.ui.gfx; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.ActivityNotFoundException; | 8 import android.content.ActivityNotFoundException; |
| 9 import android.content.Intent; | 9 import android.content.Intent; |
| 10 import android.os.Bundle; | 10 import android.os.Bundle; |
| 11 import android.util.SparseArray; | 11 import android.util.SparseArray; |
| 12 import android.widget.Toast; | 12 import android.widget.Toast; |
| 13 | 13 |
| 14 import java.util.HashMap; | 14 import java.util.HashMap; |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * The window that has access to the main activity and is able to create and rec
eive intents, | 17 * The window that has access to the main activity and is able to create and rec
eive intents, |
| 18 * and show error messages. | 18 * and show error messages. |
| 19 */ | 19 */ |
| 20 public class ActivityNativeWindow extends NativeWindow { | 20 public class ActivityWindowAndroid extends WindowAndroid { |
| 21 | 21 |
| 22 // Constants used for intent request code bounding. | 22 // Constants used for intent request code bounding. |
| 23 private static final int REQUEST_CODE_PREFIX = 1000; | 23 private static final int REQUEST_CODE_PREFIX = 1000; |
| 24 private static final int REQUEST_CODE_RANGE_SIZE = 100; | 24 private static final int REQUEST_CODE_RANGE_SIZE = 100; |
| 25 // A string used as a key to store intent errors in a bundle | 25 // A string used as a key to store intent errors in a bundle |
| 26 static final String WINDOW_CALLBACK_ERRORS = "window_callback_errors"; | 26 static final String WINDOW_CALLBACK_ERRORS = "window_callback_errors"; |
| 27 | 27 |
| 28 private int mNextRequestCode = 0; | 28 private int mNextRequestCode = 0; |
| 29 protected Activity mActivity; | 29 protected Activity mActivity; |
| 30 protected SparseArray<IntentCallback> mOutstandingIntents; | 30 protected SparseArray<IntentCallback> mOutstandingIntents; |
| 31 protected HashMap<Integer, String> mIntentErrors; | 31 protected HashMap<Integer, String> mIntentErrors; |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * @param activity | 34 * @param activity |
| 35 */ | 35 */ |
| 36 public ActivityNativeWindow(Activity activity) { | 36 public ActivityWindowAndroid(Activity activity) { |
| 37 super(activity); | 37 super(activity); |
| 38 mActivity = activity; | 38 mActivity = activity; |
| 39 mOutstandingIntents = new SparseArray<IntentCallback>(); | 39 mOutstandingIntents = new SparseArray<IntentCallback>(); |
| 40 mIntentErrors = new HashMap<Integer, String>(); | 40 mIntentErrors = new HashMap<Integer, String>(); |
| 41 | 41 |
| 42 } | 42 } |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * Shows an intent and returns the results to the callback object. | 45 * Shows an intent and returns the results to the callback object. |
| 46 * @param intent The intent that needs to be showed. | 46 * @param intent The intent that needs to be showed. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } else { | 143 } else { |
| 144 if (errorMessage != null) { | 144 if (errorMessage != null) { |
| 145 showCallbackNonExistentError(errorMessage); | 145 showCallbackNonExistentError(errorMessage); |
| 146 return true; | 146 return true; |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 return false; | 149 return false; |
| 150 } | 150 } |
| 151 | 151 |
| 152 } | 152 } |
| OLD | NEW |