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.Intent; | 8 import android.content.Intent; |
9 import android.os.Bundle; | 9 import android.os.Bundle; |
10 import android.os.Debug; | |
10 import android.text.TextUtils; | 11 import android.text.TextUtils; |
11 import android.util.Log; | 12 import android.util.Log; |
12 import android.view.KeyEvent; | 13 import android.view.KeyEvent; |
13 | 14 |
15 import org.chromium.content.browser.CommandLine; | |
14 import org.chromium.content.browser.ContentView; | 16 import org.chromium.content.browser.ContentView; |
17 import org.chromium.content.browser.LibraryLoader; | |
15 | 18 |
16 /** | 19 /** |
17 * Activity for managing the Content Shell. | 20 * Activity for managing the Content Shell. |
18 */ | 21 */ |
19 public class ContentShellActivity extends Activity { | 22 public class ContentShellActivity extends Activity { |
20 | 23 |
21 private static final String COMMAND_LINE_FILE = "/data/local/content-shell-c ommand-line"; | 24 private static final String COMMAND_LINE_FILE = "/data/local/content-shell-c ommand-line"; |
22 private static final String TAG = "ContentShellActivity"; | 25 private static final String TAG = "ContentShellActivity"; |
26 private static final String NATIVE_LIBRARY = "content_shell_content_view"; | |
23 | 27 |
24 private ShellManager mShellManager; | 28 private ShellManager mShellManager; |
25 | 29 |
26 @Override | 30 @Override |
27 protected void onCreate(Bundle savedInstanceState) { | 31 protected void onCreate(Bundle savedInstanceState) { |
28 super.onCreate(savedInstanceState); | 32 super.onCreate(savedInstanceState); |
29 | 33 |
30 // Initializing the command line must occur before loading the library. | 34 // Initializing the command line must occur before loading the library. |
31 // TODO(tedchoc): Initialize command line from file. | 35 CommandLine.initFromFile(COMMAND_LINE_FILE); |
32 String startupUrl = getUrlFromIntent(getIntent()); | 36 String startupUrl = getUrlFromIntent(getIntent()); |
33 if (!TextUtils.isEmpty(startupUrl)) { | 37 if (!TextUtils.isEmpty(startupUrl)) { |
34 // TODO(tedchoc): Append URL to command line. | 38 CommandLine.getInstance().appendSwitchesAndArguments( |
39 new String[] {ShellView.sanitizeUrl(startupUrl)}); | |
35 } | 40 } |
36 | 41 |
37 // TODO(jrg,tedchoc): upstream the async library loader, then | 42 // Debug.waitForDebugger(); |
Ted C
2012/05/09 00:26:41
remove?
John Grabowski
2012/05/09 17:18:15
Not until we have command line support (for --wait
| |
38 // make this call look like this: | 43 LibraryLoader.setLibraryToLoad(NATIVE_LIBRARY); |
Ted C
2012/05/09 00:26:41
specifying the library to load should go into Cont
| |
39 // LibraryLoader.loadAndInitSync(); | 44 LibraryLoader.loadAndInitSync(); |
40 loadNativeLibrary(); | |
41 | |
42 initializeContentViewResources(); | 45 initializeContentViewResources(); |
43 | 46 |
44 setContentView(R.layout.content_shell_activity); | 47 setContentView(R.layout.content_shell_activity); |
45 mShellManager = (ShellManager) findViewById(R.id.shell_container); | 48 mShellManager = (ShellManager) findViewById(R.id.shell_container); |
46 ContentView.enableMultiProcess(this, ContentView.MAX_RENDERERS_AUTOMATIC ); | 49 ContentView.enableMultiProcess(this, ContentView.MAX_RENDERERS_AUTOMATIC ); |
47 } | 50 } |
48 | 51 |
49 @Override | 52 @Override |
50 public boolean onKeyUp(int keyCode, KeyEvent event) { | 53 public boolean onKeyUp(int keyCode, KeyEvent event) { |
51 if (keyCode != KeyEvent.KEYCODE_BACK) return super.onKeyUp(keyCode, even t); | 54 if (keyCode != KeyEvent.KEYCODE_BACK) return super.onKeyUp(keyCode, even t); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 * @return The currently visible {@link ShellView} or null if one is not sho wing. | 89 * @return The currently visible {@link ShellView} or null if one is not sho wing. |
87 */ | 90 */ |
88 public ShellView getActiveShellView() { | 91 public ShellView getActiveShellView() { |
89 return mShellManager != null ? mShellManager.getActiveShellView() : null ; | 92 return mShellManager != null ? mShellManager.getActiveShellView() : null ; |
90 } | 93 } |
91 | 94 |
92 private void initializeContentViewResources() { | 95 private void initializeContentViewResources() { |
93 ContentView.registerPopupOverlayCornerRadius(0); | 96 ContentView.registerPopupOverlayCornerRadius(0); |
94 ContentView.registerPopupOverlayResourceId(R.drawable.popup_zoomer_overl ay); | 97 ContentView.registerPopupOverlayResourceId(R.drawable.popup_zoomer_overl ay); |
95 } | 98 } |
96 | |
97 | |
98 private static final String NATIVE_LIBRARY = "content_shell_content_view"; | |
99 | |
100 private void loadNativeLibrary() throws UnsatisfiedLinkError { | |
101 Log.i(TAG, "loading: " + NATIVE_LIBRARY); | |
102 try { | |
103 System.loadLibrary(NATIVE_LIBRARY); | |
104 } catch (UnsatisfiedLinkError e) { | |
105 Log.e(TAG, "Unable to load lib" + NATIVE_LIBRARY + ".so: " + e); | |
106 throw e; | |
107 } | |
108 Log.i(TAG, "loaded: " + NATIVE_LIBRARY); | |
109 } | |
110 } | 99 } |
OLD | NEW |