| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.init; | 5 package org.chromium.chrome.browser.init; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.os.AsyncTask; | 9 import android.os.AsyncTask; |
| 10 import android.os.Build; | 10 import android.os.Build; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 import java.util.LinkedList; | 54 import java.util.LinkedList; |
| 55 import java.util.Locale; | 55 import java.util.Locale; |
| 56 | 56 |
| 57 /** | 57 /** |
| 58 * Application level delegate that handles start up tasks. | 58 * Application level delegate that handles start up tasks. |
| 59 * {@link AsyncInitializationActivity} classes should override the {@link Browse
rParts} | 59 * {@link AsyncInitializationActivity} classes should override the {@link Browse
rParts} |
| 60 * interface for any additional initialization tasks for the initialization to w
ork as intended. | 60 * interface for any additional initialization tasks for the initialization to w
ork as intended. |
| 61 */ | 61 */ |
| 62 public class ChromeBrowserInitializer { | 62 public class ChromeBrowserInitializer { |
| 63 private static final String TAG = "BrowserInitializer"; | 63 private static final String TAG = "BrowserInitializer"; |
| 64 private static ChromeBrowserInitializer sChromeBrowserInitiliazer; | 64 private static ChromeBrowserInitializer sChromeBrowserInitializer; |
| 65 | 65 |
| 66 private final Handler mHandler; | 66 private final Handler mHandler; |
| 67 private final ChromeApplication mApplication; | 67 private final ChromeApplication mApplication; |
| 68 private final Locale mInitialLocale = Locale.getDefault(); | 68 private final Locale mInitialLocale = Locale.getDefault(); |
| 69 | 69 |
| 70 private boolean mPreInflationStartupComplete; | 70 private boolean mPreInflationStartupComplete; |
| 71 private boolean mPostInflationStartupComplete; | 71 private boolean mPostInflationStartupComplete; |
| 72 private boolean mNativeInitializationComplete; | 72 private boolean mNativeInitializationComplete; |
| 73 | 73 |
| 74 private MinidumpDirectoryObserver mMinidumpDirectoryObserver; | 74 private MinidumpDirectoryObserver mMinidumpDirectoryObserver; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 86 */ | 86 */ |
| 87 void setUpdateUrl(String updateUrl); | 87 void setUpdateUrl(String updateUrl); |
| 88 } | 88 } |
| 89 | 89 |
| 90 /** | 90 /** |
| 91 * This class is an application specific object that orchestrates the app in
itialization. | 91 * This class is an application specific object that orchestrates the app in
itialization. |
| 92 * @param context The context to get the application context from. | 92 * @param context The context to get the application context from. |
| 93 * @return The singleton instance of {@link ChromeBrowserInitializer}. | 93 * @return The singleton instance of {@link ChromeBrowserInitializer}. |
| 94 */ | 94 */ |
| 95 public static ChromeBrowserInitializer getInstance(Context context) { | 95 public static ChromeBrowserInitializer getInstance(Context context) { |
| 96 if (sChromeBrowserInitiliazer == null) { | 96 if (sChromeBrowserInitializer == null) { |
| 97 sChromeBrowserInitiliazer = new ChromeBrowserInitializer(context); | 97 sChromeBrowserInitializer = new ChromeBrowserInitializer(context); |
| 98 } | 98 } |
| 99 return sChromeBrowserInitiliazer; | 99 return sChromeBrowserInitializer; |
| 100 } | 100 } |
| 101 | 101 |
| 102 private ChromeBrowserInitializer(Context context) { | 102 private ChromeBrowserInitializer(Context context) { |
| 103 mApplication = (ChromeApplication) context.getApplicationContext(); | 103 mApplication = (ChromeApplication) context.getApplicationContext(); |
| 104 mHandler = new Handler(Looper.getMainLooper()); | 104 mHandler = new Handler(Looper.getMainLooper()); |
| 105 initLeakCanary(); | 105 initLeakCanary(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 @RemovableInRelease | 108 @RemovableInRelease |
| 109 private void initLeakCanary() { | 109 private void initLeakCanary() { |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 if (!mInitialLocale.equals(Locale.getDefault())) { | 432 if (!mInitialLocale.equals(Locale.getDefault())) { |
| 433 Log.e(TAG, "Killing process because of locale change."); | 433 Log.e(TAG, "Killing process because of locale change."); |
| 434 Process.killProcess(Process.myPid()); | 434 Process.killProcess(Process.myPid()); |
| 435 } | 435 } |
| 436 | 436 |
| 437 DeviceFormFactor.resetValuesIfNeeded(mApplication); | 437 DeviceFormFactor.resetValuesIfNeeded(mApplication); |
| 438 } | 438 } |
| 439 } | 439 } |
| 440 }; | 440 }; |
| 441 } | 441 } |
| 442 |
| 443 /** |
| 444 * For unit testing of clients. |
| 445 * @param initializer The (dummy or mocked) initializer to use. |
| 446 */ |
| 447 public static void setForTesting(ChromeBrowserInitializer initializer) { |
| 448 sChromeBrowserInitializer = initializer; |
| 449 } |
| 442 } | 450 } |
| OLD | NEW |