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/gfx/vector_icons_public.h" | 19 #include "ui/gfx/vector_icons_public.h" |
19 #include "ui/views/border.h" | 20 #include "ui/views/border.h" |
20 | 21 |
21 namespace ash { | 22 namespace ash { |
22 namespace { | 23 namespace { |
(...skipping 22 matching lines...) Expand all Loading... | |
45 return CreateDefaultView( | 46 return CreateDefaultView( |
46 base::ASCIIToUTF16("[TODO] " + PaletteToolIdToString(GetToolId()))); | 47 base::ASCIIToUTF16("[TODO] " + PaletteToolIdToString(GetToolId()))); |
47 } | 48 } |
48 | 49 |
49 void CommonPaletteTool::OnViewDestroyed() { | 50 void CommonPaletteTool::OnViewDestroyed() { |
50 highlight_view_ = nullptr; | 51 highlight_view_ = nullptr; |
51 } | 52 } |
52 | 53 |
53 void CommonPaletteTool::OnEnable() { | 54 void CommonPaletteTool::OnEnable() { |
54 PaletteTool::OnEnable(); | 55 PaletteTool::OnEnable(); |
56 start_time_ = base::TimeTicks::Now(); | |
55 | 57 |
56 if (highlight_view_) { | 58 if (highlight_view_) { |
57 highlight_view_->SetHighlight(true); | 59 highlight_view_->SetHighlight(true); |
58 highlight_view_->SetRightIconVisible(true); | 60 highlight_view_->SetRightIconVisible(true); |
59 } | 61 } |
60 } | 62 } |
61 | 63 |
62 void CommonPaletteTool::OnDisable() { | 64 void CommonPaletteTool::OnDisable() { |
63 PaletteTool::OnDisable(); | 65 PaletteTool::OnDisable(); |
64 | 66 |
67 if (GetToolId() == PaletteToolId::LASER_POINTER) { | |
68 UMA_HISTOGRAM_CUSTOM_TIMES("Ash.Shelf.Palette.InLaserPointerMode", | |
69 base::TimeTicks::Now() - start_time_, | |
70 base::TimeDelta::FromMilliseconds(100), | |
71 base::TimeDelta::FromHours(1), 50); | |
72 } else if (GetToolId() == PaletteToolId::MAGNIFY) { | |
73 UMA_HISTOGRAM_CUSTOM_TIMES("Ash.Shelf.Palette.InMagnifyMode", | |
74 base::TimeTicks::Now() - start_time_, | |
75 base::TimeDelta::FromMilliseconds(100), | |
76 base::TimeDelta::FromHours(1), 50); | |
77 } | |
stevenjb
2016/09/13 16:32:18
Do we anticipate adding more tools? If so I would
xiaoyinh(OOO Sep 11-29)
2016/09/14 00:51:24
Done.
| |
78 | |
65 if (highlight_view_) { | 79 if (highlight_view_) { |
66 highlight_view_->SetHighlight(false); | 80 highlight_view_->SetHighlight(false); |
67 highlight_view_->SetRightIconVisible(false); | 81 highlight_view_->SetRightIconVisible(false); |
68 } | 82 } |
69 } | 83 } |
70 | 84 |
71 void CommonPaletteTool::OnViewClicked(views::View* sender) { | 85 void CommonPaletteTool::OnViewClicked(views::View* sender) { |
72 if (enabled()) | 86 delegate()->RecordPaletteOptionsUsage( |
87 PaletteToolIdToPaletteTrayOptions(GetToolId())); | |
88 if (enabled()) { | |
73 delegate()->DisableTool(GetToolId()); | 89 delegate()->DisableTool(GetToolId()); |
74 else | 90 if (GetToolId() == PaletteToolId::LASER_POINTER) { |
91 delegate()->RecordPaletteModeCancellation( | |
92 PaletteModeCancelType::PALETTE_MODE_LASER_POINTER_CANCELLED); | |
93 } else if (GetToolId() == PaletteToolId::MAGNIFY) { | |
94 delegate()->RecordPaletteModeCancellation( | |
95 PaletteModeCancelType::PALETTE_MODE_MAGNIFY_CANCELLED); | |
96 } | |
stevenjb
2016/09/13 16:32:18
same here.
xiaoyinh(OOO Sep 11-29)
2016/09/14 00:51:24
Done.
| |
97 } else { | |
75 delegate()->EnableTool(GetToolId()); | 98 delegate()->EnableTool(GetToolId()); |
99 } | |
76 } | 100 } |
77 | 101 |
78 views::View* CommonPaletteTool::CreateDefaultView(const base::string16& name) { | 102 views::View* CommonPaletteTool::CreateDefaultView(const base::string16& name) { |
79 gfx::ImageSkia icon = | 103 gfx::ImageSkia icon = |
80 CreateVectorIcon(GetPaletteIcon(), kIconSize, gfx::kChromeIconGrey); | 104 CreateVectorIcon(GetPaletteIcon(), kIconSize, gfx::kChromeIconGrey); |
81 gfx::ImageSkia check = CreateVectorIcon(gfx::VectorIconId::CHECK_CIRCLE, | 105 gfx::ImageSkia check = CreateVectorIcon(gfx::VectorIconId::CHECK_CIRCLE, |
82 kIconSize, gfx::kGoogleGreen700); | 106 kIconSize, gfx::kGoogleGreen700); |
83 | 107 |
84 highlight_view_ = new HoverHighlightView(this); | 108 highlight_view_ = new HoverHighlightView(this); |
85 highlight_view_->SetBorder( | 109 highlight_view_->SetBorder( |
86 views::Border::CreateEmptyBorder(0, kExtraMarginFromLeftEdge, 0, 0)); | 110 views::Border::CreateEmptyBorder(0, kExtraMarginFromLeftEdge, 0, 0)); |
87 highlight_view_->AddIconAndLabelCustomSize(icon, name, false, kIconSize, | 111 highlight_view_->AddIconAndLabelCustomSize(icon, name, false, kIconSize, |
88 kMarginFromEdges, | 112 kMarginFromEdges, |
89 kMarginBetweenIconAndText); | 113 kMarginBetweenIconAndText); |
90 highlight_view_->AddRightIcon(check, kIconSize); | 114 highlight_view_->AddRightIcon(check, kIconSize); |
91 | 115 |
92 if (enabled()) | 116 if (enabled()) |
93 highlight_view_->SetHighlight(true); | 117 highlight_view_->SetHighlight(true); |
94 else | 118 else |
95 highlight_view_->SetRightIconVisible(false); | 119 highlight_view_->SetRightIconVisible(false); |
96 | 120 |
97 return highlight_view_; | 121 return highlight_view_; |
98 } | 122 } |
99 | 123 |
100 } // namespace ash | 124 } // namespace ash |
OLD | NEW |