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

Side by Side Diff: ui/android/java/src/org/chromium/ui/base/WindowAndroid.java

Issue 2361633002: android: Introduce DisplayAndroid (Closed)
Patch Set: test comments Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « ui/android/BUILD.gn ('k') | ui/android/java/src/org/chromium/ui/display/DisplayAndroid.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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.base; 5 package org.chromium.ui.base;
6 6
7 import android.animation.Animator; 7 import android.animation.Animator;
8 import android.animation.AnimatorListenerAdapter; 8 import android.animation.AnimatorListenerAdapter;
9 import android.annotation.SuppressLint; 9 import android.annotation.SuppressLint;
10 import android.annotation.TargetApi; 10 import android.annotation.TargetApi;
(...skipping 12 matching lines...) Expand all
23 import android.view.View; 23 import android.view.View;
24 import android.view.ViewGroup; 24 import android.view.ViewGroup;
25 import android.view.accessibility.AccessibilityManager; 25 import android.view.accessibility.AccessibilityManager;
26 26
27 import org.chromium.base.ApiCompatibilityUtils; 27 import org.chromium.base.ApiCompatibilityUtils;
28 import org.chromium.base.Callback; 28 import org.chromium.base.Callback;
29 import org.chromium.base.VisibleForTesting; 29 import org.chromium.base.VisibleForTesting;
30 import org.chromium.base.annotations.CalledByNative; 30 import org.chromium.base.annotations.CalledByNative;
31 import org.chromium.base.annotations.JNINamespace; 31 import org.chromium.base.annotations.JNINamespace;
32 import org.chromium.ui.VSyncMonitor; 32 import org.chromium.ui.VSyncMonitor;
33 import org.chromium.ui.display.DisplayAndroid;
33 import org.chromium.ui.widget.Toast; 34 import org.chromium.ui.widget.Toast;
34 35
35 import java.lang.ref.WeakReference; 36 import java.lang.ref.WeakReference;
36 import java.util.HashMap; 37 import java.util.HashMap;
37 import java.util.HashSet; 38 import java.util.HashSet;
38 import java.util.LinkedList; 39 import java.util.LinkedList;
39 40
40 /** 41 /**
41 * The window base class that has the minimum functionality. 42 * The window base class that has the minimum functionality.
42 */ 43 */
(...skipping 21 matching lines...) Expand all
64 65
65 void destroy() { 66 void destroy() {
66 mAccessibilityManager.removeTouchExplorationStateChangeListener( 67 mAccessibilityManager.removeTouchExplorationStateChangeListener(
67 mTouchExplorationListener); 68 mTouchExplorationListener);
68 } 69 }
69 } 70 }
70 71
71 // Native pointer to the c++ WindowAndroid object. 72 // Native pointer to the c++ WindowAndroid object.
72 private long mNativeWindowAndroid = 0; 73 private long mNativeWindowAndroid = 0;
73 private final VSyncMonitor mVSyncMonitor; 74 private final VSyncMonitor mVSyncMonitor;
75 private final DisplayAndroid mDisplayAndroid;
74 76
75 // A string used as a key to store intent errors in a bundle 77 // A string used as a key to store intent errors in a bundle
76 static final String WINDOW_CALLBACK_ERRORS = "window_callback_errors"; 78 static final String WINDOW_CALLBACK_ERRORS = "window_callback_errors";
77 79
78 // Error code returned when an Intent fails to start an Activity. 80 // Error code returned when an Intent fails to start an Activity.
79 public static final int START_INTENT_FAILURE = -1; 81 public static final int START_INTENT_FAILURE = -1;
80 82
81 protected Context mApplicationContext; 83 protected Context mApplicationContext;
82 protected SparseArray<IntentCallback> mOutstandingIntents; 84 protected SparseArray<IntentCallback> mOutstandingIntents;
83 // We use a weak reference here to prevent this from leaking in WebView. 85 // We use a weak reference here to prevent this from leaking in WebView.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 public WindowAndroid(Context context) { 170 public WindowAndroid(Context context) {
169 mApplicationContext = context.getApplicationContext(); 171 mApplicationContext = context.getApplicationContext();
170 // context does not have the same lifetime guarantees as an application context so we can't 172 // context does not have the same lifetime guarantees as an application context so we can't
171 // hold a strong reference to it. 173 // hold a strong reference to it.
172 mContextRef = new WeakReference<Context>(context); 174 mContextRef = new WeakReference<Context>(context);
173 mOutstandingIntents = new SparseArray<IntentCallback>(); 175 mOutstandingIntents = new SparseArray<IntentCallback>();
174 mIntentErrors = new HashMap<Integer, String>(); 176 mIntentErrors = new HashMap<Integer, String>();
175 mVSyncMonitor = new VSyncMonitor(context, mVSyncListener); 177 mVSyncMonitor = new VSyncMonitor(context, mVSyncListener);
176 mAccessibilityManager = (AccessibilityManager) mApplicationContext.getSy stemService( 178 mAccessibilityManager = (AccessibilityManager) mApplicationContext.getSy stemService(
177 Context.ACCESSIBILITY_SERVICE); 179 Context.ACCESSIBILITY_SERVICE);
180 mDisplayAndroid = DisplayAndroid.get(context);
178 } 181 }
179 182
180 @CalledByNative 183 @CalledByNative
181 private static WindowAndroid createForTesting(Context context) { 184 private static WindowAndroid createForTesting(Context context) {
182 return new WindowAndroid(context); 185 return new WindowAndroid(context);
183 } 186 }
184 187
185 @CalledByNative 188 @CalledByNative
186 private void clearNativePointer() { 189 private void clearNativePointer() {
187 mNativeWindowAndroid = 0; 190 mNativeWindowAndroid = 0;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 } 388 }
386 389
387 /** 390 /**
388 * Broadcasts the given intent to all interested BroadcastReceivers. 391 * Broadcasts the given intent to all interested BroadcastReceivers.
389 */ 392 */
390 public void sendBroadcast(Intent intent) { 393 public void sendBroadcast(Intent intent) {
391 mApplicationContext.sendBroadcast(intent); 394 mApplicationContext.sendBroadcast(intent);
392 } 395 }
393 396
394 /** 397 /**
398 * @return DisplayAndroid instance belong to this window.
399 */
400 public DisplayAndroid getDisplay() {
401 return mDisplayAndroid;
402 }
403
404 /**
395 * @return A reference to owning Activity. The returned WeakReference will never be null, but 405 * @return A reference to owning Activity. The returned WeakReference will never be null, but
396 * the contained Activity can be null (either if it has been garbage collected or if 406 * the contained Activity can be null (either if it has been garbage collected or if
397 * this is in the context of a WebView that was not created using an Activity). 407 * this is in the context of a WebView that was not created using an Activity).
398 */ 408 */
399 public WeakReference<Activity> getActivity() { 409 public WeakReference<Activity> getActivity() {
400 return new WeakReference<Activity>(null); 410 return new WeakReference<Activity>(null);
401 } 411 }
402 412
403 /** 413 /**
404 * @return The application context for this activity. 414 * @return The application context for this activity.
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 private native long nativeInit(); 678 private native long nativeInit();
669 private native void nativeOnVSync(long nativeWindowAndroid, 679 private native void nativeOnVSync(long nativeWindowAndroid,
670 long vsyncTimeMicros, 680 long vsyncTimeMicros,
671 long vsyncPeriodMicros); 681 long vsyncPeriodMicros);
672 private native void nativeOnVisibilityChanged(long nativeWindowAndroid, bool ean visible); 682 private native void nativeOnVisibilityChanged(long nativeWindowAndroid, bool ean visible);
673 private native void nativeOnActivityStopped(long nativeWindowAndroid); 683 private native void nativeOnActivityStopped(long nativeWindowAndroid);
674 private native void nativeOnActivityStarted(long nativeWindowAndroid); 684 private native void nativeOnActivityStarted(long nativeWindowAndroid);
675 private native void nativeDestroy(long nativeWindowAndroid); 685 private native void nativeDestroy(long nativeWindowAndroid);
676 686
677 } 687 }
OLDNEW
« no previous file with comments | « ui/android/BUILD.gn ('k') | ui/android/java/src/org/chromium/ui/display/DisplayAndroid.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698