| OLD | NEW |
| 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/side_tab_strip.h" | 5 #include "chrome/browser/views/tabs/side_tab_strip.h" |
| 6 | 6 |
| 7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "chrome/browser/pref_service.h" | 9 #include "chrome/browser/pref_service.h" |
| 10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 void SideTabStrip::SetModel(SideTabStripModel* model) { | 31 void SideTabStrip::SetModel(SideTabStripModel* model) { |
| 32 model_.reset(model); | 32 model_.reset(model); |
| 33 } | 33 } |
| 34 | 34 |
| 35 // static | 35 // static |
| 36 bool SideTabStrip::Available() { | 36 bool SideTabStrip::Available() { |
| 37 return CommandLine::ForCurrentProcess()->HasSwitch( | 37 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 38 switches::kEnableVerticalTabs); | 38 switches::kEnableVerticalTabs); |
| 39 } | 39 } |
| 40 | 40 |
| 41 // static | |
| 42 bool SideTabStrip::Visible(Profile* profile) { | |
| 43 return Available() && | |
| 44 profile->GetPrefs()->GetBoolean(prefs::kUseVerticalTabs); | |
| 45 } | |
| 46 | |
| 47 void SideTabStrip::AddTabAt(int index) { | 41 void SideTabStrip::AddTabAt(int index) { |
| 48 SideTab* tab = new SideTab(this); | 42 SideTab* tab = new SideTab(this); |
| 49 AddChildView(tab); | 43 AddChildView(tab); |
| 50 Layout(); | 44 Layout(); |
| 51 } | 45 } |
| 52 | 46 |
| 53 void SideTabStrip::RemoveTabAt(int index) { | 47 void SideTabStrip::RemoveTabAt(int index) { |
| 54 View* v = GetChildViewAt(index); | 48 View* v = GetChildViewAt(index); |
| 55 RemoveChildView(v); | 49 RemoveChildView(v); |
| 56 delete v; | 50 delete v; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 81 } | 75 } |
| 82 | 76 |
| 83 void SideTabStrip::SelectTab(SideTab* tab) { | 77 void SideTabStrip::SelectTab(SideTab* tab) { |
| 84 model_->SelectTab(GetIndexOfSideTab(tab)); | 78 model_->SelectTab(GetIndexOfSideTab(tab)); |
| 85 } | 79 } |
| 86 | 80 |
| 87 void SideTabStrip::CloseTab(SideTab* tab) { | 81 void SideTabStrip::CloseTab(SideTab* tab) { |
| 88 model_->CloseTab(GetIndexOfSideTab(tab)); | 82 model_->CloseTab(GetIndexOfSideTab(tab)); |
| 89 } | 83 } |
| 90 | 84 |
| 85 void SideTabStrip::ShowContextMenu(SideTab* tab, const gfx::Point& p) { |
| 86 model_->ShowContextMenu(GetIndexOfSideTab(tab), p); |
| 87 } |
| 88 |
| 91 //////////////////////////////////////////////////////////////////////////////// | 89 //////////////////////////////////////////////////////////////////////////////// |
| 92 // SideTabStrip, BaseTabStrip implementation: | 90 // SideTabStrip, BaseTabStrip implementation: |
| 93 | 91 |
| 94 int SideTabStrip::GetPreferredHeight() { | 92 int SideTabStrip::GetPreferredHeight() { |
| 95 return 0; | 93 return 0; |
| 96 } | 94 } |
| 97 | 95 |
| 98 void SideTabStrip::SetBackgroundOffset(const gfx::Point& offset) { | 96 void SideTabStrip::SetBackgroundOffset(const gfx::Point& offset) { |
| 99 } | 97 } |
| 100 | 98 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 //////////////////////////////////////////////////////////////////////////////// | 144 //////////////////////////////////////////////////////////////////////////////// |
| 147 // SideTabStrip, private: | 145 // SideTabStrip, private: |
| 148 | 146 |
| 149 int SideTabStrip::GetIndexOfSideTab(SideTab* tab) const { | 147 int SideTabStrip::GetIndexOfSideTab(SideTab* tab) const { |
| 150 return GetChildIndex(tab); | 148 return GetChildIndex(tab); |
| 151 } | 149 } |
| 152 | 150 |
| 153 SideTab* SideTabStrip::GetSideTabAt(int index) const { | 151 SideTab* SideTabStrip::GetSideTabAt(int index) const { |
| 154 return static_cast<SideTab*>(GetChildViewAt(index)); | 152 return static_cast<SideTab*>(GetChildViewAt(index)); |
| 155 } | 153 } |
| OLD | NEW |