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

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

Issue 2663373003: [Android] Add options in the context menu of CCT to open in a new Chrome tab or incoginto tab (Closed)
Patch Set: Fix comflict. Created 3 years, 10 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 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.content.Context; 7 import android.content.Context;
8 import android.content.Intent;
9 import android.content.SharedPreferences; 8 import android.content.SharedPreferences;
10 import android.content.pm.ResolveInfo;
11 import android.net.Uri;
12 import android.os.AsyncTask; 9 import android.os.AsyncTask;
13 import android.os.Looper; 10 import android.os.Looper;
14 import android.os.MessageQueue; 11 import android.os.MessageQueue;
15 import android.os.SystemClock; 12 import android.os.SystemClock;
16 import android.support.annotation.UiThread; 13 import android.support.annotation.UiThread;
17 import android.support.annotation.WorkerThread; 14 import android.support.annotation.WorkerThread;
18 import android.view.inputmethod.InputMethodInfo; 15 import android.view.inputmethod.InputMethodInfo;
19 import android.view.inputmethod.InputMethodManager; 16 import android.view.inputmethod.InputMethodManager;
20 import android.view.inputmethod.InputMethodSubtype; 17 import android.view.inputmethod.InputMethodSubtype;
21 18
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 273
277 // Initialize whether or not precaching is enabled. 274 // Initialize whether or not precaching is enabled.
278 PrecacheLauncher.updatePrecachingEnabled(mAppContext); 275 PrecacheLauncher.updatePrecachingEnabled(mAppContext);
279 276
280 if (ChromeWebApkHost.isEnabled()) { 277 if (ChromeWebApkHost.isEnabled()) {
281 WebApkVersionManager.updateWebApksIfNeeded(); 278 WebApkVersionManager.updateWebApksIfNeeded();
282 } 279 }
283 280
284 removeSnapshotDatabase(); 281 removeSnapshotDatabase();
285 282
286 cacheIsChromeDefaultBrowser(); 283 DefaultBrowserInfo.cacheIsChromeDefaultBrowser();
284
285 DefaultBrowserInfo.initBrowserFetcher();
Maria 2017/02/17 23:01:23 should this be called from UI thread rather than f
ltian 2017/02/21 19:15:37 Done.
287 286
288 // Warm up all web app shared prefs. This must be run after the WebappRegistry 287 // Warm up all web app shared prefs. This must be run after the WebappRegistry
289 // instance is initialized. 288 // instance is initialized.
290 WebappRegistry.warmUpSharedPrefs(); 289 WebappRegistry.warmUpSharedPrefs();
291 290
292 return null; 291 return null;
293 } finally { 292 } finally {
294 TraceEvent.end("ChromeBrowserInitializer.onDeferredStartup.d oInBackground"); 293 TraceEvent.end("ChromeBrowserInitializer.onDeferredStartup.d oInBackground");
295 } 294 }
296 } 295 }
(...skipping 16 matching lines...) Expand all
313 if (SysUtils.isLowEndDevice()) return; 312 if (SysUtils.isLowEndDevice()) return;
314 313
315 boolean moderateBindingTillBackgrounded = 314 boolean moderateBindingTillBackgrounded =
316 FieldTrialList.findFullName("ModerateBindingOnBackgroundTabCreat ion") 315 FieldTrialList.findFullName("ModerateBindingOnBackgroundTabCreat ion")
317 .equals("Enabled"); 316 .equals("Enabled");
318 ChildProcessLauncher.startModerateBindingManagement( 317 ChildProcessLauncher.startModerateBindingManagement(
319 mAppContext, moderateBindingTillBackgrounded); 318 mAppContext, moderateBindingTillBackgrounded);
320 } 319 }
321 320
322 /** 321 /**
323 * Caches whether Chrome is set as a default browser on the device.
324 */
325 @WorkerThread
326 private void cacheIsChromeDefaultBrowser() {
327 // Retrieve whether Chrome is default in background to avoid strict mode checks.
328 Intent intent = new Intent(Intent.ACTION_VIEW,
329 Uri.parse("http://www.madeupdomainforcheck123.com/"));
330 ResolveInfo info = mAppContext.getPackageManager().resolveActivity(inten t, 0);
331 boolean isDefault = (info != null && info.match != 0
332 && mAppContext.getPackageName().equals(info.activityInfo.package Name));
333 ChromePreferenceManager.getInstance().setCachedChromeDefaultBrowser(isDe fault);
334 }
335
336 /**
337 * Deletes the snapshot database which is no longer used because the feature has been removed 322 * Deletes the snapshot database which is no longer used because the feature has been removed
338 * in Chrome M41. 323 * in Chrome M41.
339 */ 324 */
340 @WorkerThread 325 @WorkerThread
341 private void removeSnapshotDatabase() { 326 private void removeSnapshotDatabase() {
342 synchronized (SNAPSHOT_DATABASE_LOCK) { 327 synchronized (SNAPSHOT_DATABASE_LOCK) {
343 SharedPreferences prefs = 328 SharedPreferences prefs =
344 ContextUtils.getAppSharedPreferences(); 329 ContextUtils.getAppSharedPreferences();
345 if (!prefs.getBoolean(SNAPSHOT_DATABASE_REMOVED, false)) { 330 if (!prefs.getBoolean(SNAPSHOT_DATABASE_REMOVED, false)) {
346 mAppContext.deleteDatabase(SNAPSHOT_DATABASE_NAME); 331 mAppContext.deleteDatabase(SNAPSHOT_DATABASE_NAME);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 } 364 }
380 365
381 /** 366 /**
382 * @return Whether deferred startup has been completed. 367 * @return Whether deferred startup has been completed.
383 */ 368 */
384 @VisibleForTesting 369 @VisibleForTesting
385 public boolean isDeferredStartupCompleteForApp() { 370 public boolean isDeferredStartupCompleteForApp() {
386 return mDeferredStartupCompletedForApp; 371 return mDeferredStartupCompletedForApp;
387 } 372 }
388 } 373 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698