Chromium Code Reviews| 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..19d93680799b711a60ded6bf8f8ccd02cc8a9a89 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,15 @@ 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, |
|
Jeffrey Yasskin
2016/01/06 19:23:45
After looking at your Android patch, I think this
juncai
2016/01/11 21:55:16
Done.
|
| + device_names_and_ids_[index].second); |
| + |
| if (bubble_controller_) |
| bubble_controller_->CloseBubble(BUBBLE_CLOSE_ACCEPTED); |
| } |