| Index: chrome/browser/ui/bluetooth/bluetooth_chooser_bubble_delegate.cc
|
| diff --git a/chrome/browser/ui/bluetooth/bluetooth_chooser_bubble_delegate.cc b/chrome/browser/ui/bluetooth/bluetooth_chooser_bubble_delegate.cc
|
| index 8ca66407287cfea142d9fb79fb54da8fa20a6832..4a9e4a9f7a0438ecc50102bc96432b4e6206565e 100644
|
| --- a/chrome/browser/ui/bluetooth/bluetooth_chooser_bubble_delegate.cc
|
| +++ b/chrome/browser/ui/bluetooth/bluetooth_chooser_bubble_delegate.cc
|
| @@ -5,11 +5,22 @@
|
| #include "chrome/browser/ui/bluetooth/bluetooth_chooser_bubble_delegate.h"
|
|
|
| #include "base/stl_util.h"
|
| +#include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/browser/ui/bluetooth/bluetooth_chooser_context.h"
|
| +#include "chrome/browser/ui/bluetooth/bluetooth_chooser_context_factory.h"
|
| #include "chrome/browser/ui/bluetooth/bluetooth_chooser_desktop.h"
|
| #include "components/bubble/bubble_controller.h"
|
| +#include "content/public/browser/render_frame_host.h"
|
| +#include "content/public/browser/web_contents.h"
|
|
|
| -BluetoothChooserBubbleDelegate::BluetoothChooserBubbleDelegate(Browser* browser)
|
| - : ChooserBubbleDelegate(browser), bluetooth_chooser_(nullptr) {}
|
| +BluetoothChooserBubbleDelegate::BluetoothChooserBubbleDelegate(
|
| + Browser* browser,
|
| + content::WebContents* web_contents,
|
| + const GURL& origin)
|
| + : ChooserBubbleDelegate(browser),
|
| + web_contents_(web_contents),
|
| + origin_(origin),
|
| + bluetooth_chooser_(nullptr) {}
|
|
|
| BluetoothChooserBubbleDelegate::~BluetoothChooserBubbleDelegate() {
|
| if (bluetooth_chooser_)
|
| @@ -34,6 +45,16 @@ void BluetoothChooserBubbleDelegate::Select(size_t index) {
|
| device_names_and_ids_[index].second);
|
| }
|
|
|
| + GURL embedding_origin =
|
| + web_contents_->GetMainFrame()->GetLastCommittedURL().GetOrigin();
|
| + Profile* profile =
|
| + Profile::FromBrowserContext(web_contents_->GetBrowserContext());
|
| + BluetoothChooserContext* chooser_context =
|
| + BluetoothChooserContextFactory::GetForProfile(profile);
|
| + chooser_context->GrantDevicePermission(origin_, embedding_origin,
|
| + device_names_and_ids_[index].first,
|
| + device_names_and_ids_[index].second);
|
| +
|
| if (bubble_controller_)
|
| bubble_controller_->CloseBubble(BUBBLE_CLOSE_ACCEPTED);
|
| }
|
|
|