| 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.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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 "UMA.Debug.EnableCrashUpload.DeferredStartUptime2", | 166 "UMA.Debug.EnableCrashUpload.DeferredStartUptime2", |
| 170 SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime(), | 167 SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime(), |
| 171 TimeUnit.MILLISECONDS); | 168 TimeUnit.MILLISECONDS); |
| 172 | 169 |
| 173 mDeferredTasks.add(new Runnable() { | 170 mDeferredTasks.add(new Runnable() { |
| 174 @Override | 171 @Override |
| 175 public void run() { | 172 public void run() { |
| 176 // Punt all tasks that may block on disk off onto a background t
hread. | 173 // Punt all tasks that may block on disk off onto a background t
hread. |
| 177 initAsyncDiskTask(); | 174 initAsyncDiskTask(); |
| 178 | 175 |
| 176 DefaultBrowserInfo.initBrowserFetcher(); |
| 177 |
| 179 AfterStartupTaskUtils.setStartupComplete(); | 178 AfterStartupTaskUtils.setStartupComplete(); |
| 180 | 179 |
| 181 PartnerBrowserCustomizations.setOnInitializeAsyncFinished(new Ru
nnable() { | 180 PartnerBrowserCustomizations.setOnInitializeAsyncFinished(new Ru
nnable() { |
| 182 @Override | 181 @Override |
| 183 public void run() { | 182 public void run() { |
| 184 String homepageUrl = HomepageManager.getHomepageUri(mApp
Context); | 183 String homepageUrl = HomepageManager.getHomepageUri(mApp
Context); |
| 185 LaunchMetrics.recordHomePageLaunchMetrics( | 184 LaunchMetrics.recordHomePageLaunchMetrics( |
| 186 HomepageManager.isHomepageEnabled(mAppContext), | 185 HomepageManager.isHomepageEnabled(mAppContext), |
| 187 NewTabPage.isNTPUrl(homepageUrl), homepageUrl); | 186 NewTabPage.isNTPUrl(homepageUrl), homepageUrl); |
| 188 } | 187 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 | 275 |
| 277 // Initialize whether or not precaching is enabled. | 276 // Initialize whether or not precaching is enabled. |
| 278 PrecacheLauncher.updatePrecachingEnabled(mAppContext); | 277 PrecacheLauncher.updatePrecachingEnabled(mAppContext); |
| 279 | 278 |
| 280 if (ChromeWebApkHost.isEnabled()) { | 279 if (ChromeWebApkHost.isEnabled()) { |
| 281 WebApkVersionManager.updateWebApksIfNeeded(); | 280 WebApkVersionManager.updateWebApksIfNeeded(); |
| 282 } | 281 } |
| 283 | 282 |
| 284 removeSnapshotDatabase(); | 283 removeSnapshotDatabase(); |
| 285 | 284 |
| 286 cacheIsChromeDefaultBrowser(); | |
| 287 | |
| 288 // Warm up all web app shared prefs. This must be run after
the WebappRegistry | 285 // Warm up all web app shared prefs. This must be run after
the WebappRegistry |
| 289 // instance is initialized. | 286 // instance is initialized. |
| 290 WebappRegistry.warmUpSharedPrefs(); | 287 WebappRegistry.warmUpSharedPrefs(); |
| 291 | 288 |
| 292 return null; | 289 return null; |
| 293 } finally { | 290 } finally { |
| 294 TraceEvent.end("ChromeBrowserInitializer.onDeferredStartup.d
oInBackground"); | 291 TraceEvent.end("ChromeBrowserInitializer.onDeferredStartup.d
oInBackground"); |
| 295 } | 292 } |
| 296 } | 293 } |
| 297 | 294 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 313 if (SysUtils.isLowEndDevice()) return; | 310 if (SysUtils.isLowEndDevice()) return; |
| 314 | 311 |
| 315 boolean moderateBindingTillBackgrounded = | 312 boolean moderateBindingTillBackgrounded = |
| 316 FieldTrialList.findFullName("ModerateBindingOnBackgroundTabCreat
ion") | 313 FieldTrialList.findFullName("ModerateBindingOnBackgroundTabCreat
ion") |
| 317 .equals("Enabled"); | 314 .equals("Enabled"); |
| 318 ChildProcessLauncher.startModerateBindingManagement( | 315 ChildProcessLauncher.startModerateBindingManagement( |
| 319 mAppContext, moderateBindingTillBackgrounded); | 316 mAppContext, moderateBindingTillBackgrounded); |
| 320 } | 317 } |
| 321 | 318 |
| 322 /** | 319 /** |
| 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 | 320 * Deletes the snapshot database which is no longer used because the feature
has been removed |
| 338 * in Chrome M41. | 321 * in Chrome M41. |
| 339 */ | 322 */ |
| 340 @WorkerThread | 323 @WorkerThread |
| 341 private void removeSnapshotDatabase() { | 324 private void removeSnapshotDatabase() { |
| 342 synchronized (SNAPSHOT_DATABASE_LOCK) { | 325 synchronized (SNAPSHOT_DATABASE_LOCK) { |
| 343 SharedPreferences prefs = | 326 SharedPreferences prefs = |
| 344 ContextUtils.getAppSharedPreferences(); | 327 ContextUtils.getAppSharedPreferences(); |
| 345 if (!prefs.getBoolean(SNAPSHOT_DATABASE_REMOVED, false)) { | 328 if (!prefs.getBoolean(SNAPSHOT_DATABASE_REMOVED, false)) { |
| 346 mAppContext.deleteDatabase(SNAPSHOT_DATABASE_NAME); | 329 mAppContext.deleteDatabase(SNAPSHOT_DATABASE_NAME); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 } | 362 } |
| 380 | 363 |
| 381 /** | 364 /** |
| 382 * @return Whether deferred startup has been completed. | 365 * @return Whether deferred startup has been completed. |
| 383 */ | 366 */ |
| 384 @VisibleForTesting | 367 @VisibleForTesting |
| 385 public boolean isDeferredStartupCompleteForApp() { | 368 public boolean isDeferredStartupCompleteForApp() { |
| 386 return mDeferredStartupCompletedForApp; | 369 return mDeferredStartupCompletedForApp; |
| 387 } | 370 } |
| 388 } | 371 } |
| OLD | NEW |