OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_update_infobar_delegate_android.
h" | 5 #include "chrome/browser/permissions/permission_update_infobar_delegate_android.
h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/android/jni_array.h" | 9 #include "base/android/jni_array.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 content::WebContents* web_contents, | 132 content::WebContents* web_contents, |
133 const std::vector<std::string>& android_permissions, | 133 const std::vector<std::string>& android_permissions, |
134 int permission_msg_id, | 134 int permission_msg_id, |
135 const PermissionUpdatedCallback& callback) | 135 const PermissionUpdatedCallback& callback) |
136 : ConfirmInfoBarDelegate(), | 136 : ConfirmInfoBarDelegate(), |
137 android_permissions_(android_permissions), | 137 android_permissions_(android_permissions), |
138 permission_msg_id_(permission_msg_id), | 138 permission_msg_id_(permission_msg_id), |
139 callback_(callback) { | 139 callback_(callback) { |
140 JNIEnv* env = base::android::AttachCurrentThread(); | 140 JNIEnv* env = base::android::AttachCurrentThread(); |
141 java_delegate_.Reset(Java_PermissionUpdateInfoBarDelegate_create( | 141 java_delegate_.Reset(Java_PermissionUpdateInfoBarDelegate_create( |
142 env, | 142 env, reinterpret_cast<intptr_t>(this), web_contents->GetJavaWebContents(), |
143 reinterpret_cast<intptr_t>(this), | 143 base::android::ToJavaArrayOfStrings(env, android_permissions_))); |
144 web_contents->GetJavaWebContents().obj(), | |
145 base::android::ToJavaArrayOfStrings(env, android_permissions_).obj())); | |
146 } | 144 } |
147 | 145 |
148 PermissionUpdateInfoBarDelegate::~PermissionUpdateInfoBarDelegate() { | 146 PermissionUpdateInfoBarDelegate::~PermissionUpdateInfoBarDelegate() { |
149 Java_PermissionUpdateInfoBarDelegate_onNativeDestroyed( | 147 Java_PermissionUpdateInfoBarDelegate_onNativeDestroyed( |
150 base::android::AttachCurrentThread(), java_delegate_.obj()); | 148 base::android::AttachCurrentThread(), java_delegate_); |
151 } | 149 } |
152 | 150 |
153 infobars::InfoBarDelegate::InfoBarIdentifier | 151 infobars::InfoBarDelegate::InfoBarIdentifier |
154 PermissionUpdateInfoBarDelegate::GetIdentifier() const { | 152 PermissionUpdateInfoBarDelegate::GetIdentifier() const { |
155 return PERMISSION_UPDATE_INFOBAR_DELEGATE; | 153 return PERMISSION_UPDATE_INFOBAR_DELEGATE; |
156 } | 154 } |
157 | 155 |
158 int PermissionUpdateInfoBarDelegate::GetIconId() const { | 156 int PermissionUpdateInfoBarDelegate::GetIconId() const { |
159 return IDR_INFOBAR_WARNING; | 157 return IDR_INFOBAR_WARNING; |
160 } | 158 } |
161 | 159 |
162 base::string16 PermissionUpdateInfoBarDelegate::GetMessageText() const { | 160 base::string16 PermissionUpdateInfoBarDelegate::GetMessageText() const { |
163 return l10n_util::GetStringUTF16(permission_msg_id_); | 161 return l10n_util::GetStringUTF16(permission_msg_id_); |
164 } | 162 } |
165 | 163 |
166 int PermissionUpdateInfoBarDelegate::GetButtons() const { | 164 int PermissionUpdateInfoBarDelegate::GetButtons() const { |
167 return BUTTON_OK; | 165 return BUTTON_OK; |
168 } | 166 } |
169 | 167 |
170 base::string16 PermissionUpdateInfoBarDelegate::GetButtonLabel( | 168 base::string16 PermissionUpdateInfoBarDelegate::GetButtonLabel( |
171 InfoBarButton button) const { | 169 InfoBarButton button) const { |
172 DCHECK_EQ(button, BUTTON_OK); | 170 DCHECK_EQ(button, BUTTON_OK); |
173 return l10n_util::GetStringUTF16(IDS_INFOBAR_UPDATE_PERMISSIONS_BUTTON_TEXT); | 171 return l10n_util::GetStringUTF16(IDS_INFOBAR_UPDATE_PERMISSIONS_BUTTON_TEXT); |
174 } | 172 } |
175 | 173 |
176 bool PermissionUpdateInfoBarDelegate::Accept() { | 174 bool PermissionUpdateInfoBarDelegate::Accept() { |
177 Java_PermissionUpdateInfoBarDelegate_requestPermissions( | 175 Java_PermissionUpdateInfoBarDelegate_requestPermissions( |
178 base::android::AttachCurrentThread(), java_delegate_.obj()); | 176 base::android::AttachCurrentThread(), java_delegate_); |
179 return false; | 177 return false; |
180 } | 178 } |
181 | 179 |
182 bool PermissionUpdateInfoBarDelegate::Cancel() { | 180 bool PermissionUpdateInfoBarDelegate::Cancel() { |
183 base::ResetAndReturn(&callback_).Run(false); | 181 base::ResetAndReturn(&callback_).Run(false); |
184 return true; | 182 return true; |
185 } | 183 } |
186 | 184 |
187 void PermissionUpdateInfoBarDelegate::InfoBarDismissed() { | 185 void PermissionUpdateInfoBarDelegate::InfoBarDismissed() { |
188 base::ResetAndReturn(&callback_).Run(false); | 186 base::ResetAndReturn(&callback_).Run(false); |
189 } | 187 } |
OLD | NEW |