| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/resources/vector_icons/vector_icons.h" | 9 #include "ash/resources/vector_icons/vector_icons.h" |
| 10 #include "ash/session/session_state_delegate.h" | 10 #include "ash/session/session_state_delegate.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 DISALLOW_COPY_AND_ASSIGN(IMEDefaultView); | 70 DISALLOW_COPY_AND_ASSIGN(IMEDefaultView); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 // A list of available IMEs shown in the IME detailed view of the system menu, | 73 // A list of available IMEs shown in the IME detailed view of the system menu, |
| 74 // along with other items in the title row (a settings button and optional | 74 // along with other items in the title row (a settings button and optional |
| 75 // enterprise-controlled icon). | 75 // enterprise-controlled icon). |
| 76 class IMEDetailedView : public ImeListView { | 76 class IMEDetailedView : public ImeListView { |
| 77 public: | 77 public: |
| 78 IMEDetailedView(SystemTrayItem* owner, LoginStatus login) | 78 explicit IMEDetailedView(SystemTrayItem* owner) |
| 79 : ImeListView(owner), login_(login), settings_button_(nullptr) {} | 79 : ImeListView(owner), settings_button_(nullptr) {} |
| 80 | 80 |
| 81 ~IMEDetailedView() override {} | 81 ~IMEDetailedView() override {} |
| 82 | 82 |
| 83 void SetImeManagedMessage(base::string16 ime_managed_message) { | 83 void SetImeManagedMessage(base::string16 ime_managed_message) { |
| 84 ime_managed_message_ = ime_managed_message; | 84 ime_managed_message_ = ime_managed_message; |
| 85 } | 85 } |
| 86 | 86 |
| 87 void Update(const IMEInfoList& list, | 87 void Update(const IMEInfoList& list, |
| 88 const IMEPropertyInfoList& property_list, | 88 const IMEPropertyInfoList& property_list, |
| 89 bool show_keyboard_toggle, | 89 bool show_keyboard_toggle, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 112 void CreateExtraTitleRowButtons() override { | 112 void CreateExtraTitleRowButtons() override { |
| 113 if (!ime_managed_message_.empty()) { | 113 if (!ime_managed_message_.empty()) { |
| 114 controlled_setting_icon_ = TrayPopupUtils::CreateMainImageView(); | 114 controlled_setting_icon_ = TrayPopupUtils::CreateMainImageView(); |
| 115 controlled_setting_icon_->SetImage( | 115 controlled_setting_icon_->SetImage( |
| 116 gfx::CreateVectorIcon(kSystemMenuBusinessIcon, kMenuIconColor)); | 116 gfx::CreateVectorIcon(kSystemMenuBusinessIcon, kMenuIconColor)); |
| 117 controlled_setting_icon_->SetTooltipText(ime_managed_message_); | 117 controlled_setting_icon_->SetTooltipText(ime_managed_message_); |
| 118 tri_view()->AddView(TriView::Container::END, controlled_setting_icon_); | 118 tri_view()->AddView(TriView::Container::END, controlled_setting_icon_); |
| 119 } | 119 } |
| 120 | 120 |
| 121 tri_view()->SetContainerVisible(TriView::Container::END, true); | 121 tri_view()->SetContainerVisible(TriView::Container::END, true); |
| 122 settings_button_ = | 122 settings_button_ = CreateSettingsButton(IDS_ASH_STATUS_TRAY_IME_SETTINGS); |
| 123 CreateSettingsButton(login_, IDS_ASH_STATUS_TRAY_IME_SETTINGS); | |
| 124 tri_view()->AddView(TriView::Container::END, settings_button_); | 123 tri_view()->AddView(TriView::Container::END, settings_button_); |
| 125 } | 124 } |
| 126 | 125 |
| 127 void ShowSettings() { | 126 void ShowSettings() { |
| 128 ShellPort::Get()->RecordUserMetricsAction( | 127 ShellPort::Get()->RecordUserMetricsAction( |
| 129 UMA_STATUS_AREA_IME_SHOW_DETAILED); | 128 UMA_STATUS_AREA_IME_SHOW_DETAILED); |
| 130 Shell::Get()->system_tray_controller()->ShowIMESettings(); | 129 Shell::Get()->system_tray_controller()->ShowIMESettings(); |
| 131 if (owner()->system_tray()) | 130 if (owner()->system_tray()) |
| 132 owner()->system_tray()->CloseSystemBubble(); | 131 owner()->system_tray()->CloseSystemBubble(); |
| 133 } | 132 } |
| 134 | 133 |
| 135 LoginStatus login_; | |
| 136 | |
| 137 views::Button* settings_button_; | 134 views::Button* settings_button_; |
| 138 | 135 |
| 139 // This icon says that the IMEs are managed by policy. | 136 // This icon says that the IMEs are managed by policy. |
| 140 views::ImageView* controlled_setting_icon_; | 137 views::ImageView* controlled_setting_icon_; |
| 141 // If non-empty, a controlled setting icon should be displayed with this | 138 // If non-empty, a controlled setting icon should be displayed with this |
| 142 // string as tooltip. | 139 // string as tooltip. |
| 143 base::string16 ime_managed_message_; | 140 base::string16 ime_managed_message_; |
| 144 | 141 |
| 145 DISALLOW_COPY_AND_ASSIGN(IMEDetailedView); | 142 DISALLOW_COPY_AND_ASSIGN(IMEDetailedView); |
| 146 }; | 143 }; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 views::View* TrayIME::CreateDefaultView(LoginStatus status) { | 237 views::View* TrayIME::CreateDefaultView(LoginStatus status) { |
| 241 CHECK(default_ == NULL); | 238 CHECK(default_ == NULL); |
| 242 default_ = new tray::IMEDefaultView( | 239 default_ = new tray::IMEDefaultView( |
| 243 this, GetDefaultViewLabel(ShouldShowImeTrayItem(ime_list_.size()))); | 240 this, GetDefaultViewLabel(ShouldShowImeTrayItem(ime_list_.size()))); |
| 244 default_->SetVisible(ShouldDefaultViewBeVisible()); | 241 default_->SetVisible(ShouldDefaultViewBeVisible()); |
| 245 return default_; | 242 return default_; |
| 246 } | 243 } |
| 247 | 244 |
| 248 views::View* TrayIME::CreateDetailedView(LoginStatus status) { | 245 views::View* TrayIME::CreateDetailedView(LoginStatus status) { |
| 249 CHECK(detailed_ == NULL); | 246 CHECK(detailed_ == NULL); |
| 250 detailed_ = new tray::IMEDetailedView(this, status); | 247 detailed_ = new tray::IMEDetailedView(this); |
| 251 detailed_->SetImeManagedMessage(ime_managed_message_); | 248 detailed_->SetImeManagedMessage(ime_managed_message_); |
| 252 detailed_->Init(ShouldShowKeyboardToggle(), GetSingleImeBehavior()); | 249 detailed_->Init(ShouldShowKeyboardToggle(), GetSingleImeBehavior()); |
| 253 return detailed_; | 250 return detailed_; |
| 254 } | 251 } |
| 255 | 252 |
| 256 void TrayIME::DestroyTrayView() { | 253 void TrayIME::DestroyTrayView() { |
| 257 tray_label_ = NULL; | 254 tray_label_ = NULL; |
| 258 } | 255 } |
| 259 | 256 |
| 260 void TrayIME::DestroyDefaultView() { | 257 void TrayIME::DestroyDefaultView() { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 return ime_count >= threshold; | 300 return ime_count >= threshold; |
| 304 } | 301 } |
| 305 | 302 |
| 306 ImeListView::SingleImeBehavior TrayIME::GetSingleImeBehavior() { | 303 ImeListView::SingleImeBehavior TrayIME::GetSingleImeBehavior() { |
| 307 // If managed, we also want to show a single IME. | 304 // If managed, we also want to show a single IME. |
| 308 return IsIMEManaged() ? ImeListView::SHOW_SINGLE_IME | 305 return IsIMEManaged() ? ImeListView::SHOW_SINGLE_IME |
| 309 : ImeListView::HIDE_SINGLE_IME; | 306 : ImeListView::HIDE_SINGLE_IME; |
| 310 } | 307 } |
| 311 | 308 |
| 312 } // namespace ash | 309 } // namespace ash |
| OLD | NEW |