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 if (!CommandLine.isInitialized()) { | |
boliu
2015/07/30 21:53:50
This check is repeated in initCommandLine. Don't n
mnaganov (inactive)
2015/07/30 21:59:40
Sure. I initially copied this from ContentShellAct
| |
84 ContentApplication.initCommandLine(this); | |
85 } | |
86 waitForDebuggerIfNeeded(); | |
87 | |
88 AwBrowserProcess.loadLibrary(this); | |
89 | |
90 if (CommandLine.getInstance().hasSwitch(AwShellSwitches.ENABLE_ATRACE)) { | |
91 Log.e(TAG, "Enabling Android trace."); | |
92 TraceEvent.setATraceEnabled(true); | |
93 } | |
94 | |
76 setContentView(R.layout.testshell_activity); | 95 setContentView(R.layout.testshell_activity); |
77 | 96 |
78 mAwTestContainerView = createAwTestContainerView(); | 97 mAwTestContainerView = createAwTestContainerView(); |
79 | 98 |
80 mWebContents = mAwTestContainerView.getContentViewCore().getWebContents( ); | 99 mWebContents = mAwTestContainerView.getContentViewCore().getWebContents( ); |
81 mNavigationController = mWebContents.getNavigationController(); | 100 mNavigationController = mWebContents.getNavigationController(); |
82 LinearLayout contentContainer = (LinearLayout) findViewById(R.id.content _container); | 101 LinearLayout contentContainer = (LinearLayout) findViewById(R.id.content _container); |
83 mAwTestContainerView.setLayoutParams(new LinearLayout.LayoutParams( | 102 mAwTestContainerView.setLayoutParams(new LinearLayout.LayoutParams( |
84 LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1f)); | 103 LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1f)); |
85 contentContainer.addView(mAwTestContainerView); | 104 contentContainer.addView(mAwTestContainerView); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 public boolean onKeyUp(int keyCode, KeyEvent event) { | 288 public boolean onKeyUp(int keyCode, KeyEvent event) { |
270 if (keyCode == KeyEvent.KEYCODE_BACK) { | 289 if (keyCode == KeyEvent.KEYCODE_BACK) { |
271 if (mNavigationController.canGoBack()) { | 290 if (mNavigationController.canGoBack()) { |
272 mNavigationController.goBack(); | 291 mNavigationController.goBack(); |
273 return true; | 292 return true; |
274 } | 293 } |
275 } | 294 } |
276 | 295 |
277 return super.onKeyUp(keyCode, event); | 296 return super.onKeyUp(keyCode, event); |
278 } | 297 } |
298 | |
299 private void waitForDebuggerIfNeeded() { | |
300 if (CommandLine.getInstance().hasSwitch(BaseSwitches.WAIT_FOR_JAVA_DEBUG GER)) { | |
301 Log.e(TAG, "Waiting for Java debugger to connect..."); | |
302 android.os.Debug.waitForDebugger(); | |
303 Log.e(TAG, "Java debugger connected. Resuming execution."); | |
304 } | |
305 } | |
279 } | 306 } |
OLD | NEW |