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

Side by Side Diff: chrome/common/extensions/extension.cc

Issue 3116011: Revert 56059 - Merge 55103 - Refactored extension privilege enumeration and i... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Created 10 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
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/extensions/extension_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/extension.h" 5 #include "chrome/common/extensions/extension.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 // Otherwise, if the new extension has a plugin, it's a privilege increase. 843 // Otherwise, if the new extension has a plugin, it's a privilege increase.
844 if (new_extension->plugins().size() > 0) 844 if (new_extension->plugins().size() > 0)
845 return true; 845 return true;
846 846
847 // If we are increasing the set of hosts we have access to, it's a privilege 847 // If we are increasing the set of hosts we have access to, it's a privilege
848 // increase. 848 // increase.
849 if (!old_extension->HasAccessToAllHosts()) { 849 if (!old_extension->HasAccessToAllHosts()) {
850 if (new_extension->HasAccessToAllHosts()) 850 if (new_extension->HasAccessToAllHosts())
851 return true; 851 return true;
852 852
853 ExtensionExtent::PatternList old_hosts = 853 std::set<std::string> old_hosts =
854 old_extension->GetEffectiveHostPermissions().patterns(); 854 old_extension->GetEffectiveHostPermissions();
855 ExtensionExtent::PatternList new_hosts = 855 std::set<std::string> new_hosts =
856 new_extension->GetEffectiveHostPermissions().patterns(); 856 new_extension->GetEffectiveHostPermissions();
857 857
858 std::set<URLPattern, URLPattern::EffectiveHostCompareFunctor> diff; 858 std::set<std::string> difference;
859 std::set_difference(new_hosts.begin(), new_hosts.end(), 859 std::set_difference(new_hosts.begin(), new_hosts.end(),
860 old_hosts.begin(), old_hosts.end(), 860 old_hosts.begin(), old_hosts.end(),
861 std::insert_iterator<std::set<URLPattern, 861 std::insert_iterator<std::set<std::string> >(
862 URLPattern::EffectiveHostCompareFunctor> >(diff, diff.end()), 862 difference, difference.end()));
863 URLPattern::EffectiveHostCompare); 863 if (difference.size() > 0)
864 if (diff.size() > 0)
865 return true; 864 return true;
866 } 865 }
867 866
868 if (!old_extension->HasEffectiveBrowsingHistoryPermission() && 867 if (!old_extension->HasEffectiveBrowsingHistoryPermission() &&
869 new_extension->HasEffectiveBrowsingHistoryPermission()) { 868 new_extension->HasEffectiveBrowsingHistoryPermission()) {
870 return true; 869 return true;
871 } 870 }
872 871
873 const SimplePermissions& simple_permissions = GetSimplePermissions(); 872 const SimplePermissions& simple_permissions = GetSimplePermissions();
874 for (SimplePermissions::const_iterator iter = simple_permissions.begin(); 873 for (SimplePermissions::const_iterator iter = simple_permissions.begin();
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 1671
1673 bool Extension::HasHostPermission(const GURL& url) const { 1672 bool Extension::HasHostPermission(const GURL& url) const {
1674 for (URLPatternList::const_iterator host = host_permissions_.begin(); 1673 for (URLPatternList::const_iterator host = host_permissions_.begin();
1675 host != host_permissions_.end(); ++host) { 1674 host != host_permissions_.end(); ++host) {
1676 if (host->MatchesUrl(url)) 1675 if (host->MatchesUrl(url))
1677 return true; 1676 return true;
1678 } 1677 }
1679 return false; 1678 return false;
1680 } 1679 }
1681 1680
1682 const ExtensionExtent Extension::GetEffectiveHostPermissions() const { 1681 const std::set<std::string> Extension::GetEffectiveHostPermissions() const {
1683 ExtensionExtent effective_hosts; 1682 std::set<std::string> effective_hosts;
1684 1683
1685 for (URLPatternList::const_iterator host = host_permissions_.begin(); 1684 for (URLPatternList::const_iterator host = host_permissions_.begin();
1686 host != host_permissions_.end(); ++host) 1685 host != host_permissions_.end(); ++host)
1687 effective_hosts.AddPattern(*host); 1686 effective_hosts.insert(host->host());
1688 1687
1689 for (UserScriptList::const_iterator content_script = content_scripts_.begin(); 1688 for (UserScriptList::const_iterator content_script = content_scripts_.begin();
1690 content_script != content_scripts_.end(); ++content_script) { 1689 content_script != content_scripts_.end(); ++content_script) {
1691 UserScript::PatternList::const_iterator pattern = 1690 UserScript::PatternList::const_iterator pattern =
1692 content_script->url_patterns().begin(); 1691 content_script->url_patterns().begin();
1693 for (; pattern != content_script->url_patterns().end(); ++pattern) 1692 for (; pattern != content_script->url_patterns().end(); ++pattern)
1694 effective_hosts.AddPattern(*pattern); 1693 effective_hosts.insert(pattern->host());
1695 } 1694 }
1696 1695
1697 return effective_hosts; 1696 return effective_hosts;
1698 } 1697 }
1699 1698
1700 bool Extension::HasAccessToAllHosts() const { 1699 bool Extension::HasAccessToAllHosts() const {
1701 for (URLPatternList::const_iterator host = host_permissions_.begin(); 1700 for (URLPatternList::const_iterator host = host_permissions_.begin();
1702 host != host_permissions_.end(); ++host) { 1701 host != host_permissions_.end(); ++host) {
1703 if (host->match_subdomains() && host->host().empty()) 1702 if (host->match_subdomains() && host->host().empty())
1704 return true; 1703 return true;
(...skipping 26 matching lines...) Expand all
1731 } else { 1730 } else {
1732 return false; 1731 return false;
1733 } 1732 }
1734 } else { 1733 } else {
1735 return true; 1734 return true;
1736 } 1735 }
1737 } 1736 }
1738 } 1737 }
1739 return false; 1738 return false;
1740 } 1739 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/extensions/extension_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698