| 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/common/system/ime/tray_ime_chromeos.h" | 5 #include "ash/common/system/ime/tray_ime_chromeos.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/common/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
| 10 #include "ash/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 private: | 106 private: |
| 107 DISALLOW_COPY_AND_ASSIGN(IMEDefaultView); | 107 DISALLOW_COPY_AND_ASSIGN(IMEDefaultView); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 class IMEDetailedView : public ImeListView { | 110 class IMEDetailedView : public ImeListView { |
| 111 public: | 111 public: |
| 112 IMEDetailedView(SystemTrayItem* owner, | 112 IMEDetailedView(SystemTrayItem* owner, |
| 113 LoginStatus login, | 113 LoginStatus login, |
| 114 bool show_keyboard_toggle) | 114 bool show_keyboard_toggle) |
| 115 : ImeListView(owner, show_keyboard_toggle, ImeListView::HIDE_SINGLE_IME), | 115 : ImeListView(owner, show_keyboard_toggle, ImeListView::HIDE_SINGLE_IME), |
| 116 login_(login) { | 116 login_(login), |
| 117 settings_(nullptr), |
| 118 settings_button_(nullptr) { |
| 117 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); | 119 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); |
| 118 IMEInfoList list; | 120 IMEInfoList list; |
| 119 delegate->GetAvailableIMEList(&list); | 121 delegate->GetAvailableIMEList(&list); |
| 120 IMEPropertyInfoList property_list; | 122 IMEPropertyInfoList property_list; |
| 121 delegate->GetCurrentIMEProperties(&property_list); | 123 delegate->GetCurrentIMEProperties(&property_list); |
| 122 Update(list, property_list, show_keyboard_toggle, | 124 Update(list, property_list, show_keyboard_toggle, |
| 123 ImeListView::HIDE_SINGLE_IME); | 125 ImeListView::HIDE_SINGLE_IME); |
| 124 } | 126 } |
| 125 | 127 |
| 126 ~IMEDetailedView() override {} | 128 ~IMEDetailedView() override {} |
| 127 | 129 |
| 128 void Update(const IMEInfoList& list, | 130 void Update(const IMEInfoList& list, |
| 129 const IMEPropertyInfoList& property_list, | 131 const IMEPropertyInfoList& property_list, |
| 130 bool show_keyboard_toggle, | 132 bool show_keyboard_toggle, |
| 131 SingleImeBehavior single_ime_behavior) override { | 133 SingleImeBehavior single_ime_behavior) override { |
| 132 ImeListView::Update(list, property_list, show_keyboard_toggle, | 134 ImeListView::Update(list, property_list, show_keyboard_toggle, |
| 133 single_ime_behavior); | 135 single_ime_behavior); |
| 134 if (login_ != LoginStatus::NOT_LOGGED_IN && login_ != LoginStatus::LOCKED && | 136 if (!MaterialDesignController::IsSystemTrayMenuMaterial() && |
| 135 !WmShell::Get() | 137 CanOpenWebUISettings(login_)) { |
| 136 ->GetSessionStateDelegate() | |
| 137 ->IsInSecondaryLoginScreen()) { | |
| 138 AppendSettings(); | 138 AppendSettings(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 CreateTitleRow(IDS_ASH_STATUS_TRAY_IME); | 141 CreateTitleRow(IDS_ASH_STATUS_TRAY_IME); |
| 142 } | 142 } |
| 143 | 143 |
| 144 private: | 144 private: |
| 145 // ImeListView: | 145 // ImeListView: |
| 146 void HandleViewClicked(views::View* view) override { | 146 void HandleViewClicked(views::View* view) override { |
| 147 ImeListView::HandleViewClicked(view); | 147 ImeListView::HandleViewClicked(view); |
| 148 if (view == settings_) { | 148 if (view == settings_) |
| 149 WmShell::Get()->RecordUserMetricsAction( | 149 ShowSettings(); |
| 150 UMA_STATUS_AREA_IME_SHOW_DETAILED); | 150 } |
| 151 WmShell::Get()->system_tray_controller()->ShowIMESettings(); | 151 |
| 152 } | 152 void HandleButtonPressed(views::Button* sender, |
| 153 const ui::Event& event) override { |
| 154 if (sender == settings_button_) |
| 155 ShowSettings(); |
| 156 } |
| 157 |
| 158 void CreateExtraTitleRowButtons() override { |
| 159 if (MaterialDesignController::IsSystemTrayMenuMaterial()) |
| 160 settings_button_ = title_row()->AddSettingsButton(this, login_); |
| 153 } | 161 } |
| 154 | 162 |
| 155 void AppendSettings() { | 163 void AppendSettings() { |
| 156 HoverHighlightView* container = new HoverHighlightView(this); | 164 HoverHighlightView* container = new HoverHighlightView(this); |
| 157 container->AddLabel( | 165 container->AddLabel( |
| 158 ui::ResourceBundle::GetSharedInstance().GetLocalizedString( | 166 ui::ResourceBundle::GetSharedInstance().GetLocalizedString( |
| 159 IDS_ASH_STATUS_TRAY_IME_SETTINGS), | 167 IDS_ASH_STATUS_TRAY_IME_SETTINGS), |
| 160 gfx::ALIGN_LEFT, false /* highlight */); | 168 gfx::ALIGN_LEFT, false /* highlight */); |
| 161 AddChildView(container); | 169 AddChildView(container); |
| 162 settings_ = container; | 170 settings_ = container; |
| 163 } | 171 } |
| 164 | 172 |
| 173 void ShowSettings() { |
| 174 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_IME_SHOW_DETAILED); |
| 175 WmShell::Get()->system_tray_controller()->ShowIMESettings(); |
| 176 if (owner()->system_tray()) |
| 177 owner()->system_tray()->CloseSystemBubble(); |
| 178 } |
| 179 |
| 165 LoginStatus login_; | 180 LoginStatus login_; |
| 166 | 181 |
| 182 // Not used in material design. |
| 167 views::View* settings_; | 183 views::View* settings_; |
| 168 | 184 |
| 185 // Only used in material design. |
| 186 views::Button* settings_button_; |
| 187 |
| 169 DISALLOW_COPY_AND_ASSIGN(IMEDetailedView); | 188 DISALLOW_COPY_AND_ASSIGN(IMEDetailedView); |
| 170 }; | 189 }; |
| 171 | 190 |
| 172 } // namespace tray | 191 } // namespace tray |
| 173 | 192 |
| 174 TrayIME::TrayIME(SystemTray* system_tray) | 193 TrayIME::TrayIME(SystemTray* system_tray) |
| 175 : SystemTrayItem(system_tray, UMA_IME), | 194 : SystemTrayItem(system_tray, UMA_IME), |
| 176 tray_label_(NULL), | 195 tray_label_(NULL), |
| 177 default_(NULL), | 196 default_(NULL), |
| 178 detailed_(NULL), | 197 detailed_(NULL), |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 else | 332 else |
| 314 Update(); | 333 Update(); |
| 315 } | 334 } |
| 316 | 335 |
| 317 bool TrayIME::ShouldDefaultViewBeVisible() { | 336 bool TrayIME::ShouldDefaultViewBeVisible() { |
| 318 return is_visible_ && (ime_list_.size() > 1 || property_list_.size() > 1 || | 337 return is_visible_ && (ime_list_.size() > 1 || property_list_.size() > 1 || |
| 319 ShouldShowKeyboardToggle()); | 338 ShouldShowKeyboardToggle()); |
| 320 } | 339 } |
| 321 | 340 |
| 322 } // namespace ash | 341 } // namespace ash |
| OLD | NEW |