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

Side by Side Diff: chrome/browser/ui/bluetooth/bluetooth_chooser_controller.h

Issue 2245603003: Add signal strength indicator icon to WebBluetooth chooser on non-Mac desktops (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address more comments Created 4 years, 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_UI_BLUETOOTH_BLUETOOTH_CHOOSER_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_BLUETOOTH_BLUETOOTH_CHOOSER_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_BLUETOOTH_BLUETOOTH_CHOOSER_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_BLUETOOTH_BLUETOOTH_CHOOSER_CONTROLLER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 10 matching lines...) Expand all
21 // It can be used by WebBluetooth API to get the user's permission to 21 // It can be used by WebBluetooth API to get the user's permission to
22 // access a Bluetooth device. It is owned by ChooserBubbleDelegate. 22 // access a Bluetooth device. It is owned by ChooserBubbleDelegate.
23 class BluetoothChooserController : public ChooserController { 23 class BluetoothChooserController : public ChooserController {
24 public: 24 public:
25 explicit BluetoothChooserController( 25 explicit BluetoothChooserController(
26 content::RenderFrameHost* owner, 26 content::RenderFrameHost* owner,
27 const content::BluetoothChooser::EventHandler& event_handler); 27 const content::BluetoothChooser::EventHandler& event_handler);
28 ~BluetoothChooserController() override; 28 ~BluetoothChooserController() override;
29 29
30 // ChooserController: 30 // ChooserController:
31 bool ShouldShowIconBeforeText() const override;
31 base::string16 GetNoOptionsText() const override; 32 base::string16 GetNoOptionsText() const override;
32 base::string16 GetOkButtonLabel() const override; 33 base::string16 GetOkButtonLabel() const override;
33 size_t NumOptions() const override; 34 size_t NumOptions() const override;
35 int GetSignalStrengthLevel(size_t index) const override;
34 base::string16 GetOption(size_t index) const override; 36 base::string16 GetOption(size_t index) const override;
35 void RefreshOptions() override; 37 void RefreshOptions() override;
36 base::string16 GetStatus() const override; 38 base::string16 GetStatus() const override;
37 void Select(size_t index) override; 39 void Select(size_t index) override;
38 void Cancel() override; 40 void Cancel() override;
39 void Close() override; 41 void Close() override;
40 void OpenHelpCenterUrl() const override; 42 void OpenHelpCenterUrl() const override;
41 43
42 // Update the state of the Bluetooth adapter. 44 // Update the state of the Bluetooth adapter.
43 void OnAdapterPresenceChanged( 45 void OnAdapterPresenceChanged(
44 content::BluetoothChooser::AdapterPresence presence); 46 content::BluetoothChooser::AdapterPresence presence);
45 47
46 // Update the Bluetooth discovery state and let the user know whether 48 // Update the Bluetooth discovery state and let the user know whether
47 // discovery is happening. 49 // discovery is happening.
48 void OnDiscoveryStateChanged(content::BluetoothChooser::DiscoveryState state); 50 void OnDiscoveryStateChanged(content::BluetoothChooser::DiscoveryState state);
49 51
50 // Shows a new device in the chooser or updates its information. 52 // Shows a new device in the chooser or updates its information.
53 // The range of |signal_strength_level| is -1 to 4 inclusively.
51 void AddOrUpdateDevice(const std::string& device_id, 54 void AddOrUpdateDevice(const std::string& device_id,
52 bool should_update_name, 55 bool should_update_name,
53 const base::string16& device_name, 56 const base::string16& device_name,
54 bool is_gatt_connected, 57 bool is_gatt_connected,
55 bool is_paired, 58 bool is_paired,
56 const int8_t* rssi); 59 int signal_strength_level);
57 60
58 // Tells the chooser that a device is no longer available. 61 // Tells the chooser that a device is no longer available.
59 void RemoveDevice(const std::string& device_id); 62 void RemoveDevice(const std::string& device_id);
60 63
61 // Called when |event_handler_| is no longer valid and should not be used 64 // Called when |event_handler_| is no longer valid and should not be used
62 // any more. 65 // any more.
63 void ResetEventHandler(); 66 void ResetEventHandler();
64 67
65 private: 68 private:
69 struct BluetoothDeviceInfo {
70 std::string id;
71 int signal_strength_level;
72 };
73
66 // Clears |device_names_and_ids_| and |device_name_counts_|. Called when 74 // Clears |device_names_and_ids_| and |device_name_counts_|. Called when
67 // Bluetooth adapter is turned on or off, or when re-scan happens. 75 // Bluetooth adapter is turned on or off, or when re-scan happens.
68 void ClearAllDevices(); 76 void ClearAllDevices();
69 77
70 std::vector<std::string> device_ids_; 78 std::vector<BluetoothDeviceInfo> devices_;
71 std::unordered_map<std::string, base::string16> device_id_to_name_map_; 79 std::unordered_map<std::string, base::string16> device_id_to_name_map_;
72 // Maps from device name to number of devices with that name. 80 // Maps from device name to number of devices with that name.
73 std::unordered_map<base::string16, int> device_name_counts_; 81 std::unordered_map<base::string16, int> device_name_counts_;
74 82
75 content::BluetoothChooser::EventHandler event_handler_; 83 content::BluetoothChooser::EventHandler event_handler_;
76 base::string16 no_devices_text_; 84 base::string16 no_devices_text_;
77 base::string16 status_text_; 85 base::string16 status_text_;
78 86
79 DISALLOW_COPY_AND_ASSIGN(BluetoothChooserController); 87 DISALLOW_COPY_AND_ASSIGN(BluetoothChooserController);
80 }; 88 };
81 89
82 #endif // CHROME_BROWSER_UI_BLUETOOTH_BLUETOOTH_CHOOSER_CONTROLLER_H_ 90 #endif // CHROME_BROWSER_UI_BLUETOOTH_BLUETOOTH_CHOOSER_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/bluetooth_chooser_android.cc ('k') | chrome/browser/ui/bluetooth/bluetooth_chooser_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698