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 29 matching lines...) Expand all Loading... |
40 int message_id = IDS_INFOBAR_MISSING_MULTIPLE_PERMISSIONS_TEXT; | 40 int message_id = IDS_INFOBAR_MISSING_MULTIPLE_PERMISSIONS_TEXT; |
41 | 41 |
42 for (ContentSettingsType content_settings_type : content_settings_types) { | 42 for (ContentSettingsType content_settings_type : content_settings_types) { |
43 int previous_size = permissions.size(); | 43 int previous_size = permissions.size(); |
44 PrefServiceBridge::GetAndroidPermissionsForContentSetting( | 44 PrefServiceBridge::GetAndroidPermissionsForContentSetting( |
45 content_settings_type, &permissions); | 45 content_settings_type, &permissions); |
46 | 46 |
47 if (missing_permission_count > 1) | 47 if (missing_permission_count > 1) |
48 continue; | 48 continue; |
49 | 49 |
| 50 bool has_all_permissions = true; |
50 for (auto it = permissions.begin() + previous_size; it != permissions.end(); | 51 for (auto it = permissions.begin() + previous_size; it != permissions.end(); |
51 ++it) { | 52 ++it) { |
52 if (window_android->HasPermission(*it)) | 53 has_all_permissions &= window_android->HasPermission(*it); |
53 continue; | 54 } |
54 | 55 |
| 56 if (!has_all_permissions) { |
55 missing_permission_count++; | 57 missing_permission_count++; |
56 if (missing_permission_count > 1) { | 58 if (missing_permission_count > 1) { |
57 message_id = IDS_INFOBAR_MISSING_MULTIPLE_PERMISSIONS_TEXT; | 59 message_id = IDS_INFOBAR_MISSING_MULTIPLE_PERMISSIONS_TEXT; |
58 } else if (content_settings_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { | 60 } else if (content_settings_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { |
59 message_id = IDS_INFOBAR_MISSING_LOCATION_PERMISSION_TEXT; | 61 message_id = IDS_INFOBAR_MISSING_LOCATION_PERMISSION_TEXT; |
60 } else if (content_settings_type == | 62 } else if (content_settings_type == |
61 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { | 63 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { |
62 message_id = IDS_INFOBAR_MISSING_MICROPHONE_PERMISSION_TEXT; | 64 message_id = IDS_INFOBAR_MISSING_MICROPHONE_PERMISSION_TEXT; |
63 } else if (content_settings_type == | 65 } else if (content_settings_type == |
64 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { | 66 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 } | 186 } |
185 | 187 |
186 bool PermissionUpdateInfoBarDelegate::Cancel() { | 188 bool PermissionUpdateInfoBarDelegate::Cancel() { |
187 base::ResetAndReturn(&callback_).Run(false); | 189 base::ResetAndReturn(&callback_).Run(false); |
188 return true; | 190 return true; |
189 } | 191 } |
190 | 192 |
191 void PermissionUpdateInfoBarDelegate::InfoBarDismissed() { | 193 void PermissionUpdateInfoBarDelegate::InfoBarDismissed() { |
192 base::ResetAndReturn(&callback_).Run(false); | 194 base::ResetAndReturn(&callback_).Run(false); |
193 } | 195 } |
OLD | NEW |