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 <stddef.h> | 7 #include <stddef.h> |
8 #include <limits> | 8 #include <limits> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/debug/alias.h" | 12 #include "base/debug/alias.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/metrics/user_metrics.h" |
14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
16 #include "cc/paint/paint_shader.h" | 17 #include "cc/paint/paint_shader.h" |
17 #include "chrome/app/vector_icons/vector_icons.h" | 18 #include "chrome/app/vector_icons/vector_icons.h" |
18 #include "chrome/browser/themes/theme_properties.h" | 19 #include "chrome/browser/themes/theme_properties.h" |
19 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/layout_constants.h" | 21 #include "chrome/browser/ui/layout_constants.h" |
21 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 22 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
22 #include "chrome/browser/ui/tabs/tab_utils.h" | 23 #include "chrome/browser/ui/tabs/tab_utils.h" |
23 #include "chrome/browser/ui/view_ids.h" | 24 #include "chrome/browser/ui/view_ids.h" |
24 #include "chrome/browser/ui/views/frame/browser_view.h" | 25 #include "chrome/browser/ui/views/frame/browser_view.h" |
25 #include "chrome/browser/ui/views/tabs/alert_indicator_button.h" | 26 #include "chrome/browser/ui/views/tabs/alert_indicator_button.h" |
26 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" | 27 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" |
27 #include "chrome/browser/ui/views/tabs/tab_controller.h" | 28 #include "chrome/browser/ui/views/tabs/tab_controller.h" |
28 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 29 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
29 #include "chrome/browser/ui/views/touch_uma/touch_uma.h" | 30 #include "chrome/browser/ui/views/touch_uma/touch_uma.h" |
30 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
31 #include "chrome/common/url_constants.h" | 32 #include "chrome/common/url_constants.h" |
32 #include "chrome/grit/generated_resources.h" | 33 #include "chrome/grit/generated_resources.h" |
33 #include "chrome/grit/theme_resources.h" | 34 #include "chrome/grit/theme_resources.h" |
34 #include "components/grit/components_scaled_resources.h" | 35 #include "components/grit/components_scaled_resources.h" |
35 #include "components/strings/grit/components_strings.h" | 36 #include "components/strings/grit/components_strings.h" |
36 #include "content/public/browser/user_metrics.h" | |
37 #include "content/public/common/url_constants.h" | 37 #include "content/public/common/url_constants.h" |
38 #include "third_party/skia/include/effects/SkGradientShader.h" | 38 #include "third_party/skia/include/effects/SkGradientShader.h" |
39 #include "third_party/skia/include/pathops/SkPathOps.h" | 39 #include "third_party/skia/include/pathops/SkPathOps.h" |
40 #include "ui/accessibility/ax_node_data.h" | 40 #include "ui/accessibility/ax_node_data.h" |
41 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
42 #include "ui/base/models/list_selection_model.h" | 42 #include "ui/base/models/list_selection_model.h" |
43 #include "ui/base/resource/resource_bundle.h" | 43 #include "ui/base/resource/resource_bundle.h" |
44 #include "ui/base/theme_provider.h" | 44 #include "ui/base/theme_provider.h" |
45 #include "ui/gfx/animation/animation_container.h" | 45 #include "ui/gfx/animation/animation_container.h" |
46 #include "ui/gfx/animation/throb_animation.h" | 46 #include "ui/gfx/animation/throb_animation.h" |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 | 758 |
759 void Tab::AnimationEnded(const gfx::Animation* animation) { | 759 void Tab::AnimationEnded(const gfx::Animation* animation) { |
760 SchedulePaint(); | 760 SchedulePaint(); |
761 } | 761 } |
762 | 762 |
763 //////////////////////////////////////////////////////////////////////////////// | 763 //////////////////////////////////////////////////////////////////////////////// |
764 // Tab, views::ButtonListener overrides: | 764 // Tab, views::ButtonListener overrides: |
765 | 765 |
766 void Tab::ButtonPressed(views::Button* sender, const ui::Event& event) { | 766 void Tab::ButtonPressed(views::Button* sender, const ui::Event& event) { |
767 if (!alert_indicator_button_ || !alert_indicator_button_->visible()) | 767 if (!alert_indicator_button_ || !alert_indicator_button_->visible()) |
768 content::RecordAction(UserMetricsAction("CloseTab_NoAlertIndicator")); | 768 base::RecordAction(UserMetricsAction("CloseTab_NoAlertIndicator")); |
769 else if (alert_indicator_button_->enabled()) | 769 else if (alert_indicator_button_->enabled()) |
770 content::RecordAction(UserMetricsAction("CloseTab_MuteToggleAvailable")); | 770 base::RecordAction(UserMetricsAction("CloseTab_MuteToggleAvailable")); |
771 else if (data_.alert_state == TabAlertState::AUDIO_PLAYING) | 771 else if (data_.alert_state == TabAlertState::AUDIO_PLAYING) |
772 content::RecordAction(UserMetricsAction("CloseTab_AudioIndicator")); | 772 base::RecordAction(UserMetricsAction("CloseTab_AudioIndicator")); |
773 else | 773 else |
774 content::RecordAction(UserMetricsAction("CloseTab_RecordingIndicator")); | 774 base::RecordAction(UserMetricsAction("CloseTab_RecordingIndicator")); |
775 | 775 |
776 const CloseTabSource source = | 776 const CloseTabSource source = |
777 (event.type() == ui::ET_MOUSE_RELEASED && | 777 (event.type() == ui::ET_MOUSE_RELEASED && |
778 !(event.flags() & ui::EF_FROM_TOUCH)) ? CLOSE_TAB_FROM_MOUSE | 778 !(event.flags() & ui::EF_FROM_TOUCH)) ? CLOSE_TAB_FROM_MOUSE |
779 : CLOSE_TAB_FROM_TOUCH; | 779 : CLOSE_TAB_FROM_TOUCH; |
780 DCHECK_EQ(close_button_, sender); | 780 DCHECK_EQ(close_button_, sender); |
781 controller_->CloseTab(this, source); | 781 controller_->CloseTab(this, source); |
782 if (event.type() == ui::ET_GESTURE_TAP) | 782 if (event.type() == ui::ET_GESTURE_TAP) |
783 TouchUMA::RecordGestureAction(TouchUMA::GESTURE_TABCLOSE_TAP); | 783 TouchUMA::RecordGestureAction(TouchUMA::GESTURE_TABCLOSE_TAP); |
784 } | 784 } |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 } else if (event.IsShiftDown()) { | 955 } else if (event.IsShiftDown()) { |
956 controller_->ExtendSelectionTo(this); | 956 controller_->ExtendSelectionTo(this); |
957 } else if (event.IsControlDown()) { | 957 } else if (event.IsControlDown()) { |
958 controller_->ToggleSelected(this); | 958 controller_->ToggleSelected(this); |
959 if (!IsSelected()) { | 959 if (!IsSelected()) { |
960 // Don't allow dragging non-selected tabs. | 960 // Don't allow dragging non-selected tabs. |
961 return false; | 961 return false; |
962 } | 962 } |
963 } else if (!IsSelected()) { | 963 } else if (!IsSelected()) { |
964 controller_->SelectTab(this); | 964 controller_->SelectTab(this); |
965 content::RecordAction(UserMetricsAction("SwitchTab_Click")); | 965 base::RecordAction(UserMetricsAction("SwitchTab_Click")); |
966 } | 966 } |
967 } else if (!IsSelected()) { | 967 } else if (!IsSelected()) { |
968 controller_->SelectTab(this); | 968 controller_->SelectTab(this); |
969 content::RecordAction(UserMetricsAction("SwitchTab_Click")); | 969 base::RecordAction(UserMetricsAction("SwitchTab_Click")); |
970 } | 970 } |
971 ui::MouseEvent cloned_event(event_in_parent, parent(), | 971 ui::MouseEvent cloned_event(event_in_parent, parent(), |
972 static_cast<View*>(this)); | 972 static_cast<View*>(this)); |
973 controller_->MaybeStartDrag(this, cloned_event, original_selection); | 973 controller_->MaybeStartDrag(this, cloned_event, original_selection); |
974 } | 974 } |
975 return true; | 975 return true; |
976 } | 976 } |
977 | 977 |
978 bool Tab::OnMouseDragged(const ui::MouseEvent& event) { | 978 bool Tab::OnMouseDragged(const ui::MouseEvent& event) { |
979 controller_->ContinueDrag(this, event); | 979 controller_->ContinueDrag(this, event); |
(...skipping 28 matching lines...) Expand all Loading... |
1008 } | 1008 } |
1009 } else if (event.IsOnlyLeftMouseButton() && !event.IsShiftDown() && | 1009 } else if (event.IsOnlyLeftMouseButton() && !event.IsShiftDown() && |
1010 !event.IsControlDown()) { | 1010 !event.IsControlDown()) { |
1011 // If the tab was already selected mouse pressed doesn't change the | 1011 // If the tab was already selected mouse pressed doesn't change the |
1012 // selection. Reset it now to handle the case where multiple tabs were | 1012 // selection. Reset it now to handle the case where multiple tabs were |
1013 // selected. | 1013 // selected. |
1014 controller_->SelectTab(this); | 1014 controller_->SelectTab(this); |
1015 | 1015 |
1016 if (alert_indicator_button_ && alert_indicator_button_->visible() && | 1016 if (alert_indicator_button_ && alert_indicator_button_->visible() && |
1017 alert_indicator_button_->bounds().Contains(event.location())) { | 1017 alert_indicator_button_->bounds().Contains(event.location())) { |
1018 content::RecordAction(UserMetricsAction("TabAlertIndicator_Clicked")); | 1018 base::RecordAction(UserMetricsAction("TabAlertIndicator_Clicked")); |
1019 } | 1019 } |
1020 } | 1020 } |
1021 } | 1021 } |
1022 | 1022 |
1023 void Tab::OnMouseCaptureLost() { | 1023 void Tab::OnMouseCaptureLost() { |
1024 controller_->EndDrag(END_DRAG_CAPTURE_LOST); | 1024 controller_->EndDrag(END_DRAG_CAPTURE_LOST); |
1025 } | 1025 } |
1026 | 1026 |
1027 void Tab::OnMouseEntered(const ui::MouseEvent& event) { | 1027 void Tab::OnMouseEntered(const ui::MouseEvent& event) { |
1028 hover_controller_.Show(views::GlowHoverController::SUBTLE); | 1028 hover_controller_.Show(views::GlowHoverController::SUBTLE); |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 gfx::Rect bounds = favicon_bounds_; | 1486 gfx::Rect bounds = favicon_bounds_; |
1487 if (bounds.IsEmpty()) | 1487 if (bounds.IsEmpty()) |
1488 return; | 1488 return; |
1489 | 1489 |
1490 // Extends the area to the bottom when the crash animation is in progress. | 1490 // Extends the area to the bottom when the crash animation is in progress. |
1491 if (crash_icon_animation_->is_animating()) | 1491 if (crash_icon_animation_->is_animating()) |
1492 bounds.set_height(height() - bounds.y()); | 1492 bounds.set_height(height() - bounds.y()); |
1493 bounds.set_x(GetMirroredXForRect(bounds)); | 1493 bounds.set_x(GetMirroredXForRect(bounds)); |
1494 SchedulePaintInRect(bounds); | 1494 SchedulePaintInRect(bounds); |
1495 } | 1495 } |
OLD | NEW |