OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/bluetooth/bluetooth_notification_controller.h" | 5 #include "ash/system/chromeos/bluetooth/bluetooth_notification_controller.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "ash/system/system_notifier.h" | 9 #include "ash/system/system_notifier.h" |
8 #include "base/bind.h" | 10 #include "base/bind.h" |
9 #include "base/callback.h" | 11 #include "base/callback.h" |
10 #include "base/logging.h" | 12 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
12 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
13 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
14 #include "device/bluetooth/bluetooth_adapter_factory.h" | 16 #include "device/bluetooth/bluetooth_adapter_factory.h" |
15 #include "device/bluetooth/bluetooth_device.h" | 17 #include "device/bluetooth/bluetooth_device.h" |
16 #include "grit/ash_resources.h" | 18 #include "grit/ash_resources.h" |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 message_center::NOTIFICATION_TYPE_SIMPLE, | 278 message_center::NOTIFICATION_TYPE_SIMPLE, |
277 kBluetoothDeviceDiscoverableNotificationId, base::string16() /* title */, | 279 kBluetoothDeviceDiscoverableNotificationId, base::string16() /* title */, |
278 l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERABLE, | 280 l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERABLE, |
279 base::UTF8ToUTF16(adapter_->GetName()), | 281 base::UTF8ToUTF16(adapter_->GetName()), |
280 base::UTF8ToUTF16(adapter_->GetAddress())), | 282 base::UTF8ToUTF16(adapter_->GetAddress())), |
281 bundle.GetImageNamed(IDR_AURA_NOTIFICATION_BLUETOOTH), | 283 bundle.GetImageNamed(IDR_AURA_NOTIFICATION_BLUETOOTH), |
282 base::string16() /* display source */, GURL(), | 284 base::string16() /* display source */, GURL(), |
283 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, | 285 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, |
284 system_notifier::kNotifierBluetooth), | 286 system_notifier::kNotifierBluetooth), |
285 optional, NULL)); | 287 optional, NULL)); |
286 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); | 288 message_center::MessageCenter::Get()->AddNotification( |
| 289 std::move(notification)); |
287 } | 290 } |
288 | 291 |
289 void BluetoothNotificationController::NotifyPairing( | 292 void BluetoothNotificationController::NotifyPairing( |
290 BluetoothDevice* device, | 293 BluetoothDevice* device, |
291 const base::string16& message, | 294 const base::string16& message, |
292 bool with_buttons) { | 295 bool with_buttons) { |
293 message_center::RichNotificationData optional; | 296 message_center::RichNotificationData optional; |
294 if (with_buttons) { | 297 if (with_buttons) { |
295 optional.buttons.push_back(message_center::ButtonInfo( | 298 optional.buttons.push_back(message_center::ButtonInfo( |
296 l10n_util::GetStringUTF16( | 299 l10n_util::GetStringUTF16( |
297 IDS_ASH_STATUS_TRAY_BLUETOOTH_ACCEPT))); | 300 IDS_ASH_STATUS_TRAY_BLUETOOTH_ACCEPT))); |
298 optional.buttons.push_back(message_center::ButtonInfo( | 301 optional.buttons.push_back(message_center::ButtonInfo( |
299 l10n_util::GetStringUTF16( | 302 l10n_util::GetStringUTF16( |
300 IDS_ASH_STATUS_TRAY_BLUETOOTH_REJECT))); | 303 IDS_ASH_STATUS_TRAY_BLUETOOTH_REJECT))); |
301 } | 304 } |
302 | 305 |
303 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 306 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
304 | 307 |
305 scoped_ptr<Notification> notification(new Notification( | 308 scoped_ptr<Notification> notification(new Notification( |
306 message_center::NOTIFICATION_TYPE_SIMPLE, | 309 message_center::NOTIFICATION_TYPE_SIMPLE, |
307 kBluetoothDevicePairingNotificationId, base::string16() /* title */, | 310 kBluetoothDevicePairingNotificationId, base::string16() /* title */, |
308 message, bundle.GetImageNamed(IDR_AURA_NOTIFICATION_BLUETOOTH), | 311 message, bundle.GetImageNamed(IDR_AURA_NOTIFICATION_BLUETOOTH), |
309 base::string16() /* display source */, GURL(), | 312 base::string16() /* display source */, GURL(), |
310 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, | 313 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, |
311 system_notifier::kNotifierBluetooth), | 314 system_notifier::kNotifierBluetooth), |
312 optional, new BluetoothPairingNotificationDelegate( | 315 optional, new BluetoothPairingNotificationDelegate( |
313 adapter_, device->GetAddress()))); | 316 adapter_, device->GetAddress()))); |
314 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); | 317 message_center::MessageCenter::Get()->AddNotification( |
| 318 std::move(notification)); |
315 } | 319 } |
316 | 320 |
317 void BluetoothNotificationController::NotifyPairedDevice( | 321 void BluetoothNotificationController::NotifyPairedDevice( |
318 BluetoothDevice* device) { | 322 BluetoothDevice* device) { |
319 // Remove the currently presented pairing notification; since only one | 323 // Remove the currently presented pairing notification; since only one |
320 // pairing request is queued at a time, this is guaranteed to be the device | 324 // pairing request is queued at a time, this is guaranteed to be the device |
321 // that just became paired. | 325 // that just became paired. |
322 message_center::MessageCenter::Get()->RemoveNotification( | 326 message_center::MessageCenter::Get()->RemoveNotification( |
323 kBluetoothDevicePairingNotificationId, false /* by_user */); | 327 kBluetoothDevicePairingNotificationId, false /* by_user */); |
324 | 328 |
325 message_center::RichNotificationData optional; | 329 message_center::RichNotificationData optional; |
326 | 330 |
327 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 331 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
328 | 332 |
329 scoped_ptr<Notification> notification(new Notification( | 333 scoped_ptr<Notification> notification(new Notification( |
330 message_center::NOTIFICATION_TYPE_SIMPLE, | 334 message_center::NOTIFICATION_TYPE_SIMPLE, |
331 kBluetoothDevicePairedNotificationId, base::string16() /* title */, | 335 kBluetoothDevicePairedNotificationId, base::string16() /* title */, |
332 l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_BLUETOOTH_PAIRED, | 336 l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_BLUETOOTH_PAIRED, |
333 device->GetName()), | 337 device->GetName()), |
334 bundle.GetImageNamed(IDR_AURA_NOTIFICATION_BLUETOOTH), | 338 bundle.GetImageNamed(IDR_AURA_NOTIFICATION_BLUETOOTH), |
335 base::string16() /* display source */, GURL(), | 339 base::string16() /* display source */, GURL(), |
336 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, | 340 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, |
337 system_notifier::kNotifierBluetooth), | 341 system_notifier::kNotifierBluetooth), |
338 optional, NULL)); | 342 optional, NULL)); |
339 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); | 343 message_center::MessageCenter::Get()->AddNotification( |
| 344 std::move(notification)); |
340 } | 345 } |
341 | 346 |
342 } // namespace ash | 347 } // namespace ash |
OLD | NEW |