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

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

Issue 12385064: Introduce 'connecting' field to bluetooth device info for system tray (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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
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/hover_highlight_view.h" 8 #include "ash/system/tray/hover_highlight_view.h"
9 #include "ash/system/tray/system_tray.h" 9 #include "ash/system/tray/system_tray.h"
10 #include "ash/system/tray/system_tray_delegate.h" 10 #include "ash/system/tray/system_tray_delegate.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 ash::Shell::GetInstance()->system_tray_delegate(); 118 ash::Shell::GetInstance()->system_tray_delegate();
119 if (delegate && bluetooth_discovering_) { 119 if (delegate && bluetooth_discovering_) {
120 bluetooth_discovering_ = false; 120 bluetooth_discovering_ = false;
121 delegate->BluetoothStopDiscovering(); 121 delegate->BluetoothStopDiscovering();
122 throbber_->Stop(); 122 throbber_->Stop();
123 } 123 }
124 } 124 }
125 125
126 void UpdateBlueToothDeviceList() { 126 void UpdateBlueToothDeviceList() {
127 connected_devices_.clear(); 127 connected_devices_.clear();
128 connecting_devices_.clear();
128 paired_not_connected_devices_.clear(); 129 paired_not_connected_devices_.clear();
129 discovered_not_paired_devices_.clear(); 130 discovered_not_paired_devices_.clear();
130 BluetoothDeviceList list; 131 BluetoothDeviceList list;
131 Shell::GetInstance()->system_tray_delegate()-> 132 Shell::GetInstance()->system_tray_delegate()->
132 GetAvailableBluetoothDevices(&list); 133 GetAvailableBluetoothDevices(&list);
133 for (size_t i = 0; i < list.size(); ++i) { 134 for (size_t i = 0; i < list.size(); ++i) {
134 if (list[i].connected) 135 if (list[i].connected)
135 connected_devices_.push_back(list[i]); 136 connected_devices_.push_back(list[i]);
137 else if (list[i].connecting)
deymo 2013/03/02 02:31:13 If the property IsConnecting() is true the device
Jun Mukai 2013/04/09 03:15:08 Done.
138 connecting_devices_.push_back(list[i]);
136 else if (list[i].paired) 139 else if (list[i].paired)
137 paired_not_connected_devices_.push_back(list[i]); 140 paired_not_connected_devices_.push_back(list[i]);
138 else if (list[i].visible) 141 else if (list[i].visible)
139 discovered_not_paired_devices_.push_back(list[i]); 142 discovered_not_paired_devices_.push_back(list[i]);
140 } 143 }
141 } 144 }
142 145
143 void AppendHeaderEntry() { 146 void AppendHeaderEntry() {
144 CreateSpecialRow(IDS_ASH_STATUS_TRAY_BLUETOOTH, this); 147 CreateSpecialRow(IDS_ASH_STATUS_TRAY_BLUETOOTH, this);
145 148
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 toggle_bluetooth_) { 192 toggle_bluetooth_) {
190 enable_bluetooth_ = 193 enable_bluetooth_ =
191 AddScrollListItem( 194 AddScrollListItem(
192 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ENABLE_BLUETOOTH), 195 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ENABLE_BLUETOOTH),
193 gfx::Font::NORMAL, false, true); 196 gfx::Font::NORMAL, false, true);
194 } 197 }
195 198
196 AppendSameTypeDevicesToScrollList( 199 AppendSameTypeDevicesToScrollList(
197 connected_devices_, true, true, bluetooth_enabled); 200 connected_devices_, true, true, bluetooth_enabled);
198 AppendSameTypeDevicesToScrollList( 201 AppendSameTypeDevicesToScrollList(
202 connecting_devices_, true, false, bluetooth_enabled);
203 AppendSameTypeDevicesToScrollList(
199 paired_not_connected_devices_, false, false, bluetooth_enabled); 204 paired_not_connected_devices_, false, false, bluetooth_enabled);
200 if (discovered_not_paired_devices_.size() > 0) 205 if (discovered_not_paired_devices_.size() > 0)
201 AddScrollSeparator(); 206 AddScrollSeparator();
202 AppendSameTypeDevicesToScrollList( 207 AppendSameTypeDevicesToScrollList(
203 discovered_not_paired_devices_, false, false, bluetooth_enabled); 208 discovered_not_paired_devices_, false, false, bluetooth_enabled);
204 209
205 // Show user Bluetooth state if there is no bluetooth devices in list. 210 // Show user Bluetooth state if there is no bluetooth devices in list.
206 if (device_map_.size() == 0) { 211 if (device_map_.size() == 0) {
207 if (blueooth_available && bluetooth_enabled) { 212 if (blueooth_available && bluetooth_enabled) {
208 AddScrollListItem( 213 AddScrollListItem(
209 l10n_util::GetStringUTF16( 214 l10n_util::GetStringUTF16(
210 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERING), 215 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERING),
211 gfx::Font::NORMAL, false, true); 216 gfx::Font::NORMAL, false, true);
212 } 217 }
213 } 218 }
214 219
215 scroll_content()->SizeToPreferredSize(); 220 scroll_content()->SizeToPreferredSize();
216 static_cast<views::View*>(scroller())->Layout(); 221 static_cast<views::View*>(scroller())->Layout();
217 } 222 }
218 223
219 void AppendSameTypeDevicesToScrollList(const BluetoothDeviceList& list, 224 void AppendSameTypeDevicesToScrollList(const BluetoothDeviceList& list,
220 bool bold, 225 bool bold,
221 bool checked, 226 bool checked,
222 bool enabled) { 227 bool enabled) {
223 for (size_t i = 0; i < list.size(); ++i) { 228 for (size_t i = 0; i < list.size(); ++i) {
229 string16 display_name = list[i].display_name;
230 if (list[i].connecting) {
231 display_name = l10n_util::GetStringFUTF16(
232 IDS_ASH_STATUS_TRAY_BLUETOOTH_CONNECTING, display_name);
233 }
224 HoverHighlightView* container = AddScrollListItem( 234 HoverHighlightView* container = AddScrollListItem(
225 list[i].display_name, 235 display_name,
226 bold? gfx::Font::BOLD : gfx::Font::NORMAL, 236 bold? gfx::Font::BOLD : gfx::Font::NORMAL,
227 checked, enabled); 237 checked, enabled);
228 device_map_[container] = list[i].address; 238 device_map_[container] = list[i].address;
229 } 239 }
230 } 240 }
231 241
232 HoverHighlightView* AddScrollListItem(const string16& text, 242 HoverHighlightView* AddScrollListItem(const string16& text,
233 gfx::Font::FontStyle style, 243 gfx::Font::FontStyle style,
234 bool checked, 244 bool checked,
235 bool enabled) { 245 bool enabled) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 return true; 281 return true;
272 } 282 }
273 } 283 }
274 return false; 284 return false;
275 } 285 }
276 286
277 // Updates UI of the clicked bluetooth device to show it is being connected 287 // Updates UI of the clicked bluetooth device to show it is being connected
278 // or disconnected if such an operation is going to be performed underway. 288 // or disconnected if such an operation is going to be performed underway.
279 void UpdateClickedDevice(std::string device_id, views::View* item_container) { 289 void UpdateClickedDevice(std::string device_id, views::View* item_container) {
280 string16 display_name; 290 string16 display_name;
281 if (FoundDevice(device_id, connected_devices_, &display_name)) { 291 if (FoundDevice(device_id, connected_devices_, &display_name) ||
292 FoundDevice(device_id, connecting_devices_, &display_name)) {
282 display_name = l10n_util::GetStringFUTF16( 293 display_name = l10n_util::GetStringFUTF16(
283 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCONNECTING, display_name); 294 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCONNECTING, display_name);
284 } else if (FoundDevice(device_id, paired_not_connected_devices_, 295 } else if (FoundDevice(device_id, paired_not_connected_devices_,
285 &display_name)) { 296 &display_name)) {
286 display_name = l10n_util::GetStringFUTF16( 297 display_name = l10n_util::GetStringFUTF16(
287 IDS_ASH_STATUS_TRAY_BLUETOOTH_CONNECTING, display_name); 298 IDS_ASH_STATUS_TRAY_BLUETOOTH_CONNECTING, display_name);
288 } 299 }
289 if (display_name.length() > 0) { 300 if (display_name.length() > 0) {
290 item_container->RemoveAllChildViews(true); 301 item_container->RemoveAllChildViews(true);
291 static_cast<HoverHighlightView*>(item_container)-> 302 static_cast<HoverHighlightView*>(item_container)->
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } 341 }
331 342
332 user::LoginStatus login_; 343 user::LoginStatus login_;
333 344
334 std::map<views::View*, std::string> device_map_; 345 std::map<views::View*, std::string> device_map_;
335 views::View* add_device_; 346 views::View* add_device_;
336 ThrobberView* throbber_; 347 ThrobberView* throbber_;
337 TrayPopupHeaderButton* toggle_bluetooth_; 348 TrayPopupHeaderButton* toggle_bluetooth_;
338 HoverHighlightView* enable_bluetooth_; 349 HoverHighlightView* enable_bluetooth_;
339 BluetoothDeviceList connected_devices_; 350 BluetoothDeviceList connected_devices_;
351 BluetoothDeviceList connecting_devices_;
340 BluetoothDeviceList paired_not_connected_devices_; 352 BluetoothDeviceList paired_not_connected_devices_;
341 BluetoothDeviceList discovered_not_paired_devices_; 353 BluetoothDeviceList discovered_not_paired_devices_;
342 bool bluetooth_discovering_; 354 bool bluetooth_discovering_;
343 355
344 DISALLOW_COPY_AND_ASSIGN(BluetoothDetailedView); 356 DISALLOW_COPY_AND_ASSIGN(BluetoothDetailedView);
345 }; 357 };
346 358
347 } // namespace tray 359 } // namespace tray
348 360
349 TrayBluetooth::TrayBluetooth(SystemTray* system_tray) 361 TrayBluetooth::TrayBluetooth(SystemTray* system_tray)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 } 410 }
399 411
400 void TrayBluetooth::OnBluetoothDiscoveringChanged() { 412 void TrayBluetooth::OnBluetoothDiscoveringChanged() {
401 if (!detailed_) 413 if (!detailed_)
402 return; 414 return;
403 detailed_->Update(); 415 detailed_->Update();
404 } 416 }
405 417
406 } // namespace internal 418 } // namespace internal
407 } // namespace ash 419 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/system/tray/system_tray_delegate.h » ('j') | chrome/browser/chromeos/system/ash_system_tray_delegate.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698