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

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

Issue 1141005: Revert r42156, r42157, r42160. Allow dynamic switching in and out of sidetabs... (Closed) Base URL: svn://chrome-svn/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
« no previous file with comments | « chrome/browser/tabs/tab_strip_model.h ('k') | chrome/browser/tabs/tab_strip_model_unittest.cc » ('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) 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
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 case CommandUseVerticalTabs: 579 }
580 return true;
581 default: 580 default:
582 NOTREACHED(); 581 NOTREACHED();
583 } 582 }
584 return false; 583 return false;
585 } 584 }
586 585
587 bool TabStripModel::IsContextMenuCommandChecked(
588 int context_index,
589 ContextMenuCommand command_id) const {
590 switch (command_id) {
591 case CommandUseVerticalTabs:
592 return delegate()->UseVerticalTabs();
593 default:
594 NOTREACHED();
595 break;
596 }
597 return false;
598 }
599
600 void TabStripModel::ExecuteContextMenuCommand( 586 void TabStripModel::ExecuteContextMenuCommand(
601 int context_index, ContextMenuCommand command_id) { 587 int context_index, ContextMenuCommand command_id) {
602 DCHECK(command_id > CommandFirst && command_id < CommandLast); 588 DCHECK(command_id > CommandFirst && command_id < CommandLast);
603 switch (command_id) { 589 switch (command_id) {
604 case CommandNewTab: 590 case CommandNewTab:
605 UserMetrics::RecordAction("TabContextMenu_NewTab", profile_); 591 UserMetrics::RecordAction("TabContextMenu_NewTab", profile_);
606 delegate()->AddBlankTabAt(context_index + 1, true); 592 delegate()->AddBlankTabAt(context_index + 1, true);
607 break; 593 break;
608 case CommandReload: 594 case CommandReload:
609 UserMetrics::RecordAction("TabContextMenu_Reload", profile_); 595 UserMetrics::RecordAction("TabContextMenu_Reload", profile_);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 SetTabPinned(context_index, !IsTabPinned(context_index)); 649 SetTabPinned(context_index, !IsTabPinned(context_index));
664 break; 650 break;
665 } 651 }
666 652
667 case CommandBookmarkAllTabs: { 653 case CommandBookmarkAllTabs: {
668 UserMetrics::RecordAction("TabContextMenu_BookmarkAllTabs", profile_); 654 UserMetrics::RecordAction("TabContextMenu_BookmarkAllTabs", profile_);
669 655
670 delegate_->BookmarkAllTabs(); 656 delegate_->BookmarkAllTabs();
671 break; 657 break;
672 } 658 }
673 case CommandUseVerticalTabs: {
674 UserMetrics::RecordAction("TabContextMenu_UseVerticalTabs", profile_);
675
676 delegate()->ToggleUseVerticalTabs();
677 break;
678 }
679 default: 659 default:
680 NOTREACHED(); 660 NOTREACHED();
681 } 661 }
682 } 662 }
683 663
684 std::vector<int> TabStripModel::GetIndexesOpenedBy(int index) const { 664 std::vector<int> TabStripModel::GetIndexesOpenedBy(int index) const {
685 std::vector<int> indices; 665 std::vector<int> indices;
686 NavigationController* opener = &GetTabContentsAt(index)->controller(); 666 NavigationController* opener = &GetTabContentsAt(index)->controller();
687 for (int i = count() - 1; i >= 0; --i) { 667 for (int i = count() - 1; i >= 0; --i) {
688 if (OpenerMatches(contents_data_.at(i), opener, true)) 668 if (OpenerMatches(contents_data_.at(i), opener, true))
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 FOR_EACH_OBSERVER(TabStripModelObserver, observers_, 930 FOR_EACH_OBSERVER(TabStripModelObserver, observers_,
951 TabMoved(moved_data->contents, index, to_position)); 931 TabMoved(moved_data->contents, index, to_position));
952 } 932 }
953 933
954 // static 934 // static
955 bool TabStripModel::OpenerMatches(const TabContentsData* data, 935 bool TabStripModel::OpenerMatches(const TabContentsData* data,
956 const NavigationController* opener, 936 const NavigationController* opener,
957 bool use_group) { 937 bool use_group) {
958 return data->opener == opener || (use_group && data->group == opener); 938 return data->opener == opener || (use_group && data->group == opener);
959 } 939 }
OLDNEW
« no previous file with comments | « chrome/browser/tabs/tab_strip_model.h ('k') | chrome/browser/tabs/tab_strip_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698