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/browser_tab_strip_controller.h" | 5 #include "chrome/browser/views/tabs/browser_tab_strip_controller.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "chrome/browser/browser.h" | 9 #include "chrome/browser/browser.h" |
10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 return TabRendererData::NETWORK_STATE_WAITING; | 29 return TabRendererData::NETWORK_STATE_WAITING; |
30 return TabRendererData::NETWORK_STATE_LOADING; | 30 return TabRendererData::NETWORK_STATE_LOADING; |
31 } | 31 } |
32 | 32 |
33 class BrowserTabStripController::TabContextMenuContents | 33 class BrowserTabStripController::TabContextMenuContents |
34 : public menus::SimpleMenuModel::Delegate { | 34 : public menus::SimpleMenuModel::Delegate { |
35 public: | 35 public: |
36 TabContextMenuContents(BaseTab* tab, | 36 TabContextMenuContents(BaseTab* tab, |
37 BrowserTabStripController* controller) | 37 BrowserTabStripController* controller) |
38 : ALLOW_THIS_IN_INITIALIZER_LIST( | 38 : ALLOW_THIS_IN_INITIALIZER_LIST( |
39 model_(this, controller->IsTabPinned(tab), controller->IsAppTab(tab), | 39 model_(this, controller->IsTabPinned(tab))), |
40 controller->IsToolbarVisible(tab))), | |
41 tab_(tab), | 40 tab_(tab), |
42 controller_(controller), | 41 controller_(controller), |
43 last_command_(TabStripModel::CommandFirst) { | 42 last_command_(TabStripModel::CommandFirst) { |
44 Build(); | 43 Build(); |
45 } | 44 } |
46 virtual ~TabContextMenuContents() { | 45 virtual ~TabContextMenuContents() { |
47 menu_->CancelMenu(); | 46 menu_->CancelMenu(); |
48 if (controller_) | 47 if (controller_) |
49 controller_->tabstrip_->StopAllHighlighting(); | 48 controller_->tabstrip_->StopAllHighlighting(); |
50 } | 49 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 BaseTab* tab) { | 163 BaseTab* tab) { |
165 int model_index = tabstrip_->GetModelIndexOfBaseTab(tab); | 164 int model_index = tabstrip_->GetModelIndexOfBaseTab(tab); |
166 if (model_->ContainsIndex(model_index)) | 165 if (model_->ContainsIndex(model_index)) |
167 model_->ExecuteContextMenuCommand(model_index, command_id); | 166 model_->ExecuteContextMenuCommand(model_index, command_id); |
168 } | 167 } |
169 | 168 |
170 bool BrowserTabStripController::IsTabPinned(BaseTab* tab) { | 169 bool BrowserTabStripController::IsTabPinned(BaseTab* tab) { |
171 return IsTabPinned(tabstrip_->GetModelIndexOfBaseTab(tab)); | 170 return IsTabPinned(tabstrip_->GetModelIndexOfBaseTab(tab)); |
172 } | 171 } |
173 | 172 |
174 bool BrowserTabStripController::IsAppTab(BaseTab* tab) { | |
175 int index = tabstrip_->GetModelIndexOfBaseTab(tab); | |
176 if (!model_->ContainsIndex(index)) | |
177 return false; | |
178 | |
179 return model_->IsAppTab(index); | |
180 } | |
181 | |
182 bool BrowserTabStripController::IsToolbarVisible(BaseTab* tab) { | |
183 int index = tabstrip_->GetModelIndexOfBaseTab(tab); | |
184 if (!model_->ContainsIndex(index)) | |
185 return false; | |
186 | |
187 return model_->IsToolbarVisible(index); | |
188 } | |
189 | |
190 int BrowserTabStripController::GetCount() const { | 173 int BrowserTabStripController::GetCount() const { |
191 return model_->count(); | 174 return model_->count(); |
192 } | 175 } |
193 | 176 |
194 bool BrowserTabStripController::IsValidIndex(int index) const { | 177 bool BrowserTabStripController::IsValidIndex(int index) const { |
195 return model_->ContainsIndex(index); | 178 return model_->ContainsIndex(index); |
196 } | 179 } |
197 | 180 |
198 int BrowserTabStripController::GetSelectedIndex() const { | 181 int BrowserTabStripController::GetSelectedIndex() const { |
199 return model_->selected_index(); | 182 return model_->selected_index(); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 DCHECK(type.value == NotificationType::TAB_CLOSEABLE_STATE_CHANGED); | 420 DCHECK(type.value == NotificationType::TAB_CLOSEABLE_STATE_CHANGED); |
438 // Note that this notification may be fired during a model mutation and | 421 // Note that this notification may be fired during a model mutation and |
439 // possibly before the tabstrip has processed the change. | 422 // possibly before the tabstrip has processed the change. |
440 // Here, we just re-layout each existing tab to reflect the change in its | 423 // Here, we just re-layout each existing tab to reflect the change in its |
441 // closeable state, and then schedule paint for entire tabstrip. | 424 // closeable state, and then schedule paint for entire tabstrip. |
442 for (int i = 0; i < tabstrip_->tab_count(); ++i) { | 425 for (int i = 0; i < tabstrip_->tab_count(); ++i) { |
443 tabstrip_->base_tab_at_tab_index(i)->Layout(); | 426 tabstrip_->base_tab_at_tab_index(i)->Layout(); |
444 } | 427 } |
445 tabstrip_->SchedulePaint(); | 428 tabstrip_->SchedulePaint(); |
446 } | 429 } |
OLD | NEW |