Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1023)

Side by Side Diff: chrome/browser/ui/android/infobars/grouped_permission_infobar.cc

Issue 2923393002: Make UI with PermissionRequestManager enabled match PermissionQueueController (Closed)
Patch Set: address comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/android/infobars/grouped_permission_infobar.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ui/android/infobars/grouped_permission_infobar.h" 5 #include "chrome/browser/ui/android/infobars/grouped_permission_infobar.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "chrome/browser/android/resource_mapper.h" 10 #include "chrome/browser/android/resource_mapper.h"
11 #include "chrome/browser/android/tab_android.h" 11 #include "chrome/browser/android/tab_android.h"
12 #include "chrome/browser/permissions/grouped_permission_infobar_delegate_android .h" 12 #include "chrome/browser/permissions/grouped_permission_infobar_delegate_android .h"
13 #include "jni/GroupedPermissionInfoBar_jni.h" 13 #include "jni/PermissionInfoBar_jni.h"
14 14
15 GroupedPermissionInfoBar::GroupedPermissionInfoBar( 15 GroupedPermissionInfoBar::GroupedPermissionInfoBar(
16 std::unique_ptr<GroupedPermissionInfoBarDelegate> delegate) 16 std::unique_ptr<GroupedPermissionInfoBarDelegate> delegate)
17 : ConfirmInfoBar(std::move(delegate)) {} 17 : ConfirmInfoBar(std::move(delegate)) {}
18 18
19 GroupedPermissionInfoBar::~GroupedPermissionInfoBar() { 19 GroupedPermissionInfoBar::~GroupedPermissionInfoBar() {
20 } 20 }
21 21
22 void GroupedPermissionInfoBar::ProcessButton(int action) { 22 void GroupedPermissionInfoBar::ProcessButton(int action) {
23 // Check if the delegate asked us to display a persistence toggle. If so, 23 // Check if the delegate asked us to display a persistence toggle. If so,
24 // inform it of the toggle state. 24 // inform it of the toggle state.
25 GroupedPermissionInfoBarDelegate* delegate = GetDelegate(); 25 GroupedPermissionInfoBarDelegate* delegate = GetDelegate();
26 if (delegate->ShouldShowPersistenceToggle()) { 26 if (delegate->ShouldShowPersistenceToggle()) {
27 delegate->set_persist(Java_GroupedPermissionInfoBar_isPersistSwitchOn( 27 delegate->set_persist(Java_PermissionInfoBar_isPersistSwitchOn(
28 base::android::AttachCurrentThread(), GetJavaInfoBar())); 28 base::android::AttachCurrentThread(), GetJavaInfoBar()));
29 } 29 }
30 30
31 ConfirmInfoBar::ProcessButton(action); 31 ConfirmInfoBar::ProcessButton(action);
32 } 32 }
33 33
34 base::android::ScopedJavaLocalRef<jobject> 34 base::android::ScopedJavaLocalRef<jobject>
35 GroupedPermissionInfoBar::CreateRenderInfoBar(JNIEnv* env) { 35 GroupedPermissionInfoBar::CreateRenderInfoBar(JNIEnv* env) {
36 GroupedPermissionInfoBarDelegate* delegate = GetDelegate(); 36 GroupedPermissionInfoBarDelegate* delegate = GetDelegate();
37 37
38 base::android::ScopedJavaLocalRef<jstring> message_text = 38 base::android::ScopedJavaLocalRef<jstring> message_text =
39 base::android::ConvertUTF16ToJavaString( 39 base::android::ConvertUTF16ToJavaString(
40 env, delegate->GetMessageText()); 40 env, delegate->GetMessageText());
41 base::android::ScopedJavaLocalRef<jstring> link_text = 41 base::android::ScopedJavaLocalRef<jstring> link_text =
42 base::android::ConvertUTF16ToJavaString(env, delegate->GetLinkText()); 42 base::android::ConvertUTF16ToJavaString(env, delegate->GetLinkText());
43 base::android::ScopedJavaLocalRef<jstring> ok_button_text = 43 base::android::ScopedJavaLocalRef<jstring> ok_button_text =
44 base::android::ConvertUTF16ToJavaString( 44 base::android::ConvertUTF16ToJavaString(
45 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK)); 45 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK));
46 base::android::ScopedJavaLocalRef<jstring> cancel_button_text = 46 base::android::ScopedJavaLocalRef<jstring> cancel_button_text =
47 base::android::ConvertUTF16ToJavaString( 47 base::android::ConvertUTF16ToJavaString(
48 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_CANCEL)); 48 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_CANCEL));
49 49
50 std::vector<base::string16> permission_strings; 50 int permission_icon =
51 std::vector<int> permission_icons; 51 ResourceMapper::MapFromChromiumId(delegate->GetIconId());
52
52 std::vector<int> content_settings_types; 53 std::vector<int> content_settings_types;
53
54 for (size_t i = 0; i < delegate->PermissionCount(); i++) { 54 for (size_t i = 0; i < delegate->PermissionCount(); i++) {
55 permission_strings.push_back(delegate->GetMessageTextFragment(i));
56 permission_icons.push_back(
57 ResourceMapper::MapFromChromiumId(delegate->GetIconIdForPermission(i)));
58 content_settings_types.push_back(delegate->GetContentSettingType(i)); 55 content_settings_types.push_back(delegate->GetContentSettingType(i));
59 } 56 }
60 57
61 return Java_GroupedPermissionInfoBar_create( 58 return Java_PermissionInfoBar_create(
62 env, GetTab()->GetJavaObject(), 59 env, GetTab()->GetJavaObject(), permission_icon, nullptr, message_text,
63 base::android::ToJavaIntArray(env, content_settings_types), message_text,
64 link_text, ok_button_text, cancel_button_text, 60 link_text, ok_button_text, cancel_button_text,
65 delegate->ShouldShowPersistenceToggle(), 61 base::android::ToJavaIntArray(env, content_settings_types),
66 base::android::ToJavaArrayOfStrings(env, permission_strings), 62 delegate->ShouldShowPersistenceToggle());
67 base::android::ToJavaIntArray(env, permission_icons));
68 } 63 }
69 64
70 GroupedPermissionInfoBarDelegate* GroupedPermissionInfoBar::GetDelegate() { 65 GroupedPermissionInfoBarDelegate* GroupedPermissionInfoBar::GetDelegate() {
71 return static_cast<GroupedPermissionInfoBarDelegate*>(delegate()); 66 return static_cast<GroupedPermissionInfoBarDelegate*>(delegate());
72 } 67 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/infobars/grouped_permission_infobar.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698