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

Side by Side Diff: ash/system/chromeos/tray_caps_lock.cc

Issue 800983006: Update {virtual,override,final} to follow C++11 style in ash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Workaround Created 5 years, 11 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
« no previous file with comments | « ash/system/chromeos/tray_caps_lock.h ('k') | ash/system/chromeos/tray_display.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/system/chromeos/tray_caps_lock.h" 5 #include "ash/system/chromeos/tray_caps_lock.h"
6 6
7 #include "ash/metrics/user_metrics_recorder.h" 7 #include "ash/metrics/user_metrics_recorder.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/system/tray/actionable_view.h" 9 #include "ash/system/tray/actionable_view.h"
10 #include "ash/system/tray/fixed_sized_image_view.h" 10 #include "ash/system/tray/fixed_sized_image_view.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 ToImageSkia()); 54 ToImageSkia());
55 AddChildView(image); 55 AddChildView(image);
56 56
57 text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 57 text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
58 AddChildView(text_label_); 58 AddChildView(text_label_);
59 59
60 shortcut_label_->SetEnabled(false); 60 shortcut_label_->SetEnabled(false);
61 AddChildView(shortcut_label_); 61 AddChildView(shortcut_label_);
62 } 62 }
63 63
64 virtual ~CapsLockDefaultView() {} 64 ~CapsLockDefaultView() override {}
65 65
66 // Updates the label text and the shortcut text. 66 // Updates the label text and the shortcut text.
67 void Update(bool caps_lock_enabled) { 67 void Update(bool caps_lock_enabled) {
68 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 68 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
69 const int text_string_id = caps_lock_enabled ? 69 const int text_string_id = caps_lock_enabled ?
70 IDS_ASH_STATUS_TRAY_CAPS_LOCK_ENABLED : 70 IDS_ASH_STATUS_TRAY_CAPS_LOCK_ENABLED :
71 IDS_ASH_STATUS_TRAY_CAPS_LOCK_DISABLED; 71 IDS_ASH_STATUS_TRAY_CAPS_LOCK_DISABLED;
72 text_label_->SetText(bundle.GetLocalizedString(text_string_id)); 72 text_label_->SetText(bundle.GetLocalizedString(text_string_id));
73 73
74 int shortcut_string_id = 0; 74 int shortcut_string_id = 0;
75 bool search_mapped_to_caps_lock = Shell::GetInstance()-> 75 bool search_mapped_to_caps_lock = Shell::GetInstance()->
76 system_tray_delegate()->IsSearchKeyMappedToCapsLock(); 76 system_tray_delegate()->IsSearchKeyMappedToCapsLock();
77 if (caps_lock_enabled) { 77 if (caps_lock_enabled) {
78 shortcut_string_id = search_mapped_to_caps_lock ? 78 shortcut_string_id = search_mapped_to_caps_lock ?
79 IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_SEARCH_OR_SHIFT : 79 IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_SEARCH_OR_SHIFT :
80 IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_ALT_SEARCH_OR_SHIFT; 80 IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_ALT_SEARCH_OR_SHIFT;
81 } else { 81 } else {
82 shortcut_string_id = search_mapped_to_caps_lock ? 82 shortcut_string_id = search_mapped_to_caps_lock ?
83 IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_SEARCH : 83 IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_SEARCH :
84 IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_ALT_SEARCH; 84 IDS_ASH_STATUS_TRAY_CAPS_LOCK_SHORTCUT_ALT_SEARCH;
85 } 85 }
86 shortcut_label_->SetText(bundle.GetLocalizedString(shortcut_string_id)); 86 shortcut_label_->SetText(bundle.GetLocalizedString(shortcut_string_id));
87 87
88 Layout(); 88 Layout();
89 } 89 }
90 90
91 private: 91 private:
92 // Overridden from views::View: 92 // Overridden from views::View:
93 virtual void Layout() override { 93 void Layout() override {
94 views::View::Layout(); 94 views::View::Layout();
95 95
96 // Align the shortcut text with the right end 96 // Align the shortcut text with the right end
97 const int old_x = shortcut_label_->x(); 97 const int old_x = shortcut_label_->x();
98 const int new_x = 98 const int new_x =
99 width() - shortcut_label_->width() - kTrayPopupPaddingHorizontal; 99 width() - shortcut_label_->width() - kTrayPopupPaddingHorizontal;
100 shortcut_label_->SetX(new_x); 100 shortcut_label_->SetX(new_x);
101 const gfx::Size text_size = text_label_->size(); 101 const gfx::Size text_size = text_label_->size();
102 text_label_->SetSize(gfx::Size(text_size.width() + new_x - old_x, 102 text_label_->SetSize(gfx::Size(text_size.width() + new_x - old_x,
103 text_size.height())); 103 text_size.height()));
104 } 104 }
105 105
106 virtual void GetAccessibleState(ui::AXViewState* state) override { 106 void GetAccessibleState(ui::AXViewState* state) override {
107 state->role = ui::AX_ROLE_BUTTON; 107 state->role = ui::AX_ROLE_BUTTON;
108 state->name = text_label_->text(); 108 state->name = text_label_->text();
109 } 109 }
110 110
111 // Overridden from ActionableView: 111 // Overridden from ActionableView:
112 virtual bool PerformAction(const ui::Event& event) override { 112 bool PerformAction(const ui::Event& event) override {
113 chromeos::input_method::ImeKeyboard* keyboard = 113 chromeos::input_method::ImeKeyboard* keyboard =
114 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard(); 114 chromeos::input_method::InputMethodManager::Get()->GetImeKeyboard();
115 if (keyboard) { 115 if (keyboard) {
116 Shell::GetInstance()->metrics()->RecordUserMetricsAction( 116 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
117 keyboard->CapsLockIsEnabled() ? 117 keyboard->CapsLockIsEnabled() ?
118 ash::UMA_STATUS_AREA_CAPS_LOCK_DISABLED_BY_CLICK : 118 ash::UMA_STATUS_AREA_CAPS_LOCK_DISABLED_BY_CLICK :
119 ash::UMA_STATUS_AREA_CAPS_LOCK_ENABLED_BY_CLICK); 119 ash::UMA_STATUS_AREA_CAPS_LOCK_ENABLED_BY_CLICK);
120 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); 120 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled());
121 } 121 }
122 return true; 122 return true;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 213
214 void TrayCapsLock::DestroyDefaultView() { 214 void TrayCapsLock::DestroyDefaultView() {
215 default_ = NULL; 215 default_ = NULL;
216 } 216 }
217 217
218 void TrayCapsLock::DestroyDetailedView() { 218 void TrayCapsLock::DestroyDetailedView() {
219 detailed_ = NULL; 219 detailed_ = NULL;
220 } 220 }
221 221
222 } // namespace ash 222 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/tray_caps_lock.h ('k') | ash/system/chromeos/tray_display.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698