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

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

Issue 18854021: Making the extension permissions dialog scrollable, when needed (adding expandable sections for thi… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Even more param reductions Created 7 years, 5 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 return GetDistinctHosts(hosts_displayed_as_url, true, true); 254 return GetDistinctHosts(hosts_displayed_as_url, true, true);
255 } 255 }
256 256
257 PermissionMessages PermissionSet::GetPermissionMessages( 257 PermissionMessages PermissionSet::GetPermissionMessages(
258 Manifest::Type extension_type) const { 258 Manifest::Type extension_type) const {
259 PermissionMessages messages; 259 PermissionMessages messages;
260 260
261 if (HasEffectiveFullAccess()) { 261 if (HasEffectiveFullAccess()) {
262 messages.push_back(PermissionMessage( 262 messages.push_back(PermissionMessage(
263 PermissionMessage::kFullAccess, 263 PermissionMessage::kFullAccess,
264 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS))); 264 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS),
265 string16()));
265 return messages; 266 return messages;
266 } 267 }
267 268
268 std::set<PermissionMessage> host_msgs = 269 std::set<PermissionMessage> host_msgs =
269 GetHostPermissionMessages(extension_type); 270 GetHostPermissionMessages(extension_type);
270 std::set<PermissionMessage> api_msgs = GetAPIPermissionMessages(); 271 std::set<PermissionMessage> api_msgs = GetAPIPermissionMessages();
271 messages.insert(messages.end(), host_msgs.begin(), host_msgs.end()); 272 messages.insert(messages.end(), host_msgs.begin(), host_msgs.end());
272 messages.insert(messages.end(), api_msgs.begin(), api_msgs.end()); 273 messages.insert(messages.end(), api_msgs.begin(), api_msgs.end());
273 274
274 return messages; 275 return messages;
(...skipping 26 matching lines...) Expand all
301 continue; 302 continue;
302 } 303 }
303 } 304 }
304 305
305 messages.push_back(i->message()); 306 messages.push_back(i->message());
306 } 307 }
307 308
308 return messages; 309 return messages;
309 } 310 }
310 311
312 std::vector<string16> PermissionSet::GetWarningMessagesDetails(
313 Manifest::Type extension_type) const {
314 std::vector<string16> messages;
315 PermissionMessages permissions = GetPermissionMessages(extension_type);
316
317 for (PermissionMessages::const_iterator i = permissions.begin();
318 i != permissions.end(); ++i)
319 messages.push_back(i->details());
320
321 return messages;
322 }
323
311 bool PermissionSet::IsEmpty() const { 324 bool PermissionSet::IsEmpty() const {
312 // Not default if any host permissions are present. 325 // Not default if any host permissions are present.
313 if (!(explicit_hosts().is_empty() && scriptable_hosts().is_empty())) 326 if (!(explicit_hosts().is_empty() && scriptable_hosts().is_empty()))
314 return false; 327 return false;
315 328
316 // Or if it has no api permissions. 329 // Or if it has no api permissions.
317 return apis().empty(); 330 return apis().empty();
318 } 331 }
319 332
320 bool PermissionSet::HasAPIPermission( 333 bool PermissionSet::HasAPIPermission(
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 // access user data on other domains, so there's no need to prompt. 556 // access user data on other domains, so there's no need to prompt.
544 // Note: this must remain consistent with HasLessHostPrivilegesThan. 557 // Note: this must remain consistent with HasLessHostPrivilegesThan.
545 // See crbug.com/255229. 558 // See crbug.com/255229.
546 std::set<PermissionMessage> messages; 559 std::set<PermissionMessage> messages;
547 if (extension_type == Manifest::TYPE_PLATFORM_APP) 560 if (extension_type == Manifest::TYPE_PLATFORM_APP)
548 return messages; 561 return messages;
549 562
550 if (HasEffectiveAccessToAllHosts()) { 563 if (HasEffectiveAccessToAllHosts()) {
551 messages.insert(PermissionMessage( 564 messages.insert(PermissionMessage(
552 PermissionMessage::kHostsAll, 565 PermissionMessage::kHostsAll,
553 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_ALL_HOSTS))); 566 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_ALL_HOSTS),
567 string16()));
554 } else { 568 } else {
555 PermissionMessages additional_warnings = 569 PermissionMessages additional_warnings =
556 GetChromeSchemePermissionWarnings(effective_hosts_); 570 GetChromeSchemePermissionWarnings(effective_hosts_);
557 for (size_t i = 0; i < additional_warnings.size(); ++i) 571 for (size_t i = 0; i < additional_warnings.size(); ++i)
558 messages.insert(additional_warnings[i]); 572 messages.insert(additional_warnings[i]);
559 573
560 std::set<std::string> hosts = GetDistinctHostsForDisplay(); 574 std::set<std::string> hosts = GetDistinctHostsForDisplay();
561 if (!hosts.empty()) 575 if (!hosts.empty())
562 messages.insert(PermissionMessage::CreateFromHostList(hosts)); 576 messages.insert(PermissionMessage::CreateFromHostList(hosts));
563 } 577 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 std::set<std::string> new_hosts_only; 624 std::set<std::string> new_hosts_only;
611 625
612 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), 626 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(),
613 old_hosts_set.begin(), old_hosts_set.end(), 627 old_hosts_set.begin(), old_hosts_set.end(),
614 std::inserter(new_hosts_only, new_hosts_only.begin())); 628 std::inserter(new_hosts_only, new_hosts_only.begin()));
615 629
616 return !new_hosts_only.empty(); 630 return !new_hosts_only.empty();
617 } 631 }
618 632
619 } // namespace extensions 633 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698