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