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/ui/android/infobars/grouped_permission_infobar.h" | |
| 6 | |
| 7 #include "base/android/jni_android.h" | |
| 8 #include "base/android/jni_array.h" | |
| 9 #include "base/android/jni_string.h" | |
| 10 #include "chrome/browser/android/resource_mapper.h" | |
| 11 #include "chrome/browser/permissions/grouped_permission_infobar_delegate.h" | |
| 12 #include "jni/GroupedPermissionInfoBar_jni.h" | |
| 13 | |
| 14 GroupedPermissionInfoBar::GroupedPermissionInfoBar( | |
| 15 std::unique_ptr<GroupedPermissionInfoBarDelegate> delegate) | |
| 16 : ConfirmInfoBar(std::move(delegate)) {} | |
| 17 | |
| 18 GroupedPermissionInfoBar::~GroupedPermissionInfoBar() { | |
|
mlamouri (slow - plz ping)
2016/04/28 13:06:49
= default;
You might even be able to move that to
| |
| 19 } | |
| 20 | |
| 21 bool GroupedPermissionInfoBar::Register(JNIEnv* env) { | |
| 22 return RegisterNativesImpl(env); | |
| 23 } | |
| 24 | |
| 25 base::android::ScopedJavaLocalRef<jobject> | |
| 26 GroupedPermissionInfoBar::CreateRenderInfoBar(JNIEnv* env) { | |
| 27 GroupedPermissionInfoBarDelegate* delegate = GetDelegate(); | |
| 28 | |
| 29 base::android::ScopedJavaLocalRef<jstring> message_text = | |
| 30 base::android::ConvertUTF16ToJavaString( | |
| 31 env, delegate->GetMessageText()); | |
| 32 base::android::ScopedJavaLocalRef<jstring> ok_button_text = | |
| 33 base::android::ConvertUTF16ToJavaString( | |
| 34 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK)); | |
| 35 base::android::ScopedJavaLocalRef<jstring> cancel_button_text = | |
| 36 base::android::ConvertUTF16ToJavaString( | |
| 37 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_CANCEL)); | |
| 38 | |
| 39 std::vector<base::string16> permission_strings; | |
| 40 std::vector<int> permission_icons; | |
| 41 std::vector<int> content_settings_types; | |
| 42 | |
| 43 for (int i = 0; i < delegate->GetPermissionCount(); i++) { | |
| 44 permission_strings.push_back(delegate->GetMessageTextFragment(i)); | |
| 45 permission_icons.push_back( | |
| 46 ResourceMapper::MapFromChromiumId(delegate->GetIconIdForPermission(i))); | |
| 47 content_settings_types.push_back(delegate->GetContentSettingType(i)); | |
| 48 } | |
| 49 | |
| 50 return Java_GroupedPermissionInfoBar_create( | |
| 51 env, message_text.obj(), ok_button_text.obj(), cancel_button_text.obj(), | |
| 52 base::android::ToJavaIntArray(env, permission_icons).obj(), | |
| 53 base::android::ToJavaArrayOfStrings(env, permission_strings).obj(), | |
| 54 GetWindowAndroid().obj(), | |
| 55 base::android::ToJavaIntArray(env, content_settings_types).obj()); | |
| 56 } | |
| 57 | |
| 58 GroupedPermissionInfoBarDelegate* GroupedPermissionInfoBar::GetDelegate() { | |
| 59 return static_cast<GroupedPermissionInfoBarDelegate*>(delegate()); | |
| 60 } | |
| 61 | |
| 62 std::unique_ptr<infobars::InfoBar> | |
| 63 GroupedPermissionInfoBarDelegate::CreateInfoBar( | |
| 64 infobars::InfoBarManager* infobar_manager, | |
| 65 std::unique_ptr<GroupedPermissionInfoBarDelegate> delegate) { | |
| 66 return std::unique_ptr<infobars::InfoBar>( | |
| 67 new GroupedPermissionInfoBar(std::move(delegate))); | |
| 68 } | |
| OLD | NEW |