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

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

Issue 12093036: Move Extension Location and Type enums to Manifest, and move InstallWarning to its own file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/permission_set.h" 5 #include "chrome/common/extensions/permissions/permission_set.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <string> 9 #include <string>
10 10
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 261
262 return false; 262 return false;
263 } 263 }
264 264
265 std::set<std::string> 265 std::set<std::string>
266 PermissionSet::GetDistinctHostsForDisplay() const { 266 PermissionSet::GetDistinctHostsForDisplay() const {
267 return GetDistinctHosts(effective_hosts_, true, true); 267 return GetDistinctHosts(effective_hosts_, true, true);
268 } 268 }
269 269
270 PermissionMessages PermissionSet::GetPermissionMessages( 270 PermissionMessages PermissionSet::GetPermissionMessages(
271 Extension::Type extension_type) const { 271 Manifest::Type extension_type) const {
272 PermissionMessages messages; 272 PermissionMessages messages;
273 273
274 if (HasEffectiveFullAccess()) { 274 if (HasEffectiveFullAccess()) {
275 messages.push_back(PermissionMessage( 275 messages.push_back(PermissionMessage(
276 PermissionMessage::kFullAccess, 276 PermissionMessage::kFullAccess,
277 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS))); 277 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS)));
278 return messages; 278 return messages;
279 } 279 }
280 280
281 // Since platform apps always use isolated storage, they can't (silently) 281 // Since platform apps always use isolated storage, they can't (silently)
282 // access user data on other domains, so there's no need to prompt. 282 // access user data on other domains, so there's no need to prompt.
283 if (extension_type != Extension::TYPE_PLATFORM_APP) { 283 if (extension_type != Manifest::TYPE_PLATFORM_APP) {
284 if (HasEffectiveAccessToAllHosts()) { 284 if (HasEffectiveAccessToAllHosts()) {
285 messages.push_back(PermissionMessage( 285 messages.push_back(PermissionMessage(
286 PermissionMessage::kHostsAll, 286 PermissionMessage::kHostsAll,
287 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_ALL_HOSTS))); 287 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_ALL_HOSTS)));
288 } else { 288 } else {
289 std::set<std::string> hosts = GetDistinctHostsForDisplay(); 289 std::set<std::string> hosts = GetDistinctHostsForDisplay();
290 if (!hosts.empty()) 290 if (!hosts.empty())
291 messages.push_back(PermissionMessage::CreateFromHostList(hosts)); 291 messages.push_back(PermissionMessage::CreateFromHostList(hosts));
292 } 292 }
293 } 293 }
294 294
295 std::set<PermissionMessage> simple_msgs = 295 std::set<PermissionMessage> simple_msgs =
296 GetSimplePermissionMessages(); 296 GetSimplePermissionMessages();
297 messages.insert(messages.end(), simple_msgs.begin(), simple_msgs.end()); 297 messages.insert(messages.end(), simple_msgs.begin(), simple_msgs.end());
298 298
299 return messages; 299 return messages;
300 } 300 }
301 301
302 std::vector<string16> PermissionSet::GetWarningMessages( 302 std::vector<string16> PermissionSet::GetWarningMessages(
303 Extension::Type extension_type) const { 303 Manifest::Type extension_type) const {
304 std::vector<string16> messages; 304 std::vector<string16> messages;
305 PermissionMessages permissions = GetPermissionMessages(extension_type); 305 PermissionMessages permissions = GetPermissionMessages(extension_type);
306 306
307 bool audio_capture = false; 307 bool audio_capture = false;
308 bool video_capture = false; 308 bool video_capture = false;
309 for (PermissionMessages::const_iterator i = permissions.begin(); 309 for (PermissionMessages::const_iterator i = permissions.begin();
310 i != permissions.end(); ++i) { 310 i != permissions.end(); ++i) {
311 if (i->id() == PermissionMessage::kAudioCapture) 311 if (i->id() == PermissionMessage::kAudioCapture)
312 audio_capture = true; 312 audio_capture = true;
313 if (i->id() == PermissionMessage::kVideoCapture) 313 if (i->id() == PermissionMessage::kVideoCapture)
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 std::set<std::string> new_hosts_only; 607 std::set<std::string> new_hosts_only;
608 608
609 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), 609 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(),
610 old_hosts_set.begin(), old_hosts_set.end(), 610 old_hosts_set.begin(), old_hosts_set.end(),
611 std::inserter(new_hosts_only, new_hosts_only.begin())); 611 std::inserter(new_hosts_only, new_hosts_only.begin()));
612 612
613 return !new_hosts_only.empty(); 613 return !new_hosts_only.empty();
614 } 614 }
615 615
616 } // namespace extensions 616 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/permissions/permission_set.h ('k') | chrome/common/extensions/permissions/permission_set_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698