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.app.Activity; | 7 import android.app.Activity; |
8 import android.content.Intent; | 8 import android.content.Intent; |
9 import android.os.Bundle; | 9 import android.os.Bundle; |
10 import android.text.TextUtils; | 10 import android.text.TextUtils; |
11 import android.util.Log; | 11 import android.util.Log; |
12 import android.view.KeyEvent; | 12 import android.view.KeyEvent; |
13 import android.widget.Toast; | 13 import android.widget.Toast; |
14 | 14 |
| 15 import org.chromium.base.BaseSwitches; |
| 16 import org.chromium.base.CommandLine; |
15 import org.chromium.base.MemoryPressureListener; | 17 import org.chromium.base.MemoryPressureListener; |
16 import org.chromium.content.app.LibraryLoader; | 18 import org.chromium.content.app.LibraryLoader; |
17 import org.chromium.content.browser.ActivityContentVideoViewClient; | 19 import org.chromium.content.browser.ActivityContentVideoViewClient; |
18 import org.chromium.content.browser.BrowserStartupController; | 20 import org.chromium.content.browser.BrowserStartupController; |
19 import org.chromium.content.browser.ContentVideoViewClient; | 21 import org.chromium.content.browser.ContentVideoViewClient; |
20 import org.chromium.content.browser.ContentView; | 22 import org.chromium.content.browser.ContentView; |
21 import org.chromium.content.browser.ContentViewClient; | 23 import org.chromium.content.browser.ContentViewClient; |
22 import org.chromium.content.browser.DeviceUtils; | 24 import org.chromium.content.browser.DeviceUtils; |
23 import org.chromium.content.common.CommandLine; | 25 import org.chromium.content.common.ContentSwitches; |
24 import org.chromium.content.common.ProcessInitException; | 26 import org.chromium.content.common.ProcessInitException; |
25 import org.chromium.content_shell.Shell; | 27 import org.chromium.content_shell.Shell; |
26 import org.chromium.content_shell.ShellManager; | 28 import org.chromium.content_shell.ShellManager; |
27 import org.chromium.ui.base.ActivityWindowAndroid; | 29 import org.chromium.ui.base.ActivityWindowAndroid; |
28 import org.chromium.ui.base.WindowAndroid; | 30 import org.chromium.ui.base.WindowAndroid; |
29 | 31 |
30 /** | 32 /** |
31 * Activity for managing the Content Shell. | 33 * Activity for managing the Content Shell. |
32 */ | 34 */ |
33 public class ContentShellActivity extends Activity { | 35 public class ContentShellActivity extends Activity { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 mShellManager = (ShellManager) findViewById(R.id.shell_container); | 70 mShellManager = (ShellManager) findViewById(R.id.shell_container); |
69 mWindowAndroid = new ActivityWindowAndroid(this); | 71 mWindowAndroid = new ActivityWindowAndroid(this); |
70 mWindowAndroid.restoreInstanceState(savedInstanceState); | 72 mWindowAndroid.restoreInstanceState(savedInstanceState); |
71 mShellManager.setWindow(mWindowAndroid); | 73 mShellManager.setWindow(mWindowAndroid); |
72 | 74 |
73 String startupUrl = getUrlFromIntent(getIntent()); | 75 String startupUrl = getUrlFromIntent(getIntent()); |
74 if (!TextUtils.isEmpty(startupUrl)) { | 76 if (!TextUtils.isEmpty(startupUrl)) { |
75 mShellManager.setStartupUrl(Shell.sanitizeUrl(startupUrl)); | 77 mShellManager.setStartupUrl(Shell.sanitizeUrl(startupUrl)); |
76 } | 78 } |
77 | 79 |
78 if (CommandLine.getInstance().hasSwitch(CommandLine.DUMP_RENDER_TREE)) { | 80 if (CommandLine.getInstance().hasSwitch(ContentSwitches.DUMP_RENDER_TREE
)) { |
79 if(BrowserStartupController.get(this).startBrowserProcessesSync( | 81 if(BrowserStartupController.get(this).startBrowserProcessesSync( |
80 BrowserStartupController.MAX_RENDERERS_LIMIT)) { | 82 BrowserStartupController.MAX_RENDERERS_LIMIT)) { |
81 finishInitialization(savedInstanceState); | 83 finishInitialization(savedInstanceState); |
82 } else { | 84 } else { |
83 initializationFailed(); | 85 initializationFailed(); |
84 } | 86 } |
85 } else { | 87 } else { |
86 BrowserStartupController.get(this).startBrowserProcessesAsync( | 88 BrowserStartupController.get(this).startBrowserProcessesAsync( |
87 new BrowserStartupController.StartupCallback() { | 89 new BrowserStartupController.StartupCallback() { |
88 @Override | 90 @Override |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 super.onSaveInstanceState(outState); | 128 super.onSaveInstanceState(outState); |
127 Shell activeShell = getActiveShell(); | 129 Shell activeShell = getActiveShell(); |
128 if (activeShell != null) { | 130 if (activeShell != null) { |
129 outState.putString(ACTIVE_SHELL_URL_KEY, activeShell.getContentView(
).getUrl()); | 131 outState.putString(ACTIVE_SHELL_URL_KEY, activeShell.getContentView(
).getUrl()); |
130 } | 132 } |
131 | 133 |
132 mWindowAndroid.saveInstanceState(outState); | 134 mWindowAndroid.saveInstanceState(outState); |
133 } | 135 } |
134 | 136 |
135 private void waitForDebuggerIfNeeded() { | 137 private void waitForDebuggerIfNeeded() { |
136 if (CommandLine.getInstance().hasSwitch(CommandLine.WAIT_FOR_JAVA_DEBUGG
ER)) { | 138 if (CommandLine.getInstance().hasSwitch(BaseSwitches.WAIT_FOR_JAVA_DEBUG
GER)) { |
137 Log.e(TAG, "Waiting for Java debugger to connect..."); | 139 Log.e(TAG, "Waiting for Java debugger to connect..."); |
138 android.os.Debug.waitForDebugger(); | 140 android.os.Debug.waitForDebugger(); |
139 Log.e(TAG, "Java debugger connected. Resuming execution."); | 141 Log.e(TAG, "Java debugger connected. Resuming execution."); |
140 } | 142 } |
141 } | 143 } |
142 | 144 |
143 @Override | 145 @Override |
144 public boolean onKeyUp(int keyCode, KeyEvent event) { | 146 public boolean onKeyUp(int keyCode, KeyEvent event) { |
145 if (keyCode != KeyEvent.KEYCODE_BACK) return super.onKeyUp(keyCode, even
t); | 147 if (keyCode != KeyEvent.KEYCODE_BACK) return super.onKeyUp(keyCode, even
t); |
146 | 148 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 219 |
218 /** | 220 /** |
219 * @return The {@link ContentView} owned by the currently visible {@link She
ll} or null if one | 221 * @return The {@link ContentView} owned by the currently visible {@link She
ll} or null if one |
220 * is not showing. | 222 * is not showing. |
221 */ | 223 */ |
222 public ContentView getActiveContentView() { | 224 public ContentView getActiveContentView() { |
223 Shell shell = getActiveShell(); | 225 Shell shell = getActiveShell(); |
224 return shell != null ? shell.getContentView() : null; | 226 return shell != null ? shell.getContentView() : null; |
225 } | 227 } |
226 } | 228 } |
OLD | NEW |