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; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 protected void onNewIntent(Intent intent) { | 92 protected void onNewIntent(Intent intent) { |
93 String url = getUrlFromIntent(intent); | 93 String url = getUrlFromIntent(intent); |
94 if (!TextUtils.isEmpty(url)) { | 94 if (!TextUtils.isEmpty(url)) { |
95 Shell activeView = getActiveShell(); | 95 Shell activeView = getActiveShell(); |
96 if (activeView != null) { | 96 if (activeView != null) { |
97 activeView.loadUrl(url); | 97 activeView.loadUrl(url); |
98 } | 98 } |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
| 102 @Override |
| 103 protected void onPause() { |
| 104 ContentView view = getActiveContentView(); |
| 105 if (view != null) view.onActivityPause(); |
| 106 |
| 107 super.onPause(); |
| 108 } |
| 109 |
| 110 @Override |
| 111 protected void onResume() { |
| 112 super.onResume(); |
| 113 |
| 114 ContentView view = getActiveContentView(); |
| 115 if (view != null) view.onActivityResume(); |
| 116 } |
| 117 |
102 private static String getUrlFromIntent(Intent intent) { | 118 private static String getUrlFromIntent(Intent intent) { |
103 return intent != null ? intent.getDataString() : null; | 119 return intent != null ? intent.getDataString() : null; |
104 } | 120 } |
105 | 121 |
106 /** | 122 /** |
107 * @return The {@link ShellManager} configured for the activity or null if i
t has not been | 123 * @return The {@link ShellManager} configured for the activity or null if i
t has not been |
108 * created yet. | 124 * created yet. |
109 */ | 125 */ |
110 public ShellManager getShellManager() { | 126 public ShellManager getShellManager() { |
111 return mShellManager; | 127 return mShellManager; |
112 } | 128 } |
113 | 129 |
114 /** | 130 /** |
115 * @return The currently visible {@link Shell} or null if one is not showing
. | 131 * @return The currently visible {@link Shell} or null if one is not showing
. |
116 */ | 132 */ |
117 public Shell getActiveShell() { | 133 public Shell getActiveShell() { |
118 return mShellManager != null ? mShellManager.getActiveShell() : null; | 134 return mShellManager != null ? mShellManager.getActiveShell() : null; |
119 } | 135 } |
120 | 136 |
| 137 /** |
| 138 * @return The {@link ContentView} owned by the currently visible {@link She
ll} or null if one |
| 139 * is not showing. |
| 140 */ |
| 141 public ContentView getActiveContentView() { |
| 142 Shell shell = getActiveShell(); |
| 143 return shell != null ? shell.getContentView() : null; |
| 144 } |
| 145 |
121 private void initializeContentViewResources() { | 146 private void initializeContentViewResources() { |
122 AppResource.DIMENSION_LINK_PREVIEW_OVERLAY_RADIUS = R.dimen.link_preview
_overlay_radius; | 147 AppResource.DIMENSION_LINK_PREVIEW_OVERLAY_RADIUS = R.dimen.link_preview
_overlay_radius; |
123 AppResource.DRAWABLE_LINK_PREVIEW_POPUP_OVERLAY = R.drawable.popup_zoome
r_overlay; | 148 AppResource.DRAWABLE_LINK_PREVIEW_POPUP_OVERLAY = R.drawable.popup_zoome
r_overlay; |
124 } | 149 } |
125 } | 150 } |
OLD | NEW |