OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/common/system/chromeos/palette/common_palette_tool.h" | 5 #include "ash/common/system/chromeos/palette/common_palette_tool.h" |
6 | 6 |
7 #include "ash/common/shelf/shelf_constants.h" | 7 #include "ash/common/shelf/shelf_constants.h" |
8 #include "ash/common/system/chromeos/palette/palette_ids.h" | 8 #include "ash/common/system/chromeos/palette/palette_ids.h" |
9 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" | 9 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" |
10 #include "ash/common/system/tray/hover_highlight_view.h" | 10 #include "ash/common/system/tray/hover_highlight_view.h" |
11 #include "ash/common/system/tray/view_click_listener.h" | 11 #include "ash/common/system/tray/view_click_listener.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/metrics/histogram_macros.h" |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
14 #include "grit/ash_resources.h" | 15 #include "grit/ash_resources.h" |
15 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
16 #include "ui/gfx/color_palette.h" | 17 #include "ui/gfx/color_palette.h" |
17 #include "ui/gfx/paint_vector_icon.h" | 18 #include "ui/gfx/paint_vector_icon.h" |
18 #include "ui/views/border.h" | 19 #include "ui/views/border.h" |
19 | 20 |
20 namespace ash { | 21 namespace ash { |
21 namespace { | 22 namespace { |
22 | 23 |
(...skipping 21 matching lines...) Expand all Loading... |
44 return CreateDefaultView( | 45 return CreateDefaultView( |
45 base::ASCIIToUTF16("[TODO] " + PaletteToolIdToString(GetToolId()))); | 46 base::ASCIIToUTF16("[TODO] " + PaletteToolIdToString(GetToolId()))); |
46 } | 47 } |
47 | 48 |
48 void CommonPaletteTool::OnViewDestroyed() { | 49 void CommonPaletteTool::OnViewDestroyed() { |
49 highlight_view_ = nullptr; | 50 highlight_view_ = nullptr; |
50 } | 51 } |
51 | 52 |
52 void CommonPaletteTool::OnEnable() { | 53 void CommonPaletteTool::OnEnable() { |
53 PaletteTool::OnEnable(); | 54 PaletteTool::OnEnable(); |
| 55 start_time_ = base::TimeTicks::Now(); |
54 | 56 |
55 if (highlight_view_) { | 57 if (highlight_view_) { |
56 highlight_view_->SetHighlight(true); | 58 highlight_view_->SetHighlight(true); |
57 highlight_view_->SetRightIconVisible(true); | 59 highlight_view_->SetRightIconVisible(true); |
58 } | 60 } |
59 } | 61 } |
60 | 62 |
61 void CommonPaletteTool::OnDisable() { | 63 void CommonPaletteTool::OnDisable() { |
62 PaletteTool::OnDisable(); | 64 PaletteTool::OnDisable(); |
63 | 65 |
| 66 if (GetToolId() == PaletteToolId::LASER_POINTER) { |
| 67 UMA_HISTOGRAM_CUSTOM_TIMES("Ash.Shelf.Palette.InLaserPointerMode", |
| 68 base::TimeTicks::Now() - start_time_, |
| 69 base::TimeDelta::FromMilliseconds(100), |
| 70 base::TimeDelta::FromHours(1), 50); |
| 71 } else if (GetToolId() == PaletteToolId::MAGNIFY) { |
| 72 UMA_HISTOGRAM_CUSTOM_TIMES("Ash.Shelf.Palette.InMagnifyMode", |
| 73 base::TimeTicks::Now() - start_time_, |
| 74 base::TimeDelta::FromMilliseconds(100), |
| 75 base::TimeDelta::FromHours(1), 50); |
| 76 } |
| 77 |
64 if (highlight_view_) { | 78 if (highlight_view_) { |
65 highlight_view_->SetHighlight(false); | 79 highlight_view_->SetHighlight(false); |
66 highlight_view_->SetRightIconVisible(false); | 80 highlight_view_->SetRightIconVisible(false); |
67 } | 81 } |
68 } | 82 } |
69 | 83 |
70 void CommonPaletteTool::OnViewClicked(views::View* sender) { | 84 void CommonPaletteTool::OnViewClicked(views::View* sender) { |
71 if (enabled()) | 85 delegate()->RecordPaletteOptionsUsage( |
| 86 PaletteToolIdToPaletteTrayOptions(GetToolId())); |
| 87 if (enabled()) { |
72 delegate()->DisableTool(GetToolId()); | 88 delegate()->DisableTool(GetToolId()); |
73 else | 89 if (GetToolId() == PaletteToolId::LASER_POINTER) { |
| 90 delegate()->RecordPaletteModeCancellation( |
| 91 PaletteModeCancelType::PALETTE_MODE_LASER_POINTER_CANCELLED); |
| 92 } else if (GetToolId() == PaletteToolId::MAGNIFY) { |
| 93 delegate()->RecordPaletteModeCancellation( |
| 94 PaletteModeCancelType::PALETTE_MODE_MAGNIFY_CANCELLED); |
| 95 } |
| 96 } else { |
74 delegate()->EnableTool(GetToolId()); | 97 delegate()->EnableTool(GetToolId()); |
| 98 } |
75 } | 99 } |
76 | 100 |
77 views::View* CommonPaletteTool::CreateDefaultView(const base::string16& name) { | 101 views::View* CommonPaletteTool::CreateDefaultView(const base::string16& name) { |
78 gfx::ImageSkia icon = | 102 gfx::ImageSkia icon = |
79 CreateVectorIcon(GetPaletteIconId(), kIconSize, gfx::kChromeIconGrey); | 103 CreateVectorIcon(GetPaletteIconId(), kIconSize, gfx::kChromeIconGrey); |
80 gfx::ImageSkia check = CreateVectorIcon(gfx::VectorIconId::CHECK_CIRCLE, | 104 gfx::ImageSkia check = CreateVectorIcon(gfx::VectorIconId::CHECK_CIRCLE, |
81 kIconSize, gfx::kGoogleGreen700); | 105 kIconSize, gfx::kGoogleGreen700); |
82 | 106 |
83 highlight_view_ = new HoverHighlightView(this); | 107 highlight_view_ = new HoverHighlightView(this); |
84 highlight_view_->SetBorder( | 108 highlight_view_->SetBorder( |
85 views::Border::CreateEmptyBorder(0, kExtraMarginFromLeftEdge, 0, 0)); | 109 views::Border::CreateEmptyBorder(0, kExtraMarginFromLeftEdge, 0, 0)); |
86 highlight_view_->AddIconAndLabelCustomSize(icon, name, false, kIconSize, | 110 highlight_view_->AddIconAndLabelCustomSize(icon, name, false, kIconSize, |
87 kMarginFromEdges, | 111 kMarginFromEdges, |
88 kMarginBetweenIconAndText); | 112 kMarginBetweenIconAndText); |
89 highlight_view_->AddRightIcon(check, kIconSize); | 113 highlight_view_->AddRightIcon(check, kIconSize); |
90 | 114 |
91 if (enabled()) | 115 if (enabled()) |
92 highlight_view_->SetHighlight(true); | 116 highlight_view_->SetHighlight(true); |
93 else | 117 else |
94 highlight_view_->SetRightIconVisible(false); | 118 highlight_view_->SetRightIconVisible(false); |
95 | 119 |
96 return highlight_view_; | 120 return highlight_view_; |
97 } | 121 } |
98 | 122 |
99 } // namespace ash | 123 } // namespace ash |
OLD | NEW |