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 <memory> |
7 #include <utility> | 8 #include <utility> |
8 | 9 |
9 #include "ash/system/system_notifier.h" | 10 #include "ash/system/system_notifier.h" |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/callback.h" | 12 #include "base/callback.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "device/bluetooth/bluetooth_adapter_factory.h" | 16 #include "device/bluetooth/bluetooth_adapter_factory.h" |
17 #include "device/bluetooth/bluetooth_device.h" | 17 #include "device/bluetooth/bluetooth_device.h" |
18 #include "grit/ash_resources.h" | 18 #include "grit/ash_resources.h" |
19 #include "grit/ash_strings.h" | 19 #include "grit/ash_strings.h" |
20 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
21 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
22 #include "ui/message_center/message_center.h" | 22 #include "ui/message_center/message_center.h" |
23 #include "ui/message_center/notification.h" | 23 #include "ui/message_center/notification.h" |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 paired_devices_.insert(device->GetAddress()); | 267 paired_devices_.insert(device->GetAddress()); |
268 } | 268 } |
269 } | 269 } |
270 | 270 |
271 | 271 |
272 void BluetoothNotificationController::NotifyAdapterDiscoverable() { | 272 void BluetoothNotificationController::NotifyAdapterDiscoverable() { |
273 message_center::RichNotificationData optional; | 273 message_center::RichNotificationData optional; |
274 | 274 |
275 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 275 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
276 | 276 |
277 scoped_ptr<Notification> notification(new Notification( | 277 std::unique_ptr<Notification> notification(new Notification( |
278 message_center::NOTIFICATION_TYPE_SIMPLE, | 278 message_center::NOTIFICATION_TYPE_SIMPLE, |
279 kBluetoothDeviceDiscoverableNotificationId, base::string16() /* title */, | 279 kBluetoothDeviceDiscoverableNotificationId, base::string16() /* title */, |
280 l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERABLE, | 280 l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERABLE, |
281 base::UTF8ToUTF16(adapter_->GetName()), | 281 base::UTF8ToUTF16(adapter_->GetName()), |
282 base::UTF8ToUTF16(adapter_->GetAddress())), | 282 base::UTF8ToUTF16(adapter_->GetAddress())), |
283 bundle.GetImageNamed(IDR_AURA_NOTIFICATION_BLUETOOTH), | 283 bundle.GetImageNamed(IDR_AURA_NOTIFICATION_BLUETOOTH), |
284 base::string16() /* display source */, GURL(), | 284 base::string16() /* display source */, GURL(), |
285 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, | 285 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, |
286 system_notifier::kNotifierBluetooth), | 286 system_notifier::kNotifierBluetooth), |
287 optional, NULL)); | 287 optional, NULL)); |
(...skipping 10 matching lines...) Expand all Loading... |
298 optional.buttons.push_back(message_center::ButtonInfo( | 298 optional.buttons.push_back(message_center::ButtonInfo( |
299 l10n_util::GetStringUTF16( | 299 l10n_util::GetStringUTF16( |
300 IDS_ASH_STATUS_TRAY_BLUETOOTH_ACCEPT))); | 300 IDS_ASH_STATUS_TRAY_BLUETOOTH_ACCEPT))); |
301 optional.buttons.push_back(message_center::ButtonInfo( | 301 optional.buttons.push_back(message_center::ButtonInfo( |
302 l10n_util::GetStringUTF16( | 302 l10n_util::GetStringUTF16( |
303 IDS_ASH_STATUS_TRAY_BLUETOOTH_REJECT))); | 303 IDS_ASH_STATUS_TRAY_BLUETOOTH_REJECT))); |
304 } | 304 } |
305 | 305 |
306 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 306 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
307 | 307 |
308 scoped_ptr<Notification> notification(new Notification( | 308 std::unique_ptr<Notification> notification(new Notification( |
309 message_center::NOTIFICATION_TYPE_SIMPLE, | 309 message_center::NOTIFICATION_TYPE_SIMPLE, |
310 kBluetoothDevicePairingNotificationId, base::string16() /* title */, | 310 kBluetoothDevicePairingNotificationId, base::string16() /* title */, |
311 message, bundle.GetImageNamed(IDR_AURA_NOTIFICATION_BLUETOOTH), | 311 message, bundle.GetImageNamed(IDR_AURA_NOTIFICATION_BLUETOOTH), |
312 base::string16() /* display source */, GURL(), | 312 base::string16() /* display source */, GURL(), |
313 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, | 313 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, |
314 system_notifier::kNotifierBluetooth), | 314 system_notifier::kNotifierBluetooth), |
315 optional, new BluetoothPairingNotificationDelegate( | 315 optional, new BluetoothPairingNotificationDelegate( |
316 adapter_, device->GetAddress()))); | 316 adapter_, device->GetAddress()))); |
317 message_center::MessageCenter::Get()->AddNotification( | 317 message_center::MessageCenter::Get()->AddNotification( |
318 std::move(notification)); | 318 std::move(notification)); |
319 } | 319 } |
320 | 320 |
321 void BluetoothNotificationController::NotifyPairedDevice( | 321 void BluetoothNotificationController::NotifyPairedDevice( |
322 BluetoothDevice* device) { | 322 BluetoothDevice* device) { |
323 // Remove the currently presented pairing notification; since only one | 323 // Remove the currently presented pairing notification; since only one |
324 // 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 |
325 // that just became paired. | 325 // that just became paired. |
326 message_center::MessageCenter::Get()->RemoveNotification( | 326 message_center::MessageCenter::Get()->RemoveNotification( |
327 kBluetoothDevicePairingNotificationId, false /* by_user */); | 327 kBluetoothDevicePairingNotificationId, false /* by_user */); |
328 | 328 |
329 message_center::RichNotificationData optional; | 329 message_center::RichNotificationData optional; |
330 | 330 |
331 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 331 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
332 | 332 |
333 scoped_ptr<Notification> notification(new Notification( | 333 std::unique_ptr<Notification> notification(new Notification( |
334 message_center::NOTIFICATION_TYPE_SIMPLE, | 334 message_center::NOTIFICATION_TYPE_SIMPLE, |
335 kBluetoothDevicePairedNotificationId, base::string16() /* title */, | 335 kBluetoothDevicePairedNotificationId, base::string16() /* title */, |
336 l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_BLUETOOTH_PAIRED, | 336 l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_BLUETOOTH_PAIRED, |
337 device->GetName()), | 337 device->GetName()), |
338 bundle.GetImageNamed(IDR_AURA_NOTIFICATION_BLUETOOTH), | 338 bundle.GetImageNamed(IDR_AURA_NOTIFICATION_BLUETOOTH), |
339 base::string16() /* display source */, GURL(), | 339 base::string16() /* display source */, GURL(), |
340 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, | 340 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, |
341 system_notifier::kNotifierBluetooth), | 341 system_notifier::kNotifierBluetooth), |
342 optional, NULL)); | 342 optional, NULL)); |
343 message_center::MessageCenter::Get()->AddNotification( | 343 message_center::MessageCenter::Get()->AddNotification( |
344 std::move(notification)); | 344 std::move(notification)); |
345 } | 345 } |
346 | 346 |
347 } // namespace ash | 347 } // namespace ash |
OLD | NEW |