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

Side by Side Diff: chrome/common/extensions/permissions/api_permission.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/api_permission.h"
6
7 #include "chrome/common/extensions/permissions/permissions_info.h"
8 #include "grit/generated_resources.h"
9 #include "ui/base/l10n/l10n_util.h"
10
11 namespace {
12
13 const char kOldUnlimitedStoragePermission[] = "unlimited_storage";
14 const char kWindowsPermission[] = "windows";
15 const char kTemporaryBackgroundAlias[] = "background_alias_do_not_use";
16
17 } // namespace
18
19 namespace extensions {
20
21 //
22 // APIPermission
23 //
24
25 APIPermission::~APIPermission() {}
26
27 PermissionMessage APIPermission::GetMessage_() const {
28 return PermissionMessage(
29 message_id_, l10n_util::GetStringUTF16(l10n_message_id_));
30 }
31
32 APIPermission::APIPermission(
33 ID id,
34 const char* name,
35 int l10n_message_id,
36 PermissionMessage::ID message_id,
37 int flags)
38 : id_(id),
39 name_(name),
40 flags_(flags),
41 l10n_message_id_(l10n_message_id),
42 message_id_(message_id) {}
43
44 // static
45 void APIPermission::RegisterAllPermissions(
46 PermissionsInfo* info) {
47
48 struct PermissionRegistration {
49 APIPermission::ID id;
50 const char* name;
51 int flags;
52 int l10n_message_id;
53 PermissionMessage::ID message_id;
54 } PermissionsToRegister[] = {
55 // Register permissions for all extension types.
56 { kBackground, "background" },
57 { kClipboardRead, "clipboardRead", kFlagNone,
58 IDS_EXTENSION_PROMPT_WARNING_CLIPBOARD,
59 PermissionMessage::kClipboard },
60 { kClipboardWrite, "clipboardWrite" },
61 { kDeclarative, "declarative" },
62 { kDeclarativeWebRequest, "declarativeWebRequest" },
63 { kDownloads, "downloads", kFlagNone,
64 IDS_EXTENSION_PROMPT_WARNING_DOWNLOADS,
65 PermissionMessage::kDownloads },
66 { kExperimental, "experimental", kFlagCannotBeOptional },
67 { kGeolocation, "geolocation", kFlagCannotBeOptional,
68 IDS_EXTENSION_PROMPT_WARNING_GEOLOCATION,
69 PermissionMessage::kGeolocation },
70 { kNotification, "notifications" },
71 { kUnlimitedStorage, "unlimitedStorage", kFlagCannotBeOptional },
72
73 // Register hosted and packaged app permissions.
74 { kAppNotifications, "appNotifications" },
75
76 // Register extension permissions.
77 { kActiveTab, "activeTab" },
78 { kAlarms, "alarms" },
79 { kBookmark, "bookmarks", kFlagNone,
80 IDS_EXTENSION_PROMPT_WARNING_BOOKMARKS,
81 PermissionMessage::kBookmarks },
82 { kBrowsingData, "browsingData" },
83 { kContentSettings, "contentSettings", kFlagNone,
84 IDS_EXTENSION_PROMPT_WARNING_CONTENT_SETTINGS,
85 PermissionMessage::kContentSettings },
86 { kContextMenus, "contextMenus" },
87 { kCookie, "cookies" },
88 { kFileBrowserHandler, "fileBrowserHandler", kFlagCannotBeOptional },
89 { kFileSystem, "fileSystem" },
90 { kHistory, "history", kFlagNone,
91 IDS_EXTENSION_PROMPT_WARNING_BROWSING_HISTORY,
92 PermissionMessage::kBrowsingHistory },
93 { kKeybinding, "keybinding" },
94 { kIdle, "idle" },
95 { kInput, "input", kFlagNone,
96 IDS_EXTENSION_PROMPT_WARNING_INPUT,
97 PermissionMessage::kInput },
98 { kManagement, "management", kFlagNone,
99 IDS_EXTENSION_PROMPT_WARNING_MANAGEMENT,
100 PermissionMessage::kManagement },
101 { kPageCapture, "pageCapture", kFlagNone,
102 IDS_EXTENSION_PROMPT_WARNING_ALL_PAGES_CONTENT,
103 PermissionMessage::kAllPageContent },
104 { kPrivacy, "privacy", kFlagNone,
105 IDS_EXTENSION_PROMPT_WARNING_PRIVACY,
106 PermissionMessage::kPrivacy },
107 { kStorage, "storage" },
108 { kTab, "tabs", kFlagNone,
109 IDS_EXTENSION_PROMPT_WARNING_TABS,
110 PermissionMessage::kTabs },
111 { kTopSites, "topSites", kFlagNone,
112 IDS_EXTENSION_PROMPT_WARNING_BROWSING_HISTORY,
113 PermissionMessage::kBrowsingHistory },
114 { kTts, "tts", 0, kFlagCannotBeOptional },
115 { kTtsEngine, "ttsEngine", kFlagCannotBeOptional,
116 IDS_EXTENSION_PROMPT_WARNING_TTS_ENGINE,
117 PermissionMessage::kTtsEngine },
118 { kUsb, "usb", kFlagNone,
119 IDS_EXTENSION_PROMPT_WARNING_USB,
120 PermissionMessage::kNone },
121 { kWebNavigation, "webNavigation", kFlagNone,
122 IDS_EXTENSION_PROMPT_WARNING_TABS, PermissionMessage::kTabs },
123 { kWebRequest, "webRequest" },
124 { kWebRequestBlocking, "webRequestBlocking" },
125
126 // Register private permissions.
127 { kChromeosInfoPrivate, "chromeosInfoPrivate", kFlagCannotBeOptional },
128 { kFileBrowserHandlerInternal, "fileBrowserHandlerInternal",
129 kFlagCannotBeOptional },
130 { kFileBrowserPrivate, "fileBrowserPrivate", kFlagCannotBeOptional },
131 { kManagedModePrivate, "managedModePrivate", kFlagCannotBeOptional },
132 { kMediaPlayerPrivate, "mediaPlayerPrivate", kFlagCannotBeOptional },
133 { kMetricsPrivate, "metricsPrivate", kFlagCannotBeOptional },
134 { kSystemPrivate, "systemPrivate", kFlagCannotBeOptional },
135 { kChromeAuthPrivate, "chromeAuthPrivate", kFlagCannotBeOptional },
136 { kInputMethodPrivate, "inputMethodPrivate", kFlagCannotBeOptional },
137 { kEchoPrivate, "echoPrivate", kFlagCannotBeOptional },
138 { kTerminalPrivate, "terminalPrivate", kFlagCannotBeOptional },
139 { kWebRequestInternal, "webRequestInternal", kFlagCannotBeOptional },
140 { kWebSocketProxyPrivate, "webSocketProxyPrivate", kFlagCannotBeOptional },
141 { kWebstorePrivate, "webstorePrivate", kFlagCannotBeOptional },
142
143 // Full url access permissions.
144 { kProxy, "proxy", kFlagImpliesFullURLAccess | kFlagCannotBeOptional },
145 { kDebugger, "debugger", kFlagImpliesFullURLAccess | kFlagCannotBeOptional,
146 IDS_EXTENSION_PROMPT_WARNING_DEBUGGER,
147 PermissionMessage::kDebugger },
148 { kDevtools, "devtools",
149 kFlagImpliesFullURLAccess | kFlagCannotBeOptional },
150 { kPlugin, "plugin",
151 kFlagImpliesFullURLAccess | kFlagImpliesFullAccess |
152 kFlagCannotBeOptional,
153 IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS,
154 PermissionMessage::kFullAccess },
155
156 // Platform-app permissions.
157 { kSocket, "socket", kFlagCannotBeOptional },
158 { kAppWindow, "appWindow" },
159 { kAudioCapture, "audioCapture", kFlagNone,
160 IDS_EXTENSION_PROMPT_WARNING_AUDIO_CAPTURE,
161 PermissionMessage::kAudioCapture },
162 { kVideoCapture, "videoCapture", kFlagNone,
163 IDS_EXTENSION_PROMPT_WARNING_VIDEO_CAPTURE,
164 PermissionMessage::kVideoCapture },
165 };
166
167 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(PermissionsToRegister); ++i) {
168 const PermissionRegistration& pr = PermissionsToRegister[i];
169 info->RegisterPermission(
170 pr.id, pr.name, pr.l10n_message_id,
171 pr.message_id ? pr.message_id : PermissionMessage::kNone,
172 pr.flags);
173 }
174
175 // Register aliases.
176 info->RegisterAlias("unlimitedStorage", kOldUnlimitedStoragePermission);
177 info->RegisterAlias("tabs", kWindowsPermission);
178 // TODO(mihaip): Should be removed for the M20 branch, see
179 // http://crbug.com/120447 for more details.
180 info->RegisterAlias("background", kTemporaryBackgroundAlias);
181 }
182
183 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/permissions/api_permission.h ('k') | chrome/common/extensions/permissions/permission_message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698