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.h" | 5 #include "ash/system/ime/tray_ime.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/system/tray/system_tray.h" | 10 #include "ash/system/tray/system_tray.h" |
11 #include "ash/system/tray/system_tray_delegate.h" | 11 #include "ash/system/tray/system_tray_delegate.h" |
12 #include "ash/system/tray/tray_constants.h" | 12 #include "ash/system/tray/tray_constants.h" |
13 #include "ash/system/tray/tray_details_view.h" | 13 #include "ash/system/tray/tray_details_view.h" |
14 #include "ash/system/tray/tray_item_more.h" | 14 #include "ash/system/tray/tray_item_more.h" |
15 #include "ash/system/tray/tray_item_view.h" | 15 #include "ash/system/tray/tray_item_view.h" |
16 #include "ash/system/tray/tray_notification_view.h" | 16 #include "ash/system/tray/tray_notification_view.h" |
17 #include "ash/system/tray/tray_views.h" | 17 #include "ash/system/tray/tray_views.h" |
| 18 #include "ash/wm/shelf_layout_manager.h" |
18 #include "base/logging.h" | 19 #include "base/logging.h" |
19 #include "base/timer.h" | 20 #include "base/timer.h" |
20 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
21 #include "grit/ash_strings.h" | 22 #include "grit/ash_strings.h" |
22 #include "grit/ui_resources.h" | 23 #include "grit/ui_resources.h" |
23 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
24 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
25 #include "ui/gfx/font.h" | 26 #include "ui/gfx/font.h" |
26 #include "ui/gfx/image/image.h" | 27 #include "ui/gfx/image/image.h" |
27 #include "ui/views/controls/label.h" | 28 #include "ui/views/controls/label.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 std::map<views::View*, std::string> property_map_; | 165 std::map<views::View*, std::string> property_map_; |
165 views::View* settings_; | 166 views::View* settings_; |
166 | 167 |
167 DISALLOW_COPY_AND_ASSIGN(IMEDetailedView); | 168 DISALLOW_COPY_AND_ASSIGN(IMEDetailedView); |
168 }; | 169 }; |
169 | 170 |
170 class IMENotificationView : public TrayNotificationView { | 171 class IMENotificationView : public TrayNotificationView { |
171 public: | 172 public: |
172 explicit IMENotificationView(TrayIME* tray) | 173 explicit IMENotificationView(TrayIME* tray) |
173 : TrayNotificationView(tray, IDR_AURA_UBER_TRAY_IME) { | 174 : TrayNotificationView(tray, IDR_AURA_UBER_TRAY_IME) { |
174 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 175 InitView(GetLabel()); |
175 IMEInfo current; | 176 } |
176 delegate->GetCurrentIME(¤t); | |
177 | 177 |
178 // TODO(zork): Use IDS_ASH_STATUS_TRAY_THIRD_PARTY_IME_TURNED_ON_BUBBLE for | 178 void UpdateLabel() { |
179 // third party IMEs | 179 RestartAutoCloseTimer(); |
180 InitView(new views::Label( | 180 UpdateView(GetLabel()); |
181 l10n_util::GetStringFUTF16( | |
182 IDS_ASH_STATUS_TRAY_IME_TURNED_ON_BUBBLE, | |
183 current.short_name))); | |
184 } | 181 } |
185 | 182 |
186 void StartAutoCloseTimer(int seconds) { | 183 void StartAutoCloseTimer(int seconds) { |
187 autoclose_.Stop(); | 184 autoclose_.Stop(); |
188 autoclose_delay_ = seconds; | 185 autoclose_delay_ = seconds; |
189 if (autoclose_delay_) { | 186 if (autoclose_delay_) { |
190 autoclose_.Start(FROM_HERE, | 187 autoclose_.Start(FROM_HERE, |
191 base::TimeDelta::FromSeconds(autoclose_delay_), | 188 base::TimeDelta::FromSeconds(autoclose_delay_), |
192 this, &IMENotificationView::Close); | 189 this, &IMENotificationView::Close); |
193 } | 190 } |
(...skipping 11 matching lines...) Expand all Loading... |
205 // Overridden from TrayNotificationView. | 202 // Overridden from TrayNotificationView. |
206 virtual void OnClickAction() OVERRIDE { | 203 virtual void OnClickAction() OVERRIDE { |
207 tray()->PopupDetailedView(0, true); | 204 tray()->PopupDetailedView(0, true); |
208 } | 205 } |
209 | 206 |
210 private: | 207 private: |
211 void Close() { | 208 void Close() { |
212 tray()->HideNotificationView(); | 209 tray()->HideNotificationView(); |
213 } | 210 } |
214 | 211 |
| 212 views::Label* GetLabel() { |
| 213 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
| 214 IMEInfo current; |
| 215 delegate->GetCurrentIME(¤t); |
| 216 |
| 217 // TODO(zork): Use IDS_ASH_STATUS_TRAY_THIRD_PARTY_IME_TURNED_ON_BUBBLE for |
| 218 // third party IMEs |
| 219 return new views::Label( |
| 220 l10n_util::GetStringFUTF16( |
| 221 IDS_ASH_STATUS_TRAY_IME_TURNED_ON_BUBBLE, |
| 222 current.short_name)); |
| 223 } |
| 224 |
| 225 |
215 int autoclose_delay_; | 226 int autoclose_delay_; |
216 base::OneShotTimer<IMENotificationView> autoclose_; | 227 base::OneShotTimer<IMENotificationView> autoclose_; |
217 | 228 |
218 DISALLOW_COPY_AND_ASSIGN(IMENotificationView); | 229 DISALLOW_COPY_AND_ASSIGN(IMENotificationView); |
219 }; | 230 }; |
220 | 231 |
221 | 232 |
222 } // namespace tray | 233 } // namespace tray |
223 | 234 |
224 TrayIME::TrayIME() | 235 TrayIME::TrayIME() |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 delegate->GetAvailableIMEList(&list); | 323 delegate->GetAvailableIMEList(&list); |
313 delegate->GetCurrentIMEProperties(&property_list); | 324 delegate->GetCurrentIMEProperties(&property_list); |
314 | 325 |
315 UpdateTrayLabel(current, list.size()); | 326 UpdateTrayLabel(current, list.size()); |
316 | 327 |
317 if (default_) | 328 if (default_) |
318 default_->UpdateLabel(current); | 329 default_->UpdateLabel(current); |
319 if (detailed_) | 330 if (detailed_) |
320 detailed_->Update(list, property_list); | 331 detailed_->Update(list, property_list); |
321 | 332 |
322 if (list.size() > 1 && show_message && !message_shown_) { | 333 if (list.size() > 1 && show_message) { |
323 if (!notification_) { | 334 // If the notification is still visible, hide it and clear the flag so it is |
| 335 // refreshed. |
| 336 if (notification_) { |
| 337 notification_->UpdateLabel(); |
| 338 } else if (!Shell::GetInstance()->shelf()->IsVisible() || !message_shown_) { |
324 ShowNotificationView(); | 339 ShowNotificationView(); |
325 message_shown_ = true; | 340 message_shown_ = true; |
326 } | 341 } |
327 } | 342 } |
328 } | 343 } |
329 | 344 |
330 } // namespace internal | 345 } // namespace internal |
331 } // namespace ash | 346 } // namespace ash |
OLD | NEW |