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

Side by Side Diff: content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java

Issue 10701177: Make content shell on android support relaunching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and removed unnecessary content:: namespacing. Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.util.Log;
12 import android.view.KeyEvent; 12 import android.view.KeyEvent;
13 13
14 import org.chromium.content.app.AppResource; 14 import org.chromium.content.app.AppResource;
15 import org.chromium.content.app.LibraryLoader; 15 import org.chromium.content.app.LibraryLoader;
16 import org.chromium.content.browser.ContentView; 16 import org.chromium.content.browser.ContentView;
17 import org.chromium.content.common.CommandLine; 17 import org.chromium.content.common.CommandLine;
18 18
19 /** 19 /**
20 * Activity for managing the Content Shell. 20 * Activity for managing the Content Shell.
21 */ 21 */
22 public class ContentShellActivity extends Activity { 22 public class ContentShellActivity extends Activity {
23 23
24 private static final String COMMAND_LINE_FILE = "/data/local/tmp/content-she ll-command-line"; 24 private static final String COMMAND_LINE_FILE = "/data/local/tmp/content-she ll-command-line";
25 private static final String TAG = ContentShellActivity.class.getName(); 25 private static final String TAG = ContentShellActivity.class.getName();
26 26
27 private static final String ACTIVE_SHELL_URL_KEY = "activeUrl";
28 private static final String DEFAULT_SHELL_URL = "http://www.google.com";
29
27 private ShellManager mShellManager; 30 private ShellManager mShellManager;
28 31
29 @Override 32 @Override
30 protected void onCreate(Bundle savedInstanceState) { 33 protected void onCreate(Bundle savedInstanceState) {
31 super.onCreate(savedInstanceState); 34 super.onCreate(savedInstanceState);
32 35
33 // Initializing the command line must occur before loading the library. 36 // Initializing the command line must occur before loading the library.
34 CommandLine.initFromFile(COMMAND_LINE_FILE); 37 if (!CommandLine.isInitialized()) CommandLine.initFromFile(COMMAND_LINE_ FILE);
35 String startupUrl = getUrlFromIntent(getIntent()); 38 String startupUrl = getUrlFromIntent(getIntent());
36 if (!TextUtils.isEmpty(startupUrl)) { 39 if (!TextUtils.isEmpty(startupUrl)) {
37 CommandLine.getInstance().appendSwitchesAndArguments( 40 CommandLine.getInstance().appendSwitchesAndArguments(
38 new String[] {Shell.sanitizeUrl(startupUrl)}); 41 new String[] {Shell.sanitizeUrl(startupUrl)});
39 } 42 }
40 waitForDebuggerIfNeeded(); 43 waitForDebuggerIfNeeded();
41 44
42 LibraryLoader.loadAndInitSync(); 45 LibraryLoader.loadAndInitSync();
43 initializeContentViewResources(); 46 initializeContentViewResources();
44 47
45 setContentView(R.layout.content_shell_activity); 48 setContentView(R.layout.content_shell_activity);
46 mShellManager = (ShellManager) findViewById(R.id.shell_container); 49 mShellManager = (ShellManager) findViewById(R.id.shell_container);
47 ContentView.enableMultiProcess(this, ContentView.MAX_RENDERERS_AUTOMATIC ); 50 if (!ContentView.enableMultiProcess(this, ContentView.MAX_RENDERERS_AUTO MATIC)) {
51 String shellUrl = DEFAULT_SHELL_URL;
52 if (savedInstanceState != null
53 && savedInstanceState.containsKey(ACTIVE_SHELL_URL_KEY)) {
54 shellUrl = savedInstanceState.getString(ACTIVE_SHELL_URL_KEY);
55 }
56 mShellManager.launchShell(shellUrl);
57 }
58 }
59
60 @Override
61 protected void onSaveInstanceState(Bundle outState) {
62 super.onSaveInstanceState(outState);
63 Shell activeShell = getActiveShell();
64 if (activeShell != null) {
65 outState.putString(ACTIVE_SHELL_URL_KEY, activeShell.getContentView( ).getUrl());
66 }
48 } 67 }
49 68
50 private void waitForDebuggerIfNeeded() { 69 private void waitForDebuggerIfNeeded() {
51 if (CommandLine.getInstance().hasSwitch(CommandLine.WAIT_FOR_JAVA_DEBUGG ER)) { 70 if (CommandLine.getInstance().hasSwitch(CommandLine.WAIT_FOR_JAVA_DEBUGG ER)) {
52 Log.e(TAG, "Waiting for Java debugger to connect..."); 71 Log.e(TAG, "Waiting for Java debugger to connect...");
53 android.os.Debug.waitForDebugger(); 72 android.os.Debug.waitForDebugger();
54 Log.e(TAG, "Java debugger connected. Resuming execution."); 73 Log.e(TAG, "Java debugger connected. Resuming execution.");
55 } 74 }
56 } 75 }
57 76
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 */ 115 */
97 public Shell getActiveShell() { 116 public Shell getActiveShell() {
98 return mShellManager != null ? mShellManager.getActiveShell() : null; 117 return mShellManager != null ? mShellManager.getActiveShell() : null;
99 } 118 }
100 119
101 private void initializeContentViewResources() { 120 private void initializeContentViewResources() {
102 AppResource.DIMENSION_LINK_PREVIEW_OVERLAY_RADIUS = R.dimen.link_preview _overlay_radius; 121 AppResource.DIMENSION_LINK_PREVIEW_OVERLAY_RADIUS = R.dimen.link_preview _overlay_radius;
103 AppResource.DRAWABLE_LINK_PREVIEW_POPUP_OVERLAY = R.drawable.popup_zoome r_overlay; 122 AppResource.DRAWABLE_LINK_PREVIEW_POPUP_OVERLAY = R.drawable.popup_zoome r_overlay;
104 } 123 }
105 } 124 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698