Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.chrome.browser.history; | |
| 6 | |
| 7 import android.app.Activity; | |
| 8 import android.content.Intent; | |
| 9 import android.text.TextUtils; | |
| 10 | |
| 11 import org.chromium.base.CommandLine; | |
| 12 import org.chromium.chrome.browser.IntentHandler; | |
| 13 import org.chromium.components.variations.VariationsAssociatedData; | |
| 14 | |
| 15 /** | |
| 16 * Utility methods for the browsing history manager. | |
| 17 */ | |
| 18 public class HistoryManagerUtils { | |
| 19 private static final String FIELD_TRIAL_NAME = "AndroidHistoryManager"; | |
| 20 private static final String ENABLE_HISTORY_SWTICH = "enable_android_history_ manager"; | |
| 21 private static final Object sLock = new Object(); | |
|
gone
2016/12/02 20:52:28
nit: NATIVE_HISTORY_ENABLED_LOCK?
Theresa
2016/12/02 21:35:34
Done.
| |
| 22 private static Boolean sNativeHistoryEnabled; | |
| 23 | |
| 24 /** | |
| 25 * @return Whether the Android-specific browsing history manager is enabled. | |
| 26 */ | |
| 27 public static boolean isAndroidHistoryManagerEnabled() { | |
| 28 synchronized (sLock) { | |
| 29 if (sNativeHistoryEnabled == null) { | |
| 30 if (CommandLine.getInstance().hasSwitch(ENABLE_HISTORY_SWTICH)) { | |
| 31 sNativeHistoryEnabled = true; | |
| 32 } else { | |
| 33 sNativeHistoryEnabled = TextUtils.equals("true", | |
| 34 VariationsAssociatedData.getVariationParamValue(FIEL D_TRIAL_NAME, | |
| 35 ENABLE_HISTORY_SWTICH)); | |
| 36 } | |
| 37 } | |
| 38 } | |
| 39 | |
| 40 return sNativeHistoryEnabled; | |
| 41 } | |
| 42 | |
| 43 /** | |
| 44 * @return Whether the Android-specific browsing history UI is was shown. | |
| 45 */ | |
| 46 public static boolean showHistoryManager(Activity activity) { | |
| 47 if (!isAndroidHistoryManagerEnabled()) return false; | |
| 48 | |
| 49 // TODO(twellington): Add support for tablets | |
| 50 Intent intent = new Intent(); | |
| 51 intent.setClass(activity.getApplicationContext(), HistoryActivity.class) ; | |
| 52 intent.putExtra(IntentHandler.EXTRA_PARENT_COMPONENT, activity.getCompon entName()); | |
| 53 activity.startActivity(intent); | |
| 54 | |
| 55 return true; | |
| 56 } | |
| 57 } | |
| OLD | NEW |