Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/AppHooks.java

Issue 2697933002: Remove factory methods from ChromeApplication. (Closed)
Patch Set: Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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.app.Activity;
8 import android.app.Notification; 7 import android.app.Notification;
9 import android.content.Context;
10 import android.content.Intent; 8 import android.content.Intent;
11 import android.content.SharedPreferences;
12 import android.os.Handler; 9 import android.os.Handler;
13 import android.os.Looper; 10 import android.os.Looper;
14 import android.os.SystemClock;
15 import android.util.Log;
16 11
17 import org.chromium.base.ActivityState;
18 import org.chromium.base.ApplicationStatus;
19 import org.chromium.base.CommandLineInitUtil;
20 import org.chromium.base.ContextUtils; 12 import org.chromium.base.ContextUtils;
21 import org.chromium.base.ThreadUtils;
22 import org.chromium.base.TraceEvent;
23 import org.chromium.base.annotations.CalledByNative;
24 import org.chromium.base.annotations.MainDex;
25 import org.chromium.base.annotations.SuppressFBWarnings;
26 import org.chromium.base.library_loader.ProcessInitException;
27 import org.chromium.chrome.browser.banners.AppDetailsDelegate; 13 import org.chromium.chrome.browser.banners.AppDetailsDelegate;
28 import org.chromium.chrome.browser.customtabs.CustomTabsConnection; 14 import org.chromium.chrome.browser.customtabs.CustomTabsConnection;
29 import org.chromium.chrome.browser.datausage.ExternalDataUseObserver; 15 import org.chromium.chrome.browser.datausage.ExternalDataUseObserver;
30 import org.chromium.chrome.browser.document.DocumentActivity;
31 import org.chromium.chrome.browser.document.IncognitoDocumentActivity;
32 import org.chromium.chrome.browser.externalauth.ExternalAuthUtils; 16 import org.chromium.chrome.browser.externalauth.ExternalAuthUtils;
33 import org.chromium.chrome.browser.feedback.EmptyFeedbackReporter; 17 import org.chromium.chrome.browser.feedback.EmptyFeedbackReporter;
34 import org.chromium.chrome.browser.feedback.FeedbackReporter; 18 import org.chromium.chrome.browser.feedback.FeedbackReporter;
35 import org.chromium.chrome.browser.gsa.GSAHelper; 19 import org.chromium.chrome.browser.gsa.GSAHelper;
36 import org.chromium.chrome.browser.help.HelpAndFeedback; 20 import org.chromium.chrome.browser.help.HelpAndFeedback;
37 import org.chromium.chrome.browser.historyreport.AppIndexingReporter; 21 import org.chromium.chrome.browser.historyreport.AppIndexingReporter;
38 import org.chromium.chrome.browser.init.InvalidStartupDialog; 22 import org.chromium.chrome.browser.init.ProcessInitializationHandler;
39 import org.chromium.chrome.browser.instantapps.InstantAppsHandler; 23 import org.chromium.chrome.browser.instantapps.InstantAppsHandler;
40 import org.chromium.chrome.browser.locale.LocaleManager; 24 import org.chromium.chrome.browser.locale.LocaleManager;
41 import org.chromium.chrome.browser.media.VideoPersister; 25 import org.chromium.chrome.browser.media.VideoPersister;
42 import org.chromium.chrome.browser.metrics.UmaUtils;
43 import org.chromium.chrome.browser.metrics.VariationsSession; 26 import org.chromium.chrome.browser.metrics.VariationsSession;
44 import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; 27 import org.chromium.chrome.browser.multiwindow.MultiWindowUtils;
45 import org.chromium.chrome.browser.net.qualityprovider.ExternalEstimateProviderA ndroid; 28 import org.chromium.chrome.browser.net.qualityprovider.ExternalEstimateProviderA ndroid;
46 import org.chromium.chrome.browser.omaha.RequestGenerator; 29 import org.chromium.chrome.browser.omaha.RequestGenerator;
47 import org.chromium.chrome.browser.partnercustomizations.PartnerBrowserCustomiza tions;
48 import org.chromium.chrome.browser.physicalweb.PhysicalWebBleClient; 30 import org.chromium.chrome.browser.physicalweb.PhysicalWebBleClient;
49 import org.chromium.chrome.browser.policy.PolicyAuditor; 31 import org.chromium.chrome.browser.policy.PolicyAuditor;
50 import org.chromium.chrome.browser.preferences.LocationSettings; 32 import org.chromium.chrome.browser.preferences.LocationSettings;
51 import org.chromium.chrome.browser.preferences.PreferencesLauncher;
52 import org.chromium.chrome.browser.preferences.autofill.AutofillAndPaymentsPrefe rences;
53 import org.chromium.chrome.browser.preferences.password.SavePasswordsPreferences ;
54 import org.chromium.chrome.browser.rlz.RevenueStats; 33 import org.chromium.chrome.browser.rlz.RevenueStats;
55 import org.chromium.chrome.browser.services.AndroidEduOwnerCheckCallback; 34 import org.chromium.chrome.browser.services.AndroidEduOwnerCheckCallback;
56 import org.chromium.chrome.browser.signin.GoogleActivityController; 35 import org.chromium.chrome.browser.signin.GoogleActivityController;
57 import org.chromium.chrome.browser.sync.GmsCoreSyncListener; 36 import org.chromium.chrome.browser.sync.GmsCoreSyncListener;
58 import org.chromium.chrome.browser.tab.AuthenticatorNavigationInterceptor; 37 import org.chromium.chrome.browser.tab.AuthenticatorNavigationInterceptor;
59 import org.chromium.chrome.browser.tab.Tab; 38 import org.chromium.chrome.browser.tab.Tab;
60 import org.chromium.chrome.browser.tabmodel.document.ActivityDelegateImpl;
61 import org.chromium.chrome.browser.tabmodel.document.DocumentTabModelSelector;
62 import org.chromium.chrome.browser.tabmodel.document.StorageDelegate;
63 import org.chromium.chrome.browser.tabmodel.document.TabDelegate;
64 import org.chromium.chrome.browser.webapps.ChromeShortcutManager; 39 import org.chromium.chrome.browser.webapps.ChromeShortcutManager;
65 import org.chromium.chrome.browser.webapps.GooglePlayWebApkInstallDelegate; 40 import org.chromium.chrome.browser.webapps.GooglePlayWebApkInstallDelegate;
66 import org.chromium.components.signin.AccountManagerDelegate; 41 import org.chromium.components.signin.AccountManagerDelegate;
67 import org.chromium.components.signin.SystemAccountManagerDelegate; 42 import org.chromium.components.signin.SystemAccountManagerDelegate;
68 import org.chromium.content.app.ContentApplication;
69 import org.chromium.policy.AppRestrictionsProvider; 43 import org.chromium.policy.AppRestrictionsProvider;
70 import org.chromium.policy.CombinedPolicyProvider; 44 import org.chromium.policy.CombinedPolicyProvider;
71 45
72 /** 46 /**
73 * Basic application functionality that should be shared among all browser appli cations that use 47 * Base class for defining methods where different behavior is required by downs tream targets.
74 * chrome layer. 48 * The correct version of {@link AppHooksImpl} will be determined at compile tim e via build rules.
49 * See http://crbug/560466.
75 */ 50 */
76 @MainDex 51 public abstract class AppHooks {
77 public class ChromeApplication extends ContentApplication { 52 private static AppHooksImpl sInstance;
78 public static final String COMMAND_LINE_FILE = "chrome-command-line";
79 53
80 private static final String TAG = "ChromiumApplication"; 54 public static AppHooks get() {
81 private static final String PREF_BOOT_TIMESTAMP = 55 if (sInstance == null) {
82 "com.google.android.apps.chrome.ChromeMobileApplication.BOOT_TIMESTA MP"; 56 sInstance = new AppHooksImpl();
83 private static final long BOOT_TIMESTAMP_MARGIN_MS = 1000; 57 }
84 58 return sInstance;
85 private static DocumentTabModelSelector sDocumentTabModelSelector;
86
87 @Override
88 protected void attachBaseContext(Context base) {
89 super.attachBaseContext(base);
90 ContextUtils.initApplicationContext(this);
91 } 59 }
92 60
93 /** 61 /**
94 * This is called once per ChromeApplication instance, which get created per process
95 * (browser OR renderer). Don't stick anything in here that shouldn't be ca lled multiple times
96 * during Chrome's lifetime.
97 */
98 @Override
99 public void onCreate() {
100 UmaUtils.recordMainEntryPointTime();
101 initCommandLine();
102 TraceEvent.maybeEnableEarlyTracing();
103 TraceEvent.begin("ChromeApplication.onCreate");
104
105 super.onCreate();
106
107 TraceEvent.end("ChromeApplication.onCreate");
108 }
109
110 /**
111 * Returns a new instance of VariationsSession.
112 */
113 public VariationsSession createVariationsSession() {
114 return new VariationsSession();
115 }
116
117 /**
118 * Return a {@link AuthenticatorNavigationInterceptor} for the given {@link Tab}.
119 * This can be null if there are no applicable interceptor to be built.
120 */
121 @SuppressWarnings("unused")
122 public AuthenticatorNavigationInterceptor createAuthenticatorNavigationInter ceptor(Tab tab) {
123 return null;
124 }
125
126 /**
127 * Initiate AndroidEdu device check. 62 * Initiate AndroidEdu device check.
128 * @param callback Callback that should receive the results of the AndroidEd u device check. 63 * @param callback Callback that should receive the results of the AndroidEd u device check.
129 */ 64 */
130 public void checkIsAndroidEduDevice(final AndroidEduOwnerCheckCallback callb ack) { 65 public void checkIsAndroidEduDevice(final AndroidEduOwnerCheckCallback callb ack) {
131 new Handler(Looper.getMainLooper()).post(new Runnable() { 66 new Handler(Looper.getMainLooper()).post(new Runnable() {
132 @Override 67 @Override
133 public void run() { 68 public void run() {
134 callback.onSchoolCheckDone(false); 69 callback.onSchoolCheckDone(false);
135 } 70 }
136 }); 71 });
137 } 72 }
138 73
139 @CalledByNative 74 /**
140 protected void showAutofillSettings() { 75 * Creates a new {@link AccountManagerDelegate}.
141 PreferencesLauncher.launchSettingsPage( 76 * @return the created {@link AccountManagerDelegate}.
142 this, AutofillAndPaymentsPreferences.class.getName()); 77 */
143 } 78 public AccountManagerDelegate createAccountManagerDelegate() {
144 79 return new SystemAccountManagerDelegate(ContextUtils.getApplicationConte xt());
145 @CalledByNative
146 protected void showPasswordSettings() {
147 PreferencesLauncher.launchSettingsPage(this,
148 SavePasswordsPreferences.class.getName());
149 }
150
151 @Override
152 public void initCommandLine() {
153 CommandLineInitUtil.initCommandLine(this, COMMAND_LINE_FILE);
154 } 80 }
155 81
156 /** 82 /**
157 * Shows an error dialog following a startup error, and then exits the appli cation. 83 * @return An instance of AppDetailsDelegate that can be queried about app i nformation for the
158 * @param e The exception reported by Chrome initialization. 84 * App Banner feature. Will be null if one is unavailable.
159 */ 85 */
160 public static void reportStartupErrorAndExit(final ProcessInitException e) { 86 public AppDetailsDelegate createAppDetailsDelegate() {
161 Activity activity = ApplicationStatus.getLastTrackedFocusedActivity(); 87 return null;
162 if (ApplicationStatus.getStateForActivity(activity) == ActivityState.DES TROYED) {
163 return;
164 }
165 InvalidStartupDialog.show(activity, e.getErrorCode());
166 } 88 }
167 89
168 /** 90 /**
169 * Returns an instance of LocationSettings to be installed as a singleton. 91 * Creates a new {@link AppIndexingReporter}.
92 * @return the created {@link AppIndexingReporter}.
170 */ 93 */
171 public LocationSettings createLocationSettings() { 94 public AppIndexingReporter createAppIndexingReporter() {
172 // Using an anonymous subclass as the constructor is protected. 95 return new AppIndexingReporter();
173 // This is done to deter instantiation of LocationSettings elsewhere wit hout using the
174 // getInstance() helper method.
175 return new LocationSettings(){};
176 } 96 }
177 97
178 /** 98 /**
179 * Opens the UI to clear browsing data. 99 * Return a {@link AuthenticatorNavigationInterceptor} for the given {@link Tab}.
180 * @param tab The tab that triggered the request. 100 * This can be null if there are no applicable interceptor to be built.
181 */ 101 */
182 @CalledByNative 102 public AuthenticatorNavigationInterceptor createAuthenticatorNavigationInter ceptor(Tab tab) {
183 protected void openClearBrowsingData(Tab tab) { 103 return null;
184 Activity activity = tab.getWindowAndroid().getActivity().get(); 104 }
185 if (activity == null) {
186 Log.e(TAG,
187 "Attempting to open clear browsing data for a tab without a valid activity");
188 return;
189 }
190 105
191 Intent intent = PreferencesLauncher.createIntentForClearBrowsingDataPage (activity); 106 /** Returns the singleton instance of ChromeShortcutManager */
192 activity.startActivity(intent); 107 public ChromeShortcutManager createChromeShortcutManager() {
108 return new ChromeShortcutManager();
193 } 109 }
194 110
195 /** 111 /**
196 * @return Whether parental controls are enabled. Returning true will disab le 112 * @return An instance of {@link CustomTabsConnection}. Should not be called
197 * incognito mode. 113 * outside of {@link CustomTabsConnection#getInstance()}.
198 */ 114 */
199 @CalledByNative 115 public CustomTabsConnection createCustomTabsConnection() {
200 protected boolean areParentalControlsEnabled() { 116 return new CustomTabsConnection(((ChromeApplication) ContextUtils.getApp licationContext()));
201 return PartnerBrowserCustomizations.isIncognitoDisabled();
202 } 117 }
203 118
204 /** 119 /**
205 * @return A provider of external estimates. 120 * @return An instance of ExternalAuthUtils to be installed as a singleton.
206 * @param nativePtr Pointer to the native ExternalEstimateProviderAndroid ob ject.
207 */ 121 */
208 public ExternalEstimateProviderAndroid createExternalEstimateProviderAndroid (long nativePtr) { 122 public ExternalAuthUtils createExternalAuthUtils() {
209 return new ExternalEstimateProviderAndroid(nativePtr) {}; 123 return new ExternalAuthUtils();
210 } 124 }
211 125
212 /** 126 /**
213 * @return An external observer of data use. 127 * @return An external observer of data use.
214 * @param nativePtr Pointer to the native ExternalDataUseObserver object. 128 * @param nativePtr Pointer to the native ExternalDataUseObserver object.
215 */ 129 */
216 public ExternalDataUseObserver createExternalDataUseObserver(long nativePtr) { 130 public ExternalDataUseObserver createExternalDataUseObserver(long nativePtr) {
217 return new ExternalDataUseObserver(nativePtr); 131 return new ExternalDataUseObserver(nativePtr);
218 } 132 }
219 133
220 /** 134 /**
221 * @return The user agent string of Chrome. 135 * @return A provider of external estimates.
136 * @param nativePtr Pointer to the native ExternalEstimateProviderAndroid ob ject.
222 */ 137 */
223 public static String getBrowserUserAgent() { 138 public ExternalEstimateProviderAndroid createExternalEstimateProviderAndroid (long nativePtr) {
224 return nativeGetBrowserUserAgent(); 139 return new ExternalEstimateProviderAndroid(nativePtr) {};
225 } 140 }
226 141
227 /** 142 /**
228 * The host activity should call this during its onPause() handler to ensure
229 * all state is saved when the app is suspended. Calling ChromiumApplicatio n.onStop() does
230 * this for you.
231 */
232 public static void flushPersistentData() {
233 try {
234 TraceEvent.begin("ChromiumApplication.flushPersistentData");
235 nativeFlushPersistentData();
236 } finally {
237 TraceEvent.end("ChromiumApplication.flushPersistentData");
238 }
239 }
240
241 /**
242 * Removes all session cookies (cookies with no expiration date) after devic e reboots.
243 * This function will incorrectly clear cookies when Daylight Savings Time c hanges the clock.
244 * Without a way to get a monotonically increasing system clock, the boot ti mestamp will be off
245 * by one hour. However, this should only happen at most once when the cloc k changes since the
246 * updated timestamp is immediately saved.
247 */
248 public static void removeSessionCookies() {
249 long lastKnownBootTimestamp =
250 ContextUtils.getAppSharedPreferences().getLong(PREF_BOOT_TIMESTA MP, 0);
251 long bootTimestamp = System.currentTimeMillis() - SystemClock.uptimeMill is();
252 long difference = bootTimestamp - lastKnownBootTimestamp;
253
254 // Allow some leeway to account for fractions of milliseconds.
255 if (Math.abs(difference) > BOOT_TIMESTAMP_MARGIN_MS) {
256 nativeRemoveSessionCookies();
257
258 SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
259 SharedPreferences.Editor editor = prefs.edit();
260 editor.putLong(PREF_BOOT_TIMESTAMP, bootTimestamp);
261 editor.apply();
262 }
263 }
264
265 private static native void nativeRemoveSessionCookies();
266 private static native String nativeGetBrowserUserAgent();
267 private static native void nativeFlushPersistentData();
268
269 /**
270 * @return An instance of {@link FeedbackReporter} to report feedback. 143 * @return An instance of {@link FeedbackReporter} to report feedback.
271 */ 144 */
272 public FeedbackReporter createFeedbackReporter() { 145 public FeedbackReporter createFeedbackReporter() {
273 return new EmptyFeedbackReporter(); 146 return new EmptyFeedbackReporter();
274 } 147 }
275 148
276 /** 149 /**
277 * @return An instance of ExternalAuthUtils to be installed as a singleton. 150 * @return An instance of GmsCoreSyncListener to notify GmsCore of sync encr yption key changes.
151 * Will be null if one is unavailable.
278 */ 152 */
279 public ExternalAuthUtils createExternalAuthUtils() { 153 public GmsCoreSyncListener createGmsCoreSyncListener() {
280 return new ExternalAuthUtils(); 154 return null;
155 }
156
157 /**
158 * @return An instance of GoogleActivityController.
159 */
160 public GoogleActivityController createGoogleActivityController() {
161 return new GoogleActivityController();
162 }
163
164 /**
165 * @return An instance of {@link GSAHelper} that handles the start point of chrome's integration
166 * with GSA.
167 */
168 public GSAHelper createGsaHelper() {
169 return new GSAHelper();
281 } 170 }
282 171
283 /** 172 /**
284 * Returns a new instance of HelpAndFeedback. 173 * Returns a new instance of HelpAndFeedback.
285 */ 174 */
286 public HelpAndFeedback createHelpAndFeedback() { 175 public HelpAndFeedback createHelpAndFeedback() {
287 return new HelpAndFeedback(); 176 return new HelpAndFeedback();
288 } 177 }
289 178
290 /**
291 * @return An instance of {@link CustomTabsConnection}. Should not be called
292 * outside of {@link CustomTabsConnection#getInstance()}.
293 */
294 public CustomTabsConnection createCustomTabsConnection() {
295 return new CustomTabsConnection(this);
296 }
297
298 /**
299 * @return A new {@link PhysicalWebBleClient} instance.
300 */
301 public PhysicalWebBleClient createPhysicalWebBleClient() {
302 return new PhysicalWebBleClient();
303 }
304
305 public InstantAppsHandler createInstantAppsHandler() { 179 public InstantAppsHandler createInstantAppsHandler() {
306 return new InstantAppsHandler(); 180 return new InstantAppsHandler();
307 } 181 }
308 182
309 /** 183 /**
310 * @return An instance of {@link GSAHelper} that handles the start point of chrome's integration
311 * with GSA.
312 */
313 public GSAHelper createGsaHelper() {
314 return new GSAHelper();
315 }
316
317 /**
318 * @return An instance of {@link LocaleManager} that handles customized loca le related logic. 184 * @return An instance of {@link LocaleManager} that handles customized loca le related logic.
319 */ 185 */
320 public LocaleManager createLocaleManager() { 186 public LocaleManager createLocaleManager() {
321 return new LocaleManager(); 187 return new LocaleManager();
322 } 188 }
323 189
324 /** 190 /**
325 * Registers various policy providers with the policy manager. 191 * Returns an instance of LocationSettings to be installed as a singleton.
326 * Providers are registered in increasing order of precedence so overrides s hould call this
327 * method in the end for this method to maintain the highest precedence.
328 * @param combinedProvider The {@link CombinedPolicyProvider} to register th e providers with.
329 */ 192 */
330 public void registerPolicyProviders(CombinedPolicyProvider combinedProvider) { 193 public LocationSettings createLocationSettings() {
331 combinedProvider.registerProvider(new AppRestrictionsProvider(getApplica tionContext())); 194 // Using an anonymous subclass as the constructor is protected.
195 // This is done to deter instantiation of LocationSettings elsewhere wit hout using the
196 // getInstance() helper method.
197 return new LocationSettings() {};
332 } 198 }
333 199
334 /** 200 /**
335 * @return An instance of PolicyAuditor that notifies the policy system of t he user's activity.
336 * Only applicable when the user has a policy active, that is tracking the a ctivity.
337 */
338 public PolicyAuditor getPolicyAuditor() {
339 // This class has a protected constructor to prevent accidental instanti ation.
340 return new PolicyAuditor() {};
341 }
342
343 /**
344 * @return An instance of MultiWindowUtils to be installed as a singleton. 201 * @return An instance of MultiWindowUtils to be installed as a singleton.
345 */ 202 */
346 public MultiWindowUtils createMultiWindowUtils() { 203 public MultiWindowUtils createMultiWindowUtils() {
347 return new MultiWindowUtils(); 204 return new MultiWindowUtils();
348 } 205 }
349 206
350 /** 207 /**
351 * @return An instance of VideoPersister to be installed as a singleton.
352 */
353 public VideoPersister createVideoPersister() {
354 return new VideoPersister();
355 }
356
357 /**
358 * @return An instance of RequestGenerator to be used for Omaha XML creation . Will be null if 208 * @return An instance of RequestGenerator to be used for Omaha XML creation . Will be null if
359 * a generator is unavailable. 209 * a generator is unavailable.
360 */ 210 */
361 public RequestGenerator createOmahaRequestGenerator() { 211 public RequestGenerator createOmahaRequestGenerator() {
362 return null; 212 return null;
363 } 213 }
364 214
365 /** 215 /**
366 * @return An instance of GmsCoreSyncListener to notify GmsCore of sync encr yption key changes. 216 * @return A new {@link PhysicalWebBleClient} instance.
367 * Will be null if one is unavailable.
368 */ 217 */
369 public GmsCoreSyncListener createGmsCoreSyncListener() { 218 public PhysicalWebBleClient createPhysicalWebBleClient() {
370 return null; 219 return new PhysicalWebBleClient();
371 } 220 }
372 221
373 /** 222 /**
374 * @return An instance of GoogleActivityController. 223 * @return a new {@link ProcessInitializationHandler} instance.
375 */
376 public GoogleActivityController createGoogleActivityController() {
377 return new GoogleActivityController();
378 }
379
380 /**
381 * @return An instance of AppDetailsDelegate that can be queried about app i nformation for the
382 * App Banner feature. Will be null if one is unavailable.
383 */ 224 */
384 public AppDetailsDelegate createAppDetailsDelegate() { 225 public ProcessInitializationHandler createProcessInitializationHandler() {
385 return null; 226 return new ProcessInitializationHandler();
386 }
387
388 /** Returns the singleton instance of GooglePlayWebApkInstallDelegate. */
389 public GooglePlayWebApkInstallDelegate getGooglePlayWebApkInstallDelegate() {
390 return null;
391 }
392
393 /** Returns the singleton instance of ChromeShortcutManager */
394 public ChromeShortcutManager createChromeShortcutManager() {
395 return new ChromeShortcutManager();
396 }
397
398 /**
399 * Returns the singleton instance of the DocumentTabModelSelector.
400 * TODO(dfalcantara): Find a better place for this once we differentiate bet ween activity and
401 * application-level TabModelSelectors.
402 * @return The DocumentTabModelSelector for the application.
403 */
404 @SuppressFBWarnings("LI_LAZY_INIT_STATIC")
405 public static DocumentTabModelSelector getDocumentTabModelSelector() {
406 ThreadUtils.assertOnUiThread();
407 if (sDocumentTabModelSelector == null) {
408 ActivityDelegateImpl activityDelegate = new ActivityDelegateImpl(
409 DocumentActivity.class, IncognitoDocumentActivity.class);
410 sDocumentTabModelSelector = new DocumentTabModelSelector(activityDel egate,
411 new StorageDelegate(), new TabDelegate(false), new TabDelega te(true));
412 }
413 return sDocumentTabModelSelector;
414 } 227 }
415 228
416 /** 229 /**
417 * @return An instance of RevenueStats to be installed as a singleton. 230 * @return An instance of RevenueStats to be installed as a singleton.
418 */ 231 */
419 public RevenueStats createRevenueStatsInstance() { 232 public RevenueStats createRevenueStatsInstance() {
420 return new RevenueStats(); 233 return new RevenueStats();
421 } 234 }
422 235
423 /** 236 /**
424 * Creates a new {@link AccountManagerDelegate}. 237 * Returns a new instance of VariationsSession.
425 * @return the created {@link AccountManagerDelegate}.
426 */ 238 */
427 public AccountManagerDelegate createAccountManagerDelegate() { 239 public VariationsSession createVariationsSession() {
428 return new SystemAccountManagerDelegate(this); 240 return new VariationsSession();
429 } 241 }
430 242
431 /** 243 /**
432 * Creates a new {@link AppIndexingReporter}. 244 * @return An instance of VideoPersister to be installed as a singleton.
433 * @return the created {@link AppIndexingReporter}.
434 */ 245 */
435 public AppIndexingReporter createAppIndexingReporter() { 246 public VideoPersister createVideoPersister() {
436 return new AppIndexingReporter(); 247 return new VideoPersister();
248 }
249
250 /** Returns the singleton instance of GooglePlayWebApkInstallDelegate. */
251 public GooglePlayWebApkInstallDelegate getGooglePlayWebApkInstallDelegate() {
252 return null;
437 } 253 }
438 254
439 /** 255 /**
256 * @return An instance of PolicyAuditor that notifies the policy system of t he user's activity.
257 * Only applicable when the user has a policy active, that is tracking the a ctivity.
258 */
259 public PolicyAuditor getPolicyAuditor() {
260 // This class has a protected constructor to prevent accidental instanti ation.
261 return new PolicyAuditor() {};
262 }
263
264 public void registerPolicyProviders(CombinedPolicyProvider combinedProvider) {
265 combinedProvider.registerProvider(
266 new AppRestrictionsProvider(ContextUtils.getApplicationContext() ));
267 }
268
269 /**
440 * Starts a service from {@code intent}. Meant to eventually be used by ser vices that want to 270 * Starts a service from {@code intent}. Meant to eventually be used by ser vices that want to
441 * be put into the foreground with {@code notification} via 271 * be put into the foreground with {@code notification} via
442 * {@link android.app.Service#startForeground(int, Notification)}. 272 * {@link android.app.Service#startForeground(int, Notification)}.
443 * 273 *
444 * @param intent The {@link Intent} to fire to start the service. 274 * @param intent The {@link Intent} to fire to start the service.
445 * @param notificationId The id of the notification to show. 275 * @param notificationId The id of the notification to show.
446 * @param notification The {@link Notification} to show. 276 * @param notification The {@link Notification} to show.
447 */ 277 */
448 @SuppressWarnings("Unused") 278 @SuppressWarnings("Unused")
449 public void startServiceWithNotification( 279 public void startServiceWithNotification(
450 Intent intent, int notificationId, Notification notification) { 280 Intent intent, int notificationId, Notification notification) {
451 // TODO(dtrainor): Eventually make sure the service gets put into the fo reground with 281 // TODO(dtrainor): Eventually make sure the service gets put into the fo reground with
452 // {@link android.app.Service#startForeground(int, Notification)}. 282 // {@link android.app.Service#startForeground(int, Notification)}.
453 startService(intent); 283 ContextUtils.getApplicationContext().startService(intent);
454 } 284 }
455 } 285 }
OLDNEW
« no previous file with comments | « chrome/android/BUILD.gn ('k') | chrome/android/java/src/org/chromium/chrome/browser/AppHooksImpl.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698