Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/history/HistoryManagerUtils.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryManagerUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryManagerUtils.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3a75e8daf4d9ec88a8ce5cf3bd90c2152319620b |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryManagerUtils.java |
| @@ -0,0 +1,57 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.chrome.browser.history; |
| + |
| +import android.app.Activity; |
| +import android.content.Intent; |
| +import android.text.TextUtils; |
| + |
| +import org.chromium.base.CommandLine; |
| +import org.chromium.chrome.browser.IntentHandler; |
| +import org.chromium.components.variations.VariationsAssociatedData; |
| + |
| +/** |
| + * Utility methods for the browsing history manager. |
| + */ |
| +public class HistoryManagerUtils { |
| + private static final String FIELD_TRIAL_NAME = "AndroidHistoryManager"; |
| + private static final String ENABLE_HISTORY_SWTICH = "enable_android_history_manager"; |
| + 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.
|
| + private static Boolean sNativeHistoryEnabled; |
| + |
| + /** |
| + * @return Whether the Android-specific browsing history manager is enabled. |
| + */ |
| + public static boolean isAndroidHistoryManagerEnabled() { |
| + synchronized (sLock) { |
| + if (sNativeHistoryEnabled == null) { |
| + if (CommandLine.getInstance().hasSwitch(ENABLE_HISTORY_SWTICH)) { |
| + sNativeHistoryEnabled = true; |
| + } else { |
| + sNativeHistoryEnabled = TextUtils.equals("true", |
| + VariationsAssociatedData.getVariationParamValue(FIELD_TRIAL_NAME, |
| + ENABLE_HISTORY_SWTICH)); |
| + } |
| + } |
| + } |
| + |
| + return sNativeHistoryEnabled; |
| + } |
| + |
| + /** |
| + * @return Whether the Android-specific browsing history UI is was shown. |
| + */ |
| + public static boolean showHistoryManager(Activity activity) { |
| + if (!isAndroidHistoryManagerEnabled()) return false; |
| + |
| + // TODO(twellington): Add support for tablets |
| + Intent intent = new Intent(); |
| + intent.setClass(activity.getApplicationContext(), HistoryActivity.class); |
| + intent.putExtra(IntentHandler.EXTRA_PARENT_COMPONENT, activity.getComponentName()); |
| + activity.startActivity(intent); |
| + |
| + return true; |
| + } |
| +} |