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

Side by Side Diff: extensions/common/permissions/permission_message_util.cc

Issue 859993002: Using "static_assert" in lieu of "COMPILE_ASSERT" in extensions module (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « extensions/common/permissions/permission_message.h ('k') | extensions/common/url_pattern.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 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
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
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
OLDNEW
« no previous file with comments | « extensions/common/permissions/permission_message.h ('k') | extensions/common/url_pattern.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698