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/tray_constants.h" | 11 #include "ash/common/system/tray/tray_constants.h" |
| 12 #include "ash/common/system/tray/tray_popup_utils.h" |
12 #include "ash/common/system/tray/view_click_listener.h" | 13 #include "ash/common/system/tray/view_click_listener.h" |
13 #include "ash/resources/grit/ash_resources.h" | 14 #include "ash/resources/grit/ash_resources.h" |
14 #include "ash/resources/vector_icons/vector_icons.h" | 15 #include "ash/resources/vector_icons/vector_icons.h" |
15 #include "base/logging.h" | 16 #include "base/logging.h" |
16 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
18 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
19 #include "ui/gfx/color_palette.h" | 20 #include "ui/gfx/color_palette.h" |
20 #include "ui/gfx/paint_vector_icon.h" | 21 #include "ui/gfx/paint_vector_icon.h" |
21 #include "ui/views/border.h" | 22 #include "ui/views/border.h" |
(...skipping 22 matching lines...) Expand all Loading... |
44 CommonPaletteTool::~CommonPaletteTool() {} | 45 CommonPaletteTool::~CommonPaletteTool() {} |
45 | 46 |
46 void CommonPaletteTool::OnViewDestroyed() { | 47 void CommonPaletteTool::OnViewDestroyed() { |
47 highlight_view_ = nullptr; | 48 highlight_view_ = nullptr; |
48 } | 49 } |
49 | 50 |
50 void CommonPaletteTool::OnEnable() { | 51 void CommonPaletteTool::OnEnable() { |
51 PaletteTool::OnEnable(); | 52 PaletteTool::OnEnable(); |
52 start_time_ = base::TimeTicks::Now(); | 53 start_time_ = base::TimeTicks::Now(); |
53 | 54 |
54 if (highlight_view_) { | 55 if (highlight_view_) |
55 highlight_view_->SetRightViewVisible(true); | 56 TrayPopupUtils::UpdateCheckMarkVisibility(highlight_view_, true); |
56 highlight_view_->SetAccessiblityState( | |
57 HoverHighlightView::AccessibilityState::CHECKED_CHECKBOX); | |
58 } | |
59 } | 57 } |
60 | 58 |
61 void CommonPaletteTool::OnDisable() { | 59 void CommonPaletteTool::OnDisable() { |
62 PaletteTool::OnDisable(); | 60 PaletteTool::OnDisable(); |
63 AddHistogramTimes(GetToolId(), base::TimeTicks::Now() - start_time_); | 61 AddHistogramTimes(GetToolId(), base::TimeTicks::Now() - start_time_); |
64 | 62 |
65 if (highlight_view_) { | 63 if (highlight_view_) |
66 highlight_view_->SetRightViewVisible(false); | 64 TrayPopupUtils::UpdateCheckMarkVisibility(highlight_view_, false); |
67 highlight_view_->SetAccessiblityState( | |
68 HoverHighlightView::AccessibilityState::UNCHECKED_CHECKBOX); | |
69 } | |
70 } | 65 } |
71 | 66 |
72 void CommonPaletteTool::OnViewClicked(views::View* sender) { | 67 void CommonPaletteTool::OnViewClicked(views::View* sender) { |
73 delegate()->RecordPaletteOptionsUsage( | 68 delegate()->RecordPaletteOptionsUsage( |
74 PaletteToolIdToPaletteTrayOptions(GetToolId())); | 69 PaletteToolIdToPaletteTrayOptions(GetToolId())); |
75 if (enabled()) { | 70 if (enabled()) { |
76 delegate()->DisableTool(GetToolId()); | 71 delegate()->DisableTool(GetToolId()); |
77 delegate()->RecordPaletteModeCancellation( | 72 delegate()->RecordPaletteModeCancellation( |
78 PaletteToolIdToPaletteModeCancelType(GetToolId(), | 73 PaletteToolIdToPaletteModeCancelType(GetToolId(), |
79 false /*is_switched*/)); | 74 false /*is_switched*/)); |
80 } else { | 75 } else { |
81 delegate()->EnableTool(GetToolId()); | 76 delegate()->EnableTool(GetToolId()); |
82 } | 77 } |
83 } | 78 } |
84 | 79 |
85 views::View* CommonPaletteTool::CreateDefaultView(const base::string16& name) { | 80 views::View* CommonPaletteTool::CreateDefaultView(const base::string16& name) { |
86 gfx::ImageSkia icon = | 81 gfx::ImageSkia icon = |
87 CreateVectorIcon(GetPaletteIcon(), kMenuIconSize, gfx::kChromeIconGrey); | 82 CreateVectorIcon(GetPaletteIcon(), kMenuIconSize, gfx::kChromeIconGrey); |
88 gfx::ImageSkia check = | |
89 CreateVectorIcon(kCheckCircleIcon, kMenuIconSize, gfx::kGoogleGreen700); | |
90 | 83 |
91 highlight_view_ = new HoverHighlightView(this); | 84 highlight_view_ = new HoverHighlightView(this); |
92 highlight_view_->SetBorder(views::CreateEmptyBorder(0, 0, 0, 0)); | 85 highlight_view_->SetBorder(views::CreateEmptyBorder(0, 0, 0, 0)); |
93 highlight_view_->AddIconAndLabel(icon, name); | 86 highlight_view_->AddIconAndLabel(icon, name); |
94 highlight_view_->AddRightIcon(check, kMenuIconSize); | |
95 highlight_view_->set_custom_height(kMenuButtonSize); | 87 highlight_view_->set_custom_height(kMenuButtonSize); |
96 | 88 |
97 if (enabled()) { | 89 TrayPopupUtils::InitializeAsCheckableRow(highlight_view_, enabled()); |
98 highlight_view_->SetAccessiblityState( | |
99 HoverHighlightView::AccessibilityState::CHECKED_CHECKBOX); | |
100 } else { | |
101 highlight_view_->SetRightViewVisible(false); | |
102 highlight_view_->SetAccessiblityState( | |
103 HoverHighlightView::AccessibilityState::UNCHECKED_CHECKBOX); | |
104 } | |
105 | 90 |
106 return highlight_view_; | 91 return highlight_view_; |
107 } | 92 } |
108 | 93 |
109 } // namespace ash | 94 } // namespace ash |
OLD | NEW |