Chromium Code Reviews| Index: chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellActivity.java |
| diff --git a/chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellActivity.java b/chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellActivity.java |
| index 182de9b539bd63d9cd0dfee1d72ae04fb9a0e80a..b831d3619eea80c445c29f185f3847b3ff5c1a74 100644 |
| --- a/chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellActivity.java |
| +++ b/chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellActivity.java |
| @@ -5,12 +5,18 @@ |
| package org.chromium.chrome.testshell; |
| import android.app.Activity; |
| +import android.content.Intent; |
| import android.os.Bundle; |
| +import android.text.TextUtils; |
| import android.util.Log; |
| +import android.view.KeyEvent; |
| +import org.chromium.chrome.browser.TabBase; |
| +import org.chromium.content.app.AppResource; |
| import org.chromium.content.app.LibraryLoader; |
| import org.chromium.content.browser.ContentView; |
| import org.chromium.content.common.CommandLine; |
| +import org.chromium.ui.gfx.NativeWindow; |
| /** |
| * The {@link Activity} component of a basic test shell to test Chrome features. |
| @@ -20,6 +26,9 @@ public class ChromiumTestShellActivity extends Activity { |
| private static final String COMMAND_LINE_FILE = |
| "/data/local/tmp/chrome-test-shell-command-line"; |
| + private NativeWindow mWindow; |
| + private TabManager mTabManager; |
| + |
| @Override |
| protected void onCreate(Bundle savedInstanceState) { |
| super.onCreate(savedInstanceState); |
| @@ -27,10 +36,74 @@ public class ChromiumTestShellActivity extends Activity { |
| if (!CommandLine.isInitialized()) CommandLine.initFromFile(COMMAND_LINE_FILE); |
| waitForDebuggerIfNeeded(); |
| - LibraryLoader.loadAndInitSync(); |
| initializeContentViewResources(); |
| - |
| ContentView.initChromiumBrowserProcess(this, ContentView.MAX_RENDERERS_AUTOMATIC); |
| + LibraryLoader.loadAndInitSync(); |
| + |
| + setContentView(R.layout.testshell_activity); |
| + mTabManager = (TabManager) findViewById(R.id.tab_manager); |
| + |
| + mWindow = new NativeWindow(this); |
| + mWindow.restoreInstanceState(savedInstanceState); |
| + mTabManager.setWindow(mWindow); |
| + } |
| + |
| + @Override |
| + protected void onSaveInstanceState(Bundle outState) { |
| + // TODO(dtrainor): Save/restore the tab state. |
| + mWindow.saveInstanceState(outState); |
| + } |
| + |
| + @Override |
| + public boolean onKeyUp(int keyCode, KeyEvent event) { |
| + if (keyCode == KeyEvent.KEYCODE_BACK) { |
| + TabBase tab = getActiveTab(); |
| + if (tab != null && tab.getContentView().canGoBack()) { |
| + tab.getContentView().goBack(); |
| + return true; |
| + } |
| + } |
| + |
| + return super.onKeyUp(keyCode, event); |
| + } |
| + |
| + @Override |
| + protected void onNewIntent(Intent intent) { |
| + String url = getUrlFromIntent(intent); |
| + if (!TextUtils.isEmpty(url)) { |
| + TabBase tab = getActiveTab(); |
| + if (tab != null) tab.loadUrlWithSanitization(url); |
| + } |
| + } |
| + |
| + @Override |
| + protected void onPause() { |
| + ContentView view = getActiveContentView(); |
| + if (view != null) view.onActivityPause(); |
| + |
| + super.onPause(); |
| + } |
| + |
| + @Override |
| + protected void onResume() { |
| + super.onResume(); |
| + |
| + ContentView view = getActiveContentView(); |
| + if (view != null) view.onActivityResume(); |
| + } |
| + |
| + @Override |
| + public void onActivityResult(int requestCode, int resultCode, Intent data) { |
| + mWindow.onActivityResult(requestCode, resultCode, data); |
| + } |
| + |
| + private TabBase getActiveTab() { |
| + return mTabManager != null ? mTabManager.getCurrentTab() : null; |
| + } |
| + |
| + private ContentView getActiveContentView() { |
| + TabBase tab = getActiveTab(); |
| + return tab != null ? tab.getContentView() : null; |
| } |
| private void waitForDebuggerIfNeeded() { |
| @@ -42,5 +115,12 @@ public class ChromiumTestShellActivity extends Activity { |
| } |
| private void initializeContentViewResources() { |
| + AppResource.DIMENSION_LINK_PREVIEW_OVERLAY_RADIUS = R.dimen.link_preview_overlay_radius; |
| + AppResource.DRAWABLE_LINK_PREVIEW_POPUP_OVERLAY = R.drawable.popup_zoomer_overlay; |
|
Ted C
2012/09/20 17:23:59
you'll need to dcommit these drawables before you
David Trainor- moved to gerrit
2012/09/21 22:59:10
:'(
On 2012/09/20 17:23:59, Ted C wrote:
|
| + AppResource.STRING_CONTENT_VIEW_CONTENT_DESCRIPTION = R.string.accessibility_content_view; |
| + } |
| + |
| + private static String getUrlFromIntent(Intent intent) { |
| + return intent != null ? intent.getDataString() : null; |
| } |
| } |