OLD | NEW |
---|---|
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
567 int next_index = GetIndexOfNextTabContentsOpenedBy( | 567 int next_index = GetIndexOfNextTabContentsOpenedBy( |
568 &GetTabContentsAt(context_index)->controller(), context_index, true); | 568 &GetTabContentsAt(context_index)->controller(), context_index, true); |
569 return next_index != kNoTab && !IsMiniTab(next_index); | 569 return next_index != kNoTab && !IsMiniTab(next_index); |
570 } | 570 } |
571 case CommandDuplicate: | 571 case CommandDuplicate: |
572 return delegate_->CanDuplicateContentsAt(context_index); | 572 return delegate_->CanDuplicateContentsAt(context_index); |
573 case CommandRestoreTab: | 573 case CommandRestoreTab: |
574 return delegate_->CanRestoreTab(); | 574 return delegate_->CanRestoreTab(); |
575 case CommandTogglePinned: | 575 case CommandTogglePinned: |
576 return true; | 576 return true; |
577 case CommandBookmarkAllTabs: { | 577 case CommandBookmarkAllTabs: |
578 return delegate_->CanBookmarkAllTabs(); | 578 return delegate_->CanBookmarkAllTabs(); |
579 } | 579 case CommandUseVerticalTabs: |
580 return true; | |
580 default: | 581 default: |
581 NOTREACHED(); | 582 NOTREACHED(); |
582 } | 583 } |
583 return false; | 584 return false; |
584 } | 585 } |
585 | 586 |
587 bool TabStripModel::IsContextMenuCommandChecked(int context_index, | |
588 ContextMenuCommand command_id) c onst { | |
sky
2010/03/19 16:14:02
nit: > 80
| |
589 switch (command_id) { | |
590 case CommandUseVerticalTabs: | |
591 return delegate()->UseVerticalTabs(); | |
592 default: | |
593 NOTREACHED(); | |
594 break; | |
595 } | |
596 return false; | |
597 } | |
598 | |
586 void TabStripModel::ExecuteContextMenuCommand( | 599 void TabStripModel::ExecuteContextMenuCommand( |
587 int context_index, ContextMenuCommand command_id) { | 600 int context_index, ContextMenuCommand command_id) { |
588 DCHECK(command_id > CommandFirst && command_id < CommandLast); | 601 DCHECK(command_id > CommandFirst && command_id < CommandLast); |
589 switch (command_id) { | 602 switch (command_id) { |
590 case CommandNewTab: | 603 case CommandNewTab: |
591 UserMetrics::RecordAction("TabContextMenu_NewTab", profile_); | 604 UserMetrics::RecordAction("TabContextMenu_NewTab", profile_); |
592 delegate()->AddBlankTabAt(context_index + 1, true); | 605 delegate()->AddBlankTabAt(context_index + 1, true); |
593 break; | 606 break; |
594 case CommandReload: | 607 case CommandReload: |
595 UserMetrics::RecordAction("TabContextMenu_Reload", profile_); | 608 UserMetrics::RecordAction("TabContextMenu_Reload", profile_); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
649 SetTabPinned(context_index, !IsTabPinned(context_index)); | 662 SetTabPinned(context_index, !IsTabPinned(context_index)); |
650 break; | 663 break; |
651 } | 664 } |
652 | 665 |
653 case CommandBookmarkAllTabs: { | 666 case CommandBookmarkAllTabs: { |
654 UserMetrics::RecordAction("TabContextMenu_BookmarkAllTabs", profile_); | 667 UserMetrics::RecordAction("TabContextMenu_BookmarkAllTabs", profile_); |
655 | 668 |
656 delegate_->BookmarkAllTabs(); | 669 delegate_->BookmarkAllTabs(); |
657 break; | 670 break; |
658 } | 671 } |
672 case CommandUseVerticalTabs: { | |
673 UserMetrics::RecordAction("TabContextMenu_UseVerticalTabs", profile_); | |
674 | |
675 delegate()->ToggleUseVerticalTabs(); | |
676 break; | |
677 } | |
659 default: | 678 default: |
660 NOTREACHED(); | 679 NOTREACHED(); |
661 } | 680 } |
662 } | 681 } |
663 | 682 |
664 std::vector<int> TabStripModel::GetIndexesOpenedBy(int index) const { | 683 std::vector<int> TabStripModel::GetIndexesOpenedBy(int index) const { |
665 std::vector<int> indices; | 684 std::vector<int> indices; |
666 NavigationController* opener = &GetTabContentsAt(index)->controller(); | 685 NavigationController* opener = &GetTabContentsAt(index)->controller(); |
667 for (int i = count() - 1; i >= 0; --i) { | 686 for (int i = count() - 1; i >= 0; --i) { |
668 if (OpenerMatches(contents_data_.at(i), opener, true)) | 687 if (OpenerMatches(contents_data_.at(i), opener, true)) |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
930 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, | 949 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, |
931 TabMoved(moved_data->contents, index, to_position)); | 950 TabMoved(moved_data->contents, index, to_position)); |
932 } | 951 } |
933 | 952 |
934 // static | 953 // static |
935 bool TabStripModel::OpenerMatches(const TabContentsData* data, | 954 bool TabStripModel::OpenerMatches(const TabContentsData* data, |
936 const NavigationController* opener, | 955 const NavigationController* opener, |
937 bool use_group) { | 956 bool use_group) { |
938 return data->opener == opener || (use_group && data->group == opener); | 957 return data->opener == opener || (use_group && data->group == opener); |
939 } | 958 } |
OLD | NEW |