OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/android/permissions/permission_group_infobar_delegate_a
ndroid.h" |
| 6 |
| 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" |
| 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/infobars/infobar_service.h" |
| 12 #include "chrome/browser/permissions/permission_infobar_request.h" |
| 13 #include "chrome/browser/ui/android/infobars/permission_group_infobar_android.h" |
| 14 #include "chrome/grit/generated_resources.h" |
| 15 #include "components/url_formatter/elide_url.h" |
| 16 #include "ui/base/l10n/l10n_util.h" |
| 17 |
| 18 PermissionGroupInfoBarDelegateAndroid:: |
| 19 PermissionGroupInfoBarDelegateAndroid( |
| 20 const GURL& requesting_frame, |
| 21 const std::string& display_languages, |
| 22 const base::Callback<void( |
| 23 bool, const std::vector<ContentSetting>&)>& callback) |
| 24 : requesting_frame_(requesting_frame), |
| 25 display_languages_(display_languages), |
| 26 callback_(callback) { |
| 27 } |
| 28 |
| 29 PermissionGroupInfoBarDelegateAndroid:: |
| 30 ~PermissionGroupInfoBarDelegateAndroid() { |
| 31 } |
| 32 |
| 33 void PermissionGroupInfoBarDelegateAndroid::OnCheckedStateUpdate( |
| 34 jboolean* raw_checked_states, |
| 35 int array_size) { |
| 36 checked_states_.clear(); |
| 37 |
| 38 for (int i = 0; i < array_size; ++i) { |
| 39 checked_states_.push_back(raw_checked_states[i] == JNI_TRUE |
| 40 ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); |
| 41 } |
| 42 } |
| 43 |
| 44 gfx::Image PermissionGroupInfoBarDelegateAndroid::GetIcon() const { |
| 45 return gfx::Image(); |
| 46 } |
| 47 |
| 48 base::string16 PermissionGroupInfoBarDelegateAndroid::GetMessageText() const { |
| 49 return l10n_util::GetStringFUTF16(IDS_COALESCED_PERMISSION_INFOBAR_QUESTION, |
| 50 url_formatter::FormatUrlForSecurityDisplay( |
| 51 requesting_frame_, display_languages_)); |
| 52 } |
| 53 |
| 54 int PermissionGroupInfoBarDelegateAndroid::GetButtons() const { |
| 55 return BUTTON_OK; |
| 56 } |
| 57 |
| 58 bool PermissionGroupInfoBarDelegateAndroid::Accept() { |
| 59 callback_.Run(true, checked_states_); |
| 60 return true; |
| 61 } |
| 62 |
| 63 void PermissionGroupInfoBarDelegateAndroid::InfoBarDismissed() { |
| 64 callback_.Run(false, checked_states_); |
| 65 } |
| 66 |
| 67 bool PermissionGroupInfoBarDelegateAndroid::LinkClicked( |
| 68 WindowOpenDisposition disposition) { |
| 69 return true; |
| 70 } |
OLD | NEW |