| 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.browser.DeviceUtils; |
| 17 import org.chromium.content.common.CommandLine; | 18 import org.chromium.content.common.CommandLine; |
| 18 import org.chromium.ui.gfx.ActivityNativeWindow; | 19 import org.chromium.ui.gfx.ActivityNativeWindow; |
| 19 | 20 |
| 20 /** | 21 /** |
| 21 * Activity for managing the Content Shell. | 22 * Activity for managing the Content Shell. |
| 22 */ | 23 */ |
| 23 public class ContentShellActivity extends Activity { | 24 public class ContentShellActivity extends Activity { |
| 24 | 25 |
| 25 private static final String COMMAND_LINE_FILE = "/data/local/tmp/content-she
ll-command-line"; | 26 private static final String COMMAND_LINE_FILE = "/data/local/tmp/content-she
ll-command-line"; |
| 26 private static final String TAG = ContentShellActivity.class.getName(); | 27 private static final String TAG = ContentShellActivity.class.getName(); |
| 27 | 28 |
| 28 private static final String ACTIVE_SHELL_URL_KEY = "activeUrl"; | 29 private static final String ACTIVE_SHELL_URL_KEY = "activeUrl"; |
| 29 public static final String DEFAULT_SHELL_URL = "http://www.google.com"; | 30 public static final String DEFAULT_SHELL_URL = "http://www.google.com"; |
| 30 | 31 |
| 31 private ShellManager mShellManager; | 32 private ShellManager mShellManager; |
| 32 private ActivityNativeWindow mActivityNativeWindow; | 33 private ActivityNativeWindow mActivityNativeWindow; |
| 33 | 34 |
| 34 @Override | 35 @Override |
| 35 protected void onCreate(Bundle savedInstanceState) { | 36 protected void onCreate(Bundle savedInstanceState) { |
| 36 super.onCreate(savedInstanceState); | 37 super.onCreate(savedInstanceState); |
| 37 | 38 |
| 38 // Initializing the command line must occur before loading the library. | 39 // Initializing the command line must occur before loading the library. |
| 39 if (!CommandLine.isInitialized()) CommandLine.initFromFile(COMMAND_LINE_
FILE); | 40 if (!CommandLine.isInitialized()) CommandLine.initFromFile(COMMAND_LINE_
FILE); |
| 40 waitForDebuggerIfNeeded(); | 41 waitForDebuggerIfNeeded(); |
| 41 | 42 |
| 43 DeviceUtils.addDeviceSpecificUserAgentSwitch(this); |
| 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 mActivityNativeWindow = new ActivityNativeWindow(this); | 50 mActivityNativeWindow = new ActivityNativeWindow(this); |
| 48 mActivityNativeWindow.restoreInstanceState(savedInstanceState); | 51 mActivityNativeWindow.restoreInstanceState(savedInstanceState); |
| 49 mShellManager.setWindow(mActivityNativeWindow); | 52 mShellManager.setWindow(mActivityNativeWindow); |
| 50 | 53 |
| 51 String startupUrl = getUrlFromIntent(getIntent()); | 54 String startupUrl = getUrlFromIntent(getIntent()); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 Shell shell = getActiveShell(); | 158 Shell shell = getActiveShell(); |
| 156 return shell != null ? shell.getContentView() : null; | 159 return shell != null ? shell.getContentView() : null; |
| 157 } | 160 } |
| 158 | 161 |
| 159 private void initializeContentViewResources() { | 162 private void initializeContentViewResources() { |
| 160 AppResource.DIMENSION_LINK_PREVIEW_OVERLAY_RADIUS = R.dimen.link_preview
_overlay_radius; | 163 AppResource.DIMENSION_LINK_PREVIEW_OVERLAY_RADIUS = R.dimen.link_preview
_overlay_radius; |
| 161 AppResource.DRAWABLE_LINK_PREVIEW_POPUP_OVERLAY = R.drawable.popup_zoome
r_overlay; | 164 AppResource.DRAWABLE_LINK_PREVIEW_POPUP_OVERLAY = R.drawable.popup_zoome
r_overlay; |
| 162 AppResource.STRING_CONTENT_VIEW_CONTENT_DESCRIPTION = R.string.accessibi
lity_content_view; | 165 AppResource.STRING_CONTENT_VIEW_CONTENT_DESCRIPTION = R.string.accessibi
lity_content_view; |
| 163 } | 166 } |
| 164 } | 167 } |
| OLD | NEW |