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

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

Issue 10837060: Don't show host permission warnings for platform apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 4 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 } 257 }
258 258
259 return false; 259 return false;
260 } 260 }
261 261
262 std::set<std::string> 262 std::set<std::string>
263 PermissionSet::GetDistinctHostsForDisplay() const { 263 PermissionSet::GetDistinctHostsForDisplay() const {
264 return GetDistinctHosts(effective_hosts_, true, true); 264 return GetDistinctHosts(effective_hosts_, true, true);
265 } 265 }
266 266
267 PermissionMessages 267 PermissionMessages PermissionSet::GetPermissionMessages(
268 PermissionSet::GetPermissionMessages() const { 268 Extension::Type extension_type) const {
269 PermissionMessages messages; 269 PermissionMessages messages;
270 270
271 if (HasEffectiveFullAccess()) { 271 if (HasEffectiveFullAccess()) {
272 messages.push_back(PermissionMessage( 272 messages.push_back(PermissionMessage(
273 PermissionMessage::kFullAccess, 273 PermissionMessage::kFullAccess,
274 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS))); 274 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS)));
275 return messages; 275 return messages;
276 } 276 }
277 277
278 if (HasEffectiveAccessToAllHosts()) { 278 // Since platform apps always use isolated storage, they can't (silently)
279 messages.push_back(PermissionMessage( 279 // access user data on other domains, so there's no need to prompt.
280 PermissionMessage::kHostsAll, 280 if (extension_type != Extension::TYPE_PLATFORM_APP) {
281 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_ALL_HOSTS))); 281 if (HasEffectiveAccessToAllHosts()) {
282 } else { 282 messages.push_back(PermissionMessage(
283 std::set<std::string> hosts = GetDistinctHostsForDisplay(); 283 PermissionMessage::kHostsAll,
284 if (!hosts.empty()) 284 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_ALL_HOSTS)));
285 messages.push_back(PermissionMessage::CreateFromHostList(hosts)); 285 } else {
286 std::set<std::string> hosts = GetDistinctHostsForDisplay();
287 if (!hosts.empty())
288 messages.push_back(PermissionMessage::CreateFromHostList(hosts));
289 }
286 } 290 }
287 291
288 std::set<PermissionMessage> simple_msgs = 292 std::set<PermissionMessage> simple_msgs =
289 GetSimplePermissionMessages(); 293 GetSimplePermissionMessages();
290 messages.insert(messages.end(), simple_msgs.begin(), simple_msgs.end()); 294 messages.insert(messages.end(), simple_msgs.begin(), simple_msgs.end());
291 295
292 return messages; 296 return messages;
293 } 297 }
294 298
295 std::vector<string16> PermissionSet::GetWarningMessages() const { 299 std::vector<string16> PermissionSet::GetWarningMessages(
300 Extension::Type extension_type) const {
296 std::vector<string16> messages; 301 std::vector<string16> messages;
297 PermissionMessages permissions = GetPermissionMessages(); 302 PermissionMessages permissions = GetPermissionMessages(extension_type);
298 303
299 bool audio_capture = false; 304 bool audio_capture = false;
300 bool video_capture = false; 305 bool video_capture = false;
301 for (PermissionMessages::const_iterator i = permissions.begin(); 306 for (PermissionMessages::const_iterator i = permissions.begin();
302 i != permissions.end(); ++i) { 307 i != permissions.end(); ++i) {
303 if (i->id() == PermissionMessage::kAudioCapture) 308 if (i->id() == PermissionMessage::kAudioCapture)
304 audio_capture = true; 309 audio_capture = true;
305 if (i->id() == PermissionMessage::kVideoCapture) 310 if (i->id() == PermissionMessage::kVideoCapture)
306 video_capture = true; 311 video_capture = true;
307 } 312 }
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 std::set<std::string> new_hosts_only; 591 std::set<std::string> new_hosts_only;
587 592
588 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), 593 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(),
589 old_hosts_set.begin(), old_hosts_set.end(), 594 old_hosts_set.begin(), old_hosts_set.end(),
590 std::inserter(new_hosts_only, new_hosts_only.begin())); 595 std::inserter(new_hosts_only, new_hosts_only.begin()));
591 596
592 return !new_hosts_only.empty(); 597 return !new_hosts_only.empty();
593 } 598 }
594 599
595 } // namespace extensions 600 } // 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