Index: chrome/common/extensions/extension.cc |
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc |
index c3b44198ef633361ddf2faaa8486f1611e273f3c..4933e34bba012062cf1740a4beae60f0b0a7ce11 100644 |
--- a/chrome/common/extensions/extension.cc |
+++ b/chrome/common/extensions/extension.cc |
@@ -316,14 +316,14 @@ std::set<string16> Extension::GetSimplePermissionMessages() const { |
return messages; |
} |
-std::vector<std::string> Extension::GetDistinctHosts() const { |
- return GetDistinctHosts(GetEffectiveHostPermissions().patterns()); |
+std::vector<std::string> Extension::GetDistinctHosts(bool include_rcd) const { |
+ return GetDistinctHosts(GetEffectiveHostPermissions().patterns(), |
+ include_rcd); |
} |
// static |
std::vector<std::string> Extension::GetDistinctHosts( |
- const URLPatternList& host_patterns) { |
- |
+ const URLPatternList& host_patterns, bool include_rcd) { |
// Vector because we later want to access these by index. |
std::vector<std::string> distinct_hosts; |
@@ -337,6 +337,8 @@ std::vector<std::string> Extension::GetDistinctHosts( |
if (rcd_set.count(no_rcd)) |
continue; |
rcd_set.insert(no_rcd); |
+ if (!include_rcd) |
+ candidate = no_rcd; |
} |
if (std::find(distinct_hosts.begin(), distinct_hosts.end(), candidate) == |
distinct_hosts.end()) { |
@@ -351,7 +353,8 @@ string16 Extension::GetHostPermissionMessage() const { |
if (HasEffectiveAccessToAllHosts()) |
return l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_WARNING_ALL_HOSTS); |
- std::vector<std::string> hosts = GetDistinctHosts(); |
+ // Include the RCDs in the distinct hosts to make it easier on the users. |
Erik does not do reviews
2010/12/03 17:56:42
buff this comment out a bit:
"...to make it easier
jstritar
2010/12/03 21:52:55
I ended up removing this comment after switching t
|
+ std::vector<std::string> hosts = GetDistinctHosts(true); |
if (hosts.size() == 1) { |
return l10n_util::GetStringFUTF16(IDS_EXTENSION_PROMPT_WARNING_1_HOST, |
UTF8ToUTF16(hosts[0])); |
@@ -1114,12 +1117,14 @@ bool Extension::IsPrivilegeIncrease(const bool granted_full_access, |
if (new_extension->HasEffectiveAccessToAllHosts()) |
return true; |
+ // Get the distinct hosts without the RCDs to make sure we get the same |
+ // hosts regardless of the URL pattern ordering. |
const ExtensionExtent new_extent = |
new_extension->GetEffectiveHostPermissions(); |
std::vector<std::string> new_hosts = |
- GetDistinctHosts(new_extent.patterns()); |
+ GetDistinctHosts(new_extent.patterns(), false); |
std::vector<std::string> old_hosts = |
- GetDistinctHosts(granted_extent.patterns()); |
+ GetDistinctHosts(granted_extent.patterns(), false); |
std::set<std::string> old_hosts_set(old_hosts.begin(), old_hosts.end()); |
std::set<std::string> new_hosts_set(new_hosts.begin(), new_hosts.end()); |