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

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

Issue 2344133003: Add help link when Bluetooth adapter is off for WebBluetooth chooser (Closed)
Patch Set: address more comments Created 4 years, 2 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 #include "chrome/browser/ui/bluetooth/bluetooth_chooser_controller.h" 5 #include "chrome/browser/ui/bluetooth/bluetooth_chooser_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 22 matching lines...) Expand all
33 } 33 }
34 34
35 } // namespace 35 } // namespace
36 36
37 BluetoothChooserController::BluetoothChooserController( 37 BluetoothChooserController::BluetoothChooserController(
38 content::RenderFrameHost* owner, 38 content::RenderFrameHost* owner,
39 const content::BluetoothChooser::EventHandler& event_handler) 39 const content::BluetoothChooser::EventHandler& event_handler)
40 : ChooserController(owner, 40 : ChooserController(owner,
41 IDS_BLUETOOTH_DEVICE_CHOOSER_PROMPT_ORIGIN, 41 IDS_BLUETOOTH_DEVICE_CHOOSER_PROMPT_ORIGIN,
42 IDS_BLUETOOTH_DEVICE_CHOOSER_PROMPT_EXTENSION_NAME), 42 IDS_BLUETOOTH_DEVICE_CHOOSER_PROMPT_EXTENSION_NAME),
43 event_handler_(event_handler), 43 event_handler_(event_handler) {}
44 no_devices_text_(l10n_util::GetStringUTF16(
45 IDS_BLUETOOTH_DEVICE_CHOOSER_NO_DEVICES_FOUND_PROMPT)) {}
46 44
47 BluetoothChooserController::~BluetoothChooserController() {} 45 BluetoothChooserController::~BluetoothChooserController() {}
48 46
49 bool BluetoothChooserController::ShouldShowIconBeforeText() const { 47 bool BluetoothChooserController::ShouldShowIconBeforeText() const {
50 return true; 48 return true;
51 } 49 }
52 50
53 base::string16 BluetoothChooserController::GetNoOptionsText() const { 51 base::string16 BluetoothChooserController::GetNoOptionsText() const {
54 return no_devices_text_; 52 return l10n_util::GetStringUTF16(
53 IDS_BLUETOOTH_DEVICE_CHOOSER_NO_DEVICES_FOUND_PROMPT);
55 } 54 }
56 55
57 base::string16 BluetoothChooserController::GetOkButtonLabel() const { 56 base::string16 BluetoothChooserController::GetOkButtonLabel() const {
58 return l10n_util::GetStringUTF16( 57 return l10n_util::GetStringUTF16(
59 IDS_BLUETOOTH_DEVICE_CHOOSER_PAIR_BUTTON_TEXT); 58 IDS_BLUETOOTH_DEVICE_CHOOSER_PAIR_BUTTON_TEXT);
60 } 59 }
61 60
62 size_t BluetoothChooserController::NumOptions() const { 61 size_t BluetoothChooserController::NumOptions() const {
63 return devices_.size(); 62 return devices_.size();
64 } 63 }
(...skipping 25 matching lines...) Expand all
90 } 89 }
91 90
92 void BluetoothChooserController::RefreshOptions() { 91 void BluetoothChooserController::RefreshOptions() {
93 RecordInteractionWithChooser(event_handler_.is_null()); 92 RecordInteractionWithChooser(event_handler_.is_null());
94 if (event_handler_.is_null()) 93 if (event_handler_.is_null())
95 return; 94 return;
96 ClearAllDevices(); 95 ClearAllDevices();
97 event_handler_.Run(content::BluetoothChooser::Event::RESCAN, std::string()); 96 event_handler_.Run(content::BluetoothChooser::Event::RESCAN, std::string());
98 } 97 }
99 98
99 void BluetoothChooserController::OpenAdapterOffHelpUrl() const {
100 GetBrowser()->OpenURL(content::OpenURLParams(
101 GURL(chrome::kBluetoothAdapterOffHelpURL), content::Referrer(),
102 WindowOpenDisposition::NEW_FOREGROUND_TAB,
103 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, false /* is_renderer_initialized */));
104 }
105
100 base::string16 BluetoothChooserController::GetStatus() const { 106 base::string16 BluetoothChooserController::GetStatus() const {
101 return status_text_; 107 return status_text_;
102 } 108 }
103 109
104 void BluetoothChooserController::Select(size_t index) { 110 void BluetoothChooserController::Select(size_t index) {
105 RecordInteractionWithChooser(event_handler_.is_null()); 111 RecordInteractionWithChooser(event_handler_.is_null());
106 if (event_handler_.is_null()) { 112 if (event_handler_.is_null()) {
107 return; 113 return;
108 } 114 }
109 DCHECK_LT(index, devices_.size()); 115 DCHECK_LT(index, devices_.size());
(...skipping 25 matching lines...) Expand all
135 } 141 }
136 142
137 void BluetoothChooserController::OnAdapterPresenceChanged( 143 void BluetoothChooserController::OnAdapterPresenceChanged(
138 content::BluetoothChooser::AdapterPresence presence) { 144 content::BluetoothChooser::AdapterPresence presence) {
139 ClearAllDevices(); 145 ClearAllDevices();
140 switch (presence) { 146 switch (presence) {
141 case content::BluetoothChooser::AdapterPresence::ABSENT: 147 case content::BluetoothChooser::AdapterPresence::ABSENT:
142 NOTREACHED(); 148 NOTREACHED();
143 break; 149 break;
144 case content::BluetoothChooser::AdapterPresence::POWERED_OFF: 150 case content::BluetoothChooser::AdapterPresence::POWERED_OFF:
145 no_devices_text_ =
146 l10n_util::GetStringUTF16(IDS_BLUETOOTH_DEVICE_CHOOSER_ADAPTER_OFF);
147 status_text_ = base::string16(); 151 status_text_ = base::string16();
148 if (view()) { 152 if (view()) {
149 view()->OnAdapterEnabledChanged( 153 view()->OnAdapterEnabledChanged(
150 false /* Bluetooth adapter is turned off */); 154 false /* Bluetooth adapter is turned off */);
151 } 155 }
152 break; 156 break;
153 case content::BluetoothChooser::AdapterPresence::POWERED_ON: 157 case content::BluetoothChooser::AdapterPresence::POWERED_ON:
154 no_devices_text_ = l10n_util::GetStringUTF16(
155 IDS_BLUETOOTH_DEVICE_CHOOSER_NO_DEVICES_FOUND_PROMPT);
156 status_text_ = 158 status_text_ =
157 l10n_util::GetStringUTF16(IDS_BLUETOOTH_DEVICE_CHOOSER_RE_SCAN); 159 l10n_util::GetStringUTF16(IDS_BLUETOOTH_DEVICE_CHOOSER_RE_SCAN);
158 if (view()) { 160 if (view()) {
159 view()->OnAdapterEnabledChanged( 161 view()->OnAdapterEnabledChanged(
160 true /* Bluetooth adapter is turned on */); 162 true /* Bluetooth adapter is turned on */);
161 } 163 }
162 break; 164 break;
163 } 165 }
164 } 166 }
165 167
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 269
268 void BluetoothChooserController::ResetEventHandler() { 270 void BluetoothChooserController::ResetEventHandler() {
269 event_handler_.Reset(); 271 event_handler_.Reset();
270 } 272 }
271 273
272 void BluetoothChooserController::ClearAllDevices() { 274 void BluetoothChooserController::ClearAllDevices() {
273 devices_.clear(); 275 devices_.clear();
274 device_id_to_name_map_.clear(); 276 device_id_to_name_map_.clear();
275 device_name_counts_.clear(); 277 device_name_counts_.clear();
276 } 278 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698