| 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/resources/grit/ash_resources.h" | 7 #include "ash/resources/grit/ash_resources.h" |
| 8 #include "ash/resources/vector_icons/vector_icons.h" | 8 #include "ash/resources/vector_icons/vector_icons.h" |
| 9 #include "ash/session/session_state_delegate.h" | 9 #include "ash/session/session_state_delegate.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/shell_port.h" | 11 #include "ash/shell_port.h" |
| 12 #include "ash/strings/grit/ash_strings.h" | 12 #include "ash/strings/grit/ash_strings.h" |
| 13 #include "ash/system/bluetooth/tray_bluetooth_helper.h" | 13 #include "ash/system/bluetooth/tray_bluetooth_helper.h" |
| 14 #include "ash/system/tray/hover_highlight_view.h" | 14 #include "ash/system/tray/hover_highlight_view.h" |
| 15 #include "ash/system/tray/system_tray.h" | 15 #include "ash/system/tray/system_tray.h" |
| 16 #include "ash/system/tray/system_tray_controller.h" | 16 #include "ash/system/tray/system_tray_controller.h" |
| 17 #include "ash/system/tray/system_tray_notifier.h" | 17 #include "ash/system/tray/system_tray_notifier.h" |
| 18 #include "ash/system/tray/throbber_view.h" | 18 #include "ash/system/tray/throbber_view.h" |
| 19 #include "ash/system/tray/tray_constants.h" | 19 #include "ash/system/tray/tray_constants.h" |
| 20 #include "ash/system/tray/tray_details_view.h" | 20 #include "ash/system/tray/tray_details_view.h" |
| 21 #include "ash/system/tray/tray_item_more.h" | 21 #include "ash/system/tray/tray_item_more.h" |
| 22 #include "ash/system/tray/tray_popup_item_style.h" | 22 #include "ash/system/tray/tray_popup_item_style.h" |
| 23 #include "ash/system/tray/tray_popup_utils.h" | 23 #include "ash/system/tray/tray_popup_utils.h" |
| 24 #include "ash/system/tray/tri_view.h" | 24 #include "ash/system/tray/tri_view.h" |
| 25 #include "device/bluetooth/bluetooth_common.h" | 25 #include "device/bluetooth/bluetooth_common.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "ui/base/resource/resource_bundle.h" | |
| 28 #include "ui/gfx/color_palette.h" | 27 #include "ui/gfx/color_palette.h" |
| 29 #include "ui/gfx/image/image.h" | 28 #include "ui/gfx/image/image.h" |
| 30 #include "ui/gfx/paint_vector_icon.h" | 29 #include "ui/gfx/paint_vector_icon.h" |
| 30 #include "ui/gfx/vector_icon_types.h" |
| 31 #include "ui/views/controls/button/toggle_button.h" | 31 #include "ui/views/controls/button/toggle_button.h" |
| 32 #include "ui/views/controls/image_view.h" | 32 #include "ui/views/controls/image_view.h" |
| 33 #include "ui/views/controls/label.h" | 33 #include "ui/views/controls/label.h" |
| 34 #include "ui/views/controls/progress_bar.h" | 34 #include "ui/views/controls/progress_bar.h" |
| 35 #include "ui/views/controls/scroll_view.h" | 35 #include "ui/views/controls/scroll_view.h" |
| 36 #include "ui/views/controls/separator.h" | 36 #include "ui/views/controls/separator.h" |
| 37 #include "ui/views/layout/box_layout.h" | 37 #include "ui/views/layout/box_layout.h" |
| 38 | 38 |
| 39 namespace ash { | 39 namespace ash { |
| 40 namespace tray { | 40 namespace tray { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } // namespace | 112 } // namespace |
| 113 | 113 |
| 114 class BluetoothDefaultView : public TrayItemMore { | 114 class BluetoothDefaultView : public TrayItemMore { |
| 115 public: | 115 public: |
| 116 explicit BluetoothDefaultView(SystemTrayItem* owner) : TrayItemMore(owner) {} | 116 explicit BluetoothDefaultView(SystemTrayItem* owner) : TrayItemMore(owner) {} |
| 117 ~BluetoothDefaultView() override {} | 117 ~BluetoothDefaultView() override {} |
| 118 | 118 |
| 119 void Update() { | 119 void Update() { |
| 120 TrayBluetoothHelper* helper = Shell::Get()->tray_bluetooth_helper(); | 120 TrayBluetoothHelper* helper = Shell::Get()->tray_bluetooth_helper(); |
| 121 if (helper->GetBluetoothAvailable()) { | 121 if (helper->GetBluetoothAvailable()) { |
| 122 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 122 const base::string16 label = l10n_util::GetStringUTF16( |
| 123 const base::string16 label = | 123 helper->GetBluetoothEnabled() |
| 124 rb.GetLocalizedString(helper->GetBluetoothEnabled() | 124 ? IDS_ASH_STATUS_TRAY_BLUETOOTH_ENABLED |
| 125 ? IDS_ASH_STATUS_TRAY_BLUETOOTH_ENABLED | 125 : IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED); |
| 126 : IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED); | |
| 127 SetLabel(label); | 126 SetLabel(label); |
| 128 SetAccessibleName(label); | 127 SetAccessibleName(label); |
| 129 SetVisible(true); | 128 SetVisible(true); |
| 130 } else { | 129 } else { |
| 131 SetVisible(false); | 130 SetVisible(false); |
| 132 } | 131 } |
| 133 UpdateStyle(); | 132 UpdateStyle(); |
| 134 } | 133 } |
| 135 | 134 |
| 136 protected: | 135 protected: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 156 } | 155 } |
| 157 | 156 |
| 158 private: | 157 private: |
| 159 const gfx::VectorIcon& GetCurrentIcon() { | 158 const gfx::VectorIcon& GetCurrentIcon() { |
| 160 TrayBluetoothHelper* helper = Shell::Get()->tray_bluetooth_helper(); | 159 TrayBluetoothHelper* helper = Shell::Get()->tray_bluetooth_helper(); |
| 161 if (!helper->GetBluetoothEnabled()) | 160 if (!helper->GetBluetoothEnabled()) |
| 162 return kSystemMenuBluetoothDisabledIcon; | 161 return kSystemMenuBluetoothDisabledIcon; |
| 163 | 162 |
| 164 bool has_connected_device = false; | 163 bool has_connected_device = false; |
| 165 BluetoothDeviceList list = helper->GetAvailableBluetoothDevices(); | 164 BluetoothDeviceList list = helper->GetAvailableBluetoothDevices(); |
| 166 for (size_t i = 0; i < list.size(); ++i) { | 165 for (const auto& device : list) { |
| 167 if (list[i].connected) { | 166 if (device.connected) { |
| 168 has_connected_device = true; | 167 has_connected_device = true; |
| 169 break; | 168 break; |
| 170 } | 169 } |
| 171 } | 170 } |
| 172 return has_connected_device ? kSystemMenuBluetoothConnectedIcon | 171 return has_connected_device ? kSystemMenuBluetoothConnectedIcon |
| 173 : kSystemMenuBluetoothIcon; | 172 : kSystemMenuBluetoothIcon; |
| 174 } | 173 } |
| 175 | 174 |
| 176 DISALLOW_COPY_AND_ASSIGN(BluetoothDefaultView); | 175 DISALLOW_COPY_AND_ASSIGN(BluetoothDefaultView); |
| 177 }; | 176 }; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 } | 227 } |
| 229 | 228 |
| 230 void UpdateBluetoothDeviceList() { | 229 void UpdateBluetoothDeviceList() { |
| 231 std::set<std::string> new_connecting_devices; | 230 std::set<std::string> new_connecting_devices; |
| 232 std::set<std::string> new_connected_devices; | 231 std::set<std::string> new_connected_devices; |
| 233 std::set<std::string> new_paired_not_connected_devices; | 232 std::set<std::string> new_paired_not_connected_devices; |
| 234 std::set<std::string> new_discovered_not_paired_devices; | 233 std::set<std::string> new_discovered_not_paired_devices; |
| 235 | 234 |
| 236 BluetoothDeviceList list = | 235 BluetoothDeviceList list = |
| 237 Shell::Get()->tray_bluetooth_helper()->GetAvailableBluetoothDevices(); | 236 Shell::Get()->tray_bluetooth_helper()->GetAvailableBluetoothDevices(); |
| 238 for (size_t i = 0; i < list.size(); ++i) { | 237 for (const auto& device : list) { |
| 239 if (list[i].connecting) { | 238 if (device.connecting) { |
| 240 new_connecting_devices.insert(list[i].address); | 239 new_connecting_devices.insert(device.address); |
| 241 UpdateBluetoothDeviceListHelper(&connecting_devices_, list[i]); | 240 UpdateBluetoothDeviceListHelper(&connecting_devices_, device); |
| 242 } else if (list[i].connected && list[i].paired) { | 241 } else if (device.connected && device.paired) { |
| 243 new_connected_devices.insert(list[i].address); | 242 new_connected_devices.insert(device.address); |
| 244 UpdateBluetoothDeviceListHelper(&connected_devices_, list[i]); | 243 UpdateBluetoothDeviceListHelper(&connected_devices_, device); |
| 245 } else if (list[i].paired) { | 244 } else if (device.paired) { |
| 246 new_paired_not_connected_devices.insert(list[i].address); | 245 new_paired_not_connected_devices.insert(device.address); |
| 247 UpdateBluetoothDeviceListHelper(&paired_not_connected_devices_, | 246 UpdateBluetoothDeviceListHelper(&paired_not_connected_devices_, device); |
| 248 list[i]); | |
| 249 } else { | 247 } else { |
| 250 new_discovered_not_paired_devices.insert(list[i].address); | 248 new_discovered_not_paired_devices.insert(device.address); |
| 251 UpdateBluetoothDeviceListHelper(&discovered_not_paired_devices_, | 249 UpdateBluetoothDeviceListHelper(&discovered_not_paired_devices_, |
| 252 list[i]); | 250 device); |
| 253 } | 251 } |
| 254 } | 252 } |
| 255 RemoveObsoleteBluetoothDevicesFromList(&connecting_devices_, | 253 RemoveObsoleteBluetoothDevicesFromList(&connecting_devices_, |
| 256 new_connecting_devices); | 254 new_connecting_devices); |
| 257 RemoveObsoleteBluetoothDevicesFromList(&connected_devices_, | 255 RemoveObsoleteBluetoothDevicesFromList(&connected_devices_, |
| 258 new_connected_devices); | 256 new_connected_devices); |
| 259 RemoveObsoleteBluetoothDevicesFromList(&paired_not_connected_devices_, | 257 RemoveObsoleteBluetoothDevicesFromList(&paired_not_connected_devices_, |
| 260 new_paired_not_connected_devices); | 258 new_paired_not_connected_devices); |
| 261 RemoveObsoleteBluetoothDevicesFromList(&discovered_not_paired_devices_, | 259 RemoveObsoleteBluetoothDevicesFromList(&discovered_not_paired_devices_, |
| 262 new_discovered_not_paired_devices); | 260 new_discovered_not_paired_devices); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 286 } else { | 284 } else { |
| 287 ShowDisabledPanel(); | 285 ShowDisabledPanel(); |
| 288 return; | 286 return; |
| 289 } | 287 } |
| 290 | 288 |
| 291 // Add paired devices and their section header to the list. | 289 // Add paired devices and their section header to the list. |
| 292 size_t num_paired_devices = connected_devices_.size() + | 290 size_t num_paired_devices = connected_devices_.size() + |
| 293 connecting_devices_.size() + | 291 connecting_devices_.size() + |
| 294 paired_not_connected_devices_.size(); | 292 paired_not_connected_devices_.size(); |
| 295 if (num_paired_devices > 0) { | 293 if (num_paired_devices > 0) { |
| 296 AddSubHeader(IDS_ASH_STATUS_TRAY_BLUETOOTH_PAIRED_DEVICES); | 294 AddScrollListSubHeader(IDS_ASH_STATUS_TRAY_BLUETOOTH_PAIRED_DEVICES); |
| 297 AppendSameTypeDevicesToScrollList(connected_devices_, true, true, | 295 AppendSameTypeDevicesToScrollList(connected_devices_, true, true, |
| 298 bluetooth_enabled); | 296 bluetooth_enabled); |
| 299 AppendSameTypeDevicesToScrollList(connecting_devices_, true, false, | 297 AppendSameTypeDevicesToScrollList(connecting_devices_, true, false, |
| 300 bluetooth_enabled); | 298 bluetooth_enabled); |
| 301 AppendSameTypeDevicesToScrollList(paired_not_connected_devices_, false, | 299 AppendSameTypeDevicesToScrollList(paired_not_connected_devices_, false, |
| 302 false, bluetooth_enabled); | 300 false, bluetooth_enabled); |
| 303 } | 301 } |
| 304 | 302 |
| 305 // Add unpaired devices to the list. If at least one paired device is | 303 // Add unpaired devices to the list. If at least one paired device is |
| 306 // present, also add a section header above the unpaired devices. | 304 // present, also add a section header above the unpaired devices. |
| 307 if (discovered_not_paired_devices_.size() > 0) { | 305 if (discovered_not_paired_devices_.size() > 0) { |
| 308 if (num_paired_devices > 0) | 306 if (num_paired_devices > 0) |
| 309 AddSubHeader(IDS_ASH_STATUS_TRAY_BLUETOOTH_UNPAIRED_DEVICES); | 307 AddScrollListSubHeader(IDS_ASH_STATUS_TRAY_BLUETOOTH_UNPAIRED_DEVICES); |
| 310 AppendSameTypeDevicesToScrollList(discovered_not_paired_devices_, false, | 308 AppendSameTypeDevicesToScrollList(discovered_not_paired_devices_, false, |
| 311 false, bluetooth_enabled); | 309 false, bluetooth_enabled); |
| 312 } | 310 } |
| 313 | 311 |
| 314 // Show user Bluetooth state if there is no bluetooth devices in list. | 312 // Show user Bluetooth state if there is no bluetooth devices in list. |
| 315 if (device_map_.size() == 0 && bluetooth_available && bluetooth_enabled) { | 313 if (device_map_.size() == 0 && bluetooth_available && bluetooth_enabled) { |
| 316 scroll_content()->AddChildView(TrayPopupUtils::CreateInfoLabelRowView( | 314 scroll_content()->AddChildView(TrayPopupUtils::CreateInfoLabelRowView( |
| 317 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERING)); | 315 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERING)); |
| 318 } | 316 } |
| 319 | 317 |
| 320 // Focus the device which was focused before the device-list update. | 318 // Focus the device which was focused before the device-list update. |
| 321 if (!focused_device_address.empty()) | 319 if (!focused_device_address.empty()) |
| 322 FocusDeviceByAddress(focused_device_address); | 320 FocusDeviceByAddress(focused_device_address); |
| 323 | 321 |
| 324 scroll_content()->InvalidateLayout(); | 322 scroll_content()->InvalidateLayout(); |
| 325 } | 323 } |
| 326 | 324 |
| 327 void AppendSameTypeDevicesToScrollList(const BluetoothDeviceList& list, | 325 void AppendSameTypeDevicesToScrollList(const BluetoothDeviceList& list, |
| 328 bool highlight, | 326 bool highlight, |
| 329 bool checked, | 327 bool checked, |
| 330 bool enabled) { | 328 bool enabled) { |
| 331 for (size_t i = 0; i < list.size(); ++i) { | 329 for (const auto& device : list) { |
| 332 HoverHighlightView* container = nullptr; | 330 const gfx::VectorIcon& icon = |
| 333 gfx::ImageSkia icon_image = CreateVectorIcon( | 331 GetBluetoothDeviceIcon(device.device_type, device.connected); |
| 334 GetBluetoothDeviceIcon(list[i].device_type, list[i].connected), | 332 HoverHighlightView* container = |
| 335 kMenuIconColor); | 333 AddScrollListItem(icon, device.display_name); |
| 336 container = AddScrollListItem(list[i].display_name, icon_image, | 334 if (device.connected) |
| 337 list[i].connected, list[i].connecting); | 335 SetupConnectedItem(container); |
| 338 device_map_[container] = list[i].address; | 336 else if (device.connecting) |
| 337 SetupConnectingItem(container); |
| 338 device_map_[container] = device.address; |
| 339 } | 339 } |
| 340 } | 340 } |
| 341 | 341 |
| 342 HoverHighlightView* AddScrollListItem(const base::string16& text, | 342 void SetupConnectedItem(HoverHighlightView* container) { |
| 343 const gfx::ImageSkia& image, | 343 container->SetSubText(l10n_util::GetStringUTF16( |
| 344 bool connected, | 344 IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTED)); |
| 345 bool connecting) { | |
| 346 HoverHighlightView* container = new HoverHighlightView(this); | |
| 347 if (connected) { | |
| 348 SetupConnectedItem(container, text, image); | |
| 349 } else if (connecting) { | |
| 350 SetupConnectingItem(container, text, image); | |
| 351 } else { | |
| 352 container->AddIconAndLabel(image, text); | |
| 353 } | |
| 354 scroll_content()->AddChildView(container); | |
| 355 return container; | |
| 356 } | |
| 357 | |
| 358 void AddSubHeader(int message_id) { | |
| 359 TriView* header = TrayPopupUtils::CreateSubHeaderRowView(); | |
| 360 TrayPopupUtils::ConfigureAsStickyHeader(header); | |
| 361 | |
| 362 views::Label* label = TrayPopupUtils::CreateDefaultLabel(); | |
| 363 label->SetText(l10n_util::GetStringUTF16(message_id)); | |
| 364 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SUB_HEADER); | |
| 365 style.SetupLabel(label); | |
| 366 header->AddView(TriView::Container::CENTER, label); | |
| 367 | |
| 368 scroll_content()->AddChildView(header); | |
| 369 } | |
| 370 | |
| 371 void SetupConnectedItem(HoverHighlightView* container, | |
| 372 const base::string16& text, | |
| 373 const gfx::ImageSkia& image) { | |
| 374 container->AddIconAndLabels( | |
| 375 image, text, l10n_util::GetStringUTF16( | |
| 376 IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTED)); | |
| 377 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::CAPTION); | 345 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::CAPTION); |
| 378 style.set_color_style(TrayPopupItemStyle::ColorStyle::CONNECTED); | 346 style.set_color_style(TrayPopupItemStyle::ColorStyle::CONNECTED); |
| 379 style.SetupLabel(container->sub_text_label()); | 347 style.SetupLabel(container->sub_text_label()); |
| 380 } | 348 } |
| 381 | 349 |
| 382 void SetupConnectingItem(HoverHighlightView* container, | 350 void SetupConnectingItem(HoverHighlightView* container) { |
| 383 const base::string16& text, | 351 container->SetSubText(l10n_util::GetStringUTF16( |
| 384 const gfx::ImageSkia& image) { | 352 IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTING)); |
| 385 container->AddIconAndLabels( | |
| 386 image, text, l10n_util::GetStringUTF16( | |
| 387 IDS_ASH_STATUS_TRAY_NETWORK_STATUS_CONNECTING)); | |
| 388 ThrobberView* throbber = new ThrobberView; | 353 ThrobberView* throbber = new ThrobberView; |
| 389 throbber->Start(); | 354 throbber->Start(); |
| 390 container->AddRightView(throbber); | 355 container->AddRightView(throbber); |
| 391 } | 356 } |
| 392 | 357 |
| 393 // Returns true if the device with |device_id| is found in |device_list|, | 358 // Returns true if the device with |device_id| is found in |device_list|. |
| 394 // and the display_name of the device will be returned in |display_name| if | |
| 395 // it's not NULL. | |
| 396 bool FoundDevice(const std::string& device_id, | 359 bool FoundDevice(const std::string& device_id, |
| 397 const BluetoothDeviceList& device_list, | 360 const BluetoothDeviceList& device_list) { |
| 398 base::string16* display_name, | 361 for (const auto& device : device_list) { |
| 399 device::BluetoothDeviceType* device_type) { | 362 if (device.address == device_id) |
| 400 for (size_t i = 0; i < device_list.size(); ++i) { | |
| 401 if (device_list[i].address == device_id) { | |
| 402 if (display_name) | |
| 403 *display_name = device_list[i].display_name; | |
| 404 if (device_type) | |
| 405 *device_type = device_list[i].device_type; | |
| 406 return true; | 363 return true; |
| 407 } | |
| 408 } | 364 } |
| 409 return false; | 365 return false; |
| 410 } | 366 } |
| 411 | 367 |
| 412 // Updates UI of the clicked bluetooth device to show it is being connected | 368 // Updates UI of the clicked bluetooth device to show it is being connected |
| 413 // or disconnected if such an operation is going to be performed underway. | 369 // or disconnected if such an operation is going to be performed underway. |
| 414 void UpdateClickedDevice(const std::string& device_id, | 370 void UpdateClickedDevice(const std::string& device_id, |
| 415 views::View* item_container) { | 371 views::View* item_container) { |
| 416 base::string16 display_name; | 372 if (FoundDevice(device_id, paired_not_connected_devices_)) { |
| 417 device::BluetoothDeviceType device_type; | |
| 418 if (FoundDevice(device_id, paired_not_connected_devices_, &display_name, | |
| 419 &device_type)) { | |
| 420 item_container->RemoveAllChildViews(true); | |
| 421 HoverHighlightView* container = | 373 HoverHighlightView* container = |
| 422 static_cast<HoverHighlightView*>(item_container); | 374 static_cast<HoverHighlightView*>(item_container); |
| 423 TrayPopupItemStyle style( | 375 SetupConnectingItem(container); |
| 424 TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL); | |
| 425 gfx::ImageSkia icon_image = CreateVectorIcon( | |
| 426 GetBluetoothDeviceIcon(device_type, false), style.GetIconColor()); | |
| 427 SetupConnectingItem(container, display_name, icon_image); | |
| 428 scroll_content()->SizeToPreferredSize(); | 376 scroll_content()->SizeToPreferredSize(); |
| 429 scroller()->Layout(); | 377 scroller()->Layout(); |
| 430 } | 378 } |
| 431 } | 379 } |
| 432 | 380 |
| 433 // TrayDetailsView: | 381 // TrayDetailsView: |
| 434 void HandleViewClicked(views::View* view) override { | 382 void HandleViewClicked(views::View* view) override { |
| 435 TrayBluetoothHelper* helper = Shell::Get()->tray_bluetooth_helper(); | 383 TrayBluetoothHelper* helper = Shell::Get()->tray_bluetooth_helper(); |
| 436 if (!helper->GetBluetoothEnabled()) | 384 if (!helper->GetBluetoothEnabled()) |
| 437 return; | 385 return; |
| 438 | 386 |
| 439 std::map<views::View*, std::string>::iterator find; | 387 std::map<views::View*, std::string>::iterator find; |
| 440 find = device_map_.find(view); | 388 find = device_map_.find(view); |
| 441 if (find == device_map_.end()) | 389 if (find == device_map_.end()) |
| 442 return; | 390 return; |
| 443 | 391 |
| 444 const std::string device_id = find->second; | 392 const std::string device_id = find->second; |
| 445 if (FoundDevice(device_id, connecting_devices_, nullptr, nullptr)) | 393 if (FoundDevice(device_id, connecting_devices_)) |
| 446 return; | 394 return; |
| 447 | 395 |
| 448 UpdateClickedDevice(device_id, view); | 396 UpdateClickedDevice(device_id, view); |
| 449 helper->ConnectToBluetoothDevice(device_id); | 397 helper->ConnectToBluetoothDevice(device_id); |
| 450 } | 398 } |
| 451 | 399 |
| 452 void HandleButtonPressed(views::Button* sender, | 400 void HandleButtonPressed(views::Button* sender, |
| 453 const ui::Event& event) override { | 401 const ui::Event& event) override { |
| 454 if (sender == toggle_) { | 402 if (sender == toggle_) { |
| 455 TrayBluetoothHelper* helper = Shell::Get()->tray_bluetooth_helper(); | 403 TrayBluetoothHelper* helper = Shell::Get()->tray_bluetooth_helper(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL); | 477 TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL); |
| 530 style.set_color_style(TrayPopupItemStyle::ColorStyle::DISABLED); | 478 style.set_color_style(TrayPopupItemStyle::ColorStyle::DISABLED); |
| 531 | 479 |
| 532 views::ImageView* image_view = new views::ImageView; | 480 views::ImageView* image_view = new views::ImageView; |
| 533 image_view->SetImage(gfx::CreateVectorIcon(kSystemMenuBluetoothDisabledIcon, | 481 image_view->SetImage(gfx::CreateVectorIcon(kSystemMenuBluetoothDisabledIcon, |
| 534 style.GetIconColor())); | 482 style.GetIconColor())); |
| 535 image_view->SetVerticalAlignment(views::ImageView::TRAILING); | 483 image_view->SetVerticalAlignment(views::ImageView::TRAILING); |
| 536 container->AddChildView(image_view); | 484 container->AddChildView(image_view); |
| 537 | 485 |
| 538 views::Label* label = new views::Label( | 486 views::Label* label = new views::Label( |
| 539 ui::ResourceBundle::GetSharedInstance().GetLocalizedString( | 487 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED)); |
| 540 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED)); | |
| 541 style.SetupLabel(label); | 488 style.SetupLabel(label); |
| 542 label->SetBorder(views::CreateEmptyBorder( | 489 label->SetBorder(views::CreateEmptyBorder( |
| 543 kDisabledPanelLabelBaselineY - label->GetBaseline(), 0, 0, 0)); | 490 kDisabledPanelLabelBaselineY - label->GetBaseline(), 0, 0, 0)); |
| 544 container->AddChildView(label); | 491 container->AddChildView(label); |
| 545 | 492 |
| 546 // Make top padding of the icon equal to the height of the label so that the | 493 // Make top padding of the icon equal to the height of the label so that the |
| 547 // icon is vertically aligned to center of the container. | 494 // icon is vertically aligned to center of the container. |
| 548 image_view->SetBorder( | 495 image_view->SetBorder( |
| 549 views::CreateEmptyBorder(label->GetPreferredSize().height(), 0, 0, 0)); | 496 views::CreateEmptyBorder(label->GetPreferredSize().height(), 0, 0, 0)); |
| 550 return container; | 497 return container; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 detailed_->Update(); | 589 detailed_->Update(); |
| 643 } | 590 } |
| 644 | 591 |
| 645 void TrayBluetooth::OnBluetoothDiscoveringChanged() { | 592 void TrayBluetooth::OnBluetoothDiscoveringChanged() { |
| 646 if (!detailed_) | 593 if (!detailed_) |
| 647 return; | 594 return; |
| 648 detailed_->Update(); | 595 detailed_->Update(); |
| 649 } | 596 } |
| 650 | 597 |
| 651 } // namespace ash | 598 } // namespace ash |
| OLD | NEW |