| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <utility> | 13 #include <utility> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "ash/common/login_status.h" | 16 #include "ash/common/login_status.h" |
| 17 #include "ash/common/shell_delegate.h" | 17 #include "ash/common/shell_delegate.h" |
| 18 #include "ash/common/system/chromeos/bluetooth/bluetooth_observer.h" | |
| 19 #include "ash/common/system/chromeos/power/power_status.h" | 18 #include "ash/common/system/chromeos/power/power_status.h" |
| 20 #include "ash/common/system/chromeos/session/logout_button_observer.h" | 19 #include "ash/common/system/chromeos/session/logout_button_observer.h" |
| 21 #include "ash/common/system/date/clock_observer.h" | 20 #include "ash/common/system/date/clock_observer.h" |
| 22 #include "ash/common/system/ime/ime_observer.h" | 21 #include "ash/common/system/ime/ime_observer.h" |
| 23 #include "ash/common/system/tray/system_tray_notifier.h" | 22 #include "ash/common/system/tray/system_tray_notifier.h" |
| 24 #include "ash/common/system/tray_accessibility.h" | 23 #include "ash/common/system/tray_accessibility.h" |
| 25 #include "ash/common/system/user/user_observer.h" | 24 #include "ash/common/system/user/user_observer.h" |
| 26 #include "ash/common/wm_shell.h" | 25 #include "ash/common/wm_shell.h" |
| 27 #include "ash/shell.h" | 26 #include "ash/shell.h" |
| 28 #include "ash/system/chromeos/rotation/tray_rotation_lock.h" | 27 #include "ash/system/chromeos/rotation/tray_rotation_lock.h" |
| 29 #include "base/bind_helpers.h" | |
| 30 #include "base/callback.h" | 28 #include "base/callback.h" |
| 31 #include "base/logging.h" | 29 #include "base/logging.h" |
| 32 #include "base/memory/ptr_util.h" | 30 #include "base/memory/ptr_util.h" |
| 33 #include "base/memory/weak_ptr.h" | |
| 34 #include "base/metrics/user_metrics.h" | 31 #include "base/metrics/user_metrics.h" |
| 35 #include "base/strings/utf_string_conversions.h" | 32 #include "base/strings/utf_string_conversions.h" |
| 36 #include "base/sys_info.h" | 33 #include "base/sys_info.h" |
| 37 #include "base/time/time.h" | 34 #include "base/time/time.h" |
| 38 #include "chrome/browser/browser_process.h" | 35 #include "chrome/browser/browser_process.h" |
| 39 #include "chrome/browser/chrome_notification_types.h" | 36 #include "chrome/browser/chrome_notification_types.h" |
| 40 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 37 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 41 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h" | |
| 42 #include "chrome/browser/chromeos/events/system_key_event_listener.h" | 38 #include "chrome/browser/chromeos/events/system_key_event_listener.h" |
| 43 #include "chrome/browser/chromeos/input_method/input_method_switch_recorder.h" | 39 #include "chrome/browser/chromeos/input_method/input_method_switch_recorder.h" |
| 44 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 40 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 45 #include "chrome/browser/chromeos/login/help_app_launcher.h" | 41 #include "chrome/browser/chromeos/login/help_app_launcher.h" |
| 46 #include "chrome/browser/chromeos/login/login_wizard.h" | 42 #include "chrome/browser/chromeos/login/login_wizard.h" |
| 47 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 43 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
| 48 #include "chrome/browser/chromeos/login/user_flow.h" | 44 #include "chrome/browser/chromeos/login/user_flow.h" |
| 49 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 45 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
| 50 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 46 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
| 51 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 47 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 52 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" | 48 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
| 53 #include "chrome/browser/chromeos/profiles/multiprofiles_intro_dialog.h" | 49 #include "chrome/browser/chromeos/profiles/multiprofiles_intro_dialog.h" |
| 54 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 50 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 55 #include "chrome/browser/profiles/profile_manager.h" | 51 #include "chrome/browser/profiles/profile_manager.h" |
| 56 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 52 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 57 #include "chrome/browser/ui/ash/networking_config_delegate_chromeos.h" | 53 #include "chrome/browser/ui/ash/networking_config_delegate_chromeos.h" |
| 58 #include "chrome/browser/ui/ash/system_tray_client.h" | 54 #include "chrome/browser/ui/ash/system_tray_client.h" |
| 55 #include "chrome/browser/ui/ash/tray_bluetooth_helper.h" |
| 59 #include "chrome/browser/ui/browser.h" | 56 #include "chrome/browser/ui/browser.h" |
| 60 #include "chrome/browser/ui/browser_list.h" | 57 #include "chrome/browser/ui/browser_list.h" |
| 61 #include "chrome/browser/ui/chrome_pages.h" | 58 #include "chrome/browser/ui/chrome_pages.h" |
| 62 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 59 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 63 #include "chrome/browser/ui/singleton_tabs.h" | 60 #include "chrome/browser/ui/singleton_tabs.h" |
| 64 #include "chrome/common/chrome_switches.h" | 61 #include "chrome/common/chrome_switches.h" |
| 65 #include "chrome/common/features.h" | 62 #include "chrome/common/features.h" |
| 66 #include "chrome/common/pref_names.h" | 63 #include "chrome/common/pref_names.h" |
| 67 #include "chrome/common/url_constants.h" | 64 #include "chrome/common/url_constants.h" |
| 68 #include "chrome/grit/generated_resources.h" | 65 #include "chrome/grit/generated_resources.h" |
| 69 #include "chrome/grit/locale_settings.h" | 66 #include "chrome/grit/locale_settings.h" |
| 70 #include "chromeos/dbus/dbus_thread_manager.h" | 67 #include "chromeos/dbus/dbus_thread_manager.h" |
| 71 #include "chromeos/dbus/session_manager_client.h" | 68 #include "chromeos/dbus/session_manager_client.h" |
| 72 #include "chromeos/login/login_state.h" | 69 #include "chromeos/login/login_state.h" |
| 73 #include "chromeos/network/portal_detector/network_portal_detector.h" | 70 #include "chromeos/network/portal_detector/network_portal_detector.h" |
| 74 #include "components/google/core/browser/google_util.h" | 71 #include "components/google/core/browser/google_util.h" |
| 75 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 72 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| 76 #include "components/prefs/pref_service.h" | 73 #include "components/prefs/pref_service.h" |
| 77 #include "components/session_manager/core/session_manager.h" | 74 #include "components/session_manager/core/session_manager.h" |
| 78 #include "components/user_manager/user.h" | 75 #include "components/user_manager/user.h" |
| 79 #include "components/user_manager/user_manager.h" | 76 #include "components/user_manager/user_manager.h" |
| 80 #include "components/user_manager/user_type.h" | 77 #include "components/user_manager/user_type.h" |
| 81 #include "content/public/browser/notification_observer.h" | 78 #include "content/public/browser/notification_observer.h" |
| 82 #include "content/public/browser/notification_service.h" | 79 #include "content/public/browser/notification_service.h" |
| 83 #include "content/public/browser/user_metrics.h" | 80 #include "content/public/browser/user_metrics.h" |
| 84 #include "device/bluetooth/bluetooth_adapter.h" | |
| 85 #include "device/bluetooth/bluetooth_adapter_factory.h" | |
| 86 #include "device/bluetooth/bluetooth_device.h" | |
| 87 #include "ui/base/ime/chromeos/extension_ime_util.h" | 81 #include "ui/base/ime/chromeos/extension_ime_util.h" |
| 88 #include "ui/base/ime/chromeos/input_method_manager.h" | 82 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 89 #include "ui/base/l10n/l10n_util.h" | 83 #include "ui/base/l10n/l10n_util.h" |
| 90 #include "ui/base/l10n/time_format.h" | 84 #include "ui/base/l10n/time_format.h" |
| 91 #include "ui/chromeos/events/pref_names.h" | 85 #include "ui/chromeos/events/pref_names.h" |
| 92 #include "ui/chromeos/ime/input_method_menu_item.h" | 86 #include "ui/chromeos/ime/input_method_menu_item.h" |
| 93 #include "ui/chromeos/ime/input_method_menu_manager.h" | 87 #include "ui/chromeos/ime/input_method_menu_manager.h" |
| 94 | 88 |
| 95 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) | 89 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
| 96 #include "chrome/browser/supervised_user/supervised_user_service.h" | 90 #include "chrome/browser/supervised_user/supervised_user_service.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 110 void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime, | 104 void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime, |
| 111 const input_method::InputMethodUtil& util, | 105 const input_method::InputMethodUtil& util, |
| 112 ash::IMEInfo* info) { | 106 ash::IMEInfo* info) { |
| 113 info->id = ime.id(); | 107 info->id = ime.id(); |
| 114 info->name = util.GetInputMethodLongName(ime); | 108 info->name = util.GetInputMethodLongName(ime); |
| 115 info->medium_name = util.GetInputMethodMediumName(ime); | 109 info->medium_name = util.GetInputMethodMediumName(ime); |
| 116 info->short_name = util.GetInputMethodShortName(ime); | 110 info->short_name = util.GetInputMethodShortName(ime); |
| 117 info->third_party = extension_ime_util::IsExtensionIME(ime.id()); | 111 info->third_party = extension_ime_util::IsExtensionIME(ime.id()); |
| 118 } | 112 } |
| 119 | 113 |
| 120 void BluetoothSetDiscoveringError() { | |
| 121 LOG(ERROR) << "BluetoothSetDiscovering failed."; | |
| 122 } | |
| 123 | |
| 124 void BluetoothDeviceConnectError( | |
| 125 device::BluetoothDevice::ConnectErrorCode error_code) { | |
| 126 } | |
| 127 | |
| 128 void OnAcceptMultiprofilesIntro(bool no_show_again) { | 114 void OnAcceptMultiprofilesIntro(bool no_show_again) { |
| 129 PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); | 115 PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); |
| 130 prefs->SetBoolean(prefs::kMultiProfileNeverShowIntro, no_show_again); | 116 prefs->SetBoolean(prefs::kMultiProfileNeverShowIntro, no_show_again); |
| 131 UserAddingScreen::Get()->Start(); | 117 UserAddingScreen::Get()->Start(); |
| 132 } | 118 } |
| 133 | 119 |
| 134 bool IsSessionInSecondaryLoginScreen() { | 120 bool IsSessionInSecondaryLoginScreen() { |
| 135 return session_manager::SessionManager::Get()->IsInSecondaryLoginScreen(); | 121 return session_manager::SessionManager::Get()->IsInSecondaryLoginScreen(); |
| 136 } | 122 } |
| 137 | 123 |
| 138 } // namespace | 124 } // namespace |
| 139 | 125 |
| 140 SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS() | 126 SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS() |
| 141 : networking_config_delegate_(new NetworkingConfigDelegateChromeos()), | 127 : bluetooth_helper_(base::MakeUnique<TrayBluetoothHelper>(this)), |
| 142 weak_ptr_factory_(this) { | 128 networking_config_delegate_( |
| 129 base::MakeUnique<NetworkingConfigDelegateChromeos>()) { |
| 143 // Register notifications on construction so that events such as | 130 // Register notifications on construction so that events such as |
| 144 // PROFILE_CREATED do not get missed if they happen before Initialize(). | 131 // PROFILE_CREATED do not get missed if they happen before Initialize(). |
| 145 registrar_.reset(new content::NotificationRegistrar); | 132 registrar_.reset(new content::NotificationRegistrar); |
| 146 if (GetUserLoginStatus() == ash::LoginStatus::NOT_LOGGED_IN) { | 133 if (GetUserLoginStatus() == ash::LoginStatus::NOT_LOGGED_IN) { |
| 147 registrar_->Add(this, | 134 registrar_->Add(this, |
| 148 chrome::NOTIFICATION_SESSION_STARTED, | 135 chrome::NOTIFICATION_SESSION_STARTED, |
| 149 content::NotificationService::AllSources()); | 136 content::NotificationService::AllSources()); |
| 150 } | 137 } |
| 151 registrar_->Add(this, | 138 registrar_->Add(this, |
| 152 chrome::NOTIFICATION_PROFILE_CREATED, | 139 chrome::NOTIFICATION_PROFILE_CREATED, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 165 user_manager::UserManager::Get()->AddSessionStateObserver(this); | 152 user_manager::UserManager::Get()->AddSessionStateObserver(this); |
| 166 } | 153 } |
| 167 | 154 |
| 168 void SystemTrayDelegateChromeOS::Initialize() { | 155 void SystemTrayDelegateChromeOS::Initialize() { |
| 169 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); | 156 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); |
| 170 | 157 |
| 171 input_method::InputMethodManager::Get()->AddObserver(this); | 158 input_method::InputMethodManager::Get()->AddObserver(this); |
| 172 input_method::InputMethodManager::Get()->AddImeMenuObserver(this); | 159 input_method::InputMethodManager::Get()->AddImeMenuObserver(this); |
| 173 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); | 160 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); |
| 174 | 161 |
| 175 device::BluetoothAdapterFactory::GetAdapter( | 162 bluetooth_helper_->Initialize(); |
| 176 base::Bind(&SystemTrayDelegateChromeOS::InitializeOnAdapterReady, | |
| 177 weak_ptr_factory_.GetWeakPtr())); | |
| 178 | 163 |
| 179 BrowserList::AddObserver(this); | 164 BrowserList::AddObserver(this); |
| 180 } | 165 } |
| 181 | 166 |
| 182 void SystemTrayDelegateChromeOS::InitializeOnAdapterReady( | 167 void SystemTrayDelegateChromeOS::InitializeOnAdapterReady() { |
| 183 scoped_refptr<device::BluetoothAdapter> adapter) { | |
| 184 bluetooth_adapter_ = adapter; | |
| 185 CHECK(bluetooth_adapter_); | |
| 186 bluetooth_adapter_->AddObserver(this); | |
| 187 | |
| 188 local_state_registrar_.reset(new PrefChangeRegistrar); | 168 local_state_registrar_.reset(new PrefChangeRegistrar); |
| 189 local_state_registrar_->Init(g_browser_process->local_state()); | 169 local_state_registrar_->Init(g_browser_process->local_state()); |
| 190 | 170 |
| 191 UpdateSessionStartTime(); | 171 UpdateSessionStartTime(); |
| 192 UpdateSessionLengthLimit(); | 172 UpdateSessionLengthLimit(); |
| 193 | 173 |
| 194 local_state_registrar_->Add( | 174 local_state_registrar_->Add( |
| 195 prefs::kSessionStartTime, | 175 prefs::kSessionStartTime, |
| 196 base::Bind(&SystemTrayDelegateChromeOS::UpdateSessionStartTime, | 176 base::Bind(&SystemTrayDelegateChromeOS::UpdateSessionStartTime, |
| 197 base::Unretained(this))); | 177 base::Unretained(this))); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 216 | 196 |
| 217 // Unregister content notifications before destroying any components. | 197 // Unregister content notifications before destroying any components. |
| 218 registrar_.reset(); | 198 registrar_.reset(); |
| 219 | 199 |
| 220 // Unregister a11y status subscription. | 200 // Unregister a11y status subscription. |
| 221 accessibility_subscription_.reset(); | 201 accessibility_subscription_.reset(); |
| 222 | 202 |
| 223 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); | 203 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); |
| 224 input_method::InputMethodManager::Get()->RemoveObserver(this); | 204 input_method::InputMethodManager::Get()->RemoveObserver(this); |
| 225 ui::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this); | 205 ui::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this); |
| 226 if (bluetooth_adapter_) | 206 |
| 227 bluetooth_adapter_->RemoveObserver(this); | 207 bluetooth_helper_.reset(); |
| 228 | 208 |
| 229 BrowserList::RemoveObserver(this); | 209 BrowserList::RemoveObserver(this); |
| 230 StopObservingAppWindowRegistry(); | 210 StopObservingAppWindowRegistry(); |
| 231 StopObservingCustodianInfoChanges(); | 211 StopObservingCustodianInfoChanges(); |
| 232 | 212 |
| 233 policy::BrowserPolicyConnectorChromeOS* connector = | 213 policy::BrowserPolicyConnectorChromeOS* connector = |
| 234 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 214 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 235 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = | 215 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = |
| 236 connector->GetDeviceCloudPolicyManager(); | 216 connector->GetDeviceCloudPolicyManager(); |
| 237 if (policy_manager) | 217 if (policy_manager) |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 base::Bind(&OnAcceptMultiprofilesIntro); | 343 base::Bind(&OnAcceptMultiprofilesIntro); |
| 364 ShowMultiprofilesIntroDialog(on_accept); | 344 ShowMultiprofilesIntroDialog(on_accept); |
| 365 } else { | 345 } else { |
| 366 UserAddingScreen::Get()->Start(); | 346 UserAddingScreen::Get()->Start(); |
| 367 } | 347 } |
| 368 } | 348 } |
| 369 } | 349 } |
| 370 | 350 |
| 371 void SystemTrayDelegateChromeOS::GetAvailableBluetoothDevices( | 351 void SystemTrayDelegateChromeOS::GetAvailableBluetoothDevices( |
| 372 ash::BluetoothDeviceList* list) { | 352 ash::BluetoothDeviceList* list) { |
| 373 device::BluetoothAdapter::DeviceList devices = | 353 bluetooth_helper_->GetAvailableDevices(list); |
| 374 bluetooth_adapter_->GetDevices(); | |
| 375 for (size_t i = 0; i < devices.size(); ++i) { | |
| 376 device::BluetoothDevice* device = devices[i]; | |
| 377 ash::BluetoothDeviceInfo info; | |
| 378 info.address = device->GetAddress(); | |
| 379 info.display_name = device->GetNameForDisplay(); | |
| 380 info.connected = device->IsConnected(); | |
| 381 info.connecting = device->IsConnecting(); | |
| 382 info.paired = device->IsPaired(); | |
| 383 info.device_type = device->GetDeviceType(); | |
| 384 list->push_back(info); | |
| 385 } | |
| 386 } | 354 } |
| 387 | 355 |
| 388 void SystemTrayDelegateChromeOS::BluetoothStartDiscovering() { | 356 void SystemTrayDelegateChromeOS::BluetoothStartDiscovering() { |
| 389 if (GetBluetoothDiscovering()) { | 357 bluetooth_helper_->StartDiscovering(); |
| 390 LOG(WARNING) << "Already have active Bluetooth device discovery session."; | |
| 391 return; | |
| 392 } | |
| 393 VLOG(1) << "Requesting new Bluetooth device discovery session."; | |
| 394 should_run_bluetooth_discovery_ = true; | |
| 395 bluetooth_adapter_->StartDiscoverySession( | |
| 396 base::Bind(&SystemTrayDelegateChromeOS::OnStartBluetoothDiscoverySession, | |
| 397 weak_ptr_factory_.GetWeakPtr()), | |
| 398 base::Bind(&BluetoothSetDiscoveringError)); | |
| 399 } | 358 } |
| 400 | 359 |
| 401 void SystemTrayDelegateChromeOS::BluetoothStopDiscovering() { | 360 void SystemTrayDelegateChromeOS::BluetoothStopDiscovering() { |
| 402 should_run_bluetooth_discovery_ = false; | 361 bluetooth_helper_->StopDiscovering(); |
| 403 if (!GetBluetoothDiscovering()) { | |
| 404 LOG(WARNING) << "No active Bluetooth device discovery session."; | |
| 405 return; | |
| 406 } | |
| 407 VLOG(1) << "Stopping Bluetooth device discovery session."; | |
| 408 bluetooth_discovery_session_->Stop( | |
| 409 base::Bind(&base::DoNothing), base::Bind(&BluetoothSetDiscoveringError)); | |
| 410 } | 362 } |
| 411 | 363 |
| 412 void SystemTrayDelegateChromeOS::ConnectToBluetoothDevice( | 364 void SystemTrayDelegateChromeOS::ConnectToBluetoothDevice( |
| 413 const std::string& address) { | 365 const std::string& address) { |
| 414 device::BluetoothDevice* device = bluetooth_adapter_->GetDevice(address); | 366 bluetooth_helper_->ConnectToDevice(address); |
| 415 if (!device || device->IsConnecting() || | |
| 416 (device->IsConnected() && device->IsPaired())) { | |
| 417 return; | |
| 418 } | |
| 419 if (device->IsPaired() && !device->IsConnectable()) | |
| 420 return; | |
| 421 if (device->IsPaired() || !device->IsPairable()) { | |
| 422 base::RecordAction( | |
| 423 base::UserMetricsAction("StatusArea_Bluetooth_Connect_Known")); | |
| 424 device->Connect(NULL, | |
| 425 base::Bind(&base::DoNothing), | |
| 426 base::Bind(&BluetoothDeviceConnectError)); | |
| 427 return; | |
| 428 } | |
| 429 // Show pairing dialog for the unpaired device. | |
| 430 base::RecordAction( | |
| 431 base::UserMetricsAction("StatusArea_Bluetooth_Connect_Unknown")); | |
| 432 BluetoothPairingDialog* dialog = new BluetoothPairingDialog(device); | |
| 433 // The dialog deletes itself on close. | |
| 434 dialog->ShowInContainer(SystemTrayClient::GetDialogParentContainerId()); | |
| 435 } | 367 } |
| 436 | 368 |
| 437 bool SystemTrayDelegateChromeOS::IsBluetoothDiscovering() const { | 369 bool SystemTrayDelegateChromeOS::IsBluetoothDiscovering() const { |
| 438 return bluetooth_adapter_ && bluetooth_adapter_->IsDiscovering(); | 370 return bluetooth_helper_->IsDiscovering(); |
| 439 } | 371 } |
| 440 | 372 |
| 441 void SystemTrayDelegateChromeOS::GetCurrentIME(ash::IMEInfo* info) { | 373 void SystemTrayDelegateChromeOS::GetCurrentIME(ash::IMEInfo* info) { |
| 442 input_method::InputMethodManager* manager = | 374 input_method::InputMethodManager* manager = |
| 443 input_method::InputMethodManager::Get(); | 375 input_method::InputMethodManager::Get(); |
| 444 input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); | 376 input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); |
| 445 input_method::InputMethodDescriptor ime = | 377 input_method::InputMethodDescriptor ime = |
| 446 manager->GetActiveIMEState()->GetCurrentInputMethod(); | 378 manager->GetActiveIMEState()->GetCurrentInputMethod(); |
| 447 ExtractIMEInfo(ime, *util, info); | 379 ExtractIMEInfo(ime, *util, info); |
| 448 info->selected = true; | 380 info->selected = true; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 ->GetActiveIMEState() | 423 ->GetActiveIMEState() |
| 492 ->ChangeInputMethod(ime_id, false /* show_message */); | 424 ->ChangeInputMethod(ime_id, false /* show_message */); |
| 493 input_method::InputMethodSwitchRecorder::Get()->RecordSwitch( | 425 input_method::InputMethodSwitchRecorder::Get()->RecordSwitch( |
| 494 true /* by_tray_menu */); | 426 true /* by_tray_menu */); |
| 495 } | 427 } |
| 496 | 428 |
| 497 void SystemTrayDelegateChromeOS::ActivateIMEProperty(const std::string& key) { | 429 void SystemTrayDelegateChromeOS::ActivateIMEProperty(const std::string& key) { |
| 498 input_method::InputMethodManager::Get()->ActivateInputMethodMenuItem(key); | 430 input_method::InputMethodManager::Get()->ActivateInputMethodMenuItem(key); |
| 499 } | 431 } |
| 500 | 432 |
| 433 // TODO(jamescook): Move to SystemTrayClient where other Web UI lives. |
| 501 void SystemTrayDelegateChromeOS::ManageBluetoothDevices() { | 434 void SystemTrayDelegateChromeOS::ManageBluetoothDevices() { |
| 502 content::RecordAction(base::UserMetricsAction("ShowBluetoothSettingsPage")); | 435 content::RecordAction(base::UserMetricsAction("ShowBluetoothSettingsPage")); |
| 503 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), | 436 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), |
| 504 chrome::kBluetoothSubPage); | 437 chrome::kBluetoothSubPage); |
| 505 } | 438 } |
| 506 | 439 |
| 507 void SystemTrayDelegateChromeOS::ToggleBluetooth() { | 440 void SystemTrayDelegateChromeOS::ToggleBluetooth() { |
| 508 bluetooth_adapter_->SetPowered(!bluetooth_adapter_->IsPowered(), | 441 bluetooth_helper_->ToggleEnabled(); |
| 509 base::Bind(&base::DoNothing), | |
| 510 base::Bind(&base::DoNothing)); | |
| 511 } | 442 } |
| 512 | 443 |
| 513 bool SystemTrayDelegateChromeOS::GetBluetoothAvailable() { | 444 bool SystemTrayDelegateChromeOS::GetBluetoothAvailable() { |
| 514 return bluetooth_adapter_ && bluetooth_adapter_->IsPresent(); | 445 return bluetooth_helper_->GetAvailable(); |
| 515 } | 446 } |
| 516 | 447 |
| 517 bool SystemTrayDelegateChromeOS::GetBluetoothEnabled() { | 448 bool SystemTrayDelegateChromeOS::GetBluetoothEnabled() { |
| 518 return bluetooth_adapter_ && bluetooth_adapter_->IsPowered(); | 449 return bluetooth_helper_->GetEnabled(); |
| 519 } | 450 } |
| 520 | 451 |
| 521 bool SystemTrayDelegateChromeOS::GetBluetoothDiscovering() { | 452 bool SystemTrayDelegateChromeOS::GetBluetoothDiscovering() { |
| 522 return bluetooth_discovery_session_ && | 453 return bluetooth_helper_->HasDiscoverySession(); |
| 523 bluetooth_discovery_session_->IsActive(); | |
| 524 } | 454 } |
| 525 | 455 |
| 526 ash::NetworkingConfigDelegate* | 456 ash::NetworkingConfigDelegate* |
| 527 SystemTrayDelegateChromeOS::GetNetworkingConfigDelegate() const { | 457 SystemTrayDelegateChromeOS::GetNetworkingConfigDelegate() const { |
| 528 return networking_config_delegate_.get(); | 458 return networking_config_delegate_.get(); |
| 529 } | 459 } |
| 530 | 460 |
| 531 bool SystemTrayDelegateChromeOS::GetSessionStartTime( | 461 bool SystemTrayDelegateChromeOS::GetSessionStartTime( |
| 532 base::TimeTicks* session_start_time) { | 462 base::TimeTicks* session_start_time) { |
| 533 *session_start_time = session_start_time_; | 463 *session_start_time = session_start_time_; |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 bool show_message) { | 736 bool show_message) { |
| 807 GetSystemTrayNotifier()->NotifyRefreshIME(); | 737 GetSystemTrayNotifier()->NotifyRefreshIME(); |
| 808 } | 738 } |
| 809 | 739 |
| 810 // Overridden from InputMethodMenuManager::Observer. | 740 // Overridden from InputMethodMenuManager::Observer. |
| 811 void SystemTrayDelegateChromeOS::InputMethodMenuItemChanged( | 741 void SystemTrayDelegateChromeOS::InputMethodMenuItemChanged( |
| 812 ui::ime::InputMethodMenuManager* manager) { | 742 ui::ime::InputMethodMenuManager* manager) { |
| 813 GetSystemTrayNotifier()->NotifyRefreshIME(); | 743 GetSystemTrayNotifier()->NotifyRefreshIME(); |
| 814 } | 744 } |
| 815 | 745 |
| 816 // Overridden from BluetoothAdapter::Observer. | |
| 817 void SystemTrayDelegateChromeOS::AdapterPresentChanged( | |
| 818 device::BluetoothAdapter* adapter, | |
| 819 bool present) { | |
| 820 GetSystemTrayNotifier()->NotifyRefreshBluetooth(); | |
| 821 } | |
| 822 | |
| 823 void SystemTrayDelegateChromeOS::AdapterPoweredChanged( | |
| 824 device::BluetoothAdapter* adapter, | |
| 825 bool powered) { | |
| 826 GetSystemTrayNotifier()->NotifyRefreshBluetooth(); | |
| 827 } | |
| 828 | |
| 829 void SystemTrayDelegateChromeOS::AdapterDiscoveringChanged( | |
| 830 device::BluetoothAdapter* adapter, | |
| 831 bool discovering) { | |
| 832 GetSystemTrayNotifier()->NotifyBluetoothDiscoveringChanged(); | |
| 833 } | |
| 834 | |
| 835 void SystemTrayDelegateChromeOS::DeviceAdded(device::BluetoothAdapter* adapter, | |
| 836 device::BluetoothDevice* device) { | |
| 837 GetSystemTrayNotifier()->NotifyRefreshBluetooth(); | |
| 838 } | |
| 839 | |
| 840 void SystemTrayDelegateChromeOS::DeviceChanged( | |
| 841 device::BluetoothAdapter* adapter, | |
| 842 device::BluetoothDevice* device) { | |
| 843 GetSystemTrayNotifier()->NotifyRefreshBluetooth(); | |
| 844 } | |
| 845 | |
| 846 void SystemTrayDelegateChromeOS::DeviceRemoved( | |
| 847 device::BluetoothAdapter* adapter, | |
| 848 device::BluetoothDevice* device) { | |
| 849 GetSystemTrayNotifier()->NotifyRefreshBluetooth(); | |
| 850 } | |
| 851 | |
| 852 void SystemTrayDelegateChromeOS::OnStartBluetoothDiscoverySession( | |
| 853 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session) { | |
| 854 // If the discovery session was returned after a request to stop discovery | |
| 855 // (e.g. the user dismissed the Bluetooth detailed view before the call | |
| 856 // returned), don't claim the discovery session and let it clean up. | |
| 857 if (!should_run_bluetooth_discovery_) | |
| 858 return; | |
| 859 VLOG(1) << "Claiming new Bluetooth device discovery session."; | |
| 860 bluetooth_discovery_session_ = std::move(discovery_session); | |
| 861 GetSystemTrayNotifier()->NotifyBluetoothDiscoveringChanged(); | |
| 862 } | |
| 863 | |
| 864 void SystemTrayDelegateChromeOS::UpdateEnterpriseDomain() { | 746 void SystemTrayDelegateChromeOS::UpdateEnterpriseDomain() { |
| 865 policy::BrowserPolicyConnectorChromeOS* connector = | 747 policy::BrowserPolicyConnectorChromeOS* connector = |
| 866 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 748 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 867 std::string old_enterprise_domain(std::move(enterprise_domain_)); | 749 std::string old_enterprise_domain(std::move(enterprise_domain_)); |
| 868 enterprise_domain_ = connector->GetEnterpriseDomain(); | 750 enterprise_domain_ = connector->GetEnterpriseDomain(); |
| 869 bool old_is_active_directory_managed = is_active_directory_managed_; | 751 bool old_is_active_directory_managed = is_active_directory_managed_; |
| 870 is_active_directory_managed_ = connector->IsActiveDirectoryManaged(); | 752 is_active_directory_managed_ = connector->IsActiveDirectoryManaged(); |
| 871 if ((!is_active_directory_managed_ && | 753 if ((!is_active_directory_managed_ && |
| 872 enterprise_domain_ != old_enterprise_domain) || | 754 enterprise_domain_ != old_enterprise_domain) || |
| 873 (is_active_directory_managed_ != old_is_active_directory_managed)) { | 755 (is_active_directory_managed_ != old_is_active_directory_managed)) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " | 844 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " |
| 963 << "ENABLE_SUPERVISED_USERS undefined."; | 845 << "ENABLE_SUPERVISED_USERS undefined."; |
| 964 return base::string16(); | 846 return base::string16(); |
| 965 } | 847 } |
| 966 | 848 |
| 967 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 849 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
| 968 return new SystemTrayDelegateChromeOS(); | 850 return new SystemTrayDelegateChromeOS(); |
| 969 } | 851 } |
| 970 | 852 |
| 971 } // namespace chromeos | 853 } // namespace chromeos |
| OLD | NEW |