OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" | 5 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "ash/ash_switches.h" | 12 #include "ash/ash_switches.h" |
13 #include "ash/desktop_background/desktop_background_controller.h" | 13 #include "ash/desktop_background/desktop_background_controller.h" |
| 14 #include "ash/ime/input_method_menu_item.h" |
| 15 #include "ash/ime/input_method_menu_manager.h" |
14 #include "ash/metrics/user_metrics_recorder.h" | 16 #include "ash/metrics/user_metrics_recorder.h" |
15 #include "ash/session_state_delegate.h" | 17 #include "ash/session_state_delegate.h" |
16 #include "ash/session_state_observer.h" | 18 #include "ash/session_state_observer.h" |
17 #include "ash/shell.h" | 19 #include "ash/shell.h" |
18 #include "ash/shell_delegate.h" | 20 #include "ash/shell_delegate.h" |
19 #include "ash/shell_window_ids.h" | 21 #include "ash/shell_window_ids.h" |
20 #include "ash/system/bluetooth/bluetooth_observer.h" | 22 #include "ash/system/bluetooth/bluetooth_observer.h" |
21 #include "ash/system/date/clock_observer.h" | 23 #include "ash/system/date/clock_observer.h" |
22 #include "ash/system/drive/drive_observer.h" | 24 #include "ash/system/drive/drive_observer.h" |
23 #include "ash/system/ime/ime_observer.h" | 25 #include "ash/system/ime/ime_observer.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 registrar_->Add( | 292 registrar_->Add( |
291 this, | 293 this, |
292 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD, | 294 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD, |
293 content::NotificationService::AllSources()); | 295 content::NotificationService::AllSources()); |
294 } | 296 } |
295 | 297 |
296 void SystemTrayDelegateChromeOS::Initialize() { | 298 void SystemTrayDelegateChromeOS::Initialize() { |
297 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); | 299 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); |
298 | 300 |
299 input_method::InputMethodManager::Get()->AddObserver(this); | 301 input_method::InputMethodManager::Get()->AddObserver(this); |
| 302 ash::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); |
300 UpdateClockType(); | 303 UpdateClockType(); |
301 | 304 |
302 if (SystemKeyEventListener::GetInstance()) | 305 if (SystemKeyEventListener::GetInstance()) |
303 SystemKeyEventListener::GetInstance()->AddCapsLockObserver(this); | 306 SystemKeyEventListener::GetInstance()->AddCapsLockObserver(this); |
304 | 307 |
305 device::BluetoothAdapterFactory::GetAdapter( | 308 device::BluetoothAdapterFactory::GetAdapter( |
306 base::Bind(&SystemTrayDelegateChromeOS::InitializeOnAdapterReady, | 309 base::Bind(&SystemTrayDelegateChromeOS::InitializeOnAdapterReady, |
307 weak_ptr_factory_.GetWeakPtr())); | 310 weak_ptr_factory_.GetWeakPtr())); |
308 | 311 |
309 ash::Shell::GetInstance()->session_state_delegate()->AddSessionStateObserver( | 312 ash::Shell::GetInstance()->session_state_delegate()->AddSessionStateObserver( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() { | 353 SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() { |
351 // Unregister PrefChangeRegistrars. | 354 // Unregister PrefChangeRegistrars. |
352 local_state_registrar_.reset(); | 355 local_state_registrar_.reset(); |
353 user_pref_registrar_.reset(); | 356 user_pref_registrar_.reset(); |
354 | 357 |
355 // Unregister content notifications befure destroying any components. | 358 // Unregister content notifications befure destroying any components. |
356 registrar_.reset(); | 359 registrar_.reset(); |
357 | 360 |
358 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); | 361 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); |
359 input_method::InputMethodManager::Get()->RemoveObserver(this); | 362 input_method::InputMethodManager::Get()->RemoveObserver(this); |
| 363 ash::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this); |
360 if (SystemKeyEventListener::GetInstance()) | 364 if (SystemKeyEventListener::GetInstance()) |
361 SystemKeyEventListener::GetInstance()->RemoveCapsLockObserver(this); | 365 SystemKeyEventListener::GetInstance()->RemoveCapsLockObserver(this); |
362 bluetooth_adapter_->RemoveObserver(this); | 366 bluetooth_adapter_->RemoveObserver(this); |
363 ash::Shell::GetInstance() | 367 ash::Shell::GetInstance() |
364 ->session_state_delegate() | 368 ->session_state_delegate() |
365 ->RemoveSessionStateObserver(this); | 369 ->RemoveSessionStateObserver(this); |
366 LoginState::Get()->RemoveObserver(this); | 370 LoginState::Get()->RemoveObserver(this); |
367 | 371 |
368 // Stop observing Drive operations. | 372 // Stop observing Drive operations. |
369 UnobserveDriveUpdates(); | 373 UnobserveDriveUpdates(); |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 input_method::InputMethodDescriptor& ime = ime_descriptors->at(i); | 763 input_method::InputMethodDescriptor& ime = ime_descriptors->at(i); |
760 ash::IMEInfo info; | 764 ash::IMEInfo info; |
761 ExtractIMEInfo(ime, *util, &info); | 765 ExtractIMEInfo(ime, *util, &info); |
762 info.selected = ime.id() == current; | 766 info.selected = ime.id() == current; |
763 list->push_back(info); | 767 list->push_back(info); |
764 } | 768 } |
765 } | 769 } |
766 | 770 |
767 void SystemTrayDelegateChromeOS::GetCurrentIMEProperties( | 771 void SystemTrayDelegateChromeOS::GetCurrentIMEProperties( |
768 ash::IMEPropertyInfoList* list) { | 772 ash::IMEPropertyInfoList* list) { |
769 input_method::InputMethodManager* manager = | 773 ash::ime::InputMethodMenuItemList menu_list = |
770 input_method::InputMethodManager::Get(); | 774 ash::ime::InputMethodMenuManager::GetInstance()-> |
771 input_method::InputMethodPropertyList properties = | 775 GetCurrentInputMethodMenuItemList(); |
772 manager->GetCurrentInputMethodProperties(); | 776 for (size_t i = 0; i < menu_list.size(); ++i) { |
773 for (size_t i = 0; i < properties.size(); ++i) { | |
774 ash::IMEPropertyInfo property; | 777 ash::IMEPropertyInfo property; |
775 property.key = properties[i].key; | 778 property.key = menu_list[i].key; |
776 property.name = base::UTF8ToUTF16(properties[i].label); | 779 property.name = base::UTF8ToUTF16(menu_list[i].label); |
777 property.selected = properties[i].is_selection_item_checked; | 780 property.selected = menu_list[i].is_selection_item_checked; |
778 list->push_back(property); | 781 list->push_back(property); |
779 } | 782 } |
780 } | 783 } |
781 | 784 |
782 void SystemTrayDelegateChromeOS::SwitchIME(const std::string& ime_id) { | 785 void SystemTrayDelegateChromeOS::SwitchIME(const std::string& ime_id) { |
783 input_method::InputMethodManager::Get()->ChangeInputMethod(ime_id); | 786 input_method::InputMethodManager::Get()->ChangeInputMethod(ime_id); |
784 } | 787 } |
785 | 788 |
786 void SystemTrayDelegateChromeOS::ActivateIMEProperty(const std::string& key) { | 789 void SystemTrayDelegateChromeOS::ActivateIMEProperty(const std::string& key) { |
787 input_method::InputMethodManager::Get()->ActivateInputMethodProperty(key); | 790 input_method::InputMethodManager::Get()->ActivateInputMethodMenuItem(key); |
788 } | 791 } |
789 | 792 |
790 void SystemTrayDelegateChromeOS::CancelDriveOperation(int32 operation_id) { | 793 void SystemTrayDelegateChromeOS::CancelDriveOperation(int32 operation_id) { |
791 DriveIntegrationService* integration_service = FindDriveIntegrationService(); | 794 DriveIntegrationService* integration_service = FindDriveIntegrationService(); |
792 if (!integration_service) | 795 if (!integration_service) |
793 return; | 796 return; |
794 | 797 |
795 integration_service->job_list()->CancelJob(operation_id); | 798 integration_service->job_list()->CancelJob(operation_id); |
796 } | 799 } |
797 | 800 |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 // |show_message| in ash means the message_center notifications | 1197 // |show_message| in ash means the message_center notifications |
1195 // which should not be shown unless kDisableIMEModeIndicator is | 1198 // which should not be shown unless kDisableIMEModeIndicator is |
1196 // on, since the mode indicator already notifies the user. | 1199 // on, since the mode indicator already notifies the user. |
1197 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 1200 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
1198 switches::kDisableIMEModeIndicator)) { | 1201 switches::kDisableIMEModeIndicator)) { |
1199 show_message = false; | 1202 show_message = false; |
1200 } | 1203 } |
1201 GetSystemTrayNotifier()->NotifyRefreshIME(show_message); | 1204 GetSystemTrayNotifier()->NotifyRefreshIME(show_message); |
1202 } | 1205 } |
1203 | 1206 |
1204 void SystemTrayDelegateChromeOS::InputMethodPropertyChanged( | 1207 // Overridden from InputMethodMenuManager::Observer. |
1205 input_method::InputMethodManager* manager) { | 1208 void SystemTrayDelegateChromeOS::InputMethodMenuItemChanged( |
| 1209 ash::ime::InputMethodMenuManager* manager) { |
1206 GetSystemTrayNotifier()->NotifyRefreshIME(false); | 1210 GetSystemTrayNotifier()->NotifyRefreshIME(false); |
1207 } | 1211 } |
1208 | 1212 |
1209 // drive::JobListObserver overrides. | 1213 // drive::JobListObserver overrides. |
1210 void SystemTrayDelegateChromeOS::OnJobAdded(const drive::JobInfo& job_info) { | 1214 void SystemTrayDelegateChromeOS::OnJobAdded(const drive::JobInfo& job_info) { |
1211 OnJobUpdated(job_info); | 1215 OnJobUpdated(job_info); |
1212 } | 1216 } |
1213 | 1217 |
1214 void SystemTrayDelegateChromeOS::OnJobDone(const drive::JobInfo& job_info, | 1218 void SystemTrayDelegateChromeOS::OnJobDone(const drive::JobInfo& job_info, |
1215 drive::FileError error) { | 1219 drive::FileError error) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1301 void SystemTrayDelegateChromeOS::UserAddedToSession( | 1305 void SystemTrayDelegateChromeOS::UserAddedToSession( |
1302 const std::string& user_id) { | 1306 const std::string& user_id) { |
1303 GetSystemTrayNotifier()->NotifyUserAddedToSession(); | 1307 GetSystemTrayNotifier()->NotifyUserAddedToSession(); |
1304 } | 1308 } |
1305 | 1309 |
1306 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 1310 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
1307 return new SystemTrayDelegateChromeOS(); | 1311 return new SystemTrayDelegateChromeOS(); |
1308 } | 1312 } |
1309 | 1313 |
1310 } // namespace chromeos | 1314 } // namespace chromeos |
OLD | NEW |