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.content_shell_apk; | 5 package org.chromium.content_shell_apk; |
6 | 6 |
7 import android.content.BroadcastReceiver; | 7 import android.content.BroadcastReceiver; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.content.Intent; | 9 import android.content.Intent; |
10 import android.content.IntentFilter; | 10 import android.content.IntentFilter; |
11 import android.os.Bundle; | 11 import android.os.Bundle; |
12 import android.text.TextUtils; | 12 import android.text.TextUtils; |
13 import android.util.Log; | 13 import android.util.Log; |
14 import android.view.KeyEvent; | 14 import android.view.KeyEvent; |
15 | 15 |
16 import org.chromium.base.ChromiumActivity; | 16 import org.chromium.base.ChromiumActivity; |
| 17 import org.chromium.base.MemoryPressureListener; |
17 import org.chromium.content.app.LibraryLoader; | 18 import org.chromium.content.app.LibraryLoader; |
18 import org.chromium.content.browser.ActivityContentVideoViewClient; | 19 import org.chromium.content.browser.ActivityContentVideoViewClient; |
19 import org.chromium.content.browser.AndroidBrowserProcess; | 20 import org.chromium.content.browser.AndroidBrowserProcess; |
20 import org.chromium.content.browser.ContentVideoView; | 21 import org.chromium.content.browser.ContentVideoView; |
21 import org.chromium.content.browser.ContentVideoViewClient; | 22 import org.chromium.content.browser.ContentVideoViewClient; |
22 import org.chromium.content.browser.ContentView; | 23 import org.chromium.content.browser.ContentView; |
23 import org.chromium.content.browser.ContentViewClient; | 24 import org.chromium.content.browser.ContentViewClient; |
24 import org.chromium.content.browser.DeviceUtils; | 25 import org.chromium.content.browser.DeviceUtils; |
25 import org.chromium.content.browser.TracingIntentHandler; | 26 import org.chromium.content.browser.TracingIntentHandler; |
26 import org.chromium.content.common.CommandLine; | 27 import org.chromium.content.common.CommandLine; |
(...skipping 10 matching lines...) Expand all Loading... |
37 public static final String COMMAND_LINE_FILE = "/data/local/tmp/content-shel
l-command-line"; | 38 public static final String COMMAND_LINE_FILE = "/data/local/tmp/content-shel
l-command-line"; |
38 private static final String TAG = ContentShellActivity.class.getName(); | 39 private static final String TAG = ContentShellActivity.class.getName(); |
39 | 40 |
40 private static final String ACTIVE_SHELL_URL_KEY = "activeUrl"; | 41 private static final String ACTIVE_SHELL_URL_KEY = "activeUrl"; |
41 private static final String ACTION_START_TRACE = | 42 private static final String ACTION_START_TRACE = |
42 "org.chromium.content_shell.action.PROFILE_START"; | 43 "org.chromium.content_shell.action.PROFILE_START"; |
43 private static final String ACTION_STOP_TRACE = | 44 private static final String ACTION_STOP_TRACE = |
44 "org.chromium.content_shell.action.PROFILE_STOP"; | 45 "org.chromium.content_shell.action.PROFILE_STOP"; |
45 public static final String COMMAND_LINE_ARGS_KEY = "commandLineArgs"; | 46 public static final String COMMAND_LINE_ARGS_KEY = "commandLineArgs"; |
46 | 47 |
| 48 /** |
| 49 * Sending an intent with this action will simulate a memory pressure signal |
| 50 * at a critical level. |
| 51 */ |
| 52 private static final String ACTION_LOW_MEMORY = |
| 53 "org.chromium.content_shell.action.ACTION_LOW_MEMORY"; |
| 54 |
| 55 /** |
| 56 * Sending an intent with this action will simulate a memory pressure signal |
| 57 * at a moderate level. |
| 58 */ |
| 59 private static final String ACTION_TRIM_MEMORY_MODERATE = |
| 60 "org.chromium.content_shell.action.ACTION_TRIM_MEMORY_MODERATE"; |
| 61 |
| 62 |
47 private ShellManager mShellManager; | 63 private ShellManager mShellManager; |
48 private WindowAndroid mWindowAndroid; | 64 private WindowAndroid mWindowAndroid; |
49 private BroadcastReceiver mReceiver; | 65 private BroadcastReceiver mReceiver; |
50 | 66 |
51 @Override | 67 @Override |
52 protected void onCreate(Bundle savedInstanceState) { | 68 protected void onCreate(Bundle savedInstanceState) { |
53 super.onCreate(savedInstanceState); | 69 super.onCreate(savedInstanceState); |
54 | 70 |
55 // Initializing the command line must occur before loading the library. | 71 // Initializing the command line must occur before loading the library. |
56 if (!CommandLine.isInitialized()) { | 72 if (!CommandLine.isInitialized()) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 143 |
128 return super.onKeyUp(keyCode, event); | 144 return super.onKeyUp(keyCode, event); |
129 } | 145 } |
130 | 146 |
131 @Override | 147 @Override |
132 protected void onNewIntent(Intent intent) { | 148 protected void onNewIntent(Intent intent) { |
133 if (getCommandLineParamsFromIntent(intent) != null) { | 149 if (getCommandLineParamsFromIntent(intent) != null) { |
134 Log.i(TAG, "Ignoring command line params: can only be set when creat
ing the activity."); | 150 Log.i(TAG, "Ignoring command line params: can only be set when creat
ing the activity."); |
135 } | 151 } |
136 | 152 |
| 153 if (ACTION_LOW_MEMORY.equals(intent.getAction())) { |
| 154 MemoryPressureListener.simulateMemoryPressureSignal(TRIM_MEMORY_COMP
LETE); |
| 155 return; |
| 156 } else if (ACTION_TRIM_MEMORY_MODERATE.equals(intent.getAction())) { |
| 157 MemoryPressureListener.simulateMemoryPressureSignal(TRIM_MEMORY_MODE
RATE); |
| 158 return; |
| 159 } |
| 160 |
137 String url = getUrlFromIntent(intent); | 161 String url = getUrlFromIntent(intent); |
138 if (!TextUtils.isEmpty(url)) { | 162 if (!TextUtils.isEmpty(url)) { |
139 Shell activeView = getActiveShell(); | 163 Shell activeView = getActiveShell(); |
140 if (activeView != null) { | 164 if (activeView != null) { |
141 activeView.loadUrl(url); | 165 activeView.loadUrl(url); |
142 } | 166 } |
143 } | 167 } |
144 } | 168 } |
145 | 169 |
146 @Override | 170 @Override |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 236 |
213 /** | 237 /** |
214 * @return The {@link ContentView} owned by the currently visible {@link She
ll} or null if one | 238 * @return The {@link ContentView} owned by the currently visible {@link She
ll} or null if one |
215 * is not showing. | 239 * is not showing. |
216 */ | 240 */ |
217 public ContentView getActiveContentView() { | 241 public ContentView getActiveContentView() { |
218 Shell shell = getActiveShell(); | 242 Shell shell = getActiveShell(); |
219 return shell != null ? shell.getContentView() : null; | 243 return shell != null ? shell.getContentView() : null; |
220 } | 244 } |
221 } | 245 } |
OLD | NEW |