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), delegate_(nullptr), infobar_(nullptr) { | |
| 19 DCHECK(web_contents); | |
| 20 } | |
| 21 | |
| 22 PermissionPromptAndroid::~PermissionPromptAndroid() {} | |
| 23 | |
| 24 void PermissionPromptAndroid::SetDelegate(Delegate* delegate) { | |
| 25 delegate_ = delegate; | |
| 26 } | |
| 27 | |
| 28 void PermissionPromptAndroid::Show( | |
| 29 const std::vector<PermissionRequest*>& requests, | |
| 30 const std::vector<bool>& values) { | |
| 31 InfoBarService* infobar_service = | |
| 32 InfoBarService::FromWebContents(web_contents_); | |
| 33 if (!infobar_service) | |
| 34 return; | |
| 35 | |
| 36 infobar_ = GroupedPermissionInfoBarDelegate::Create( | |
| 37 infobar_service, requests[0]->GetOrigin(), requests); | |
| 38 } | |
| 39 | |
| 40 bool PermissionPromptAndroid::CanAcceptRequestUpdate() { | |
| 41 return false; | |
| 42 } | |
| 43 | |
| 44 void PermissionPromptAndroid::Hide() { | |
| 45 InfoBarService* infobar_service = | |
| 46 InfoBarService::FromWebContents(web_contents_); | |
| 47 if (infobar_ && infobar_service) { | |
| 48 infobar_service->RemoveInfoBar(infobar_); | |
| 49 infobar_ = nullptr; | |
|
raymes
2016/10/26 05:37:36
Should we clear the pointer here even if there is
lshang
2016/10/26 05:55:49
Done. Yeah we should clear it if infobar_service i
| |
| 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_) | |
|
raymes
2016/10/26 05:37:36
nit: we can probably remove this
lshang
2016/10/26 05:55:49
Done.
| |
| 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::MakeUnique<PermissionPromptAndroid>(web_contents); | |
| 77 } | |
| OLD | NEW |