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/ime/tray_ime_chromeos.h" | 5 #include "ash/system/ime/tray_ime_chromeos.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/resources/vector_icons/vector_icons.h" | 10 #include "ash/resources/vector_icons/vector_icons.h" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
12 #include "ash/shell_port.h" | 12 #include "ash/shell_port.h" |
13 #include "ash/strings/grit/ash_strings.h" | 13 #include "ash/strings/grit/ash_strings.h" |
14 #include "ash/system/tray/system_tray.h" | 14 #include "ash/system/tray/system_tray.h" |
15 #include "ash/system/tray/system_tray_controller.h" | 15 #include "ash/system/tray/system_tray_controller.h" |
16 #include "ash/system/tray/system_tray_delegate.h" | 16 #include "ash/system/tray/system_tray_delegate.h" |
17 #include "ash/system/tray/system_tray_notifier.h" | 17 #include "ash/system/tray/system_tray_notifier.h" |
18 #include "ash/system/tray/tray_constants.h" | 18 #include "ash/system/tray/tray_constants.h" |
19 #include "ash/system/tray/tray_details_view.h" | 19 #include "ash/system/tray/tray_details_view.h" |
20 #include "ash/system/tray/tray_item_more.h" | 20 #include "ash/system/tray/tray_item_more.h" |
21 #include "ash/system/tray/tray_item_view.h" | 21 #include "ash/system/tray/tray_item_view.h" |
22 #include "ash/system/tray/tray_popup_item_style.h" | 22 #include "ash/system/tray/tray_popup_item_style.h" |
23 #include "ash/system/tray/tray_popup_utils.h" | 23 #include "ash/system/tray/tray_popup_utils.h" |
24 #include "ash/system/tray/tray_utils.h" | 24 #include "ash/system/tray/tray_utils.h" |
25 #include "ash/system/tray/tri_view.h" | 25 #include "ash/system/tray/tri_view.h" |
26 #include "ash/system/tray_accessibility.h" | 26 #include "ash/system/tray_accessibility.h" |
27 #include "base/logging.h" | 27 #include "base/logging.h" |
28 #include "base/strings/utf_string_conversions.h" | 28 #include "base/strings/utf_string_conversions.h" |
| 29 #include "components/strings/grit/components_strings.h" |
29 #include "ui/accessibility/ax_enums.h" | 30 #include "ui/accessibility/ax_enums.h" |
30 #include "ui/accessibility/ax_node_data.h" | 31 #include "ui/accessibility/ax_node_data.h" |
| 32 #include "ui/base/ime/chromeos/input_method_manager.h" |
31 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
32 #include "ui/gfx/font.h" | 34 #include "ui/gfx/font.h" |
33 #include "ui/gfx/image/image.h" | 35 #include "ui/gfx/image/image.h" |
34 #include "ui/gfx/paint_vector_icon.h" | 36 #include "ui/gfx/paint_vector_icon.h" |
35 #include "ui/keyboard/keyboard_util.h" | 37 #include "ui/keyboard/keyboard_util.h" |
36 #include "ui/views/controls/image_view.h" | 38 #include "ui/views/controls/image_view.h" |
37 #include "ui/views/controls/label.h" | 39 #include "ui/views/controls/label.h" |
38 #include "ui/views/layout/box_layout.h" | 40 #include "ui/views/layout/box_layout.h" |
39 #include "ui/views/widget/widget.h" | 41 #include "ui/views/widget/widget.h" |
40 | 42 |
| 43 using chromeos::input_method::InputMethodManager; |
| 44 |
41 namespace ash { | 45 namespace ash { |
42 namespace tray { | 46 namespace tray { |
43 | 47 |
44 class IMEDefaultView : public TrayItemMore { | 48 class IMEDefaultView : public TrayItemMore { |
45 public: | 49 public: |
46 IMEDefaultView(SystemTrayItem* owner, const base::string16& label) | 50 IMEDefaultView(SystemTrayItem* owner, const base::string16& label) |
47 : TrayItemMore(owner) { | 51 : TrayItemMore(owner) { |
48 SetImage(gfx::CreateVectorIcon(kSystemMenuKeyboardIcon, kMenuIconColor)); | 52 SetImage(gfx::CreateVectorIcon(kSystemMenuKeyboardIcon, kMenuIconColor)); |
49 UpdateLabel(label); | 53 UpdateLabel(label); |
50 } | 54 } |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 } | 267 } |
264 | 268 |
265 void TrayIME::OnIMERefresh() { | 269 void TrayIME::OnIMERefresh() { |
266 // Caches the current ime state. | 270 // Caches the current ime state. |
267 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate(); | 271 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate(); |
268 ime_list_.clear(); | 272 ime_list_.clear(); |
269 property_list_.clear(); | 273 property_list_.clear(); |
270 delegate->GetCurrentIME(¤t_ime_); | 274 delegate->GetCurrentIME(¤t_ime_); |
271 delegate->GetAvailableIMEList(&ime_list_); | 275 delegate->GetAvailableIMEList(&ime_list_); |
272 delegate->GetCurrentIMEProperties(&property_list_); | 276 delegate->GetCurrentIMEProperties(&property_list_); |
273 ime_managed_message_ = delegate->GetIMEManagedMessage(); | 277 auto ime_state = InputMethodManager::Get()->GetActiveIMEState(); |
| 278 ime_managed_message_ = |
| 279 ime_state->GetAllowedInputMethods().empty() |
| 280 ? base::string16() |
| 281 : l10n_util::GetStringUTF16(IDS_OPTIONS_CONTROLLED_SETTING_POLICY); |
274 | 282 |
275 Update(); | 283 Update(); |
276 } | 284 } |
277 | 285 |
278 void TrayIME::OnIMEMenuActivationChanged(bool is_active) { | 286 void TrayIME::OnIMEMenuActivationChanged(bool is_active) { |
279 is_visible_ = !is_active; | 287 is_visible_ = !is_active; |
280 if (is_visible_) | 288 if (is_visible_) |
281 OnIMERefresh(); | 289 OnIMERefresh(); |
282 else | 290 else |
283 Update(); | 291 Update(); |
(...skipping 16 matching lines...) Expand all Loading... |
300 return ime_count >= threshold; | 308 return ime_count >= threshold; |
301 } | 309 } |
302 | 310 |
303 ImeListView::SingleImeBehavior TrayIME::GetSingleImeBehavior() { | 311 ImeListView::SingleImeBehavior TrayIME::GetSingleImeBehavior() { |
304 // If managed, we also want to show a single IME. | 312 // If managed, we also want to show a single IME. |
305 return IsIMEManaged() ? ImeListView::SHOW_SINGLE_IME | 313 return IsIMEManaged() ? ImeListView::SHOW_SINGLE_IME |
306 : ImeListView::HIDE_SINGLE_IME; | 314 : ImeListView::HIDE_SINGLE_IME; |
307 } | 315 } |
308 | 316 |
309 } // namespace ash | 317 } // namespace ash |
OLD | NEW |