Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: chrome/browser/views/tabs/tab_strip.cc

Issue 1001003: Allow dynamic switching in and out of sidetabs mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "chrome/browser/views/tabs/tab_strip.h" 5 #include "chrome/browser/views/tabs/tab_strip.h"
6 6
7 #include "app/drag_drop_types.h" 7 #include "app/drag_drop_types.h"
8 #include "app/gfx/canvas.h" 8 #include "app/gfx/canvas.h"
9 #include "app/gfx/path.h" 9 #include "app/gfx/path.h"
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 needs_resize_layout_(false), 737 needs_resize_layout_(false),
738 current_unselected_width_(Tab::GetStandardSize().width()), 738 current_unselected_width_(Tab::GetStandardSize().width()),
739 current_selected_width_(Tab::GetStandardSize().width()), 739 current_selected_width_(Tab::GetStandardSize().width()),
740 available_width_for_tabs_(-1) { 740 available_width_for_tabs_(-1) {
741 Init(); 741 Init();
742 } 742 }
743 743
744 TabStrip::~TabStrip() { 744 TabStrip::~TabStrip() {
745 active_animation_.reset(NULL); 745 active_animation_.reset(NULL);
746 746
747 // TODO(beng): (1031854) Restore this line once XPFrame/VistaFrame are dead. 747 model_->RemoveObserver(this);
748 // model_->RemoveObserver(this);
749 748
750 // TODO(beng): remove this if it doesn't work to fix the TabSelectedAt bug. 749 // TODO(beng): remove this if it doesn't work to fix the TabSelectedAt bug.
751 drag_controller_.reset(NULL); 750 drag_controller_.reset(NULL);
752 751
753 // Make sure we unhook ourselves as a message loop observer so that we don't 752 // Make sure we unhook ourselves as a message loop observer so that we don't
754 // crash in the case where the user closes the window after closing a tab 753 // crash in the case where the user closes the window after closing a tab
755 // but before moving the mouse. 754 // but before moving the mouse.
756 RemoveMessageLoopObserver(); 755 RemoveMessageLoopObserver();
757 756
758 // The children (tabs) may callback to us from their destructor. Delete them 757 // The children (tabs) may callback to us from their destructor. Delete them
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 } 810 }
812 LoadNewTabButtonImage(); 811 LoadNewTabButtonImage();
813 newtab_button_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_NEWTAB)); 812 newtab_button_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_NEWTAB));
814 AddChildView(newtab_button_); 813 AddChildView(newtab_button_);
815 } 814 }
816 815
817 bool TabStrip::IsCompatibleWith(TabStrip* other) const { 816 bool TabStrip::IsCompatibleWith(TabStrip* other) const {
818 return model_->profile() == other->model()->profile(); 817 return model_->profile() == other->model()->profile();
819 } 818 }
820 819
820 void TabStrip::InitFromModel() {
821 // Walk the model, calling our insertion observer method for each item within
822 // it.
823 for (int i = 0; i < model_->count(); ++i) {
824 TabInsertedAt(model_->GetTabContentsAt(i), i,
825 i == model_->selected_index());
826 }
827 }
828
821 //////////////////////////////////////////////////////////////////////////////// 829 ////////////////////////////////////////////////////////////////////////////////
822 // TabStrip, BaseTabStrip implementation: 830 // TabStrip, BaseTabStrip implementation:
823 831
824 int TabStrip::GetPreferredHeight() { 832 int TabStrip::GetPreferredHeight() {
825 return GetPreferredSize().height(); 833 return GetPreferredSize().height();
826 } 834 }
827 835
828 void TabStrip::SetBackgroundOffset(const gfx::Point& offset) { 836 void TabStrip::SetBackgroundOffset(const gfx::Point& offset) {
829 int tab_count = GetTabCount(); 837 int tab_count = GetTabCount();
830 for (int i = 0; i < tab_count; ++i) 838 for (int i = 0; i < tab_count; ++i)
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 // TabStrip, Tab::Delegate implementation: 1271 // TabStrip, Tab::Delegate implementation:
1264 1272
1265 bool TabStrip::IsTabSelected(const Tab* tab) const { 1273 bool TabStrip::IsTabSelected(const Tab* tab) const {
1266 if (tab->closing()) 1274 if (tab->closing())
1267 return false; 1275 return false;
1268 1276
1269 return GetIndexOfTab(tab) == model_->selected_index(); 1277 return GetIndexOfTab(tab) == model_->selected_index();
1270 } 1278 }
1271 1279
1272 bool TabStrip::IsTabPinned(const Tab* tab) const { 1280 bool TabStrip::IsTabPinned(const Tab* tab) const {
1281 // TODO(beng): This "closing" state should be stored in the model.
sky 2010/03/19 16:14:02 You sure? It's only the ui that knows about it. It
1273 if (tab->closing()) 1282 if (tab->closing())
1274 return false; 1283 return false;
1275 1284
1276 return model_->IsTabPinned(GetIndexOfTab(tab)); 1285 return model_->IsTabPinned(GetIndexOfTab(tab));
1277 } 1286 }
1278 1287
1279 void TabStrip::SelectTab(Tab* tab) { 1288 void TabStrip::SelectTab(Tab* tab) {
1280 int index = GetIndexOfTab(tab); 1289 int index = GetIndexOfTab(tab);
1281 if (model_->ContainsIndex(index)) 1290 if (model_->ContainsIndex(index))
1282 model_->SelectTabContentsAt(index, true); 1291 model_->SelectTabContentsAt(index, true);
(...skipping 19 matching lines...) Expand all
1302 } 1311 }
1303 1312
1304 bool TabStrip::IsCommandEnabledForTab( 1313 bool TabStrip::IsCommandEnabledForTab(
1305 TabStripModel::ContextMenuCommand command_id, const Tab* tab) const { 1314 TabStripModel::ContextMenuCommand command_id, const Tab* tab) const {
1306 int index = GetIndexOfTab(tab); 1315 int index = GetIndexOfTab(tab);
1307 if (model_->ContainsIndex(index)) 1316 if (model_->ContainsIndex(index))
1308 return model_->IsContextMenuCommandEnabled(index, command_id); 1317 return model_->IsContextMenuCommandEnabled(index, command_id);
1309 return false; 1318 return false;
1310 } 1319 }
1311 1320
1321 bool TabStrip::IsCommandCheckedForTab(
1322 TabStripModel::ContextMenuCommand command_id, const Tab* tab) const {
1323 // TODO(beng): move to TabStripModel, see note in IsTabPinned.
1324 if (command_id == TabStripModel::CommandTogglePinned)
1325 return IsTabPinned(tab);
1326
1327 int index = GetIndexOfTab(tab);
1328 if (model_->ContainsIndex(index))
1329 return model_->IsContextMenuCommandChecked(index, command_id);
1330 return false;
1331 }
1332
1312 void TabStrip::ExecuteCommandForTab( 1333 void TabStrip::ExecuteCommandForTab(
1313 TabStripModel::ContextMenuCommand command_id, Tab* tab) { 1334 TabStripModel::ContextMenuCommand command_id, Tab* tab) {
1314 int index = GetIndexOfTab(tab); 1335 int index = GetIndexOfTab(tab);
1315 if (model_->ContainsIndex(index)) 1336 if (model_->ContainsIndex(index))
1316 model_->ExecuteContextMenuCommand(index, command_id); 1337 model_->ExecuteContextMenuCommand(index, command_id);
1317 } 1338 }
1318 1339
1319 void TabStrip::StartHighlightTabsForCommand( 1340 void TabStrip::StartHighlightTabsForCommand(
1320 TabStripModel::ContextMenuCommand command_id, Tab* tab) { 1341 TabStripModel::ContextMenuCommand command_id, Tab* tab) {
1321 if (command_id == TabStripModel::CommandCloseTabsOpenedBy) { 1342 if (command_id == TabStripModel::CommandCloseTabsOpenedBy) {
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 } 2071 }
2051 } 2072 }
2052 2073
2053 bool TabStrip::HasPhantomTabs() const { 2074 bool TabStrip::HasPhantomTabs() const {
2054 for (int i = 0; i < GetTabCount(); ++i) { 2075 for (int i = 0; i < GetTabCount(); ++i) {
2055 if (GetTabAt(i)->phantom()) 2076 if (GetTabAt(i)->phantom())
2056 return true; 2077 return true;
2057 } 2078 }
2058 return false; 2079 return false;
2059 } 2080 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698