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

Side by Side Diff: device/bluetooth/bluetooth_adapter_factory.cc

Issue 2384463002: bluetooth: mac: Reject requestDevice promise if Mac version is <= 10.9 (Closed)
Patch Set: 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 (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 "device/bluetooth/bluetooth_adapter_factory.h" 5 #include "device/bluetooth/bluetooth_adapter_factory.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/mac/mac_util.h"
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
13 #include "build/build_config.h" 14 #include "build/build_config.h"
14 #include "device/bluetooth/bluetooth_adapter.h" 15 #include "device/bluetooth/bluetooth_adapter.h"
15 16
16 namespace device { 17 namespace device {
17 18
18 namespace { 19 namespace {
19 20
20 // Shared default adapter instance. We don't want to keep this class around 21 // Shared default adapter instance. We don't want to keep this class around
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 return true; 58 return true;
58 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) || defined(OS_WIN) || \ 59 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) || defined(OS_WIN) || \
59 defined(OS_LINUX) || defined(OS_MACOSX) 60 defined(OS_LINUX) || defined(OS_MACOSX)
60 return true; 61 return true;
61 #else 62 #else
62 return false; 63 return false;
63 #endif 64 #endif
64 } 65 }
65 66
66 // static 67 // static
68 bool BluetoothAdapterFactory::IsLowEnergyAvailable() {
69 DCHECK(IsBluetoothAdapterAvailable());
70
71 // SetAdapterForTesting() may be used to provide a test or mock adapter
72 // instance even on platforms that would otherwise not support it.
73 if (default_adapter.Get())
74 return true;
75 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) || defined(OS_WIN) || \
ortuno 2016/10/04 03:20:24 We have a couple of issues to remove devices the u
François Beaufort 2016/10/04 10:00:22 So you want Web Bluetooth chooser to not show up o
ortuno 2016/10/04 21:23:16 Now that I think about it the only way to use Web
76 defined(OS_LINUX)
77 return true;
78 #endif
79 #if defined(OS_MACOSX)
ortuno 2016/10/04 03:20:24 nit: Could you combine this with the previous line
François Beaufort 2016/10/04 10:00:22 Done.
80 return base::mac::IsAtLeastOS10_10();
81 #endif
ortuno 2016/10/04 03:20:24 nit: comment missing: // defined(OS_ANDROID) || de
François Beaufort 2016/10/04 10:00:22 Done.
82 return false;
83 }
84
85 // static
67 void BluetoothAdapterFactory::GetAdapter(const AdapterCallback& callback) { 86 void BluetoothAdapterFactory::GetAdapter(const AdapterCallback& callback) {
68 DCHECK(IsBluetoothAdapterAvailable()); 87 DCHECK(IsBluetoothAdapterAvailable());
69 88
70 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) 89 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS)
71 if (!default_adapter.Get()) { 90 if (!default_adapter.Get()) {
72 default_adapter.Get() = 91 default_adapter.Get() =
73 BluetoothAdapter::CreateAdapter(base::Bind(&RunAdapterCallbacks)); 92 BluetoothAdapter::CreateAdapter(base::Bind(&RunAdapterCallbacks));
74 DCHECK(!default_adapter.Get()->IsInitialized()); 93 DCHECK(!default_adapter.Get()->IsInitialized());
75 } 94 }
76 95
(...skipping 25 matching lines...) Expand all
102 scoped_refptr<BluetoothAdapter> adapter) { 121 scoped_refptr<BluetoothAdapter> adapter) {
103 default_adapter.Get() = adapter->GetWeakPtrForTesting(); 122 default_adapter.Get() = adapter->GetWeakPtrForTesting();
104 } 123 }
105 124
106 // static 125 // static
107 bool BluetoothAdapterFactory::HasSharedInstanceForTesting() { 126 bool BluetoothAdapterFactory::HasSharedInstanceForTesting() {
108 return default_adapter.Get() != nullptr; 127 return default_adapter.Get() != nullptr;
109 } 128 }
110 129
111 } // namespace device 130 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698