Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: ash/system/bluetooth/tray_bluetooth.cc

Issue 2831023003: Refactor AddScrollListItem() in system menu detailed views (Closed)
Patch Set: Cleanup Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(
tdanderson 2017/04/24 15:43:39 Thanks for the extra little fixes such as this thr
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
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
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
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 const base::string16 text = l10n_util::GetStringUTF16(
295 IDS_ASH_STATUS_TRAY_BLUETOOTH_PAIRED_DEVICES);
296 AddScrollListSubHeader(gfx::kNoneIcon, text);
297 AppendSameTypeDevicesToScrollList(connected_devices_, true, true, 297 AppendSameTypeDevicesToScrollList(connected_devices_, true, true,
298 bluetooth_enabled); 298 bluetooth_enabled);
299 AppendSameTypeDevicesToScrollList(connecting_devices_, true, false, 299 AppendSameTypeDevicesToScrollList(connecting_devices_, true, false,
300 bluetooth_enabled); 300 bluetooth_enabled);
301 AppendSameTypeDevicesToScrollList(paired_not_connected_devices_, false, 301 AppendSameTypeDevicesToScrollList(paired_not_connected_devices_, false,
302 false, bluetooth_enabled); 302 false, bluetooth_enabled);
303 } 303 }
304 304
305 // Add unpaired devices to the list. If at least one paired device is 305 // Add unpaired devices to the list. If at least one paired device is
306 // present, also add a section header above the unpaired devices. 306 // present, also add a section header above the unpaired devices.
307 if (discovered_not_paired_devices_.size() > 0) { 307 if (discovered_not_paired_devices_.size() > 0) {
308 if (num_paired_devices > 0) 308 if (num_paired_devices > 0) {
309 AddSubHeader(IDS_ASH_STATUS_TRAY_BLUETOOTH_UNPAIRED_DEVICES); 309 const base::string16 text = l10n_util::GetStringUTF16(
310 IDS_ASH_STATUS_TRAY_BLUETOOTH_UNPAIRED_DEVICES);
311 AddScrollListSubHeader(gfx::kNoneIcon, text);
312 }
310 AppendSameTypeDevicesToScrollList(discovered_not_paired_devices_, false, 313 AppendSameTypeDevicesToScrollList(discovered_not_paired_devices_, false,
311 false, bluetooth_enabled); 314 false, bluetooth_enabled);
312 } 315 }
313 316
314 // Show user Bluetooth state if there is no bluetooth devices in list. 317 // Show user Bluetooth state if there is no bluetooth devices in list.
315 if (device_map_.size() == 0 && bluetooth_available && bluetooth_enabled) { 318 if (device_map_.size() == 0 && bluetooth_available && bluetooth_enabled) {
316 scroll_content()->AddChildView(TrayPopupUtils::CreateInfoLabelRowView( 319 scroll_content()->AddChildView(TrayPopupUtils::CreateInfoLabelRowView(
317 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERING)); 320 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERING));
318 } 321 }
319 322
320 // Focus the device which was focused before the device-list update. 323 // Focus the device which was focused before the device-list update.
321 if (!focused_device_address.empty()) 324 if (!focused_device_address.empty())
322 FocusDeviceByAddress(focused_device_address); 325 FocusDeviceByAddress(focused_device_address);
323 326
324 scroll_content()->InvalidateLayout(); 327 scroll_content()->InvalidateLayout();
325 } 328 }
326 329
327 void AppendSameTypeDevicesToScrollList(const BluetoothDeviceList& list, 330 void AppendSameTypeDevicesToScrollList(const BluetoothDeviceList& list,
328 bool highlight, 331 bool highlight,
329 bool checked, 332 bool checked,
330 bool enabled) { 333 bool enabled) {
331 for (size_t i = 0; i < list.size(); ++i) { 334 for (const auto& device : list) {
332 HoverHighlightView* container = nullptr; 335 const gfx::VectorIcon& icon =
333 gfx::ImageSkia icon_image = CreateVectorIcon( 336 GetBluetoothDeviceIcon(device.device_type, device.connected);
334 GetBluetoothDeviceIcon(list[i].device_type, list[i].connected), 337 HoverHighlightView* container =
335 kMenuIconColor); 338 AddScrollListItem(icon, device.display_name);
336 container = AddScrollListItem(list[i].display_name, icon_image, 339 if (device.connected)
337 list[i].connected, list[i].connecting); 340 SetupConnectedItem(container);
338 device_map_[container] = list[i].address; 341 else if (device.connecting)
342 SetupConnectingItem(container);
343 device_map_[container] = device.address;
339 } 344 }
340 } 345 }
341 346
342 HoverHighlightView* AddScrollListItem(const base::string16& text, 347 void SetupConnectedItem(HoverHighlightView* container) {
343 const gfx::ImageSkia& image, 348 container->SetSubText(l10n_util::GetStringUTF16(
344 bool connected, 349 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); 350 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::CAPTION);
378 style.set_color_style(TrayPopupItemStyle::ColorStyle::CONNECTED); 351 style.set_color_style(TrayPopupItemStyle::ColorStyle::CONNECTED);
379 style.SetupLabel(container->sub_text_label()); 352 style.SetupLabel(container->sub_text_label());
380 } 353 }
381 354
382 void SetupConnectingItem(HoverHighlightView* container, 355 void SetupConnectingItem(HoverHighlightView* container) {
383 const base::string16& text, 356 container->SetSubText(l10n_util::GetStringUTF16(
384 const gfx::ImageSkia& image) { 357 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; 358 ThrobberView* throbber = new ThrobberView;
389 throbber->Start(); 359 throbber->Start();
390 container->AddRightView(throbber); 360 container->AddRightView(throbber);
391 } 361 }
392 362
393 // Returns true if the device with |device_id| is found in |device_list|, 363 // 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, 364 bool FoundDevice(const std::string& device_id,
397 const BluetoothDeviceList& device_list, 365 const BluetoothDeviceList& device_list) {
398 base::string16* display_name, 366 for (const auto& device : device_list) {
399 device::BluetoothDeviceType* device_type) { 367 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)
tdanderson 2017/04/24 15:43:39 I am slightly uneasy about removing this logic alo
mohsen 2017/04/25 05:10:01 If a device name is changed, it would be updated i
tdanderson 2017/04/25 14:32:48 OK, that makes sense. I'd be ok landing as-is. But
403 *display_name = device_list[i].display_name;
404 if (device_type)
405 *device_type = device_list[i].device_type;
406 return true; 368 return true;
407 }
408 } 369 }
409 return false; 370 return false;
410 } 371 }
411 372
412 // Updates UI of the clicked bluetooth device to show it is being connected 373 // 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. 374 // or disconnected if such an operation is going to be performed underway.
414 void UpdateClickedDevice(const std::string& device_id, 375 void UpdateClickedDevice(const std::string& device_id,
415 views::View* item_container) { 376 views::View* item_container) {
416 base::string16 display_name; 377 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 = 378 HoverHighlightView* container =
422 static_cast<HoverHighlightView*>(item_container); 379 static_cast<HoverHighlightView*>(item_container);
423 TrayPopupItemStyle style( 380 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(); 381 scroll_content()->SizeToPreferredSize();
429 scroller()->Layout(); 382 scroller()->Layout();
430 } 383 }
431 } 384 }
432 385
433 // TrayDetailsView: 386 // TrayDetailsView:
434 void HandleViewClicked(views::View* view) override { 387 void HandleViewClicked(views::View* view) override {
435 TrayBluetoothHelper* helper = Shell::Get()->tray_bluetooth_helper(); 388 TrayBluetoothHelper* helper = Shell::Get()->tray_bluetooth_helper();
436 if (!helper->GetBluetoothEnabled()) 389 if (!helper->GetBluetoothEnabled())
437 return; 390 return;
438 391
439 std::map<views::View*, std::string>::iterator find; 392 std::map<views::View*, std::string>::iterator find;
440 find = device_map_.find(view); 393 find = device_map_.find(view);
441 if (find == device_map_.end()) 394 if (find == device_map_.end())
442 return; 395 return;
443 396
444 const std::string device_id = find->second; 397 const std::string device_id = find->second;
445 if (FoundDevice(device_id, connecting_devices_, nullptr, nullptr)) 398 if (FoundDevice(device_id, connecting_devices_))
446 return; 399 return;
447 400
448 UpdateClickedDevice(device_id, view); 401 UpdateClickedDevice(device_id, view);
449 helper->ConnectToBluetoothDevice(device_id); 402 helper->ConnectToBluetoothDevice(device_id);
450 } 403 }
451 404
452 void HandleButtonPressed(views::Button* sender, 405 void HandleButtonPressed(views::Button* sender,
453 const ui::Event& event) override { 406 const ui::Event& event) override {
454 if (sender == toggle_) { 407 if (sender == toggle_) {
455 TrayBluetoothHelper* helper = Shell::Get()->tray_bluetooth_helper(); 408 TrayBluetoothHelper* helper = Shell::Get()->tray_bluetooth_helper();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL); 482 TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL);
530 style.set_color_style(TrayPopupItemStyle::ColorStyle::DISABLED); 483 style.set_color_style(TrayPopupItemStyle::ColorStyle::DISABLED);
531 484
532 views::ImageView* image_view = new views::ImageView; 485 views::ImageView* image_view = new views::ImageView;
533 image_view->SetImage(gfx::CreateVectorIcon(kSystemMenuBluetoothDisabledIcon, 486 image_view->SetImage(gfx::CreateVectorIcon(kSystemMenuBluetoothDisabledIcon,
534 style.GetIconColor())); 487 style.GetIconColor()));
535 image_view->SetVerticalAlignment(views::ImageView::TRAILING); 488 image_view->SetVerticalAlignment(views::ImageView::TRAILING);
536 container->AddChildView(image_view); 489 container->AddChildView(image_view);
537 490
538 views::Label* label = new views::Label( 491 views::Label* label = new views::Label(
539 ui::ResourceBundle::GetSharedInstance().GetLocalizedString( 492 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED));
540 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISABLED));
541 style.SetupLabel(label); 493 style.SetupLabel(label);
542 label->SetBorder(views::CreateEmptyBorder( 494 label->SetBorder(views::CreateEmptyBorder(
543 kDisabledPanelLabelBaselineY - label->GetBaseline(), 0, 0, 0)); 495 kDisabledPanelLabelBaselineY - label->GetBaseline(), 0, 0, 0));
544 container->AddChildView(label); 496 container->AddChildView(label);
545 497
546 // Make top padding of the icon equal to the height of the label so that the 498 // 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. 499 // icon is vertically aligned to center of the container.
548 image_view->SetBorder( 500 image_view->SetBorder(
549 views::CreateEmptyBorder(label->GetPreferredSize().height(), 0, 0, 0)); 501 views::CreateEmptyBorder(label->GetPreferredSize().height(), 0, 0, 0));
550 return container; 502 return container;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 detailed_->Update(); 594 detailed_->Update();
643 } 595 }
644 596
645 void TrayBluetooth::OnBluetoothDiscoveringChanged() { 597 void TrayBluetooth::OnBluetoothDiscoveringChanged() {
646 if (!detailed_) 598 if (!detailed_)
647 return; 599 return;
648 detailed_->Update(); 600 detailed_->Update();
649 } 601 }
650 602
651 } // namespace ash 603 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698