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.content.Context;
8 import android.content.Intent;
9 
10 import org.chromium.base.ContextUtils;
11 import org.chromium.chrome.browser.IntentHandler;
12 import org.chromium.chrome.browser.app.ChromeActivity;
13 import org.chromium.chrome.browser.tab.Tab;
14 import org.chromium.components.embedder_support.util.UrlConstants;
15 import org.chromium.content_public.browser.LoadUrlParams;
16 
17 /**
18  * Utility methods for the browsing history manager.
19  */
20 public class HistoryManagerUtils {
21     /**
22      * Opens the browsing history manager.
23      *
24      * @param activity The {@link ChromeActivity} that owns the {@link HistoryManager}.
25      * @param tab The {@link Tab} to used to display the native page version of the
26      *            {@link HistoryManager}.
27      */
showHistoryManager(ChromeActivity activity, Tab tab)28     public static void showHistoryManager(ChromeActivity activity, Tab tab) {
29         Context appContext = ContextUtils.getApplicationContext();
30         if (activity.isTablet()) {
31             // History shows up as a tab on tablets.
32             LoadUrlParams params = new LoadUrlParams(UrlConstants.NATIVE_HISTORY_URL);
33             tab.loadUrl(params);
34         } else {
35             Intent intent = new Intent();
36             intent.setClass(appContext, HistoryActivity.class);
37             intent.putExtra(IntentHandler.EXTRA_PARENT_COMPONENT, activity.getComponentName());
38             intent.putExtra(IntentHandler.EXTRA_INCOGNITO_MODE,
39                     activity.getTabModelSelector().isIncognitoSelected());
40             activity.startActivity(intent);
41         }
42     }
43 }
44