Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.view.View; | 9 import android.view.View; |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 import org.chromium.chrome.browser.DevToolsServer; | 24 import org.chromium.chrome.browser.DevToolsServer; |
| 25 import org.chromium.chrome.browser.banners.AppBannerManager; | 25 import org.chromium.chrome.browser.banners.AppBannerManager; |
| 26 import org.chromium.chrome.browser.download.DownloadController; | 26 import org.chromium.chrome.browser.download.DownloadController; |
| 27 import org.chromium.chrome.browser.download.DownloadManagerService; | 27 import org.chromium.chrome.browser.download.DownloadManagerService; |
| 28 import org.chromium.chrome.browser.firstrun.ForcedSigninProcessor; | 28 import org.chromium.chrome.browser.firstrun.ForcedSigninProcessor; |
| 29 import org.chromium.chrome.browser.identity.UniqueIdentificationGeneratorFactory ; | 29 import org.chromium.chrome.browser.identity.UniqueIdentificationGeneratorFactory ; |
| 30 import org.chromium.chrome.browser.identity.UuidBasedUniqueIdentificationGenerat or; | 30 import org.chromium.chrome.browser.identity.UuidBasedUniqueIdentificationGenerat or; |
| 31 import org.chromium.chrome.browser.invalidation.UniqueIdInvalidationClientNameGe nerator; | 31 import org.chromium.chrome.browser.invalidation.UniqueIdInvalidationClientNameGe nerator; |
| 32 import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; | 32 import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; |
| 33 import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; | 33 import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; |
| 34 import org.chromium.chrome.browser.photo_picker.PhotoPickerDialog; | |
| 34 import org.chromium.chrome.browser.preferences.PrefServiceBridge; | 35 import org.chromium.chrome.browser.preferences.PrefServiceBridge; |
| 35 import org.chromium.chrome.browser.rlz.RevenueStats; | 36 import org.chromium.chrome.browser.rlz.RevenueStats; |
| 36 import org.chromium.chrome.browser.services.AccountsChangedReceiver; | 37 import org.chromium.chrome.browser.services.AccountsChangedReceiver; |
| 37 import org.chromium.chrome.browser.services.GoogleServicesManager; | 38 import org.chromium.chrome.browser.services.GoogleServicesManager; |
| 38 import org.chromium.chrome.browser.sync.SyncController; | 39 import org.chromium.chrome.browser.sync.SyncController; |
| 39 import org.chromium.components.signin.AccountManagerHelper; | 40 import org.chromium.components.signin.AccountManagerHelper; |
| 40 import org.chromium.content.common.ContentSwitches; | 41 import org.chromium.content.common.ContentSwitches; |
| 41 import org.chromium.printing.PrintDocumentAdapterWrapper; | 42 import org.chromium.printing.PrintDocumentAdapterWrapper; |
| 42 import org.chromium.printing.PrintingControllerImpl; | 43 import org.chromium.printing.PrintingControllerImpl; |
| 43 import org.chromium.ui.PhotoPickerListener; | 44 import org.chromium.ui.PhotoPickerListener; |
| 44 import org.chromium.ui.UiUtils; | 45 import org.chromium.ui.UiUtils; |
| 45 import org.chromium.ui.widget.Toast; | |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * Handles the initialization dependences of the browser process. This is meant to handle the | 48 * Handles the initialization dependences of the browser process. This is meant to handle the |
| 49 * initialization that is not tied to any particular Activity, and the logic tha t should only be | 49 * initialization that is not tied to any particular Activity, and the logic tha t should only be |
| 50 * triggered a single time for the lifetime of the browser process. | 50 * triggered a single time for the lifetime of the browser process. |
| 51 */ | 51 */ |
| 52 public class ProcessInitializationHandler { | 52 public class ProcessInitializationHandler { |
| 53 | 53 |
| 54 private static final String SESSIONS_UUID_PREF_KEY = "chromium.sync.sessions .id"; | 54 private static final String SESSIONS_UUID_PREF_KEY = "chromium.sync.sessions .id"; |
| 55 private static final String DEV_TOOLS_SERVER_SOCKET_PREFIX = "chrome"; | 55 private static final String DEV_TOOLS_SERVER_SOCKET_PREFIX = "chrome"; |
| 56 | 56 |
| 57 private static ProcessInitializationHandler sInstance; | 57 private static ProcessInitializationHandler sInstance; |
| 58 | 58 |
| 59 private boolean mInitializedPreNative; | 59 private boolean mInitializedPreNative; |
| 60 private boolean mInitializedPostNative; | 60 private boolean mInitializedPostNative; |
| 61 private boolean mInitializedDeferredStartupTasks; | 61 private boolean mInitializedDeferredStartupTasks; |
| 62 private DevToolsServer mDevToolsServer; | 62 private DevToolsServer mDevToolsServer; |
| 63 private PhotoPickerDialog mDialog; | |
|
Ted C
2017/04/06 23:52:15
will this ever need to be used outside of the dele
Finnur
2017/04/07 13:52:20
Done.
| |
| 63 | 64 |
| 64 /** | 65 /** |
| 65 * @return The ProcessInitializationHandler for use during the lifetime of t he browser process. | 66 * @return The ProcessInitializationHandler for use during the lifetime of t he browser process. |
| 66 */ | 67 */ |
| 67 public static ProcessInitializationHandler getInstance() { | 68 public static ProcessInitializationHandler getInstance() { |
| 68 ThreadUtils.assertOnUiThread(); | 69 ThreadUtils.assertOnUiThread(); |
| 69 if (sInstance == null) { | 70 if (sInstance == null) { |
| 70 sInstance = AppHooks.get().createProcessInitializationHandler(); | 71 sInstance = AppHooks.get().createProcessInitializationHandler(); |
| 71 } | 72 } |
| 72 return sInstance; | 73 return sInstance; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 AppBannerManager.setAppDetailsDelegate(AppHooks.get().createAppDetailsDe legate()); | 156 AppBannerManager.setAppDetailsDelegate(AppHooks.get().createAppDetailsDe legate()); |
| 156 ChromeLifetimeController.initialize(); | 157 ChromeLifetimeController.initialize(); |
| 157 | 158 |
| 158 PrefServiceBridge.getInstance().migratePreferences(application); | 159 PrefServiceBridge.getInstance().migratePreferences(application); |
| 159 | 160 |
| 160 if (ChromeFeatureList.isEnabled(ChromeFeatureList.NEW_PHOTO_PICKER)) { | 161 if (ChromeFeatureList.isEnabled(ChromeFeatureList.NEW_PHOTO_PICKER)) { |
| 161 UiUtils.setPhotoPickerDelegate(new UiUtils.PhotoPickerDelegate() { | 162 UiUtils.setPhotoPickerDelegate(new UiUtils.PhotoPickerDelegate() { |
| 162 @Override | 163 @Override |
| 163 public void showPhotoPicker( | 164 public void showPhotoPicker( |
| 164 Context context, PhotoPickerListener listener, boolean a llowMultiple) { | 165 Context context, PhotoPickerListener listener, boolean a llowMultiple) { |
| 165 Toast toast = Toast.makeText(context, "Not implemented!", To ast.LENGTH_SHORT); | 166 mDialog = new PhotoPickerDialog(context, listener, allowMult iple); |
| 166 toast.show(); | 167 mDialog.show(); |
| 167 } | 168 } |
| 168 | 169 |
| 169 @Override | 170 @Override |
| 170 public void dismissPhotoPicker() {} | 171 public void dismissPhotoPicker() { |
| 172 mDialog.dismiss(); | |
| 173 mDialog = null; | |
| 174 } | |
| 171 }); | 175 }); |
| 172 } | 176 } |
| 173 } | 177 } |
| 174 | 178 |
| 175 /** | 179 /** |
| 176 * Initializes the deferred startup tasks that should only be triggered once per browser process | 180 * Initializes the deferred startup tasks that should only be triggered once per browser process |
| 177 * lifetime. | 181 * lifetime. |
| 178 */ | 182 */ |
| 179 public final void initializeDeferredStartupTasks() { | 183 public final void initializeDeferredStartupTasks() { |
| 180 ThreadUtils.assertOnUiThread(); | 184 ThreadUtils.assertOnUiThread(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 | 243 |
| 240 if (ApiCompatibilityUtils.isPrintingSupported()) { | 244 if (ApiCompatibilityUtils.isPrintingSupported()) { |
| 241 String errorText = application.getResources().getString( | 245 String errorText = application.getResources().getString( |
| 242 R.string.error_printing_failed); | 246 R.string.error_printing_failed); |
| 243 PrintingControllerImpl.create(new PrintDocumentAdapterWrappe r(), errorText); | 247 PrintingControllerImpl.create(new PrintDocumentAdapterWrappe r(), errorText); |
| 244 } | 248 } |
| 245 } | 249 } |
| 246 }); | 250 }); |
| 247 } | 251 } |
| 248 } | 252 } |
| OLD | NEW |