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.base.ChromiumActivity; | 14 import org.chromium.base.ChromiumActivity; |
15 import org.chromium.content.app.LibraryLoader; | 15 import org.chromium.content.app.LibraryLoader; |
16 import org.chromium.content.browser.ActivityContentVideoViewDelegate; | 16 import org.chromium.content.browser.ActivityContentVideoViewDelegate; |
| 17 import org.chromium.content.browser.AndroidBrowserProcessInitException; |
17 import org.chromium.content.browser.ContentVideoView; | 18 import org.chromium.content.browser.ContentVideoView; |
18 import org.chromium.content.browser.ContentView; | 19 import org.chromium.content.browser.ContentView; |
19 import org.chromium.content.browser.DeviceUtils; | 20 import org.chromium.content.browser.DeviceUtils; |
20 import org.chromium.content.common.CommandLine; | 21 import org.chromium.content.common.CommandLine; |
21 import org.chromium.ui.gfx.ActivityNativeWindow; | 22 import org.chromium.ui.gfx.ActivityNativeWindow; |
22 | 23 |
23 /** | 24 /** |
24 * Activity for managing the Content Shell. | 25 * Activity for managing the Content Shell. |
25 */ | 26 */ |
26 public class ContentShellActivity extends ChromiumActivity { | 27 public class ContentShellActivity extends ChromiumActivity { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 mActivityNativeWindow.restoreInstanceState(savedInstanceState); | 60 mActivityNativeWindow.restoreInstanceState(savedInstanceState); |
60 mShellManager.setWindow(mActivityNativeWindow); | 61 mShellManager.setWindow(mActivityNativeWindow); |
61 ContentVideoView.registerContentVideoViewContextDelegate( | 62 ContentVideoView.registerContentVideoViewContextDelegate( |
62 new ActivityContentVideoViewDelegate(this)); | 63 new ActivityContentVideoViewDelegate(this)); |
63 | 64 |
64 String startupUrl = getUrlFromIntent(getIntent()); | 65 String startupUrl = getUrlFromIntent(getIntent()); |
65 if (!TextUtils.isEmpty(startupUrl)) { | 66 if (!TextUtils.isEmpty(startupUrl)) { |
66 mShellManager.setStartupUrl(Shell.sanitizeUrl(startupUrl)); | 67 mShellManager.setStartupUrl(Shell.sanitizeUrl(startupUrl)); |
67 } | 68 } |
68 | 69 |
69 if (!ContentView.enableMultiProcess(this, ContentView.MAX_RENDERERS_AUTO
MATIC)) { | 70 try { |
70 String shellUrl = DEFAULT_SHELL_URL; | 71 if (!ContentView.enableMultiProcess(this, ContentView.MAX_RENDERERS_
AUTOMATIC)) { |
71 if (savedInstanceState != null | 72 String shellUrl = DEFAULT_SHELL_URL; |
| 73 if (savedInstanceState != null |
72 && savedInstanceState.containsKey(ACTIVE_SHELL_URL_KEY)) { | 74 && savedInstanceState.containsKey(ACTIVE_SHELL_URL_KEY)) { |
73 shellUrl = savedInstanceState.getString(ACTIVE_SHELL_URL_KEY); | 75 shellUrl = savedInstanceState.getString(ACTIVE_SHELL_URL_KEY
); |
| 76 } |
| 77 mShellManager.launchShell(shellUrl); |
74 } | 78 } |
75 mShellManager.launchShell(shellUrl); | 79 } catch (AndroidBrowserProcessInitException e) { |
| 80 Log.e(TAG, "ContentView initialization failed.", e); |
| 81 finish(); |
76 } | 82 } |
77 } | 83 } |
78 | 84 |
79 @Override | 85 @Override |
80 protected void onSaveInstanceState(Bundle outState) { | 86 protected void onSaveInstanceState(Bundle outState) { |
81 super.onSaveInstanceState(outState); | 87 super.onSaveInstanceState(outState); |
82 Shell activeShell = getActiveShell(); | 88 Shell activeShell = getActiveShell(); |
83 if (activeShell != null) { | 89 if (activeShell != null) { |
84 outState.putString(ACTIVE_SHELL_URL_KEY, activeShell.getContentView(
).getUrl()); | 90 outState.putString(ACTIVE_SHELL_URL_KEY, activeShell.getContentView(
).getUrl()); |
85 } | 91 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 176 |
171 /** | 177 /** |
172 * @return The {@link ContentView} owned by the currently visible {@link She
ll} or null if one | 178 * @return The {@link ContentView} owned by the currently visible {@link She
ll} or null if one |
173 * is not showing. | 179 * is not showing. |
174 */ | 180 */ |
175 public ContentView getActiveContentView() { | 181 public ContentView getActiveContentView() { |
176 Shell shell = getActiveShell(); | 182 Shell shell = getActiveShell(); |
177 return shell != null ? shell.getContentView() : null; | 183 return shell != null ? shell.getContentView() : null; |
178 } | 184 } |
179 } | 185 } |
OLD | NEW |