| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/api/bluetooth_socket/bluetooth_socket_api.h" | 5 #include "chrome/browser/extensions/api/bluetooth_socket/bluetooth_socket_api.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/api/bluetooth_socket/bluetooth_api_socket.h" | 7 #include "chrome/browser/extensions/api/bluetooth_socket/bluetooth_api_socket.h" |
| 8 #include "chrome/browser/extensions/api/bluetooth_socket/bluetooth_socket_event_
dispatcher.h" | 8 #include "chrome/browser/extensions/api/bluetooth_socket/bluetooth_socket_event_
dispatcher.h" |
| 9 #include "chrome/common/extensions/api/bluetooth/bluetooth_manifest_data.h" | 9 #include "chrome/common/extensions/api/bluetooth/bluetooth_manifest_data.h" |
| 10 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 bool BluetoothSocketAsyncApiFunction::RunAsync() { | 91 bool BluetoothSocketAsyncApiFunction::RunAsync() { |
| 92 if (!PrePrepare() || !Prepare()) { | 92 if (!PrePrepare() || !Prepare()) { |
| 93 return false; | 93 return false; |
| 94 } | 94 } |
| 95 AsyncWorkStart(); | 95 AsyncWorkStart(); |
| 96 return true; | 96 return true; |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool BluetoothSocketAsyncApiFunction::PrePrepare() { | 99 bool BluetoothSocketAsyncApiFunction::PrePrepare() { |
| 100 if (!BluetoothManifestData::CheckSocketPermitted(GetExtension())) { |
| 101 error_ = kPermissionDeniedError; |
| 102 return false; |
| 103 } |
| 104 |
| 100 manager_ = ApiResourceManager<BluetoothApiSocket>::Get(browser_context()); | 105 manager_ = ApiResourceManager<BluetoothApiSocket>::Get(browser_context()); |
| 101 DCHECK(manager_) | 106 DCHECK(manager_) |
| 102 << "There is no socket manager. " | 107 << "There is no socket manager. " |
| 103 "If this assertion is failing during a test, then it is likely that " | 108 "If this assertion is failing during a test, then it is likely that " |
| 104 "TestExtensionSystem is failing to provide an instance of " | 109 "TestExtensionSystem is failing to provide an instance of " |
| 105 "ApiResourceManager<BluetoothApiSocket>."; | 110 "ApiResourceManager<BluetoothApiSocket>."; |
| 106 return manager_ != NULL; | 111 return manager_ != NULL; |
| 107 } | 112 } |
| 108 | 113 |
| 109 bool BluetoothSocketAsyncApiFunction::Respond() { return error_.empty(); } | 114 bool BluetoothSocketAsyncApiFunction::Respond() { return error_.empty(); } |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 if (socket) { | 639 if (socket) { |
| 635 socket_infos.push_back(CreateSocketInfo(socket_id, socket)); | 640 socket_infos.push_back(CreateSocketInfo(socket_id, socket)); |
| 636 } | 641 } |
| 637 } | 642 } |
| 638 } | 643 } |
| 639 results_ = bluetooth_socket::GetSockets::Results::Create(socket_infos); | 644 results_ = bluetooth_socket::GetSockets::Results::Create(socket_infos); |
| 640 } | 645 } |
| 641 | 646 |
| 642 } // namespace api | 647 } // namespace api |
| 643 } // namespace extensions | 648 } // namespace extensions |
| OLD | NEW |