Chromium Code Reviews| 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_delegate_(nullptr), | |
|
raymes
2016/10/19 00:25:41
Where does this get set?
lshang
2016/10/20 05:03:10
Done. Added a line to get delegate from infobar_->
lshang
2016/10/23 23:56:43
Sorry this is not correct. Please see updated repl
lshang
2016/10/23 23:56:43
Should check with infobar_ instead of infobar_dele
| |
| 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 | |
| 36 if (!infobar_service_) | |
| 37 return; | |
| 38 | |
| 39 infobar_ = GroupedPermissionInfoBarDelegate::Create( | |
| 40 infobar_service_, requests[0]->GetOrigin(), requests); | |
| 41 } | |
| 42 | |
| 43 bool PermissionPromptAndroid::CanAcceptRequestUpdate() { | |
| 44 return false; | |
| 45 } | |
| 46 | |
| 47 void PermissionPromptAndroid::Hide() { | |
| 48 if (infobar_delegate_ && infobar_service_) { | |
| 49 infobar_service_->RemoveInfoBar(infobar_); | |
| 50 infobar_delegate_ = nullptr; | |
| 51 } | |
| 52 } | |
| 53 | |
| 54 bool PermissionPromptAndroid::IsVisible() { | |
| 55 return infobar_delegate_ != nullptr; | |
| 56 } | |
| 57 | |
| 58 void PermissionPromptAndroid::UpdateAnchorPosition() { | |
| 59 NOTREACHED() << "UpdateAnchorPosition is not implemented"; | |
| 60 } | |
| 61 | |
| 62 gfx::NativeWindow PermissionPromptAndroid::GetNativeWindow() { | |
| 63 NOTREACHED() << "GetNativeWindow is not implemented"; | |
| 64 return nullptr; | |
| 65 } | |
| 66 | |
| 67 void PermissionPromptAndroid::Closing() { | |
| 68 if (infobar_delegate_) | |
| 69 infobar_delegate_ = nullptr; | |
| 70 if (delegate_) | |
| 71 delegate_->Closing(); | |
| 72 } | |
| 73 | |
| 74 void PermissionPromptAndroid::ToggleAccept(int index, bool value) { | |
| 75 if (infobar_delegate_) | |
| 76 infobar_delegate_->ToggleAccept(index, value); | |
| 77 } | |
| 78 | |
| 79 void PermissionPromptAndroid::Accept() { | |
| 80 if (infobar_delegate_) | |
| 81 infobar_delegate_->Accept(); | |
| 82 } | |
| 83 | |
| 84 void PermissionPromptAndroid::Deny() { | |
| 85 if (infobar_delegate_) | |
| 86 infobar_delegate_->Cancel(); | |
| 87 } | |
| 88 | |
| 89 // static | |
| 90 std::unique_ptr<PermissionPrompt> PermissionPrompt::Create( | |
| 91 content::WebContents* web_contents) { | |
| 92 return base::WrapUnique(new PermissionPromptAndroid(web_contents)); | |
| 93 } | |
| OLD | NEW |