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

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

Issue 12180027: Add spinner UI to show bluetooth is discovering devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a subclass of SmoothedThrobber and override GetTooltipText to show tooltip on throbber. Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ash/system/tray/tray_views.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/tray/system_tray.h" 8 #include "ash/system/tray/system_tray.h"
9 #include "ash/system/tray/system_tray_delegate.h" 9 #include "ash/system/tray/system_tray_delegate.h"
10 #include "ash/system/tray/system_tray_notifier.h" 10 #include "ash/system/tray/system_tray_notifier.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 void CreateItems() { 96 void CreateItems() {
97 CreateScrollableList(); 97 CreateScrollableList();
98 AppendSettingsEntries(); 98 AppendSettingsEntries();
99 AppendHeaderEntry(); 99 AppendHeaderEntry();
100 } 100 }
101 101
102 void BluetoothStartDiscovering() { 102 void BluetoothStartDiscovering() {
103 ash::SystemTrayDelegate* delegate = 103 ash::SystemTrayDelegate* delegate =
104 ash::Shell::GetInstance()->system_tray_delegate(); 104 ash::Shell::GetInstance()->system_tray_delegate();
105 bool bluetooth_enabled = delegate->GetBluetoothEnabled(); 105 bool bluetooth_enabled = delegate->GetBluetoothEnabled();
106 if (!bluetooth_discovering_ && bluetooth_enabled) 106 if (!bluetooth_discovering_ && bluetooth_enabled) {
107 delegate->BluetoothStartDiscovering(); 107 delegate->BluetoothStartDiscovering();
108 throbber_->Start();
109 } else if(!bluetooth_enabled) {
110 throbber_->Stop();
111 }
108 bluetooth_discovering_ = bluetooth_enabled; 112 bluetooth_discovering_ = bluetooth_enabled;
109 } 113 }
110 114
111 void BluetoothStopDiscovering() { 115 void BluetoothStopDiscovering() {
112 ash::SystemTrayDelegate* delegate = 116 ash::SystemTrayDelegate* delegate =
113 ash::Shell::GetInstance()->system_tray_delegate(); 117 ash::Shell::GetInstance()->system_tray_delegate();
114 if (bluetooth_discovering_) { 118 if (bluetooth_discovering_) {
115 bluetooth_discovering_ = false; 119 bluetooth_discovering_ = false;
116 delegate->BluetoothStopDiscovering(); 120 delegate->BluetoothStopDiscovering();
121 throbber_->Stop();
117 } 122 }
118 } 123 }
119 124
120 void UpdateBlueToothDeviceList() { 125 void UpdateBlueToothDeviceList() {
121 connected_devices_.clear(); 126 connected_devices_.clear();
122 paired_not_connected_devices_.clear(); 127 paired_not_connected_devices_.clear();
123 discovered_not_paired_devices_.clear(); 128 discovered_not_paired_devices_.clear();
124 BluetoothDeviceList list; 129 BluetoothDeviceList list;
125 Shell::GetInstance()->system_tray_delegate()-> 130 Shell::GetInstance()->system_tray_delegate()->
126 GetAvailableBluetoothDevices(&list); 131 GetAvailableBluetoothDevices(&list);
127 for (size_t i = 0; i < list.size(); ++i) { 132 for (size_t i = 0; i < list.size(); ++i) {
128 if (list[i].connected) 133 if (list[i].connected)
129 connected_devices_.push_back(list[i]); 134 connected_devices_.push_back(list[i]);
130 else if (list[i].paired) 135 else if (list[i].paired)
131 paired_not_connected_devices_.push_back(list[i]); 136 paired_not_connected_devices_.push_back(list[i]);
132 else if (list[i].visible) 137 else if (list[i].visible)
133 discovered_not_paired_devices_.push_back(list[i]); 138 discovered_not_paired_devices_.push_back(list[i]);
134 } 139 }
135 } 140 }
136 141
137 void AppendHeaderEntry() { 142 void AppendHeaderEntry() {
138 CreateSpecialRow(IDS_ASH_STATUS_TRAY_BLUETOOTH, this); 143 CreateSpecialRow(IDS_ASH_STATUS_TRAY_BLUETOOTH, this);
139 144
140 if (login_ == user::LOGGED_IN_LOCKED) 145 if (login_ == user::LOGGED_IN_LOCKED)
141 return; 146 return;
142 147
148 throbber_ = new ThrobberView;
149 throbber_->SetTooltipText(
150 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERING));
151 footer()->AddThrobber(throbber_);
152
143 // Do not allow toggling bluetooth in the lock screen. 153 // Do not allow toggling bluetooth in the lock screen.
144 ash::SystemTrayDelegate* delegate = 154 ash::SystemTrayDelegate* delegate =
145 ash::Shell::GetInstance()->system_tray_delegate(); 155 ash::Shell::GetInstance()->system_tray_delegate();
146 toggle_bluetooth_ = new TrayPopupHeaderButton(this, 156 toggle_bluetooth_ = new TrayPopupHeaderButton(this,
147 IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED, 157 IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED,
148 IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED, 158 IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED,
149 IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED_HOVER, 159 IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED_HOVER,
150 IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED_HOVER, 160 IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED_HOVER,
151 IDS_ASH_STATUS_TRAY_BLUETOOTH); 161 IDS_ASH_STATUS_TRAY_BLUETOOTH);
152 toggle_bluetooth_->SetToggled(!delegate->GetBluetoothEnabled()); 162 toggle_bluetooth_->SetToggled(!delegate->GetBluetoothEnabled());
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 if (sender == toggle_bluetooth_) 325 if (sender == toggle_bluetooth_)
316 delegate->ToggleBluetooth(); 326 delegate->ToggleBluetooth();
317 else 327 else
318 NOTREACHED(); 328 NOTREACHED();
319 } 329 }
320 330
321 user::LoginStatus login_; 331 user::LoginStatus login_;
322 332
323 std::map<views::View*, std::string> device_map_; 333 std::map<views::View*, std::string> device_map_;
324 views::View* add_device_; 334 views::View* add_device_;
335 ThrobberView* throbber_;
325 TrayPopupHeaderButton* toggle_bluetooth_; 336 TrayPopupHeaderButton* toggle_bluetooth_;
326 HoverHighlightView* enable_bluetooth_; 337 HoverHighlightView* enable_bluetooth_;
327 BluetoothDeviceList connected_devices_; 338 BluetoothDeviceList connected_devices_;
328 BluetoothDeviceList paired_not_connected_devices_; 339 BluetoothDeviceList paired_not_connected_devices_;
329 BluetoothDeviceList discovered_not_paired_devices_; 340 BluetoothDeviceList discovered_not_paired_devices_;
330 bool bluetooth_discovering_; 341 bool bluetooth_discovering_;
331 342
332 DISALLOW_COPY_AND_ASSIGN(BluetoothDetailedView); 343 DISALLOW_COPY_AND_ASSIGN(BluetoothDetailedView);
333 }; 344 };
334 345
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 } 396 }
386 397
387 void TrayBluetooth::OnBluetoothDiscoveringChanged() { 398 void TrayBluetooth::OnBluetoothDiscoveringChanged() {
388 if (!detailed_) 399 if (!detailed_)
389 return; 400 return;
390 detailed_->Update(); 401 detailed_->Update();
391 } 402 }
392 403
393 } // namespace internal 404 } // namespace internal
394 } // namespace ash 405 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/system/tray/tray_views.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698