| 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/tab.h" | 5 #include "chrome/browser/ui/views/tabs/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" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/defaults.h" | 12 #include "chrome/browser/defaults.h" |
| 13 #include "chrome/browser/themes/theme_properties.h" | 13 #include "chrome/browser/themes/theme_properties.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 15 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 16 #include "chrome/browser/ui/tabs/tab_resources.h" | 16 #include "chrome/browser/ui/tabs/tab_resources.h" |
| 17 #include "chrome/browser/ui/view_ids.h" | 17 #include "chrome/browser/ui/view_ids.h" |
| 18 #include "chrome/browser/ui/views/tabs/tab_controller.h" | 18 #include "chrome/browser/ui/views/tabs/tab_controller.h" |
| 19 #include "chrome/browser/ui/views/theme_image_mapper.h" | 19 #include "chrome/browser/ui/views/theme_image_mapper.h" |
| 20 #include "chrome/browser/ui/views/touch_uma/touch_uma.h" |
| 20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 21 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
| 22 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
| 23 #include "grit/ui_resources.h" | 24 #include "grit/ui_resources.h" |
| 24 #include "third_party/skia/include/effects/SkGradientShader.h" | 25 #include "third_party/skia/include/effects/SkGradientShader.h" |
| 25 #include "ui/base/accessibility/accessible_view_state.h" | 26 #include "ui/base/accessibility/accessible_view_state.h" |
| 26 #include "ui/base/animation/animation_container.h" | 27 #include "ui/base/animation/animation_container.h" |
| 27 #include "ui/base/animation/multi_animation.h" | 28 #include "ui/base/animation/multi_animation.h" |
| 28 #include "ui/base/animation/slide_animation.h" | 29 #include "ui/base/animation/slide_animation.h" |
| 29 #include "ui/base/animation/throb_animation.h" | 30 #include "ui/base/animation/throb_animation.h" |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 | 451 |
| 451 Tab::Tab(TabController* controller) | 452 Tab::Tab(TabController* controller) |
| 452 : controller_(controller), | 453 : controller_(controller), |
| 453 closing_(false), | 454 closing_(false), |
| 454 dragging_(false), | 455 dragging_(false), |
| 455 favicon_hiding_offset_(0), | 456 favicon_hiding_offset_(0), |
| 456 loading_animation_frame_(0), | 457 loading_animation_frame_(0), |
| 457 immersive_loading_step_(0), | 458 immersive_loading_step_(0), |
| 458 should_display_crashed_favicon_(false), | 459 should_display_crashed_favicon_(false), |
| 459 theme_provider_(NULL), | 460 theme_provider_(NULL), |
| 461 tab_activated_with_last_gesture_begin_(false), |
| 460 hover_controller_(this), | 462 hover_controller_(this), |
| 461 showing_icon_(false), | 463 showing_icon_(false), |
| 462 showing_close_button_(false), | 464 showing_close_button_(false), |
| 463 close_button_color_(0) { | 465 close_button_color_(0) { |
| 464 InitTabResources(); | 466 InitTabResources(); |
| 465 | 467 |
| 466 // So we get don't get enter/exit on children and don't prematurely stop the | 468 // So we get don't get enter/exit on children and don't prematurely stop the |
| 467 // hover. | 469 // hover. |
| 468 set_notify_enter_exit_on_child(true); | 470 set_notify_enter_exit_on_child(true); |
| 469 | 471 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 //////////////////////////////////////////////////////////////////////////////// | 706 //////////////////////////////////////////////////////////////////////////////// |
| 705 // Tab, views::ButtonListener overrides: | 707 // Tab, views::ButtonListener overrides: |
| 706 | 708 |
| 707 void Tab::ButtonPressed(views::Button* sender, const ui::Event& event) { | 709 void Tab::ButtonPressed(views::Button* sender, const ui::Event& event) { |
| 708 const CloseTabSource source = | 710 const CloseTabSource source = |
| 709 (event.type() == ui::ET_MOUSE_RELEASED && | 711 (event.type() == ui::ET_MOUSE_RELEASED && |
| 710 (event.flags() & ui::EF_FROM_TOUCH) == 0) ? CLOSE_TAB_FROM_MOUSE : | 712 (event.flags() & ui::EF_FROM_TOUCH) == 0) ? CLOSE_TAB_FROM_MOUSE : |
| 711 CLOSE_TAB_FROM_TOUCH; | 713 CLOSE_TAB_FROM_TOUCH; |
| 712 DCHECK_EQ(close_button_, sender); | 714 DCHECK_EQ(close_button_, sender); |
| 713 controller()->CloseTab(this, source); | 715 controller()->CloseTab(this, source); |
| 716 if (event.type() == ui::ET_GESTURE_TAP) |
| 717 TouchUMA::RecordGestureAction(TouchUMA::GESTURE_TABCLOSE_TAP); |
| 714 } | 718 } |
| 715 | 719 |
| 716 //////////////////////////////////////////////////////////////////////////////// | 720 //////////////////////////////////////////////////////////////////////////////// |
| 717 // Tab, views::ContextMenuController overrides: | 721 // Tab, views::ContextMenuController overrides: |
| 718 | 722 |
| 719 void Tab::ShowContextMenuForView(views::View* source, | 723 void Tab::ShowContextMenuForView(views::View* source, |
| 720 const gfx::Point& point, | 724 const gfx::Point& point, |
| 721 ui::MenuSourceType source_type) { | 725 ui::MenuSourceType source_type) { |
| 722 if (controller() && !closing()) | 726 if (controller() && !closing()) |
| 723 controller()->ShowContextMenuForTab(this, point, source_type); | 727 controller()->ShowContextMenuForTab(this, point, source_type); |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 switch (event->type()) { | 1025 switch (event->type()) { |
| 1022 case ui::ET_GESTURE_BEGIN: { | 1026 case ui::ET_GESTURE_BEGIN: { |
| 1023 if (event->details().touch_points() != 1) | 1027 if (event->details().touch_points() != 1) |
| 1024 return; | 1028 return; |
| 1025 | 1029 |
| 1026 // See comment in OnMousePressed() as to why we copy the event. | 1030 // See comment in OnMousePressed() as to why we copy the event. |
| 1027 ui::GestureEvent event_in_parent(*event, static_cast<View*>(this), | 1031 ui::GestureEvent event_in_parent(*event, static_cast<View*>(this), |
| 1028 parent()); | 1032 parent()); |
| 1029 ui::ListSelectionModel original_selection; | 1033 ui::ListSelectionModel original_selection; |
| 1030 original_selection.Copy(controller()->GetSelectionModel()); | 1034 original_selection.Copy(controller()->GetSelectionModel()); |
| 1035 tab_activated_with_last_gesture_begin_ = !IsActive(); |
| 1031 if (!IsSelected()) | 1036 if (!IsSelected()) |
| 1032 controller()->SelectTab(this); | 1037 controller()->SelectTab(this); |
| 1033 gfx::Point loc(event->location()); | 1038 gfx::Point loc(event->location()); |
| 1034 views::View::ConvertPointToScreen(this, &loc); | 1039 views::View::ConvertPointToScreen(this, &loc); |
| 1035 ui::GestureEvent cloned_event(event_in_parent, parent(), | 1040 ui::GestureEvent cloned_event(event_in_parent, parent(), |
| 1036 static_cast<View*>(this)); | 1041 static_cast<View*>(this)); |
| 1037 controller()->MaybeStartDrag(this, cloned_event, original_selection); | 1042 controller()->MaybeStartDrag(this, cloned_event, original_selection); |
| 1038 break; | 1043 break; |
| 1039 } | 1044 } |
| 1040 | 1045 |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1821 const gfx::ImageSkia& image) { | 1826 const gfx::ImageSkia& image) { |
| 1822 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); | 1827 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); |
| 1823 ImageCacheEntry entry; | 1828 ImageCacheEntry entry; |
| 1824 entry.resource_id = resource_id; | 1829 entry.resource_id = resource_id; |
| 1825 entry.scale_factor = scale_factor; | 1830 entry.scale_factor = scale_factor; |
| 1826 entry.image = image; | 1831 entry.image = image; |
| 1827 image_cache_->push_front(entry); | 1832 image_cache_->push_front(entry); |
| 1828 if (image_cache_->size() > kMaxImageCacheSize) | 1833 if (image_cache_->size() > kMaxImageCacheSize) |
| 1829 image_cache_->pop_back(); | 1834 image_cache_->pop_back(); |
| 1830 } | 1835 } |
| OLD | NEW |