diff options
46 files changed, 102 insertions, 740 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 393d50a..b585865 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -2602,7 +2602,8 @@ void Browser::TabMoved(TabContents* contents, } void Browser::TabReplacedAt(TabContents* old_contents, - TabContents* new_contents, int index) { + TabContents* new_contents, + int index) { TabDetachedAtImpl(old_contents, index, DETACH_TYPE_REPLACE); TabInsertedAt(new_contents, index, (index == tab_handler_->GetTabStripModel()->selected_index())); @@ -3261,9 +3262,7 @@ void Browser::CommitMatchPreview(TabContents* preview_contents) { tab_contents->controller()); // TabStripModel takes ownership of preview_contents. tab_handler_->GetTabStripModel()->ReplaceTabContentsAt( - index, - preview_contents, - TabStripModelObserver::REPLACE_MATCH_PREVIEW); + index, preview_contents); } void Browser::SetSuggestedText(const string16& text) { diff --git a/chrome/browser/browser_browsertest.cc b/chrome/browser/browser_browsertest.cc index 1bd9a14..e63eb84 100644 --- a/chrome/browser/browser_browsertest.cc +++ b/chrome/browser/browser_browsertest.cc @@ -101,40 +101,6 @@ class MockTabStripModelObserver : public TabStripModelObserver { } // namespace class BrowserTest : public ExtensionBrowserTest { - public: - // Used by phantom tab tests. Creates two tabs, pins the first and makes it - // a phantom tab (by closing it). - void PhantomTabTest() { - ASSERT_TRUE(test_server()->Start()); - host_resolver()->AddRule("www.example.com", "127.0.0.1"); - GURL url(test_server()->GetURL("empty.html")); - TabStripModel* model = browser()->tabstrip_model(); - - ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); - - Extension* extension_app = GetExtension(); - - ui_test_utils::NavigateToURL(browser(), url); - - TabContents* app_contents = new TabContents(browser()->profile(), NULL, - MSG_ROUTING_NONE, NULL, NULL); - app_contents->SetExtensionApp(extension_app); - - model->AddTabContents(app_contents, 0, 0, TabStripModel::ADD_NONE); - model->SetTabPinned(0, true); - ui_test_utils::NavigateToURL(browser(), url); - - // Close the first, which should make it a phantom. - model->CloseTabContentsAt(0, TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); - - // There should still be two tabs. - ASSERT_EQ(2, browser()->tab_count()); - // The first tab should be a phantom. - EXPECT_TRUE(model->IsPhantomTab(0)); - // And the tab contents of the first tab should have changed. - EXPECT_TRUE(model->GetTabContentsAt(0) != app_contents); - } - protected: // In RTL locales wrap the page title with RTL embedding characters so that it // matches the value returned by GetWindowTitle(). @@ -155,7 +121,7 @@ class BrowserTest : public ExtensionBrowserTest { #endif } - // Returns the app extension installed by PhantomTabTest. + // Returns the app extension aptly named "App Test". Extension* GetExtension() { const ExtensionList* extensions = browser()->profile()->GetExtensionsService()->extensions(); @@ -418,35 +384,6 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, FaviconChange) { EXPECT_EQ(expected_favicon_url.spec(), entry->favicon().url().spec()); } -// TODO(sky): get these to run on a Mac. -#if !defined(OS_MACOSX) -IN_PROC_BROWSER_TEST_F(BrowserTest, PhantomTab) { - if (!browser_defaults::kPhantomTabsEnabled) - return; - - PhantomTabTest(); -} - -IN_PROC_BROWSER_TEST_F(BrowserTest, RevivePhantomTab) { - if (!browser_defaults::kPhantomTabsEnabled) - return; - - PhantomTabTest(); - - if (HasFatalFailure()) - return; - - TabStripModel* model = browser()->tabstrip_model(); - - // Revive the phantom tab by selecting it. - browser()->SelectTabContentsAt(0, true); - - // There should still be two tabs. - ASSERT_EQ(2, browser()->tab_count()); - // The first tab should no longer be a phantom. - EXPECT_FALSE(model->IsPhantomTab(0)); -} - // Makes sure TabClosing is sent when uninstalling an extension that is an app // tab. IN_PROC_BROWSER_TEST_F(BrowserTest, TabClosingWhenRemovingExtension) { @@ -483,20 +420,6 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, TabClosingWhenRemovingExtension) { ASSERT_EQ(1, browser()->tab_count()); } -IN_PROC_BROWSER_TEST_F(BrowserTest, AppTabRemovedWhenExtensionUninstalled) { - if (!browser_defaults::kPhantomTabsEnabled) - return; - - PhantomTabTest(); - - Extension* extension = GetExtension(); - UninstallExtension(extension->id()); - - // The uninstall should have removed the tab. - ASSERT_EQ(1, browser()->tab_count()); -} -#endif // !defined(OS_MACOSX) - #if defined(OS_WIN) // http://crbug.com/46198. On XP/Vista, the failure rate is 5 ~ 6%. #define MAYBE_PageLanguageDetection FLAKY_PageLanguageDetection diff --git a/chrome/browser/chromeos/tab_closeable_state_watcher.cc b/chrome/browser/chromeos/tab_closeable_state_watcher.cc index 7b7f2cb..25bbf6e 100644 --- a/chrome/browser/chromeos/tab_closeable_state_watcher.cc +++ b/chrome/browser/chromeos/tab_closeable_state_watcher.cc @@ -43,13 +43,9 @@ void TabCloseableStateWatcher::TabStripWatcher::TabInsertedAt( void TabCloseableStateWatcher::TabStripWatcher::TabClosingAt( TabContents* tab_contents, int index) { TabStripModel* tabstrip = browser_->tabstrip_model(); - if ((!browser_defaults::kPhantomTabsEnabled && tabstrip->count() == 1) || - (browser_defaults::kPhantomTabsEnabled && - tabstrip->GetNonPhantomTabCount() == 1 && - !tabstrip->IsTabPinned(index))) { - // Closing last tab. + // Check if the last tab is closing. + if (tabstrip->count() == 1) main_watcher_->OnTabStripChanged(browser_, true); - } } void TabCloseableStateWatcher::TabStripWatcher::TabDetachedAt( @@ -194,12 +190,9 @@ void TabCloseableStateWatcher::CheckAndUpdateState( new_can_close = true; } else { TabStripModel* tabstrip_model = browser_to_check->tabstrip_model(); - // If NTP is the only non-phantom tab, it's not closeable. - if (tabstrip_model->GetNonPhantomTabCount() == 1) { - int first_non_phantom_tab = tabstrip_model->IndexOfFirstNonPhantomTab(); - new_can_close = - tabstrip_model->GetTabContentsAt(first_non_phantom_tab)->GetURL() != - GURL(chrome::kChromeUINewTabURL); // Tab is not NewTabPage. + if (tabstrip_model->count() == 1) { + new_can_close = tabstrip_model->GetTabContentsAt(0)->GetURL() != + GURL(chrome::kChromeUINewTabURL); // Tab is not NewTabPage. } else { new_can_close = true; } diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index d33c0ca..ff95a04 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -407,8 +407,7 @@ // from this method. - (void)windowWillClose:(NSNotification*)notification { DCHECK_EQ([notification object], [self window]); - DCHECK(!browser_->tabstrip_model()->HasNonPhantomTabs() || - !browser_->tabstrip_model()->count()); + DCHECK(browser_->tabstrip_model()->empty()); [savedRegularWindow_ close]; // We delete statusBubble here because we need to kill off the dependency // that its window has on our window before our window goes away. @@ -458,7 +457,7 @@ // have to save the window position before we call orderOut:. [self saveWindowPositionIfNeeded]; - if (browser_->tabstrip_model()->HasNonPhantomTabs()) { + if (!browser_->tabstrip_model()->empty()) { // Tab strip isn't empty. Hide the frame (so it appears to have closed // immediately) and close all the tabs, allowing the renderers to shut // down. When the tab strip is empty we'll be called back again. @@ -1321,12 +1320,12 @@ } - (NSInteger)numberOfTabs { - // count() includes pinned tabs (both live and phantom). + // count() includes pinned tabs. return browser_->tabstrip_model()->count(); } - (BOOL)hasLiveTabs { - return browser_->tabstrip_model()->HasNonPhantomTabs(); + return !browser_->tabstrip_model()->empty(); } - (NSString*)selectedTabTitle { diff --git a/chrome/browser/cocoa/tab_controller.h b/chrome/browser/cocoa/tab_controller.h index 02190a7..5a032ba 100644 --- a/chrome/browser/cocoa/tab_controller.h +++ b/chrome/browser/cocoa/tab_controller.h @@ -48,7 +48,6 @@ class MenuDelegate; BOOL app_; BOOL mini_; BOOL pinned_; - BOOL phantom_; BOOL selected_; TabLoadingState loadingState_; CGFloat iconTitleXOffset_; // between left edges of icon and title @@ -65,7 +64,6 @@ class MenuDelegate; @property(assign, nonatomic) SEL action; @property(assign, nonatomic) BOOL app; @property(assign, nonatomic) BOOL mini; -@property(assign, nonatomic) BOOL phantom; @property(assign, nonatomic) BOOL pinned; @property(assign, nonatomic) BOOL selected; @property(assign, nonatomic) id target; diff --git a/chrome/browser/cocoa/tab_controller.mm b/chrome/browser/cocoa/tab_controller.mm index 9e5403c..6c607ad 100644 --- a/chrome/browser/cocoa/tab_controller.mm +++ b/chrome/browser/cocoa/tab_controller.mm @@ -19,7 +19,6 @@ @synthesize app = app_; @synthesize loadingState = loadingState_; @synthesize mini = mini_; -@synthesize phantom = phantom_; @synthesize pinned = pinned_; @synthesize target = target_; diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm index e7fe84f..3c0e819 100644 --- a/chrome/browser/cocoa/tab_strip_controller.mm +++ b/chrome/browser/cocoa/tab_strip_controller.mm @@ -1036,10 +1036,6 @@ private: [oldController willBecomeUnselectedTab]; oldContents->view()->StoreFocus(); oldContents->WasHidden(); - // If the selection changed because the tab was made phantom, update the - // Cocoa side of the state. - TabController* tabController = [tabArray_ objectAtIndex:oldIndex]; - [tabController setPhantom:tabStripModel_->IsPhantomTab(oldModelIndex)]; } } @@ -1218,15 +1214,8 @@ private: // Take closing tabs into account. NSInteger index = [self indexFromModelIndex:modelIndex]; - TabController* tabController = [tabArray_ objectAtIndex:index]; - // Since the tab is loading, it cannot be phantom any more. - if ([tabController phantom]) { - [tabController setPhantom:NO]; - [[tabController view] setNeedsDisplay:YES]; - } - bool oldHasIcon = [tabController iconView] != nil; bool newHasIcon = contents->ShouldDisplayFavIcon() || tabStripModel_->IsMiniTab(modelIndex); // Always show icon if mini. @@ -1300,11 +1289,6 @@ private: if (change != TabStripModelObserver::LOADING_ONLY) [self setTabTitle:tabController withContents:contents]; - // See if the change was to/from phantom. - bool isPhantom = tabStripModel_->IsPhantomTab(modelIndex); - if (isPhantom != [tabController phantom]) - [tabController setPhantom:isPhantom]; - [self updateFavIconForContents:contents atIndex:modelIndex]; TabContentsController* updatedController = diff --git a/chrome/browser/cocoa/tab_view.mm b/chrome/browser/cocoa/tab_view.mm index e2d7d49..c9674e7 100644 --- a/chrome/browser/cocoa/tab_view.mm +++ b/chrome/browser/cocoa/tab_view.mm @@ -619,11 +619,6 @@ const CGFloat kRapidCloseDist = 2.5; } - (void)drawRect:(NSRect)dirtyRect { - // If this tab is phantom, do not draw the tab background itself. The only UI - // element that will represent this tab is the favicon. - if ([controller_ phantom]) - return; - NSGraphicsContext* context = [NSGraphicsContext currentContext]; [context saveGraphicsState]; diff --git a/chrome/browser/cocoa/tab_window_controller.h b/chrome/browser/cocoa/tab_window_controller.h index ad0d5b7..b501548 100644 --- a/chrome/browser/cocoa/tab_window_controller.h +++ b/chrome/browser/cocoa/tab_window_controller.h @@ -130,8 +130,8 @@ - (NSInteger)numberOfTabs; // YES if there are tabs in the tab strip which have content, allowing for -// the notion of tabs in the tab strip that are placeholders, or phantoms, but -// currently have no content. +// the notion of tabs in the tab strip that are placeholders but currently have +// no content. - (BOOL)hasLiveTabs; // Return the view of the selected tab. diff --git a/chrome/browser/defaults.cc b/chrome/browser/defaults.cc index f985c5f..48ad842 100644 --- a/chrome/browser/defaults.cc +++ b/chrome/browser/defaults.cc @@ -80,8 +80,6 @@ const bool kBrowserAliveWithNoWindows = true; const bool kBrowserAliveWithNoWindows = false; #endif -const bool kPhantomTabsEnabled = false; - bool bookmarks_enabled = true; } // namespace browser_defaults diff --git a/chrome/browser/defaults.h b/chrome/browser/defaults.h index cd635b0..6e64fe6 100644 --- a/chrome/browser/defaults.h +++ b/chrome/browser/defaults.h @@ -71,9 +71,6 @@ extern const bool kShowOtherBrowsersInAboutMemory; // Should always open incognito windows when started with --incognito switch? extern const bool kAlwaysOpenIncognitoWindow; -// Are phantom tabs enabled? -extern const bool kPhantomTabsEnabled; - //============================================================================= // Runtime "const" - set only once after parsing command line option and should // never be modified after that. diff --git a/chrome/browser/extensions/extension_browser_event_router.cc b/chrome/browser/extensions/extension_browser_event_router.cc index cae6bfd..ef10800 100644 --- a/chrome/browser/extensions/extension_browser_event_router.cc +++ b/chrome/browser/extensions/extension_browser_event_router.cc @@ -426,15 +426,12 @@ void ExtensionBrowserEventRouter::TabChangedAt(TabContents* contents, void ExtensionBrowserEventRouter::TabReplacedAt(TabContents* old_contents, TabContents* new_contents, - int index, - TabReplaceType type) { - if (type == REPLACE_MATCH_PREVIEW) { - // The ids of the two tabs should remain the same: - DCHECK_EQ(old_contents->controller().session_id().id(), - new_contents->controller().session_id().id()); - UnregisterForTabNotifications(old_contents); - RegisterForTabNotifications(new_contents); - } + int index) { + // The ids of the two tabs should remain the same: + DCHECK_EQ(old_contents->controller().session_id().id(), + new_contents->controller().session_id().id()); + UnregisterForTabNotifications(old_contents); + RegisterForTabNotifications(new_contents); } void ExtensionBrowserEventRouter::TabStripEmpty() {} diff --git a/chrome/browser/extensions/extension_browser_event_router.h b/chrome/browser/extensions/extension_browser_event_router.h index 2c02a1c..c2c7ca3 100644 --- a/chrome/browser/extensions/extension_browser_event_router.h +++ b/chrome/browser/extensions/extension_browser_event_router.h @@ -71,8 +71,7 @@ class ExtensionBrowserEventRouter : public TabStripModelObserver, TabChangeType change_type); virtual void TabReplacedAt(TabContents* old_contents, TabContents* new_contents, - int index, - TabReplaceType type); + int index); virtual void TabStripEmpty(); // Page Action execute event. diff --git a/chrome/browser/extensions/extension_message_service.cc b/chrome/browser/extensions/extension_message_service.cc index 2fb59c3..40bfc32 100644 --- a/chrome/browser/extensions/extension_message_service.cc +++ b/chrome/browser/extensions/extension_message_service.cc @@ -247,8 +247,8 @@ void ExtensionMessageService::OpenChannelToTab( } if (contents && contents->controller().needs_reload()) { - // The tab isn't loaded yet (it may be phantom). Don't attempt to connect. - // Treat this as a disconnect. + // The tab isn't loaded yet. Don't attempt to connect. Treat this as a + // disconnect. DispatchOnDisconnect(MessagePort(source, MSG_ROUTING_CONTROL), GET_OPPOSITE_PORT_ID(receiver_port_id)); return; @@ -336,7 +336,7 @@ int ExtensionMessageService::OpenSpecialChannelToTab( DCHECK(target_tab_contents); if (target_tab_contents->controller().needs_reload()) { - // The tab isn't loaded yet (it may be phantom). Don't attempt to connect. + // The tab isn't loaded yet. Don't attempt to connect. return -1; } diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index 6cf9c42..016c3ec 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -800,13 +800,6 @@ bool RemoveTabFunction::RunImpl() { &browser, NULL, &contents, NULL, &error_)) return false; - int tab_index = browser->GetIndexOfController(&contents->controller()); - if (browser->tabstrip_model()->IsPhantomTab(tab_index)) { - // Don't allow closing phantom tabs. - error_ = keys::kCannotRemovePhantomTab; - return false; - } - // Close the tab in this convoluted way, since there's a chance that the tab // is being dragged, or we're in some other nested event loop. This code path // should ensure that the tab is safely closed under such circumstances, @@ -1003,8 +996,7 @@ bool DetectTabLanguageFunction::RunImpl() { } if (contents->controller().needs_reload()) { - // If the tab hasn't been loaded, such as happens with phantom tabs, don't - // wait for the tab to load, instead return. + // If the tab hasn't been loaded, don't wait for the tab to load. error_ = keys::kCannotDetermineLanguageOfUnloadedTab; return false; } diff --git a/chrome/browser/extensions/extension_tabs_module_constants.cc b/chrome/browser/extensions/extension_tabs_module_constants.cc index d1647f8..c7c515b 100644 --- a/chrome/browser/extensions/extension_tabs_module_constants.cc +++ b/chrome/browser/extensions/extension_tabs_module_constants.cc @@ -68,7 +68,6 @@ const char kMoreThanOneValuesError[] = "Code and file should not be specified " "at the same time in the second argument."; const char kLoadFileError[] = "Failed to load file: \"*\". "; const char kCannotUpdatePinnedTab[] = "Cannot update pinned tabs"; -const char kCannotRemovePhantomTab[] = "Cannot remove phantom tabs"; const char kCannotDetermineLanguageOfUnloadedTab[] = "Cannot determine language: tab not loaded"; diff --git a/chrome/browser/extensions/extension_tabs_module_constants.h b/chrome/browser/extensions/extension_tabs_module_constants.h index 3f0ddc0..79bd9a4 100644 --- a/chrome/browser/extensions/extension_tabs_module_constants.h +++ b/chrome/browser/extensions/extension_tabs_module_constants.h @@ -69,7 +69,6 @@ extern const char kNoCodeOrFileToExecuteError[]; extern const char kMoreThanOneValuesError[]; extern const char kLoadFileError[]; extern const char kCannotUpdatePinnedTab[]; -extern const char kCannotRemovePhantomTab[]; extern const char kCannotDetermineLanguageOfUnloadedTab[]; }; // namespace extension_tabs_module_constants diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index e6062c1..58b1db5 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -1408,7 +1408,7 @@ bool BrowserWindowGtk::CanClose() const { if (!browser_->ShouldCloseWindow()) return false; - if (browser_->tabstrip_model()->HasNonPhantomTabs()) { + if (!browser_->tabstrip_model()->empty()) { // Tab strip isn't empty. Hide the window (so it appears to have closed // immediately) and close all the tabs, allowing the renderers to shut // down. When the tab strip is empty we'll be called back again. diff --git a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc index 551aeb8..5df0ea7 100644 --- a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc +++ b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc @@ -424,7 +424,7 @@ void DraggedTabControllerGtk::Detach() { } // If we've removed the last tab from the tabstrip, hide the frame now. - if (!attached_model->HasNonPhantomTabs()) + if (attached_model->empty()) HideWindow(); // Update the dragged tab. This NULL check is necessary apparently in some @@ -736,7 +736,7 @@ void DraggedTabControllerGtk::ShowWindow() { void DraggedTabControllerGtk::CleanUpHiddenFrame() { // If the model we started dragging from is now empty, we must ask the // delegate to close the frame. - if (!source_tabstrip_->model()->HasNonPhantomTabs()) + if (source_tabstrip_->model()->empty()) source_tabstrip_->model()->delegate()->CloseFrameAfterDragSession(); } diff --git a/chrome/browser/gtk/tabs/dragged_tab_gtk.cc b/chrome/browser/gtk/tabs/dragged_tab_gtk.cc index 27a1846..9929f10 100644 --- a/chrome/browser/gtk/tabs/dragged_tab_gtk.cc +++ b/chrome/browser/gtk/tabs/dragged_tab_gtk.cc @@ -55,7 +55,6 @@ DraggedTabGtk::DraggedTabGtk(TabContents* datasource, contents_size_(contents_size), close_animation_(this) { renderer_->UpdateData(datasource, - false, // phantom datasource->is_app(), false); // loading_only renderer_->set_mini(mini); diff --git a/chrome/browser/gtk/tabs/tab_gtk.cc b/chrome/browser/gtk/tabs/tab_gtk.cc index 148e7ea..3d1eb07 100644 --- a/chrome/browser/gtk/tabs/tab_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_gtk.cc @@ -315,11 +315,8 @@ void TabGtk::CloseButtonClicked() { delegate_->CloseTab(this); } -void TabGtk::UpdateData(TabContents* contents, - bool phantom, - bool app, - bool loading_only) { - TabRendererGtk::UpdateData(contents, phantom, app, loading_only); +void TabGtk::UpdateData(TabContents* contents, bool app, bool loading_only) { + TabRendererGtk::UpdateData(contents, app, loading_only); // Cache the title width so we don't recalculate it every time the tab is // resized. title_width_ = GetTitleWidth(title_font(), GetTitle()); diff --git a/chrome/browser/gtk/tabs/tab_gtk.h b/chrome/browser/gtk/tabs/tab_gtk.h index 64c5513..586e306 100644 --- a/chrome/browser/gtk/tabs/tab_gtk.h +++ b/chrome/browser/gtk/tabs/tab_gtk.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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. @@ -99,10 +99,7 @@ class TabGtk : public TabRendererGtk, virtual bool IsVisible() const; virtual void SetVisible(bool visible) const; virtual void CloseButtonClicked(); - virtual void UpdateData(TabContents* contents, - bool phantom, - bool app, - bool loading_only); + virtual void UpdateData(TabContents* contents, bool app, bool loading_only); virtual void SetBounds(const gfx::Rect& bounds); private: diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc index 4dc40a7..51c71cc 100644 --- a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc @@ -275,7 +275,6 @@ TabRendererGtk::~TabRendererGtk() { } void TabRendererGtk::UpdateData(TabContents* contents, - bool phantom, bool app, bool loading_only) { DCHECK(contents); @@ -292,7 +291,6 @@ void TabRendererGtk::UpdateData(TabContents* contents, else data_.favicon = contents->GetFavIcon(); - data_.phantom = phantom; data_.app = app; // This is kind of a hacky way to determine whether our icon is the default // favicon. But the plumbing that would be necessary to do it right would @@ -612,12 +610,7 @@ void TabRendererGtk::Paint(gfx::Canvas* canvas) { show_close_button != showing_close_button_) Layout(); - if (!phantom()) { - // TODO: this isn't quite right. To match the Windows side we need to render - // phantom tabs to a separate layer than alpha composite that. This will do - // for now though. - PaintTabBackground(canvas); - } + PaintTabBackground(canvas); if (!mini() || width() > kMiniTabRendererAsNormalTabWidth) PaintTitle(canvas); diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.h b/chrome/browser/gtk/tabs/tab_renderer_gtk.h index 092843d..f3a9763 100644 --- a/chrome/browser/gtk/tabs/tab_renderer_gtk.h +++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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. @@ -105,10 +105,7 @@ class TabRendererGtk : public AnimationDelegate, // TabContents. If only the loading state was updated, the loading_only flag // should be specified. If other things change, set this flag to false to // update everything. - virtual void UpdateData(TabContents* contents, - bool phantom, - bool app, - bool loading_only); + virtual void UpdateData(TabContents* contents, bool app, bool loading_only); // Sets the blocked state of the tab. void SetBlocked(bool pinned); @@ -118,10 +115,6 @@ class TabRendererGtk : public AnimationDelegate, void set_mini(bool mini) { data_.mini = mini; } bool mini() const { return data_.mini; } - // Sets the phantom state of the tab. - void set_phantom(bool phantom) { data_.phantom = phantom; } - bool phantom() const { return data_.phantom; } - // Sets the app state of the tab. void set_app(bool app) { data_.app = app; } bool app() const { return data_.app; } @@ -264,7 +257,6 @@ class TabRendererGtk : public AnimationDelegate, mini(false), blocked(false), animating_mini_change(false), - phantom(false), app(false) { } @@ -278,7 +270,6 @@ class TabRendererGtk : public AnimationDelegate, bool mini; bool blocked; bool animating_mini_change; - bool phantom; bool app; }; diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc index 88ef6a8..3d026b1 100644 --- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc @@ -961,8 +961,7 @@ void TabStripGtk::TabInsertedAt(TabContents* contents, if (!contains_tab) { TabData d = { tab, gfx::Rect() }; tab_data_.insert(tab_data_.begin() + index, d); - tab->UpdateData(contents, model_->IsPhantomTab(index), - model_->IsAppTab(index), false); + tab->UpdateData(contents, model_->IsAppTab(index), false); } tab->set_mini(model_->IsMiniTab(index)); tab->set_app(model_->IsAppTab(index)); @@ -1023,8 +1022,6 @@ void TabStripGtk::TabMoved(TabContents* contents, tab->set_mini(model_->IsMiniTab(to_index)); tab->SetBlocked(model_->IsTabBlocked(to_index)); tab_data_.insert(tab_data_.begin() + to_index, data); - if (tab->phantom() != model_->IsPhantomTab(to_index)) - tab->set_phantom(!tab->phantom()); GenerateIdealBounds(); StartMoveTabAnimation(from_index, to_index); } @@ -1041,7 +1038,6 @@ void TabStripGtk::TabChangedAt(TabContents* contents, int index, return; } tab->UpdateData(contents, - model_->IsPhantomTab(index), model_->IsAppTab(index), change_type == LOADING_ONLY); tab->UpdateFromModel(); diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc index fa89c30..db257e0 100644 --- a/chrome/browser/memory_details.cc +++ b/chrome/browser/memory_details.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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. @@ -94,8 +94,7 @@ void MemoryDetails::CollectChildInfoOnUIThread() { RenderProcessHost::AllHostsIterator()); !renderer_iter.IsAtEnd(); renderer_iter.Advance()) { DCHECK(renderer_iter.GetCurrentValue()); - // Ignore processes that don't have a connection, such as crashed tabs or - // phantom tabs. + // Ignore processes that don't have a connection, such as crashed tabs. if (!renderer_iter.GetCurrentValue()->HasConnection() || process.pid != base::GetProcId(renderer_iter.GetCurrentValue()->GetHandle())) { continue; diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 731de0e..d37fdcc 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -1447,30 +1447,6 @@ bool TabContents::ShouldAcceptDragAndDrop() const { #endif } -TabContents* TabContents::CloneAndMakePhantom() { - TabNavigation tab_nav; - - NavigationEntry* entry = controller().GetActiveEntry(); - if (extension_app_) - tab_nav.set_virtual_url(extension_app_->GetFullLaunchURL()); - else if (entry) - tab_nav.SetFromNavigationEntry(*entry); - - std::vector<TabNavigation> navigations; - navigations.push_back(tab_nav); - - TabContents* new_contents = - new TabContents(profile(), NULL, MSG_ROUTING_NONE, NULL, - controller_.session_storage_namespace()->Clone()); - new_contents->SetExtensionApp(extension_app_); - new_contents->controller().RestoreFromState(navigations, 0, false); - - if (!extension_app_ && entry) - new_contents->controller().GetActiveEntry()->favicon() = entry->favicon(); - - return new_contents; -} - void TabContents::UpdateHistoryForNavigation( scoped_refptr<history::HistoryAddPageArgs> add_page_args) { if (profile()->IsOffTheRecord()) diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index be8ac99..bf0a890 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -654,13 +654,6 @@ class TabContents : public PageNavigator, // Returns true if underlying TabContentsView should accept drag-n-drop. bool ShouldAcceptDragAndDrop() const; - // Creates a duplicate of this TabContents. The returned TabContents is - // configured such that the renderer has not been loaded (it'll load the first - // time it is selected). - // This is intended for use with apps. - // The caller owns the returned object. - TabContents* CloneAndMakePhantom(); - // Indicates if this tab was explicitly closed by the user (control-w, close // tab menu item...). This is false for actions that indirectly close the tab, // such as closing the window. The setter is maintained by TabStripModel, and diff --git a/chrome/browser/tabs/default_tab_handler.cc b/chrome/browser/tabs/default_tab_handler.cc index 5149173..dc3598b 100644 --- a/chrome/browser/tabs/default_tab_handler.cc +++ b/chrome/browser/tabs/default_tab_handler.cc @@ -18,8 +18,8 @@ DefaultTabHandler::DefaultTabHandler(TabHandlerDelegate* delegate) } DefaultTabHandler::~DefaultTabHandler() { - // The tab strip should not have any significant tabs at this point. - DCHECK(!model_->HasNonPhantomTabs()); + // The tab strip should not have any tabs at this point. + DCHECK(model_->empty()); model_->RemoveObserver(this); } diff --git a/chrome/browser/tabs/pinned_tab_codec.cc b/chrome/browser/tabs/pinned_tab_codec.cc index 6920bfa..7b9e0b3 100644 --- a/chrome/browser/tabs/pinned_tab_codec.cc +++ b/chrome/browser/tabs/pinned_tab_codec.cc @@ -46,10 +46,9 @@ static void EncodePinnedTab(TabStripModel* model, Extension* extension = tab_contents->extension_app(); DCHECK(extension); value->SetString(kAppID, extension->id()); - // For apps we use the launch url. We do this for two reasons: + // For apps we use the launch url. We do this for the following reason: // . the user is effectively restarting the app, so that returning them to // the app's launch page seems closest to what they expect. - // . we do the same when restoring a phantom tab. value->SetString(kURL, extension->GetFullLaunchURL().spec()); values->Append(value.release()); } else { diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc index f27b5a8..1f7a668 100644 --- a/chrome/browser/tabs/tab_strip_model.cc +++ b/chrome/browser/tabs/tab_strip_model.cc @@ -75,17 +75,6 @@ TabStripModel::TabStripModel(TabStripModelDelegate* delegate, Profile* profile) TabStripModel::~TabStripModel() { FOR_EACH_OBSERVER(TabStripModelObserver, observers_, TabStripModelDeleted()); - - // Before deleting any phantom tabs remove our notification observers so that - // we don't attempt to notify our delegate or do any processing. - registrar_.RemoveAll(); - - // Phantom tabs still have valid TabConents that we own and need to delete. - for (int i = count() - 1; i >= 0; --i) { - if (IsPhantomTab(i)) - delete contents_data_[i]->contents; - } - STLDeleteContainerPointers(contents_data_.begin(), contents_data_.end()); delete order_controller_; } @@ -98,14 +87,6 @@ void TabStripModel::RemoveObserver(TabStripModelObserver* observer) { observers_.RemoveObserver(observer); } -bool TabStripModel::HasNonPhantomTabs() const { - for (int i = 0; i < count(); i++) { - if (!IsPhantomTab(i)) - return true; - } - return false; -} - void TabStripModel::SetInsertionPolicy(InsertionPolicy policy) { order_controller_->set_insertion_policy(policy); } @@ -181,12 +162,9 @@ void TabStripModel::InsertTabContentsAt(int index, ChangeSelectedContentsFrom(selected_contents, index, false); } -void TabStripModel::ReplaceTabContentsAt( - int index, - TabContents* new_contents, - TabStripModelObserver::TabReplaceType type) { +void TabStripModel::ReplaceTabContentsAt(int index, TabContents* new_contents) { scoped_ptr<TabContents> old_contents( - ReplaceTabContentsAtImpl(index, new_contents, type)); + ReplaceTabContentsAtImpl(index, new_contents)); // When the selected tab contents is replaced send out selected notification // too. We do this as nearly all observers need to treat a replace of the @@ -218,20 +196,17 @@ TabContents* TabStripModel::DetachTabContentsAt(int index) { DCHECK(ContainsIndex(index)); TabContents* removed_contents = GetContentsAt(index); - int next_selected_index = - order_controller_->DetermineNewSelectedIndex(index, true); + int next_selected_index = order_controller_->DetermineNewSelectedIndex(index); delete contents_data_.at(index); contents_data_.erase(contents_data_.begin() + index); - next_selected_index = IndexOfNextNonPhantomTab(next_selected_index, -1); - if (!HasNonPhantomTabs()) + if (empty()) closing_all_ = true; FOR_EACH_OBSERVER(TabStripModelObserver, observers_, TabDetachedAt(removed_contents, index)); - if (!HasNonPhantomTabs()) { + if (empty()) { // TabDetachedAt() might unregister observers, so send |TabStripEmtpy()| in // a second pass. - FOR_EACH_OBSERVER(TabStripModelObserver, observers_, - TabStripEmpty()); + FOR_EACH_OBSERVER(TabStripModelObserver, observers_, TabStripEmpty()); } else { if (index == selected_index_) { ChangeSelectedContentsFrom(removed_contents, next_selected_index, false); @@ -343,17 +318,13 @@ int TabStripModel::GetIndexOfNextTabContentsOpenedBy( // Check tabs after start_index first. for (int i = start_index + 1; i < count(); ++i) { - if (OpenerMatches(contents_data_[i], opener, use_group) && - !IsPhantomTab(i)) { + if (OpenerMatches(contents_data_[i], opener, use_group)) return i; - } } // Then check tabs before start_index, iterating backwards. for (int i = start_index - 1; i >= 0; --i) { - if (OpenerMatches(contents_data_[i], opener, use_group) && - !IsPhantomTab(i)) { + if (OpenerMatches(contents_data_[i], opener, use_group)) return i; - } } return kNoTab; } @@ -365,7 +336,7 @@ int TabStripModel::GetIndexOfFirstTabContentsOpenedBy( DCHECK(ContainsIndex(start_index)); for (int i = 0; i < start_index; ++i) { - if (contents_data_[i]->opener == opener && !IsPhantomTab(i)) + if (contents_data_[i]->opener == opener) return i; } return kNoTab; @@ -384,10 +355,8 @@ int TabStripModel::GetIndexOfLastTabContentsOpenedBy( next = iter - 1; if (next == end) break; - if ((*next)->opener == opener && - !IsPhantomTab(static_cast<int>(next - contents_data_.begin()))) { + if ((*next)->opener == opener) return static_cast<int>(next - contents_data_.begin()); - } } return kNoTab; } @@ -497,11 +466,6 @@ bool TabStripModel::IsAppTab(int index) const { return contents && contents->is_app(); } -bool TabStripModel::IsPhantomTab(int index) const { - return IsTabPinned(index) && - GetTabContentsAt(index)->controller().needs_reload(); -} - bool TabStripModel::IsTabBlocked(int index) const { return contents_data_[index]->blocked; } @@ -520,23 +484,6 @@ int TabStripModel::ConstrainInsertionIndex(int index, bool mini_tab) { std::min(count(), std::max(index, IndexOfFirstNonMiniTab())); } -int TabStripModel::IndexOfFirstNonPhantomTab() const { - for (int i = 0; i < count(); ++i) { - if (!IsPhantomTab(i)) - return i; - } - return kNoTab; -} - -int TabStripModel::GetNonPhantomTabCount() const { - int tabs = 0; - for (int i = 0; i < count(); ++i) { - if (!IsPhantomTab(i)) - ++tabs; - } - return tabs; -} - void TabStripModel::AddTabContents(TabContents* contents, int index, PageTransition::Type transition, @@ -734,15 +681,8 @@ void TabStripModel::ExecuteContextMenuCommand( UserMetrics::RecordAction( UserMetricsAction("TabContextMenu_TogglePinned"), profile_); - - if (IsPhantomTab(context_index)) { - // The tab is a phantom tab, close it. - CloseTabContentsAt(context_index, - CLOSE_USER_GESTURE | CLOSE_CREATE_HISTORICAL_TAB); - } else { - SelectTabContentsAt(context_index, true); - SetTabPinned(context_index, !IsTabPinned(context_index)); - } + SelectTabContentsAt(context_index, true); + SetTabPinned(context_index, !IsTabPinned(context_index)); break; } @@ -803,13 +743,7 @@ void TabStripModel::Observe(NotificationType type, if (index != TabStripModel::kNoTab) { // Note that we only detach the contents here, not close it - it's // already been closed. We just want to undo our bookkeeping. - if (ShouldMakePhantomOnClose(index)) { - // We don't actually allow pinned tabs to close. Instead they become - // phantom. - MakePhantom(index); - } else { - DetachTabContentsAt(index); - } + DetachTabContentsAt(index); } break; } @@ -960,79 +894,12 @@ void TabStripModel::SelectRelativeTab(bool next) { if (contents_data_.empty()) return; - // Skip pinned-app-phantom tabs when iterating. int index = selected_index_; int delta = next ? 1 : -1; - do { - index = (index + count() + delta) % count(); - } while (index != selected_index_ && IsPhantomTab(index)); + index = (index + count() + delta) % count(); SelectTabContentsAt(index, true); } -int TabStripModel::IndexOfNextNonPhantomTab(int index, - int ignore_index) { - if (index == kNoTab) - return kNoTab; - - if (empty()) - return index; - - index = std::min(count() - 1, std::max(0, index)); - int start = index; - do { - if (index != ignore_index && !IsPhantomTab(index)) - return index; - index = (index + 1) % count(); - } while (index != start); - - // All phantom tabs. - return start; -} - -bool TabStripModel::ShouldMakePhantomOnClose(int index) { - if (browser_defaults::kPhantomTabsEnabled && IsTabPinned(index) && - !IsPhantomTab(index) && !closing_all_ && profile()) { - if (!IsAppTab(index)) - return true; // Always make non-app tabs go phantom. - - ExtensionsService* extension_service = profile()->GetExtensionsService(); - if (!extension_service) - return false; - - Extension* extension_app = GetTabContentsAt(index)->extension_app(); - DCHECK(extension_app); - - // Only allow the tab to be made phantom if the extension still exists. - return extension_service->GetExtensionById(extension_app->id(), - false) != NULL; - } - return false; -} - -void TabStripModel::MakePhantom(int index) { - // MakePhantom is called when the TabContents is being destroyed so we don't - // need to do anything with the returned value from ReplaceTabContentsAtImpl. - ReplaceTabContentsAtImpl(index, GetContentsAt(index)->CloneAndMakePhantom(), - TabStripModelObserver::REPLACE_MADE_PHANTOM); - - if (selected_index_ == index && HasNonPhantomTabs()) { - // Change the selection, otherwise we're going to force the phantom tab - // to become selected. - // NOTE: we must do this after the call to Replace otherwise browser's - // TabSelectedAt will send out updates for the old TabContents which we've - // already told observers has been closed (we sent out TabClosing at). - int new_selected_index = - order_controller_->DetermineNewSelectedIndex(index, false); - new_selected_index = IndexOfNextNonPhantomTab(new_selected_index, - index); - SelectTabContentsAt(new_selected_index, true); - } - - if (!HasNonPhantomTabs()) - FOR_EACH_OBSERVER(TabStripModelObserver, observers_, TabStripEmpty()); -} - - void TabStripModel::MoveTabContentsAtImpl(int index, int to_position, bool select_after_move) { TabContentsData* moved_data = contents_data_.at(index); @@ -1061,8 +928,7 @@ bool TabStripModel::OpenerMatches(const TabContentsData* data, TabContents* TabStripModel::ReplaceTabContentsAtImpl( int index, - TabContents* new_contents, - TabStripModelObserver::TabReplaceType type) { + TabContents* new_contents) { // TODO: this should reset group/opener of any tabs that point at // old_contents. DCHECK(ContainsIndex(index)); @@ -1072,6 +938,6 @@ TabContents* TabStripModel::ReplaceTabContentsAtImpl( contents_data_[index]->contents = new_contents; FOR_EACH_OBSERVER(TabStripModelObserver, observers_, - TabReplacedAt(old_contents, new_contents, index, type)); + TabReplacedAt(old_contents, new_contents, index)); return old_contents; } diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h index 003f3d6..5b58afc 100644 --- a/chrome/browser/tabs/tab_strip_model.h +++ b/chrome/browser/tabs/tab_strip_model.h @@ -41,18 +41,8 @@ class TabStripModelOrderController; // . App. Corresponds to an extension that wants an app tab. App tabs are // identified by TabContents::is_app(). App tabs are always pinneded (you // can't unpin them). -// . Pinned. Any tab can be pinned. A pinned tab is made phantom when closed. -// Non-app tabs whose pinned state is changed are moved to be with other -// mini-tabs or non-mini tabs. -// . Phantom. Only pinned tabs may be made phantom. When a tab that can be made -// phantom is closed the renderer is shutdown, a new -// TabContents/NavigationController is created that has not yet loaded the -// renderer and observers are notified via the TabReplacedAt method. When a -// phantom tab is selected the renderer is loaded and the tab is no longer -// phantom. -// Phantom tabs do not prevent the tabstrip from closing, for example if the -// tabstrip has one phantom and one non-phantom tab and the non-phantom tab is -// closed, then the tabstrip/browser are closed. +// . Pinned. Any tab can be pinned. Non-app tabs whose pinned state is changed +// are moved to be with other mini-tabs or non-mini tabs. // // A TabStripModel has one delegate that it relies on to perform certain tasks // like creating new TabStripModels (probably hosted in Browser windows) when @@ -137,11 +127,6 @@ class TabStripModel : public NotificationObserver { int count() const { return static_cast<int>(contents_data_.size()); } bool empty() const { return contents_data_.empty(); } - // Returns true if there are any non-phantom tabs. When there are no - // non-phantom tabs the delegate is notified by way of TabStripEmpty and the - // browser closes. - bool HasNonPhantomTabs() const; - // Retrieve the Profile associated with this TabStripModel. Profile* profile() const { return profile_; } @@ -208,11 +193,9 @@ class TabStripModel : public NotificationObserver { void ReplaceNavigationControllerAt(int index, NavigationController* controller); - // Replaces the tab contents at |index| with |new_contents|. |type| is passed - // to the observer. This deletes the TabContents currently at |index|. - void ReplaceTabContentsAt(int index, - TabContents* new_contents, - TabStripModelObserver::TabReplaceType type); + // Replaces the tab contents at |index| with |new_contents|. This deletes the + // TabContents currently at |index|. + void ReplaceTabContentsAt(int index, TabContents* new_contents); // Detaches the TabContents at the specified index from this strip. The // TabContents is not destroyed, just removed from display. The caller is @@ -277,20 +260,17 @@ class TabStripModel : public NotificationObserver { // If |use_group| is true, the group property of the tab is used instead of // the opener to find the next tab. Under some circumstances the group // relationship may exist but the opener may not. - // NOTE: this skips phantom tabs. int GetIndexOfNextTabContentsOpenedBy(const NavigationController* opener, int start_index, bool use_group) const; // Returns the index of the first TabContents in the model opened by the // specified opener. - // NOTE: this skips phantom tabs. int GetIndexOfFirstTabContentsOpenedBy(const NavigationController* opener, int start_index) const; // Returns the index of the last TabContents in the model opened by the // specified opener, starting at |start_index|. - // NOTE: this skips phantom tabs. int GetIndexOfLastTabContentsOpenedBy(const NavigationController* opener, int start_index) const; @@ -337,11 +317,6 @@ class TabStripModel : public NotificationObserver { // See description above class for details on app tabs. bool IsAppTab(int index) const; - // Returns true if the tab is a phantom tab. A phantom tab is one where the - // renderer has not been loaded. - // See description above class for details on phantom tabs. - bool IsPhantomTab(int index) const; - // Returns true if the tab at |index| is blocked by a tab modal dialog. bool IsTabBlocked(int index) const; @@ -357,14 +332,6 @@ class TabStripModel : public NotificationObserver { // is between IndexOfFirstNonMiniTab and count(). int ConstrainInsertionIndex(int index, bool mini_tab); - // Returns the index of the first tab that is not a phantom tab. This returns - // kNoTab if all of the tabs are phantom tabs. - int IndexOfFirstNonPhantomTab() const; - - // Returns the number of non phantom tabs in the TabStripModel. - int GetNonPhantomTabCount() const; - - // Command level API ///////////////////////////////////////////////////////// // Adds a TabContents at the best position in the TabStripModel given the @@ -481,17 +448,6 @@ class TabStripModel : public NotificationObserver { // (|forward| is false). void SelectRelativeTab(bool forward); - // Returns the first non-phantom tab starting at |index|, skipping the tab at - // |ignore_index|. - int IndexOfNextNonPhantomTab(int index, int ignore_index); - - // Returns true if the tab at the specified index should be made phantom when - // the tab is closing. - bool ShouldMakePhantomOnClose(int index); - - // Makes the tab a phantom tab. - void MakePhantom(int index); - // Does the work of MoveTabContentsAt. This has no checks to make sure the // position is valid, those are done in MoveTabContentsAt. void MoveTabContentsAtImpl(int index, @@ -508,10 +464,7 @@ class TabStripModel : public NotificationObserver { // Does the work for ReplaceTabContentsAt returning the old TabContents. // The caller owns the returned TabContents. - TabContents* ReplaceTabContentsAtImpl( - int index, - TabContents* new_contents, - TabStripModelObserver::TabReplaceType type); + TabContents* ReplaceTabContentsAtImpl(int index, TabContents* new_contents); // Our delegate. TabStripModelDelegate* delegate_; diff --git a/chrome/browser/tabs/tab_strip_model_observer.cc b/chrome/browser/tabs/tab_strip_model_observer.cc index c3bfb9b..fa2fe8b 100644 --- a/chrome/browser/tabs/tab_strip_model_observer.cc +++ b/chrome/browser/tabs/tab_strip_model_observer.cc @@ -38,13 +38,6 @@ void TabStripModelObserver::TabReplacedAt(TabContents* old_contents, int index) { } -void TabStripModelObserver::TabReplacedAt(TabContents* old_contents, - TabContents* new_contents, - int index, - TabReplaceType type) { - TabReplacedAt(old_contents, new_contents, index); -} - void TabStripModelObserver::TabPinnedStateChanged(TabContents* contents, int index) { } diff --git a/chrome/browser/tabs/tab_strip_model_observer.h b/chrome/browser/tabs/tab_strip_model_observer.h index cfbf9e8..931497b 100644 --- a/chrome/browser/tabs/tab_strip_model_observer.h +++ b/chrome/browser/tabs/tab_strip_model_observer.h @@ -37,17 +37,6 @@ class TabStripModelObserver { ALL }; - // Enum used by ReplaceTabContentsAt. - // TODO(sky): nuke this, pinned is being removed so there is no point in the - // enum. - enum TabReplaceType { - // The replace is the result of the tab being made phantom. - REPLACE_MADE_PHANTOM, - - // The replace is the result of the match preview being committed. - REPLACE_MATCH_PREVIEW - }; - // A new TabContents was inserted into the TabStripModel at the specified // index. |foreground| is whether or not it was opened in the foreground // (selected). @@ -100,14 +89,6 @@ class TabStripModelObserver { TabContents* new_contents, int index); - // The tab contents was replaced at the specified index. |type| describes - // the type of replace. - // This invokes TabReplacedAt with three args. - virtual void TabReplacedAt(TabContents* old_contents, - TabContents* new_contents, - int index, - TabReplaceType type); - // Invoked when the pinned state of a tab changes. This is not invoked if the // tab ends up moving as a result of the mini state changing. // See note in TabMiniStateChanged as to how this relates to diff --git a/chrome/browser/tabs/tab_strip_model_order_controller.cc b/chrome/browser/tabs/tab_strip_model_order_controller.cc index a967bd9..aa66920 100644 --- a/chrome/browser/tabs/tab_strip_model_order_controller.cc +++ b/chrome/browser/tabs/tab_strip_model_order_controller.cc @@ -64,8 +64,7 @@ int TabStripModelOrderController::DetermineInsertionIndexForAppending() { } int TabStripModelOrderController::DetermineNewSelectedIndex( - int removing_index, - bool is_remove) const { + int removing_index) const { int tab_count = tabstrip_->count(); DCHECK(removing_index >= 0 && removing_index < tab_count); NavigationController* parent_opener = @@ -79,7 +78,7 @@ int TabStripModelOrderController::DetermineNewSelectedIndex( removing_index, false); if (index != TabStripModel::kNoTab) - return GetValidIndex(index, removing_index, is_remove); + return GetValidIndex(index, removing_index); if (parent_opener) { // If the tab was in a group, shift selection to the next tab in the group. @@ -87,20 +86,21 @@ int TabStripModelOrderController::DetermineNewSelectedIndex( removing_index, false); if (index != TabStripModel::kNoTab) - return GetValidIndex(index, removing_index, is_remove); + return GetValidIndex(index, removing_index); // If we can't find a subsequent group member, just fall back to the // parent_opener itself. Note that we use "group" here since opener is // reset by select operations.. index = tabstrip_->GetIndexOfController(parent_opener); if (index != TabStripModel::kNoTab) - return GetValidIndex(index, removing_index, is_remove); + return GetValidIndex(index, removing_index); } // No opener set, fall through to the default handler... int selected_index = tabstrip_->selected_index(); - if (is_remove && selected_index >= (tab_count - 1)) + if (selected_index >= (tab_count - 1)) return selected_index - 1; + return selected_index; } @@ -132,10 +132,9 @@ void TabStripModelOrderController::TabSelectedAt(TabContents* old_contents, /////////////////////////////////////////////////////////////////////////////// // TabStripModelOrderController, private: -int TabStripModelOrderController::GetValidIndex(int index, - int removing_index, - bool is_remove) const { - if (is_remove && removing_index < index) +int TabStripModelOrderController::GetValidIndex( + int index, int removing_index) const { + if (removing_index < index) index = std::max(0, index - 1); return index; } diff --git a/chrome/browser/tabs/tab_strip_model_order_controller.h b/chrome/browser/tabs/tab_strip_model_order_controller.h index b7b579c..f2c466f 100644 --- a/chrome/browser/tabs/tab_strip_model_order_controller.h +++ b/chrome/browser/tabs/tab_strip_model_order_controller.h @@ -39,11 +39,8 @@ class TabStripModelOrderController : public TabStripModelObserver { // Returns the index to append tabs at. int DetermineInsertionIndexForAppending(); - // Determine where to shift selection after a tab is closed is made phantom. - // If |is_remove| is false, the tab is not being removed but rather made - // phantom (see description of phantom tabs in TabStripModel). - int DetermineNewSelectedIndex(int removed_index, - bool is_remove) const; + // Determine where to shift selection after a tab is closed. + int DetermineNewSelectedIndex(int removed_index) const; // Overridden from TabStripModelObserver: virtual void TabSelectedAt(TabContents* old_contents, @@ -53,10 +50,9 @@ class TabStripModelOrderController : public TabStripModelObserver { private: // Returns a valid index to be selected after the tab at |removing_index| is - // closed. If |index| is after |removing_index| and |is_remove| is true, - // |index| is adjusted to reflect the fact that |removing_index| is going - // away. This also skips any phantom tabs. - int GetValidIndex(int index, int removing_index, bool is_remove) const; + // closed. If |index| is after |removing_index|, |index| is adjusted to + // reflect the fact that |removing_index| is going away. + int GetValidIndex(int index, int removing_index) const; TabStripModel* tabstrip_; diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc index 9fabf5b..6eee910 100644 --- a/chrome/browser/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/tabs/tab_strip_model_unittest.cc @@ -163,9 +163,6 @@ class TabStripModelTest : public RenderViewHostTestHarness { if (model.IsTabPinned(i)) actual += "p"; - - if (model.IsPhantomTab(i)) - actual += "h"; } return actual; } @@ -818,7 +815,6 @@ TEST_F(TabStripModelTest, TestSelectOnClose) { EXPECT_EQ(1, tabstrip.selected_index()); tabstrip.CloseTabContentsAt(1, TabStripModel::CLOSE_NONE); EXPECT_EQ(0, tabstrip.selected_index()); - // Finally test that when a tab has no "siblings" that the opener is // selected. TabContents* other_contents = CreateTabContents(); @@ -1780,167 +1776,6 @@ TEST_F(TabStripModelTest, Pinning) { tabstrip.CloseAllTabs(); } -// Tests various permutations of making a tab phantom. -TEST_F(TabStripModelTest, Phantom) { - if (!browser_defaults::kPhantomTabsEnabled) - return; - - TabStripDummyDelegate delegate(NULL); - TabStripModel tabstrip(&delegate, profile()); - MockTabStripModelObserver observer; - tabstrip.AddObserver(&observer); - - EXPECT_TRUE(tabstrip.empty()); - - typedef MockTabStripModelObserver::State State; - - TabContents* contents1 = CreateTabContents(); - TabContents* contents2 = CreateTabContents(); - TabContents* contents3 = CreateTabContents(); - - SetID(contents1, 1); - SetID(contents2, 2); - SetID(contents3, 3); - - // Note! The ordering of these tests is important, each subsequent test - // builds on the state established in the previous. This is important if you - // ever insert tests rather than append. - - // Initial state, three tabs, first selected. - tabstrip.AppendTabContents(contents1, true); - tabstrip.AppendTabContents(contents2, false); - tabstrip.AppendTabContents(contents3, false); - - observer.ClearStates(); - - // Pin the first tab, and make it phantom. - { - tabstrip.SetTabPinned(0, true); - - observer.ClearStates(); - - tabstrip.CloseTabContentsAt(0, TabStripModel::CLOSE_NONE); - - // The tabcontents should have changed. - TabContents* old_contents1 = contents1; - TabContents* new_contents1 = tabstrip.GetTabContentsAt(0); - ASSERT_TRUE(new_contents1 != contents1); - contents1 = new_contents1; - SetID(contents1, 1); - - // Verify the state. - EXPECT_EQ("1ph 2 3", GetPinnedState(tabstrip)); - - // We should have gotten notification of the following: - // . tab closing. - // . selection changed. - // . tab replaced. - ASSERT_EQ(3, observer.GetStateCount()); - State state(old_contents1, 0, MockTabStripModelObserver::CLOSE); - EXPECT_TRUE(observer.StateEquals(0, state)); - state = State(contents1, 0, MockTabStripModelObserver::REPLACED); - state.src_contents = old_contents1; - EXPECT_TRUE(observer.StateEquals(1, state)); - state = State(contents2, 1, MockTabStripModelObserver::SELECT); - state.src_contents = contents1; - state.user_gesture = true; - EXPECT_TRUE(observer.StateEquals(2, state)); - - observer.ClearStates(); - } - - { - tabstrip.SetTabPinned(1, true); - observer.ClearStates(); - - // Close the second tab, which should make it phantom. - tabstrip.CloseTabContentsAt(1, TabStripModel::CLOSE_NONE); - - // The tabcontents should have changed. - TabContents* new_contents2 = tabstrip.GetTabContentsAt(1); - ASSERT_TRUE(new_contents2 != contents2); - contents2 = new_contents2; - SetID(contents2, 2); - - EXPECT_EQ("1ph 2ph 3", GetPinnedState(tabstrip)); - - EXPECT_EQ(2, tabstrip.selected_index()); - - contents2 = tabstrip.GetTabContentsAt(1); - - observer.ClearStates(); - } - - { - tabstrip.SetTabPinned(2, true); - observer.ClearStates(); - - // Close the last tab, we should get a tabstrip empty notification. - tabstrip.CloseTabContentsAt(2, TabStripModel::CLOSE_NONE); - - // The tabcontents should have changed. - TabContents* old_contents3 = contents3; - TabContents* new_contents3 = tabstrip.GetTabContentsAt(2); - ASSERT_TRUE(new_contents3 != contents3); - contents3 = new_contents3; - SetID(contents3, 3); - - EXPECT_EQ("1ph 2ph 3ph", GetPinnedState(tabstrip)); - - // We should have gotten notification of the following: - // . tab closing. - // . tab replaced. - // . tabstrip empty. - ASSERT_EQ(2, observer.GetStateCount()); - State state(old_contents3, 2, MockTabStripModelObserver::CLOSE); - EXPECT_TRUE(observer.StateEquals(0, state)); - state = State(contents3, 2, MockTabStripModelObserver::REPLACED); - state.src_contents = old_contents3; - EXPECT_TRUE(observer.StateEquals(1, state)); - EXPECT_TRUE(observer.empty()); - - observer.ClearStates(); - } - - // Clean up the phantom tabs. - tabstrip.CloseAllTabs(); -} - -// Makes sure the TabStripModel deletes phantom TabContents from its destructor. -TEST_F(TabStripModelTest, DeletePhantomTabContents) { - if (!browser_defaults::kPhantomTabsEnabled) - return; - - TabStripDummyDelegate delegate(NULL); - scoped_ptr<TabStripModel> strip(new TabStripModel(&delegate, profile())); - - strip->AddTabContents(CreateTabContents(), -1, PageTransition::TYPED, - TabStripModel::ADD_PINNED); - - // This will make the tab go phantom. - delete strip->GetTabContentsAt(0); - - ASSERT_TRUE(strip->IsPhantomTab(0)); - - NotificationRegistrar registrar; - NotificationObserverMock notification_observer; - MockTabStripModelObserver tabstrip_observer; - registrar.Add(¬ification_observer, - NotificationType::TAB_CONTENTS_DESTROYED, - NotificationService::AllSources()); - strip->AddObserver(&tabstrip_observer); - - // Deleting the strip should delete the phanton tabcontents and result in one - // TAB_CONTENTS_DESTROYED. - EXPECT_CALL(notification_observer, Observe(_, _, _)).Times(1); - - // Delete the tabstrip. - strip.reset(); - - // And there should have been no methods sent to the TabStripModelObserver. - EXPECT_EQ(0, tabstrip_observer.GetStateCount()); -} - // Makes sure the TabStripModel calls the right observer methods during a // replace. TEST_F(TabStripModelTest, ReplaceSendsSelected) { @@ -1957,8 +1792,7 @@ TEST_F(TabStripModelTest, ReplaceSendsSelected) { strip.AddObserver(&tabstrip_observer); TabContents* new_contents = CreateTabContents(); - strip.ReplaceTabContentsAt(0, new_contents, - TabStripModelObserver::REPLACE_MATCH_PREVIEW); + strip.ReplaceTabContentsAt(0, new_contents); ASSERT_EQ(2, tabstrip_observer.GetStateCount()); @@ -1982,8 +1816,7 @@ TEST_F(TabStripModelTest, ReplaceSendsSelected) { // And replace it. new_contents = CreateTabContents(); - strip.ReplaceTabContentsAt(1, new_contents, - TabStripModelObserver::REPLACE_MATCH_PREVIEW); + strip.ReplaceTabContentsAt(1, new_contents); ASSERT_EQ(1, tabstrip_observer.GetStateCount()); diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 0b668bf..a25aae0 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -1468,12 +1468,9 @@ void BrowserView::TabSelectedAt(TabContents* old_contents, void BrowserView::TabReplacedAt(TabContents* old_contents, TabContents* new_contents, - int index, - TabStripModelObserver::TabReplaceType type) { - if (type != TabStripModelObserver::REPLACE_MATCH_PREVIEW || - index != browser_->tabstrip_model()->selected_index()) { + int index) { + if (index != browser_->tabstrip_model()->selected_index()) return; - } // Swap the 'active' and 'preview' and delete what was the active. contents_->MakePreviewContentsActiveContents(); @@ -1690,7 +1687,7 @@ bool BrowserView::CanClose() const { if (!browser_->ShouldCloseWindow()) return false; - if (browser_->tabstrip_model()->HasNonPhantomTabs()) { + if (!browser_->tabstrip_model()->empty()) { // Tab strip isn't empty. Hide the frame (so it appears to have closed // immediately) and close all the tabs, allowing the renderers to shut // down. When the tab strip is empty we'll be called back again. diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index 142c520..08ab3ce 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -346,8 +346,7 @@ class BrowserView : public BrowserBubbleHost, bool user_gesture); virtual void TabReplacedAt(TabContents* old_contents, TabContents* new_contents, - int index, - TabStripModelObserver::TabReplaceType type); + int index); virtual void TabStripEmpty(); // Overridden from menus::SimpleMenuModel::Delegate: diff --git a/chrome/browser/views/tabs/browser_tab_strip_controller.cc b/chrome/browser/views/tabs/browser_tab_strip_controller.cc index 76de3ae..52d58a8 100644 --- a/chrome/browser/views/tabs/browser_tab_strip_controller.cc +++ b/chrome/browser/views/tabs/browser_tab_strip_controller.cc @@ -385,7 +385,6 @@ void BrowserTabStripController::SetTabRendererDataFromModel( data->show_icon = contents->ShouldDisplayFavIcon(); data->mini = model_->IsMiniTab(model_index); data->blocked = model_->IsTabBlocked(model_index); - data->phantom = model_->IsPhantomTab(model_index); data->app = contents->is_app(); } diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc index b0dc9e3..3798180 100644 --- a/chrome/browser/views/tabs/dragged_tab_controller.cc +++ b/chrome/browser/views/tabs/dragged_tab_controller.cc @@ -886,7 +886,7 @@ void DraggedTabController::Detach() { attached_tab_ = NULL; // If we've removed the last Tab from the TabStrip, hide the frame now. - if (!attached_model->HasNonPhantomTabs()) + if (attached_model->empty()) HideFrame(); // Set up the photo booth to start capturing the contents of the dragged @@ -1287,7 +1287,7 @@ void DraggedTabController::HideFrame() { void DraggedTabController::CleanUpHiddenFrame() { // If the model we started dragging from is now empty, we must ask the // delegate to close the frame. - if (!GetModel(source_tabstrip_)->HasNonPhantomTabs()) + if (GetModel(source_tabstrip_)->empty()) GetModel(source_tabstrip_)->delegate()->CloseFrameAfterDragSession(); } diff --git a/chrome/browser/views/tabs/side_tab.cc b/chrome/browser/views/tabs/side_tab.cc index a73bdee..b42bca0 100644 --- a/chrome/browser/views/tabs/side_tab.cc +++ b/chrome/browser/views/tabs/side_tab.cc @@ -20,16 +20,12 @@ const int kTitleCloseSpacing = 4; const SkScalar kRoundRectRadius = 4; const SkColor kTabBackgroundColor = SK_ColorWHITE; const SkColor kTextColor = SK_ColorBLACK; -const SkColor kPhantomTextColor = SK_ColorGRAY; // Padding between the edge and the icon. const int kIconLeftPadding = 5; // Location the title starts at. const int kTitleX = kIconLeftPadding + kFavIconSize + 5; - -// Alpha value phantom tab icons are rendered at. -const int kPhantomTabIconAlpha = 100; }; //////////////////////////////////////////////////////////////////////////////// @@ -99,18 +95,10 @@ void SideTab::Paint(gfx::Canvas* canvas) { paint); } - if (ShouldShowIcon()) { - if (data().phantom) { - canvas->SaveLayerAlpha(kPhantomTabIconAlpha, - gfx::Rect(width(), height())); - PaintIcon(canvas, icon_bounds_.x(), icon_bounds_.y()); - canvas->Restore(); - } else { - PaintIcon(canvas, icon_bounds_.x(), icon_bounds_.y()); - } - } + if (ShouldShowIcon()) + PaintIcon(canvas, icon_bounds_.x(), icon_bounds_.y()); - PaintTitle(canvas, data().phantom ? kPhantomTextColor : kTextColor); + PaintTitle(canvas, kTextColor); } gfx::Size SideTab::GetPreferredSize() { diff --git a/chrome/browser/views/tabs/tab.cc b/chrome/browser/views/tabs/tab.cc index 1f58245..dda22fb 100644 --- a/chrome/browser/views/tabs/tab.cc +++ b/chrome/browser/views/tabs/tab.cc @@ -177,15 +177,13 @@ int Tab::GetMiniWidth() { // Tab, protected: void Tab::DataChanged(const TabRendererData& old) { - if (data().phantom) - StopMiniTabTitleAnimation(); + if (data().blocked == old.blocked) + return; - if (data().blocked != old.blocked) { - if (data().blocked) - StartPulse(); - else - StopPulse(); - } + if (data().blocked) + StartPulse(); + else + StopPulse(); } //////////////////////////////////////////////////////////////////////////////// @@ -198,7 +196,7 @@ void Tab::Paint(gfx::Canvas* canvas) { return; // See if the model changes whether the icons should be painted. - const bool show_icon = ShouldShowIcon() && !data().phantom; + const bool show_icon = ShouldShowIcon(); const bool show_close_button = ShouldShowCloseBox(); if (show_icon != showing_icon_ || show_close_button != showing_close_button_) Layout(); diff --git a/chrome/browser/views/tabs/tab_renderer_data.h b/chrome/browser/views/tabs/tab_renderer_data.h index f91a3f9..31e84ed 100644 --- a/chrome/browser/views/tabs/tab_renderer_data.h +++ b/chrome/browser/views/tabs/tab_renderer_data.h @@ -28,7 +28,6 @@ struct TabRendererData { show_icon(true), mini(false), blocked(false), - phantom(false), app(false) { } @@ -41,7 +40,6 @@ struct TabRendererData { bool show_icon; bool mini; bool blocked; - bool phantom; bool app; }; diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc index c408585..1a1a99e 100644 --- a/chrome/browser/views/tabs/tab_strip.cc +++ b/chrome/browser/views/tabs/tab_strip.cc @@ -51,12 +51,6 @@ static const int kSuspendAnimationsTimeMs = 200; static const int kTabHOffset = -16; static const int kTabStripAnimationVSlop = 40; -// Alpha value phantom tabs are rendered at. -static const int kPhantomTabAlpha = 105; - -// Alpha value phantom tab icons are rendered at. -static const int kPhantomTabIconAlpha = 160; - // Size of the drop indicator. static int drop_indicator_width; static int drop_indicator_height; @@ -280,37 +274,7 @@ BaseTab* TabStrip::CreateTabForDragging() { void TabStrip::PaintChildren(gfx::Canvas* canvas) { // Tabs are painted in reverse order, so they stack to the left. - // Phantom tabs appear behind all other tabs and are rendered first. To make - // them slightly transparent we render them to a different layer. - if (HasPhantomTabs()) { - gfx::Rect local_bounds = GetLocalBounds(true); - canvas->SaveLayerAlpha(kPhantomTabAlpha, local_bounds); - canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); - for (int i = tab_count() - 1; i >= 0; --i) { - Tab* tab = GetTabAtTabDataIndex(i); - if (tab->data().phantom) - tab->ProcessPaint(canvas); - } - canvas->Restore(); - - canvas->SaveLayerAlpha(kPhantomTabIconAlpha, local_bounds); - canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); - for (int i = tab_count() - 1; i >= 0; --i) { - Tab* tab = GetTabAtTabDataIndex(i); - if (tab->data().phantom) { - canvas->Save(); - canvas->ClipRectInt(tab->MirroredX(), tab->y(), tab->width(), - tab->height()); - canvas->TranslateInt(tab->MirroredX(), tab->y()); - tab->PaintIcon(canvas); - canvas->Restore(); - } - } - canvas->Restore(); - } - Tab* selected_tab = NULL; - Tab* dragging_tab = NULL; for (int i = tab_count() - 1; i >= 0; --i) { @@ -318,14 +282,12 @@ void TabStrip::PaintChildren(gfx::Canvas* canvas) { // We must ask the _Tab's_ model, not ourselves, because in some situations // the model will be different to this object, e.g. when a Tab is being // removed after its TabContents has been destroyed. - if (!tab->data().phantom) { - if (tab->dragging()) { - dragging_tab = tab; - } else if (!tab->IsSelected()) { - tab->ProcessPaint(canvas); - } else { - selected_tab = tab; - } + if (tab->dragging()) { + dragging_tab = tab; + } else if (!tab->IsSelected()) { + tab->ProcessPaint(canvas); + } else { + selected_tab = tab; } } @@ -1020,11 +982,3 @@ bool TabStrip::IsPointInTab(Tab* tab, View::ConvertPointToView(this, tab, &point_in_tab_coords); return tab->HitTest(point_in_tab_coords); } - -bool TabStrip::HasPhantomTabs() const { - for (int i = 0; i < tab_count(); ++i) { - if (GetTabAtTabDataIndex(i)->data().phantom) - return true; - } - return false; -} diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h index 64c23fe..188868d 100644 --- a/chrome/browser/views/tabs/tab_strip.h +++ b/chrome/browser/views/tabs/tab_strip.h @@ -234,9 +234,6 @@ class TabStrip : public BaseTabStrip, // hit-test region of the specified Tab. bool IsPointInTab(Tab* tab, const gfx::Point& point_in_tabstrip_coords); - // Returns true if any of the tabs are phantom. - bool HasPhantomTabs() const; - // -- Member Variables ------------------------------------------------------ // The "New Tab" button. |