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

Side by Side Diff: chrome/browser/tabs/tab_strip_model.cc

Issue 6913026: Compact Navigation prototype (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Clang build fix. After commit/revert. Created 9 years, 7 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
« no previous file with comments | « chrome/browser/tabs/tab_strip_model.h ('k') | chrome/browser/tabs/tab_strip_model_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/tabs/tab_strip_model.h" 5 #include "chrome/browser/tabs/tab_strip_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 int new_index = std::min(active_index() + 1, count() - 1); 704 int new_index = std::min(active_index() + 1, count() - 1);
705 MoveTabContentsAt(active_index(), new_index, true); 705 MoveTabContentsAt(active_index(), new_index, true);
706 } 706 }
707 707
708 void TabStripModel::MoveTabPrevious() { 708 void TabStripModel::MoveTabPrevious() {
709 // TODO: this likely needs to be updated for multi-selection. 709 // TODO: this likely needs to be updated for multi-selection.
710 int new_index = std::max(active_index() - 1, 0); 710 int new_index = std::max(active_index() - 1, 0);
711 MoveTabContentsAt(active_index(), new_index, true); 711 MoveTabContentsAt(active_index(), new_index, true);
712 } 712 }
713 713
714 void TabStripModel::ActiveTabClicked(int index) {
715 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, ActiveTabClicked(index));
716 }
717
714 // Context menu functions. 718 // Context menu functions.
715 bool TabStripModel::IsContextMenuCommandEnabled( 719 bool TabStripModel::IsContextMenuCommandEnabled(
716 int context_index, ContextMenuCommand command_id) const { 720 int context_index, ContextMenuCommand command_id) const {
717 DCHECK(command_id > CommandFirst && command_id < CommandLast); 721 DCHECK(command_id > CommandFirst && command_id < CommandLast);
718 switch (command_id) { 722 switch (command_id) {
719 case CommandNewTab: 723 case CommandNewTab:
720 return true; 724 return true;
721 725
722 case CommandCloseTab: 726 case CommandCloseTab:
723 return delegate_->CanCloseTab(); 727 return delegate_->CanCloseTab();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 return true; 761 return true;
758 } 762 }
759 return false; 763 return false;
760 } 764 }
761 765
762 case CommandBookmarkAllTabs: 766 case CommandBookmarkAllTabs:
763 return browser_defaults::bookmarks_enabled && 767 return browser_defaults::bookmarks_enabled &&
764 delegate_->CanBookmarkAllTabs(); 768 delegate_->CanBookmarkAllTabs();
765 769
766 case CommandUseVerticalTabs: 770 case CommandUseVerticalTabs:
771 case CommandUseCompactNavigationBar:
767 return true; 772 return true;
768 773
769 case CommandSelectByDomain: 774 case CommandSelectByDomain:
770 case CommandSelectByOpener: 775 case CommandSelectByOpener:
771 return true; 776 return true;
772 777
773 default: 778 default:
774 NOTREACHED(); 779 NOTREACHED();
775 } 780 }
776 return false; 781 return false;
777 } 782 }
778 783
779 bool TabStripModel::IsContextMenuCommandChecked( 784 bool TabStripModel::IsContextMenuCommandChecked(
780 int context_index, 785 int context_index,
781 ContextMenuCommand command_id) const { 786 ContextMenuCommand command_id) const {
782 switch (command_id) { 787 switch (command_id) {
783 case CommandUseVerticalTabs: 788 case CommandUseVerticalTabs:
784 return delegate()->UseVerticalTabs(); 789 return delegate()->UseVerticalTabs();
790 case CommandUseCompactNavigationBar:
791 return delegate()->UseCompactNavigationBar();
785 default: 792 default:
786 NOTREACHED(); 793 NOTREACHED();
787 break; 794 break;
788 } 795 }
789 return false; 796 return false;
790 } 797 }
791 798
792 void TabStripModel::ExecuteContextMenuCommand( 799 void TabStripModel::ExecuteContextMenuCommand(
793 int context_index, ContextMenuCommand command_id) { 800 int context_index, ContextMenuCommand command_id) {
794 DCHECK(command_id > CommandFirst && command_id < CommandLast); 801 DCHECK(command_id > CommandFirst && command_id < CommandLast);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 } 904 }
898 905
899 case CommandUseVerticalTabs: { 906 case CommandUseVerticalTabs: {
900 UserMetrics::RecordAction( 907 UserMetrics::RecordAction(
901 UserMetricsAction("TabContextMenu_UseVerticalTabs")); 908 UserMetricsAction("TabContextMenu_UseVerticalTabs"));
902 909
903 delegate()->ToggleUseVerticalTabs(); 910 delegate()->ToggleUseVerticalTabs();
904 break; 911 break;
905 } 912 }
906 913
914 case CommandUseCompactNavigationBar: {
915 UserMetrics::RecordAction(
916 UserMetricsAction("TabContextMenu_CompactNavigationBar"));
917
918 delegate()->ToggleUseCompactNavigationBar();
919 break;
920 }
921
907 case CommandSelectByDomain: 922 case CommandSelectByDomain:
908 case CommandSelectByOpener: { 923 case CommandSelectByOpener: {
909 std::vector<int> indices; 924 std::vector<int> indices;
910 if (command_id == CommandSelectByDomain) 925 if (command_id == CommandSelectByDomain)
911 GetIndicesWithSameDomain(context_index, &indices); 926 GetIndicesWithSameDomain(context_index, &indices);
912 else 927 else
913 GetIndicesWithSameOpener(context_index, &indices); 928 GetIndicesWithSameOpener(context_index, &indices);
914 TabStripSelectionModel selection_model; 929 TabStripSelectionModel selection_model;
915 selection_model.SetSelectedIndex(context_index); 930 selection_model.SetSelectedIndex(context_index);
916 for (size_t i = 0; i < indices.size(); ++i) 931 for (size_t i = 0; i < indices.size(); ++i)
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 break; 1037 break;
1023 case CommandRestoreTab: 1038 case CommandRestoreTab:
1024 *browser_cmd = IDC_RESTORE_TAB; 1039 *browser_cmd = IDC_RESTORE_TAB;
1025 break; 1040 break;
1026 case CommandBookmarkAllTabs: 1041 case CommandBookmarkAllTabs:
1027 *browser_cmd = IDC_BOOKMARK_ALL_TABS; 1042 *browser_cmd = IDC_BOOKMARK_ALL_TABS;
1028 break; 1043 break;
1029 case CommandUseVerticalTabs: 1044 case CommandUseVerticalTabs:
1030 *browser_cmd = IDC_TOGGLE_VERTICAL_TABS; 1045 *browser_cmd = IDC_TOGGLE_VERTICAL_TABS;
1031 break; 1046 break;
1047 case CommandUseCompactNavigationBar:
1048 *browser_cmd = IDC_COMPACT_NAVBAR;
1049 break;
1032 default: 1050 default:
1033 *browser_cmd = 0; 1051 *browser_cmd = 0;
1034 return false; 1052 return false;
1035 } 1053 }
1036 1054
1037 return true; 1055 return true;
1038 } 1056 }
1039 1057
1040 /////////////////////////////////////////////////////////////////////////////// 1058 ///////////////////////////////////////////////////////////////////////////////
1041 // TabStripModel, private: 1059 // TabStripModel, private:
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 void TabStripModel::ForgetOpenersAndGroupsReferencing( 1310 void TabStripModel::ForgetOpenersAndGroupsReferencing(
1293 const NavigationController* tab) { 1311 const NavigationController* tab) {
1294 for (TabContentsDataVector::const_iterator i = contents_data_.begin(); 1312 for (TabContentsDataVector::const_iterator i = contents_data_.begin();
1295 i != contents_data_.end(); ++i) { 1313 i != contents_data_.end(); ++i) {
1296 if ((*i)->group == tab) 1314 if ((*i)->group == tab)
1297 (*i)->group = NULL; 1315 (*i)->group = NULL;
1298 if ((*i)->opener == tab) 1316 if ((*i)->opener == tab)
1299 (*i)->opener = NULL; 1317 (*i)->opener = NULL;
1300 } 1318 }
1301 } 1319 }
OLDNEW
« no previous file with comments | « chrome/browser/tabs/tab_strip_model.h ('k') | chrome/browser/tabs/tab_strip_model_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698