| 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 TrayPopupUtils::UpdateCheckMarkVisibility(highlight_view_, true); |
| 55 highlight_view_->SetRightViewVisible(true); | |
| 56 highlight_view_->SetAccessiblityState( | |
| 57 HoverHighlightView::AccessibilityState::CHECKED_CHECKBOX); | |
| 58 } | |
| 59 } | 56 } |
| 60 | 57 |
| 61 void CommonPaletteTool::OnDisable() { | 58 void CommonPaletteTool::OnDisable() { |
| 62 PaletteTool::OnDisable(); | 59 PaletteTool::OnDisable(); |
| 63 AddHistogramTimes(GetToolId(), base::TimeTicks::Now() - start_time_); | 60 AddHistogramTimes(GetToolId(), base::TimeTicks::Now() - start_time_); |
| 64 | 61 |
| 65 if (highlight_view_) { | 62 TrayPopupUtils::UpdateCheckMarkVisibility(highlight_view_, false); |
| 66 highlight_view_->SetRightViewVisible(false); | |
| 67 highlight_view_->SetAccessiblityState( | |
| 68 HoverHighlightView::AccessibilityState::UNCHECKED_CHECKBOX); | |
| 69 } | |
| 70 } | 63 } |
| 71 | 64 |
| 72 void CommonPaletteTool::OnViewClicked(views::View* sender) { | 65 void CommonPaletteTool::OnViewClicked(views::View* sender) { |
| 73 delegate()->RecordPaletteOptionsUsage( | 66 delegate()->RecordPaletteOptionsUsage( |
| 74 PaletteToolIdToPaletteTrayOptions(GetToolId())); | 67 PaletteToolIdToPaletteTrayOptions(GetToolId())); |
| 75 if (enabled()) { | 68 if (enabled()) { |
| 76 delegate()->DisableTool(GetToolId()); | 69 delegate()->DisableTool(GetToolId()); |
| 77 delegate()->RecordPaletteModeCancellation( | 70 delegate()->RecordPaletteModeCancellation( |
| 78 PaletteToolIdToPaletteModeCancelType(GetToolId(), | 71 PaletteToolIdToPaletteModeCancelType(GetToolId(), |
| 79 false /*is_switched*/)); | 72 false /*is_switched*/)); |
| 80 } else { | 73 } else { |
| 81 delegate()->EnableTool(GetToolId()); | 74 delegate()->EnableTool(GetToolId()); |
| 82 } | 75 } |
| 83 } | 76 } |
| 84 | 77 |
| 85 views::View* CommonPaletteTool::CreateDefaultView(const base::string16& name) { | 78 views::View* CommonPaletteTool::CreateDefaultView(const base::string16& name) { |
| 86 gfx::ImageSkia icon = | 79 gfx::ImageSkia icon = |
| 87 CreateVectorIcon(GetPaletteIcon(), kMenuIconSize, gfx::kChromeIconGrey); | 80 CreateVectorIcon(GetPaletteIcon(), kMenuIconSize, gfx::kChromeIconGrey); |
| 88 gfx::ImageSkia check = | |
| 89 CreateVectorIcon(kCheckCircleIcon, kMenuIconSize, gfx::kGoogleGreen700); | |
| 90 | 81 |
| 91 highlight_view_ = new HoverHighlightView(this); | 82 highlight_view_ = new HoverHighlightView(this); |
| 92 highlight_view_->SetBorder(views::CreateEmptyBorder(0, 0, 0, 0)); | 83 highlight_view_->SetBorder(views::CreateEmptyBorder(0, 0, 0, 0)); |
| 93 highlight_view_->AddIconAndLabel(icon, name); | 84 highlight_view_->AddIconAndLabel(icon, name); |
| 94 highlight_view_->AddRightIcon(check, kMenuIconSize); | |
| 95 highlight_view_->set_custom_height(kMenuButtonSize); | 85 highlight_view_->set_custom_height(kMenuButtonSize); |
| 96 | 86 |
| 97 if (enabled()) { | 87 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 | 88 |
| 106 return highlight_view_; | 89 return highlight_view_; |
| 107 } | 90 } |
| 108 | 91 |
| 109 } // namespace ash | 92 } // namespace ash |
| OLD | NEW |