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_strip.h" | 5 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <iterator> | 10 #include <iterator> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
| 18 #include "base/metrics/user_metrics.h" |
18 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
20 #include "build/build_config.h" | 21 #include "build/build_config.h" |
21 #include "cc/paint/paint_flags.h" | 22 #include "cc/paint/paint_flags.h" |
22 #include "chrome/browser/defaults.h" | 23 #include "chrome/browser/defaults.h" |
23 #include "chrome/browser/themes/theme_properties.h" | 24 #include "chrome/browser/themes/theme_properties.h" |
24 #include "chrome/browser/ui/layout_constants.h" | 25 #include "chrome/browser/ui/layout_constants.h" |
25 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 26 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
26 #include "chrome/browser/ui/view_ids.h" | 27 #include "chrome/browser/ui/view_ids.h" |
27 #include "chrome/browser/ui/views/frame/browser_view.h" | 28 #include "chrome/browser/ui/views/frame/browser_view.h" |
28 #include "chrome/browser/ui/views/tabs/stacked_tab_strip_layout.h" | 29 #include "chrome/browser/ui/views/tabs/stacked_tab_strip_layout.h" |
29 #include "chrome/browser/ui/views/tabs/tab.h" | 30 #include "chrome/browser/ui/views/tabs/tab.h" |
30 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" | 31 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" |
31 #include "chrome/browser/ui/views/tabs/tab_strip_controller.h" | 32 #include "chrome/browser/ui/views/tabs/tab_strip_controller.h" |
32 #include "chrome/browser/ui/views/tabs/tab_strip_layout.h" | 33 #include "chrome/browser/ui/views/tabs/tab_strip_layout.h" |
33 #include "chrome/browser/ui/views/tabs/tab_strip_observer.h" | 34 #include "chrome/browser/ui/views/tabs/tab_strip_observer.h" |
34 #include "chrome/browser/ui/views/touch_uma/touch_uma.h" | 35 #include "chrome/browser/ui/views/touch_uma/touch_uma.h" |
35 #include "chrome/common/chrome_switches.h" | 36 #include "chrome/common/chrome_switches.h" |
36 #include "chrome/grit/generated_resources.h" | 37 #include "chrome/grit/generated_resources.h" |
37 #include "chrome/grit/theme_resources.h" | 38 #include "chrome/grit/theme_resources.h" |
38 #include "content/public/browser/user_metrics.h" | |
39 #include "content/public/common/content_switches.h" | 39 #include "content/public/common/content_switches.h" |
40 #include "third_party/skia/include/core/SkColorFilter.h" | 40 #include "third_party/skia/include/core/SkColorFilter.h" |
41 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" | 41 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" |
42 #include "third_party/skia/include/effects/SkLayerDrawLooper.h" | 42 #include "third_party/skia/include/effects/SkLayerDrawLooper.h" |
43 #include "third_party/skia/include/pathops/SkPathOps.h" | 43 #include "third_party/skia/include/pathops/SkPathOps.h" |
44 #include "ui/accessibility/ax_node_data.h" | 44 #include "ui/accessibility/ax_node_data.h" |
45 #include "ui/base/default_theme_provider.h" | 45 #include "ui/base/default_theme_provider.h" |
46 #include "ui/base/dragdrop/drag_drop_types.h" | 46 #include "ui/base/dragdrop/drag_drop_types.h" |
47 #include "ui/base/l10n/l10n_util.h" | 47 #include "ui/base/l10n/l10n_util.h" |
48 #include "ui/base/models/list_selection_model.h" | 48 #include "ui/base/models/list_selection_model.h" |
(...skipping 2536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2585 tab_size, Tab::kOverlap, kStackedPadding, kMaxStackedCount, &tabs_)); | 2585 tab_size, Tab::kOverlap, kStackedPadding, kMaxStackedCount, &tabs_)); |
2586 touch_layout_->SetWidth(GetTabAreaWidth()); | 2586 touch_layout_->SetWidth(GetTabAreaWidth()); |
2587 // This has to be after SetWidth() as SetWidth() is going to reset the | 2587 // This has to be after SetWidth() as SetWidth() is going to reset the |
2588 // bounds of the pinned tabs (since StackedTabStripLayout doesn't yet know | 2588 // bounds of the pinned tabs (since StackedTabStripLayout doesn't yet know |
2589 // how many pinned tabs there are). | 2589 // how many pinned tabs there are). |
2590 GenerateIdealBoundsForPinnedTabs(NULL); | 2590 GenerateIdealBoundsForPinnedTabs(NULL); |
2591 touch_layout_->SetXAndPinnedCount(GetStartXForNormalTabs(), | 2591 touch_layout_->SetXAndPinnedCount(GetStartXForNormalTabs(), |
2592 GetPinnedTabCount()); | 2592 GetPinnedTabCount()); |
2593 touch_layout_->SetActiveIndex(controller_->GetActiveIndex()); | 2593 touch_layout_->SetActiveIndex(controller_->GetActiveIndex()); |
2594 | 2594 |
2595 content::RecordAction(UserMetricsAction("StackedTab_EnteredStackedLayout")); | 2595 base::RecordAction(UserMetricsAction("StackedTab_EnteredStackedLayout")); |
2596 } else { | 2596 } else { |
2597 touch_layout_.reset(); | 2597 touch_layout_.reset(); |
2598 } | 2598 } |
2599 PrepareForAnimation(); | 2599 PrepareForAnimation(); |
2600 GenerateIdealBounds(); | 2600 GenerateIdealBounds(); |
2601 SetTabVisibility(); | 2601 SetTabVisibility(); |
2602 AnimateToIdealBounds(); | 2602 AnimateToIdealBounds(); |
2603 } | 2603 } |
2604 | 2604 |
2605 bool TabStrip::NeedsTouchLayout() const { | 2605 bool TabStrip::NeedsTouchLayout() const { |
(...skipping 22 matching lines...) Expand all Loading... |
2628 reset_to_shrink_on_exit_ = value; | 2628 reset_to_shrink_on_exit_ = value; |
2629 // Add an observer so we know when the mouse moves out of the tabstrip. | 2629 // Add an observer so we know when the mouse moves out of the tabstrip. |
2630 if (reset_to_shrink_on_exit_) | 2630 if (reset_to_shrink_on_exit_) |
2631 AddMessageLoopObserver(); | 2631 AddMessageLoopObserver(); |
2632 else | 2632 else |
2633 RemoveMessageLoopObserver(); | 2633 RemoveMessageLoopObserver(); |
2634 } | 2634 } |
2635 | 2635 |
2636 void TabStrip::ButtonPressed(views::Button* sender, const ui::Event& event) { | 2636 void TabStrip::ButtonPressed(views::Button* sender, const ui::Event& event) { |
2637 if (sender == newtab_button_) { | 2637 if (sender == newtab_button_) { |
2638 content::RecordAction(UserMetricsAction("NewTab_Button")); | 2638 base::RecordAction(UserMetricsAction("NewTab_Button")); |
2639 UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", TabStripModel::NEW_TAB_BUTTON, | 2639 UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", TabStripModel::NEW_TAB_BUTTON, |
2640 TabStripModel::NEW_TAB_ENUM_COUNT); | 2640 TabStripModel::NEW_TAB_ENUM_COUNT); |
2641 if (event.IsMouseEvent()) { | 2641 if (event.IsMouseEvent()) { |
2642 const ui::MouseEvent& mouse = static_cast<const ui::MouseEvent&>(event); | 2642 const ui::MouseEvent& mouse = static_cast<const ui::MouseEvent&>(event); |
2643 if (mouse.IsOnlyMiddleMouseButton()) { | 2643 if (mouse.IsOnlyMiddleMouseButton()) { |
2644 if (ui::Clipboard::IsSupportedClipboardType( | 2644 if (ui::Clipboard::IsSupportedClipboardType( |
2645 ui::CLIPBOARD_TYPE_SELECTION)) { | 2645 ui::CLIPBOARD_TYPE_SELECTION)) { |
2646 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); | 2646 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); |
2647 CHECK(clipboard); | 2647 CHECK(clipboard); |
2648 base::string16 clipboard_text; | 2648 base::string16 clipboard_text; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2781 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); | 2781 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); |
2782 if (view) | 2782 if (view) |
2783 return view; | 2783 return view; |
2784 } | 2784 } |
2785 Tab* tab = FindTabForEvent(point); | 2785 Tab* tab = FindTabForEvent(point); |
2786 if (tab) | 2786 if (tab) |
2787 return ConvertPointToViewAndGetEventHandler(this, tab, point); | 2787 return ConvertPointToViewAndGetEventHandler(this, tab, point); |
2788 } | 2788 } |
2789 return this; | 2789 return this; |
2790 } | 2790 } |
OLD | NEW |