| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bluetooth/tray_bluetooth.h" | 5 #include "ash/system/bluetooth/tray_bluetooth.h" |
| 6 | 6 |
| 7 #include "ash/session/session_state_delegate.h" | 7 #include "ash/session/session_state_delegate.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/system/tray/fixed_sized_scroll_view.h" | 9 #include "ash/system/tray/fixed_sized_scroll_view.h" |
| 10 #include "ash/system/tray/hover_highlight_view.h" | 10 #include "ash/system/tray/hover_highlight_view.h" |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 if (display_name) | 331 if (display_name) |
| 332 *display_name = device_list[i].display_name; | 332 *display_name = device_list[i].display_name; |
| 333 return true; | 333 return true; |
| 334 } | 334 } |
| 335 } | 335 } |
| 336 return false; | 336 return false; |
| 337 } | 337 } |
| 338 | 338 |
| 339 // Updates UI of the clicked bluetooth device to show it is being connected | 339 // Updates UI of the clicked bluetooth device to show it is being connected |
| 340 // or disconnected if such an operation is going to be performed underway. | 340 // or disconnected if such an operation is going to be performed underway. |
| 341 void UpdateClickedDevice(std::string device_id, views::View* item_container) { | 341 void UpdateClickedDevice(const std::string& device_id, |
| 342 views::View* item_container) { |
| 342 base::string16 display_name; | 343 base::string16 display_name; |
| 343 if (FoundDevice(device_id, paired_not_connected_devices_, | 344 if (FoundDevice(device_id, paired_not_connected_devices_, |
| 344 &display_name)) { | 345 &display_name)) { |
| 345 display_name = l10n_util::GetStringFUTF16( | 346 display_name = l10n_util::GetStringFUTF16( |
| 346 IDS_ASH_STATUS_TRAY_BLUETOOTH_CONNECTING, display_name); | 347 IDS_ASH_STATUS_TRAY_BLUETOOTH_CONNECTING, display_name); |
| 347 | 348 |
| 348 item_container->RemoveAllChildViews(true); | 349 item_container->RemoveAllChildViews(true); |
| 349 static_cast<HoverHighlightView*>(item_container) | 350 static_cast<HoverHighlightView*>(item_container) |
| 350 ->AddCheckableLabel(display_name, true /* highlight */, false); | 351 ->AddCheckableLabel(display_name, true /* highlight */, false); |
| 351 scroll_content()->SizeToPreferredSize(); | 352 scroll_content()->SizeToPreferredSize(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 367 ash::UMA_STATUS_AREA_BLUETOOTH_DISABLED : | 368 ash::UMA_STATUS_AREA_BLUETOOTH_DISABLED : |
| 368 ash::UMA_STATUS_AREA_BLUETOOTH_ENABLED); | 369 ash::UMA_STATUS_AREA_BLUETOOTH_ENABLED); |
| 369 delegate->ToggleBluetooth(); | 370 delegate->ToggleBluetooth(); |
| 370 } else { | 371 } else { |
| 371 if (!delegate->GetBluetoothEnabled()) | 372 if (!delegate->GetBluetoothEnabled()) |
| 372 return; | 373 return; |
| 373 std::map<views::View*, std::string>::iterator find; | 374 std::map<views::View*, std::string>::iterator find; |
| 374 find = device_map_.find(sender); | 375 find = device_map_.find(sender); |
| 375 if (find == device_map_.end()) | 376 if (find == device_map_.end()) |
| 376 return; | 377 return; |
| 377 std::string device_id = find->second; | 378 const std::string device_id = find->second; |
| 378 if (FoundDevice(device_id, connecting_devices_, NULL)) | 379 if (FoundDevice(device_id, connecting_devices_, NULL)) |
| 379 return; | 380 return; |
| 380 UpdateClickedDevice(device_id, sender); | 381 UpdateClickedDevice(device_id, sender); |
| 381 delegate->ConnectToBluetoothDevice(device_id); | 382 delegate->ConnectToBluetoothDevice(device_id); |
| 382 } | 383 } |
| 383 } | 384 } |
| 384 | 385 |
| 385 // Overridden from ButtonListener. | 386 // Overridden from ButtonListener. |
| 386 void ButtonPressed(views::Button* sender, const ui::Event& event) override { | 387 void ButtonPressed(views::Button* sender, const ui::Event& event) override { |
| 387 ash::SystemTrayDelegate* delegate = | 388 ash::SystemTrayDelegate* delegate = |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 detailed_->Update(); | 464 detailed_->Update(); |
| 464 } | 465 } |
| 465 | 466 |
| 466 void TrayBluetooth::OnBluetoothDiscoveringChanged() { | 467 void TrayBluetooth::OnBluetoothDiscoveringChanged() { |
| 467 if (!detailed_) | 468 if (!detailed_) |
| 468 return; | 469 return; |
| 469 detailed_->Update(); | 470 detailed_->Update(); |
| 470 } | 471 } |
| 471 | 472 |
| 472 } // namespace ash | 473 } // namespace ash |
| OLD | NEW |