OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.chrome.browser; | 5 package org.chromium.chrome.browser; |
6 | 6 |
7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
8 import android.app.Activity; | 8 import android.app.Activity; |
9 import android.app.SearchManager; | 9 import android.app.SearchManager; |
10 import android.app.assist.AssistContent; | 10 //import android.app.assist.AssistContent; |
11 import android.content.Context; | 11 import android.content.Context; |
12 import android.content.Intent; | 12 import android.content.Intent; |
13 import android.content.SharedPreferences; | 13 import android.content.SharedPreferences; |
14 import android.content.res.Configuration; | 14 import android.content.res.Configuration; |
15 import android.graphics.Bitmap; | 15 import android.graphics.Bitmap; |
16 import android.graphics.Color; | 16 import android.graphics.Color; |
17 import android.graphics.Rect; | 17 import android.graphics.Rect; |
18 import android.net.Uri; | 18 import android.net.Uri; |
19 import android.os.AsyncTask; | 19 import android.os.AsyncTask; |
20 import android.os.Build; | 20 import android.os.Build; |
(...skipping 22 matching lines...) Expand all Loading... |
43 import org.chromium.base.BaseSwitches; | 43 import org.chromium.base.BaseSwitches; |
44 import org.chromium.base.CommandLine; | 44 import org.chromium.base.CommandLine; |
45 import org.chromium.base.Log; | 45 import org.chromium.base.Log; |
46 import org.chromium.base.SysUtils; | 46 import org.chromium.base.SysUtils; |
47 import org.chromium.base.ThreadUtils; | 47 import org.chromium.base.ThreadUtils; |
48 import org.chromium.base.TraceEvent; | 48 import org.chromium.base.TraceEvent; |
49 import org.chromium.base.VisibleForTesting; | 49 import org.chromium.base.VisibleForTesting; |
50 import org.chromium.base.metrics.RecordHistogram; | 50 import org.chromium.base.metrics.RecordHistogram; |
51 import org.chromium.base.metrics.RecordUserAction; | 51 import org.chromium.base.metrics.RecordUserAction; |
52 import org.chromium.chrome.R; | 52 import org.chromium.chrome.R; |
53 import org.chromium.chrome.browser.BookmarksBridge.BookmarkModelObserver; | 53 //import org.chromium.chrome.browser.BookmarksBridge.BookmarkModelObserver; |
54 import org.chromium.chrome.browser.IntentHandler.IntentHandlerDelegate; | 54 import org.chromium.chrome.browser.IntentHandler.IntentHandlerDelegate; |
55 import org.chromium.chrome.browser.IntentHandler.TabOpenType; | 55 import org.chromium.chrome.browser.IntentHandler.TabOpenType; |
56 import org.chromium.chrome.browser.appmenu.AppMenu; | 56 //import org.chromium.chrome.browser.appmenu.AppMenu; |
57 import org.chromium.chrome.browser.appmenu.AppMenuHandler; | 57 //import org.chromium.chrome.browser.appmenu.AppMenuHandler; |
58 import org.chromium.chrome.browser.appmenu.AppMenuObserver; | 58 //import org.chromium.chrome.browser.appmenu.AppMenuObserver; |
59 import org.chromium.chrome.browser.appmenu.AppMenuPropertiesDelegate; | 59 //import org.chromium.chrome.browser.appmenu.AppMenuPropertiesDelegate; |
60 import org.chromium.chrome.browser.appmenu.ChromeAppMenuPropertiesDelegate; | 60 //import org.chromium.chrome.browser.appmenu.ChromeAppMenuPropertiesDelegate; |
61 import org.chromium.chrome.browser.bookmark.ManageBookmarkActivity; | 61 //import org.chromium.chrome.browser.bookmark.ManageBookmarkActivity; |
62 import org.chromium.chrome.browser.compositor.CompositorViewHolder; | 62 //import org.chromium.chrome.browser.compositor.CompositorViewHolder; |
63 import org.chromium.chrome.browser.compositor.layouts.Layout; | 63 //import org.chromium.chrome.browser.compositor.layouts.Layout; |
64 import org.chromium.chrome.browser.compositor.layouts.LayoutManager; | 64 //import org.chromium.chrome.browser.compositor.layouts.LayoutManager; |
65 import org.chromium.chrome.browser.compositor.layouts.LayoutManagerDocument; | 65 //import org.chromium.chrome.browser.compositor.layouts.LayoutManagerDocument; |
66 import org.chromium.chrome.browser.compositor.layouts.SceneChangeObserver; | 66 //import org.chromium.chrome.browser.compositor.layouts.SceneChangeObserver; |
67 import org.chromium.chrome.browser.compositor.layouts.content.ContentOffsetProvi
der; | 67 //import org.chromium.chrome.browser.compositor.layouts.content.ContentOffsetPro
vider; |
68 import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; | 68 //import org.chromium.chrome.browser.compositor.layouts.content.TabContentManage
r; |
69 import org.chromium.chrome.browser.contextualsearch.ContextualSearchFieldTrial; | 69 //import org.chromium.chrome.browser.contextualsearch.ContextualSearchFieldTrial
; |
70 import org.chromium.chrome.browser.contextualsearch.ContextualSearchManager; | 70 //import org.chromium.chrome.browser.contextualsearch.ContextualSearchManager; |
71 import org.chromium.chrome.browser.contextualsearch.ContextualSearchManager.Cont
extualSearchTabPromotionDelegate; | 71 //import org.chromium.chrome.browser.contextualsearch.ContextualSearchManager.Co
ntextualSearchTabPromotionDelegate; |
72 import org.chromium.chrome.browser.customtabs.CustomTab; | 72 //import org.chromium.chrome.browser.customtabs.CustomTab; |
73 import org.chromium.chrome.browser.customtabs.CustomTabActivity; | 73 //import org.chromium.chrome.browser.customtabs.CustomTabActivity; |
74 import org.chromium.chrome.browser.device.DeviceClassManager; | 74 import org.chromium.chrome.browser.device.DeviceClassManager; |
75 import org.chromium.chrome.browser.dom_distiller.DistilledPagePrefsView; | 75 //import org.chromium.chrome.browser.dom_distiller.DistilledPagePrefsView; |
76 import org.chromium.chrome.browser.dom_distiller.ReaderModeActivityDelegate; | 76 //import org.chromium.chrome.browser.dom_distiller.ReaderModeActivityDelegate; |
77 import org.chromium.chrome.browser.dom_distiller.ReaderModeManager; | 77 //import org.chromium.chrome.browser.dom_distiller.ReaderModeManager; |
78 import org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarkUtils; | 78 //import org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarkUtils; |
79 import org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarksModel; | 79 //import org.chromium.chrome.browser.enhancedbookmarks.EnhancedBookmarksModel; |
80 import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager; | 80 //import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager; |
81 import org.chromium.chrome.browser.gsa.ContextReporter; | 81 //import org.chromium.chrome.browser.gsa.ContextReporter; |
82 import org.chromium.chrome.browser.gsa.GSAServiceClient; | 82 //import org.chromium.chrome.browser.gsa.GSAServiceClient; |
83 import org.chromium.chrome.browser.gsa.GSAState; | 83 //import org.chromium.chrome.browser.gsa.GSAState; |
84 import org.chromium.chrome.browser.help.HelpAndFeedback; | 84 //import org.chromium.chrome.browser.help.HelpAndFeedback; |
85 import org.chromium.chrome.browser.infobar.InfoBarContainer; | 85 //import org.chromium.chrome.browser.infobar.InfoBarContainer; |
86 import org.chromium.chrome.browser.init.AsyncInitializationActivity; | 86 import org.chromium.chrome.browser.init.AsyncInitializationActivity; |
87 import org.chromium.chrome.browser.metrics.LaunchMetrics; | 87 //import org.chromium.chrome.browser.metrics.LaunchMetrics; |
88 import org.chromium.chrome.browser.metrics.UmaSessionStats; | 88 //import org.chromium.chrome.browser.metrics.UmaSessionStats; |
89 import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; | 89 //import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; |
90 import org.chromium.chrome.browser.nfc.BeamController; | 90 //import org.chromium.chrome.browser.nfc.BeamController; |
91 import org.chromium.chrome.browser.nfc.BeamProvider; | 91 //import org.chromium.chrome.browser.nfc.BeamProvider; |
92 import org.chromium.chrome.browser.partnercustomizations.PartnerBrowserCustomiza
tions; | 92 //import org.chromium.chrome.browser.partnercustomizations.PartnerBrowserCustomi
zations; |
93 import org.chromium.chrome.browser.preferences.ChromePreferenceManager; | 93 //import org.chromium.chrome.browser.preferences.ChromePreferenceManager; |
94 import org.chromium.chrome.browser.preferences.PrefServiceBridge; | 94 //import org.chromium.chrome.browser.preferences.PrefServiceBridge; |
95 import org.chromium.chrome.browser.preferences.PreferencesLauncher; | 95 //import org.chromium.chrome.browser.preferences.PreferencesLauncher; |
96 import org.chromium.chrome.browser.printing.TabPrinter; | 96 //import org.chromium.chrome.browser.printing.TabPrinter; |
97 import org.chromium.chrome.browser.share.ShareHelper; | 97 //import org.chromium.chrome.browser.share.ShareHelper; |
98 import org.chromium.chrome.browser.snackbar.LoFiBarPopupController; | 98 //import org.chromium.chrome.browser.snackbar.LoFiBarPopupController; |
99 import org.chromium.chrome.browser.snackbar.SnackbarManager; | 99 //import org.chromium.chrome.browser.snackbar.SnackbarManager; |
100 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarManageable; | 100 //import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarManageable
; |
101 import org.chromium.chrome.browser.sync.ProfileSyncService; | 101 //import org.chromium.chrome.browser.sync.ProfileSyncService; |
102 import org.chromium.chrome.browser.tab.EmptyTabObserver; | 102 //import org.chromium.chrome.browser.tab.EmptyTabObserver; |
103 import org.chromium.chrome.browser.tab.Tab; | 103 //import org.chromium.chrome.browser.tab.Tab; |
104 import org.chromium.chrome.browser.tab.TabObserver; | 104 //import org.chromium.chrome.browser.tab.TabObserver; |
105 import org.chromium.chrome.browser.tabmodel.ChromeTabCreator; | 105 //import org.chromium.chrome.browser.tabmodel.ChromeTabCreator; |
106 import org.chromium.chrome.browser.tabmodel.EmptyTabModel; | 106 //import org.chromium.chrome.browser.tabmodel.EmptyTabModel; |
107 import org.chromium.chrome.browser.tabmodel.TabCreatorManager; | 107 //import org.chromium.chrome.browser.tabmodel.TabCreatorManager; |
108 import org.chromium.chrome.browser.tabmodel.TabModel; | 108 //import org.chromium.chrome.browser.tabmodel.TabModel; |
109 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; | 109 //import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; |
110 import org.chromium.chrome.browser.tabmodel.TabModelSelector; | 110 //import org.chromium.chrome.browser.tabmodel.TabModelSelector; |
111 import org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver; | 111 //import org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver; |
112 import org.chromium.chrome.browser.tabmodel.TabModelUtils; | 112 //import org.chromium.chrome.browser.tabmodel.TabModelUtils; |
113 import org.chromium.chrome.browser.tabmodel.TabWindowManager; | 113 //import org.chromium.chrome.browser.tabmodel.TabWindowManager; |
114 import org.chromium.chrome.browser.toolbar.Toolbar; | 114 //import org.chromium.chrome.browser.toolbar.Toolbar; |
115 import org.chromium.chrome.browser.toolbar.ToolbarControlContainer; | 115 //import org.chromium.chrome.browser.toolbar.ToolbarControlContainer; |
116 import org.chromium.chrome.browser.toolbar.ToolbarManager; | 116 //import org.chromium.chrome.browser.toolbar.ToolbarManager; |
117 import org.chromium.chrome.browser.util.FeatureUtilities; | 117 //import org.chromium.chrome.browser.util.FeatureUtilities; |
118 import org.chromium.chrome.browser.webapps.AddToHomescreenDialog; | 118 //import org.chromium.chrome.browser.webapps.AddToHomescreenDialog; |
119 import org.chromium.chrome.browser.widget.ControlContainer; | 119 //import org.chromium.chrome.browser.widget.ControlContainer; |
120 import org.chromium.content.browser.ContentReadbackHandler; | 120 import org.chromium.content.browser.ContentReadbackHandler; |
121 import org.chromium.content.browser.ContentReadbackHandler.GetBitmapCallback; | 121 import org.chromium.content.browser.ContentReadbackHandler.GetBitmapCallback; |
122 import org.chromium.content.browser.ContentViewCore; | 122 import org.chromium.content.browser.ContentViewCore; |
123 import org.chromium.content.common.ContentSwitches; | 123 import org.chromium.content.common.ContentSwitches; |
124 import org.chromium.content_public.browser.LoadUrlParams; | 124 import org.chromium.content_public.browser.LoadUrlParams; |
125 import org.chromium.content_public.browser.readback_types.ReadbackResponse; | 125 //import org.chromium.content_public.browser.readback_types.ReadbackResponse; |
126 import org.chromium.policy.CombinedPolicyProvider.PolicyChangeListener; | 126 import org.chromium.policy.CombinedPolicyProvider.PolicyChangeListener; |
127 import org.chromium.printing.PrintManagerDelegateImpl; | 127 import org.chromium.printing.PrintManagerDelegateImpl; |
128 import org.chromium.printing.PrintingController; | 128 import org.chromium.printing.PrintingController; |
129 import org.chromium.ui.base.ActivityWindowAndroid; | 129 import org.chromium.ui.base.ActivityWindowAndroid; |
130 import org.chromium.ui.base.PageTransition; | 130 //import org.chromium.ui.base.PageTransition; |
131 import org.chromium.ui.base.WindowAndroid; | 131 import org.chromium.ui.base.WindowAndroid; |
132 | 132 |
133 import java.util.Locale; | 133 import java.util.Locale; |
134 import java.util.concurrent.TimeUnit; | 134 import java.util.concurrent.TimeUnit; |
135 | 135 |
136 /** | 136 /** |
137 * A {@link AsyncInitializationActivity} that builds and manages a {@link Compos
itorViewHolder} | 137 * A {@link AsyncInitializationActivity} that builds and manages a {@link Compos
itorViewHolder} |
138 * and associated classes. | 138 * and associated classes. |
139 */ | 139 */ |
140 public abstract class ChromeActivity extends AsyncInitializationActivity | 140 public abstract class ChromeActivity extends AsyncInitializationActivity |
141 implements TabCreatorManager, AccessibilityStateChangeListener, PolicyCh
angeListener, | 141 implements AccessibilityStateChangeListener, PolicyChangeListener { |
142 ContextualSearchTabPromotionDelegate, SnackbarManageable, SceneChangeObs
erver { | 142 // /** |
143 /** | 143 // * Factory which creates the AppMenuHandler. |
144 * Factory which creates the AppMenuHandler. | 144 // */ |
145 */ | 145 // public interface AppMenuHandlerFactory { |
146 public interface AppMenuHandlerFactory { | 146 // /** |
147 /** | 147 // * @return AppMenuHandler for the given activity and menu resource id. |
148 * @return AppMenuHandler for the given activity and menu resource id. | 148 // */ |
149 */ | 149 // public AppMenuHandler get(Activity activity, |
150 public AppMenuHandler get(Activity activity, | 150 // AppMenuPropertiesDelegate delegate, int menuResourceId); |
151 AppMenuPropertiesDelegate delegate, int menuResourceId); | 151 // } |
152 } | |
153 | 152 |
154 /** | 153 /** |
155 * No control container to inflate during initialization. | 154 * No control container to inflate during initialization. |
156 */ | 155 */ |
157 private static final int NO_CONTROL_CONTAINER = -1; | 156 private static final int NO_CONTROL_CONTAINER = -1; |
158 | 157 |
159 /** Prevents race conditions when deleting snapshot database. */ | 158 /** Prevents race conditions when deleting snapshot database. */ |
160 private static final Object SNAPSHOT_DATABASE_LOCK = new Object(); | 159 private static final Object SNAPSHOT_DATABASE_LOCK = new Object(); |
161 private static final String SNAPSHOT_DATABASE_REMOVED = "snapshot_database_r
emoved"; | 160 private static final String SNAPSHOT_DATABASE_REMOVED = "snapshot_database_r
emoved"; |
162 private static final String SNAPSHOT_DATABASE_NAME = "snapshots.db"; | 161 private static final String SNAPSHOT_DATABASE_NAME = "snapshots.db"; |
163 | 162 |
164 /** Delay in ms after first page load finishes before we initiate deferred s
tartup actions. */ | 163 /** Delay in ms after first page load finishes before we initiate deferred s
tartup actions. */ |
165 private static final int DEFERRED_STARTUP_DELAY_MS = 1000; | 164 private static final int DEFERRED_STARTUP_DELAY_MS = 1000; |
166 | 165 |
167 /** | 166 /** |
168 * Timeout in ms for reading PartnerBrowserCustomizations provider. | 167 * Timeout in ms for reading PartnerBrowserCustomizations provider. |
169 */ | 168 */ |
170 private static final int PARTNER_BROWSER_CUSTOMIZATIONS_TIMEOUT_MS = 10000; | 169 private static final int PARTNER_BROWSER_CUSTOMIZATIONS_TIMEOUT_MS = 10000; |
171 private static final String TAG = "cr.ChromeActivity"; | 170 private static final String TAG = "cr.ChromeActivity"; |
172 | 171 |
173 private TabModelSelector mTabModelSelector; | 172 // private TabModelSelector mTabModelSelector; |
174 private TabModelSelectorTabObserver mTabModelSelectorTabObserver; | 173 // private TabModelSelectorTabObserver mTabModelSelectorTabObserver; |
175 private TabCreatorManager.TabCreator mRegularTabCreator; | 174 // private TabCreatorManager.TabCreator mRegularTabCreator; |
176 private TabCreatorManager.TabCreator mIncognitoTabCreator; | 175 // private TabCreatorManager.TabCreator mIncognitoTabCreator; |
177 private TabContentManager mTabContentManager; | 176 // private TabContentManager mTabContentManager; |
178 private UmaSessionStats mUmaSessionStats; | 177 // private UmaSessionStats mUmaSessionStats; |
179 private ContextReporter mContextReporter; | 178 // private ContextReporter mContextReporter; |
180 protected GSAServiceClient mGSAServiceClient; | 179 // protected GSAServiceClient mGSAServiceClient; |
181 | 180 |
182 private boolean mPartnerBrowserRefreshNeeded = false; | 181 private boolean mPartnerBrowserRefreshNeeded = false; |
183 | 182 |
184 protected IntentHandler mIntentHandler; | 183 protected IntentHandler mIntentHandler; |
185 | 184 |
186 /** Whether onDeferredStartup() has been run. */ | 185 /** Whether onDeferredStartup() has been run. */ |
187 private boolean mDeferredStartupNotified; | 186 private boolean mDeferredStartupNotified; |
188 | 187 |
189 // The class cannot implement TouchExplorationStateChangeListener, | 188 // The class cannot implement TouchExplorationStateChangeListener, |
190 // because it is only available for Build.VERSION_CODES.KITKAT and later. | 189 // because it is only available for Build.VERSION_CODES.KITKAT and later. |
191 // We have to instantiate the TouchExplorationStateChangeListner object in t
he code. | 190 // We have to instantiate the TouchExplorationStateChangeListner object in t
he code. |
192 @SuppressLint("NewApi") | 191 @SuppressLint("NewApi") |
193 private TouchExplorationStateChangeListener mTouchExplorationStateChangeList
ener; | 192 private TouchExplorationStateChangeListener mTouchExplorationStateChangeList
ener; |
194 | 193 |
195 // Observes when sync becomes ready to create the mContextReporter. | 194 // Observes when sync becomes ready to create the mContextReporter. |
196 private ProfileSyncService.SyncStateChangedListener mSyncStateChangedListene
r; | 195 // private ProfileSyncService.SyncStateChangedListener mSyncStateChangedListe
ner; |
197 | 196 |
198 private ActivityWindowAndroid mWindowAndroid; | 197 private ActivityWindowAndroid mWindowAndroid; |
199 private ChromeFullscreenManager mFullscreenManager; | 198 // private ChromeFullscreenManager mFullscreenManager; |
200 private CompositorViewHolder mCompositorViewHolder; | 199 // private CompositorViewHolder mCompositorViewHolder; |
201 private ContextualSearchManager mContextualSearchManager; | 200 // private ContextualSearchManager mContextualSearchManager; |
202 private ReaderModeActivityDelegate mReaderModeActivityDelegate; | 201 // private ReaderModeActivityDelegate mReaderModeActivityDelegate; |
203 private SnackbarManager mSnackbarManager; | 202 // private SnackbarManager mSnackbarManager; |
204 private LoFiBarPopupController mLoFiBarPopupController; | 203 // private LoFiBarPopupController mLoFiBarPopupController; |
205 private ChromeAppMenuPropertiesDelegate mAppMenuPropertiesDelegate; | 204 // private ChromeAppMenuPropertiesDelegate mAppMenuPropertiesDelegate; |
206 private AppMenuHandler mAppMenuHandler; | 205 // private AppMenuHandler mAppMenuHandler; |
207 private ToolbarManager mToolbarManager; | 206 // private ToolbarManager mToolbarManager; |
208 private BookmarkModelObserver mBookmarkObserver; | 207 // private BookmarkModelObserver mBookmarkObserver; |
209 | 208 |
210 // Time in ms that it took took us to inflate the initial layout | 209 // Time in ms that it took took us to inflate the initial layout |
211 private long mInflateInitialLayoutDurationMs; | 210 private long mInflateInitialLayoutDurationMs; |
212 | 211 |
213 private OnPreDrawListener mFirstDrawListener; | 212 private OnPreDrawListener mFirstDrawListener; |
214 | 213 |
215 private final Locale mCurrentLocale = Locale.getDefault(); | 214 private final Locale mCurrentLocale = Locale.getDefault(); |
216 | 215 |
217 private AssistStatusHandler mAssistStatusHandler; | 216 // private AssistStatusHandler mAssistStatusHandler; |
218 | 217 |
219 private static AppMenuHandlerFactory sAppMenuHandlerFactory = new AppMenuHan
dlerFactory() { | 218 // private static AppMenuHandlerFactory sAppMenuHandlerFactory = new AppMenuH
andlerFactory() { |
220 @Override | 219 // @Override |
221 public AppMenuHandler get( | 220 // public AppMenuHandler get( |
222 Activity activity, AppMenuPropertiesDelegate delegate, int menuR
esourceId) { | 221 // Activity activity, AppMenuPropertiesDelegate delegate, int men
uResourceId) { |
223 return new AppMenuHandler(activity, delegate, menuResourceId); | 222 // return new AppMenuHandler(activity, delegate, menuResourceId); |
224 } | 223 // } |
225 }; | 224 // }; |
226 | 225 |
227 /** | 226 // /** |
228 * @param The {@link AppMenuHandlerFactory} for creating {@link mAppMenuHand
ler} | 227 // * @param The {@link AppMenuHandlerFactory} for creating {@link mAppMenuHa
ndler} |
229 */ | 228 // */ |
230 @VisibleForTesting | 229 // @VisibleForTesting |
231 public static void setAppMenuHandlerFactoryForTesting(AppMenuHandlerFactory
factory) { | 230 // public static void setAppMenuHandlerFactoryForTesting(AppMenuHandlerFactor
y factory) { |
232 sAppMenuHandlerFactory = factory; | 231 // sAppMenuHandlerFactory = factory; |
233 } | 232 // } |
234 | 233 |
235 @Override | 234 @Override |
236 public void preInflationStartup() { | 235 public void preInflationStartup() { |
237 super.preInflationStartup(); | 236 super.preInflationStartup(); |
238 ApplicationInitialization.enableFullscreenFlags( | 237 ApplicationInitialization.enableFullscreenFlags( |
239 getResources(), this, getControlContainerHeightResource()); | 238 getResources(), this, getControlContainerHeightResource()); |
240 getWindow().setBackgroundDrawableResource(R.color.light_background_color
); | 239 getWindow().setBackgroundDrawableResource(R.color.light_background_color
); |
241 } | 240 } |
242 | 241 |
243 @SuppressLint("NewApi") | 242 @SuppressLint("NewApi") |
244 @Override | 243 @Override |
245 public void postInflationStartup() { | 244 public void postInflationStartup() { |
246 super.postInflationStartup(); | 245 super.postInflationStartup(); |
247 | 246 |
248 mWindowAndroid = ((ChromeApplication) getApplicationContext()) | 247 // mWindowAndroid = ((ChromeApplication) getApplicationContext()) |
249 .createActivityWindowAndroid(this); | 248 // .createActivityWindowAndroid(this); |
250 mWindowAndroid.restoreInstanceState(getSavedInstanceState()); | 249 // mWindowAndroid.restoreInstanceState(getSavedInstanceState()); |
251 mSnackbarManager = new SnackbarManager(getWindow()); | 250 // mSnackbarManager = new SnackbarManager(getWindow()); |
252 mLoFiBarPopupController = new LoFiBarPopupController(this, getSnackbarMa
nager()); | 251 // mLoFiBarPopupController = new LoFiBarPopupController(this, getSnackbar
Manager()); |
253 | 252 |
254 mAssistStatusHandler = createAssistStatusHandler(); | 253 // mAssistStatusHandler = createAssistStatusHandler(); |
255 if (mAssistStatusHandler != null) { | 254 // if (mAssistStatusHandler != null) { |
256 if (mTabModelSelector != null) { | 255 //// if (mTabModelSelector != null) { |
257 mAssistStatusHandler.setTabModelSelector(mTabModelSelector); | 256 //// mAssistStatusHandler.setTabModelSelector(mTabModelSelector); |
258 } | 257 //// } |
259 mAssistStatusHandler.updateAssistState(); | 258 // mAssistStatusHandler.updateAssistState(); |
260 } | 259 // } |
261 | 260 |
262 // If a user had ALLOW_LOW_END_DEVICE_UI explicitly set to false then we
manually override | 261 // If a user had ALLOW_LOW_END_DEVICE_UI explicitly set to false then we
manually override |
263 // SysUtils.isLowEndDevice() with a switch so that they continue to see
the normal UI. This | 262 // SysUtils.isLowEndDevice() with a switch so that they continue to see
the normal UI. This |
264 // is only the case for grandfathered-in svelte users. We no longer do s
o for newer users. | 263 // is only the case for grandfathered-in svelte users. We no longer do s
o for newer users. |
265 if (!ChromePreferenceManager.getInstance(this).getAllowLowEndDeviceUi())
{ | 264 // if (!ChromePreferenceManager.getInstance(this).getAllowLowEndDeviceUi(
)) { |
266 CommandLine.getInstance().appendSwitch( | 265 // CommandLine.getInstance().appendSwitch( |
267 BaseSwitches.DISABLE_LOW_END_DEVICE_MODE); | 266 // BaseSwitches.DISABLE_LOW_END_DEVICE_MODE); |
268 } | 267 // } |
269 | 268 |
270 AccessibilityManager manager = (AccessibilityManager) | 269 AccessibilityManager manager = (AccessibilityManager) |
271 getBaseContext().getSystemService(Context.ACCESSIBILITY_SERVICE)
; | 270 getBaseContext().getSystemService(Context.ACCESSIBILITY_SERVICE)
; |
272 manager.addAccessibilityStateChangeListener(this); | 271 manager.addAccessibilityStateChangeListener(this); |
273 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { | 272 // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { |
274 mTouchExplorationStateChangeListener = new TouchExplorationStateChan
geListener() { | 273 // mTouchExplorationStateChangeListener = new TouchExplorationStateCh
angeListener() { |
275 @Override | 274 // @Override |
276 public void onTouchExplorationStateChanged(boolean enabled) { | 275 // public void onTouchExplorationStateChanged(boolean enabled) { |
277 checkAccessibility(); | 276 // checkAccessibility(); |
278 } | 277 // } |
279 }; | 278 // }; |
280 manager.addTouchExplorationStateChangeListener(mTouchExplorationStat
eChangeListener); | 279 // manager.addTouchExplorationStateChangeListener(mTouchExplorationSt
ateChangeListener); |
281 } | 280 // } |
282 | 281 |
283 // Make the activity listen to policy change events | 282 // Make the activity listen to policy change events |
284 getChromeApplication().addPolicyChangeListener(this); | 283 getChromeApplication().addPolicyChangeListener(this); |
285 | 284 |
286 // Set up the animation placeholder to be the SurfaceView. This disables
the | 285 // Set up the animation placeholder to be the SurfaceView. This disables
the |
287 // SurfaceView's 'hole' clipping during animations that are notified to
the window. | 286 // SurfaceView's 'hole' clipping during animations that are notified to
the window. |
288 mWindowAndroid.setAnimationPlaceholderView(mCompositorViewHolder.getSurf
aceView()); | 287 // mWindowAndroid.setAnimationPlaceholderView(mCompositorViewHolder.getSu
rfaceView()); |
289 | 288 |
290 // Inform the WindowAndroid of the keyboard accessory view. | 289 // Inform the WindowAndroid of the keyboard accessory view. |
291 mWindowAndroid.setKeyboardAccessoryView((ViewGroup) findViewById(R.id.ke
yboard_accessory)); | 290 mWindowAndroid.setKeyboardAccessoryView((ViewGroup) findViewById(R.id.ke
yboard_accessory)); |
292 final View controlContainer = findViewById(R.id.control_container); | 291 final View controlContainer = findViewById(R.id.control_container); |
293 if (controlContainer != null) { | 292 if (controlContainer != null) { |
294 mFirstDrawListener = new ViewTreeObserver.OnPreDrawListener() { | 293 mFirstDrawListener = new ViewTreeObserver.OnPreDrawListener() { |
295 @Override | 294 @Override |
296 public boolean onPreDraw() { | 295 public boolean onPreDraw() { |
297 controlContainer.getViewTreeObserver() | 296 controlContainer.getViewTreeObserver() |
298 .removeOnPreDrawListener(mFirstDrawListener); | 297 .removeOnPreDrawListener(mFirstDrawListener); |
299 mFirstDrawListener = null; | 298 mFirstDrawListener = null; |
300 onFirstDrawComplete(); | 299 onFirstDrawComplete(); |
301 return true; | 300 return true; |
302 } | 301 } |
303 }; | 302 }; |
304 controlContainer.getViewTreeObserver().addOnPreDrawListener(mFirstDr
awListener); | 303 controlContainer.getViewTreeObserver().addOnPreDrawListener(mFirstDr
awListener); |
305 } | 304 } |
306 initializeToolbar(); | 305 // initializeToolbar(); |
307 } | 306 } |
308 | 307 |
309 /** | 308 /** |
310 * This function builds the {@link CompositorViewHolder}. Subclasses *must*
call | 309 * This function builds the {@link CompositorViewHolder}. Subclasses *must*
call |
311 * super.setContentView() before using {@link #getTabModelSelector()} or | 310 * super.setContentView() before using {@link #getTabModelSelector()} or |
312 * {@link #getCompositorViewHolder()}. | 311 * {@link #getCompositorViewHolder()}. |
313 */ | 312 */ |
314 @Override | 313 @Override |
315 protected final void setContentView() { | 314 protected final void setContentView() { |
316 final long begin = SystemClock.elapsedRealtime(); | 315 final long begin = SystemClock.elapsedRealtime(); |
317 TraceEvent.begin("onCreate->setContentView()"); | 316 TraceEvent.begin("onCreate->setContentView()"); |
318 if (WarmupManager.getInstance().hasBuiltViewHierarchy()) { | 317 // if (WarmupManager.getInstance().hasBuiltViewHierarchy()) { |
319 View placeHolderView = new View(this); | 318 // View placeHolderView = new View(this); |
320 setContentView(placeHolderView); | 319 // setContentView(placeHolderView); |
321 ViewGroup contentParent = (ViewGroup) placeHolderView.getParent(); | 320 // ViewGroup contentParent = (ViewGroup) placeHolderView.getParent(); |
322 WarmupManager.getInstance().transferViewHierarchyTo(contentParent); | 321 // WarmupManager.getInstance().transferViewHierarchyTo(contentParent)
; |
323 contentParent.removeView(placeHolderView); | 322 // contentParent.removeView(placeHolderView); |
324 } else { | 323 // } else { |
325 setContentView(R.layout.main); | 324 setContentView(R.layout.main); |
326 if (getControlContainerLayoutId() != NO_CONTROL_CONTAINER) { | 325 if (getControlContainerLayoutId() != NO_CONTROL_CONTAINER) { |
327 ViewStub toolbarContainerStub = | 326 ViewStub toolbarContainerStub = |
328 ((ViewStub) findViewById(R.id.control_container_stub)); | 327 ((ViewStub) findViewById(R.id.control_container_stub)); |
329 toolbarContainerStub.setLayoutResource(getControlContainerLayout
Id()); | 328 toolbarContainerStub.setLayoutResource(getControlContainerLayout
Id()); |
330 toolbarContainerStub.inflate(); | 329 toolbarContainerStub.inflate(); |
331 } | 330 } |
332 } | 331 // } |
333 TraceEvent.end("onCreate->setContentView()"); | 332 TraceEvent.end("onCreate->setContentView()"); |
334 mInflateInitialLayoutDurationMs = SystemClock.elapsedRealtime() - begin; | 333 mInflateInitialLayoutDurationMs = SystemClock.elapsedRealtime() - begin; |
335 | 334 |
336 // Set the status bar color to black by default. This is an optimization
for | 335 // Set the status bar color to black by default. This is an optimization
for |
337 // Chrome not to draw under status and navigation bars when we use the d
efault | 336 // Chrome not to draw under status and navigation bars when we use the d
efault |
338 // black status bar | 337 // black status bar |
339 ApiCompatibilityUtils.setStatusBarColor(getWindow(), Color.BLACK); | 338 // ApiCompatibilityUtils.setStatusBarColor(getWindow(), Color.BLACK); |
340 | 339 |
341 mCompositorViewHolder = (CompositorViewHolder) findViewById(R.id.composi
tor_view_holder); | 340 // mCompositorViewHolder = (CompositorViewHolder) findViewById(R.id.compo
sitor_view_holder); |
342 mCompositorViewHolder.setRootView(getWindow().getDecorView().getRootView
()); | 341 // mCompositorViewHolder.setRootView(getWindow().getDecorView().getRootVi
ew()); |
343 | 342 |
344 enableHardwareAcceleration(); | 343 enableHardwareAcceleration(); |
345 } | 344 } |
346 | 345 |
347 /** | 346 // /** |
348 * Constructs {@link ToolbarManager} and the handler necessary for controlli
ng the menu on the | 347 // * Constructs {@link ToolbarManager} and the handler necessary for control
ling the menu on the |
349 * {@link Toolbar}. Extending classes can override this call to avoid creati
ng the toolbar. | 348 // * {@link Toolbar}. Extending classes can override this call to avoid crea
ting the toolbar. |
350 */ | 349 // */ |
351 protected void initializeToolbar() { | 350 // protected void initializeToolbar() { |
352 final View controlContainer = findViewById(R.id.control_container); | 351 // final View controlContainer = findViewById(R.id.control_container); |
353 assert controlContainer != null; | 352 // assert controlContainer != null; |
354 ToolbarControlContainer toolbarContainer = (ToolbarControlContainer) con
trolContainer; | 353 // ToolbarControlContainer toolbarContainer = (ToolbarControlContainer) c
ontrolContainer; |
355 mAppMenuPropertiesDelegate = createAppMenuPropertiesDelegate(); | 354 // mAppMenuPropertiesDelegate = createAppMenuPropertiesDelegate(); |
356 mAppMenuHandler = sAppMenuHandlerFactory.get(this, mAppMenuPropertiesDel
egate, | 355 // mAppMenuHandler = sAppMenuHandlerFactory.get(this, mAppMenuPropertiesD
elegate, |
357 getAppMenuLayoutId()); | 356 // getAppMenuLayoutId()); |
358 mToolbarManager = new ToolbarManager(this, toolbarContainer, mAppMenuHan
dler, | 357 // mToolbarManager = new ToolbarManager(this, toolbarContainer, mAppMenuH
andler, |
359 mAppMenuPropertiesDelegate, getCompositorViewHolder().getInvalid
ator()); | 358 // mAppMenuPropertiesDelegate, getCompositorViewHolder().getInval
idator()); |
360 mAppMenuHandler.addObserver(new AppMenuObserver() { | 359 // mAppMenuHandler.addObserver(new AppMenuObserver() { |
361 @Override | 360 // @Override |
362 public void onMenuVisibilityChanged(boolean isVisible) { | 361 // public void onMenuVisibilityChanged(boolean isVisible) { |
363 if (!isVisible) { | 362 // if (!isVisible) { |
364 mAppMenuPropertiesDelegate.onMenuDismissed(); | 363 // mAppMenuPropertiesDelegate.onMenuDismissed(); |
365 } | 364 // } |
366 } | 365 // } |
367 }); | 366 // }); |
368 } | 367 // } |
369 | 368 |
370 /** | 369 /** |
371 * @return {@link ToolbarManager} that belongs to this activity. | 370 * @return {@link ToolbarManager} that belongs to this activity. |
372 */ | 371 */ |
373 protected ToolbarManager getToolbarManager() { | 372 // protected ToolbarManager getToolbarManager() { |
374 return mToolbarManager; | 373 // return mToolbarManager; |
375 } | 374 // } |
376 | 375 |
377 /** | 376 /** |
378 * @return The resource id for the menu to use in {@link AppMenu}. Default i
s R.menu.main_menu. | 377 * @return The resource id for the menu to use in {@link AppMenu}. Default i
s R.menu.main_menu. |
379 */ | 378 */ |
380 protected int getAppMenuLayoutId() { | 379 protected int getAppMenuLayoutId() { |
381 return R.menu.main_menu; | 380 return R.menu.main_menu; |
382 } | 381 } |
383 | 382 |
384 /** | 383 // /** |
385 * @return {@link ChromeAppMenuPropertiesDelegate} instance that the {@link
AppMenuHandler} | 384 // * @return {@link ChromeAppMenuPropertiesDelegate} instance that the {@lin
k AppMenuHandler} |
386 * should be using in this activity. | 385 // * should be using in this activity. |
387 */ | 386 // */ |
388 protected ChromeAppMenuPropertiesDelegate createAppMenuPropertiesDelegate()
{ | 387 // protected ChromeAppMenuPropertiesDelegate createAppMenuPropertiesDelegate(
) { |
389 return new ChromeAppMenuPropertiesDelegate(this); | 388 // return new ChromeAppMenuPropertiesDelegate(this); |
390 } | 389 // } |
391 | 390 |
392 /** | 391 /** |
393 * @return The assist handler for this activity. | 392 * @return The assist handler for this activity. |
394 */ | 393 */ |
395 protected AssistStatusHandler getAssistStatusHandler() { | 394 // protected AssistStatusHandler getAssistStatusHandler() { |
396 return mAssistStatusHandler; | 395 // return mAssistStatusHandler; |
397 } | 396 // } |
398 | 397 |
399 /** | 398 /** |
400 * @return A newly constructed assist handler for this given activity type. | 399 * @return A newly constructed assist handler for this given activity type. |
401 */ | 400 */ |
402 protected AssistStatusHandler createAssistStatusHandler() { | 401 // protected AssistStatusHandler createAssistStatusHandler() { |
403 return new AssistStatusHandler(this); | 402 // return new AssistStatusHandler(this); |
404 } | 403 // } |
405 | 404 |
406 /** | 405 /** |
407 * @return The resource id for the layout to use for {@link ControlContainer
}. 0 by default. | 406 * @return The resource id for the layout to use for {@link ControlContainer
}. 0 by default. |
408 */ | 407 */ |
409 protected int getControlContainerLayoutId() { | 408 protected int getControlContainerLayoutId() { |
410 return NO_CONTROL_CONTAINER; | 409 return NO_CONTROL_CONTAINER; |
411 } | 410 } |
412 | 411 |
413 /** | 412 /** |
414 * @return Whether contextual search is allowed for this activity or not. | 413 * @return Whether contextual search is allowed for this activity or not. |
415 */ | 414 */ |
416 protected boolean isContextualSearchAllowed() { | 415 protected boolean isContextualSearchAllowed() { |
417 return true; | 416 return true; |
418 } | 417 } |
419 | 418 |
420 @Override | 419 @Override |
421 public void initializeState() { | 420 public void initializeState() { |
422 super.initializeState(); | 421 super.initializeState(); |
423 IntentHandler.setTestIntentsEnabled( | 422 IntentHandler.setTestIntentsEnabled( |
424 CommandLine.getInstance().hasSwitch(ContentSwitches.ENABLE_TEST_
INTENTS)); | 423 CommandLine.getInstance().hasSwitch(ContentSwitches.ENABLE_TEST_
INTENTS)); |
425 mIntentHandler = new IntentHandler(createIntentHandlerDelegate(), getPac
kageName()); | 424 mIntentHandler = new IntentHandler(createIntentHandlerDelegate(), getPac
kageName()); |
426 } | 425 } |
427 | 426 |
428 @Override | 427 // @Override |
429 public void initializeCompositor() { | 428 // public void initializeCompositor() { |
430 TraceEvent.begin("ChromeActivity:CompositorInitialization"); | 429 // TraceEvent.begin("ChromeActivity:CompositorInitialization"); |
431 super.initializeCompositor(); | 430 // super.initializeCompositor(); |
432 | 431 // |
433 setTabContentManager(new TabContentManager(this, getContentOffsetProvide
r(), | 432 // setTabContentManager(new TabContentManager(this, getContentOffsetProvi
der(), |
434 DeviceClassManager.enableSnapshots())); | 433 // DeviceClassManager.enableSnapshots())); |
435 mCompositorViewHolder.onNativeLibraryReady(mWindowAndroid, getTabContent
Manager()); | 434 // mCompositorViewHolder.onNativeLibraryReady(mWindowAndroid, getTabConte
ntManager()); |
436 | 435 // |
437 if (isContextualSearchAllowed() && ContextualSearchFieldTrial.isEnabled(
)) { | 436 // if (isContextualSearchAllowed() && ContextualSearchFieldTrial.isEnable
d()) { |
438 mContextualSearchManager = new ContextualSearchManager(this, mWindow
Android, this); | 437 // mContextualSearchManager = new ContextualSearchManager(this, mWind
owAndroid, this); |
439 } | 438 // } |
440 | 439 // |
441 if (ReaderModeManager.isEnabled(this)) { | 440 // if (ReaderModeManager.isEnabled(this)) { |
442 mReaderModeActivityDelegate = new ReaderModeActivityDelegate(this); | 441 // mReaderModeActivityDelegate = new ReaderModeActivityDelegate(this)
; |
443 } | 442 // } |
444 | 443 // |
445 TraceEvent.end("ChromeActivity:CompositorInitialization"); | 444 // TraceEvent.end("ChromeActivity:CompositorInitialization"); |
446 } | 445 // } |
447 | 446 // |
448 /** | 447 // /** |
449 * Sets the {@link TabModelSelector} owned by this {@link ChromeActivity}. | 448 // * Sets the {@link TabModelSelector} owned by this {@link ChromeActivity}. |
450 * @param tabModelSelector A {@link TabModelSelector} instance. | 449 // * @param tabModelSelector A {@link TabModelSelector} instance. |
451 */ | 450 // */ |
452 protected void setTabModelSelector(TabModelSelector tabModelSelector) { | 451 // protected void setTabModelSelector(TabModelSelector tabModelSelector) { |
453 mTabModelSelector = tabModelSelector; | 452 // mTabModelSelector = tabModelSelector; |
454 | 453 // |
455 if (mTabModelSelectorTabObserver != null) mTabModelSelectorTabObserver.d
estroy(); | 454 // if (mTabModelSelectorTabObserver != null) mTabModelSelectorTabObserver
.destroy(); |
456 mTabModelSelectorTabObserver = new TabModelSelectorTabObserver(tabModelS
elector) { | 455 // mTabModelSelectorTabObserver = new TabModelSelectorTabObserver(tabMode
lSelector) { |
457 @Override | 456 // @Override |
458 public void didFirstVisuallyNonEmptyPaint(Tab tab) { | 457 // public void didFirstVisuallyNonEmptyPaint(Tab tab) { |
459 if (!tab.isNativePage() && !tab.isIncognito() | 458 // if (!tab.isNativePage() && !tab.isIncognito() |
460 && DataReductionProxySettings.getInstance().wasLoFiModeA
ctiveOnMainFrame() | 459 // && DataReductionProxySettings.getInstance().wasLoFiMod
eActiveOnMainFrame() |
461 && DataReductionProxySettings.getInstance().canUseDataRe
ductionProxy( | 460 // && DataReductionProxySettings.getInstance().canUseData
ReductionProxy( |
462 tab.getUrl())) { | 461 // tab.getUrl())) { |
463 if (tab.isHidden()) { | 462 // if (tab.isHidden()) { |
464 TabObserver tabObserver = new EmptyTabObserver() { | 463 // TabObserver tabObserver = new EmptyTabObserver() { |
465 @Override | 464 // @Override |
466 public void onShown(Tab tab) { | 465 // public void onShown(Tab tab) { |
467 mLoFiBarPopupController.showLoFiBar(tab); | 466 // mLoFiBarPopupController.showLoFiBar(tab); |
468 tab.removeObserver(this); | 467 // tab.removeObserver(this); |
469 } | 468 // } |
470 }; | 469 // }; |
471 tab.addObserver(tabObserver); | 470 // tab.addObserver(tabObserver); |
472 return; | 471 // return; |
473 } | 472 // } |
474 mLoFiBarPopupController.showLoFiBar(tab); | 473 // mLoFiBarPopupController.showLoFiBar(tab); |
475 } | 474 // } |
476 } | 475 // } |
477 | 476 // |
478 @Override | 477 // @Override |
479 public void onHidden(Tab tab) { | 478 // public void onHidden(Tab tab) { |
480 mLoFiBarPopupController.dismissLoFiBar(); | 479 // mLoFiBarPopupController.dismissLoFiBar(); |
481 } | 480 // } |
482 | 481 // |
483 @Override | 482 // @Override |
484 public void onDestroyed(Tab tab) { | 483 // public void onDestroyed(Tab tab) { |
485 mLoFiBarPopupController.dismissLoFiBar(); | 484 // mLoFiBarPopupController.dismissLoFiBar(); |
486 } | 485 // } |
487 | 486 // |
488 @Override | 487 // @Override |
489 public void onLoadStopped(Tab tab) { | 488 // public void onLoadStopped(Tab tab) { |
490 postDeferredStartupIfNeeded(); | 489 // postDeferredStartupIfNeeded(); |
491 showUpdateInfoBarIfNecessary(); | 490 // showUpdateInfoBarIfNecessary(); |
492 } | 491 // } |
493 | 492 // |
494 @Override | 493 // @Override |
495 public void onPageLoadFinished(Tab tab) { | 494 // public void onPageLoadFinished(Tab tab) { |
496 postDeferredStartupIfNeeded(); | 495 // postDeferredStartupIfNeeded(); |
497 showUpdateInfoBarIfNecessary(); | 496 // showUpdateInfoBarIfNecessary(); |
498 } | 497 // } |
499 | 498 // |
500 @Override | 499 // @Override |
501 public void onCrash(Tab tab, boolean sadTabShown) { | 500 // public void onCrash(Tab tab, boolean sadTabShown) { |
502 postDeferredStartupIfNeeded(); | 501 // postDeferredStartupIfNeeded(); |
503 } | 502 // } |
504 | 503 // |
505 @Override | 504 // @Override |
506 public void onDidChangeThemeColor(Tab tab, int color) { | 505 // public void onDidChangeThemeColor(Tab tab, int color) { |
507 if (getToolbarManager() == null) return; | 506 // if (getToolbarManager() == null) return; |
508 if (getActivityTab() != tab) return; | 507 // if (getActivityTab() != tab) return; |
509 | 508 // |
510 getToolbarManager().updatePrimaryColor(color); | 509 // getToolbarManager().updatePrimaryColor(color); |
511 | 510 // |
512 ControlContainer controlContainer = | 511 // ControlContainer controlContainer = |
513 (ControlContainer) findViewById(R.id.control_container); | 512 // (ControlContainer) findViewById(R.id.control_container
); |
514 controlContainer.getToolbarResourceAdapter().invalidate(null); | 513 // controlContainer.getToolbarResourceAdapter().invalidate(null); |
515 } | 514 // } |
516 }; | 515 // }; |
517 | 516 // |
518 if (mAssistStatusHandler != null) { | 517 // if (mAssistStatusHandler != null) { |
519 mAssistStatusHandler.setTabModelSelector(tabModelSelector); | 518 // mAssistStatusHandler.setTabModelSelector(tabModelSelector); |
520 } | 519 // } |
521 } | 520 // } |
522 | 521 |
523 @Override | 522 @Override |
524 public void onStartWithNative() { | 523 public void onStartWithNative() { |
525 super.onStartWithNative(); | 524 super.onStartWithNative(); |
526 getChromeApplication().onStartWithNative(); | 525 getChromeApplication().onStartWithNative(); |
527 Tab tab = getActivityTab(); | 526 // Tab tab = getActivityTab(); |
528 if (tab != null) tab.onActivityStart(); | 527 // if (tab != null) tab.onActivityStart(); |
529 FeatureUtilities.setDocumentModeEnabled(FeatureUtilities.isDocumentMode(
this)); | 528 // FeatureUtilities.setDocumentModeEnabled(FeatureUtilities.isDocumentMod
e(this)); |
530 WarmupManager.getInstance().clearWebContentsIfNecessary(); | 529 // WarmupManager.getInstance().clearWebContentsIfNecessary(); |
531 | 530 |
532 if (GSAState.getInstance(this).isGsaAvailable()) { | 531 // if (GSAState.getInstance(this).isGsaAvailable()) { |
533 mGSAServiceClient = new GSAServiceClient(this); | 532 // mGSAServiceClient = new GSAServiceClient(this); |
534 mGSAServiceClient.connect(); | 533 // mGSAServiceClient.connect(); |
535 createContextReporterIfNeeded(); | 534 // createContextReporterIfNeeded(); |
536 } else { | 535 // } else { |
537 ContextReporter.reportStatus(ContextReporter.STATUS_GSA_NOT_AVAILABL
E); | 536 // ContextReporter.reportStatus(ContextReporter.STATUS_GSA_NOT_AVAILA
BLE); |
538 } | 537 // } |
539 mCompositorViewHolder.resetFlags(); | 538 // mCompositorViewHolder.resetFlags(); |
540 } | 539 } |
541 | 540 |
542 private void createContextReporterIfNeeded() { | 541 // private void createContextReporterIfNeeded() { |
543 if (mContextReporter != null || getActivityTab() == null) return; | 542 // if (mContextReporter != null || getActivityTab() == null) return; |
544 | 543 // |
545 final ProfileSyncService syncService = ProfileSyncService.get(this); | 544 // final ProfileSyncService syncService = ProfileSyncService.get(this); |
546 | 545 // |
547 if (syncService.isSyncingUrlsWithKeystorePassphrase()) { | 546 // if (syncService.isSyncingUrlsWithKeystorePassphrase()) { |
548 mContextReporter = ((ChromeApplication) getApplicationContext()).cre
ateGsaHelper() | 547 // mContextReporter = ((ChromeApplication) getApplicationContext()).c
reateGsaHelper() |
549 .getContextReporter(this); | 548 // .getContextReporter(this); |
550 | 549 // |
551 if (mSyncStateChangedListener != null) { | 550 // if (mSyncStateChangedListener != null) { |
552 syncService.removeSyncStateChangedListener(mSyncStateChangedList
ener); | 551 // syncService.removeSyncStateChangedListener(mSyncStateChangedLi
stener); |
553 mSyncStateChangedListener = null; | 552 // mSyncStateChangedListener = null; |
554 } | 553 // } |
555 | 554 // |
556 return; | 555 // return; |
557 } else { | 556 // } else { |
558 ContextReporter.reportSyncStatus(syncService); | 557 // ContextReporter.reportSyncStatus(syncService); |
559 } | 558 // } |
560 | 559 // |
561 if (mSyncStateChangedListener == null) { | 560 // if (mSyncStateChangedListener == null) { |
562 mSyncStateChangedListener = new ProfileSyncService.SyncStateChangedL
istener() { | 561 // mSyncStateChangedListener = new ProfileSyncService.SyncStateChange
dListener() { |
563 @Override | 562 // @Override |
564 public void syncStateChanged() { | 563 // public void syncStateChanged() { |
565 createContextReporterIfNeeded(); | 564 // createContextReporterIfNeeded(); |
566 } | 565 // } |
567 }; | 566 // }; |
568 syncService.addSyncStateChangedListener(mSyncStateChangedListener); | 567 // syncService.addSyncStateChangedListener(mSyncStateChangedListener)
; |
569 } | 568 // } |
570 } | 569 // } |
571 | 570 |
572 @Override | 571 @Override |
573 public void onResumeWithNative() { | 572 public void onResumeWithNative() { |
574 super.onResumeWithNative(); | 573 super.onResumeWithNative(); |
575 markSessionResume(); | 574 // markSessionResume(); |
576 | 575 |
577 if (getActivityTab() != null) { | 576 // if (getActivityTab() != null) { |
578 LaunchMetrics.commitLaunchMetrics(getActivityTab().getWebContents())
; | 577 // LaunchMetrics.commitLaunchMetrics(getActivityTab().getWebContents(
)); |
579 } | 578 // } |
580 FeatureUtilities.setCustomTabVisible(isCustomTab()); | 579 // FeatureUtilities.setCustomTabVisible(isCustomTab()); |
581 } | 580 } |
582 | 581 |
583 @Override | 582 @Override |
584 public void onPauseWithNative() { | 583 public void onPauseWithNative() { |
585 markSessionEnd(); | 584 // markSessionEnd(); |
586 super.onPauseWithNative(); | 585 super.onPauseWithNative(); |
587 } | 586 } |
588 | 587 |
589 @Override | 588 // @Override |
590 public void onStopWithNative() { | 589 // public void onStopWithNative() { |
591 if (mAppMenuHandler != null) mAppMenuHandler.hideAppMenu(); | 590 // if (mAppMenuHandler != null) mAppMenuHandler.hideAppMenu(); |
592 if (mGSAServiceClient != null) { | 591 // if (mGSAServiceClient != null) { |
593 mGSAServiceClient.disconnect(); | 592 // mGSAServiceClient.disconnect(); |
594 mGSAServiceClient = null; | 593 // mGSAServiceClient = null; |
595 if (mSyncStateChangedListener != null) { | 594 // if (mSyncStateChangedListener != null) { |
596 ProfileSyncService syncService = ProfileSyncService.get(this); | 595 // ProfileSyncService syncService = ProfileSyncService.get(this); |
597 syncService.removeSyncStateChangedListener(mSyncStateChangedList
ener); | 596 // syncService.removeSyncStateChangedListener(mSyncStateChangedLi
stener); |
598 mSyncStateChangedListener = null; | 597 // mSyncStateChangedListener = null; |
599 } | 598 // } |
600 } | 599 // } |
601 super.onStopWithNative(); | 600 // super.onStopWithNative(); |
602 } | 601 // } |
603 | 602 |
604 @Override | 603 @Override |
605 public void onNewIntentWithNative(Intent intent) { | 604 public void onNewIntentWithNative(Intent intent) { |
606 super.onNewIntentWithNative(intent); | 605 super.onNewIntentWithNative(intent); |
607 if (mIntentHandler.shouldIgnoreIntent(this, intent)) return; | 606 if (mIntentHandler.shouldIgnoreIntent(this, intent)) return; |
608 | 607 |
609 mIntentHandler.onNewIntent(this, intent); | 608 mIntentHandler.onNewIntent(this, intent); |
610 } | 609 } |
611 | 610 |
612 @Override | 611 // @Override |
613 public boolean hasDoneFirstDraw() { | 612 // public boolean hasDoneFirstDraw() { |
614 return mToolbarManager != null | 613 // return mToolbarManager != null |
615 ? mToolbarManager.hasDoneFirstDraw() : super.hasDoneFirstDraw(); | 614 // ? mToolbarManager.hasDoneFirstDraw() : super.hasDoneFirstDraw(
); |
616 } | 615 // } |
617 | 616 |
618 /** | 617 // /** |
619 * @return Whether the given activity contains a {@link CustomTab}. | 618 // * @return Whether the given activity contains a {@link CustomTab}. |
620 */ | 619 // */ |
621 private boolean isCustomTab() { | 620 // private boolean isCustomTab() { |
622 return this instanceof CustomTabActivity; | 621 // return this instanceof CustomTabActivity; |
623 } | 622 // } |
624 | 623 |
625 @Override | 624 // @Override |
626 protected void onDeferredStartup() { | 625 // protected void onDeferredStartup() { |
627 super.onDeferredStartup(); | 626 // super.onDeferredStartup(); |
628 boolean crashDumpUploadingDisabled = getIntent() != null | 627 // boolean crashDumpUploadingDisabled = getIntent() != null |
629 && getIntent().hasExtra( | 628 // && getIntent().hasExtra( |
630 ChromeTabbedActivity.INTENT_EXTRA_DISABLE_CRASH_DUMP_UPL
OADING); | 629 // ChromeTabbedActivity.INTENT_EXTRA_DISABLE_CRASH_DUMP_U
PLOADING); |
631 DeferredStartupHandler.getInstance() | 630 // DeferredStartupHandler.getInstance() |
632 .onDeferredStartup(getChromeApplication(), crashDumpUploadingDis
abled); | 631 // .onDeferredStartup(getChromeApplication(), crashDumpUploadingD
isabled); |
| 632 // |
| 633 //// BeamController.registerForBeam(this, new BeamProvider() { |
| 634 //// @Override |
| 635 //// public String getTabUrlForBeam() { |
| 636 //// return null; |
| 637 ////// if (isOverlayVisible()) return null; |
| 638 ////// if (getActivityTab() == null) return null; |
| 639 ////// return getActivityTab().getUrl(); |
| 640 //// } |
| 641 //// }); |
| 642 // |
| 643 //// getChromeApplication().getUpdateInfoBarHelper().checkForUpdateOnBack
groundThread(this); |
| 644 // |
| 645 // removeSnapshotDatabase(); |
| 646 //// if (mToolbarManager != null) { |
| 647 //// String simpleName = getClass().getSimpleName(); |
| 648 //// RecordHistogram.recordTimesHistogram("MobileStartup.ToolbarInfla
tionTime." + simpleName, |
| 649 //// mInflateInitialLayoutDurationMs, TimeUnit.MILLISECONDS); |
| 650 //// mToolbarManager.onDeferredStartup(getOnCreateTimestampMs(), simp
leName); |
| 651 //// } |
| 652 // } |
633 | 653 |
634 BeamController.registerForBeam(this, new BeamProvider() { | 654 // @Override |
635 @Override | 655 // public void onStart() { |
636 public String getTabUrlForBeam() { | 656 // super.onStart(); |
637 if (isOverlayVisible()) return null; | 657 //// if (mContextReporter != null) mContextReporter.enable(); |
638 if (getActivityTab() == null) return null; | 658 // |
639 return getActivityTab().getUrl(); | 659 // if (mPartnerBrowserRefreshNeeded) { |
640 } | 660 // mPartnerBrowserRefreshNeeded = false; |
641 }); | 661 // PartnerBrowserCustomizations.initializeAsync(getApplicationContext
(), |
642 | 662 // PARTNER_BROWSER_CUSTOMIZATIONS_TIMEOUT_MS); |
643 getChromeApplication().getUpdateInfoBarHelper().checkForUpdateOnBackgrou
ndThread(this); | 663 // PartnerBrowserCustomizations.setOnInitializeAsyncFinished(new Runn
able() { |
644 | 664 // @Override |
645 removeSnapshotDatabase(); | 665 // public void run() { |
646 if (mToolbarManager != null) { | 666 // if (PartnerBrowserCustomizations.isIncognitoDisabled()) { |
647 String simpleName = getClass().getSimpleName(); | 667 // terminateIncognitoSession(); |
648 RecordHistogram.recordTimesHistogram("MobileStartup.ToolbarInflation
Time." + simpleName, | 668 // } |
649 mInflateInitialLayoutDurationMs, TimeUnit.MILLISECONDS); | 669 // } |
650 mToolbarManager.onDeferredStartup(getOnCreateTimestampMs(), simpleNa
me); | 670 // }); |
651 } | 671 // } |
652 } | 672 //// if (mCompositorViewHolder != null) mCompositorViewHolder.onStart(); |
653 | 673 // } |
654 @Override | |
655 public void onStart() { | |
656 super.onStart(); | |
657 if (mContextReporter != null) mContextReporter.enable(); | |
658 | |
659 if (mPartnerBrowserRefreshNeeded) { | |
660 mPartnerBrowserRefreshNeeded = false; | |
661 PartnerBrowserCustomizations.initializeAsync(getApplicationContext()
, | |
662 PARTNER_BROWSER_CUSTOMIZATIONS_TIMEOUT_MS); | |
663 PartnerBrowserCustomizations.setOnInitializeAsyncFinished(new Runnab
le() { | |
664 @Override | |
665 public void run() { | |
666 if (PartnerBrowserCustomizations.isIncognitoDisabled()) { | |
667 terminateIncognitoSession(); | |
668 } | |
669 } | |
670 }); | |
671 } | |
672 if (mCompositorViewHolder != null) mCompositorViewHolder.onStart(); | |
673 } | |
674 | 674 |
675 @Override | 675 @Override |
676 public void onStop() { | 676 public void onStop() { |
677 super.onStop(); | 677 super.onStop(); |
678 if (mContextReporter != null) mContextReporter.disable(); | 678 // if (mContextReporter != null) mContextReporter.disable(); |
679 | 679 |
680 // We want to refresh partner browser provider every onStart(). | 680 // We want to refresh partner browser provider every onStart(). |
681 mPartnerBrowserRefreshNeeded = true; | 681 mPartnerBrowserRefreshNeeded = true; |
682 if (mCompositorViewHolder != null) mCompositorViewHolder.onStop(); | 682 // if (mCompositorViewHolder != null) mCompositorViewHolder.onStop(); |
683 } | 683 } |
684 | 684 |
685 @Override | 685 @Override |
686 public void onPause() { | 686 public void onPause() { |
687 super.onPause(); | 687 super.onPause(); |
688 if (mSnackbarManager != null) mSnackbarManager.dismissSnackbar(false); | 688 // if (mSnackbarManager != null) mSnackbarManager.dismissSnackbar(false); |
689 } | 689 } |
690 | 690 |
691 // @TargetApi(Build.VERSION_CODES.M) TODO(sgurun) add method document once A
PI is public | 691 // // @TargetApi(Build.VERSION_CODES.M) TODO(sgurun) add method document once
API is public |
692 // crbug/512264 | 692 // // crbug/512264 |
693 // @Override | 693 // // @Override |
694 public void onProvideAssistContent(AssistContent outContent) { | 694 // public void onProvideAssistContent(AssistContent outContent) { |
695 if (getAssistStatusHandler() == null || !getAssistStatusHandler().isAssi
stSupported()) { | 695 // if (getAssistStatusHandler() == null || !getAssistStatusHandler().isAs
sistSupported()) { |
696 // No information is provided in incognito mode. | 696 // // No information is provided in incognito mode. |
697 return; | 697 // return; |
698 } | 698 // } |
699 Tab tab = getActivityTab(); | 699 // Tab tab = getActivityTab(); |
700 if (tab != null && !isInOverviewMode()) { | 700 // if (tab != null && !isInOverviewMode()) { |
701 outContent.setWebUri(Uri.parse(tab.getUrl())); | 701 // outContent.setWebUri(Uri.parse(tab.getUrl())); |
702 } | 702 // } |
703 } | 703 // } |
704 | 704 |
705 @Override | 705 @Override |
706 public long getOnCreateTimestampMs() { | 706 public long getOnCreateTimestampMs() { |
707 return super.getOnCreateTimestampMs(); | 707 return super.getOnCreateTimestampMs(); |
708 } | 708 } |
709 | 709 |
710 /** | 710 /** |
711 * This cannot be overridden in order to preserve destruction order. Overri
de | 711 * This cannot be overridden in order to preserve destruction order. Overri
de |
712 * {@link #onDestroyInternal()} instead to perform clean up tasks. | 712 * {@link #onDestroyInternal()} instead to perform clean up tasks. |
713 */ | 713 */ |
714 @SuppressLint("NewApi") | 714 @SuppressLint("NewApi") |
715 @Override | 715 @Override |
716 protected final void onDestroy() { | 716 protected final void onDestroy() { |
717 if (mReaderModeActivityDelegate != null) mReaderModeActivityDelegate.des
troy(); | 717 // if (mReaderModeActivityDelegate != null) mReaderModeActivityDelegate.d
estroy(); |
718 if (mContextualSearchManager != null) mContextualSearchManager.destroy()
; | 718 // if (mContextualSearchManager != null) mContextualSearchManager.destroy
(); |
719 if (mTabModelSelectorTabObserver != null) mTabModelSelectorTabObserver.d
estroy(); | 719 // if (mTabModelSelectorTabObserver != null) mTabModelSelectorTabObserver
.destroy(); |
720 if (mCompositorViewHolder != null) { | 720 // if (mCompositorViewHolder != null) { |
721 if (mCompositorViewHolder.getLayoutManager() != null) { | 721 // if (mCompositorViewHolder.getLayoutManager() != null) { |
722 mCompositorViewHolder.getLayoutManager().removeSceneChangeObserv
er(this); | 722 // mCompositorViewHolder.getLayoutManager().removeSceneChangeObse
rver(this); |
723 } | 723 // } |
724 mCompositorViewHolder.shutDown(); | 724 // mCompositorViewHolder.shutDown(); |
725 } | 725 // } |
726 onDestroyInternal(); | 726 // onDestroyInternal(); |
727 | 727 |
728 TabModelSelector selector = getTabModelSelector(); | 728 // TabModelSelector selector = getTabModelSelector(); |
729 if (selector != null) selector.destroy(); | 729 // if (selector != null) selector.destroy(); |
730 | 730 |
731 if (mWindowAndroid != null) mWindowAndroid.destroy(); | 731 if (mWindowAndroid != null) mWindowAndroid.destroy(); |
732 if (!Locale.getDefault().equals(mCurrentLocale)) { | 732 if (!Locale.getDefault().equals(mCurrentLocale)) { |
733 // This is a hack to relaunch renderer processes. Killing the main p
rocess also kills | 733 // This is a hack to relaunch renderer processes. Killing the main p
rocess also kills |
734 // its dependent (renderer) processes, and Android's activity manage
r service seems to | 734 // its dependent (renderer) processes, and Android's activity manage
r service seems to |
735 // still relaunch the activity even when process dies in onDestroy()
. | 735 // still relaunch the activity even when process dies in onDestroy()
. |
736 // This shouldn't be moved to ChromeActivity since it may cause a cr
ash if | 736 // This shouldn't be moved to ChromeActivity since it may cause a cr
ash if |
737 // you kill the process from EmbedContentViewActivity since Preferen
ces looks up | 737 // you kill the process from EmbedContentViewActivity since Preferen
ces looks up |
738 // ChildAccountManager#hasChildAccount() when it is not set. | 738 // ChildAccountManager#hasChildAccount() when it is not set. |
739 // TODO(changwan): Implement a more generic and safe relaunch mechan
ism such as | 739 // TODO(changwan): Implement a more generic and safe relaunch mechan
ism such as |
740 // killing dependent processes on onDestroy and launching them at on
Create(). | 740 // killing dependent processes on onDestroy and launching them at on
Create(). |
741 Log.w(TAG, "Forcefully killing process..."); | 741 Log.w(TAG, "Forcefully killing process..."); |
742 Process.killProcess(Process.myPid()); | 742 Process.killProcess(Process.myPid()); |
743 } | 743 } |
744 getChromeApplication().removePolicyChangeListener(this); | 744 getChromeApplication().removePolicyChangeListener(this); |
745 if (mTabContentManager != null) mTabContentManager.destroy(); | 745 // if (mTabContentManager != null) mTabContentManager.destroy(); |
746 if (mTabModelSelectorTabObserver != null) mTabModelSelectorTabObserver.d
estroy(); | 746 // if (mTabModelSelectorTabObserver != null) mTabModelSelectorTabObserver
.destroy(); |
747 | 747 |
748 AccessibilityManager manager = (AccessibilityManager) | 748 AccessibilityManager manager = (AccessibilityManager) |
749 getBaseContext().getSystemService(Context.ACCESSIBILITY_SERVICE)
; | 749 getBaseContext().getSystemService(Context.ACCESSIBILITY_SERVICE)
; |
750 manager.removeAccessibilityStateChangeListener(this); | 750 manager.removeAccessibilityStateChangeListener(this); |
751 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { | 751 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { |
752 manager.removeTouchExplorationStateChangeListener(mTouchExplorationS
tateChangeListener); | 752 manager.removeTouchExplorationStateChangeListener(mTouchExplorationS
tateChangeListener); |
753 } | 753 } |
754 super.onDestroy(); | 754 super.onDestroy(); |
755 } | 755 } |
756 | 756 |
757 /** | 757 /** |
758 * Override this to perform destruction tasks. Note that by the time this i
s called, the | 758 * Override this to perform destruction tasks. Note that by the time this i
s called, the |
759 * {@link CompositorViewHolder} will be destroyed, but the {@link WindowAndr
oid} and | 759 * {@link CompositorViewHolder} will be destroyed, but the {@link WindowAndr
oid} and |
760 * {@link TabModelSelector} will not. | 760 * {@link TabModelSelector} will not. |
761 * <p> | 761 * <p> |
762 * After returning from this, the {@link TabModelSelector} will be destroyed
followed | 762 * After returning from this, the {@link TabModelSelector} will be destroyed
followed |
763 * by the {@link WindowAndroid}. | 763 * by the {@link WindowAndroid}. |
764 */ | 764 */ |
765 protected void onDestroyInternal() { | 765 // protected void onDestroyInternal() { |
766 if (mToolbarManager != null) mToolbarManager.destroy(); | 766 // if (mToolbarManager != null) mToolbarManager.destroy(); |
767 } | 767 // } |
768 | 768 |
769 /** | 769 /** |
770 * This will handle passing {@link Intent} results back to the {@link Window
Android}. It will | 770 * This will handle passing {@link Intent} results back to the {@link Window
Android}. It will |
771 * return whether or not the {@link WindowAndroid} has consumed the event or
not. | 771 * return whether or not the {@link WindowAndroid} has consumed the event or
not. |
772 */ | 772 */ |
773 @Override | 773 @Override |
774 public boolean onActivityResultWithNative(int requestCode, int resultCode, I
ntent intent) { | 774 public boolean onActivityResultWithNative(int requestCode, int resultCode, I
ntent intent) { |
775 if (super.onActivityResultWithNative(requestCode, resultCode, intent)) r
eturn true; | 775 if (super.onActivityResultWithNative(requestCode, resultCode, intent)) r
eturn true; |
776 return mWindowAndroid.onActivityResult(requestCode, resultCode, intent); | 776 return mWindowAndroid.onActivityResult(requestCode, resultCode, intent); |
777 } | 777 } |
778 | 778 |
779 // @Override[ANDROID-M] | 779 // @Override[ANDROID-M] |
780 public void onRequestPermissionsResult(int requestCode, String[] permissions
, | 780 public void onRequestPermissionsResult(int requestCode, String[] permissions
, |
781 int[] grantResults) { | 781 int[] grantResults) { |
782 if (mWindowAndroid != null) { | 782 if (mWindowAndroid != null) { |
783 mWindowAndroid.onRequestPermissionsResult(requestCode, permissions,
grantResults); | 783 mWindowAndroid.onRequestPermissionsResult(requestCode, permissions,
grantResults); |
784 } | 784 } |
785 //super.onRequestPermissionsResult(requestCode, permissions, grantResult
s); | 785 //super.onRequestPermissionsResult(requestCode, permissions, grantResult
s); |
786 } | 786 } |
787 | 787 |
788 @Override | 788 @Override |
789 protected void onSaveInstanceState(Bundle outState) { | 789 protected void onSaveInstanceState(Bundle outState) { |
790 super.onSaveInstanceState(outState); | 790 super.onSaveInstanceState(outState); |
791 mWindowAndroid.saveInstanceState(outState); | 791 mWindowAndroid.saveInstanceState(outState); |
792 } | 792 } |
793 | 793 |
794 /** | 794 // /** |
795 * @return The unified manager for all snackbar related operations. | 795 // * @return The unified manager for all snackbar related operations. |
796 */ | 796 // */ |
797 @Override | 797 // @Override |
798 public SnackbarManager getSnackbarManager() { | 798 // public SnackbarManager getSnackbarManager() { |
799 return mSnackbarManager; | 799 // return mSnackbarManager; |
800 } | 800 // } |
801 | 801 |
802 /** | 802 /** |
803 * Called when the accessibility status of this device changes. This might
be triggered by | 803 * Called when the accessibility status of this device changes. This might
be triggered by |
804 * touch exploration or general accessibility status updates. It is an aggr
egate of two other | 804 * touch exploration or general accessibility status updates. It is an aggr
egate of two other |
805 * accessibility update methods. | 805 * accessibility update methods. |
806 * @see #onAccessibilityModeChanged(boolean) | 806 * @see #onAccessibilityModeChanged(boolean) |
807 * @see #onTouchExplorationStateChanged(boolean) | 807 * @see #onTouchExplorationStateChanged(boolean) |
808 * @param enabled Whether or not accessibility and touch exploration are cur
rently enabled. | 808 * @param enabled Whether or not accessibility and touch exploration are cur
rently enabled. |
809 */ | 809 */ |
810 protected void onAccessibilityModeChanged(boolean enabled) { | 810 // protected void onAccessibilityModeChanged(boolean enabled) { |
811 InfoBarContainer.setIsAllowedToAutoHide(!enabled); | 811 // InfoBarContainer.setIsAllowedToAutoHide(!enabled); |
812 if (mToolbarManager != null) mToolbarManager.onAccessibilityStatusChange
d(enabled); | 812 // if (mToolbarManager != null) mToolbarManager.onAccessibilityStatusChan
ged(enabled); |
813 } | 813 // } |
814 | 814 |
815 @Override | 815 // @Override |
816 public boolean onOptionsItemSelected(MenuItem item) { | 816 // public boolean onOptionsItemSelected(MenuItem item) { |
817 if (item != null && onMenuOrKeyboardAction(item.getItemId(), true)) { | 817 // if (item != null && onMenuOrKeyboardAction(item.getItemId(), true)) { |
818 return true; | 818 // return true; |
819 } | 819 // } |
820 return super.onOptionsItemSelected(item); | 820 // return super.onOptionsItemSelected(item); |
821 } | 821 // } |
822 | 822 |
823 /** | 823 // /** |
824 * Triggered when the share menu item is selected. | 824 // * Triggered when the share menu item is selected. |
825 * This creates and shows a share intent picker dialog or starts a share int
ent directly. | 825 // * This creates and shows a share intent picker dialog or starts a share i
ntent directly. |
826 * | 826 // * |
827 * @param currentTab The {@link Tab} a user is watching. | 827 // * @param currentTab The {@link Tab} a user is watching. |
828 * @param windowAndroid The {@link WindowAndroid} currentTab is linked to. | 828 // * @param windowAndroid The {@link WindowAndroid} currentTab is linked to. |
829 * @param shareDirectly Whether it should share directly with the activity t
hat was most | 829 // * @param shareDirectly Whether it should share directly with the activity
that was most |
830 * recently used to share. | 830 // * recently used to share. |
831 * @param isIncognito Whether currentTab is incognito. | 831 // * @param isIncognito Whether currentTab is incognito. |
832 */ | 832 // */ |
833 public void onShareMenuItemSelected(final Tab currentTab, | 833 // public void onShareMenuItemSelected(final Tab currentTab, |
834 final WindowAndroid windowAndroid, final boolean shareDirectly, bool
ean isIncognito) { | 834 // final WindowAndroid windowAndroid, final boolean shareDirectly, bo
olean isIncognito) { |
835 if (currentTab == null) return; | 835 // if (currentTab == null) return; |
836 | 836 // |
837 final Activity mainActivity = this; | 837 // final Activity mainActivity = this; |
838 ContentReadbackHandler.GetBitmapCallback bitmapCallback = | 838 // ContentReadbackHandler.GetBitmapCallback bitmapCallback = |
839 new ContentReadbackHandler.GetBitmapCallback() { | 839 // new ContentReadbackHandler.GetBitmapCallback() { |
840 @Override | 840 // @Override |
841 public void onFinishGetBitmap(Bitmap bitmap, int reponse) { | 841 // public void onFinishGetBitmap(Bitmap bitmap, int reponse)
{ |
842 ShareHelper.share(shareDirectly, mainActivity, currentTa
b.getTitle(), | 842 // ShareHelper.share(shareDirectly, mainActivity, current
Tab.getTitle(), |
843 currentTab.getUrl(), bitmap); | 843 // currentTab.getUrl(), bitmap); |
844 if (shareDirectly) { | 844 // if (shareDirectly) { |
845 RecordUserAction.record("MobileMenuDirectShare"); | 845 // RecordUserAction.record("MobileMenuDirectShare"); |
846 } else { | 846 // } else { |
847 RecordUserAction.record("MobileMenuShare"); | 847 // RecordUserAction.record("MobileMenuShare"); |
848 } | 848 // } |
849 } | 849 // } |
850 }; | 850 // }; |
851 ContentReadbackHandler readbackHandler = getContentReadbackHandler(); | 851 // ContentReadbackHandler readbackHandler = getContentReadbackHandler(); |
852 if (isIncognito || readbackHandler == null || windowAndroid == null | 852 // if (isIncognito || readbackHandler == null || windowAndroid == null |
853 || currentTab.getContentViewCore() == null) { | 853 // || currentTab.getContentViewCore() == null) { |
854 bitmapCallback.onFinishGetBitmap(null, ReadbackResponse.SURFACE_UNAV
AILABLE); | 854 // bitmapCallback.onFinishGetBitmap(null, ReadbackResponse.SURFACE_UN
AVAILABLE); |
855 } else { | 855 // } else { |
856 readbackHandler.getContentBitmapAsync(1, new Rect(), currentTab.getC
ontentViewCore(), | 856 // readbackHandler.getContentBitmapAsync(1, new Rect(), currentTab.ge
tContentViewCore(), |
857 Bitmap.Config.ARGB_8888, bitmapCallback); | 857 // Bitmap.Config.ARGB_8888, bitmapCallback); |
858 } | 858 // } |
859 } | 859 // } |
860 | 860 |
861 /** | 861 /** |
862 * @return Whether the activity is in overview mode. | 862 * @return Whether the activity is in overview mode. |
863 */ | 863 */ |
864 public boolean isInOverviewMode() { | 864 public boolean isInOverviewMode() { |
865 return false; | 865 return false; |
866 } | 866 } |
867 | 867 |
868 /** | 868 /** |
869 * @return Whether the app menu should be shown. | 869 * @return Whether the app menu should be shown. |
870 */ | 870 */ |
871 public boolean shouldShowAppMenu() { | 871 public boolean shouldShowAppMenu() { |
872 // Do not show the menu if Contextual Search Panel is opened. | 872 // // Do not show the menu if Contextual Search Panel is opened. |
873 if (mContextualSearchManager != null && mContextualSearchManager.isSearc
hPanelOpened()) { | 873 // if (mContextualSearchManager != null && mContextualSearchManager.isSea
rchPanelOpened()) { |
874 return false; | 874 // return false; |
875 } | 875 // } |
876 | 876 |
877 return true; | 877 return true; |
878 } | 878 } |
879 | 879 |
880 /** | 880 /** |
881 * Allows Activities that extend ChromeActivity to do additional hiding/show
ing of menu items. | 881 * Allows Activities that extend ChromeActivity to do additional hiding/show
ing of menu items. |
882 * @param menu Menu that is going to be shown when the menu button is presse
d. | 882 * @param menu Menu that is going to be shown when the menu button is presse
d. |
883 */ | 883 */ |
884 public void prepareMenu(Menu menu) { | 884 public void prepareMenu(Menu menu) { |
885 } | 885 } |
(...skipping 15 matching lines...) Expand all Loading... |
901 }; | 901 }; |
902 } | 902 } |
903 | 903 |
904 /** | 904 /** |
905 * @return The resource id that contains how large the top controls are. | 905 * @return The resource id that contains how large the top controls are. |
906 */ | 906 */ |
907 public int getControlContainerHeightResource() { | 907 public int getControlContainerHeightResource() { |
908 return R.dimen.control_container_height; | 908 return R.dimen.control_container_height; |
909 } | 909 } |
910 | 910 |
911 @Override | 911 // @Override |
912 public final void onAccessibilityStateChanged(boolean enabled) { | 912 // public final void onAccessibilityStateChanged(boolean enabled) { |
913 checkAccessibility(); | 913 // checkAccessibility(); |
914 } | 914 // } |
915 | 915 |
916 private void checkAccessibility() { | 916 // private void checkAccessibility() { |
917 onAccessibilityModeChanged(DeviceClassManager.isAccessibilityModeEnabled
(this)); | 917 // onAccessibilityModeChanged(DeviceClassManager.isAccessibilityModeEnabl
ed(this)); |
918 } | 918 // } |
919 | 919 |
920 /** | 920 /** |
921 * @return A casted version of {@link #getApplication()}. | 921 * @return A casted version of {@link #getApplication()}. |
922 */ | 922 */ |
923 public ChromeApplication getChromeApplication() { | 923 public ChromeApplication getChromeApplication() { |
924 return (ChromeApplication) getApplication(); | 924 return (ChromeApplication) getApplication(); |
925 } | 925 } |
926 | 926 |
927 /** | 927 /** |
928 * @return Whether the update infobar may be shown. | 928 * @return Whether the update infobar may be shown. |
929 */ | 929 */ |
930 public boolean mayShowUpdateInfoBar() { | 930 public boolean mayShowUpdateInfoBar() { |
931 return true; | 931 return true; |
932 } | 932 } |
933 | 933 |
934 /** | 934 /** |
935 * Add the specified tab to bookmarks or allows to edit the bookmark if the
specified tab is | 935 * Add the specified tab to bookmarks or allows to edit the bookmark if the
specified tab is |
936 * already bookmarked. If a new bookmark is added, a snackbar will be shown. | 936 * already bookmarked. If a new bookmark is added, a snackbar will be shown. |
937 * @param tabToBookmark The tab that needs to be bookmarked. | 937 * @param tabToBookmark The tab that needs to be bookmarked. |
938 */ | 938 */ |
939 public void addOrEditBookmark(final Tab tabToBookmark) { | 939 // public void addOrEditBookmark(final Tab tabToBookmark) { |
940 if (tabToBookmark == null || tabToBookmark.isFrozen()) { | 940 // if (tabToBookmark == null || tabToBookmark.isFrozen()) { |
941 return; | 941 // return; |
942 } | 942 // } |
943 | 943 // |
944 assert mToolbarManager.getBookmarksBridge().isEditBookmarksEnabled(); | 944 // assert mToolbarManager.getBookmarksBridge().isEditBookmarksEnabled(); |
945 | 945 // |
946 // Note the use of getUserBookmarkId() over getBookmarkId() here: Manage
d bookmarks can't be | 946 // // Note the use of getUserBookmarkId() over getBookmarkId() here: Mana
ged bookmarks can't be |
947 // edited. If the current URL is only bookmarked by managed bookmarks, t
his will return | 947 // // edited. If the current URL is only bookmarked by managed bookmarks,
this will return |
948 // INVALID_BOOKMARK_ID, so the code below will fall back on adding a new
bookmark instead. | 948 // // INVALID_BOOKMARK_ID, so the code below will fall back on adding a n
ew bookmark instead. |
949 // TODO(bauerb): This does not take partner bookmarks into account. | 949 // // TODO(bauerb): This does not take partner bookmarks into account. |
950 final long bookmarkId = tabToBookmark.getUserBookmarkId(); | 950 // final long bookmarkId = tabToBookmark.getUserBookmarkId(); |
951 | 951 // |
952 if (EnhancedBookmarkUtils.isEnhancedBookmarkEnabled(tabToBookmark.getPro
file())) { | 952 // if (EnhancedBookmarkUtils.isEnhancedBookmarkEnabled(tabToBookmark.getP
rofile())) { |
953 final EnhancedBookmarksModel bookmarkModel = new EnhancedBookmarksMo
del(); | 953 // final EnhancedBookmarksModel bookmarkModel = new EnhancedBookmarks
Model(); |
954 if (bookmarkModel.isBookmarkModelLoaded()) { | 954 // if (bookmarkModel.isBookmarkModelLoaded()) { |
955 EnhancedBookmarkUtils.addOrEditBookmark(bookmarkId, bookmarkMode
l, | 955 // EnhancedBookmarkUtils.addOrEditBookmark(bookmarkId, bookmarkMo
del, |
956 tabToBookmark, getSnackbarManager(), ChromeActivity.this
); | 956 // tabToBookmark, getSnackbarManager(), ChromeActivity.th
is); |
957 } else if (mBookmarkObserver == null) { | 957 // } else if (mBookmarkObserver == null) { |
958 mBookmarkObserver = new BookmarkModelObserver() { | 958 // mBookmarkObserver = new BookmarkModelObserver() { |
959 @Override | 959 // @Override |
960 public void bookmarkModelChanged() {} | 960 // public void bookmarkModelChanged() {} |
961 | 961 // |
962 @Override | 962 // @Override |
963 public void bookmarkModelLoaded() { | 963 // public void bookmarkModelLoaded() { |
964 EnhancedBookmarkUtils.addOrEditBookmark(bookmarkId, book
markModel, | 964 // EnhancedBookmarkUtils.addOrEditBookmark(bookmarkId, bo
okmarkModel, |
965 tabToBookmark, getSnackbarManager(), ChromeActiv
ity.this); | 965 // tabToBookmark, getSnackbarManager(), ChromeAct
ivity.this); |
966 bookmarkModel.removeObserver(this); | 966 // bookmarkModel.removeObserver(this); |
967 } | 967 // } |
968 }; | 968 // }; |
969 bookmarkModel.addObserver(mBookmarkObserver); | 969 // bookmarkModel.addObserver(mBookmarkObserver); |
970 } | 970 // } |
971 } else { | 971 // } else { |
972 Intent intent = new Intent(this, ManageBookmarkActivity.class); | 972 // Intent intent = new Intent(this, ManageBookmarkActivity.class); |
973 if (bookmarkId == ChromeBrowserProviderClient.INVALID_BOOKMARK_ID) { | 973 // if (bookmarkId == ChromeBrowserProviderClient.INVALID_BOOKMARK_ID)
{ |
974 intent.putExtra(ManageBookmarkActivity.BOOKMARK_INTENT_IS_FOLDER
, false); | 974 // intent.putExtra(ManageBookmarkActivity.BOOKMARK_INTENT_IS_FOLD
ER, false); |
975 intent.putExtra(ManageBookmarkActivity.BOOKMARK_INTENT_TITLE, | 975 // intent.putExtra(ManageBookmarkActivity.BOOKMARK_INTENT_TITLE, |
976 tabToBookmark.getTitle()); | 976 // tabToBookmark.getTitle()); |
977 intent.putExtra(ManageBookmarkActivity.BOOKMARK_INTENT_URL, tabT
oBookmark.getUrl()); | 977 // intent.putExtra(ManageBookmarkActivity.BOOKMARK_INTENT_URL, ta
bToBookmark.getUrl()); |
978 } else { | 978 // } else { |
979 intent.putExtra(ManageBookmarkActivity.BOOKMARK_INTENT_IS_FOLDER
, false); | 979 // intent.putExtra(ManageBookmarkActivity.BOOKMARK_INTENT_IS_FOLD
ER, false); |
980 intent.putExtra(ManageBookmarkActivity.BOOKMARK_INTENT_ID, bookm
arkId); | 980 // intent.putExtra(ManageBookmarkActivity.BOOKMARK_INTENT_ID, boo
kmarkId); |
981 } | 981 // } |
982 startActivity(intent); | 982 // startActivity(intent); |
983 } | 983 // } |
984 } | 984 // } |
985 | 985 |
986 /** | 986 /** |
987 * {@link TabModelSelector} no longer implements TabModel. Use getTabModelS
elector() or | 987 * {@link TabModelSelector} no longer implements TabModel. Use getTabModelS
elector() or |
988 * getCurrentTabModel() depending on your needs. | 988 * getCurrentTabModel() depending on your needs. |
989 * @return The {@link TabModelSelector}, possibly null. | 989 * @return The {@link TabModelSelector}, possibly null. |
990 */ | 990 */ |
991 public TabModelSelector getTabModelSelector() { | 991 // public TabModelSelector getTabModelSelector() { |
992 return mTabModelSelector; | 992 // return mTabModelSelector; |
993 } | 993 // } |
994 | 994 // |
995 @Override | 995 // @Override |
996 public TabCreatorManager.TabCreator getTabCreator(boolean incognito) { | 996 // public TabCreatorManager.TabCreator getTabCreator(boolean incognito) { |
997 return incognito ? mIncognitoTabCreator : mRegularTabCreator; | 997 // return incognito ? mIncognitoTabCreator : mRegularTabCreator; |
998 } | 998 // } |
999 | 999 // |
1000 /** | 1000 // /** |
1001 * Sets the {@link ChromeTabCreator}s owned by this {@link ChromeActivity}. | 1001 // * Sets the {@link ChromeTabCreator}s owned by this {@link ChromeActivity}
. |
1002 * @param regularTabCreator A {@link ChromeTabCreator} instance. | 1002 // * @param regularTabCreator A {@link ChromeTabCreator} instance. |
1003 */ | 1003 // */ |
1004 public void setTabCreators(TabCreatorManager.TabCreator regularTabCreator, | 1004 // public void setTabCreators(TabCreatorManager.TabCreator regularTabCreator, |
1005 TabCreatorManager.TabCreator incognitoTabCreator) { | 1005 // TabCreatorManager.TabCreator incognitoTabCreator) { |
1006 mRegularTabCreator = regularTabCreator; | 1006 // mRegularTabCreator = regularTabCreator; |
1007 mIncognitoTabCreator = incognitoTabCreator; | 1007 // mIncognitoTabCreator = incognitoTabCreator; |
1008 } | 1008 // } |
1009 | 1009 // |
1010 /** | 1010 // /** |
1011 * Convenience method that returns a tab creator for the currently selected
{@link TabModel}. | 1011 // * Convenience method that returns a tab creator for the currently selecte
d {@link TabModel}. |
1012 * @return A tab creator for the currently selected {@link TabModel}. | 1012 // * @return A tab creator for the currently selected {@link TabModel}. |
1013 */ | 1013 // */ |
1014 public TabCreatorManager.TabCreator getCurrentTabCreator() { | 1014 // public TabCreatorManager.TabCreator getCurrentTabCreator() { |
1015 return getTabCreator(getTabModelSelector().isIncognitoSelected()); | 1015 // return getTabCreator(getTabModelSelector().isIncognitoSelected()); |
1016 } | 1016 // } |
1017 | 1017 // |
1018 /** | 1018 // /** |
1019 * Gets the {@link TabContentManager} instance which holds snapshots of the
tabs in this model. | 1019 // * Gets the {@link TabContentManager} instance which holds snapshots of th
e tabs in this model. |
1020 * @return The thumbnail cache, possibly null. | 1020 // * @return The thumbnail cache, possibly null. |
1021 */ | 1021 // */ |
1022 public TabContentManager getTabContentManager() { | 1022 // public TabContentManager getTabContentManager() { |
1023 return mTabContentManager; | 1023 // return mTabContentManager; |
1024 } | 1024 // } |
1025 | 1025 // |
1026 /** | 1026 // /** |
1027 * Sets the {@link TabContentManager} owned by this {@link ChromeActivity}. | 1027 // * Sets the {@link TabContentManager} owned by this {@link ChromeActivity}
. |
1028 * @param tabContentManager A {@link TabContentManager} instance. | 1028 // * @param tabContentManager A {@link TabContentManager} instance. |
1029 */ | 1029 // */ |
1030 protected void setTabContentManager(TabContentManager tabContentManager) { | 1030 // protected void setTabContentManager(TabContentManager tabContentManager) { |
1031 mTabContentManager = tabContentManager; | 1031 // mTabContentManager = tabContentManager; |
1032 } | 1032 // } |
1033 | 1033 // |
1034 /** | 1034 // /** |
1035 * Gets the current (inner) TabModel. This is a convenience function for | 1035 // * Gets the current (inner) TabModel. This is a convenience function for |
1036 * getModelSelector().getCurrentModel(). It is *not* equivalent to the form
er getModel() | 1036 // * getModelSelector().getCurrentModel(). It is *not* equivalent to the fo
rmer getModel() |
1037 * @return Never null, if modelSelector or its field is uninstantiated retur
ns a | 1037 // * @return Never null, if modelSelector or its field is uninstantiated ret
urns a |
1038 * {@link EmptyTabModel} singleton | 1038 // * {@link EmptyTabModel} singleton |
1039 */ | 1039 // */ |
1040 public TabModel getCurrentTabModel() { | 1040 // public TabModel getCurrentTabModel() { |
1041 TabModelSelector modelSelector = getTabModelSelector(); | 1041 // TabModelSelector modelSelector = getTabModelSelector(); |
1042 if (modelSelector == null) return EmptyTabModel.getInstance(); | 1042 // if (modelSelector == null) return EmptyTabModel.getInstance(); |
1043 return modelSelector.getCurrentModel(); | 1043 // return modelSelector.getCurrentModel(); |
1044 } | 1044 // } |
1045 | 1045 // |
1046 /** | 1046 // /** |
1047 * Returns the tab being displayed by this ChromeActivity instance. This all
ows differentiation | 1047 // * Returns the tab being displayed by this ChromeActivity instance. This a
llows differentiation |
1048 * between ChromeActivity subclasses that swap between multiple tabs (e.g. C
hromeTabbedActivity) | 1048 // * between ChromeActivity subclasses that swap between multiple tabs (e.g.
ChromeTabbedActivity) |
1049 * and subclasses that only display one Tab (e.g. FullScreenActivity and Doc
umentActivity). | 1049 // * and subclasses that only display one Tab (e.g. FullScreenActivity and D
ocumentActivity). |
1050 * | 1050 // * |
1051 * The default implementation grabs the tab currently selected by the TabMod
el, which may be | 1051 // * The default implementation grabs the tab currently selected by the TabM
odel, which may be |
1052 * null if the Tab does not exist or the system is not initialized. | 1052 // * null if the Tab does not exist or the system is not initialized. |
1053 */ | 1053 // */ |
1054 public Tab getActivityTab() { | 1054 // public Tab getActivityTab() { |
1055 return TabModelUtils.getCurrentTab(getCurrentTabModel()); | 1055 // return TabModelUtils.getCurrentTab(getCurrentTabModel()); |
1056 } | 1056 // } |
1057 | 1057 // |
1058 /** | 1058 // /** |
1059 * @return The current ContentViewCore, or null if the tab does not exist or
is not showing a | 1059 // * @return The current ContentViewCore, or null if the tab does not exist
or is not showing a |
1060 * ContentViewCore. | 1060 // * ContentViewCore. |
1061 */ | 1061 // */ |
1062 public ContentViewCore getCurrentContentViewCore() { | 1062 // public ContentViewCore getCurrentContentViewCore() { |
1063 return TabModelUtils.getCurrentContentViewCore(getCurrentTabModel()); | 1063 // return TabModelUtils.getCurrentContentViewCore(getCurrentTabModel()); |
1064 } | 1064 // } |
1065 | 1065 |
1066 /** | 1066 /** |
1067 * @return A {@link WindowAndroid} instance. | 1067 * @return A {@link WindowAndroid} instance. |
1068 */ | 1068 */ |
1069 public WindowAndroid getWindowAndroid() { | 1069 public WindowAndroid getWindowAndroid() { |
1070 return mWindowAndroid; | 1070 return mWindowAndroid; |
1071 } | 1071 } |
1072 | 1072 |
1073 /** | 1073 /** |
1074 * @return A {@link CompositorViewHolder} instance. | 1074 * @return A {@link CompositorViewHolder} instance. |
1075 */ | 1075 */ |
1076 public CompositorViewHolder getCompositorViewHolder() { | 1076 // public CompositorViewHolder getCompositorViewHolder() { |
1077 return mCompositorViewHolder; | 1077 // return mCompositorViewHolder; |
1078 } | 1078 // } |
| 1079 // |
| 1080 // /** |
| 1081 // * Gets the full screen manager. |
| 1082 // * @return The fullscreen manager, possibly null |
| 1083 // */ |
| 1084 // public ChromeFullscreenManager getFullscreenManager() { |
| 1085 // return mFullscreenManager; |
| 1086 // } |
| 1087 // |
| 1088 // /** |
| 1089 // * @return The content offset provider, may be null. |
| 1090 // */ |
| 1091 // public ContentOffsetProvider getContentOffsetProvider() { |
| 1092 // return mCompositorViewHolder.getContentOffsetProvider(); |
| 1093 // } |
| 1094 // |
| 1095 // /** |
| 1096 // * @return The content readback handler, may be null. |
| 1097 // */ |
| 1098 // public ContentReadbackHandler getContentReadbackHandler() { |
| 1099 // return mCompositorViewHolder.getContentReadbackHandler(); |
| 1100 // } |
1079 | 1101 |
1080 /** | 1102 // /** |
1081 * Gets the full screen manager. | 1103 // * Starts asynchronously taking the compositor activity screenshot. |
1082 * @return The fullscreen manager, possibly null | 1104 // * @param getBitmapCallback The callback to call once the screenshot is ta
ken, or when failed. |
1083 */ | 1105 // */ |
1084 public ChromeFullscreenManager getFullscreenManager() { | 1106 // public void startTakingCompositorActivityScreenshot(final GetBitmapCallbac
k getBitmapCallback) { |
1085 return mFullscreenManager; | 1107 // ContentReadbackHandler readbackHandler = getContentReadbackHandler(); |
1086 } | 1108 // if (readbackHandler == null || getWindowAndroid() == null) { |
1087 | 1109 // ThreadUtils.postOnUiThread(new Runnable() { |
1088 /** | 1110 // @Override |
1089 * @return The content offset provider, may be null. | 1111 // public void run() { |
1090 */ | 1112 // getBitmapCallback.onFinishGetBitmap(null, ReadbackResponse
.SURFACE_UNAVAILABLE); |
1091 public ContentOffsetProvider getContentOffsetProvider() { | 1113 // } |
1092 return mCompositorViewHolder.getContentOffsetProvider(); | 1114 // }); |
1093 } | 1115 // } else { |
1094 | 1116 // readbackHandler.getCompositorBitmapAsync(getWindowAndroid(), getBi
tmapCallback); |
1095 /** | 1117 // } |
1096 * @return The content readback handler, may be null. | 1118 // } |
1097 */ | 1119 // |
1098 public ContentReadbackHandler getContentReadbackHandler() { | 1120 // /** |
1099 return mCompositorViewHolder.getContentReadbackHandler(); | 1121 // * @return The {@code ContextualSearchManager} or {@code null} if none; |
1100 } | 1122 // */ |
1101 | 1123 // public ContextualSearchManager getContextualSearchManager() { |
1102 /** | 1124 // return mContextualSearchManager; |
1103 * Starts asynchronously taking the compositor activity screenshot. | 1125 // } |
1104 * @param getBitmapCallback The callback to call once the screenshot is take
n, or when failed. | 1126 // |
1105 */ | 1127 // /** |
1106 public void startTakingCompositorActivityScreenshot(final GetBitmapCallback
getBitmapCallback) { | 1128 // * @return A {@link ReaderModeActivityDelegate} instance or {@code null} i
f reader mode is |
1107 ContentReadbackHandler readbackHandler = getContentReadbackHandler(); | 1129 // * not enabled. |
1108 if (readbackHandler == null || getWindowAndroid() == null) { | 1130 // */ |
1109 ThreadUtils.postOnUiThread(new Runnable() { | 1131 // public ReaderModeActivityDelegate getReaderModeActivityDelegate() { |
1110 @Override | 1132 // return mReaderModeActivityDelegate; |
1111 public void run() { | 1133 // } |
1112 getBitmapCallback.onFinishGetBitmap(null, ReadbackResponse.S
URFACE_UNAVAILABLE); | 1134 // |
1113 } | 1135 // /** |
1114 }); | 1136 // * Create a full-screen manager to be used by this activity. |
1115 } else { | 1137 // * @param controlContainer The control container that will be controlled b
y the full-screen |
1116 readbackHandler.getCompositorBitmapAsync(getWindowAndroid(), getBitm
apCallback); | 1138 // * manager. |
1117 } | 1139 // * @return A {@link ChromeFullscreenManager} instance that's been created. |
1118 } | 1140 // */ |
1119 | 1141 // protected ChromeFullscreenManager createFullscreenManager(View controlCont
ainer) { |
1120 /** | 1142 // return new ChromeFullscreenManager(this, controlContainer, getTabModel
Selector(), |
1121 * @return The {@code ContextualSearchManager} or {@code null} if none; | 1143 // getControlContainerHeightResource(), true); |
1122 */ | 1144 // } |
1123 public ContextualSearchManager getContextualSearchManager() { | 1145 // |
1124 return mContextualSearchManager; | 1146 // /** |
1125 } | 1147 // * Initializes the {@link CompositorViewHolder} with the relevant content
it needs to properly |
1126 | 1148 // * show content on the screen. |
1127 /** | 1149 // * @param layoutManager A {@link LayoutManagerDocument} instan
ce. This class is |
1128 * @return A {@link ReaderModeActivityDelegate} instance or {@code null} if
reader mode is | 1150 // * responsible for driving all high level
screen content and |
1129 * not enabled. | 1151 // * determines which {@link Layout} is sho
wn when. |
1130 */ | 1152 // * @param urlBar The {@link View} representing the URL
bar (must be |
1131 public ReaderModeActivityDelegate getReaderModeActivityDelegate() { | 1153 // * focusable) or {@code null} if none exi
sts. |
1132 return mReaderModeActivityDelegate; | 1154 // * @param contentContainer A {@link ViewGroup} that can have cont
ent attached by |
1133 } | 1155 // * {@link Layout}s. |
1134 | 1156 // * @param controlContainer A {@link ControlContainer} instance to
draw. |
1135 /** | 1157 // */ |
1136 * Create a full-screen manager to be used by this activity. | 1158 // protected void initializeCompositorContent( |
1137 * @param controlContainer The control container that will be controlled by
the full-screen | 1159 // LayoutManagerDocument layoutManager, View urlBar, ViewGroup conten
tContainer, |
1138 * manager. | 1160 // ControlContainer controlContainer) { |
1139 * @return A {@link ChromeFullscreenManager} instance that's been created. | 1161 // CommandLine commandLine = CommandLine.getInstance(); |
1140 */ | 1162 // boolean enableFullscreen = !commandLine.hasSwitch(ChromeSwitches.DISAB
LE_FULLSCREEN); |
1141 protected ChromeFullscreenManager createFullscreenManager(View controlContai
ner) { | 1163 // |
1142 return new ChromeFullscreenManager(this, controlContainer, getTabModelSe
lector(), | 1164 // if (enableFullscreen && controlContainer != null) { |
1143 getControlContainerHeightResource(), true); | 1165 // mFullscreenManager = createFullscreenManager((View) controlContain
er); |
1144 } | 1166 // } |
1145 | 1167 // |
1146 /** | 1168 // if (mContextualSearchManager != null) { |
1147 * Initializes the {@link CompositorViewHolder} with the relevant content it
needs to properly | 1169 // mContextualSearchManager.initialize(contentContainer); |
1148 * show content on the screen. | 1170 // mContextualSearchManager.setSearchContentViewDelegate(layoutManage
r); |
1149 * @param layoutManager A {@link LayoutManagerDocument} instance
. This class is | 1171 // } |
1150 * responsible for driving all high level s
creen content and | 1172 // |
1151 * determines which {@link Layout} is shown
when. | 1173 // if (mReaderModeActivityDelegate != null) { |
1152 * @param urlBar The {@link View} representing the URL ba
r (must be | 1174 // mReaderModeActivityDelegate.initialize(contentContainer); |
1153 * focusable) or {@code null} if none exist
s. | 1175 // mReaderModeActivityDelegate.setDynamicResourceLoader( |
1154 * @param contentContainer A {@link ViewGroup} that can have conten
t attached by | 1176 // mCompositorViewHolder.getDynamicResourceLoader()); |
1155 * {@link Layout}s. | 1177 // } |
1156 * @param controlContainer A {@link ControlContainer} instance to d
raw. | 1178 // |
1157 */ | 1179 // layoutManager.addSceneChangeObserver(this); |
1158 protected void initializeCompositorContent( | 1180 // mCompositorViewHolder.setLayoutManager(layoutManager); |
1159 LayoutManagerDocument layoutManager, View urlBar, ViewGroup contentC
ontainer, | 1181 // mCompositorViewHolder.setFocusable(false); |
1160 ControlContainer controlContainer) { | 1182 // mCompositorViewHolder.setControlContainer(controlContainer); |
1161 CommandLine commandLine = CommandLine.getInstance(); | 1183 // mCompositorViewHolder.setFullscreenHandler(mFullscreenManager); |
1162 boolean enableFullscreen = !commandLine.hasSwitch(ChromeSwitches.DISABLE
_FULLSCREEN); | 1184 // mCompositorViewHolder.setUrlBar(urlBar); |
1163 | 1185 // mCompositorViewHolder.onFinishNativeInitialization(getTabModelSelector
(), this, |
1164 if (enableFullscreen && controlContainer != null) { | 1186 // getTabContentManager(), contentContainer, mContextualSearchMan
ager); |
1165 mFullscreenManager = createFullscreenManager((View) controlContainer
); | 1187 // |
1166 } | 1188 // if (controlContainer != null |
1167 | 1189 // && DeviceClassManager.enableToolbarSwipe(FeatureUtilities.isDo
cumentMode(this))) { |
1168 if (mContextualSearchManager != null) { | 1190 // controlContainer.setSwipeHandler( |
1169 mContextualSearchManager.initialize(contentContainer); | 1191 // getCompositorViewHolder().getLayoutManager().getTopSwipeHa
ndler()); |
1170 mContextualSearchManager.setSearchContentViewDelegate(layoutManager)
; | 1192 // } |
1171 } | 1193 // } |
1172 | |
1173 if (mReaderModeActivityDelegate != null) { | |
1174 mReaderModeActivityDelegate.initialize(contentContainer); | |
1175 mReaderModeActivityDelegate.setDynamicResourceLoader( | |
1176 mCompositorViewHolder.getDynamicResourceLoader()); | |
1177 } | |
1178 | |
1179 layoutManager.addSceneChangeObserver(this); | |
1180 mCompositorViewHolder.setLayoutManager(layoutManager); | |
1181 mCompositorViewHolder.setFocusable(false); | |
1182 mCompositorViewHolder.setControlContainer(controlContainer); | |
1183 mCompositorViewHolder.setFullscreenHandler(mFullscreenManager); | |
1184 mCompositorViewHolder.setUrlBar(urlBar); | |
1185 mCompositorViewHolder.onFinishNativeInitialization(getTabModelSelector()
, this, | |
1186 getTabContentManager(), contentContainer, mContextualSearchManag
er); | |
1187 | |
1188 if (controlContainer != null | |
1189 && DeviceClassManager.enableToolbarSwipe(FeatureUtilities.isDocu
mentMode(this))) { | |
1190 controlContainer.setSwipeHandler( | |
1191 getCompositorViewHolder().getLayoutManager().getTopSwipeHand
ler()); | |
1192 } | |
1193 } | |
1194 | 1194 |
1195 /** | 1195 /** |
1196 * Called when the back button is pressed. | 1196 * Called when the back button is pressed. |
1197 * @return Whether or not the back button was handled. | 1197 * @return Whether or not the back button was handled. |
1198 */ | 1198 */ |
1199 protected abstract boolean handleBackPressed(); | 1199 protected abstract boolean handleBackPressed(); |
1200 | 1200 |
1201 @Override | 1201 // @Override |
1202 public void onOrientationChange(int orientation) { | 1202 // public void onOrientationChange(int orientation) { |
1203 if (mContextualSearchManager != null) mContextualSearchManager.onOrienta
tionChange(); | 1203 //// if (mContextualSearchManager != null) mContextualSearchManager.onOri
entationChange(); |
1204 if (mToolbarManager != null) mToolbarManager.onOrientationChange(); | 1204 // if (mToolbarManager != null) mToolbarManager.onOrientationChange(); |
1205 } | 1205 // } |
1206 | 1206 |
1207 @Override | 1207 // @Override |
1208 public void onConfigurationChanged(Configuration newConfig) { | 1208 // public void onConfigurationChanged(Configuration newConfig) { |
1209 if (mAppMenuHandler != null) mAppMenuHandler.hideAppMenu(); | 1209 //// if (mAppMenuHandler != null) mAppMenuHandler.hideAppMenu(); |
1210 super.onConfigurationChanged(newConfig); | 1210 // super.onConfigurationChanged(newConfig); |
1211 } | 1211 // } |
1212 | 1212 |
1213 @Override | 1213 // @Override |
1214 public final void onBackPressed() { | 1214 // public final void onBackPressed() { |
1215 if (mCompositorViewHolder != null) { | 1215 // if (mCompositorViewHolder != null) { |
1216 LayoutManager layoutManager = mCompositorViewHolder.getLayoutManager
(); | 1216 // LayoutManager layoutManager = mCompositorViewHolder.getLayoutManag
er(); |
1217 boolean layoutConsumed = layoutManager != null && layoutManager.onBa
ckPressed(); | 1217 // boolean layoutConsumed = layoutManager != null && layoutManager.on
BackPressed(); |
1218 if (layoutConsumed || mContextualSearchManager != null | 1218 // if (layoutConsumed || mContextualSearchManager != null |
1219 && mContextualSearchManager.onBackPressed()) { | 1219 // && mContextualSearchManager.onBackPressed()) { |
1220 RecordUserAction.record("SystemBack"); | 1220 // RecordUserAction.record("SystemBack"); |
1221 return; | 1221 // return; |
1222 } | 1222 // } |
1223 } | 1223 // } |
1224 if (!isSelectActionBarShowing() && handleBackPressed()) { | 1224 // if (!isSelectActionBarShowing() && handleBackPressed()) { |
1225 return; | 1225 // return; |
1226 } | 1226 // } |
1227 // This will close the select action bar if it is showing, otherwise clo
se the activity. | 1227 // // This will close the select action bar if it is showing, otherwise c
lose the activity. |
1228 super.onBackPressed(); | 1228 // super.onBackPressed(); |
1229 } | 1229 // } |
1230 | 1230 // |
1231 private boolean isSelectActionBarShowing() { | 1231 // private boolean isSelectActionBarShowing() { |
1232 Tab tab = getActivityTab(); | 1232 // Tab tab = getActivityTab(); |
1233 if (tab == null) return false; | 1233 // if (tab == null) return false; |
1234 ContentViewCore contentViewCore = tab.getContentViewCore(); | 1234 // ContentViewCore contentViewCore = tab.getContentViewCore(); |
1235 if (contentViewCore == null) return false; | 1235 // if (contentViewCore == null) return false; |
1236 return contentViewCore.isSelectActionBarShowing(); | 1236 // return contentViewCore.isSelectActionBarShowing(); |
1237 } | 1237 // } |
1238 | 1238 /* |
| 1239 // removed because we dont need to implement ContextualSearchTabPromotionDelega
te |
1239 @Override | 1240 @Override |
1240 public boolean createContextualSearchTab(ContentViewCore searchContentViewCo
re) { | 1241 public boolean createContextualSearchTab(ContentViewCore searchContentViewCo
re) { |
1241 Tab currentTab = getActivityTab(); | 1242 Tab currentTab = getActivityTab(); |
1242 if (currentTab == null) return false; | 1243 if (currentTab == null) return false; |
1243 | 1244 |
1244 TabCreator tabCreator = getTabCreator(currentTab.isIncognito()); | 1245 TabCreator tabCreator = getTabCreator(currentTab.isIncognito()); |
1245 if (tabCreator == null) return false; | 1246 if (tabCreator == null) return false; |
1246 | 1247 |
1247 tabCreator.createTabWithWebContents(searchContentViewCore.getWebContents
(), | 1248 tabCreator.createTabWithWebContents(searchContentViewCore.getWebContents
(), |
1248 currentTab.getId(), TabLaunchType.FROM_LONGPRESS_FOREGROUND); | 1249 currentTab.getId(), TabLaunchType.FROM_LONGPRESS_FOREGROUND); |
1249 return true; | 1250 return true; |
1250 } | 1251 } |
| 1252 */ |
1251 | 1253 |
1252 /** | 1254 // /** |
1253 * @return The {@link AppMenuHandler} associated with this activity. | 1255 // * @return The {@link AppMenuHandler} associated with this activity. |
1254 */ | 1256 // */ |
1255 @VisibleForTesting | 1257 // @VisibleForTesting |
1256 public AppMenuHandler getAppMenuHandler() { | 1258 // public AppMenuHandler getAppMenuHandler() { |
1257 return mAppMenuHandler; | 1259 // return mAppMenuHandler; |
1258 } | 1260 // } |
1259 | 1261 // |
1260 /** | 1262 // /** |
1261 * @return The {@link AppMenuPropertiesDelegate} associated with this activi
ty. | 1263 // * @return The {@link AppMenuPropertiesDelegate} associated with this acti
vity. |
1262 */ | 1264 // */ |
1263 @VisibleForTesting | 1265 // @VisibleForTesting |
1264 public ChromeAppMenuPropertiesDelegate getAppMenuPropertiesDelegate() { | 1266 // public ChromeAppMenuPropertiesDelegate getAppMenuPropertiesDelegate() { |
1265 return mAppMenuPropertiesDelegate; | 1267 // return mAppMenuPropertiesDelegate; |
1266 } | 1268 // } |
1267 | 1269 |
1268 /** | 1270 /** |
1269 * Handles menu item selection and keyboard shortcuts. | 1271 * Handles menu item selection and keyboard shortcuts. |
1270 * | 1272 * |
1271 * @param id The ID of the selected menu item (defined in main_menu.xml) or | 1273 * @param id The ID of the selected menu item (defined in main_menu.xml) or |
1272 * keyboard shortcut (defined in values.xml). | 1274 * keyboard shortcut (defined in values.xml). |
1273 * @param fromMenu Whether this was triggered from the menu. | 1275 * @param fromMenu Whether this was triggered from the menu. |
1274 * @return Whether the action was handled. | 1276 * @return Whether the action was handled. |
1275 */ | 1277 */ |
1276 public boolean onMenuOrKeyboardAction(int id, boolean fromMenu) { | 1278 // public boolean onMenuOrKeyboardAction(int id, boolean fromMenu) { |
1277 if (id == R.id.preferences_id) { | 1279 // if (id == R.id.preferences_id) { |
1278 PreferencesLauncher.launchSettingsPage(this, null); | 1280 // PreferencesLauncher.launchSettingsPage(this, null); |
1279 RecordUserAction.record("MobileMenuSettings"); | 1281 // RecordUserAction.record("MobileMenuSettings"); |
1280 } | 1282 // } |
| 1283 // |
| 1284 // // All the code below assumes currentTab is not null, so return early
if it is null. |
| 1285 // final Tab currentTab = getActivityTab(); |
| 1286 // if (currentTab == null) { |
| 1287 // return false; |
| 1288 // } else if (id == R.id.forward_menu_id) { |
| 1289 // if (currentTab.canGoForward()) { |
| 1290 // currentTab.goForward(); |
| 1291 // RecordUserAction.record("MobileMenuForward"); |
| 1292 // RecordUserAction.record("MobileTabClobbered"); |
| 1293 // } |
| 1294 // } else if (id == R.id.bookmark_this_page_id) { |
| 1295 // addOrEditBookmark(currentTab); |
| 1296 // RecordUserAction.record("MobileMenuAddToBookmarks"); |
| 1297 // } else if (id == R.id.reload_menu_id) { |
| 1298 // if (currentTab.isLoading()) { |
| 1299 // currentTab.stopLoading(); |
| 1300 // } else { |
| 1301 // currentTab.reload(); |
| 1302 // RecordUserAction.record("MobileToolbarReload"); |
| 1303 // } |
| 1304 // } else if (id == R.id.info_menu_id) { |
| 1305 // WebsiteSettingsPopup.show(this, currentTab.getProfile(), currentTa
b.getWebContents()); |
| 1306 // } else if (id == R.id.open_history_menu_id) { |
| 1307 // currentTab.loadUrl( |
| 1308 // new LoadUrlParams(UrlConstants.HISTORY_URL, PageTransition
.AUTO_TOPLEVEL)); |
| 1309 // RecordUserAction.record("MobileMenuHistory"); |
| 1310 // } else if (id == R.id.share_menu_id || id == R.id.direct_share_menu_id
) { |
| 1311 // onShareMenuItemSelected(currentTab, getWindowAndroid(), |
| 1312 // id == R.id.direct_share_menu_id, getCurrentTabModel().isIn
cognito()); |
| 1313 // } else if (id == R.id.print_id) { |
| 1314 // PrintingController printingController = getChromeApplication().get
PrintingController(); |
| 1315 // if (printingController != null && !printingController.isBusy() |
| 1316 // && PrefServiceBridge.getInstance().isPrintingEnabled()) { |
| 1317 // printingController.startPrint(new TabPrinter(currentTab), |
| 1318 // new PrintManagerDelegateImpl(this)); |
| 1319 // RecordUserAction.record("MobileMenuPrint"); |
| 1320 // } |
| 1321 // } else if (id == R.id.add_to_homescreen_id) { |
| 1322 // AddToHomescreenDialog.show(this, currentTab); |
| 1323 // RecordUserAction.record("MobileMenuAddToHomescreen"); |
| 1324 // } else if (id == R.id.request_desktop_site_id) { |
| 1325 // final boolean reloadOnChange = !currentTab.isNativePage(); |
| 1326 // final boolean usingDesktopUserAgent = currentTab.getUseDesktopUser
Agent(); |
| 1327 // currentTab.setUseDesktopUserAgent(!usingDesktopUserAgent, reloadOn
Change); |
| 1328 // RecordUserAction.record("MobileMenuRequestDesktopSite"); |
| 1329 // } else if (id == R.id.reader_mode_prefs_id) { |
| 1330 // if (currentTab.getWebContents() != null) { |
| 1331 // RecordUserAction.record("DomDistiller_DistilledPagePrefsOpened
"); |
| 1332 // AlertDialog.Builder builder = |
| 1333 // new AlertDialog.Builder(this, R.style.AlertDialogTheme
); |
| 1334 // builder.setView(DistilledPagePrefsView.create(this)); |
| 1335 // builder.show(); |
| 1336 // } |
| 1337 // } else if (id == R.id.help_id) { |
| 1338 // // Since reading back the compositor is asynchronous, we need to d
o the readback |
| 1339 // // before starting the GoogleHelp. |
| 1340 // String helpContextId = HelpAndFeedback.getHelpContextIdFromUrl( |
| 1341 // this, currentTab.getUrl(), getCurrentTabModel().isIncognit
o()); |
| 1342 // HelpAndFeedback.getInstance(this) |
| 1343 // .show(this, helpContextId, currentTab.getProfile(), curren
tTab.getUrl()); |
| 1344 // RecordUserAction.record("MobileMenuFeedback"); |
| 1345 // } else { |
| 1346 // return false; |
| 1347 // } |
| 1348 // return true; |
| 1349 // } |
1281 | 1350 |
1282 // All the code below assumes currentTab is not null, so return early if
it is null. | 1351 // private void markSessionResume() { |
1283 final Tab currentTab = getActivityTab(); | 1352 // // Start new session for UMA. |
1284 if (currentTab == null) { | 1353 // if (mUmaSessionStats == null) { |
1285 return false; | 1354 // mUmaSessionStats = new UmaSessionStats(this); |
1286 } else if (id == R.id.forward_menu_id) { | 1355 // } |
1287 if (currentTab.canGoForward()) { | 1356 // |
1288 currentTab.goForward(); | 1357 // mUmaSessionStats.updateMetricsServiceState(); |
1289 RecordUserAction.record("MobileMenuForward"); | 1358 // // In DocumentMode we need the application-level TabModelSelector inst
ead of per |
1290 RecordUserAction.record("MobileTabClobbered"); | 1359 // // activity which only manages a single tab. |
1291 } | 1360 // if (FeatureUtilities.isDocumentMode(this)) { |
1292 } else if (id == R.id.bookmark_this_page_id) { | 1361 // mUmaSessionStats.startNewSession( |
1293 addOrEditBookmark(currentTab); | 1362 // ChromeApplication.getDocumentTabModelSelector()); |
1294 RecordUserAction.record("MobileMenuAddToBookmarks"); | 1363 // } else { |
1295 } else if (id == R.id.reload_menu_id) { | 1364 // mUmaSessionStats.startNewSession(getTabModelSelector()); |
1296 if (currentTab.isLoading()) { | 1365 // } |
1297 currentTab.stopLoading(); | 1366 // } |
1298 } else { | 1367 // |
1299 currentTab.reload(); | 1368 // /** |
1300 RecordUserAction.record("MobileToolbarReload"); | 1369 // * Mark that the UMA session has ended. |
1301 } | 1370 // */ |
1302 } else if (id == R.id.info_menu_id) { | 1371 // private void markSessionEnd() { |
1303 WebsiteSettingsPopup.show(this, currentTab.getProfile(), currentTab.
getWebContents()); | 1372 // if (mUmaSessionStats == null) { |
1304 } else if (id == R.id.open_history_menu_id) { | 1373 // // If you hit this assert, please update crbug.com/172653 on how y
ou got there. |
1305 currentTab.loadUrl( | 1374 // assert false; |
1306 new LoadUrlParams(UrlConstants.HISTORY_URL, PageTransition.A
UTO_TOPLEVEL)); | 1375 // return; |
1307 RecordUserAction.record("MobileMenuHistory"); | 1376 // } |
1308 } else if (id == R.id.share_menu_id || id == R.id.direct_share_menu_id)
{ | 1377 // // Record session metrics. |
1309 onShareMenuItemSelected(currentTab, getWindowAndroid(), | 1378 // mUmaSessionStats.logMultiWindowStats(windowArea(), displayArea(), |
1310 id == R.id.direct_share_menu_id, getCurrentTabModel().isInco
gnito()); | 1379 // TabWindowManager.getInstance().getNumberOfAssignedTabModelSele
ctors()); |
1311 } else if (id == R.id.print_id) { | 1380 // mUmaSessionStats.logAndEndSession(); |
1312 PrintingController printingController = getChromeApplication().getPr
intingController(); | 1381 // } |
1313 if (printingController != null && !printingController.isBusy() | |
1314 && PrefServiceBridge.getInstance().isPrintingEnabled()) { | |
1315 printingController.startPrint(new TabPrinter(currentTab), | |
1316 new PrintManagerDelegateImpl(this)); | |
1317 RecordUserAction.record("MobileMenuPrint"); | |
1318 } | |
1319 } else if (id == R.id.add_to_homescreen_id) { | |
1320 AddToHomescreenDialog.show(this, currentTab); | |
1321 RecordUserAction.record("MobileMenuAddToHomescreen"); | |
1322 } else if (id == R.id.request_desktop_site_id) { | |
1323 final boolean reloadOnChange = !currentTab.isNativePage(); | |
1324 final boolean usingDesktopUserAgent = currentTab.getUseDesktopUserAg
ent(); | |
1325 currentTab.setUseDesktopUserAgent(!usingDesktopUserAgent, reloadOnCh
ange); | |
1326 RecordUserAction.record("MobileMenuRequestDesktopSite"); | |
1327 } else if (id == R.id.reader_mode_prefs_id) { | |
1328 if (currentTab.getWebContents() != null) { | |
1329 RecordUserAction.record("DomDistiller_DistilledPagePrefsOpened")
; | |
1330 AlertDialog.Builder builder = | |
1331 new AlertDialog.Builder(this, R.style.AlertDialogTheme); | |
1332 builder.setView(DistilledPagePrefsView.create(this)); | |
1333 builder.show(); | |
1334 } | |
1335 } else if (id == R.id.help_id) { | |
1336 // Since reading back the compositor is asynchronous, we need to do
the readback | |
1337 // before starting the GoogleHelp. | |
1338 String helpContextId = HelpAndFeedback.getHelpContextIdFromUrl( | |
1339 this, currentTab.getUrl(), getCurrentTabModel().isIncognito(
)); | |
1340 HelpAndFeedback.getInstance(this) | |
1341 .show(this, helpContextId, currentTab.getProfile(), currentT
ab.getUrl()); | |
1342 RecordUserAction.record("MobileMenuFeedback"); | |
1343 } else { | |
1344 return false; | |
1345 } | |
1346 return true; | |
1347 } | |
1348 | |
1349 private void markSessionResume() { | |
1350 // Start new session for UMA. | |
1351 if (mUmaSessionStats == null) { | |
1352 mUmaSessionStats = new UmaSessionStats(this); | |
1353 } | |
1354 | |
1355 mUmaSessionStats.updateMetricsServiceState(); | |
1356 // In DocumentMode we need the application-level TabModelSelector instea
d of per | |
1357 // activity which only manages a single tab. | |
1358 if (FeatureUtilities.isDocumentMode(this)) { | |
1359 mUmaSessionStats.startNewSession( | |
1360 ChromeApplication.getDocumentTabModelSelector()); | |
1361 } else { | |
1362 mUmaSessionStats.startNewSession(getTabModelSelector()); | |
1363 } | |
1364 } | |
1365 | |
1366 /** | |
1367 * Mark that the UMA session has ended. | |
1368 */ | |
1369 private void markSessionEnd() { | |
1370 if (mUmaSessionStats == null) { | |
1371 // If you hit this assert, please update crbug.com/172653 on how you
got there. | |
1372 assert false; | |
1373 return; | |
1374 } | |
1375 // Record session metrics. | |
1376 mUmaSessionStats.logMultiWindowStats(windowArea(), displayArea(), | |
1377 TabWindowManager.getInstance().getNumberOfAssignedTabModelSelect
ors()); | |
1378 mUmaSessionStats.logAndEndSession(); | |
1379 } | |
1380 | 1382 |
1381 private int windowArea() { | 1383 private int windowArea() { |
1382 Window window = getWindow(); | 1384 Window window = getWindow(); |
1383 if (window != null) { | 1385 if (window != null) { |
1384 View view = window.getDecorView(); | 1386 View view = window.getDecorView(); |
1385 return view.getWidth() * view.getHeight(); | 1387 return view.getWidth() * view.getHeight(); |
1386 } | 1388 } |
1387 return -1; | 1389 return -1; |
1388 } | 1390 } |
1389 | 1391 |
(...skipping 20 matching lines...) Expand all Loading... |
1410 onDeferredStartup(); | 1412 onDeferredStartup(); |
1411 return false; // Remove this idle handler. | 1413 return false; // Remove this idle handler. |
1412 } | 1414 } |
1413 }); | 1415 }); |
1414 } | 1416 } |
1415 } | 1417 } |
1416 }, DEFERRED_STARTUP_DELAY_MS); | 1418 }, DEFERRED_STARTUP_DELAY_MS); |
1417 } | 1419 } |
1418 } | 1420 } |
1419 | 1421 |
1420 private void showUpdateInfoBarIfNecessary() { | 1422 // private void showUpdateInfoBarIfNecessary() { |
1421 getChromeApplication().getUpdateInfoBarHelper().showUpdateInfobarIfNeces
sary(this); | 1423 // getChromeApplication().getUpdateInfoBarHelper().showUpdateInfobarIfNec
essary(this); |
1422 } | 1424 // } |
1423 | 1425 |
1424 /** | 1426 /** |
1425 * Determines whether the ContentView is currently visible and not hidden by
an overlay | 1427 * Determines whether the ContentView is currently visible and not hidden by
an overlay |
1426 * @return true if the ContentView is fully hidden by another view (i.e. the
tab stack) | 1428 * @return true if the ContentView is fully hidden by another view (i.e. the
tab stack) |
1427 */ | 1429 */ |
1428 public boolean isOverlayVisible() { | 1430 public boolean isOverlayVisible() { |
1429 return false; | 1431 return false; |
1430 } | 1432 } |
1431 | 1433 |
1432 /** | 1434 /** |
(...skipping 14 matching lines...) Expand all Loading... |
1447 } | 1449 } |
1448 } | 1450 } |
1449 return null; | 1451 return null; |
1450 } | 1452 } |
1451 }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); | 1453 }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); |
1452 } | 1454 } |
1453 | 1455 |
1454 @Override | 1456 @Override |
1455 public void terminateIncognitoSession() {} | 1457 public void terminateIncognitoSession() {} |
1456 | 1458 |
1457 @Override | 1459 // @Override |
1458 public void onTabSelectionHinted(int tabId) { } | 1460 //// public void onTabSelectionHinted(int tabId) { } |
1459 | 1461 // |
1460 @Override | 1462 // @Override |
1461 public void onSceneChange(Layout layout) { } | 1463 // public void onSceneChange(Layout layout) { } |
1462 | 1464 |
1463 private void enableHardwareAcceleration() { | 1465 private void enableHardwareAcceleration() { |
1464 // HW acceleration is disabled in the manifest. Enable it only on high-e
nd devices. | 1466 // HW acceleration is disabled in the manifest. Enable it only on high-e
nd devices. |
1465 if (!SysUtils.isLowEndDevice()) { | 1467 if (!SysUtils.isLowEndDevice()) { |
1466 getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELE
RATED); | 1468 getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELE
RATED); |
1467 } | 1469 } |
1468 } | 1470 } |
1469 } | 1471 } |
OLD | NEW |