Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(438)

Side by Side Diff: ash/common/system/chromeos/palette/common_palette_tool.cc

Issue 2803893002: Reuse the code within UpdateCheckMark() (Closed)
Patch Set: Rename CheckMark -> SetCheckMarkVisible, UncheckMark -> SetCheckMarkInvisible. Update the comment. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_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 23 matching lines...) Expand all
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 SetCheckMarkVisible(highlight_view_);
56 highlight_view_->SetAccessiblityState(
57 HoverHighlightView::AccessibilityState::CHECKED_CHECKBOX);
58 } 57 }
59 } 58 }
60 59
61 void CommonPaletteTool::OnDisable() { 60 void CommonPaletteTool::OnDisable() {
62 PaletteTool::OnDisable(); 61 PaletteTool::OnDisable();
63 AddHistogramTimes(GetToolId(), base::TimeTicks::Now() - start_time_); 62 AddHistogramTimes(GetToolId(), base::TimeTicks::Now() - start_time_);
64 63
65 if (highlight_view_) { 64 if (highlight_view_) {
66 highlight_view_->SetRightViewVisible(false); 65 SetCheckMarkInvisible(highlight_view_);
67 highlight_view_->SetAccessiblityState(
68 HoverHighlightView::AccessibilityState::UNCHECKED_CHECKBOX);
69 } 66 }
70 } 67 }
71 68
72 void CommonPaletteTool::OnViewClicked(views::View* sender) { 69 void CommonPaletteTool::OnViewClicked(views::View* sender) {
73 delegate()->RecordPaletteOptionsUsage( 70 delegate()->RecordPaletteOptionsUsage(
74 PaletteToolIdToPaletteTrayOptions(GetToolId())); 71 PaletteToolIdToPaletteTrayOptions(GetToolId()));
75 if (enabled()) { 72 if (enabled()) {
76 delegate()->DisableTool(GetToolId()); 73 delegate()->DisableTool(GetToolId());
77 delegate()->RecordPaletteModeCancellation( 74 delegate()->RecordPaletteModeCancellation(
78 PaletteToolIdToPaletteModeCancelType(GetToolId(), 75 PaletteToolIdToPaletteModeCancelType(GetToolId(),
79 false /*is_switched*/)); 76 false /*is_switched*/));
80 } else { 77 } else {
81 delegate()->EnableTool(GetToolId()); 78 delegate()->EnableTool(GetToolId());
82 } 79 }
83 } 80 }
84 81
85 views::View* CommonPaletteTool::CreateDefaultView(const base::string16& name) { 82 views::View* CommonPaletteTool::CreateDefaultView(const base::string16& name) {
tdanderson 2017/04/06 17:52:09 There is still some code in here that is common to
86 gfx::ImageSkia icon = 83 gfx::ImageSkia icon =
87 CreateVectorIcon(GetPaletteIcon(), kMenuIconSize, gfx::kChromeIconGrey); 84 CreateVectorIcon(GetPaletteIcon(), kMenuIconSize, gfx::kChromeIconGrey);
88 gfx::ImageSkia check = 85 gfx::ImageSkia check =
89 CreateVectorIcon(kCheckCircleIcon, kMenuIconSize, gfx::kGoogleGreen700); 86 CreateVectorIcon(kCheckCircleIcon, kMenuIconSize, gfx::kGoogleGreen700);
90 87
91 highlight_view_ = new HoverHighlightView(this); 88 highlight_view_ = new HoverHighlightView(this);
92 highlight_view_->SetBorder(views::CreateEmptyBorder(0, 0, 0, 0)); 89 highlight_view_->SetBorder(views::CreateEmptyBorder(0, 0, 0, 0));
93 highlight_view_->AddIconAndLabel(icon, name); 90 highlight_view_->AddIconAndLabel(icon, name);
94 highlight_view_->AddRightIcon(check, kMenuIconSize); 91 highlight_view_->AddRightIcon(check, kMenuIconSize);
95 highlight_view_->set_custom_height(kMenuButtonSize); 92 highlight_view_->set_custom_height(kMenuButtonSize);
96 93
97 if (enabled()) { 94 if (enabled()) {
98 highlight_view_->SetAccessiblityState( 95 SetCheckMarkVisible(highlight_view_);
99 HoverHighlightView::AccessibilityState::CHECKED_CHECKBOX);
100 } else { 96 } else {
101 highlight_view_->SetRightViewVisible(false); 97 SetCheckMarkInvisible(highlight_view_);
102 highlight_view_->SetAccessiblityState(
103 HoverHighlightView::AccessibilityState::UNCHECKED_CHECKBOX);
104 } 98 }
105 99
106 return highlight_view_; 100 return highlight_view_;
107 } 101 }
108 102
109 } // namespace ash 103 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698