OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/common/permissions/permission_message_util.h" | 5 #include "extensions/common/permissions/permission_message_util.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 IDS_EXTENSION_PROMPT_WARNING_HOSTS_LIST)}; | 79 IDS_EXTENSION_PROMPT_WARNING_HOSTS_LIST)}; |
80 static const MsgPair kReadOnlyMessagesList[] = { | 80 static const MsgPair kReadOnlyMessagesList[] = { |
81 std::make_pair(PermissionMessage::kHosts1ReadOnly, | 81 std::make_pair(PermissionMessage::kHosts1ReadOnly, |
82 IDS_EXTENSION_PROMPT_WARNING_1_HOST_READ_ONLY), | 82 IDS_EXTENSION_PROMPT_WARNING_1_HOST_READ_ONLY), |
83 std::make_pair(PermissionMessage::kHosts2ReadOnly, | 83 std::make_pair(PermissionMessage::kHosts2ReadOnly, |
84 IDS_EXTENSION_PROMPT_WARNING_2_HOSTS_READ_ONLY), | 84 IDS_EXTENSION_PROMPT_WARNING_2_HOSTS_READ_ONLY), |
85 std::make_pair(PermissionMessage::kHosts3ReadOnly, | 85 std::make_pair(PermissionMessage::kHosts3ReadOnly, |
86 IDS_EXTENSION_PROMPT_WARNING_3_HOSTS_READ_ONLY), | 86 IDS_EXTENSION_PROMPT_WARNING_3_HOSTS_READ_ONLY), |
87 std::make_pair(PermissionMessage::kHosts4OrMoreReadOnly, | 87 std::make_pair(PermissionMessage::kHosts4OrMoreReadOnly, |
88 IDS_EXTENSION_PROMPT_WARNING_HOSTS_LIST_READ_ONLY)}; | 88 IDS_EXTENSION_PROMPT_WARNING_HOSTS_LIST_READ_ONLY)}; |
89 COMPILE_ASSERT( | 89 static_assert( |
90 arraysize(kReadWriteMessagesList) == arraysize(kReadOnlyMessagesList), | 90 arraysize(kReadWriteMessagesList) == arraysize(kReadOnlyMessagesList), |
91 message_lists_different_size); | 91 "message lists should be of different size"); |
92 COMPILE_ASSERT(kNumMessages == arraysize(kReadWriteMessagesList), | 92 static_assert(kNumMessages == arraysize(kReadWriteMessagesList), |
93 messages_array_different_size); | 93 "messages array should be of different size"); |
94 | 94 |
95 const MsgPair(&messages_list)[kNumMessages] = | 95 const MsgPair(&messages_list)[kNumMessages] = |
96 properties == kReadOnly ? kReadOnlyMessagesList : kReadWriteMessagesList; | 96 properties == kReadOnly ? kReadOnlyMessagesList : kReadWriteMessagesList; |
97 std::vector<base::string16> host_list = | 97 std::vector<base::string16> host_list = |
98 GetHostListFromHosts(hosts, properties); | 98 GetHostListFromHosts(hosts, properties); |
99 | 99 |
100 if (host_list.size() < kNumMessages) { | 100 if (host_list.size() < kNumMessages) { |
101 return PermissionMessage( | 101 return PermissionMessage( |
102 messages_list[host_list.size() - 1].first, | 102 messages_list[host_list.size() - 1].first, |
103 l10n_util::GetStringFUTF16(messages_list[host_list.size() - 1].second, | 103 l10n_util::GetStringFUTF16(messages_list[host_list.size() - 1].second, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 // Build up the final vector by concatenating hosts and RCDs. | 185 // Build up the final vector by concatenating hosts and RCDs. |
186 std::set<std::string> distinct_hosts; | 186 std::set<std::string> distinct_hosts; |
187 for (HostVector::iterator it = hosts_best_rcd.begin(); | 187 for (HostVector::iterator it = hosts_best_rcd.begin(); |
188 it != hosts_best_rcd.end(); | 188 it != hosts_best_rcd.end(); |
189 ++it) | 189 ++it) |
190 distinct_hosts.insert(it->first + it->second); | 190 distinct_hosts.insert(it->first + it->second); |
191 return distinct_hosts; | 191 return distinct_hosts; |
192 } | 192 } |
193 | 193 |
194 } // namespace permission_message_util | 194 } // namespace permission_message_util |
OLD | NEW |