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

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: fix Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ash/system/tray/system_tray_delegate.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/fixed_sized_scroll_view.h" 8 #include "ash/system/tray/fixed_sized_scroll_view.h"
9 #include "ash/system/tray/hover_highlight_view.h" 9 #include "ash/system/tray/hover_highlight_view.h"
10 #include "ash/system/tray/system_tray.h" 10 #include "ash/system/tray/system_tray.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 ash::Shell::GetInstance()->system_tray_delegate(); 121 ash::Shell::GetInstance()->system_tray_delegate();
122 if (delegate && bluetooth_discovering_) { 122 if (delegate && bluetooth_discovering_) {
123 bluetooth_discovering_ = false; 123 bluetooth_discovering_ = false;
124 delegate->BluetoothStopDiscovering(); 124 delegate->BluetoothStopDiscovering();
125 throbber_->Stop(); 125 throbber_->Stop();
126 } 126 }
127 } 127 }
128 128
129 void UpdateBlueToothDeviceList() { 129 void UpdateBlueToothDeviceList() {
130 connected_devices_.clear(); 130 connected_devices_.clear();
131 connecting_devices_.clear();
131 paired_not_connected_devices_.clear(); 132 paired_not_connected_devices_.clear();
132 discovered_not_paired_devices_.clear(); 133 discovered_not_paired_devices_.clear();
133 BluetoothDeviceList list; 134 BluetoothDeviceList list;
134 Shell::GetInstance()->system_tray_delegate()-> 135 Shell::GetInstance()->system_tray_delegate()->
135 GetAvailableBluetoothDevices(&list); 136 GetAvailableBluetoothDevices(&list);
136 for (size_t i = 0; i < list.size(); ++i) { 137 for (size_t i = 0; i < list.size(); ++i) {
137 if (list[i].connected) 138 if (list[i].connecting)
139 connecting_devices_.push_back(list[i]);
140 else if (list[i].connected)
138 connected_devices_.push_back(list[i]); 141 connected_devices_.push_back(list[i]);
139 else if (list[i].paired) 142 else if (list[i].paired)
140 paired_not_connected_devices_.push_back(list[i]); 143 paired_not_connected_devices_.push_back(list[i]);
141 else 144 else
142 discovered_not_paired_devices_.push_back(list[i]); 145 discovered_not_paired_devices_.push_back(list[i]);
143 } 146 }
144 } 147 }
145 148
146 void AppendHeaderEntry() { 149 void AppendHeaderEntry() {
147 CreateSpecialRow(IDS_ASH_STATUS_TRAY_BLUETOOTH, this); 150 CreateSpecialRow(IDS_ASH_STATUS_TRAY_BLUETOOTH, this);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 toggle_bluetooth_) { 195 toggle_bluetooth_) {
193 enable_bluetooth_ = 196 enable_bluetooth_ =
194 AddScrollListItem( 197 AddScrollListItem(
195 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ENABLE_BLUETOOTH), 198 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ENABLE_BLUETOOTH),
196 gfx::Font::NORMAL, false, true); 199 gfx::Font::NORMAL, false, true);
197 } 200 }
198 201
199 AppendSameTypeDevicesToScrollList( 202 AppendSameTypeDevicesToScrollList(
200 connected_devices_, true, true, bluetooth_enabled); 203 connected_devices_, true, true, bluetooth_enabled);
201 AppendSameTypeDevicesToScrollList( 204 AppendSameTypeDevicesToScrollList(
205 connecting_devices_, true, false, bluetooth_enabled);
206 AppendSameTypeDevicesToScrollList(
202 paired_not_connected_devices_, false, false, bluetooth_enabled); 207 paired_not_connected_devices_, false, false, bluetooth_enabled);
203 if (discovered_not_paired_devices_.size() > 0) 208 if (discovered_not_paired_devices_.size() > 0)
204 AddScrollSeparator(); 209 AddScrollSeparator();
205 AppendSameTypeDevicesToScrollList( 210 AppendSameTypeDevicesToScrollList(
206 discovered_not_paired_devices_, false, false, bluetooth_enabled); 211 discovered_not_paired_devices_, false, false, bluetooth_enabled);
207 212
208 // Show user Bluetooth state if there is no bluetooth devices in list. 213 // Show user Bluetooth state if there is no bluetooth devices in list.
209 if (device_map_.size() == 0) { 214 if (device_map_.size() == 0) {
210 if (blueooth_available && bluetooth_enabled) { 215 if (blueooth_available && bluetooth_enabled) {
211 AddScrollListItem( 216 AddScrollListItem(
212 l10n_util::GetStringUTF16( 217 l10n_util::GetStringUTF16(
213 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERING), 218 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERING),
214 gfx::Font::NORMAL, false, true); 219 gfx::Font::NORMAL, false, true);
215 } 220 }
216 } 221 }
217 222
218 scroll_content()->SizeToPreferredSize(); 223 scroll_content()->SizeToPreferredSize();
219 static_cast<views::View*>(scroller())->Layout(); 224 static_cast<views::View*>(scroller())->Layout();
220 } 225 }
221 226
222 void AppendSameTypeDevicesToScrollList(const BluetoothDeviceList& list, 227 void AppendSameTypeDevicesToScrollList(const BluetoothDeviceList& list,
223 bool bold, 228 bool bold,
224 bool checked, 229 bool checked,
225 bool enabled) { 230 bool enabled) {
226 for (size_t i = 0; i < list.size(); ++i) { 231 for (size_t i = 0; i < list.size(); ++i) {
232 string16 display_name = list[i].display_name;
233 if (list[i].connecting) {
234 display_name = l10n_util::GetStringFUTF16(
235 IDS_ASH_STATUS_TRAY_BLUETOOTH_CONNECTING, display_name);
236 }
jennyz 2013/04/10 16:15:37 It's a little bit unclean to modify the display na
Jun Mukai 2013/04/13 00:05:35 Done.
227 HoverHighlightView* container = AddScrollListItem( 237 HoverHighlightView* container = AddScrollListItem(
228 list[i].display_name, 238 display_name,
229 bold? gfx::Font::BOLD : gfx::Font::NORMAL, 239 bold? gfx::Font::BOLD : gfx::Font::NORMAL,
230 checked, enabled); 240 checked, enabled);
231 device_map_[container] = list[i].address; 241 device_map_[container] = list[i].address;
232 } 242 }
233 } 243 }
234 244
235 HoverHighlightView* AddScrollListItem(const string16& text, 245 HoverHighlightView* AddScrollListItem(const string16& text,
236 gfx::Font::FontStyle style, 246 gfx::Font::FontStyle style,
237 bool checked, 247 bool checked,
238 bool enabled) { 248 bool enabled) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 return false; 287 return false;
278 } 288 }
279 289
280 // Updates UI of the clicked bluetooth device to show it is being connected 290 // Updates UI of the clicked bluetooth device to show it is being connected
281 // or disconnected if such an operation is going to be performed underway. 291 // or disconnected if such an operation is going to be performed underway.
282 void UpdateClickedDevice(std::string device_id, views::View* item_container) { 292 void UpdateClickedDevice(std::string device_id, views::View* item_container) {
283 string16 display_name; 293 string16 display_name;
284 if (FoundDevice(device_id, connected_devices_, &display_name)) { 294 if (FoundDevice(device_id, connected_devices_, &display_name)) {
285 display_name = l10n_util::GetStringFUTF16( 295 display_name = l10n_util::GetStringFUTF16(
286 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCONNECTING, display_name); 296 IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCONNECTING, display_name);
287 } else if (FoundDevice(device_id, paired_not_connected_devices_, 297 } else if (FoundDevice(device_id, connecting_devices_, &display_name) ||
Jun Mukai 2013/04/13 00:05:35 noticed this is not necessary. since connecting_de
298 FoundDevice(device_id, paired_not_connected_devices_,
288 &display_name)) { 299 &display_name)) {
289 display_name = l10n_util::GetStringFUTF16( 300 display_name = l10n_util::GetStringFUTF16(
290 IDS_ASH_STATUS_TRAY_BLUETOOTH_CONNECTING, display_name); 301 IDS_ASH_STATUS_TRAY_BLUETOOTH_CONNECTING, display_name);
291 } 302 }
292 if (display_name.length() > 0) { 303 if (display_name.length() > 0) {
293 item_container->RemoveAllChildViews(true); 304 item_container->RemoveAllChildViews(true);
294 static_cast<HoverHighlightView*>(item_container)-> 305 static_cast<HoverHighlightView*>(item_container)->
295 AddCheckableLabel(display_name, gfx::Font::BOLD, false); 306 AddCheckableLabel(display_name, gfx::Font::BOLD, false);
296 scroll_content()->SizeToPreferredSize(); 307 scroll_content()->SizeToPreferredSize();
297 static_cast<views::View*>(scroller())->Layout(); 308 static_cast<views::View*>(scroller())->Layout();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 } 344 }
334 345
335 user::LoginStatus login_; 346 user::LoginStatus login_;
336 347
337 std::map<views::View*, std::string> device_map_; 348 std::map<views::View*, std::string> device_map_;
338 views::View* add_device_; 349 views::View* add_device_;
339 ThrobberView* throbber_; 350 ThrobberView* throbber_;
340 TrayPopupHeaderButton* toggle_bluetooth_; 351 TrayPopupHeaderButton* toggle_bluetooth_;
341 HoverHighlightView* enable_bluetooth_; 352 HoverHighlightView* enable_bluetooth_;
342 BluetoothDeviceList connected_devices_; 353 BluetoothDeviceList connected_devices_;
354 BluetoothDeviceList connecting_devices_;
343 BluetoothDeviceList paired_not_connected_devices_; 355 BluetoothDeviceList paired_not_connected_devices_;
344 BluetoothDeviceList discovered_not_paired_devices_; 356 BluetoothDeviceList discovered_not_paired_devices_;
345 bool bluetooth_discovering_; 357 bool bluetooth_discovering_;
346 358
347 DISALLOW_COPY_AND_ASSIGN(BluetoothDetailedView); 359 DISALLOW_COPY_AND_ASSIGN(BluetoothDetailedView);
348 }; 360 };
349 361
350 } // namespace tray 362 } // namespace tray
351 363
352 TrayBluetooth::TrayBluetooth(SystemTray* system_tray) 364 TrayBluetooth::TrayBluetooth(SystemTray* system_tray)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 } 413 }
402 414
403 void TrayBluetooth::OnBluetoothDiscoveringChanged() { 415 void TrayBluetooth::OnBluetoothDiscoveringChanged() {
404 if (!detailed_) 416 if (!detailed_)
405 return; 417 return;
406 detailed_->Update(); 418 detailed_->Update();
407 } 419 }
408 420
409 } // namespace internal 421 } // namespace internal
410 } // namespace ash 422 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/system/tray/system_tray_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698