| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/browser/bluetooth/bluetooth_device_chooser_controller.h" | 5 #include "content/browser/bluetooth/bluetooth_device_chooser_controller.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <unordered_set> | 9 #include <unordered_set> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "content/browser/bluetooth/bluetooth_blacklist.h" | 15 #include "content/browser/bluetooth/bluetooth_blocklist.h" |
| 16 #include "content/browser/bluetooth/bluetooth_metrics.h" | 16 #include "content/browser/bluetooth/bluetooth_metrics.h" |
| 17 #include "content/browser/bluetooth/web_bluetooth_service_impl.h" | 17 #include "content/browser/bluetooth/web_bluetooth_service_impl.h" |
| 18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/content_browser_client.h" | 19 #include "content/public/browser/content_browser_client.h" |
| 20 #include "content/public/browser/render_frame_host.h" | 20 #include "content/public/browser/render_frame_host.h" |
| 21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/browser/web_contents_delegate.h" | 22 #include "content/public/browser/web_contents_delegate.h" |
| 23 #include "device/bluetooth/bluetooth_adapter.h" | 23 #include "device/bluetooth/bluetooth_adapter.h" |
| 24 #include "device/bluetooth/bluetooth_common.h" | 24 #include "device/bluetooth/bluetooth_common.h" |
| 25 #include "device/bluetooth/bluetooth_discovery_session.h" | 25 #include "device/bluetooth/bluetooth_discovery_session.h" |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 251 |
| 252 // The renderer should never send empty filters. | 252 // The renderer should never send empty filters. |
| 253 if (HasEmptyOrInvalidFilter(options->filters)) { | 253 if (HasEmptyOrInvalidFilter(options->filters)) { |
| 254 web_bluetooth_service_->CrashRendererAndClosePipe( | 254 web_bluetooth_service_->CrashRendererAndClosePipe( |
| 255 bad_message::BDH_EMPTY_OR_INVALID_FILTERS); | 255 bad_message::BDH_EMPTY_OR_INVALID_FILTERS); |
| 256 return; | 256 return; |
| 257 } | 257 } |
| 258 options_ = std::move(options); | 258 options_ = std::move(options); |
| 259 LogRequestDeviceOptions(options_); | 259 LogRequestDeviceOptions(options_); |
| 260 | 260 |
| 261 // Check blacklist to reject invalid filters and adjust optional_services. | 261 // Check blocklist to reject invalid filters and adjust optional_services. |
| 262 if (BluetoothBlacklist::Get().IsExcluded(options_->filters)) { | 262 if (BluetoothBlocklist::Get().IsExcluded(options_->filters)) { |
| 263 RecordRequestDeviceOutcome( | 263 RecordRequestDeviceOutcome( |
| 264 UMARequestDeviceOutcome::BLACKLISTED_SERVICE_IN_FILTER); | 264 UMARequestDeviceOutcome::BLOCKLISTED_SERVICE_IN_FILTER); |
| 265 PostErrorCallback( | 265 PostErrorCallback( |
| 266 blink::mojom::WebBluetoothResult::REQUEST_DEVICE_WITH_BLACKLISTED_UUID); | 266 blink::mojom::WebBluetoothResult::REQUEST_DEVICE_WITH_BLOCKLISTED_UUID); |
| 267 return; | 267 return; |
| 268 } | 268 } |
| 269 BluetoothBlacklist::Get().RemoveExcludedUUIDs(options_.get()); | 269 BluetoothBlocklist::Get().RemoveExcludedUUIDs(options_.get()); |
| 270 | 270 |
| 271 const url::Origin requesting_origin = | 271 const url::Origin requesting_origin = |
| 272 render_frame_host_->GetLastCommittedOrigin(); | 272 render_frame_host_->GetLastCommittedOrigin(); |
| 273 const url::Origin embedding_origin = | 273 const url::Origin embedding_origin = |
| 274 web_contents_->GetMainFrame()->GetLastCommittedOrigin(); | 274 web_contents_->GetMainFrame()->GetLastCommittedOrigin(); |
| 275 | 275 |
| 276 // TODO(crbug.com/518042): Enforce correctly-delegated permissions instead of | 276 // TODO(crbug.com/518042): Enforce correctly-delegated permissions instead of |
| 277 // matching origins. When relaxing this, take care to handle non-sandboxed | 277 // matching origins. When relaxing this, take care to handle non-sandboxed |
| 278 // unique origins. | 278 // unique origins. |
| 279 if (!embedding_origin.IsSameOriginWith(requesting_origin)) { | 279 if (!embedding_origin.IsSameOriginWith(requesting_origin)) { |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 | 530 |
| 531 void BluetoothDeviceChooserController::PostErrorCallback( | 531 void BluetoothDeviceChooserController::PostErrorCallback( |
| 532 blink::mojom::WebBluetoothResult error) { | 532 blink::mojom::WebBluetoothResult error) { |
| 533 if (!base::ThreadTaskRunnerHandle::Get()->PostTask( | 533 if (!base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 534 FROM_HERE, base::Bind(error_callback_, error))) { | 534 FROM_HERE, base::Bind(error_callback_, error))) { |
| 535 LOG(WARNING) << "No TaskRunner."; | 535 LOG(WARNING) << "No TaskRunner."; |
| 536 } | 536 } |
| 537 } | 537 } |
| 538 | 538 |
| 539 } // namespace content | 539 } // namespace content |
| OLD | NEW |