summaryrefslogtreecommitdiffstats
path: root/ash/system/chromeos
diff options
context:
space:
mode:
authorkeybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-04 21:59:18 +0000
committerkeybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-04 21:59:18 +0000
commit98bd3f15877f933e607ddd745e1d0f623508d803 (patch)
treee9093477a591791910192aa50bd5c9b923236a07 /ash/system/chromeos
parent32deb05157e2e4b777c3df8ed04c6e9360574baa (diff)
downloadchromium_src-98bd3f15877f933e607ddd745e1d0f623508d803.zip
chromium_src-98bd3f15877f933e607ddd745e1d0f623508d803.tar.gz
chromium_src-98bd3f15877f933e607ddd745e1d0f623508d803.tar.bz2
Bluetooth: show notification when device is paired
Chrome OS security team are concerned that users may not be aware that pairing a device makes it available to all users of the system. Use the notification popups to inform of that after pairing, as agreed with the security team. BUG=239801 TEST=chromeos=1 on Linux, pair a device Review URL: https://codereview.chromium.org/184963005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254839 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/system/chromeos')
-rw-r--r--ash/system/chromeos/bluetooth/bluetooth_notification_controller.cc34
1 files changed, 31 insertions, 3 deletions
diff --git a/ash/system/chromeos/bluetooth/bluetooth_notification_controller.cc b/ash/system/chromeos/bluetooth/bluetooth_notification_controller.cc
index 1a3aae3..d740a00 100644
--- a/ash/system/chromeos/bluetooth/bluetooth_notification_controller.cc
+++ b/ash/system/chromeos/bluetooth/bluetooth_notification_controller.cc
@@ -36,6 +36,11 @@ namespace {
const char kBluetoothDevicePairingNotificationId[] =
"chrome://settings/bluetooth/pairing";
+// Identifier for the notification that a device has been paired with the
+// system.
+const char kBluetoothDevicePairedNotificationId[] =
+ "chrome://settings/bluetooth/paired";
+
// The BluetoothPairingNotificationDelegate handles user interaction with the
// pairing notification and sending the confirmation, rejection or cancellation
// back to the underlying device.
@@ -154,17 +159,21 @@ BluetoothNotificationController::~BluetoothNotificationController() {
void BluetoothNotificationController::DeviceAdded(BluetoothAdapter* adapter,
BluetoothDevice* device) {
- if (device->IsPaired()) {
+ // Add the new device to the list of currently paired devices; it doesn't
+ // receive a notification since it's assumed it was previously notified.
+ if (device->IsPaired())
paired_devices_.insert(device->GetAddress());
- NotifyPairedDevice(device);
- }
}
void BluetoothNotificationController::DeviceChanged(BluetoothAdapter* adapter,
BluetoothDevice* device) {
+ // If the device is already in the list of paired devices, then don't
+ // notify.
if (paired_devices_.find(device->GetAddress()) != paired_devices_.end())
return;
+ // Otherwise if it's marked as paired then it must be newly paired, so
+ // notify the user about that.
if (device->IsPaired()) {
paired_devices_.insert(device->GetAddress());
NotifyPairedDevice(device);
@@ -295,6 +304,25 @@ void BluetoothNotificationController::NotifyPairedDevice(
// that just became paired.
message_center::MessageCenter::Get()->RemoveNotification(
kBluetoothDevicePairingNotificationId, false /* by_user */);
+
+ message_center::RichNotificationData optional;
+
+ ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
+
+ scoped_ptr<Notification> notification(new Notification(
+ message_center::NOTIFICATION_TYPE_SIMPLE,
+ kBluetoothDevicePairedNotificationId,
+ base::string16() /* title */,
+ l10n_util::GetStringFUTF16(
+ IDS_ASH_STATUS_TRAY_BLUETOOTH_PAIRED, device->GetName()),
+ bundle.GetImageNamed(IDR_AURA_UBER_TRAY_BLUETOOTH),
+ base::string16() /* display source */,
+ message_center::NotifierId(
+ message_center::NotifierId::SYSTEM_COMPONENT,
+ system_notifier::kNotifierBluetooth),
+ optional,
+ NULL));
+ message_center::MessageCenter::Get()->AddNotification(notification.Pass());
}
} // namespace internal