Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellActivity.java

Issue 10968003: Add rendering support to the TestShell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed nits, rebased. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..55f43be0c0c571c4d6aa734370f709b2bb7b5907 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.ActivityNativeWindow;
/**
* 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 ActivityNativeWindow mWindow;
+ private TabManager mTabManager;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -27,10 +36,73 @@ public class ChromiumTestShellActivity extends Activity {
if (!CommandLine.isInitialized()) CommandLine.initFromFile(COMMAND_LINE_FILE);
waitForDebuggerIfNeeded();
- LibraryLoader.loadAndInitSync();
initializeContentViewResources();
-
ContentView.initChromiumBrowserProcess(this, ContentView.MAX_RENDERERS_AUTOMATIC);
+
+ setContentView(R.layout.testshell_activity);
+ mTabManager = (TabManager) findViewById(R.id.tab_manager);
+
+ mWindow = new ActivityNativeWindow(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 +114,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;
+ AppResource.STRING_CONTENT_VIEW_CONTENT_DESCRIPTION = R.string.accessibility_content_view;
+ }
+
+ private static String getUrlFromIntent(Intent intent) {
+ return intent != null ? intent.getDataString() : null;
}
}

Powered by Google App Engine
This is Rietveld 408576698