| 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" | 14 #include "ash/ime/input_method_menu_item.h" |
| 15 #include "ash/ime/input_method_menu_manager.h" | 15 #include "ash/ime/input_method_menu_manager.h" |
| 16 #include "ash/metrics/user_metrics_recorder.h" | 16 #include "ash/metrics/user_metrics_recorder.h" |
| 17 #include "ash/session/session_state_delegate.h" | 17 #include "ash/session/session_state_delegate.h" |
| 18 #include "ash/session/session_state_observer.h" | 18 #include "ash/session/session_state_observer.h" |
| 19 #include "ash/shell.h" | 19 #include "ash/shell.h" |
| 20 #include "ash/shell_delegate.h" | 20 #include "ash/shell_delegate.h" |
| 21 #include "ash/shell_window_ids.h" | 21 #include "ash/shell_window_ids.h" |
| 22 #include "ash/system/bluetooth/bluetooth_observer.h" | 22 #include "ash/system/bluetooth/bluetooth_observer.h" |
| 23 #include "ash/system/chromeos/session/logout_button_observer.h" | 23 #include "ash/system/chromeos/session/logout_button_observer.h" |
| 24 #include "ash/system/date/clock_observer.h" | 24 #include "ash/system/date/clock_observer.h" |
| 25 #include "ash/system/drive/drive_observer.h" | |
| 26 #include "ash/system/ime/ime_observer.h" | 25 #include "ash/system/ime/ime_observer.h" |
| 27 #include "ash/system/tray/system_tray.h" | 26 #include "ash/system/tray/system_tray.h" |
| 28 #include "ash/system/tray/system_tray_delegate.h" | 27 #include "ash/system/tray/system_tray_delegate.h" |
| 29 #include "ash/system/tray/system_tray_notifier.h" | 28 #include "ash/system/tray/system_tray_notifier.h" |
| 30 #include "ash/system/tray_accessibility.h" | 29 #include "ash/system/tray_accessibility.h" |
| 31 #include "ash/system/user/login_status.h" | 30 #include "ash/system/user/login_status.h" |
| 32 #include "ash/system/user/update_observer.h" | 31 #include "ash/system/user/update_observer.h" |
| 33 #include "ash/system/user/user_observer.h" | 32 #include "ash/system/user/user_observer.h" |
| 34 #include "ash/volume_control_delegate.h" | 33 #include "ash/volume_control_delegate.h" |
| 35 #include "ash/wm/lock_state_controller.h" | 34 #include "ash/wm/lock_state_controller.h" |
| 36 #include "base/bind_helpers.h" | 35 #include "base/bind_helpers.h" |
| 37 #include "base/callback.h" | 36 #include "base/callback.h" |
| 38 #include "base/logging.h" | 37 #include "base/logging.h" |
| 39 #include "base/memory/weak_ptr.h" | 38 #include "base/memory/weak_ptr.h" |
| 40 #include "base/prefs/pref_service.h" | 39 #include "base/prefs/pref_service.h" |
| 41 #include "base/strings/stringprintf.h" | 40 #include "base/strings/stringprintf.h" |
| 42 #include "base/strings/utf_string_conversions.h" | 41 #include "base/strings/utf_string_conversions.h" |
| 43 #include "base/sys_info.h" | 42 #include "base/sys_info.h" |
| 44 #include "base/time/time.h" | 43 #include "base/time/time.h" |
| 45 #include "chrome/browser/browser_process.h" | 44 #include "chrome/browser/browser_process.h" |
| 46 #include "chrome/browser/chrome_notification_types.h" | 45 #include "chrome/browser/chrome_notification_types.h" |
| 47 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 46 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 48 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 47 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 49 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h" | 48 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h" |
| 50 #include "chrome/browser/chromeos/charger_replace/charger_replacement_dialog.h" | 49 #include "chrome/browser/chromeos/charger_replace/charger_replacement_dialog.h" |
| 51 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | |
| 52 #include "chrome/browser/chromeos/drive/job_list.h" | |
| 53 #include "chrome/browser/chromeos/enrollment_dialog_view.h" | 50 #include "chrome/browser/chromeos/enrollment_dialog_view.h" |
| 54 #include "chrome/browser/chromeos/events/system_key_event_listener.h" | 51 #include "chrome/browser/chromeos/events/system_key_event_listener.h" |
| 55 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 52 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 56 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" | 53 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" |
| 57 #include "chrome/browser/chromeos/login/help_app_launcher.h" | 54 #include "chrome/browser/chromeos/login/help_app_launcher.h" |
| 58 #include "chrome/browser/chromeos/login/login_wizard.h" | 55 #include "chrome/browser/chromeos/login/login_wizard.h" |
| 59 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 56 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 60 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 57 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 61 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 58 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
| 62 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 59 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
| 63 #include "chrome/browser/chromeos/login/users/user_manager.h" | 60 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 64 #include "chrome/browser/chromeos/options/network_config_view.h" | 61 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 65 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 62 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 66 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" | 63 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
| 67 #include "chrome/browser/chromeos/profiles/multiprofiles_intro_dialog.h" | 64 #include "chrome/browser/chromeos/profiles/multiprofiles_intro_dialog.h" |
| 68 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 65 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 69 #include "chrome/browser/chromeos/set_time_dialog.h" | 66 #include "chrome/browser/chromeos/set_time_dialog.h" |
| 70 #include "chrome/browser/chromeos/settings/cros_settings.h" | 67 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 71 #include "chrome/browser/chromeos/sim_dialog_delegate.h" | 68 #include "chrome/browser/chromeos/sim_dialog_delegate.h" |
| 72 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" | 69 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" |
| 73 #include "chrome/browser/drive/drive_service_interface.h" | |
| 74 #include "chrome/browser/lifetime/application_lifetime.h" | 70 #include "chrome/browser/lifetime/application_lifetime.h" |
| 75 #include "chrome/browser/profiles/profile_manager.h" | 71 #include "chrome/browser/profiles/profile_manager.h" |
| 76 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 72 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 77 #include "chrome/browser/ui/ash/user_accounts_delegate_chromeos.h" | 73 #include "chrome/browser/ui/ash/user_accounts_delegate_chromeos.h" |
| 78 #include "chrome/browser/ui/ash/volume_controller_chromeos.h" | 74 #include "chrome/browser/ui/ash/volume_controller_chromeos.h" |
| 79 #include "chrome/browser/ui/browser.h" | 75 #include "chrome/browser/ui/browser.h" |
| 80 #include "chrome/browser/ui/browser_finder.h" | 76 #include "chrome/browser/ui/browser_finder.h" |
| 81 #include "chrome/browser/ui/browser_list.h" | 77 #include "chrome/browser/ui/browser_list.h" |
| 82 #include "chrome/browser/ui/chrome_pages.h" | 78 #include "chrome/browser/ui/chrome_pages.h" |
| 83 #include "chrome/browser/ui/host_desktop.h" | 79 #include "chrome/browser/ui/host_desktop.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 109 #include "device/bluetooth/bluetooth_adapter_factory.h" | 105 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 110 #include "device/bluetooth/bluetooth_device.h" | 106 #include "device/bluetooth/bluetooth_device.h" |
| 111 #include "grit/ash_strings.h" | 107 #include "grit/ash_strings.h" |
| 112 #include "grit/generated_resources.h" | 108 #include "grit/generated_resources.h" |
| 113 #include "grit/locale_settings.h" | 109 #include "grit/locale_settings.h" |
| 114 #include "net/base/escape.h" | 110 #include "net/base/escape.h" |
| 115 #include "third_party/cros_system_api/dbus/service_constants.h" | 111 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 116 #include "ui/base/l10n/l10n_util.h" | 112 #include "ui/base/l10n/l10n_util.h" |
| 117 #include "ui/base/l10n/time_format.h" | 113 #include "ui/base/l10n/time_format.h" |
| 118 | 114 |
| 119 using drive::DriveIntegrationService; | |
| 120 using drive::DriveIntegrationServiceFactory; | |
| 121 | |
| 122 namespace chromeos { | 115 namespace chromeos { |
| 123 | 116 |
| 124 namespace { | 117 namespace { |
| 125 | 118 |
| 126 // The minimum session length limit that can be set. | 119 // The minimum session length limit that can be set. |
| 127 const int kSessionLengthLimitMinMs = 30 * 1000; // 30 seconds. | 120 const int kSessionLengthLimitMinMs = 30 * 1000; // 30 seconds. |
| 128 | 121 |
| 129 // The maximum session length limit that can be set. | 122 // The maximum session length limit that can be set. |
| 130 const int kSessionLengthLimitMaxMs = 24 * 60 * 60 * 1000; // 24 hours. | 123 const int kSessionLengthLimitMaxMs = 24 * 60 * 60 * 1000; // 24 hours. |
| 131 | 124 |
| 132 const char kDisplaySettingsSubPageName[] = "display"; | 125 const char kDisplaySettingsSubPageName[] = "display"; |
| 133 const char kDisplayOverscanSettingsSubPageName[] = "displayOverscan"; | 126 const char kDisplayOverscanSettingsSubPageName[] = "displayOverscan"; |
| 134 | 127 |
| 135 // The URL for the Google Drive settings page. | |
| 136 const char kDriveSettingsPageURL[] = "https://drive.google.com"; | |
| 137 | |
| 138 void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime, | 128 void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime, |
| 139 const input_method::InputMethodUtil& util, | 129 const input_method::InputMethodUtil& util, |
| 140 ash::IMEInfo* info) { | 130 ash::IMEInfo* info) { |
| 141 info->id = ime.id(); | 131 info->id = ime.id(); |
| 142 info->name = util.GetInputMethodLongName(ime); | 132 info->name = util.GetInputMethodLongName(ime); |
| 143 info->medium_name = util.GetInputMethodMediumName(ime); | 133 info->medium_name = util.GetInputMethodMediumName(ime); |
| 144 info->short_name = util.GetInputMethodShortName(ime); | 134 info->short_name = util.GetInputMethodShortName(ime); |
| 145 info->third_party = extension_ime_util::IsExtensionIME(ime.id()); | 135 info->third_party = extension_ime_util::IsExtensionIME(ime.id()); |
| 146 } | 136 } |
| 147 | 137 |
| 148 gfx::NativeWindow GetNativeWindowByStatus(ash::user::LoginStatus login_status, | 138 gfx::NativeWindow GetNativeWindowByStatus(ash::user::LoginStatus login_status, |
| 149 bool session_started) { | 139 bool session_started) { |
| 150 int container_id = | 140 int container_id = |
| 151 (!session_started || login_status == ash::user::LOGGED_IN_NONE || | 141 (!session_started || login_status == ash::user::LOGGED_IN_NONE || |
| 152 login_status == ash::user::LOGGED_IN_LOCKED) | 142 login_status == ash::user::LOGGED_IN_LOCKED) |
| 153 ? ash::kShellWindowId_LockSystemModalContainer | 143 ? ash::kShellWindowId_LockSystemModalContainer |
| 154 : ash::kShellWindowId_SystemModalContainer; | 144 : ash::kShellWindowId_SystemModalContainer; |
| 155 return ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(), | 145 return ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(), |
| 156 container_id); | 146 container_id); |
| 157 } | 147 } |
| 158 | 148 |
| 159 // Converts drive::JobInfo to ash::DriveOperationStatus. | |
| 160 // If the job is not of type that ash tray is interested, returns false. | |
| 161 bool ConvertToDriveOperationStatus(const drive::JobInfo& info, | |
| 162 ash::DriveOperationStatus* status) { | |
| 163 if (info.job_type == drive::TYPE_DOWNLOAD_FILE) { | |
| 164 status->type = ash::DriveOperationStatus::OPERATION_DOWNLOAD; | |
| 165 } else if (info.job_type == drive::TYPE_UPLOAD_NEW_FILE || | |
| 166 info.job_type == drive::TYPE_UPLOAD_EXISTING_FILE) { | |
| 167 status->type = ash::DriveOperationStatus::OPERATION_UPLOAD; | |
| 168 } else { | |
| 169 return false; | |
| 170 } | |
| 171 | |
| 172 if (info.state == drive::STATE_NONE) | |
| 173 status->state = ash::DriveOperationStatus::OPERATION_NOT_STARTED; | |
| 174 else | |
| 175 status->state = ash::DriveOperationStatus::OPERATION_IN_PROGRESS; | |
| 176 | |
| 177 status->id = info.job_id; | |
| 178 status->file_path = info.file_path; | |
| 179 status->progress = info.num_total_bytes == 0 ? 0.0 : | |
| 180 static_cast<double>(info.num_completed_bytes) / | |
| 181 static_cast<double>(info.num_total_bytes); | |
| 182 return true; | |
| 183 } | |
| 184 | |
| 185 // Converts drive::JobInfo that has finished in |error| state | |
| 186 // to ash::DriveOperationStatus. | |
| 187 // If the job is not of type that ash tray is interested, returns false. | |
| 188 bool ConvertToFinishedDriveOperationStatus(const drive::JobInfo& info, | |
| 189 drive::FileError error, | |
| 190 ash::DriveOperationStatus* status) { | |
| 191 if (!ConvertToDriveOperationStatus(info, status)) | |
| 192 return false; | |
| 193 status->state = (error == drive::FILE_ERROR_OK) | |
| 194 ? ash::DriveOperationStatus::OPERATION_COMPLETED | |
| 195 : ash::DriveOperationStatus::OPERATION_FAILED; | |
| 196 return true; | |
| 197 } | |
| 198 | |
| 199 // Converts a list of drive::JobInfo to a list of ash::DriveOperationStatusList. | |
| 200 ash::DriveOperationStatusList ConvertToDriveStatusList( | |
| 201 const std::vector<drive::JobInfo>& list) { | |
| 202 ash::DriveOperationStatusList results; | |
| 203 for (size_t i = 0; i < list.size(); ++i) { | |
| 204 ash::DriveOperationStatus status; | |
| 205 if (ConvertToDriveOperationStatus(list[i], &status)) | |
| 206 results.push_back(status); | |
| 207 } | |
| 208 return results; | |
| 209 } | |
| 210 | |
| 211 void BluetoothPowerFailure() { | 149 void BluetoothPowerFailure() { |
| 212 // TODO(sad): Show an error bubble? | 150 // TODO(sad): Show an error bubble? |
| 213 } | 151 } |
| 214 | 152 |
| 215 void BluetoothSetDiscoveringError() { | 153 void BluetoothSetDiscoveringError() { |
| 216 LOG(ERROR) << "BluetoothSetDiscovering failed."; | 154 LOG(ERROR) << "BluetoothSetDiscovering failed."; |
| 217 } | 155 } |
| 218 | 156 |
| 219 void BluetoothDeviceConnectError( | 157 void BluetoothDeviceConnectError( |
| 220 device::BluetoothDevice::ConnectErrorCode error_code) { | 158 device::BluetoothDevice::ConnectErrorCode error_code) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 ->session_state_delegate() | 297 ->session_state_delegate() |
| 360 ->RemoveSessionStateObserver(this); | 298 ->RemoveSessionStateObserver(this); |
| 361 LoginState::Get()->RemoveObserver(this); | 299 LoginState::Get()->RemoveObserver(this); |
| 362 | 300 |
| 363 if (CrasAudioHandler::IsInitialized()) | 301 if (CrasAudioHandler::IsInitialized()) |
| 364 CrasAudioHandler::Get()->RemoveAudioObserver(this); | 302 CrasAudioHandler::Get()->RemoveAudioObserver(this); |
| 365 | 303 |
| 366 BrowserList::RemoveObserver(this); | 304 BrowserList::RemoveObserver(this); |
| 367 StopObservingAppWindowRegistry(); | 305 StopObservingAppWindowRegistry(); |
| 368 | 306 |
| 369 // Stop observing Drive operations. | |
| 370 UnobserveDriveUpdates(); | |
| 371 | |
| 372 policy::BrowserPolicyConnectorChromeOS* connector = | 307 policy::BrowserPolicyConnectorChromeOS* connector = |
| 373 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 308 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 374 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = | 309 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = |
| 375 connector->GetDeviceCloudPolicyManager(); | 310 connector->GetDeviceCloudPolicyManager(); |
| 376 if (policy_manager) | 311 if (policy_manager) |
| 377 policy_manager->core()->store()->RemoveObserver(this); | 312 policy_manager->core()->store()->RemoveObserver(this); |
| 378 } | 313 } |
| 379 | 314 |
| 380 // Overridden from ash::SystemTrayDelegate: | 315 // Overridden from ash::SystemTrayDelegate: |
| 381 bool SystemTrayDelegateChromeOS::GetTrayVisibilityOnStartup() { | 316 bool SystemTrayDelegateChromeOS::GetTrayVisibilityOnStartup() { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 | 459 |
| 525 GURL visible_url = active_contents->GetLastCommittedURL(); | 460 GURL visible_url = active_contents->GetLastCommittedURL(); |
| 526 GURL display_settings_url = | 461 GURL display_settings_url = |
| 527 chrome::GetSettingsUrl(kDisplaySettingsSubPageName); | 462 chrome::GetSettingsUrl(kDisplaySettingsSubPageName); |
| 528 GURL display_overscan_url = | 463 GURL display_overscan_url = |
| 529 chrome::GetSettingsUrl(kDisplayOverscanSettingsSubPageName); | 464 chrome::GetSettingsUrl(kDisplayOverscanSettingsSubPageName); |
| 530 return (visible_url != display_settings_url && | 465 return (visible_url != display_settings_url && |
| 531 visible_url != display_overscan_url); | 466 visible_url != display_overscan_url); |
| 532 } | 467 } |
| 533 | 468 |
| 534 void SystemTrayDelegateChromeOS::ShowDriveSettings() { | |
| 535 // TODO(tengs): Open the drive-specific settings page once we put it in. | |
| 536 // For now just show Google Drive main page. | |
| 537 chrome::ScopedTabbedBrowserDisplayer displayer( | |
| 538 ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH); | |
| 539 chrome::ShowSingletonTabOverwritingNTP( | |
| 540 displayer.browser(), | |
| 541 chrome::GetSingletonTabNavigateParams(displayer.browser(), | |
| 542 GURL(kDriveSettingsPageURL))); | |
| 543 } | |
| 544 | |
| 545 void SystemTrayDelegateChromeOS::ShowIMESettings() { | 469 void SystemTrayDelegateChromeOS::ShowIMESettings() { |
| 546 content::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog")); | 470 content::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog")); |
| 547 ShowSettingsSubPageForActiveUser(chrome::kLanguageOptionsSubPage); | 471 ShowSettingsSubPageForActiveUser(chrome::kLanguageOptionsSubPage); |
| 548 } | 472 } |
| 549 | 473 |
| 550 void SystemTrayDelegateChromeOS::ShowHelp() { | 474 void SystemTrayDelegateChromeOS::ShowHelp() { |
| 551 chrome::ShowHelpForProfile(ProfileManager::GetActiveUserProfile(), | 475 chrome::ShowHelpForProfile(ProfileManager::GetActiveUserProfile(), |
| 552 chrome::HOST_DESKTOP_TYPE_ASH, | 476 chrome::HOST_DESKTOP_TYPE_ASH, |
| 553 chrome::HELP_SOURCE_MENU); | 477 chrome::HELP_SOURCE_MENU); |
| 554 } | 478 } |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 } | 706 } |
| 783 | 707 |
| 784 void SystemTrayDelegateChromeOS::SwitchIME(const std::string& ime_id) { | 708 void SystemTrayDelegateChromeOS::SwitchIME(const std::string& ime_id) { |
| 785 input_method::InputMethodManager::Get()->ChangeInputMethod(ime_id); | 709 input_method::InputMethodManager::Get()->ChangeInputMethod(ime_id); |
| 786 } | 710 } |
| 787 | 711 |
| 788 void SystemTrayDelegateChromeOS::ActivateIMEProperty(const std::string& key) { | 712 void SystemTrayDelegateChromeOS::ActivateIMEProperty(const std::string& key) { |
| 789 input_method::InputMethodManager::Get()->ActivateInputMethodMenuItem(key); | 713 input_method::InputMethodManager::Get()->ActivateInputMethodMenuItem(key); |
| 790 } | 714 } |
| 791 | 715 |
| 792 void SystemTrayDelegateChromeOS::CancelDriveOperation(int32 operation_id) { | |
| 793 DriveIntegrationService* integration_service = FindDriveIntegrationService(); | |
| 794 if (!integration_service) | |
| 795 return; | |
| 796 | |
| 797 integration_service->job_list()->CancelJob(operation_id); | |
| 798 } | |
| 799 | |
| 800 void SystemTrayDelegateChromeOS::GetDriveOperationStatusList( | |
| 801 ash::DriveOperationStatusList* list) { | |
| 802 DriveIntegrationService* integration_service = FindDriveIntegrationService(); | |
| 803 if (!integration_service) | |
| 804 return; | |
| 805 | |
| 806 *list = ConvertToDriveStatusList( | |
| 807 integration_service->job_list()->GetJobInfoList()); | |
| 808 } | |
| 809 | |
| 810 void SystemTrayDelegateChromeOS::ShowNetworkConfigure( | 716 void SystemTrayDelegateChromeOS::ShowNetworkConfigure( |
| 811 const std::string& network_id, | 717 const std::string& network_id, |
| 812 gfx::NativeWindow parent_window) { | 718 gfx::NativeWindow parent_window) { |
| 813 NetworkConfigView::Show(network_id, parent_window); | 719 NetworkConfigView::Show(network_id, parent_window); |
| 814 } | 720 } |
| 815 | 721 |
| 816 bool SystemTrayDelegateChromeOS::EnrollNetwork( | 722 bool SystemTrayDelegateChromeOS::EnrollNetwork( |
| 817 const std::string& network_id, | 723 const std::string& network_id, |
| 818 gfx::NativeWindow parent_window) { | 724 gfx::NativeWindow parent_window) { |
| 819 return enrollment::CreateDialog(network_id, parent_window); | 725 return enrollment::CreateDialog(network_id, parent_window); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 | 828 |
| 923 ash::SystemTray* SystemTrayDelegateChromeOS::GetPrimarySystemTray() { | 829 ash::SystemTray* SystemTrayDelegateChromeOS::GetPrimarySystemTray() { |
| 924 return ash::Shell::GetInstance()->GetPrimarySystemTray(); | 830 return ash::Shell::GetInstance()->GetPrimarySystemTray(); |
| 925 } | 831 } |
| 926 | 832 |
| 927 ash::SystemTrayNotifier* SystemTrayDelegateChromeOS::GetSystemTrayNotifier() { | 833 ash::SystemTrayNotifier* SystemTrayDelegateChromeOS::GetSystemTrayNotifier() { |
| 928 return ash::Shell::GetInstance()->system_tray_notifier(); | 834 return ash::Shell::GetInstance()->system_tray_notifier(); |
| 929 } | 835 } |
| 930 | 836 |
| 931 void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) { | 837 void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) { |
| 932 // Stop observing the Drive integration status and the AppWindowRegistry of | 838 // Stop observing the AppWindowRegistry of the current |user_profile_|. |
| 933 // the current |user_profile_|. | |
| 934 UnobserveDriveUpdates(); | |
| 935 StopObservingAppWindowRegistry(); | 839 StopObservingAppWindowRegistry(); |
| 936 | 840 |
| 937 user_profile_ = profile; | 841 user_profile_ = profile; |
| 938 | 842 |
| 939 // Start observing the Drive integration status and the AppWindowRegistry of | 843 // Start observing the AppWindowRegistry of the newly set |user_profile_|. |
| 940 // the newly set |user_profile_|. | |
| 941 ObserveDriveUpdates(); | |
| 942 apps::AppWindowRegistry::Get(user_profile_)->AddObserver(this); | 844 apps::AppWindowRegistry::Get(user_profile_)->AddObserver(this); |
| 943 | 845 |
| 944 PrefService* prefs = profile->GetPrefs(); | 846 PrefService* prefs = profile->GetPrefs(); |
| 945 user_pref_registrar_.reset(new PrefChangeRegistrar); | 847 user_pref_registrar_.reset(new PrefChangeRegistrar); |
| 946 user_pref_registrar_->Init(prefs); | 848 user_pref_registrar_->Init(prefs); |
| 947 user_pref_registrar_->Add( | 849 user_pref_registrar_->Add( |
| 948 prefs::kUse24HourClock, | 850 prefs::kUse24HourClock, |
| 949 base::Bind(&SystemTrayDelegateChromeOS::UpdateClockType, | 851 base::Bind(&SystemTrayDelegateChromeOS::UpdateClockType, |
| 950 base::Unretained(this))); | 852 base::Unretained(this))); |
| 951 user_pref_registrar_->Add( | 853 user_pref_registrar_->Add( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 } | 891 } |
| 990 | 892 |
| 991 bool SystemTrayDelegateChromeOS::UnsetProfile(Profile* profile) { | 893 bool SystemTrayDelegateChromeOS::UnsetProfile(Profile* profile) { |
| 992 if (profile != user_profile_) | 894 if (profile != user_profile_) |
| 993 return false; | 895 return false; |
| 994 user_pref_registrar_.reset(); | 896 user_pref_registrar_.reset(); |
| 995 user_profile_ = NULL; | 897 user_profile_ = NULL; |
| 996 return true; | 898 return true; |
| 997 } | 899 } |
| 998 | 900 |
| 999 void SystemTrayDelegateChromeOS::ObserveDriveUpdates() { | |
| 1000 DriveIntegrationService* integration_service = FindDriveIntegrationService(); | |
| 1001 if (integration_service) | |
| 1002 integration_service->job_list()->AddObserver(this); | |
| 1003 } | |
| 1004 | |
| 1005 void SystemTrayDelegateChromeOS::UnobserveDriveUpdates() { | |
| 1006 DriveIntegrationService* integration_service = FindDriveIntegrationService(); | |
| 1007 if (integration_service) | |
| 1008 integration_service->job_list()->RemoveObserver(this); | |
| 1009 } | |
| 1010 | |
| 1011 bool SystemTrayDelegateChromeOS::GetShouldUse24HourClockForTesting() const { | 901 bool SystemTrayDelegateChromeOS::GetShouldUse24HourClockForTesting() const { |
| 1012 return ShouldUse24HourClock(); | 902 return ShouldUse24HourClock(); |
| 1013 } | 903 } |
| 1014 | 904 |
| 1015 bool SystemTrayDelegateChromeOS::ShouldUse24HourClock() const { | 905 bool SystemTrayDelegateChromeOS::ShouldUse24HourClock() const { |
| 1016 // On login screen and in guest mode owner default is used for | 906 // On login screen and in guest mode owner default is used for |
| 1017 // kUse24HourClock preference. | 907 // kUse24HourClock preference. |
| 1018 const ash::user::LoginStatus status = GetUserLoginStatus(); | 908 const ash::user::LoginStatus status = GetUserLoginStatus(); |
| 1019 const CrosSettings* const cros_settings = CrosSettings::Get(); | 909 const CrosSettings* const cros_settings = CrosSettings::Get(); |
| 1020 bool system_use_24_hour_clock = true; | 910 bool system_use_24_hour_clock = true; |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 } | 1165 } |
| 1276 | 1166 |
| 1277 void SystemTrayDelegateChromeOS::OnActiveOutputNodeChanged() { | 1167 void SystemTrayDelegateChromeOS::OnActiveOutputNodeChanged() { |
| 1278 GetSystemTrayNotifier()->NotifyAudioActiveOutputNodeChanged(); | 1168 GetSystemTrayNotifier()->NotifyAudioActiveOutputNodeChanged(); |
| 1279 } | 1169 } |
| 1280 | 1170 |
| 1281 void SystemTrayDelegateChromeOS::OnActiveInputNodeChanged() { | 1171 void SystemTrayDelegateChromeOS::OnActiveInputNodeChanged() { |
| 1282 GetSystemTrayNotifier()->NotifyAudioActiveInputNodeChanged(); | 1172 GetSystemTrayNotifier()->NotifyAudioActiveInputNodeChanged(); |
| 1283 } | 1173 } |
| 1284 | 1174 |
| 1285 // drive::JobListObserver overrides. | |
| 1286 void SystemTrayDelegateChromeOS::OnJobAdded(const drive::JobInfo& job_info) { | |
| 1287 OnJobUpdated(job_info); | |
| 1288 } | |
| 1289 | |
| 1290 void SystemTrayDelegateChromeOS::OnJobDone(const drive::JobInfo& job_info, | |
| 1291 drive::FileError error) { | |
| 1292 ash::DriveOperationStatus status; | |
| 1293 if (ConvertToFinishedDriveOperationStatus(job_info, error, &status)) | |
| 1294 GetSystemTrayNotifier()->NotifyDriveJobUpdated(status); | |
| 1295 } | |
| 1296 | |
| 1297 void SystemTrayDelegateChromeOS::OnJobUpdated(const drive::JobInfo& job_info) { | |
| 1298 ash::DriveOperationStatus status; | |
| 1299 if (ConvertToDriveOperationStatus(job_info, &status)) | |
| 1300 GetSystemTrayNotifier()->NotifyDriveJobUpdated(status); | |
| 1301 } | |
| 1302 | |
| 1303 DriveIntegrationService* | |
| 1304 SystemTrayDelegateChromeOS::FindDriveIntegrationService() { | |
| 1305 return user_profile_ | |
| 1306 ? DriveIntegrationServiceFactory::FindForProfile(user_profile_) | |
| 1307 : NULL; | |
| 1308 } | |
| 1309 | |
| 1310 // Overridden from BluetoothAdapter::Observer. | 1175 // Overridden from BluetoothAdapter::Observer. |
| 1311 void SystemTrayDelegateChromeOS::AdapterPresentChanged( | 1176 void SystemTrayDelegateChromeOS::AdapterPresentChanged( |
| 1312 device::BluetoothAdapter* adapter, | 1177 device::BluetoothAdapter* adapter, |
| 1313 bool present) { | 1178 bool present) { |
| 1314 GetSystemTrayNotifier()->NotifyRefreshBluetooth(); | 1179 GetSystemTrayNotifier()->NotifyRefreshBluetooth(); |
| 1315 } | 1180 } |
| 1316 | 1181 |
| 1317 void SystemTrayDelegateChromeOS::AdapterPoweredChanged( | 1182 void SystemTrayDelegateChromeOS::AdapterPoweredChanged( |
| 1318 device::BluetoothAdapter* adapter, | 1183 device::BluetoothAdapter* adapter, |
| 1319 bool powered) { | 1184 bool powered) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1398 accessibility_subscription_.reset(); | 1263 accessibility_subscription_.reset(); |
| 1399 else | 1264 else |
| 1400 OnAccessibilityModeChanged(details.notify); | 1265 OnAccessibilityModeChanged(details.notify); |
| 1401 } | 1266 } |
| 1402 | 1267 |
| 1403 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 1268 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
| 1404 return new SystemTrayDelegateChromeOS(); | 1269 return new SystemTrayDelegateChromeOS(); |
| 1405 } | 1270 } |
| 1406 | 1271 |
| 1407 } // namespace chromeos | 1272 } // namespace chromeos |
| OLD | NEW |