OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/views/tabs/base_tab.h" | 5 #include "chrome/browser/ui/views/tabs/base_tab.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 return tp ? tp : theme_provider_; | 283 return tp ? tp : theme_provider_; |
284 } | 284 } |
285 | 285 |
286 bool BaseTab::OnMousePressed(const views::MouseEvent& event) { | 286 bool BaseTab::OnMousePressed(const views::MouseEvent& event) { |
287 if (!controller()) | 287 if (!controller()) |
288 return false; | 288 return false; |
289 | 289 |
290 if (event.IsOnlyLeftMouseButton()) { | 290 if (event.IsOnlyLeftMouseButton()) { |
291 TabStripSelectionModel original_selection; | 291 TabStripSelectionModel original_selection; |
292 original_selection.Copy(controller()->GetSelectionModel()); | 292 original_selection.Copy(controller()->GetSelectionModel()); |
293 if (event.IsShiftDown() && event.IsControlDown()) { | 293 if (controller()->SupportsMultipleSelection()) { |
294 controller()->AddSelectionFromAnchorTo(this); | 294 if (event.IsShiftDown() && event.IsControlDown()) { |
295 } else if (event.IsShiftDown()) { | 295 controller()->AddSelectionFromAnchorTo(this); |
296 controller()->ExtendSelectionTo(this); | 296 } else if (event.IsShiftDown()) { |
297 } else if (event.IsControlDown()) { | 297 controller()->ExtendSelectionTo(this); |
298 controller()->ToggleSelected(this); | 298 } else if (event.IsControlDown()) { |
299 if (!IsSelected()) { | 299 controller()->ToggleSelected(this); |
300 // Don't allow dragging non-selected tabs. | 300 if (!IsSelected()) { |
301 return false; | 301 // Don't allow dragging non-selected tabs. |
| 302 return false; |
| 303 } |
| 304 } else if (!IsSelected()) { |
| 305 controller()->SelectTab(this); |
| 306 } else if (IsActive()) { |
| 307 controller()->ClickActiveTab(this); |
302 } | 308 } |
303 } else if (!IsSelected()) { | 309 } else if (!IsSelected()) { |
304 controller()->SelectTab(this); | 310 controller()->SelectTab(this); |
305 } else if (IsActive()) { | |
306 controller()->ClickActiveTab(this); | |
307 } | 311 } |
308 controller()->MaybeStartDrag(this, event, original_selection); | 312 controller()->MaybeStartDrag(this, event, original_selection); |
309 } | 313 } |
310 return true; | 314 return true; |
311 } | 315 } |
312 | 316 |
313 bool BaseTab::OnMouseDragged(const views::MouseEvent& event) { | 317 bool BaseTab::OnMouseDragged(const views::MouseEvent& event) { |
314 if (controller()) | 318 if (controller()) |
315 controller()->ContinueDrag(event); | 319 controller()->ContinueDrag(event); |
316 return true; | 320 return true; |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 // static | 573 // static |
570 void BaseTab::InitResources() { | 574 void BaseTab::InitResources() { |
571 static bool initialized = false; | 575 static bool initialized = false; |
572 if (!initialized) { | 576 if (!initialized) { |
573 initialized = true; | 577 initialized = true; |
574 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 578 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
575 font_ = new gfx::Font(rb.GetFont(ui::ResourceBundle::BaseFont)); | 579 font_ = new gfx::Font(rb.GetFont(ui::ResourceBundle::BaseFont)); |
576 font_height_ = font_->GetHeight(); | 580 font_height_ = font_->GetHeight(); |
577 } | 581 } |
578 } | 582 } |
OLD | NEW |