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

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

Issue 1569643002: Reland Pull the Activity context from WindowAndroid if possible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert the changes in ChromeWindow as they are not needed anymore Created 4 years, 11 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/java/src/org/chromium/ui/base/ActivityWindowAndroid.java ('k') | no next file » | 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;
11 import android.app.Activity; 11 import android.app.Activity;
12 import android.app.PendingIntent; 12 import android.app.PendingIntent;
13 import android.content.ContentResolver; 13 import android.content.ContentResolver;
14 import android.content.Context; 14 import android.content.Context;
15 import android.content.ContextWrapper;
15 import android.content.Intent; 16 import android.content.Intent;
16 import android.content.pm.PackageManager; 17 import android.content.pm.PackageManager;
17 import android.os.Build; 18 import android.os.Build;
18 import android.os.Bundle; 19 import android.os.Bundle;
19 import android.os.Process; 20 import android.os.Process;
20 import android.util.Log; 21 import android.util.Log;
21 import android.util.SparseArray; 22 import android.util.SparseArray;
22 import android.view.View; 23 import android.view.View;
23 import android.view.ViewGroup; 24 import android.view.ViewGroup;
24 import android.view.accessibility.AccessibilityManager; 25 import android.view.accessibility.AccessibilityManager;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 public void onVSync(VSyncMonitor monitor, long vsyncTimeMicros) { 119 public void onVSync(VSyncMonitor monitor, long vsyncTimeMicros) {
119 if (mNativeWindowAndroid != 0) { 120 if (mNativeWindowAndroid != 0) {
120 nativeOnVSync(mNativeWindowAndroid, 121 nativeOnVSync(mNativeWindowAndroid,
121 vsyncTimeMicros, 122 vsyncTimeMicros,
122 mVSyncMonitor.getVSyncPeriodInMicroseconds()); 123 mVSyncMonitor.getVSyncPeriodInMicroseconds());
123 } 124 }
124 } 125 }
125 }; 126 };
126 127
127 /** 128 /**
129 * Extract the activity if the given Context either is or wraps one.
130 * Only retrieve the base context if the supplied context is a {@link Contex tWrapper} but not
131 * an Activity, given that Activity is already a subclass of ContextWrapper.
132 * @param context The context to check.
133 * @return The {@link Activity} that is extracted through the given Context.
134 */
135 public static Activity activityFromContext(Context context) {
136 if (context instanceof Activity) {
137 return ((Activity) context);
138 } else if (context instanceof ContextWrapper) {
139 context = ((ContextWrapper) context).getBaseContext();
140 return activityFromContext(context);
141 } else {
142 return null;
143 }
144 }
145
146 /**
128 * @return true if onVSync handler is executing. 147 * @return true if onVSync handler is executing.
129 * 148 *
130 * @see org.chromium.ui.VSyncMonitor#isInsideVSync() 149 * @see org.chromium.ui.VSyncMonitor#isInsideVSync()
131 */ 150 */
132 public boolean isInsideVSync() { 151 public boolean isInsideVSync() {
133 return mVSyncMonitor.isInsideVSync(); 152 return mVSyncMonitor.isInsideVSync();
134 } 153 }
135 154
136 /** 155 /**
137 * @param context The application context. 156 * @param context The application context.
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 private native long nativeInit(); 637 private native long nativeInit();
619 private native void nativeOnVSync(long nativeWindowAndroid, 638 private native void nativeOnVSync(long nativeWindowAndroid,
620 long vsyncTimeMicros, 639 long vsyncTimeMicros,
621 long vsyncPeriodMicros); 640 long vsyncPeriodMicros);
622 private native void nativeOnVisibilityChanged(long nativeWindowAndroid, bool ean visible); 641 private native void nativeOnVisibilityChanged(long nativeWindowAndroid, bool ean visible);
623 private native void nativeOnActivityStopped(long nativeWindowAndroid); 642 private native void nativeOnActivityStopped(long nativeWindowAndroid);
624 private native void nativeOnActivityStarted(long nativeWindowAndroid); 643 private native void nativeOnActivityStarted(long nativeWindowAndroid);
625 private native void nativeDestroy(long nativeWindowAndroid); 644 private native void nativeDestroy(long nativeWindowAndroid);
626 645
627 } 646 }
OLDNEW
« no previous file with comments | « ui/android/java/src/org/chromium/ui/base/ActivityWindowAndroid.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698