OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.tabmodel; | 5 package org.chromium.chrome.browser.tabmodel; |
6 | 6 |
7 import org.chromium.base.ObserverList; | 7 import org.chromium.base.ObserverList; |
8 import org.chromium.base.TraceEvent; | 8 import org.chromium.base.TraceEvent; |
9 import org.chromium.chrome.browser.Tab; | 9 import org.chromium.chrome.browser.Tab; |
10 import org.chromium.chrome.browser.util.MathUtils; | 10 import org.chromium.chrome.browser.util.MathUtils; |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
446 // TODO(dtrainor): Update the list of undoable tabs instead of committin g it. | 446 // TODO(dtrainor): Update the list of undoable tabs instead of committin g it. |
447 if (!canUndo) commitAllTabClosures(); | 447 if (!canUndo) commitAllTabClosures(); |
448 | 448 |
449 // Cancel any media currently playing. | 449 // Cancel any media currently playing. |
450 if (canUndo) { | 450 if (canUndo) { |
451 WebContents webContents = tab.getWebContents(); | 451 WebContents webContents = tab.getWebContents(); |
452 if (webContents != null) webContents.releaseMediaPlayers(); | 452 if (webContents != null) webContents.releaseMediaPlayers(); |
453 } | 453 } |
454 | 454 |
455 mTabs.remove(tab); | 455 mTabs.remove(tab); |
456 for (TabModelObserver obs : mObservers) obs.didCloseTab(tab); | |
Bernhard Bauer
2014/11/19 09:57:34
Why this change? didCloseTab() means that closing
divya.bansal
2014/11/19 10:04:24
Here after tab is removed didclosetab is called.If
Bernhard Bauer
2014/11/19 10:06:45
Right, but you can't just go ahead and change the
divya.bansal
2014/11/19 10:09:39
willCloseTab() is set even before tab is removed i
Bernhard Bauer
2014/11/19 10:13:53
Would it work if you call createNewTab() if the co
divya.bansal
2014/11/19 12:07:57
Done.
| |
456 | 457 |
457 boolean nextIsIncognito = nextTab == null ? false : nextTab.isIncognito( ); | 458 boolean nextIsIncognito = nextTab == null ? false : nextTab.isIncognito( ); |
458 int nextTabId = nextTab == null ? Tab.INVALID_TAB_ID : nextTab.getId(); | 459 int nextTabId = nextTab == null ? Tab.INVALID_TAB_ID : nextTab.getId(); |
459 int nextTabIndex = nextTab == null ? INVALID_TAB_INDEX : TabModelUtils.g etTabIndexById( | 460 int nextTabIndex = nextTab == null ? INVALID_TAB_INDEX : TabModelUtils.g etTabIndexById( |
460 mModelDelegate.getModel(nextIsIncognito), nextTabId); | 461 mModelDelegate.getModel(nextIsIncognito), nextTabId); |
461 | 462 |
462 if (nextTab != currentTab) { | 463 if (nextTab != currentTab) { |
463 if (nextIsIncognito != isIncognito()) mIndex = indexOf(adjacentTab); | 464 if (nextIsIncognito != isIncognito()) mIndex = indexOf(adjacentTab); |
464 | 465 |
465 TabModel nextModel = mModelDelegate.getModel(nextIsIncognito); | 466 TabModel nextModel = mModelDelegate.getModel(nextIsIncognito); |
466 nextModel.setIndex(nextTabIndex, | 467 nextModel.setIndex(nextTabIndex, |
467 uponExit ? TabSelectionType.FROM_EXIT : TabSelectionType.FRO M_CLOSE); | 468 uponExit ? TabSelectionType.FROM_EXIT : TabSelectionType.FRO M_CLOSE); |
468 } else { | 469 } else { |
469 mIndex = nextTabIndex; | 470 mIndex = nextTabIndex; |
470 } | 471 } |
471 | 472 |
472 if (!canUndo) mRewoundList.resetRewoundState(); | 473 if (!canUndo) mRewoundList.resetRewoundState(); |
473 } | 474 } |
474 | 475 |
475 /** | 476 /** |
476 * Actually closes and cleans up {@code tab}. | 477 * Actually closes and cleans up {@code tab}. |
477 * @param tab The {@link Tab} to close. | 478 * @param tab The {@link Tab} to close. |
478 */ | 479 */ |
479 private void finalizeTabClosure(Tab tab) { | 480 private void finalizeTabClosure(Tab tab) { |
480 for (TabModelObserver obs : mObservers) obs.didCloseTab(tab); | |
481 tab.destroy(); | 481 tab.destroy(); |
482 } | 482 } |
483 | 483 |
484 private class RewoundList implements TabList { | 484 private class RewoundList implements TabList { |
485 /** | 485 /** |
486 * A list of {@link Tab}s that represents the completely rewound list (i f all | 486 * A list of {@link Tab}s that represents the completely rewound list (i f all |
487 * rewindable closes were undone). If there are no possible rewindable c loses this list | 487 * rewindable closes were undone). If there are no possible rewindable c loses this list |
488 * should match {@link #mTabs}. | 488 * should match {@link #mTabs}. |
489 */ | 489 */ |
490 private final List<Tab> mRewoundTabs = new ArrayList<Tab>(); | 490 private final List<Tab> mRewoundTabs = new ArrayList<Tab>(); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
615 @Override | 615 @Override |
616 public int index() { | 616 public int index() { |
617 return mIndex; | 617 return mIndex; |
618 } | 618 } |
619 | 619 |
620 @Override | 620 @Override |
621 protected boolean isSessionRestoreInProgress() { | 621 protected boolean isSessionRestoreInProgress() { |
622 return mModelDelegate.isSessionRestoreInProgress(); | 622 return mModelDelegate.isSessionRestoreInProgress(); |
623 } | 623 } |
624 } | 624 } |
OLD | NEW |