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 import org.chromium.ui.gfx.NativeWindow; |
18 | 19 |
19 /** | 20 /** |
20 * Activity for managing the Content Shell. | 21 * Activity for managing the Content Shell. |
21 */ | 22 */ |
22 public class ContentShellActivity extends Activity { | 23 public class ContentShellActivity extends Activity { |
23 | 24 |
24 private static final String COMMAND_LINE_FILE = "/data/local/tmp/content-she
ll-command-line"; | 25 private static final String COMMAND_LINE_FILE = "/data/local/tmp/content-she
ll-command-line"; |
25 private static final String TAG = ContentShellActivity.class.getName(); | 26 private static final String TAG = ContentShellActivity.class.getName(); |
26 | 27 |
27 private static final String ACTIVE_SHELL_URL_KEY = "activeUrl"; | 28 private static final String ACTIVE_SHELL_URL_KEY = "activeUrl"; |
28 public static final String DEFAULT_SHELL_URL = "http://www.google.com"; | 29 public static final String DEFAULT_SHELL_URL = "http://www.google.com"; |
29 | 30 |
30 private ShellManager mShellManager; | 31 private ShellManager mShellManager; |
31 | 32 |
32 @Override | 33 @Override |
33 protected void onCreate(Bundle savedInstanceState) { | 34 protected void onCreate(Bundle savedInstanceState) { |
34 super.onCreate(savedInstanceState); | 35 super.onCreate(savedInstanceState); |
35 | 36 |
36 // Initializing the command line must occur before loading the library. | 37 // Initializing the command line must occur before loading the library. |
37 if (!CommandLine.isInitialized()) CommandLine.initFromFile(COMMAND_LINE_
FILE); | 38 if (!CommandLine.isInitialized()) CommandLine.initFromFile(COMMAND_LINE_
FILE); |
38 waitForDebuggerIfNeeded(); | 39 waitForDebuggerIfNeeded(); |
39 | 40 |
40 LibraryLoader.loadAndInitSync(); | 41 LibraryLoader.loadAndInitSync(); |
41 initializeContentViewResources(); | 42 initializeContentViewResources(); |
42 | 43 |
43 setContentView(R.layout.content_shell_activity); | 44 setContentView(R.layout.content_shell_activity); |
44 mShellManager = (ShellManager) findViewById(R.id.shell_container); | 45 mShellManager = (ShellManager) findViewById(R.id.shell_container); |
| 46 mShellManager.setWindow(new NativeWindow(this)); |
45 | 47 |
46 String startupUrl = getUrlFromIntent(getIntent()); | 48 String startupUrl = getUrlFromIntent(getIntent()); |
47 if (!TextUtils.isEmpty(startupUrl)) { | 49 if (!TextUtils.isEmpty(startupUrl)) { |
48 mShellManager.setStartupUrl(Shell.sanitizeUrl(startupUrl)); | 50 mShellManager.setStartupUrl(Shell.sanitizeUrl(startupUrl)); |
49 } | 51 } |
50 | 52 |
51 if (!ContentView.enableMultiProcess(this, ContentView.MAX_RENDERERS_AUTO
MATIC)) { | 53 if (!ContentView.enableMultiProcess(this, ContentView.MAX_RENDERERS_AUTO
MATIC)) { |
52 String shellUrl = DEFAULT_SHELL_URL; | 54 String shellUrl = DEFAULT_SHELL_URL; |
53 if (savedInstanceState != null | 55 if (savedInstanceState != null |
54 && savedInstanceState.containsKey(ACTIVE_SHELL_URL_KEY)) { | 56 && savedInstanceState.containsKey(ACTIVE_SHELL_URL_KEY)) { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 Shell shell = getActiveShell(); | 144 Shell shell = getActiveShell(); |
143 return shell != null ? shell.getContentView() : null; | 145 return shell != null ? shell.getContentView() : null; |
144 } | 146 } |
145 | 147 |
146 private void initializeContentViewResources() { | 148 private void initializeContentViewResources() { |
147 AppResource.DIMENSION_LINK_PREVIEW_OVERLAY_RADIUS = R.dimen.link_preview
_overlay_radius; | 149 AppResource.DIMENSION_LINK_PREVIEW_OVERLAY_RADIUS = R.dimen.link_preview
_overlay_radius; |
148 AppResource.DRAWABLE_LINK_PREVIEW_POPUP_OVERLAY = R.drawable.popup_zoome
r_overlay; | 150 AppResource.DRAWABLE_LINK_PREVIEW_POPUP_OVERLAY = R.drawable.popup_zoome
r_overlay; |
149 AppResource.STRING_CONTENT_VIEW_CONTENT_DESCRIPTION = R.string.accessibi
lity_content_view; | 151 AppResource.STRING_CONTENT_VIEW_CONTENT_DESCRIPTION = R.string.accessibi
lity_content_view; |
150 } | 152 } |
151 } | 153 } |
OLD | NEW |