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

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

Issue 1140113002: Implement screen capture for android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ScreenCaptureMachineAndroid which inherited from content::VideoCaptureMachine Created 5 years, 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.base; 5 package org.chromium.base;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.app.Application; 8 import android.app.Application;
9 import android.content.Context; 9 import android.content.Context;
10 import android.os.Bundle; 10 import android.os.Bundle;
11 import android.view.KeyEvent; 11 import android.view.KeyEvent;
12 import android.view.Window; 12 import android.view.Window;
13 13
14 /** 14 /**
15 * Basic application functionality that should be shared among all browser appli cations. 15 * Basic application functionality that should be shared among all browser appli cations.
16 */ 16 */
17 public class BaseChromiumApplication extends Application { 17 public class BaseChromiumApplication extends Application {
18 private Activity mActivity = null;
18 /** 19 /**
19 * Interface to be implemented by listeners for window focus events. 20 * Interface to be implemented by listeners for window focus events.
20 */ 21 */
21 public interface WindowFocusChangedListener { 22 public interface WindowFocusChangedListener {
22 /** 23 /**
23 * Called when the window focus changes for {@code activity}. 24 * Called when the window focus changes for {@code activity}.
24 * @param activity The {@link Activity} that has a window focus changed event. 25 * @param activity The {@link Activity} that has a window focus changed event.
25 * @param hasFocus Whether or not {@code activity} gained or lost focus. 26 * @param hasFocus Whether or not {@code activity} gained or lost focus.
26 */ 27 */
27 public void onWindowFocusChanged(Activity activity, boolean hasFocus); 28 public void onWindowFocusChanged(Activity activity, boolean hasFocus);
28 } 29 }
29 30
30 private ObserverList<WindowFocusChangedListener> mWindowFocusListeners = 31 private ObserverList<WindowFocusChangedListener> mWindowFocusListeners =
31 new ObserverList<WindowFocusChangedListener>(); 32 new ObserverList<WindowFocusChangedListener>();
32 33
33 @Override 34 @Override
34 public void onCreate() { 35 public void onCreate() {
35 super.onCreate(); 36 super.onCreate();
36 ApplicationStatus.initialize(this); 37 ApplicationStatus.initialize(this);
37 38
38 registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() { 39 registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
39 @Override 40 @Override
40 public void onActivityCreated(final Activity activity, Bundle savedI nstanceState) { 41 public void onActivityCreated(final Activity activity, Bundle savedI nstanceState) {
42 mActivity = activity;
whywhat 2015/08/17 13:58:46 One should use the ApplicationStatus.getLastTracke
41 Window.Callback callback = activity.getWindow().getCallback(); 43 Window.Callback callback = activity.getWindow().getCallback();
42 activity.getWindow().setCallback(new WindowCallbackWrapper(callb ack) { 44 activity.getWindow().setCallback(new WindowCallbackWrapper(callb ack) {
43 @Override 45 @Override
44 public void onWindowFocusChanged(boolean hasFocus) { 46 public void onWindowFocusChanged(boolean hasFocus) {
45 super.onWindowFocusChanged(hasFocus); 47 super.onWindowFocusChanged(hasFocus);
46 48
47 for (WindowFocusChangedListener listener : mWindowFocusL isteners) { 49 for (WindowFocusChangedListener listener : mWindowFocusL isteners) {
48 listener.onWindowFocusChanged(activity, hasFocus); 50 listener.onWindowFocusChanged(activity, hasFocus);
49 } 51 }
50 } 52 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 * Unregisters a listener from receiving window focus updates on activities in this application. 108 * Unregisters a listener from receiving window focus updates on activities in this application.
107 * @param listener Listener that doesn't want to receive window focus events . 109 * @param listener Listener that doesn't want to receive window focus events .
108 */ 110 */
109 public void unregisterWindowFocusChangedListener(WindowFocusChangedListener listener) { 111 public void unregisterWindowFocusChangedListener(WindowFocusChangedListener listener) {
110 mWindowFocusListeners.removeObserver(listener); 112 mWindowFocusListeners.removeObserver(listener);
111 } 113 }
112 114
113 /** Initializes the {@link CommandLine}. */ 115 /** Initializes the {@link CommandLine}. */
114 public void initCommandLine() {} 116 public void initCommandLine() {}
115 117
118 public Activity getActivity() {
119 return mActivity;
120 }
121
116 /** 122 /**
117 * This must only be called for contexts whose application is a subclass of 123 * This must only be called for contexts whose application is a subclass of
118 * {@link BaseChromiumApplication}. 124 * {@link BaseChromiumApplication}.
119 */ 125 */
120 @VisibleForTesting 126 @VisibleForTesting
121 public static void initCommandLine(Context context) { 127 public static void initCommandLine(Context context) {
122 ((BaseChromiumApplication) context.getApplicationContext()).initCommandL ine(); 128 ((BaseChromiumApplication) context.getApplicationContext()).initCommandL ine();
123 }; 129 };
124 } 130 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698