OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/permissions/permission_prompt_android.h" | |
6 | |
7 #include "base/memory/ptr_util.h" | |
8 #include "chrome/browser/infobars/infobar_service.h" | |
9 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" | |
10 #include "chrome/browser/permissions/grouped_permission_infobar_delegate_android .h" | |
11 #include "chrome/browser/permissions/permission_request.h" | |
12 #include "chrome/browser/permissions/permission_request_id.h" | |
13 #include "components/infobars/core/infobar.h" | |
14 #include "content/public/browser/web_contents.h" | |
15 | |
16 PermissionPromptAndroid::PermissionPromptAndroid( | |
17 content::WebContents* web_contents) | |
18 : web_contents_(web_contents), | |
19 delegate_(nullptr), | |
20 infobar_(nullptr), | |
21 infobar_service_(nullptr) { | |
22 DCHECK(web_contents); | |
23 } | |
24 | |
25 PermissionPromptAndroid::~PermissionPromptAndroid() {} | |
26 | |
27 void PermissionPromptAndroid::SetDelegate(Delegate* delegate) { | |
28 delegate_ = delegate; | |
29 } | |
30 | |
31 void PermissionPromptAndroid::Show( | |
32 const std::vector<PermissionRequest*>& requests, | |
33 const std::vector<bool>& values) { | |
34 infobar_service_ = InfoBarService::FromWebContents(web_contents_); | |
35 if (!infobar_service_) | |
36 return; | |
37 | |
38 infobar_ = GroupedPermissionInfoBarDelegate::Create( | |
39 this, infobar_service_, requests[0]->GetOrigin(), requests); | |
raymes
2016/10/24 00:50:16
It would be good to get someone with infobar exper
lshang
2016/10/24 08:48:02
Will ask dominickn@ to take a look at this:-)
| |
40 } | |
41 | |
42 bool PermissionPromptAndroid::CanAcceptRequestUpdate() { | |
43 return false; | |
44 } | |
45 | |
46 void PermissionPromptAndroid::Hide() { | |
47 if (infobar_ && infobar_service_) { | |
48 infobar_service_->RemoveInfoBar(infobar_); | |
raymes
2016/10/24 00:50:15
I think we can access this from the infobar itself
lshang
2016/10/24 08:48:02
Done. Removed the infobar_service_ and get it from
| |
49 infobar_ = nullptr; | |
50 } | |
51 } | |
52 | |
53 bool PermissionPromptAndroid::IsVisible() { | |
54 return infobar_ != nullptr; | |
55 } | |
56 | |
57 void PermissionPromptAndroid::UpdateAnchorPosition() { | |
58 NOTREACHED() << "UpdateAnchorPosition is not implemented"; | |
59 } | |
60 | |
61 gfx::NativeWindow PermissionPromptAndroid::GetNativeWindow() { | |
62 NOTREACHED() << "GetNativeWindow is not implemented"; | |
63 return nullptr; | |
64 } | |
65 | |
66 void PermissionPromptAndroid::Closing() { | |
67 if (infobar_) | |
68 infobar_ = nullptr; | |
69 if (delegate_) | |
70 delegate_->Closing(); | |
71 } | |
72 | |
73 // static | |
74 std::unique_ptr<PermissionPrompt> PermissionPrompt::Create( | |
75 content::WebContents* web_contents) { | |
76 return base::WrapUnique(new PermissionPromptAndroid(web_contents)); | |
raymes
2016/10/24 00:50:15
nit: use MakeUnique instead
lshang
2016/10/24 08:48:02
Done.
| |
77 } | |
OLD | NEW |