Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/permissions/permission_prompt_android.h" | 5 #include "chrome/browser/permissions/permission_prompt_android.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/infobars/infobar_service.h" | 8 #include "chrome/browser/infobars/infobar_service.h" |
| 9 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" | 9 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" |
| 10 #include "chrome/browser/permissions/grouped_permission_infobar_delegate_android .h" | 10 #include "chrome/browser/permissions/grouped_permission_infobar_delegate_android .h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 void PermissionPromptAndroid::Show( | 28 void PermissionPromptAndroid::Show( |
| 29 const std::vector<PermissionRequest*>& requests, | 29 const std::vector<PermissionRequest*>& requests, |
| 30 const std::vector<bool>& values) { | 30 const std::vector<bool>& values) { |
| 31 InfoBarService* infobar_service = | 31 InfoBarService* infobar_service = |
| 32 InfoBarService::FromWebContents(web_contents_); | 32 InfoBarService::FromWebContents(web_contents_); |
| 33 if (!infobar_service) | 33 if (!infobar_service) |
| 34 return; | 34 return; |
| 35 | 35 |
| 36 infobar_ = GroupedPermissionInfoBarDelegate::Create( | 36 infobar_ = GroupedPermissionInfoBarDelegate::Create( |
| 37 infobar_service, requests[0]->GetOrigin(), requests); | 37 infobar_service, requests[0]->GetOrigin(), requests); |
| 38 | |
| 39 GroupedPermissionInfoBarDelegate* infobar_delegate = | |
| 40 infobar_->delegate()->AsGroupedPermissionInfoBarDelegate(); | |
| 41 infobar_delegate->SetPermissionPrompt(this); | |
|
raymes
2016/11/01 00:07:46
Now that I look at it, I think passing this pointe
lshang
2016/11/01 04:33:42
Done.
| |
| 38 } | 42 } |
| 39 | 43 |
| 40 bool PermissionPromptAndroid::CanAcceptRequestUpdate() { | 44 bool PermissionPromptAndroid::CanAcceptRequestUpdate() { |
| 41 return false; | 45 return false; |
| 42 } | 46 } |
| 43 | 47 |
| 44 void PermissionPromptAndroid::Hide() { | 48 void PermissionPromptAndroid::Hide() { |
| 45 InfoBarService* infobar_service = | 49 InfoBarService* infobar_service = |
| 46 InfoBarService::FromWebContents(web_contents_); | 50 InfoBarService::FromWebContents(web_contents_); |
| 47 if (infobar_ && infobar_service) { | 51 if (infobar_ && infobar_service) { |
| 48 infobar_service->RemoveInfoBar(infobar_); | 52 infobar_service->RemoveInfoBar(infobar_); |
| 49 } | 53 } |
| 54 GroupedPermissionInfoBarDelegate* infobar_delegate = | |
| 55 infobar_->delegate()->AsGroupedPermissionInfoBarDelegate(); | |
|
raymes
2016/11/01 00:07:46
I don't think we need to add this function, I thin
lshang
2016/11/01 04:33:42
Refer to other infobars, the convention seems to u
raymes
2016/11/01 05:29:15
If you know the type ahead of time (which I think
| |
| 56 infobar_delegate->ResetPermissionPrompt(); | |
|
raymes
2016/11/01 00:07:46
Maybe this should just go in the destructor of thi
lshang
2016/11/01 04:33:42
Done.
| |
| 50 infobar_ = nullptr; | 57 infobar_ = nullptr; |
| 51 } | 58 } |
| 52 | 59 |
| 53 bool PermissionPromptAndroid::IsVisible() { | 60 bool PermissionPromptAndroid::IsVisible() { |
| 54 return infobar_ != nullptr; | 61 return infobar_ != nullptr; |
| 55 } | 62 } |
| 56 | 63 |
| 57 void PermissionPromptAndroid::UpdateAnchorPosition() { | 64 void PermissionPromptAndroid::UpdateAnchorPosition() { |
| 58 NOTREACHED() << "UpdateAnchorPosition is not implemented"; | 65 NOTREACHED() << "UpdateAnchorPosition is not implemented"; |
| 59 } | 66 } |
| 60 | 67 |
| 61 gfx::NativeWindow PermissionPromptAndroid::GetNativeWindow() { | 68 gfx::NativeWindow PermissionPromptAndroid::GetNativeWindow() { |
| 62 NOTREACHED() << "GetNativeWindow is not implemented"; | 69 NOTREACHED() << "GetNativeWindow is not implemented"; |
| 63 return nullptr; | 70 return nullptr; |
| 64 } | 71 } |
| 65 | 72 |
| 66 void PermissionPromptAndroid::Closing() { | 73 void PermissionPromptAndroid::Closing() { |
| 67 infobar_ = nullptr; | 74 infobar_ = nullptr; |
| 68 if (delegate_) | 75 if (delegate_) |
| 69 delegate_->Closing(); | 76 delegate_->Closing(); |
| 70 } | 77 } |
| 71 | 78 |
| 79 void PermissionPromptAndroid::Accept() { | |
| 80 if (delegate_) | |
| 81 delegate_->Accept(); | |
| 82 } | |
| 83 | |
| 84 void PermissionPromptAndroid::Deny() { | |
| 85 if (delegate_) | |
| 86 delegate_->Deny(); | |
| 87 } | |
| 88 | |
| 72 // static | 89 // static |
| 73 std::unique_ptr<PermissionPrompt> PermissionPrompt::Create( | 90 std::unique_ptr<PermissionPrompt> PermissionPrompt::Create( |
| 74 content::WebContents* web_contents) { | 91 content::WebContents* web_contents) { |
| 75 return base::MakeUnique<PermissionPromptAndroid>(web_contents); | 92 return base::MakeUnique<PermissionPromptAndroid>(web_contents); |
| 76 } | 93 } |
| OLD | NEW |