OLD | NEW |
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.android_webview.shell; | 5 package org.chromium.android_webview.shell; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.content.Intent; | 9 import android.content.Intent; |
10 import android.content.SharedPreferences; | 10 import android.content.SharedPreferences; |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 import org.chromium.android_webview.AwBrowserContext; | 32 import org.chromium.android_webview.AwBrowserContext; |
33 import org.chromium.android_webview.AwBrowserProcess; | 33 import org.chromium.android_webview.AwBrowserProcess; |
34 import org.chromium.android_webview.AwContents; | 34 import org.chromium.android_webview.AwContents; |
35 import org.chromium.android_webview.AwContentsClient; | 35 import org.chromium.android_webview.AwContentsClient; |
36 import org.chromium.android_webview.AwContentsStatics; | 36 import org.chromium.android_webview.AwContentsStatics; |
37 import org.chromium.android_webview.AwDevToolsServer; | 37 import org.chromium.android_webview.AwDevToolsServer; |
38 import org.chromium.android_webview.AwSettings; | 38 import org.chromium.android_webview.AwSettings; |
39 import org.chromium.android_webview.test.AwTestContainerView; | 39 import org.chromium.android_webview.test.AwTestContainerView; |
40 import org.chromium.android_webview.test.NullContentsClient; | 40 import org.chromium.android_webview.test.NullContentsClient; |
| 41 import org.chromium.base.BaseSwitches; |
41 import org.chromium.base.CommandLine; | 42 import org.chromium.base.CommandLine; |
| 43 import org.chromium.base.Log; |
| 44 import org.chromium.base.TraceEvent; |
| 45 import org.chromium.content.app.ContentApplication; |
42 import org.chromium.content.browser.SelectActionMode; | 46 import org.chromium.content.browser.SelectActionMode; |
43 import org.chromium.content.browser.SelectActionModeCallback; | 47 import org.chromium.content.browser.SelectActionModeCallback; |
44 import org.chromium.content.browser.SelectActionModeCallback.ActionHandler; | 48 import org.chromium.content.browser.SelectActionModeCallback.ActionHandler; |
45 import org.chromium.content_public.browser.LoadUrlParams; | 49 import org.chromium.content_public.browser.LoadUrlParams; |
46 import org.chromium.content_public.browser.NavigationController; | 50 import org.chromium.content_public.browser.NavigationController; |
47 import org.chromium.content_public.browser.WebContents; | 51 import org.chromium.content_public.browser.WebContents; |
48 | 52 |
49 import java.net.URI; | 53 import java.net.URI; |
50 import java.net.URISyntaxException; | 54 import java.net.URISyntaxException; |
51 | 55 |
52 /** | 56 /** |
53 * This is a lightweight activity for tests that only require WebView functional
ity. | 57 * This is a lightweight activity for tests that only require WebView functional
ity. |
54 */ | 58 */ |
55 public class AwShellActivity extends Activity { | 59 public class AwShellActivity extends Activity { |
| 60 private static final String TAG = "cr.AwShellActivity"; |
56 private static final String PREFERENCES_NAME = "AwShellPrefs"; | 61 private static final String PREFERENCES_NAME = "AwShellPrefs"; |
57 private static final String INITIAL_URL = "about:blank"; | 62 private static final String INITIAL_URL = "about:blank"; |
58 private AwBrowserContext mBrowserContext; | 63 private AwBrowserContext mBrowserContext; |
59 private AwDevToolsServer mDevToolsServer; | 64 private AwDevToolsServer mDevToolsServer; |
60 private AwTestContainerView mAwTestContainerView; | 65 private AwTestContainerView mAwTestContainerView; |
61 private WebContents mWebContents; | 66 private WebContents mWebContents; |
62 private NavigationController mNavigationController; | 67 private NavigationController mNavigationController; |
63 private EditText mUrlTextView; | 68 private EditText mUrlTextView; |
64 private ImageButton mPrevButton; | 69 private ImageButton mPrevButton; |
65 private ImageButton mNextButton; | 70 private ImageButton mNextButton; |
66 | 71 |
67 // This is the same as data_reduction_proxy::switches::kEnableDataReductionP
roxy. | 72 // This is the same as data_reduction_proxy::switches::kEnableDataReductionP
roxy. |
68 private static final String ENABLE_DATA_REDUCTION_PROXY = "enable-spdy-proxy
-auth"; | 73 private static final String ENABLE_DATA_REDUCTION_PROXY = "enable-spdy-proxy
-auth"; |
69 // This is the same as data_reduction_proxy::switches::kDataReductionProxyKe
y. | 74 // This is the same as data_reduction_proxy::switches::kDataReductionProxyKe
y. |
70 private static final String DATA_REDUCTION_PROXY_KEY = "spdy-proxy-auth-valu
e"; | 75 private static final String DATA_REDUCTION_PROXY_KEY = "spdy-proxy-auth-valu
e"; |
71 | 76 |
72 @Override | 77 @Override |
73 public void onCreate(Bundle savedInstanceState) { | 78 public void onCreate(Bundle savedInstanceState) { |
74 super.onCreate(savedInstanceState); | 79 super.onCreate(savedInstanceState); |
75 | 80 |
| 81 AwShellResourceProvider.registerResources(this); |
| 82 |
| 83 ContentApplication.initCommandLine(this); |
| 84 waitForDebuggerIfNeeded(); |
| 85 |
| 86 AwBrowserProcess.loadLibrary(this); |
| 87 |
| 88 if (CommandLine.getInstance().hasSwitch(AwShellSwitches.ENABLE_ATRACE))
{ |
| 89 Log.e(TAG, "Enabling Android trace."); |
| 90 TraceEvent.setATraceEnabled(true); |
| 91 } |
| 92 |
76 setContentView(R.layout.testshell_activity); | 93 setContentView(R.layout.testshell_activity); |
77 | 94 |
78 mAwTestContainerView = createAwTestContainerView(); | 95 mAwTestContainerView = createAwTestContainerView(); |
79 | 96 |
80 mWebContents = mAwTestContainerView.getContentViewCore().getWebContents(
); | 97 mWebContents = mAwTestContainerView.getContentViewCore().getWebContents(
); |
81 mNavigationController = mWebContents.getNavigationController(); | 98 mNavigationController = mWebContents.getNavigationController(); |
82 LinearLayout contentContainer = (LinearLayout) findViewById(R.id.content
_container); | 99 LinearLayout contentContainer = (LinearLayout) findViewById(R.id.content
_container); |
83 mAwTestContainerView.setLayoutParams(new LinearLayout.LayoutParams( | 100 mAwTestContainerView.setLayoutParams(new LinearLayout.LayoutParams( |
84 LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1f)); | 101 LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1f)); |
85 contentContainer.addView(mAwTestContainerView); | 102 contentContainer.addView(mAwTestContainerView); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 public boolean onKeyUp(int keyCode, KeyEvent event) { | 286 public boolean onKeyUp(int keyCode, KeyEvent event) { |
270 if (keyCode == KeyEvent.KEYCODE_BACK) { | 287 if (keyCode == KeyEvent.KEYCODE_BACK) { |
271 if (mNavigationController.canGoBack()) { | 288 if (mNavigationController.canGoBack()) { |
272 mNavigationController.goBack(); | 289 mNavigationController.goBack(); |
273 return true; | 290 return true; |
274 } | 291 } |
275 } | 292 } |
276 | 293 |
277 return super.onKeyUp(keyCode, event); | 294 return super.onKeyUp(keyCode, event); |
278 } | 295 } |
| 296 |
| 297 private void waitForDebuggerIfNeeded() { |
| 298 if (CommandLine.getInstance().hasSwitch(BaseSwitches.WAIT_FOR_JAVA_DEBUG
GER)) { |
| 299 Log.e(TAG, "Waiting for Java debugger to connect..."); |
| 300 android.os.Debug.waitForDebugger(); |
| 301 Log.e(TAG, "Java debugger connected. Resuming execution."); |
| 302 } |
| 303 } |
279 } | 304 } |
OLD | NEW |