summaryrefslogtreecommitdiffstats
path: root/android_webview
diff options
context:
space:
mode:
authormnaganov <mnaganov@chromium.org>2015-07-30 15:27:26 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-30 22:27:59 +0000
commit00c4574b9362fc4b7de6346230be5898420f4a5e (patch)
tree5139240ef5e9905b4c2fced884cf537eea1d8eff /android_webview
parent8c73f834bc73178123389c29d7627e29cb09d501 (diff)
downloadchromium_src-00c4574b9362fc4b7de6346230be5898420f4a5e.zip
chromium_src-00c4574b9362fc4b7de6346230be5898420f4a5e.tar.gz
chromium_src-00c4574b9362fc4b7de6346230be5898420f4a5e.tar.bz2
[Android WebView] Move browser-side initialization out from Application
Application code runs both for the main activity and child services. Browser-side code should be run from Activity.onCreate. BUG=156062 Review URL: https://codereview.chromium.org/1262393003 Cr-Commit-Position: refs/heads/master@{#341208}
Diffstat (limited to 'android_webview')
-rw-r--r--android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellActivity.java25
-rw-r--r--android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellApplication.java31
-rw-r--r--android_webview/test/shell/src/org/chromium/android_webview/test/AwTestRunnerActivity.java6
3 files changed, 35 insertions, 27 deletions
diff --git a/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellActivity.java b/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellActivity.java
index d24d813..7f374b8 100644
--- a/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellActivity.java
+++ b/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellActivity.java
@@ -38,7 +38,11 @@ import org.chromium.android_webview.AwDevToolsServer;
import org.chromium.android_webview.AwSettings;
import org.chromium.android_webview.test.AwTestContainerView;
import org.chromium.android_webview.test.NullContentsClient;
+import org.chromium.base.BaseSwitches;
import org.chromium.base.CommandLine;
+import org.chromium.base.Log;
+import org.chromium.base.TraceEvent;
+import org.chromium.content.app.ContentApplication;
import org.chromium.content.browser.SelectActionMode;
import org.chromium.content.browser.SelectActionModeCallback;
import org.chromium.content.browser.SelectActionModeCallback.ActionHandler;
@@ -53,6 +57,7 @@ import java.net.URISyntaxException;
* This is a lightweight activity for tests that only require WebView functionality.
*/
public class AwShellActivity extends Activity {
+ private static final String TAG = "cr.AwShellActivity";
private static final String PREFERENCES_NAME = "AwShellPrefs";
private static final String INITIAL_URL = "about:blank";
private AwBrowserContext mBrowserContext;
@@ -73,6 +78,18 @@ public class AwShellActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ AwShellResourceProvider.registerResources(this);
+
+ ContentApplication.initCommandLine(this);
+ waitForDebuggerIfNeeded();
+
+ AwBrowserProcess.loadLibrary(this);
+
+ if (CommandLine.getInstance().hasSwitch(AwShellSwitches.ENABLE_ATRACE)) {
+ Log.e(TAG, "Enabling Android trace.");
+ TraceEvent.setATraceEnabled(true);
+ }
+
setContentView(R.layout.testshell_activity);
mAwTestContainerView = createAwTestContainerView();
@@ -276,4 +293,12 @@ public class AwShellActivity extends Activity {
return super.onKeyUp(keyCode, event);
}
+
+ private void waitForDebuggerIfNeeded() {
+ if (CommandLine.getInstance().hasSwitch(BaseSwitches.WAIT_FOR_JAVA_DEBUGGER)) {
+ Log.e(TAG, "Waiting for Java debugger to connect...");
+ android.os.Debug.waitForDebugger();
+ Log.e(TAG, "Java debugger connected. Resuming execution.");
+ }
+ }
}
diff --git a/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellApplication.java b/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellApplication.java
index 4e342b8..8b5a615 100644
--- a/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellApplication.java
+++ b/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellApplication.java
@@ -4,14 +4,9 @@
package org.chromium.android_webview.shell;
-import android.os.Debug;
-import android.util.Log;
-
import org.chromium.android_webview.AwBrowserProcess;
import org.chromium.android_webview.R;
-import org.chromium.base.BaseSwitches;
import org.chromium.base.CommandLine;
-import org.chromium.base.TraceEvent;
import org.chromium.base.annotations.SuppressFBWarnings;
import org.chromium.content.app.ContentApplication;
import org.chromium.ui.base.ResourceBundle;
@@ -20,30 +15,9 @@ import org.chromium.ui.base.ResourceBundle;
* The android_webview shell Application subclass.
*/
public class AwShellApplication extends ContentApplication {
-
- private static final String TAG = "AwShellApplication";
-
- @SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME")
@Override
public void onCreate() {
super.onCreate();
-
- AwShellResourceProvider.registerResources(this);
-
- CommandLine.initFromFile("/data/local/tmp/android-webview-command-line");
-
- if (CommandLine.getInstance().hasSwitch(BaseSwitches.WAIT_FOR_JAVA_DEBUGGER)) {
- Log.e(TAG, "Waiting for Java debugger to connect...");
- Debug.waitForDebugger();
- Log.e(TAG, "Java debugger connected. Resuming execution.");
- }
-
- AwBrowserProcess.loadLibrary(this);
-
- if (CommandLine.getInstance().hasSwitch(AwShellSwitches.ENABLE_ATRACE)) {
- Log.e(TAG, "Enabling Android trace.");
- TraceEvent.setATraceEnabled(true);
- }
}
@Override
@@ -51,8 +25,11 @@ public class AwShellApplication extends ContentApplication {
ResourceBundle.initializeLocalePaks(this, R.array.locale_paks);
}
+ @SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME")
@Override
public void initCommandLine() {
- throw new UnsupportedOperationException();
+ if (!CommandLine.isInitialized()) {
+ CommandLine.initFromFile("/data/local/tmp/android-webview-command-line");
+ }
}
}
diff --git a/android_webview/test/shell/src/org/chromium/android_webview/test/AwTestRunnerActivity.java b/android_webview/test/shell/src/org/chromium/android_webview/test/AwTestRunnerActivity.java
index b36ca16..d87b630 100644
--- a/android_webview/test/shell/src/org/chromium/android_webview/test/AwTestRunnerActivity.java
+++ b/android_webview/test/shell/src/org/chromium/android_webview/test/AwTestRunnerActivity.java
@@ -11,6 +11,9 @@ import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
+import org.chromium.android_webview.AwBrowserProcess;
+import org.chromium.android_webview.shell.AwShellResourceProvider;
+
/**
* This is a lightweight activity for tests that only require WebView functionality.
*/
@@ -24,6 +27,9 @@ public class AwTestRunnerActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ AwShellResourceProvider.registerResources(this);
+ AwBrowserProcess.loadLibrary(this);
+
mLinearLayout = new LinearLayout(this);
mLinearLayout.setOrientation(LinearLayout.VERTICAL);
mLinearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);