Skip to content

Commit

Permalink
Fix several crashes on the recent tabs page.
Browse files Browse the repository at this point in the history
User interactions can trigger events in the RecentTabsManager even after
the manager has been destroyed. For example, if the user taps on the
page or selects an item from a context menu while the recent tabs page
is navigating or being closed, the touch event can be delivered after
the page has already been destroyed.

To fix this, we ignore any requests to change state in the manager after
the manager has been destroyed.

BUG=595990

Review URL: https://codereview.chromium.org/1818903003

Cr-Commit-Position: refs/heads/master@{#382358}
(cherry picked from commit eaac807)

Review URL: https://codereview.chromium.org/1820003002 .

Cr-Commit-Position: refs/branch-heads/2661@{crosswalk-project#325}
Cr-Branched-From: ef6f6ae-refs/heads/master@{#378081}
  • Loading branch information
newtonallen3 committed Mar 21, 2016
1 parent 7f4a99d commit cdf06d9
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ public List<RecentlyClosedTab> getRecentlyClosedTabs() {
*/
public void openForeignSessionTab(ForeignSession session, ForeignSessionTab tab,
int windowDisposition) {
if (mIsDestroyed) return;
NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_FOREIGN_SESSION);
mForeignSessionHelper.openForeignSessionTab(mTab, session, tab, windowDisposition);
}
Expand All @@ -235,6 +236,7 @@ public void openForeignSessionTab(ForeignSession session, ForeignSessionTab tab,
* be restored into the current tab or a new tab.
*/
public void openRecentlyClosedTab(RecentlyClosedTab tab, int windowDisposition) {
if (mIsDestroyed) return;
NewTabPageUma.recordAction(NewTabPageUma.ACTION_OPENED_RECENTLY_CLOSED_ENTRY);
mRecentlyClosedBridge.openRecentlyClosedTab(mTab, tab, windowDisposition);
}
Expand All @@ -243,6 +245,7 @@ public void openRecentlyClosedTab(RecentlyClosedTab tab, int windowDisposition)
* Opens the history page.
*/
public void openHistoryPage() {
if (mIsDestroyed) return;
mTab.loadUrl(new LoadUrlParams(UrlConstants.HISTORY_URL));
StartupMetrics.getInstance().recordOpenedHistory();
}
Expand Down Expand Up @@ -287,6 +290,7 @@ public void setUpdatedCallback(UpdatedCallback updatedCallback) {
* @param isCollapsed Whether the currently open tabs list is collapsed.
*/
public void setCurrentlyOpenTabsCollapsed(boolean isCollapsed) {
if (mIsDestroyed) return;
mNewTabPagePrefs.setCurrentlyOpenTabsCollapsed(isCollapsed);
}

Expand Down Expand Up @@ -330,6 +334,7 @@ public void closeTab(CurrentlyOpenTab tab) {
* @param isCollapsed Whether the session is collapsed or expanded.
*/
public void setForeignSessionCollapsed(ForeignSession session, boolean isCollapsed) {
if (mIsDestroyed) return;
mNewTabPagePrefs.setForeignSessionCollapsed(session, isCollapsed);
}

Expand All @@ -350,6 +355,7 @@ public boolean getForeignSessionCollapsed(ForeignSession session) {
* @param isCollapsed Whether the recently closed tabs list is collapsed.
*/
public void setRecentlyClosedTabsCollapsed(boolean isCollapsed) {
if (mIsDestroyed) return;
mNewTabPagePrefs.setRecentlyClosedTabsCollapsed(isCollapsed);
}

Expand All @@ -370,13 +376,15 @@ public boolean isRecentlyClosedTabsCollapsed() {
* @param session Session to be deleted.
*/
public void deleteForeignSession(ForeignSession session) {
if (mIsDestroyed) return;
mForeignSessionHelper.deleteForeignSession(session);
}

/**
* Clears the list of recently closed tabs.
*/
public void clearRecentlyClosedTabs() {
if (mIsDestroyed) return;
mRecentlyClosedBridge.clearRecentlyClosedTabs();
}

Expand Down Expand Up @@ -414,6 +422,7 @@ public void setSigninPromoDeclined() {
* @param isCollapsed Whether the sync promo is collapsed.
*/
public void setSyncPromoCollapsed(boolean isCollapsed) {
if (mIsDestroyed) return;
mNewTabPagePrefs.setSyncPromoCollapsed(isCollapsed);
}

Expand Down

0 comments on commit cdf06d9

Please sign in to comment.