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 <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "ash/system/system_notifier.h" | 10 #include "ash/system/system_notifier.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 // Cannot provide keyboard entry in a notification; fortunately the spec | 197 // Cannot provide keyboard entry in a notification; fortunately the spec |
198 // doesn't allow for this to be an option when we're receiving the pairing | 198 // doesn't allow for this to be an option when we're receiving the pairing |
199 // request anyway. | 199 // request anyway. |
200 device->CancelPairing(); | 200 device->CancelPairing(); |
201 } | 201 } |
202 | 202 |
203 void BluetoothNotificationController::DisplayPinCode( | 203 void BluetoothNotificationController::DisplayPinCode( |
204 BluetoothDevice* device, | 204 BluetoothDevice* device, |
205 const std::string& pincode) { | 205 const std::string& pincode) { |
206 base::string16 message = l10n_util::GetStringFUTF16( | 206 base::string16 message = l10n_util::GetStringFUTF16( |
207 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISPLAY_PINCODE, | 207 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISPLAY_PINCODE, |
208 device->GetName(), base::UTF8ToUTF16(pincode)); | 208 device->GetNameForDisplay(), base::UTF8ToUTF16(pincode)); |
209 | 209 |
210 NotifyPairing(device, message, false); | 210 NotifyPairing(device, message, false); |
211 } | 211 } |
212 | 212 |
213 void BluetoothNotificationController::DisplayPasskey(BluetoothDevice* device, | 213 void BluetoothNotificationController::DisplayPasskey(BluetoothDevice* device, |
214 uint32_t passkey) { | 214 uint32_t passkey) { |
215 base::string16 message = l10n_util::GetStringFUTF16( | 215 base::string16 message = l10n_util::GetStringFUTF16( |
216 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISPLAY_PASSKEY, | 216 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISPLAY_PASSKEY, |
217 device->GetName(), base::UTF8ToUTF16( | 217 device->GetNameForDisplay(), |
218 base::StringPrintf("%06i", passkey))); | 218 base::UTF8ToUTF16(base::StringPrintf("%06i", passkey))); |
219 | 219 |
220 NotifyPairing(device, message, false); | 220 NotifyPairing(device, message, false); |
221 } | 221 } |
222 | 222 |
223 void BluetoothNotificationController::KeysEntered(BluetoothDevice* device, | 223 void BluetoothNotificationController::KeysEntered(BluetoothDevice* device, |
224 uint32_t entered) { | 224 uint32_t entered) { |
225 // Ignored since we don't have CSS in the notification to update. | 225 // Ignored since we don't have CSS in the notification to update. |
226 } | 226 } |
227 | 227 |
228 void BluetoothNotificationController::ConfirmPasskey(BluetoothDevice* device, | 228 void BluetoothNotificationController::ConfirmPasskey(BluetoothDevice* device, |
229 uint32_t passkey) { | 229 uint32_t passkey) { |
230 base::string16 message = l10n_util::GetStringFUTF16( | 230 base::string16 message = l10n_util::GetStringFUTF16( |
231 IDS_ASH_STATUS_TRAY_BLUETOOTH_CONFIRM_PASSKEY, | 231 IDS_ASH_STATUS_TRAY_BLUETOOTH_CONFIRM_PASSKEY, |
232 device->GetName(), base::UTF8ToUTF16( | 232 device->GetNameForDisplay(), |
233 base::StringPrintf("%06i", passkey))); | 233 base::UTF8ToUTF16(base::StringPrintf("%06i", passkey))); |
234 | 234 |
235 NotifyPairing(device, message, true); | 235 NotifyPairing(device, message, true); |
236 } | 236 } |
237 | 237 |
238 void BluetoothNotificationController::AuthorizePairing( | 238 void BluetoothNotificationController::AuthorizePairing( |
239 BluetoothDevice* device) { | 239 BluetoothDevice* device) { |
240 base::string16 message = l10n_util::GetStringFUTF16( | 240 base::string16 message = l10n_util::GetStringFUTF16( |
241 IDS_ASH_STATUS_TRAY_BLUETOOTH_AUTHORIZE_PAIRING, | 241 IDS_ASH_STATUS_TRAY_BLUETOOTH_AUTHORIZE_PAIRING, |
242 device->GetName()); | 242 device->GetNameForDisplay()); |
243 | 243 |
244 NotifyPairing(device, message, true); | 244 NotifyPairing(device, message, true); |
245 } | 245 } |
246 | 246 |
247 | 247 |
248 void BluetoothNotificationController::OnGetAdapter( | 248 void BluetoothNotificationController::OnGetAdapter( |
249 scoped_refptr<BluetoothAdapter> adapter) { | 249 scoped_refptr<BluetoothAdapter> adapter) { |
250 DCHECK(!adapter_.get()); | 250 DCHECK(!adapter_.get()); |
251 adapter_ = adapter; | 251 adapter_ = adapter; |
252 adapter_->AddObserver(this); | 252 adapter_->AddObserver(this); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 std::unique_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->GetNameForDisplay()), |
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 |