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

Unified Diff: chrome/common/extensions/permissions/permission_message.cc

Issue 10649003: 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 on HEAD Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/permissions/permission_message.cc
diff --git a/chrome/common/extensions/permissions/permission_message.cc b/chrome/common/extensions/permissions/permission_message.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0847f0a01fe6c1c0c6bc74542b9e906ea097e0a1
--- /dev/null
+++ b/chrome/common/extensions/permissions/permission_message.cc
@@ -0,0 +1,64 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/extensions/permissions/permission_message.h"
+
+#include "base/string_number_conversions.h"
+#include "base/utf_string_conversions.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace extensions {
+//
+// PermissionMessage
+//
+
+// static
+PermissionMessage PermissionMessage::CreateFromHostList(
+ const std::set<std::string>& hosts) {
+ std::vector<std::string> host_list(hosts.begin(), hosts.end());
+ DCHECK_GT(host_list.size(), 0UL);
+ ID message_id;
+ string16 message;
+
+ switch (host_list.size()) {
+ case 1:
+ message_id = kHosts1;
+ message = l10n_util::GetStringFUTF16(IDS_EXTENSION_PROMPT_WARNING_1_HOST,
+ UTF8ToUTF16(host_list[0]));
+ break;
+ case 2:
+ message_id = kHosts2;
+ message = l10n_util::GetStringFUTF16(IDS_EXTENSION_PROMPT_WARNING_2_HOSTS,
+ UTF8ToUTF16(host_list[0]),
+ UTF8ToUTF16(host_list[1]));
+ break;
+ case 3:
+ message_id = kHosts3;
+ message = l10n_util::GetStringFUTF16(IDS_EXTENSION_PROMPT_WARNING_3_HOSTS,
+ UTF8ToUTF16(host_list[0]),
+ UTF8ToUTF16(host_list[1]),
+ UTF8ToUTF16(host_list[2]));
+ break;
+ default:
+ message_id = kHosts4OrMore;
+ message = l10n_util::GetStringFUTF16(
+ IDS_EXTENSION_PROMPT_WARNING_4_OR_MORE_HOSTS,
+ UTF8ToUTF16(host_list[0]),
+ UTF8ToUTF16(host_list[1]),
+ base::IntToString16(hosts.size() - 2));
+ break;
+ }
+
+ return PermissionMessage(message_id, message);
+}
+
+PermissionMessage::PermissionMessage(
+ PermissionMessage::ID id, const string16& message)
+ : id_(id), message_(message) {
+}
+
+PermissionMessage::~PermissionMessage() {}
+
+} // namespace extensions
« 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