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 "ash/system/system_notifier.h" | 7 #include "ash/system/system_notifier.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 } | 267 } |
268 | 268 |
269 | 269 |
270 void BluetoothNotificationController::NotifyAdapterDiscoverable() { | 270 void BluetoothNotificationController::NotifyAdapterDiscoverable() { |
271 message_center::RichNotificationData optional; | 271 message_center::RichNotificationData optional; |
272 | 272 |
273 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 273 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
274 | 274 |
275 scoped_ptr<Notification> notification(new Notification( | 275 scoped_ptr<Notification> notification(new Notification( |
276 message_center::NOTIFICATION_TYPE_SIMPLE, | 276 message_center::NOTIFICATION_TYPE_SIMPLE, |
277 kBluetoothDeviceDiscoverableNotificationId, | 277 kBluetoothDeviceDiscoverableNotificationId, base::string16() /* title */, |
278 base::string16() /* title */, | 278 l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERABLE, |
279 l10n_util::GetStringFUTF16( | 279 base::UTF8ToUTF16(adapter_->GetName()), |
280 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERABLE, | 280 base::UTF8ToUTF16(adapter_->GetAddress())), |
281 base::UTF8ToUTF16(adapter_->GetName()), | |
282 base::UTF8ToUTF16(adapter_->GetAddress())), | |
283 bundle.GetImageNamed(IDR_AURA_NOTIFICATION_BLUETOOTH), | 281 bundle.GetImageNamed(IDR_AURA_NOTIFICATION_BLUETOOTH), |
284 base::string16() /* display source */, | 282 base::string16() /* display source */, GURL(), |
285 message_center::NotifierId( | 283 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, |
286 message_center::NotifierId::SYSTEM_COMPONENT, | 284 system_notifier::kNotifierBluetooth), |
287 system_notifier::kNotifierBluetooth), | 285 optional, NULL)); |
288 optional, | |
289 NULL)); | |
290 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); | 286 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); |
291 } | 287 } |
292 | 288 |
293 void BluetoothNotificationController::NotifyPairing( | 289 void BluetoothNotificationController::NotifyPairing( |
294 BluetoothDevice* device, | 290 BluetoothDevice* device, |
295 const base::string16& message, | 291 const base::string16& message, |
296 bool with_buttons) { | 292 bool with_buttons) { |
297 message_center::RichNotificationData optional; | 293 message_center::RichNotificationData optional; |
298 if (with_buttons) { | 294 if (with_buttons) { |
299 optional.buttons.push_back(message_center::ButtonInfo( | 295 optional.buttons.push_back(message_center::ButtonInfo( |
300 l10n_util::GetStringUTF16( | 296 l10n_util::GetStringUTF16( |
301 IDS_ASH_STATUS_TRAY_BLUETOOTH_ACCEPT))); | 297 IDS_ASH_STATUS_TRAY_BLUETOOTH_ACCEPT))); |
302 optional.buttons.push_back(message_center::ButtonInfo( | 298 optional.buttons.push_back(message_center::ButtonInfo( |
303 l10n_util::GetStringUTF16( | 299 l10n_util::GetStringUTF16( |
304 IDS_ASH_STATUS_TRAY_BLUETOOTH_REJECT))); | 300 IDS_ASH_STATUS_TRAY_BLUETOOTH_REJECT))); |
305 } | 301 } |
306 | 302 |
307 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 303 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
308 | 304 |
309 scoped_ptr<Notification> notification(new Notification( | 305 scoped_ptr<Notification> notification(new Notification( |
310 message_center::NOTIFICATION_TYPE_SIMPLE, | 306 message_center::NOTIFICATION_TYPE_SIMPLE, |
311 kBluetoothDevicePairingNotificationId, | 307 kBluetoothDevicePairingNotificationId, base::string16() /* title */, |
312 base::string16() /* title */, | 308 message, bundle.GetImageNamed(IDR_AURA_NOTIFICATION_BLUETOOTH), |
313 message, | 309 base::string16() /* display source */, GURL(), |
314 bundle.GetImageNamed(IDR_AURA_NOTIFICATION_BLUETOOTH), | 310 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, |
315 base::string16() /* display source */, | 311 system_notifier::kNotifierBluetooth), |
316 message_center::NotifierId( | 312 optional, new BluetoothPairingNotificationDelegate( |
317 message_center::NotifierId::SYSTEM_COMPONENT, | 313 adapter_, device->GetAddress()))); |
318 system_notifier::kNotifierBluetooth), | |
319 optional, | |
320 new BluetoothPairingNotificationDelegate(adapter_, | |
321 device->GetAddress()))); | |
322 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); | 314 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); |
323 } | 315 } |
324 | 316 |
325 void BluetoothNotificationController::NotifyPairedDevice( | 317 void BluetoothNotificationController::NotifyPairedDevice( |
326 BluetoothDevice* device) { | 318 BluetoothDevice* device) { |
327 // Remove the currently presented pairing notification; since only one | 319 // Remove the currently presented pairing notification; since only one |
328 // pairing request is queued at a time, this is guaranteed to be the device | 320 // pairing request is queued at a time, this is guaranteed to be the device |
329 // that just became paired. | 321 // that just became paired. |
330 message_center::MessageCenter::Get()->RemoveNotification( | 322 message_center::MessageCenter::Get()->RemoveNotification( |
331 kBluetoothDevicePairingNotificationId, false /* by_user */); | 323 kBluetoothDevicePairingNotificationId, false /* by_user */); |
332 | 324 |
333 message_center::RichNotificationData optional; | 325 message_center::RichNotificationData optional; |
334 | 326 |
335 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 327 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
336 | 328 |
337 scoped_ptr<Notification> notification(new Notification( | 329 scoped_ptr<Notification> notification(new Notification( |
338 message_center::NOTIFICATION_TYPE_SIMPLE, | 330 message_center::NOTIFICATION_TYPE_SIMPLE, |
339 kBluetoothDevicePairedNotificationId, | 331 kBluetoothDevicePairedNotificationId, base::string16() /* title */, |
340 base::string16() /* title */, | 332 l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_BLUETOOTH_PAIRED, |
341 l10n_util::GetStringFUTF16( | 333 device->GetName()), |
342 IDS_ASH_STATUS_TRAY_BLUETOOTH_PAIRED, device->GetName()), | |
343 bundle.GetImageNamed(IDR_AURA_NOTIFICATION_BLUETOOTH), | 334 bundle.GetImageNamed(IDR_AURA_NOTIFICATION_BLUETOOTH), |
344 base::string16() /* display source */, | 335 base::string16() /* display source */, GURL(), |
345 message_center::NotifierId( | 336 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, |
346 message_center::NotifierId::SYSTEM_COMPONENT, | 337 system_notifier::kNotifierBluetooth), |
347 system_notifier::kNotifierBluetooth), | 338 optional, NULL)); |
348 optional, | |
349 NULL)); | |
350 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); | 339 message_center::MessageCenter::Get()->AddNotification(notification.Pass()); |
351 } | 340 } |
352 | 341 |
353 } // namespace ash | 342 } // namespace ash |
OLD | NEW |