OLD | NEW |
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/tray_caps_lock.h" | 5 #include "ash/system/tray_caps_lock.h" |
6 | 6 |
| 7 #include "ash/caps_lock_delegate.h" |
7 #include "ash/shell.h" | 8 #include "ash/shell.h" |
8 #include "ash/system/tray/system_tray_delegate.h" | |
9 #include "ash/system/tray/tray_constants.h" | 9 #include "ash/system/tray/tray_constants.h" |
10 #include "ash/system/tray/tray_views.h" | 10 #include "ash/system/tray/tray_views.h" |
11 #include "grit/ash_strings.h" | 11 #include "grit/ash_strings.h" |
12 #include "grit/ui_resources.h" | 12 #include "grit/ui_resources.h" |
13 #include "ui/base/accessibility/accessible_view_state.h" | 13 #include "ui/base/accessibility/accessible_view_state.h" |
14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
15 #include "ui/gfx/image/image.h" | 15 #include "ui/gfx/image/image.h" |
16 #include "ui/views/controls/image_view.h" | 16 #include "ui/views/controls/image_view.h" |
17 #include "ui/views/controls/label.h" | 17 #include "ui/views/controls/label.h" |
18 #include "ui/views/layout/box_layout.h" | 18 #include "ui/views/layout/box_layout.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 text_size.height())); | 85 text_size.height())); |
86 } | 86 } |
87 | 87 |
88 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE { | 88 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE { |
89 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; | 89 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON; |
90 state->name = text_label_->text(); | 90 state->name = text_label_->text(); |
91 } | 91 } |
92 | 92 |
93 // Overridden from ActionableView: | 93 // Overridden from ActionableView: |
94 virtual bool PerformAction(const ui::Event& event) OVERRIDE { | 94 virtual bool PerformAction(const ui::Event& event) OVERRIDE { |
95 Shell::GetInstance()->tray_delegate()->SetCapsLockEnabled( | 95 Shell::GetInstance()->caps_lock_delegate()->ToggleCapsLock(); |
96 !Shell::GetInstance()->tray_delegate()->IsCapsLockOn()); | |
97 return true; | 96 return true; |
98 } | 97 } |
99 | 98 |
100 views::Label* text_label_; | 99 views::Label* text_label_; |
101 views::Label* shortcut_label_; | 100 views::Label* shortcut_label_; |
102 | 101 |
103 DISALLOW_COPY_AND_ASSIGN(CapsLockDefaultView); | 102 DISALLOW_COPY_AND_ASSIGN(CapsLockDefaultView); |
104 }; | 103 }; |
105 | 104 |
106 TrayCapsLock::TrayCapsLock() | 105 TrayCapsLock::TrayCapsLock() |
107 : TrayImageItem(IDR_AURA_UBER_TRAY_CAPS_LOCK), | 106 : TrayImageItem(IDR_AURA_UBER_TRAY_CAPS_LOCK), |
108 default_(NULL), | 107 default_(NULL), |
109 detailed_(NULL), | 108 detailed_(NULL), |
110 search_mapped_to_caps_lock_(false), | 109 search_mapped_to_caps_lock_(false), |
111 caps_lock_enabled_( | 110 caps_lock_enabled_( |
112 Shell::GetInstance()->tray_delegate()->IsCapsLockOn()), | 111 Shell::GetInstance()->caps_lock_delegate()->IsCapsLockEnabled()), |
113 message_shown_(false) { | 112 message_shown_(false) { |
114 } | 113 } |
115 | 114 |
116 TrayCapsLock::~TrayCapsLock() {} | 115 TrayCapsLock::~TrayCapsLock() {} |
117 | 116 |
118 bool TrayCapsLock::GetInitialVisibility() { | 117 bool TrayCapsLock::GetInitialVisibility() { |
119 return Shell::GetInstance()->tray_delegate()->IsCapsLockOn(); | 118 return Shell::GetInstance()->caps_lock_delegate()->IsCapsLockEnabled(); |
120 } | 119 } |
121 | 120 |
122 views::View* TrayCapsLock::CreateDefaultView(user::LoginStatus status) { | 121 views::View* TrayCapsLock::CreateDefaultView(user::LoginStatus status) { |
123 if (!caps_lock_enabled_) | 122 if (!caps_lock_enabled_) |
124 return NULL; | 123 return NULL; |
125 DCHECK(default_ == NULL); | 124 DCHECK(default_ == NULL); |
126 default_ = new CapsLockDefaultView; | 125 default_ = new CapsLockDefaultView; |
127 default_->Update(caps_lock_enabled_, search_mapped_to_caps_lock_); | 126 default_->Update(caps_lock_enabled_, search_mapped_to_caps_lock_); |
128 return default_; | 127 return default_; |
129 } | 128 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 message_shown_ = true; | 178 message_shown_ = true; |
180 } | 179 } |
181 } else if (detailed_) { | 180 } else if (detailed_) { |
182 detailed_->GetWidget()->Close(); | 181 detailed_->GetWidget()->Close(); |
183 } | 182 } |
184 } | 183 } |
185 } | 184 } |
186 | 185 |
187 } // namespace internal | 186 } // namespace internal |
188 } // namespace ash | 187 } // namespace ash |
OLD | NEW |