| 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/debug/alias.h" | 10 #include "base/debug/alias.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 tab_->controller()->OnMouseEventInTab(this, event); | 83 tab_->controller()->OnMouseEventInTab(this, event); |
| 84 CustomButton::OnMouseMoved(event); | 84 CustomButton::OnMouseMoved(event); |
| 85 } | 85 } |
| 86 | 86 |
| 87 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE { | 87 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE { |
| 88 if (tab_->controller()) | 88 if (tab_->controller()) |
| 89 tab_->controller()->OnMouseEventInTab(this, event); | 89 tab_->controller()->OnMouseEventInTab(this, event); |
| 90 CustomButton::OnMouseReleased(event); | 90 CustomButton::OnMouseReleased(event); |
| 91 } | 91 } |
| 92 | 92 |
| 93 virtual ui::GestureStatus OnGestureEvent( | 93 virtual ui::EventResult OnGestureEvent( |
| 94 const ui::GestureEvent& event) OVERRIDE { | 94 const ui::GestureEvent& event) OVERRIDE { |
| 95 // Consume all gesture events here so that the parent (BaseTab) does not | 95 // Consume all gesture events here so that the parent (BaseTab) does not |
| 96 // start consuming gestures. | 96 // start consuming gestures. |
| 97 ImageButton::OnGestureEvent(event); | 97 ImageButton::OnGestureEvent(event); |
| 98 return ui::GESTURE_STATUS_CONSUMED; | 98 return ui::ER_CONSUMED; |
| 99 } | 99 } |
| 100 | 100 |
| 101 private: | 101 private: |
| 102 BaseTab* tab_; | 102 BaseTab* tab_; |
| 103 | 103 |
| 104 DISALLOW_COPY_AND_ASSIGN(TabCloseButton); | 104 DISALLOW_COPY_AND_ASSIGN(TabCloseButton); |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 namespace { | 107 namespace { |
| 108 | 108 |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 | 404 |
| 405 void BaseTab::OnMouseMoved(const ui::MouseEvent& event) { | 405 void BaseTab::OnMouseMoved(const ui::MouseEvent& event) { |
| 406 if (controller()) | 406 if (controller()) |
| 407 controller()->OnMouseEventInTab(this, event); | 407 controller()->OnMouseEventInTab(this, event); |
| 408 } | 408 } |
| 409 | 409 |
| 410 void BaseTab::OnMouseExited(const ui::MouseEvent& event) { | 410 void BaseTab::OnMouseExited(const ui::MouseEvent& event) { |
| 411 hover_controller_.Hide(); | 411 hover_controller_.Hide(); |
| 412 } | 412 } |
| 413 | 413 |
| 414 ui::GestureStatus BaseTab::OnGestureEvent(const ui::GestureEvent& event) { | 414 ui::EventResult BaseTab::OnGestureEvent(const ui::GestureEvent& event) { |
| 415 if (!controller()) | 415 if (!controller()) |
| 416 return ui::GESTURE_STATUS_CONSUMED; | 416 return ui::ER_CONSUMED; |
| 417 | 417 |
| 418 switch (event.type()) { | 418 switch (event.type()) { |
| 419 case ui::ET_GESTURE_BEGIN: { | 419 case ui::ET_GESTURE_BEGIN: { |
| 420 if (event.details().touch_points() != 1) | 420 if (event.details().touch_points() != 1) |
| 421 return ui::GESTURE_STATUS_UNKNOWN; | 421 return ui::ER_UNHANDLED; |
| 422 | 422 |
| 423 TabStripSelectionModel original_selection; | 423 TabStripSelectionModel original_selection; |
| 424 original_selection.Copy(controller()->GetSelectionModel()); | 424 original_selection.Copy(controller()->GetSelectionModel()); |
| 425 if (!IsSelected()) | 425 if (!IsSelected()) |
| 426 controller()->SelectTab(this); | 426 controller()->SelectTab(this); |
| 427 gfx::Point loc(event.location()); | 427 gfx::Point loc(event.location()); |
| 428 views::View::ConvertPointToScreen(this, &loc); | 428 views::View::ConvertPointToScreen(this, &loc); |
| 429 controller()->MaybeStartDrag(this, event, original_selection); | 429 controller()->MaybeStartDrag(this, event, original_selection); |
| 430 break; | 430 break; |
| 431 } | 431 } |
| 432 | 432 |
| 433 case ui::ET_GESTURE_END: | 433 case ui::ET_GESTURE_END: |
| 434 controller()->EndDrag(END_DRAG_COMPLETE); | 434 controller()->EndDrag(END_DRAG_COMPLETE); |
| 435 break; | 435 break; |
| 436 | 436 |
| 437 case ui::ET_GESTURE_SCROLL_UPDATE: | 437 case ui::ET_GESTURE_SCROLL_UPDATE: |
| 438 controller()->ContinueDrag(this, event.location()); | 438 controller()->ContinueDrag(this, event.location()); |
| 439 break; | 439 break; |
| 440 | 440 |
| 441 default: | 441 default: |
| 442 break; | 442 break; |
| 443 } | 443 } |
| 444 return ui::GESTURE_STATUS_CONSUMED; | 444 return ui::ER_CONSUMED; |
| 445 } | 445 } |
| 446 | 446 |
| 447 bool BaseTab::GetTooltipText(const gfx::Point& p, string16* tooltip) const { | 447 bool BaseTab::GetTooltipText(const gfx::Point& p, string16* tooltip) const { |
| 448 if (data_.title.empty()) | 448 if (data_.title.empty()) |
| 449 return false; | 449 return false; |
| 450 | 450 |
| 451 // Only show the tooltip if the title is truncated. | 451 // Only show the tooltip if the title is truncated. |
| 452 if (font_->GetStringWidth(data_.title) > GetTitleBounds().width()) { | 452 if (font_->GetStringWidth(data_.title) > GetTitleBounds().width()) { |
| 453 *tooltip = data_.title; | 453 *tooltip = data_.title; |
| 454 return true; | 454 return true; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 // static | 655 // static |
| 656 void BaseTab::InitResources() { | 656 void BaseTab::InitResources() { |
| 657 static bool initialized = false; | 657 static bool initialized = false; |
| 658 if (!initialized) { | 658 if (!initialized) { |
| 659 initialized = true; | 659 initialized = true; |
| 660 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 660 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 661 font_ = new gfx::Font(rb.GetFont(ui::ResourceBundle::BaseFont)); | 661 font_ = new gfx::Font(rb.GetFont(ui::ResourceBundle::BaseFont)); |
| 662 font_height_ = font_->GetHeight(); | 662 font_height_ = font_->GetHeight(); |
| 663 } | 663 } |
| 664 } | 664 } |
| OLD | NEW |