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