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

Side by Side Diff: chrome/browser/permissions/permission_update_infobar_delegate_android.cc

Issue 2872853004: Remove usage of the generic multiple permissions update string. (Closed)
Patch Set: With final strings Created 3 years, 7 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
OLDNEW
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 18 matching lines...) Expand all
29 const PermissionUpdatedCallback& callback) { 29 const PermissionUpdatedCallback& callback) {
30 DCHECK(ShouldShowPermissionInfobar(web_contents, content_settings_types)) 30 DCHECK(ShouldShowPermissionInfobar(web_contents, content_settings_types))
31 << "Caller should check ShouldShowPermissionInfobar before creating the " 31 << "Caller should check ShouldShowPermissionInfobar before creating the "
32 << "infobar."; 32 << "infobar.";
33 33
34 content::ContentViewCore* cvc = 34 content::ContentViewCore* cvc =
35 content::ContentViewCore::FromWebContents(web_contents); 35 content::ContentViewCore::FromWebContents(web_contents);
36 ui::WindowAndroid* window_android = cvc->GetWindowAndroid(); 36 ui::WindowAndroid* window_android = cvc->GetWindowAndroid();
37 37
38 std::vector<std::string> permissions; 38 std::vector<std::string> permissions;
39 int missing_permission_count = 0; 39 int message_id = -1;
40 int message_id = IDS_INFOBAR_MISSING_MULTIPLE_PERMISSIONS_TEXT;
41 40
42 for (ContentSettingsType content_settings_type : content_settings_types) { 41 for (ContentSettingsType content_settings_type : content_settings_types) {
43 int previous_size = permissions.size(); 42 int previous_size = permissions.size();
44 PrefServiceBridge::GetAndroidPermissionsForContentSetting( 43 PrefServiceBridge::GetAndroidPermissionsForContentSetting(
45 content_settings_type, &permissions); 44 content_settings_type, &permissions);
46 45
47 if (missing_permission_count > 1)
48 continue;
49
50 bool has_all_permissions = true; 46 bool has_all_permissions = true;
51 for (auto it = permissions.begin() + previous_size; it != permissions.end(); 47 for (auto it = permissions.begin() + previous_size; it != permissions.end();
52 ++it) { 48 ++it) {
53 has_all_permissions &= window_android->HasPermission(*it); 49 has_all_permissions &= window_android->HasPermission(*it);
54 } 50 }
55 51
56 if (!has_all_permissions) { 52 if (!has_all_permissions) {
57 missing_permission_count++; 53 if (message_id == -1) {
58 if (missing_permission_count > 1) { 54 if (content_settings_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
59 message_id = IDS_INFOBAR_MISSING_MULTIPLE_PERMISSIONS_TEXT; 55 message_id = IDS_INFOBAR_MISSING_LOCATION_PERMISSION_TEXT;
60 } else if (content_settings_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { 56 } else if (content_settings_type ==
61 message_id = IDS_INFOBAR_MISSING_LOCATION_PERMISSION_TEXT; 57 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) {
62 } else if (content_settings_type == 58 message_id = IDS_INFOBAR_MISSING_MICROPHONE_PERMISSION_TEXT;
63 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { 59 } else if (content_settings_type ==
64 message_id = IDS_INFOBAR_MISSING_MICROPHONE_PERMISSION_TEXT; 60 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) {
65 } else if (content_settings_type == 61 message_id = IDS_INFOBAR_MISSING_CAMERA_PERMISSION_TEXT;
66 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { 62 } else {
67 message_id = IDS_INFOBAR_MISSING_CAMERA_PERMISSION_TEXT; 63 CHECK(false);
64 }
65 } else if (message_id == IDS_INFOBAR_MISSING_CAMERA_PERMISSION_TEXT) {
66 CHECK(content_settings_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC);
67 message_id = IDS_INFOBAR_MISSING_MICROPHONE_CAMERA_PERMISSIONS_TEXT;
68 } else if (message_id == IDS_INFOBAR_MISSING_MICROPHONE_PERMISSION_TEXT) {
69 CHECK(content_settings_type ==
70 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
71 message_id = IDS_INFOBAR_MISSING_MICROPHONE_CAMERA_PERMISSIONS_TEXT;
68 } else { 72 } else {
69 NOTREACHED(); 73 CHECK(false);
raymes 2017/05/14 23:22:24 Are you worried about people using this to request
benwells 2017/05/16 15:21:30 I don't think it can happen now. But if it somehow
70 message_id = IDS_INFOBAR_MISSING_MULTIPLE_PERMISSIONS_TEXT;
71 } 74 }
72 } 75 }
73 } 76 }
74 77
75 return PermissionUpdateInfoBarDelegate::Create( 78 return PermissionUpdateInfoBarDelegate::Create(
76 web_contents, permissions, message_id, callback); 79 web_contents, permissions, message_id, callback);
77 } 80 }
78 81
79 // static 82 // static
80 infobars::InfoBar* PermissionUpdateInfoBarDelegate::Create( 83 infobars::InfoBar* PermissionUpdateInfoBarDelegate::Create(
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 189 }
187 190
188 bool PermissionUpdateInfoBarDelegate::Cancel() { 191 bool PermissionUpdateInfoBarDelegate::Cancel() {
189 base::ResetAndReturn(&callback_).Run(false); 192 base::ResetAndReturn(&callback_).Run(false);
190 return true; 193 return true;
191 } 194 }
192 195
193 void PermissionUpdateInfoBarDelegate::InfoBarDismissed() { 196 void PermissionUpdateInfoBarDelegate::InfoBarDismissed() {
194 base::ResetAndReturn(&callback_).Run(false); 197 base::ResetAndReturn(&callback_).Run(false);
195 } 198 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698