OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_permission_set.h" | 5 #include "chrome/common/extensions/extension_permission_set.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 83 |
84 void AddPatternsAndRemovePaths(const URLPatternSet& set, URLPatternSet* out) { | 84 void AddPatternsAndRemovePaths(const URLPatternSet& set, URLPatternSet* out) { |
85 CHECK(out); | 85 CHECK(out); |
86 for (URLPatternSet::const_iterator i = set.begin(); i != set.end(); ++i) { | 86 for (URLPatternSet::const_iterator i = set.begin(); i != set.end(); ++i) { |
87 URLPattern p = *i; | 87 URLPattern p = *i; |
88 p.SetPath("/*"); | 88 p.SetPath("/*"); |
89 out->AddPattern(p); | 89 out->AddPattern(p); |
90 } | 90 } |
91 } | 91 } |
92 | 92 |
93 } // namespace | 93 } // namespace |
94 | 94 |
95 // | 95 // |
96 // PermissionMessage | 96 // PermissionMessage |
97 // | 97 // |
98 | 98 |
99 // static | 99 // static |
100 ExtensionPermissionMessage ExtensionPermissionMessage::CreateFromHostList( | 100 ExtensionPermissionMessage ExtensionPermissionMessage::CreateFromHostList( |
101 const std::set<std::string>& hosts) { | 101 const std::set<std::string>& hosts) { |
102 std::vector<std::string> host_list(hosts.begin(), hosts.end()); | 102 std::vector<std::string> host_list(hosts.begin(), hosts.end()); |
103 CHECK(host_list.size() > 0); | 103 CHECK_GT(host_list.size(), 0UL); |
104 ID message_id; | 104 ID message_id; |
105 string16 message; | 105 string16 message; |
106 | 106 |
107 switch (host_list.size()) { | 107 switch (host_list.size()) { |
108 case 1: | 108 case 1: |
109 message_id = kHosts1; | 109 message_id = kHosts1; |
110 message = l10n_util::GetStringFUTF16(IDS_EXTENSION_PROMPT_WARNING_1_HOST, | 110 message = l10n_util::GetStringFUTF16(IDS_EXTENSION_PROMPT_WARNING_1_HOST, |
111 UTF8ToUTF16(host_list[0])); | 111 UTF8ToUTF16(host_list[0])); |
112 break; | 112 break; |
113 case 2: | 113 case 2: |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 std::set<std::string> new_hosts_set(GetDistinctHosts(new_list, false, false)); | 833 std::set<std::string> new_hosts_set(GetDistinctHosts(new_list, false, false)); |
834 std::set<std::string> old_hosts_set(GetDistinctHosts(old_list, false, false)); | 834 std::set<std::string> old_hosts_set(GetDistinctHosts(old_list, false, false)); |
835 std::set<std::string> new_hosts_only; | 835 std::set<std::string> new_hosts_only; |
836 | 836 |
837 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), | 837 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), |
838 old_hosts_set.begin(), old_hosts_set.end(), | 838 old_hosts_set.begin(), old_hosts_set.end(), |
839 std::inserter(new_hosts_only, new_hosts_only.begin())); | 839 std::inserter(new_hosts_only, new_hosts_only.begin())); |
840 | 840 |
841 return !new_hosts_only.empty(); | 841 return !new_hosts_only.empty(); |
842 } | 842 } |
OLD | NEW |