Commit 06f66670 authored by jcampan@chromium.org's avatar jcampan@chromium.org

Reverting 14948.

Broke the Mac build.

TBR=ben
Review URL: http://codereview.chromium.org/99224

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14949 0039d316-1c4b-4281-b951-d872f2087c98
parent 1cfe52b3
......@@ -1525,15 +1525,6 @@ bool Browser::RunUnloadListenerBeforeClosing(TabContents* contents) {
return false;
}
bool Browser::CanCloseContentsAt(int index) {
if (tabstrip_model_.count() > 1)
return true;
// We are closing the last tab for this browser. Make sure to check for
// in-progress downloads.
// Note that the next call when it returns false will ask the user for
// confirmation before closing the browser if the user decides so.
return CanCloseWithInProgressDownloads();
}
///////////////////////////////////////////////////////////////////////////////
// Browser, TabStripModelObserver implementation:
......
......@@ -432,7 +432,6 @@ class Browser : public TabStripModelDelegate,
virtual void CloseFrameAfterDragSession();
virtual void CreateHistoricalTab(TabContents* contents);
virtual bool RunUnloadListenerBeforeClosing(TabContents* contents);
virtual bool CanCloseContentsAt(int index);
// Overridden from TabStripModelObserver:
virtual void TabInsertedAt(TabContents* contents,
......
......@@ -515,9 +515,6 @@ bool TabStripModel::IsNewTabAtEndOfTabStrip(TabContents* contents) const {
bool TabStripModel::InternalCloseTabContentsAt(int index,
bool create_historical_tab) {
if (!delegate_->CanCloseContentsAt(index))
return false;
TabContents* detached_contents = GetContentsAt(index);
if (delegate_->RunUnloadListenerBeforeClosing(detached_contents))
......
......@@ -109,7 +109,7 @@ class TabStripModelDelegate {
virtual TabContents* AddBlankTab(bool foreground) = 0;
virtual TabContents* AddBlankTabAt(int index, bool foreground) = 0;
// Asks for a new TabStripModel to be created and the given tab contents to
// Ask for a new TabStripModel to be created and the given tab contents to
// be added to it. Its size and position are reflected in |window_bounds|.
// If |dock_info|'s type is other than NONE, the newly created window should
// be docked as identified by |dock_info|. Returns the Browser object
......@@ -128,7 +128,7 @@ class TabStripModelDelegate {
TAB_TEAROFF_ACTION = 2
};
// Determines what drag actions are possible for the specified strip.
// Determine what drag actions are possible for the specified strip.
virtual int GetDragActions() const = 0;
// Creates an appropriate TabContents for the given URL. This is handled by
......@@ -144,10 +144,10 @@ class TabStripModelDelegate {
bool defer_load,
SiteInstance* instance) const = 0;
// Returns whether some contents can be duplicated.
// Return whether some contents can be duplicated.
virtual bool CanDuplicateContentsAt(int index) = 0;
// Duplicates the contents at the provided index and places it into its own
// Duplicate the contents at the provided index and places it into its own
// window.
virtual void DuplicateContentsAt(int index) = 0;
......@@ -171,9 +171,6 @@ class TabStripModelDelegate {
// Restores the last closed tab if CanRestoreTab would return true.
virtual void RestoreTab() = 0;
// Returns whether some contents can be closed.
virtual bool CanCloseContentsAt(int index) = 0;
};
////////////////////////////////////////////////////////////////////////////////
......@@ -257,9 +254,8 @@ class TabStripModel : public NotificationObserver {
// Closes the TabContents at the specified index. This causes the TabContents
// to be destroyed, but it may not happen immediately (e.g. if it's a
// WebContents).
// Returns true if the TabContents was closed immediately, false if it was not
// closed (we may be waiting for a response from an onunload handler, or
// waiting for the user to confirm closure).
// Returns true if the TabContents was closed immediately, false if we are
// waiting for a response from an onunload handler.
bool CloseTabContentsAt(int index) {
return InternalCloseTabContentsAt(index, true);
}
......
......@@ -22,11 +22,9 @@
class TabStripDummyDelegate : public TabStripModelDelegate {
public:
explicit TabStripDummyDelegate(TabContents* dummy)
: dummy_contents_(dummy), can_close_(true) {}
: dummy_contents_(dummy) {}
virtual ~TabStripDummyDelegate() {}
void set_can_close(bool value) { can_close_ = value; }
// Overridden from TabStripModelDelegate:
virtual TabContents* AddBlankTab(bool foreground) { return NULL; }
virtual TabContents* AddBlankTabAt(int index, bool foreground) {
......@@ -58,16 +56,12 @@ class TabStripDummyDelegate : public TabStripModelDelegate {
}
virtual bool CanRestoreTab() { return false; }
virtual void RestoreTab() {}
virtual bool CanCloseContentsAt(int index) { return can_close_ ; }
private:
// A dummy TabContents we give to callers that expect us to actually build a
// Destinations tab for them.
TabContents* dummy_contents_;
// Whether tabs can be closed.
bool can_close_;
DISALLOW_EVIL_CONSTRUCTORS(TabStripDummyDelegate);
};
......@@ -317,15 +311,7 @@ TEST_F(TabStripModelTest, TestBasicAPI) {
// Test CloseTabContentsAt
{
// Let's test nothing happens when the delegate veto the close.
delegate.set_can_close(false);
EXPECT_FALSE(tabstrip.CloseTabContentsAt(2));
EXPECT_EQ(3, tabstrip.count());
EXPECT_EQ(0, observer.GetStateCount());
// Now let's close for real.
delegate.set_can_close(true);
EXPECT_TRUE(tabstrip.CloseTabContentsAt(2));
tabstrip.CloseTabContentsAt(2);
EXPECT_EQ(2, tabstrip.count());
EXPECT_EQ(3, observer.GetStateCount());
......
......@@ -904,8 +904,6 @@ void TabStrip::CloseTab(Tab* tab) {
available_width_for_tabs_ = GetAvailableWidthForTabs(last_tab);
resize_layout_scheduled_ = true;
AddMessageLoopObserver();
// Note that the next call might not close the tab (because of unload
// hanlders or if the delegate veto the close).
model_->CloseTabContentsAt(tab_index);
}
}
......
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