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 if (DeviceUtils.isTablet(this)) { |
| 44 CommandLine.getInstance().appendSwitch(DeviceUtils.TABLET_UI); |
| 45 } else { |
| 46 CommandLine.getInstance().appendSwitch(CommandLine.USE_MOBILE_UA); |
| 47 } |
| 48 |
42 LibraryLoader.loadAndInitSync(); | 49 LibraryLoader.loadAndInitSync(); |
43 initializeContentViewResources(); | 50 initializeContentViewResources(); |
44 | 51 |
45 setContentView(R.layout.content_shell_activity); | 52 setContentView(R.layout.content_shell_activity); |
46 mShellManager = (ShellManager) findViewById(R.id.shell_container); | 53 mShellManager = (ShellManager) findViewById(R.id.shell_container); |
47 mActivityNativeWindow = new ActivityNativeWindow(this); | 54 mActivityNativeWindow = new ActivityNativeWindow(this); |
48 mActivityNativeWindow.restoreInstanceState(savedInstanceState); | 55 mActivityNativeWindow.restoreInstanceState(savedInstanceState); |
49 mShellManager.setWindow(mActivityNativeWindow); | 56 mShellManager.setWindow(mActivityNativeWindow); |
50 | 57 |
51 String startupUrl = getUrlFromIntent(getIntent()); | 58 String startupUrl = getUrlFromIntent(getIntent()); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 Shell shell = getActiveShell(); | 162 Shell shell = getActiveShell(); |
156 return shell != null ? shell.getContentView() : null; | 163 return shell != null ? shell.getContentView() : null; |
157 } | 164 } |
158 | 165 |
159 private void initializeContentViewResources() { | 166 private void initializeContentViewResources() { |
160 AppResource.DIMENSION_LINK_PREVIEW_OVERLAY_RADIUS = R.dimen.link_preview
_overlay_radius; | 167 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; | 168 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; | 169 AppResource.STRING_CONTENT_VIEW_CONTENT_DESCRIPTION = R.string.accessibi
lity_content_view; |
163 } | 170 } |
164 } | 171 } |
OLD | NEW |