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

Side by Side Diff: chrome/common/extensions/permissions/permission_message.cc

Issue 10675007: Move each permission classes to its own files in extensions/permissions (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase again Created 8 years, 5 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
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/common/extensions/permissions/permission_message.h"
6
7 #include "base/string_number_conversions.h"
8 #include "base/utf_string_conversions.h"
9 #include "grit/generated_resources.h"
10 #include "ui/base/l10n/l10n_util.h"
11
12 namespace extensions {
13 //
14 // PermissionMessage
15 //
16
17 // static
18 PermissionMessage PermissionMessage::CreateFromHostList(
19 const std::set<std::string>& hosts) {
20 std::vector<std::string> host_list(hosts.begin(), hosts.end());
21 DCHECK_GT(host_list.size(), 0UL);
22 ID message_id;
23 string16 message;
24
25 switch (host_list.size()) {
26 case 1:
27 message_id = kHosts1;
28 message = l10n_util::GetStringFUTF16(IDS_EXTENSION_PROMPT_WARNING_1_HOST,
29 UTF8ToUTF16(host_list[0]));
30 break;
31 case 2:
32 message_id = kHosts2;
33 message = l10n_util::GetStringFUTF16(IDS_EXTENSION_PROMPT_WARNING_2_HOSTS,
34 UTF8ToUTF16(host_list[0]),
35 UTF8ToUTF16(host_list[1]));
36 break;
37 case 3:
38 message_id = kHosts3;
39 message = l10n_util::GetStringFUTF16(IDS_EXTENSION_PROMPT_WARNING_3_HOSTS,
40 UTF8ToUTF16(host_list[0]),
41 UTF8ToUTF16(host_list[1]),
42 UTF8ToUTF16(host_list[2]));
43 break;
44 default:
45 message_id = kHosts4OrMore;
46 message = l10n_util::GetStringFUTF16(
47 IDS_EXTENSION_PROMPT_WARNING_4_OR_MORE_HOSTS,
48 UTF8ToUTF16(host_list[0]),
49 UTF8ToUTF16(host_list[1]),
50 base::IntToString16(hosts.size() - 2));
51 break;
52 }
53
54 return PermissionMessage(message_id, message);
55 }
56
57 PermissionMessage::PermissionMessage(
58 PermissionMessage::ID id, const string16& message)
59 : id_(id), message_(message) {
60 }
61
62 PermissionMessage::~PermissionMessage() {}
63
64 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/permissions/permission_message.h ('k') | chrome/common/extensions/permissions/permission_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698