| 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.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"; | 27 private static final String ACTIVE_SHELL_URL_KEY = "activeUrl"; |
| 28 private static final String DEFAULT_SHELL_URL = "http://www.google.com"; | 28 public static final String DEFAULT_SHELL_URL = "http://www.google.com"; |
| 29 | 29 |
| 30 private ShellManager mShellManager; | 30 private ShellManager mShellManager; |
| 31 | 31 |
| 32 @Override | 32 @Override |
| 33 protected void onCreate(Bundle savedInstanceState) { | 33 protected void onCreate(Bundle savedInstanceState) { |
| 34 super.onCreate(savedInstanceState); | 34 super.onCreate(savedInstanceState); |
| 35 | 35 |
| 36 // Initializing the command line must occur before loading the library. | 36 // Initializing the command line must occur before loading the library. |
| 37 if (!CommandLine.isInitialized()) CommandLine.initFromFile(COMMAND_LINE_
FILE); | 37 if (!CommandLine.isInitialized()) CommandLine.initFromFile(COMMAND_LINE_
FILE); |
| 38 String startupUrl = getUrlFromIntent(getIntent()); | |
| 39 if (!TextUtils.isEmpty(startupUrl)) { | |
| 40 CommandLine.getInstance().appendSwitchesAndArguments( | |
| 41 new String[] {Shell.sanitizeUrl(startupUrl)}); | |
| 42 } | |
| 43 waitForDebuggerIfNeeded(); | 38 waitForDebuggerIfNeeded(); |
| 44 | 39 |
| 45 LibraryLoader.loadAndInitSync(); | 40 LibraryLoader.loadAndInitSync(); |
| 46 initializeContentViewResources(); | 41 initializeContentViewResources(); |
| 47 | 42 |
| 48 setContentView(R.layout.content_shell_activity); | 43 setContentView(R.layout.content_shell_activity); |
| 49 mShellManager = (ShellManager) findViewById(R.id.shell_container); | 44 mShellManager = (ShellManager) findViewById(R.id.shell_container); |
| 45 |
| 46 String startupUrl = getUrlFromIntent(getIntent()); |
| 47 if (!TextUtils.isEmpty(startupUrl)) { |
| 48 mShellManager.setStartupUrl(Shell.sanitizeUrl(startupUrl)); |
| 49 } |
| 50 |
| 50 if (!ContentView.enableMultiProcess(this, ContentView.MAX_RENDERERS_AUTO
MATIC)) { | 51 if (!ContentView.enableMultiProcess(this, ContentView.MAX_RENDERERS_AUTO
MATIC)) { |
| 51 String shellUrl = DEFAULT_SHELL_URL; | 52 String shellUrl = DEFAULT_SHELL_URL; |
| 52 if (savedInstanceState != null | 53 if (savedInstanceState != null |
| 53 && savedInstanceState.containsKey(ACTIVE_SHELL_URL_KEY)) { | 54 && savedInstanceState.containsKey(ACTIVE_SHELL_URL_KEY)) { |
| 54 shellUrl = savedInstanceState.getString(ACTIVE_SHELL_URL_KEY); | 55 shellUrl = savedInstanceState.getString(ACTIVE_SHELL_URL_KEY); |
| 55 } | 56 } |
| 56 mShellManager.launchShell(shellUrl); | 57 mShellManager.launchShell(shellUrl); |
| 57 } | 58 } |
| 58 } | 59 } |
| 59 | 60 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 */ | 116 */ |
| 116 public Shell getActiveShell() { | 117 public Shell getActiveShell() { |
| 117 return mShellManager != null ? mShellManager.getActiveShell() : null; | 118 return mShellManager != null ? mShellManager.getActiveShell() : null; |
| 118 } | 119 } |
| 119 | 120 |
| 120 private void initializeContentViewResources() { | 121 private void initializeContentViewResources() { |
| 121 AppResource.DIMENSION_LINK_PREVIEW_OVERLAY_RADIUS = R.dimen.link_preview
_overlay_radius; | 122 AppResource.DIMENSION_LINK_PREVIEW_OVERLAY_RADIUS = R.dimen.link_preview
_overlay_radius; |
| 122 AppResource.DRAWABLE_LINK_PREVIEW_POPUP_OVERLAY = R.drawable.popup_zoome
r_overlay; | 123 AppResource.DRAWABLE_LINK_PREVIEW_POPUP_OVERLAY = R.drawable.popup_zoome
r_overlay; |
| 123 } | 124 } |
| 124 } | 125 } |
| OLD | NEW |