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

Side by Side Diff: chrome/common/extensions/permissions/chrome_permission_message_provider.cc

Issue 336313009: Showing devices transport method in one device (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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/app/generated_resources.grd ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/common/extensions/permissions/chrome_permission_message_provide r.h" 5 #include "chrome/common/extensions/permissions/chrome_permission_message_provide r.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "extensions/common/extensions_client.h" 9 #include "extensions/common/extensions_client.h"
10 #include "extensions/common/permissions/permission_message.h" 10 #include "extensions/common/permissions/permission_message.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 Manifest::Type extension_type) const { 104 Manifest::Type extension_type) const {
105 std::vector<base::string16> message_strings; 105 std::vector<base::string16> message_strings;
106 PermissionMessages messages = 106 PermissionMessages messages =
107 GetPermissionMessages(permissions, extension_type); 107 GetPermissionMessages(permissions, extension_type);
108 108
109 bool audio_capture = false; 109 bool audio_capture = false;
110 bool video_capture = false; 110 bool video_capture = false;
111 bool media_galleries_read = false; 111 bool media_galleries_read = false;
112 bool media_galleries_copy_to = false; 112 bool media_galleries_copy_to = false;
113 bool media_galleries_delete = false; 113 bool media_galleries_delete = false;
114 int access_to_devices = 0;
115 bool access_to_devices_message_pushed = false;
114 for (PermissionMessages::const_iterator i = messages.begin(); 116 for (PermissionMessages::const_iterator i = messages.begin();
115 i != messages.end(); ++i) { 117 i != messages.end(); ++i) {
116 switch (i->id()) { 118 switch (i->id()) {
117 case PermissionMessage::kAudioCapture: 119 case PermissionMessage::kAudioCapture:
118 audio_capture = true; 120 audio_capture = true;
119 break; 121 break;
120 case PermissionMessage::kVideoCapture: 122 case PermissionMessage::kVideoCapture:
121 video_capture = true; 123 video_capture = true;
122 break; 124 break;
123 case PermissionMessage::kMediaGalleriesAllGalleriesRead: 125 case PermissionMessage::kMediaGalleriesAllGalleriesRead:
124 media_galleries_read = true; 126 media_galleries_read = true;
125 break; 127 break;
126 case PermissionMessage::kMediaGalleriesAllGalleriesCopyTo: 128 case PermissionMessage::kMediaGalleriesAllGalleriesCopyTo:
127 media_galleries_copy_to = true; 129 media_galleries_copy_to = true;
128 break; 130 break;
129 case PermissionMessage::kMediaGalleriesAllGalleriesDelete: 131 case PermissionMessage::kMediaGalleriesAllGalleriesDelete:
130 media_galleries_delete = true; 132 media_galleries_delete = true;
131 break; 133 break;
134 case PermissionMessage::kBluetoothDevices:
135 case PermissionMessage::kHid:
136 case PermissionMessage::kSerial:
137 case PermissionMessage::kUsbDevice:
meacer 2014/06/18 02:25:02 These should be kUsb and kBluetooth instead, as th
Ken Rockot(use gerrit already) 2014/06/18 21:06:17 kUsb and kBluetooth are correct, yes. The k[Usb,B
mhm 2014/06/18 22:16:44 rockot@ aren't these two only used to list the Blu
138 access_to_devices += 1;
132 default: 139 default:
133 break; 140 break;
134 } 141 }
135 } 142 }
136 143
137 for (PermissionMessages::const_iterator i = messages.begin(); 144 for (PermissionMessages::const_iterator i = messages.begin();
138 i != messages.end(); ++i) { 145 i != messages.end(); ++i) {
139 int id = i->id(); 146 int id = i->id();
147 if (access_to_devices > 1) {
148 if (!access_to_devices_message_pushed) {
149 message_strings.push_back(
150 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_DEVICES));
151 access_to_devices_message_pushed = true;
152 continue;
153 }
154 if (id == PermissionMessage::kBluetoothDevices ||
155 id == PermissionMessage::kHid || id == PermissionMessage::kSerial ||
156 id == PermissionMessage::kUsbDevice) {
157 continue;
158 }
not at google - send to devlin 2014/06/18 20:53:32 I think the upgrade path here is a bit weird. What
159 }
140 if (audio_capture && video_capture) { 160 if (audio_capture && video_capture) {
141 if (id == PermissionMessage::kAudioCapture) { 161 if (id == PermissionMessage::kAudioCapture) {
142 message_strings.push_back(l10n_util::GetStringUTF16( 162 message_strings.push_back(l10n_util::GetStringUTF16(
143 IDS_EXTENSION_PROMPT_WARNING_AUDIO_AND_VIDEO_CAPTURE)); 163 IDS_EXTENSION_PROMPT_WARNING_AUDIO_AND_VIDEO_CAPTURE));
144 continue; 164 continue;
145 } else if (id == PermissionMessage::kVideoCapture) { 165 } else if (id == PermissionMessage::kVideoCapture) {
146 // The combined message will be pushed above. 166 // The combined message will be pushed above.
147 continue; 167 continue;
148 } 168 }
149 } 169 }
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 std::set<std::string> old_hosts_set( 387 std::set<std::string> old_hosts_set(
368 permission_message_util::GetDistinctHosts(old_list, false, false)); 388 permission_message_util::GetDistinctHosts(old_list, false, false));
369 std::set<std::string> new_hosts_only = 389 std::set<std::string> new_hosts_only =
370 base::STLSetDifference<std::set<std::string> >(new_hosts_set, 390 base::STLSetDifference<std::set<std::string> >(new_hosts_set,
371 old_hosts_set); 391 old_hosts_set);
372 392
373 return !new_hosts_only.empty(); 393 return !new_hosts_only.empty();
374 } 394 }
375 395
376 } // namespace extensions 396 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698