Index: content/shell/android/java/org/chromium/content_shell/ContentShellActivity.java |
diff --git a/content/shell/android/java/org/chromium/content_shell/ContentShellActivity.java b/content/shell/android/java/org/chromium/content_shell/ContentShellActivity.java |
index 4a57e9cfaee4dc1108ef0f53901c62910f4c0c3d..837656130cbf9e2ba9766015066babf7311a446e 100644 |
--- a/content/shell/android/java/org/chromium/content_shell/ContentShellActivity.java |
+++ b/content/shell/android/java/org/chromium/content_shell/ContentShellActivity.java |
@@ -5,20 +5,86 @@ |
package org.chromium.content_shell; |
import android.app.Activity; |
+import android.content.Intent; |
import android.os.Bundle; |
-import android.util.Log; |
+import android.text.TextUtils; |
+import android.view.KeyEvent; |
+ |
+import org.chromium.content.browser.ContentView; |
/** |
- * This is the main activity for content_shell on android, gets invoked when the |
- * app is invoked from the launcher. This activity hosts the main UI for content |
- * shell and displays the web content via its child views. |
+ * Activity for managing the Content Shell. |
*/ |
public class ContentShellActivity extends Activity { |
- private final String TAG = "ContentShellActivity"; |
+ |
+ private static final String COMMAND_LINE_FILE = "/data/local/content-shell-command-line"; |
+ |
+ private ShellManager mShellManager; |
@Override |
- public void onCreate(Bundle savedInstanceState) { |
+ protected void onCreate(Bundle savedInstanceState) { |
super.onCreate(savedInstanceState); |
- Log.i(TAG, "Content shell started"); |
+ |
+ // Initializing the command line must occur before loading the library. |
+ // TODO(tedchoc): Initialize command line from file. |
+ String startupUrl = getUrlFromIntent(getIntent()); |
+ if (!TextUtils.isEmpty(startupUrl)) { |
+ // TODO(tedchoc): Append URL to command line. |
+ } |
+ |
+ // TODO(tedchoc): Load the native library. |
+ initializeContentViewResources(); |
+ |
+ setContentView(R.layout.content_shell_activity); |
+ mShellManager = (ShellManager) findViewById(R.id.shell_container); |
+ ContentView.enableMultiProcess(this, ContentView.MAX_RENDERERS_AUTOMATIC); |
+ } |
+ |
+ @Override |
+ public boolean onKeyUp(int keyCode, KeyEvent event) { |
+ if (keyCode != KeyEvent.KEYCODE_BACK) return super.onKeyUp(keyCode, event); |
+ |
+ ShellView activeView = getActiveShellView(); |
+ if (activeView != null && activeView.getContentView().canGoBack()) { |
+ activeView.getContentView().goBack(); |
+ return true; |
+ } |
+ |
+ return super.onKeyUp(keyCode, event); |
+ } |
+ |
+ @Override |
+ protected void onNewIntent(Intent intent) { |
+ String url = getUrlFromIntent(intent); |
+ if (!TextUtils.isEmpty(url)) { |
+ ShellView activeView = getActiveShellView(); |
+ if (activeView != null) { |
+ activeView.loadUrl(url); |
+ } |
+ } |
+ } |
+ |
+ private static String getUrlFromIntent(Intent intent) { |
+ return intent != null ? intent.getDataString() : null; |
+ } |
+ |
+ /** |
+ * @return The {@link ShellManager} configured for the activity or null if it has not been |
+ * created yet. |
+ */ |
+ public ShellManager getShellManager() { |
+ return mShellManager; |
+ } |
+ |
+ /** |
+ * @return The currently visible {@link ShellView} or null if one is not showing. |
+ */ |
+ public ShellView getActiveShellView() { |
+ return mShellManager != null ? mShellManager.getActiveShellView() : null; |
+ } |
+ |
+ private void initializeContentViewResources() { |
+ ContentView.registerPopupOverlayCornerRadius(0); |
+ ContentView.registerPopupOverlayResourceId(R.drawable.popup_zoomer_overlay); |
} |
} |