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

Side by Side Diff: extensions/browser/api/bluetooth/bluetooth_extension_function.cc

Issue 1412493002: Bluetooth extension api fixes for WebUI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_543294_bluetooth_idl
Patch Set: Created 5 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 "extensions/browser/api/bluetooth/bluetooth_extension_function.h" 5 #include "extensions/browser/api/bluetooth/bluetooth_extension_function.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "content/public/browser/web_contents.h"
9 #include "device/bluetooth/bluetooth_adapter.h" 10 #include "device/bluetooth/bluetooth_adapter.h"
10 #include "device/bluetooth/bluetooth_adapter_factory.h" 11 #include "device/bluetooth/bluetooth_adapter_factory.h"
11 #include "extensions/browser/api/bluetooth/bluetooth_api.h" 12 #include "extensions/browser/api/bluetooth/bluetooth_api.h"
12 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" 13 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h"
14 #include "url/gurl.h"
13 15
14 using content::BrowserThread; 16 using content::BrowserThread;
15 17
16 namespace { 18 namespace {
17 19
18 const char kPlatformNotSupported[] = 20 const char kPlatformNotSupported[] =
19 "This operation is not supported on your platform"; 21 "This operation is not supported on your platform";
20 22
21 extensions::BluetoothEventRouter* GetEventRouter( 23 extensions::BluetoothEventRouter* GetEventRouter(
22 content::BrowserContext* context) { 24 content::BrowserContext* context) {
(...skipping 29 matching lines...) Expand all
52 if (!IsBluetoothSupported(browser_context())) { 54 if (!IsBluetoothSupported(browser_context())) {
53 SetError(kPlatformNotSupported); 55 SetError(kPlatformNotSupported);
54 return false; 56 return false;
55 } 57 }
56 GetAdapter(base::Bind(&BluetoothExtensionFunction::RunOnAdapterReady, this), 58 GetAdapter(base::Bind(&BluetoothExtensionFunction::RunOnAdapterReady, this),
57 browser_context()); 59 browser_context());
58 60
59 return true; 61 return true;
60 } 62 }
61 63
64 std::string BluetoothExtensionFunction::GetExtensionId() {
65 if (extension())
66 return extension()->id();
67 return GetSenderWebContents()->GetURL().host();
68 }
69
62 void BluetoothExtensionFunction::RunOnAdapterReady( 70 void BluetoothExtensionFunction::RunOnAdapterReady(
63 scoped_refptr<device::BluetoothAdapter> adapter) { 71 scoped_refptr<device::BluetoothAdapter> adapter) {
64 DCHECK_CURRENTLY_ON(BrowserThread::UI); 72 DCHECK_CURRENTLY_ON(BrowserThread::UI);
65 DoWork(adapter); 73 DoWork(adapter);
66 } 74 }
67 75
68 } // namespace api 76 } // namespace api
69 } // namespace extensions 77 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698