Chromium Code Reviews| 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 |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 } | 335 } |
| 336 BluetoothBlocklist::Get().RemoveExcludedUUIDs(options_.get()); | 336 BluetoothBlocklist::Get().RemoveExcludedUUIDs(options_.get()); |
| 337 | 337 |
| 338 const url::Origin requesting_origin = | 338 const url::Origin requesting_origin = |
| 339 render_frame_host_->GetLastCommittedOrigin(); | 339 render_frame_host_->GetLastCommittedOrigin(); |
| 340 const url::Origin embedding_origin = | 340 const url::Origin embedding_origin = |
| 341 web_contents_->GetMainFrame()->GetLastCommittedOrigin(); | 341 web_contents_->GetMainFrame()->GetLastCommittedOrigin(); |
| 342 | 342 |
| 343 // TODO(crbug.com/518042): Enforce correctly-delegated permissions instead of | 343 // TODO(crbug.com/518042): Enforce correctly-delegated permissions instead of |
| 344 // matching origins. When relaxing this, take care to handle non-sandboxed | 344 // matching origins. When relaxing this, take care to handle non-sandboxed |
| 345 // unique origins. | 345 // opaque origins. |
| 346 if (!embedding_origin.IsSameOriginWith(requesting_origin)) { | 346 if (!embedding_origin.IsSameOriginWith(requesting_origin)) { |
| 347 PostErrorCallback(blink::mojom::WebBluetoothResult:: | 347 PostErrorCallback(blink::mojom::WebBluetoothResult:: |
| 348 REQUEST_DEVICE_FROM_CROSS_ORIGIN_IFRAME); | 348 REQUEST_DEVICE_FROM_CROSS_ORIGIN_IFRAME); |
| 349 return; | 349 return; |
| 350 } | 350 } |
| 351 // The above also excludes unique origins, which are not even same-origin with | 351 // The above also excludes opaque origins, which are not even same-origin with |
|
ortuno
2017/02/23 21:59:34
Do opaque origins still generate the same key in m
Mike West
2017/02/24 08:01:45
I'd suggest doing this in a separate patch. Mechan
| |
| 352 // themselves. | 352 // themselves. |
| 353 DCHECK(!requesting_origin.unique()); | 353 // TODO: This is no longer true, and will crash here if embedding_origin is |
| 354 // the same object as requesting_origin. | |
| 355 DCHECK(!requesting_origin.opaque()); | |
| 354 | 356 |
| 355 if (!adapter_->IsPresent()) { | 357 if (!adapter_->IsPresent()) { |
| 356 DVLOG(1) << "Bluetooth Adapter not present. Can't serve requestDevice."; | 358 DVLOG(1) << "Bluetooth Adapter not present. Can't serve requestDevice."; |
| 357 RecordRequestDeviceOutcome( | 359 RecordRequestDeviceOutcome( |
| 358 UMARequestDeviceOutcome::BLUETOOTH_ADAPTER_NOT_PRESENT); | 360 UMARequestDeviceOutcome::BLUETOOTH_ADAPTER_NOT_PRESENT); |
| 359 PostErrorCallback(blink::mojom::WebBluetoothResult::NO_BLUETOOTH_ADAPTER); | 361 PostErrorCallback(blink::mojom::WebBluetoothResult::NO_BLUETOOTH_ADAPTER); |
| 360 return; | 362 return; |
| 361 } | 363 } |
| 362 | 364 |
| 363 switch (GetContentClient()->browser()->AllowWebBluetooth( | 365 switch (GetContentClient()->browser()->AllowWebBluetooth( |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 617 | 619 |
| 618 void BluetoothDeviceChooserController::PostErrorCallback( | 620 void BluetoothDeviceChooserController::PostErrorCallback( |
| 619 blink::mojom::WebBluetoothResult error) { | 621 blink::mojom::WebBluetoothResult error) { |
| 620 if (!base::ThreadTaskRunnerHandle::Get()->PostTask( | 622 if (!base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 621 FROM_HERE, base::Bind(error_callback_, error))) { | 623 FROM_HERE, base::Bind(error_callback_, error))) { |
| 622 LOG(WARNING) << "No TaskRunner."; | 624 LOG(WARNING) << "No TaskRunner."; |
| 623 } | 625 } |
| 624 } | 626 } |
| 625 | 627 |
| 626 } // namespace content | 628 } // namespace content |
| OLD | NEW |