Commit 04b297ee authored by mvanouwerkerk's avatar mvanouwerkerk Committed by Commit bot

Delete dead code for CurrentlyOpenTabs

RecentTabsManager#getCurrentlyOpenTabs() always returns null,
and from that point on all this other code seems to be unused.

BUG=659631

Review-Url: https://codereview.chromium.org/2604453004
Cr-Commit-Position: refs/heads/master@{#441387}
parent e5e86244
// Copyright 2015 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.ntp;
/**
* A class that represents tabs open in this device that can be switched to. The Runnable is
* expected to bring the Tab back when run.
*/
public class CurrentlyOpenTab {
private final int mTabId;
private final String mUrl;
private final String mTitle;
private final Runnable mRunnable;
/**
* Basic constructor for {@link CurrentlyOpenTab}.
* @param tabId The id of the tab.
* @param url The url that the tab is currently at.
* @param title The title of the page that the tab is showing.
* @param runnable Run when the item is selected.
*/
public CurrentlyOpenTab(int tabId, String url, String title, Runnable runnable) {
mTabId = tabId;
mUrl = url;
mTitle = title;
mRunnable = runnable;
}
public int getTabId() {
return mTabId;
}
public String getUrl() {
return mUrl;
}
public String getTitle() {
return mTitle;
}
public Runnable getRunnable() {
return mRunnable;
}
}
......@@ -30,24 +30,6 @@ class NewTabPagePrefs {
mNativeNewTabPagePrefs = 0;
}
/**
* Sets whether the list of currently open tabs is collapsed (vs expanded) on the Recent Tabs
* page.
* @param isCollapsed Whether we want the currently open tabs list to be collapsed.
*/
void setCurrentlyOpenTabsCollapsed(boolean isCollapsed) {
nativeSetCurrentlyOpenTabsCollapsed(mNativeNewTabPagePrefs, isCollapsed);
}
/**
* Gets whether the list of currently open tabs is collapsed (vs expanded) on Recent Tabs page.
* @return Whether the list of currently open tabs is collapsed (vs expanded) on
* the Recent Tabs page.
*/
boolean getCurrentlyOpenTabsCollapsed() {
return nativeGetCurrentlyOpenTabsCollapsed(mNativeNewTabPagePrefs);
}
/**
* Sets whether the list of snapshot documents is collapsed (vs expanded) on the Recent Tabs
* page.
......@@ -122,10 +104,6 @@ class NewTabPagePrefs {
private static native long nativeInit(Profile profile);
private static native void nativeDestroy(long nativeNewTabPagePrefs);
private static native void nativeSetCurrentlyOpenTabsCollapsed(
long nativeNewTabPagePrefs, boolean isCollapsed);
private static native boolean nativeGetCurrentlyOpenTabsCollapsed(
long nativeNewTabPagePrefs);
private static native void nativeSetSnapshotDocumentCollapsed(
long nativeNewTabPagePrefs, boolean isCollapsed);
private static native boolean nativeGetSnapshotDocumentCollapsed(
......
......@@ -17,7 +17,6 @@ import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ntp.ForeignSessionHelper.ForeignSession;
import org.chromium.chrome.browser.widget.TintedDrawable;
import org.chromium.ui.base.DeviceFormFactor;
/**
* Header view shown above each group of items on the Recent Tabs page. Shows the name of the
......@@ -77,21 +76,6 @@ public class RecentTabsGroupView extends RelativeLayout {
mExpandCollapseIcon.setImageDrawable(collapseIcon);
}
/**
* Configures the view for currently open tabs.
*
* @param isExpanded Whether the view is expanded or collapsed.
*/
public void configureForCurrentlyOpenTabs(boolean isExpanded) {
mDeviceIcon.setVisibility(View.VISIBLE);
mDeviceIcon.setImageResource(DeviceFormFactor.isTablet(getContext())
? R.drawable.recent_tablet : R.drawable.recent_phone);
String title = getResources().getString(R.string.recent_tabs_this_device);
mDeviceLabel.setText(title);
setTimeLabelVisibility(View.GONE);
configureExpandedCollapsed(isExpanded);
}
/**
* Configures the view for a foreign session.
*
......
......@@ -164,9 +164,6 @@ public class RecentTabsManager implements AndroidSyncSettingsObserver, SignInSta
mSignInManager.addSignInStateObserver(this);
}
protected void updateCurrentlyOpenTabs() {
}
private void updateRecentlyClosedTabs() {
mRecentlyClosedTabs = mRecentlyClosedBridge.getRecentlyClosedTabs(
RECENTLY_CLOSED_MAX_TAB_COUNT);
......@@ -179,13 +176,6 @@ public class RecentTabsManager implements AndroidSyncSettingsObserver, SignInSta
}
}
/**
* @return Most up-to-date list of currently open tabs.
*/
public List<CurrentlyOpenTab> getCurrentlyOpenTabs() {
return null;
}
/**
* @return Most up-to-date list of foreign sessions.
*/
......@@ -270,49 +260,6 @@ public class RecentTabsManager implements AndroidSyncSettingsObserver, SignInSta
mUpdatedCallback = updatedCallback;
}
/**
* Sets the persistent expanded/collapsed state of the currently open tabs list.
*
* @param isCollapsed Whether the currently open tabs list is collapsed.
*/
public void setCurrentlyOpenTabsCollapsed(boolean isCollapsed) {
if (mIsDestroyed) return;
mNewTabPagePrefs.setCurrentlyOpenTabsCollapsed(isCollapsed);
}
/**
* Determine the expanded/collapsed state of the currently open tabs list.
*
* @return Whether the currently open tabs list is collapsed.
*/
public boolean isCurrentlyOpenTabsCollapsed() {
return mNewTabPagePrefs.getCurrentlyOpenTabsCollapsed();
}
/**
* Sets the state for showing all tabs in the currently open tabs list. This is intended to
* be overridden in extending classes and set to true when the user clicks the "More" button
* at the end of the list.
* @param showingAll Whether the currently open tabs list should start to show all.
*/
public void setCurrentlyOpenTabsShowAll(boolean showingAll) {
}
/**
* @return Whether the currently open tabs group shows all tabs. If it is not, only a limited
* number of tabs is shown with a "More" button at the end of the list to show all.
*/
public boolean isCurrentlyOpenTabsShowingAll() {
return false;
}
/**
* Closes the specified currently open tab.
* @param tab Information about the tab that should be closed.
*/
public void closeTab(CurrentlyOpenTab tab) {
}
/**
* Sets the persistent expanded/collapsed state of a foreign session list.
*
......
......@@ -35,7 +35,6 @@ import org.chromium.ui.base.DeviceFormFactor;
import org.chromium.ui.mojom.WindowOpenDisposition;
import java.util.ArrayList;
import java.util.List;
/**
* Row adapter for presenting recently closed tabs, synced tabs from other devices, the sync or
......@@ -202,106 +201,6 @@ public class RecentTabsRowAdapter extends BaseExpandableListAdapter {
}
}
/**
* A group containing all the tabs currently open on this device.
*/
class CurrentlyOpenTabsGroup extends Group {
private static final int NUM_DEFAULT_VISIBLE_TABS = 6;
private final List<CurrentlyOpenTab> mCurrentlyOpenTabs;
private final boolean mShowingAll;
public CurrentlyOpenTabsGroup(List<CurrentlyOpenTab> tabsList) {
mCurrentlyOpenTabs = tabsList;
mShowingAll = mRecentTabsManager.isCurrentlyOpenTabsShowingAll();
}
private boolean isMoreButton(int childPosition) {
return !mShowingAll && childPosition
== Math.min(NUM_DEFAULT_VISIBLE_TABS, mCurrentlyOpenTabs.size());
}
@Override
GroupType getGroupType() {
return GroupType.CONTENT;
}
@Override
int getChildrenCount() {
if (mShowingAll) return mCurrentlyOpenTabs.size();
return Math.min(NUM_DEFAULT_VISIBLE_TABS, mCurrentlyOpenTabs.size() - 1) + 1;
}
@Override
ChildType getChildType() {
return ChildType.DEFAULT_CONTENT;
}
@Override
CurrentlyOpenTab getChild(int childPosition) {
if (isMoreButton(childPosition)) return null;
return mCurrentlyOpenTabs.get(childPosition);
}
@Override
void configureChildView(int childPosition, ViewHolder viewHolder) {
if (isMoreButton(childPosition)) {
Resources resources = mActivity.getResources();
String text = resources.getString(R.string.recent_tabs_show_more);
viewHolder.textView.setText(text);
Drawable drawable = ApiCompatibilityUtils.getDrawable(
resources, R.drawable.more_horiz);
ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(
viewHolder.textView, drawable, null, null, null);
} else {
CurrentlyOpenTab openTab = getChild(childPosition);
viewHolder.textView.setText(TextUtils.isEmpty(openTab.getTitle()) ? openTab.getUrl()
: openTab.getTitle());
loadLocalFavicon(viewHolder, openTab.getUrl());
}
}
@Override
void configureGroupView(RecentTabsGroupView groupView, boolean isExpanded) {
groupView.configureForCurrentlyOpenTabs(isExpanded);
}
@Override
void setCollapsed(boolean isCollapsed) {
mRecentTabsManager.setCurrentlyOpenTabsCollapsed(isCollapsed);
}
@Override
boolean isCollapsed() {
return mRecentTabsManager.isCurrentlyOpenTabsCollapsed();
}
@Override
boolean onChildClick(int childPosition) {
if (isMoreButton(childPosition)) {
mRecentTabsManager.setCurrentlyOpenTabsShowAll(true);
} else {
getChild(childPosition).getRunnable().run();
}
return true;
}
@Override
void onCreateContextMenuForChild(final int childPosition, ContextMenu menu,
Activity activity) {
if (isMoreButton(childPosition)) return;
OnMenuItemClickListener listener = new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
mRecentTabsManager.closeTab(getChild(childPosition));
return true;
}
};
menu.add(R.string.close_tab).setOnMenuItemClickListener(listener);
}
}
/**
* A group containing all the tabs associated with a foreign session from a synced device.
*/
......@@ -881,10 +780,6 @@ public class RecentTabsRowAdapter extends BaseExpandableListAdapter {
@Override
public void notifyDataSetChanged() {
mGroups.clear();
List<CurrentlyOpenTab> tabList = mRecentTabsManager.getCurrentlyOpenTabs();
if (tabList != null && !tabList.isEmpty()) {
addGroup(new CurrentlyOpenTabsGroup(tabList));
}
addGroup(mRecentlyClosedTabsGroup);
for (ForeignSession session : mRecentTabsManager.getForeignSessions()) {
if (!mHasForeignDataRecorded) {
......
......@@ -1978,9 +1978,6 @@ To obtain new licenses, connect to the internet and play your downloaded content
<message name="IDS_RECENT_TABS_HIDE_MENU_OPTION" desc="Context menu option to remove a foreign session.">
Hide for now
</message>
<message name="IDS_RECENT_TABS_THIS_DEVICE" desc="Header shown above the list of tabs currently open on this device.">
This device
</message>
<message name="IDS_RECENT_TABS_SHOW_MORE" desc="Text shown on the button that shows all the currently open tabs in recent tabs page.">
More
</message>
......
......@@ -555,7 +555,6 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/notifications/WebApkNotificationClient.java",
"java/src/org/chromium/chrome/browser/ntp/ContentSuggestionsNotificationHelper.java",
"java/src/org/chromium/chrome/browser/ntp/ContextMenuManager.java",
"java/src/org/chromium/chrome/browser/ntp/CurrentlyOpenTab.java",
"java/src/org/chromium/chrome/browser/ntp/DisplayStyleObserver.java",
"java/src/org/chromium/chrome/browser/ntp/ForeignSessionHelper.java",
"java/src/org/chromium/chrome/browser/ntp/IncognitoNewTabPage.java",
......
......@@ -36,21 +36,6 @@ void NewTabPagePrefs::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) {
NewTabPagePrefs::~NewTabPagePrefs() {
}
jboolean NewTabPagePrefs::GetCurrentlyOpenTabsCollapsed(
JNIEnv* env,
const JavaParamRef<jobject>& obj) {
PrefService* prefs = profile_->GetPrefs();
return prefs->GetBoolean(prefs::kNtpCollapsedCurrentlyOpenTabs);
}
void NewTabPagePrefs::SetCurrentlyOpenTabsCollapsed(
JNIEnv* env,
const JavaParamRef<jobject>& obj,
jboolean is_collapsed) {
PrefService* prefs = profile_->GetPrefs();
prefs->SetBoolean(prefs::kNtpCollapsedCurrentlyOpenTabs, is_collapsed);
}
jboolean NewTabPagePrefs::GetSnapshotDocumentCollapsed(
JNIEnv* env,
const JavaParamRef<jobject>& obj) {
......@@ -120,7 +105,6 @@ void NewTabPagePrefs::SetForeignSessionCollapsed(
// static
void NewTabPagePrefs::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(prefs::kNtpCollapsedCurrentlyOpenTabs, false);
registry->RegisterBooleanPref(prefs::kNtpCollapsedSnapshotDocument, false);
registry->RegisterBooleanPref(prefs::kNtpCollapsedRecentlyClosedTabs, false);
registry->RegisterBooleanPref(prefs::kNtpCollapsedSyncPromo, false);
......
......@@ -16,14 +16,6 @@ class NewTabPagePrefs {
explicit NewTabPagePrefs(Profile* profile);
void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
jboolean GetCurrentlyOpenTabsCollapsed(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
void SetCurrentlyOpenTabsCollapsed(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
jboolean is_collapsed);
jboolean GetSnapshotDocumentCollapsed(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
......
......@@ -1522,11 +1522,6 @@ const char kDisablePluginFinder[] = "plugins.disable_plugin_finder";
// Customized app page names that appear on the New Tab Page.
const char kNtpAppPageNames[] = "ntp.app_page_names";
#if BUILDFLAG(ANDROID_JAVA_UI)
// Keeps track of currently open tabs collapsed state in the Other Devices menu.
const char kNtpCollapsedCurrentlyOpenTabs[] = "ntp.collapsed_open_tabs";
#endif
// Keeps track of which sessions are collapsed in the Other Devices menu.
const char kNtpCollapsedForeignSessions[] = "ntp.collapsed_foreign_sessions";
......
......@@ -550,9 +550,6 @@ extern const char kDisableExtensions[];
extern const char kDisablePluginFinder[];
extern const char kNtpAppPageNames[];
#if BUILDFLAG(ANDROID_JAVA_UI)
extern const char kNtpCollapsedCurrentlyOpenTabs[];
#endif
extern const char kNtpCollapsedForeignSessions[];
#if BUILDFLAG(ANDROID_JAVA_UI)
extern const char kNtpCollapsedRecentlyClosedTabs[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment