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/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "ui/views/layout/box_layout.h" | 30 #include "ui/views/layout/box_layout.h" |
31 #include "ui/views/widget/widget.h" | 31 #include "ui/views/widget/widget.h" |
32 | 32 |
33 namespace ash { | 33 namespace ash { |
34 namespace internal { | 34 namespace internal { |
35 | 35 |
36 namespace tray { | 36 namespace tray { |
37 | 37 |
38 class IMEDefaultView : public TrayItemMore { | 38 class IMEDefaultView : public TrayItemMore { |
39 public: | 39 public: |
40 explicit IMEDefaultView(SystemTrayItem* owner) | 40 explicit IMEDefaultView(SystemTrayItem* tray) |
41 : TrayItemMore(owner, true) { | 41 : TrayItemMore(tray, true) { |
42 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 42 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
43 | 43 |
44 SetImage(bundle.GetImageNamed( | 44 SetImage(bundle.GetImageNamed( |
45 IDR_AURA_UBER_TRAY_IME).ToImageSkia()); | 45 IDR_AURA_UBER_TRAY_IME).ToImageSkia()); |
46 | 46 |
47 IMEInfo info; | 47 IMEInfo info; |
48 Shell::GetInstance()->tray_delegate()->GetCurrentIME(&info); | 48 Shell::GetInstance()->tray_delegate()->GetCurrentIME(&info); |
49 UpdateLabel(info); | 49 UpdateLabel(info); |
50 } | 50 } |
51 | 51 |
52 virtual ~IMEDefaultView() {} | 52 virtual ~IMEDefaultView() {} |
53 | 53 |
54 void UpdateLabel(const IMEInfo& info) { | 54 void UpdateLabel(const IMEInfo& info) { |
55 SetLabel(info.name); | 55 SetLabel(info.name); |
56 SetAccessibleName(info.name); | 56 SetAccessibleName(info.name); |
57 } | 57 } |
58 | 58 |
59 private: | 59 private: |
60 DISALLOW_COPY_AND_ASSIGN(IMEDefaultView); | 60 DISALLOW_COPY_AND_ASSIGN(IMEDefaultView); |
61 }; | 61 }; |
62 | 62 |
63 class IMEDetailedView : public TrayDetailsView, | 63 class IMEDetailedView : public TrayDetailsView, |
64 public ViewClickListener { | 64 public ViewClickListener { |
65 public: | 65 public: |
66 IMEDetailedView(SystemTrayItem* owner, user::LoginStatus login) | 66 IMEDetailedView(SystemTrayItem* tray, user::LoginStatus login) |
67 : login_(login) { | 67 : TrayDetailsView(tray), |
| 68 login_(login) { |
68 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 69 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
69 IMEInfoList list; | 70 IMEInfoList list; |
70 delegate->GetAvailableIMEList(&list); | 71 delegate->GetAvailableIMEList(&list); |
71 IMEPropertyInfoList property_list; | 72 IMEPropertyInfoList property_list; |
72 delegate->GetCurrentIMEProperties(&property_list); | 73 delegate->GetCurrentIMEProperties(&property_list); |
73 Update(list, property_list); | 74 Update(list, property_list); |
74 } | 75 } |
75 | 76 |
76 virtual ~IMEDetailedView() {} | 77 virtual ~IMEDetailedView() {} |
77 | 78 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 GetLocalizedString(IDS_ASH_STATUS_TRAY_IME_SETTINGS), | 132 GetLocalizedString(IDS_ASH_STATUS_TRAY_IME_SETTINGS), |
132 gfx::Font::NORMAL); | 133 gfx::Font::NORMAL); |
133 AddChildView(container); | 134 AddChildView(container); |
134 settings_ = container; | 135 settings_ = container; |
135 } | 136 } |
136 | 137 |
137 // Overridden from ViewClickListener. | 138 // Overridden from ViewClickListener. |
138 virtual void ClickedOn(views::View* sender) OVERRIDE { | 139 virtual void ClickedOn(views::View* sender) OVERRIDE { |
139 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 140 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
140 if (sender == footer()->content()) { | 141 if (sender == footer()->content()) { |
141 Shell::GetInstance()->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); | 142 tray()->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); |
142 } else if (sender == settings_) { | 143 } else if (sender == settings_) { |
143 delegate->ShowIMESettings(); | 144 delegate->ShowIMESettings(); |
144 } else { | 145 } else { |
145 std::map<views::View*, std::string>::const_iterator ime_find; | 146 std::map<views::View*, std::string>::const_iterator ime_find; |
146 ime_find = ime_map_.find(sender); | 147 ime_find = ime_map_.find(sender); |
147 if (ime_find != ime_map_.end()) { | 148 if (ime_find != ime_map_.end()) { |
148 std::string ime_id = ime_find->second; | 149 std::string ime_id = ime_find->second; |
149 delegate->SwitchIME(ime_id); | 150 delegate->SwitchIME(ime_id); |
150 GetWidget()->Close(); | 151 GetWidget()->Close(); |
151 } else { | 152 } else { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 | 230 |
230 int autoclose_delay_; | 231 int autoclose_delay_; |
231 base::OneShotTimer<IMENotificationView> autoclose_; | 232 base::OneShotTimer<IMENotificationView> autoclose_; |
232 | 233 |
233 DISALLOW_COPY_AND_ASSIGN(IMENotificationView); | 234 DISALLOW_COPY_AND_ASSIGN(IMENotificationView); |
234 }; | 235 }; |
235 | 236 |
236 | 237 |
237 } // namespace tray | 238 } // namespace tray |
238 | 239 |
239 TrayIME::TrayIME() | 240 TrayIME::TrayIME(SystemTray* system_tray) |
240 : tray_label_(NULL), | 241 : SystemTrayItem(system_tray), |
| 242 tray_label_(NULL), |
241 default_(NULL), | 243 default_(NULL), |
242 detailed_(NULL), | 244 detailed_(NULL), |
243 notification_(NULL), | 245 notification_(NULL), |
244 message_shown_(false) { | 246 message_shown_(false) { |
245 } | 247 } |
246 | 248 |
247 TrayIME::~TrayIME() { | 249 TrayIME::~TrayIME() { |
248 } | 250 } |
249 | 251 |
250 void TrayIME::UpdateTrayLabel(const IMEInfo& current, size_t count) { | 252 void TrayIME::UpdateTrayLabel(const IMEInfo& current, size_t count) { |
251 if (tray_label_) { | 253 if (tray_label_) { |
252 if (current.third_party) { | 254 if (current.third_party) { |
253 tray_label_->label()->SetText(current.short_name + UTF8ToUTF16("*")); | 255 tray_label_->label()->SetText(current.short_name + UTF8ToUTF16("*")); |
254 } else { | 256 } else { |
255 tray_label_->label()->SetText(current.short_name); | 257 tray_label_->label()->SetText(current.short_name); |
256 } | 258 } |
257 tray_label_->SetVisible(count > 1); | 259 tray_label_->SetVisible(count > 1); |
258 SetTrayLabelItemBorder(tray_label_, | 260 SetTrayLabelItemBorder(tray_label_, system_tray()->shelf_alignment()); |
259 ash::Shell::GetInstance()->system_tray()->shelf_alignment()); | |
260 tray_label_->Layout(); | 261 tray_label_->Layout(); |
261 } | 262 } |
262 } | 263 } |
263 | 264 |
264 views::View* TrayIME::CreateTrayView(user::LoginStatus status) { | 265 views::View* TrayIME::CreateTrayView(user::LoginStatus status) { |
265 CHECK(tray_label_ == NULL); | 266 CHECK(tray_label_ == NULL); |
266 tray_label_ = new TrayItemView; | 267 tray_label_ = new TrayItemView(this); |
267 tray_label_->CreateLabel(); | 268 tray_label_->CreateLabel(); |
268 SetupLabelForTray(tray_label_->label()); | 269 SetupLabelForTray(tray_label_->label()); |
269 return tray_label_; | 270 return tray_label_; |
270 } | 271 } |
271 | 272 |
272 views::View* TrayIME::CreateDefaultView(user::LoginStatus status) { | 273 views::View* TrayIME::CreateDefaultView(user::LoginStatus status) { |
273 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 274 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
274 IMEInfoList list; | 275 IMEInfoList list; |
275 IMEPropertyInfoList property_list; | 276 IMEPropertyInfoList property_list; |
276 delegate->GetAvailableIMEList(&list); | 277 delegate->GetAvailableIMEList(&list); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 } else if (!Shell::GetPrimaryRootWindowController()->shelf()->IsVisible() || | 343 } else if (!Shell::GetPrimaryRootWindowController()->shelf()->IsVisible() || |
343 !message_shown_) { | 344 !message_shown_) { |
344 ShowNotificationView(); | 345 ShowNotificationView(); |
345 message_shown_ = true; | 346 message_shown_ = true; |
346 } | 347 } |
347 } | 348 } |
348 } | 349 } |
349 | 350 |
350 } // namespace internal | 351 } // namespace internal |
351 } // namespace ash | 352 } // namespace ash |
OLD | NEW |