-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Android Tab Restore] HistoricalTabSaver bulk closure
Expand HistoricalTabSaver to support groups and bulk closures. Also convert HistoricalTabSaver to an interface with the implementation HistoricalTabSaverImpl - this will make testing easier in a follow up CL. Once CL [1] lands we just need to hook this up to a didCloseTabs observer that knows about groups and saving should be working. This also implements basic reading of Group/Bulk/Tab entries for RecentlyClosedBridge which will be required to for the UI, but was helpful for testing. [1] https://chromium-review.googlesource.com/c/chromium/src/+/3514563 Bug: 1306278, 1307345 Change-Id: I50e4f98570b65391190f36e226efe1683534fe7a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3550461 Reviewed-by: Fred Mello <fredmello@chromium.org> Reviewed-by: David Trainor <dtrainor@chromium.org> Commit-Queue: Calder Kitagawa <ckitagawa@chromium.org> Cr-Commit-Position: refs/heads/main@{#989013}
- Loading branch information
1 parent
0fc0ef7
commit e445dc5
Showing
29 changed files
with
1,595 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
chrome/android/java/src/org/chromium/chrome/browser/ntp/RecentlyClosedBulkEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2022 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; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Represents a recent closure of multiple tabs and groups (AKA Window) from TabRestoreService. | ||
*/ | ||
public class RecentlyClosedBulkEvent extends RecentlyClosedEntry { | ||
private final List<RecentlyClosedTab> mTabs = new ArrayList<>(); | ||
private final Map<String, String> mGroups = new HashMap<>(); | ||
|
||
public RecentlyClosedBulkEvent(int sessionId, long timestamp) { | ||
super(sessionId, timestamp); | ||
} | ||
|
||
/** | ||
* @return list of {@link RecentlyClosedTab} in this event. | ||
*/ | ||
public List<RecentlyClosedTab> getTabs() { | ||
return mTabs; | ||
} | ||
|
||
/** | ||
* @return map of {@link RecentlyClosedTab#getGroupId()} to group titles. | ||
*/ | ||
public Map<String, String> getGroupIdToTitleMap() { | ||
return mGroups; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
chrome/android/java/src/org/chromium/chrome/browser/ntp/RecentlyClosedEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2022 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; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* Represents a recently closed entry from TabRestoreService. | ||
*/ | ||
public class RecentlyClosedEntry { | ||
private final int mSessionId; | ||
private final Date mDate; | ||
|
||
/** | ||
* @param sessionId The Session ID of this entry. | ||
* @param timestamp The milliseconds since the Unix Epoch this entry was created. | ||
*/ | ||
protected RecentlyClosedEntry(int sessionId, long timestamp) { | ||
mSessionId = sessionId; | ||
mDate = new Date(timestamp); | ||
} | ||
|
||
/** | ||
* @return the Session ID of the entry in TabRestoreService. | ||
*/ | ||
public int getSessionId() { | ||
return mSessionId; | ||
} | ||
|
||
/** | ||
* @return the {@link Date} when this entry was created. | ||
*/ | ||
public Date getDate() { | ||
return mDate; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
chrome/android/java/src/org/chromium/chrome/browser/ntp/RecentlyClosedGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2022 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; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Represents a recently closed group from TabRestoreService. | ||
*/ | ||
public class RecentlyClosedGroup extends RecentlyClosedEntry { | ||
private final String mTitle; | ||
private final List<RecentlyClosedTab> mTabs = new ArrayList<>(); | ||
|
||
public RecentlyClosedGroup(int sessionId, long timestamp, String title) { | ||
super(sessionId, timestamp); | ||
mTitle = title; | ||
} | ||
|
||
/** | ||
* @return title of the group this may be an empty string if the default title was used when | ||
* saving. | ||
*/ | ||
public String getTitle() { | ||
return mTitle; | ||
} | ||
|
||
/** | ||
* @return the list of tabs for this group. | ||
*/ | ||
public List<RecentlyClosedTab> getTabs() { | ||
return mTabs; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.