| 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" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 std::map<views::View*, std::string> ime_map_; | 174 std::map<views::View*, std::string> ime_map_; |
| 175 std::map<views::View*, std::string> property_map_; | 175 std::map<views::View*, std::string> property_map_; |
| 176 views::View* header_; | 176 views::View* header_; |
| 177 views::View* settings_; | 177 views::View* settings_; |
| 178 | 178 |
| 179 DISALLOW_COPY_AND_ASSIGN(IMEDetailedView); | 179 DISALLOW_COPY_AND_ASSIGN(IMEDetailedView); |
| 180 }; | 180 }; |
| 181 | 181 |
| 182 } // namespace tray | 182 } // namespace tray |
| 183 | 183 |
| 184 TrayIME::TrayIME() { | 184 TrayIME::TrayIME() |
| 185 : tray_label_(NULL), |
| 186 default_(NULL), |
| 187 detailed_(NULL) { |
| 185 } | 188 } |
| 186 | 189 |
| 187 TrayIME::~TrayIME() { | 190 TrayIME::~TrayIME() { |
| 188 } | 191 } |
| 189 | 192 |
| 190 void TrayIME::UpdateTrayLabel(const IMEInfo& current, size_t count) { | 193 void TrayIME::UpdateTrayLabel(const IMEInfo& current, size_t count) { |
| 191 tray_label_->label()->SetText(current.short_name); | 194 if (tray_label_) { |
| 192 tray_label_->SetVisible(count > 1); | 195 tray_label_->label()->SetText(current.short_name); |
| 196 tray_label_->SetVisible(count > 1); |
| 197 } |
| 193 } | 198 } |
| 194 | 199 |
| 195 views::View* TrayIME::CreateTrayView(user::LoginStatus status) { | 200 views::View* TrayIME::CreateTrayView(user::LoginStatus status) { |
| 196 tray_label_.reset(new TrayItemView); | 201 CHECK(tray_label_ == NULL); |
| 202 tray_label_ = new TrayItemView; |
| 197 tray_label_->CreateLabel(); | 203 tray_label_->CreateLabel(); |
| 198 SetupLabelForTray(tray_label_->label()); | 204 SetupLabelForTray(tray_label_->label()); |
| 199 tray_label_->set_border( | 205 tray_label_->set_border( |
| 200 views::Border::CreateEmptyBorder(0, 2, 0, 2)); | 206 views::Border::CreateEmptyBorder(0, 2, 0, 2)); |
| 201 return tray_label_.get(); | 207 return tray_label_; |
| 202 } | 208 } |
| 203 | 209 |
| 204 views::View* TrayIME::CreateDefaultView(user::LoginStatus status) { | 210 views::View* TrayIME::CreateDefaultView(user::LoginStatus status) { |
| 205 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 211 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
| 206 IMEInfoList list; | 212 IMEInfoList list; |
| 207 IMEPropertyInfoList property_list; | 213 IMEPropertyInfoList property_list; |
| 208 delegate->GetAvailableIMEList(&list); | 214 delegate->GetAvailableIMEList(&list); |
| 209 delegate->GetCurrentIMEProperties(&property_list); | 215 delegate->GetCurrentIMEProperties(&property_list); |
| 210 if (list.size() <= 1 && property_list.size() <= 1) | 216 if (list.size() <= 1 && property_list.size() <= 1) |
| 211 return NULL; | 217 return NULL; |
| 212 default_.reset(new tray::IMEDefaultView(this)); | 218 CHECK(default_ == NULL); |
| 213 return default_.get(); | 219 default_ = new tray::IMEDefaultView(this); |
| 220 return default_; |
| 214 } | 221 } |
| 215 | 222 |
| 216 views::View* TrayIME::CreateDetailedView(user::LoginStatus status) { | 223 views::View* TrayIME::CreateDetailedView(user::LoginStatus status) { |
| 217 detailed_.reset(new tray::IMEDetailedView(this, status)); | 224 CHECK(detailed_ == NULL); |
| 218 return detailed_.get(); | 225 detailed_ = new tray::IMEDetailedView(this, status); |
| 226 return detailed_; |
| 219 } | 227 } |
| 220 | 228 |
| 221 void TrayIME::DestroyTrayView() { | 229 void TrayIME::DestroyTrayView() { |
| 222 tray_label_.reset(); | 230 tray_label_ = NULL; |
| 223 } | 231 } |
| 224 | 232 |
| 225 void TrayIME::DestroyDefaultView() { | 233 void TrayIME::DestroyDefaultView() { |
| 226 default_.reset(); | 234 default_ = NULL; |
| 227 } | 235 } |
| 228 | 236 |
| 229 void TrayIME::DestroyDetailedView() { | 237 void TrayIME::DestroyDetailedView() { |
| 230 detailed_.reset(); | 238 detailed_ = NULL; |
| 231 } | 239 } |
| 232 | 240 |
| 233 void TrayIME::UpdateAfterLoginStatusChange(user::LoginStatus status) { | 241 void TrayIME::UpdateAfterLoginStatusChange(user::LoginStatus status) { |
| 234 } | 242 } |
| 235 | 243 |
| 236 void TrayIME::OnIMERefresh() { | 244 void TrayIME::OnIMERefresh() { |
| 237 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 245 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
| 238 IMEInfoList list; | 246 IMEInfoList list; |
| 239 IMEInfo current; | 247 IMEInfo current; |
| 240 IMEPropertyInfoList property_list; | 248 IMEPropertyInfoList property_list; |
| 241 delegate->GetCurrentIME(¤t); | 249 delegate->GetCurrentIME(¤t); |
| 242 delegate->GetAvailableIMEList(&list); | 250 delegate->GetAvailableIMEList(&list); |
| 243 delegate->GetCurrentIMEProperties(&property_list); | 251 delegate->GetCurrentIMEProperties(&property_list); |
| 244 | 252 |
| 245 UpdateTrayLabel(current, list.size()); | 253 UpdateTrayLabel(current, list.size()); |
| 246 | 254 |
| 247 if (default_.get()) | 255 if (default_) |
| 248 default_->UpdateLabel(current); | 256 default_->UpdateLabel(current); |
| 249 if (detailed_.get()) | 257 if (detailed_) |
| 250 detailed_->Update(list, property_list); | 258 detailed_->Update(list, property_list); |
| 251 } | 259 } |
| 252 | 260 |
| 253 } // namespace internal | 261 } // namespace internal |
| 254 } // namespace ash | 262 } // namespace ash |
| OLD | NEW |