Chromium Code Reviews| 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; | 5 package org.chromium.content_shell; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.BroadcastReceiver; | |
| 9 import android.content.Context; | |
| 8 import android.content.Intent; | 10 import android.content.Intent; |
| 11 import android.content.IntentFilter; | |
| 9 import android.os.Bundle; | 12 import android.os.Bundle; |
| 10 import android.text.TextUtils; | 13 import android.text.TextUtils; |
| 11 import android.util.Log; | 14 import android.util.Log; |
| 12 import android.view.KeyEvent; | 15 import android.view.KeyEvent; |
| 13 | 16 |
| 14 import org.chromium.base.ChromiumActivity; | 17 import org.chromium.base.ChromiumActivity; |
| 15 import org.chromium.content.app.LibraryLoader; | 18 import org.chromium.content.app.LibraryLoader; |
| 16 import org.chromium.content.browser.ActivityContentVideoViewDelegate; | 19 import org.chromium.content.browser.ActivityContentVideoViewDelegate; |
| 17 import org.chromium.content.browser.ContentVideoView; | 20 import org.chromium.content.browser.ContentVideoView; |
| 18 import org.chromium.content.browser.ContentView; | 21 import org.chromium.content.browser.ContentView; |
| 19 import org.chromium.content.browser.DeviceUtils; | 22 import org.chromium.content.browser.DeviceUtils; |
| 20 import org.chromium.content.common.CommandLine; | 23 import org.chromium.content.common.CommandLine; |
| 21 import org.chromium.ui.gfx.ActivityNativeWindow; | 24 import org.chromium.ui.gfx.ActivityNativeWindow; |
| 22 | 25 |
| 23 /** | 26 /** |
| 24 * Activity for managing the Content Shell. | 27 * Activity for managing the Content Shell. |
| 25 */ | 28 */ |
| 26 public class ContentShellActivity extends ChromiumActivity { | 29 public class ContentShellActivity extends ChromiumActivity { |
| 27 | 30 |
| 28 public static final String COMMAND_LINE_FILE = "/data/local/tmp/content-shel l-command-line"; | 31 public static final String COMMAND_LINE_FILE = "/data/local/tmp/content-shel l-command-line"; |
| 29 private static final String TAG = ContentShellActivity.class.getName(); | 32 private static final String TAG = ContentShellActivity.class.getName(); |
| 30 | 33 |
| 31 private static final String ACTIVE_SHELL_URL_KEY = "activeUrl"; | 34 private static final String ACTIVE_SHELL_URL_KEY = "activeUrl"; |
| 35 private static final String ACTION_START_TRACE = "com.contentshell.action.PR OFILE_START"; | |
|
Ted C
2012/12/26 16:18:28
This should probably be:
org.chromium.content_she
| |
| 36 private static final String ACTION_STOP_TRACE = "com.contentshell.action.PRO FILE_STOP"; | |
| 32 public static final String DEFAULT_SHELL_URL = "http://www.google.com"; | 37 public static final String DEFAULT_SHELL_URL = "http://www.google.com"; |
| 33 public static final String COMMAND_LINE_ARGS_KEY = "commandLineArgs"; | 38 public static final String COMMAND_LINE_ARGS_KEY = "commandLineArgs"; |
| 34 | 39 |
| 35 private ShellManager mShellManager; | 40 private ShellManager mShellManager; |
| 36 private ActivityNativeWindow mActivityNativeWindow; | 41 private ActivityNativeWindow mActivityNativeWindow; |
| 42 private BroadcastReceiver mReceiver; | |
| 37 | 43 |
| 38 @Override | 44 @Override |
| 39 protected void onCreate(Bundle savedInstanceState) { | 45 protected void onCreate(Bundle savedInstanceState) { |
| 40 super.onCreate(savedInstanceState); | 46 super.onCreate(savedInstanceState); |
| 41 | 47 |
| 42 // Initializing the command line must occur before loading the library. | 48 // Initializing the command line must occur before loading the library. |
| 43 if (!CommandLine.isInitialized()) { | 49 if (!CommandLine.isInitialized()) { |
| 44 CommandLine.initFromFile(COMMAND_LINE_FILE); | 50 CommandLine.initFromFile(COMMAND_LINE_FILE); |
| 45 String[] commandLineParams = getCommandLineParamsFromIntent(getInten t()); | 51 String[] commandLineParams = getCommandLineParamsFromIntent(getInten t()); |
| 46 if (commandLineParams != null) { | 52 if (commandLineParams != null) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 } | 128 } |
| 123 } | 129 } |
| 124 } | 130 } |
| 125 | 131 |
| 126 @Override | 132 @Override |
| 127 protected void onPause() { | 133 protected void onPause() { |
| 128 ContentView view = getActiveContentView(); | 134 ContentView view = getActiveContentView(); |
| 129 if (view != null) view.onActivityPause(); | 135 if (view != null) view.onActivityPause(); |
| 130 | 136 |
| 131 super.onPause(); | 137 super.onPause(); |
| 138 unregisterReceiver(mReceiver); | |
| 132 } | 139 } |
| 133 | 140 |
| 134 @Override | 141 @Override |
| 135 protected void onResume() { | 142 protected void onResume() { |
| 136 super.onResume(); | 143 super.onResume(); |
| 137 | 144 |
| 138 ContentView view = getActiveContentView(); | 145 ContentView view = getActiveContentView(); |
| 139 if (view != null) view.onActivityResume(); | 146 if (view != null) view.onActivityResume(); |
| 147 IntentFilter intentFilter = new IntentFilter(ACTION_START_TRACE); | |
| 148 intentFilter.addAction(ACTION_STOP_TRACE); | |
| 149 mReceiver = new BroadcastReceiver() { | |
| 150 @Override | |
| 151 public void onReceive(Context context, Intent intent) { | |
| 152 String action = intent.getAction(); | |
| 153 String extra = intent.getStringExtra("file"); | |
| 154 if (action.equals(ACTION_START_TRACE) && (extra.length() > 0)) { | |
|
Ted C
2012/12/26 16:18:28
When comparing against constants, I prefer to use
| |
| 155 Log.i("ContentShell", "start tracing"); | |
| 156 TraceController.beginTracing(extra); | |
| 157 } else if (action.equals(ACTION_STOP_TRACE)) { | |
| 158 Log.i("ContentShell", "stop tracing"); | |
| 159 TraceController.endTracing(); | |
| 160 } | |
| 161 } | |
| 162 }; | |
| 163 registerReceiver(mReceiver, intentFilter); | |
| 140 } | 164 } |
| 141 | 165 |
| 166 | |
|
Ted C
2012/12/26 16:18:28
no need for this extra line
| |
| 142 @Override | 167 @Override |
| 143 public void onActivityResult(int requestCode, int resultCode, Intent data) { | 168 public void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 144 super.onActivityResult(requestCode, resultCode, data); | 169 super.onActivityResult(requestCode, resultCode, data); |
| 145 mActivityNativeWindow.onActivityResult(requestCode, resultCode, data); | 170 mActivityNativeWindow.onActivityResult(requestCode, resultCode, data); |
| 146 } | 171 } |
| 147 | 172 |
| 148 private static String getUrlFromIntent(Intent intent) { | 173 private static String getUrlFromIntent(Intent intent) { |
| 149 return intent != null ? intent.getDataString() : null; | 174 return intent != null ? intent.getDataString() : null; |
| 150 } | 175 } |
| 151 | 176 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 170 | 195 |
| 171 /** | 196 /** |
| 172 * @return The {@link ContentView} owned by the currently visible {@link She ll} or null if one | 197 * @return The {@link ContentView} owned by the currently visible {@link She ll} or null if one |
| 173 * is not showing. | 198 * is not showing. |
| 174 */ | 199 */ |
| 175 public ContentView getActiveContentView() { | 200 public ContentView getActiveContentView() { |
| 176 Shell shell = getActiveShell(); | 201 Shell shell = getActiveShell(); |
| 177 return shell != null ? shell.getContentView() : null; | 202 return shell != null ? shell.getContentView() : null; |
| 178 } | 203 } |
| 179 } | 204 } |
| OLD | NEW |