Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/common/extensions/extension_permission_set.h" | 5 #include "chrome/common/extensions/extension_permission_set.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | |
|
Aaron Boodman
2012/02/02 18:17:31
Not needed.
jstritar
2012/02/03 14:33:17
Woops, I do still need this. I added the command l
| |
| 10 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 11 #include "base/values.h" | 12 #include "base/values.h" |
| 12 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/common/chrome_switches.h" | |
|
Aaron Boodman
2012/02/02 18:17:31
Not needed?
jstritar
2012/02/03 14:33:17
ditto
| |
| 14 #include "chrome/common/extensions/extension.h" | 16 #include "chrome/common/extensions/extension.h" |
| 15 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" |
| 16 #include "chrome/common/extensions/extension_l10n_util.h" | 18 #include "chrome/common/extensions/extension_l10n_util.h" |
| 17 #include "chrome/common/extensions/url_pattern.h" | 19 #include "chrome/common/extensions/url_pattern.h" |
| 18 #include "chrome/common/extensions/url_pattern_set.h" | 20 #include "chrome/common/extensions/url_pattern_set.h" |
| 19 #include "content/public/common/url_constants.h" | 21 #include "content/public/common/url_constants.h" |
| 20 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
| 21 #include "net/base/registry_controlled_domain.h" | 23 #include "net/base/registry_controlled_domain.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 23 | 25 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 const char* kNonPermissionFunctionNames[] = { | 61 const char* kNonPermissionFunctionNames[] = { |
| 60 "management.getPermissionWarningsByManifest", | 62 "management.getPermissionWarningsByManifest", |
| 61 "tabs.create", | 63 "tabs.create", |
| 62 "tabs.onRemoved", | 64 "tabs.onRemoved", |
| 63 "tabs.remove", | 65 "tabs.remove", |
| 64 "tabs.update", | 66 "tabs.update", |
| 65 }; | 67 }; |
| 66 const size_t kNumNonPermissionFunctionNames = | 68 const size_t kNumNonPermissionFunctionNames = |
| 67 arraysize(kNonPermissionFunctionNames); | 69 arraysize(kNonPermissionFunctionNames); |
| 68 | 70 |
| 71 // TODO(jstritar): We should find out what these extensions are. | |
|
Aaron Boodman
2012/02/02 18:17:31
This is a pretty ominous comment :). Can you track
| |
| 72 | |
| 73 // ExtensionAPIPermission::kTerminalPrivate whitelist. | |
| 74 const char* kTerminalPrivateWhitelist[] = { | |
| 75 extension_misc::kHTermAppId, | |
| 76 extension_misc::kHTermDevAppId | |
| 77 }; | |
| 78 | |
| 79 // ExtensionAPIPermission::kWebSocketProxyPrivate whitelist. | |
| 80 // ExtensionAPIPermission::kInputMethodPrivate whitelist. | |
| 81 const char* kChromeOSWhitelist[] = { | |
| 82 "haiffjcadagjlijoggckpgfnoeiflnem", | |
| 83 "gnedhmakppccajfpfiihfcdlnpgomkcf", | |
| 84 "fjcibdnjlbfnbfdjneajpipnlcppleek", | |
| 85 extension_misc::kHTermAppId, | |
| 86 extension_misc::kHTermDevAppId | |
| 87 }; | |
| 88 | |
| 89 // ExtensionAPIPermission::kChromePrivate whitelist. | |
| 90 const char* kChromePrivateWhitelist[] = { | |
| 91 "haiffjcadagjlijoggckpgfnoeiflnem", | |
| 92 "gnedhmakppccajfpfiihfcdlnpgomkcf", | |
| 93 "fjcibdnjlbfnbfdjneajpipnlcppleek" | |
| 94 }; | |
| 95 | |
| 96 // ExtensionAPIPermission::kChromeAuthPrivate whitelist. | |
| 97 const char* kChromeAuthPrivateWhitelist[] = { | |
| 98 extension_misc::kCloudPrintAppId | |
| 99 }; | |
| 100 | |
| 101 // ExtensionAPIPermission::kWebstorePrivate whitelist. | |
| 102 const char* kWebstorePrivateWhitelist[] = { | |
| 103 extension_misc::kEnterpriseWebStoreAppId, | |
| 104 extension_misc::kWebStoreAppId | |
| 105 }; | |
| 106 | |
| 69 const char kOldUnlimitedStoragePermission[] = "unlimited_storage"; | 107 const char kOldUnlimitedStoragePermission[] = "unlimited_storage"; |
| 70 const char kWindowsPermission[] = "windows"; | 108 const char kWindowsPermission[] = "windows"; |
| 71 | 109 |
| 72 void AddPatternsAndRemovePaths(const URLPatternSet& set, URLPatternSet* out) { | 110 void AddPatternsAndRemovePaths(const URLPatternSet& set, URLPatternSet* out) { |
| 73 DCHECK(out); | 111 DCHECK(out); |
| 74 for (URLPatternSet::const_iterator i = set.begin(); i != set.end(); ++i) { | 112 for (URLPatternSet::const_iterator i = set.begin(); i != set.end(); ++i) { |
| 75 URLPattern p = *i; | 113 URLPattern p = *i; |
| 76 p.SetPath("/*"); | 114 p.SetPath("/*"); |
| 77 out->AddPattern(p); | 115 out->AddPattern(p); |
| 78 } | 116 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 kGeolocation, "geolocation", IDS_EXTENSION_PROMPT_WARNING_GEOLOCATION, | 227 kGeolocation, "geolocation", IDS_EXTENSION_PROMPT_WARNING_GEOLOCATION, |
| 190 ExtensionPermissionMessage::kGeolocation, | 228 ExtensionPermissionMessage::kGeolocation, |
| 191 kFlagCannotBeOptional, kTypeAll); | 229 kFlagCannotBeOptional, kTypeAll); |
| 192 info->RegisterPermission( | 230 info->RegisterPermission( |
| 193 kNotification, "notifications", 0, | 231 kNotification, "notifications", 0, |
| 194 ExtensionPermissionMessage::kNone, kFlagNone, kTypeAll); | 232 ExtensionPermissionMessage::kNone, kFlagNone, kTypeAll); |
| 195 info->RegisterPermission( | 233 info->RegisterPermission( |
| 196 kUnlimitedStorage, "unlimitedStorage", 0, | 234 kUnlimitedStorage, "unlimitedStorage", 0, |
| 197 ExtensionPermissionMessage::kNone, kFlagCannotBeOptional, kTypeAll); | 235 ExtensionPermissionMessage::kNone, kFlagCannotBeOptional, kTypeAll); |
| 198 | 236 |
| 199 // Register hosted app permissions that are also private. | |
| 200 info->RegisterPermission( | |
| 201 kChromePrivate, "chromePrivate", 0, | |
| 202 ExtensionPermissionMessage::kNone, kFlagCannotBeOptional, | |
| 203 kTypeAll - kTypePlatformApp); | |
| 204 info->RegisterPermission( | |
| 205 kChromeAuthPrivate, "chromeAuthPrivate", 0, | |
| 206 ExtensionPermissionMessage::kNone, | |
| 207 kFlagComponentOnly | kFlagCannotBeOptional, kTypeAll - kTypePlatformApp); | |
| 208 info->RegisterPermission( | |
| 209 kWebstorePrivate, "webstorePrivate", 0, | |
| 210 ExtensionPermissionMessage::kNone, | |
| 211 kFlagComponentOnly | kFlagCannotBeOptional, kTypeAll - kTypePlatformApp); | |
| 212 | 237 |
| 213 // Register hosted and packaged app permissions. | 238 // Register hosted and packaged app permissions. |
| 214 info->RegisterPermission( | 239 info->RegisterPermission( |
| 215 kAppNotifications, "appNotifications", 0, | 240 kAppNotifications, "appNotifications", 0, |
| 216 ExtensionPermissionMessage::kNone, kFlagNone, | 241 ExtensionPermissionMessage::kNone, kFlagNone, |
| 217 kTypeHostedApp | kTypePackagedApp); | 242 kTypeHostedApp | kTypePackagedApp); |
| 218 | 243 |
| 219 // Register extension permissions. | 244 // Register extension permissions. |
| 220 info->RegisterPermission( | 245 info->RegisterPermission( |
| 221 kBookmark, "bookmarks", IDS_EXTENSION_PROMPT_WARNING_BOOKMARKS, | 246 kBookmark, "bookmarks", IDS_EXTENSION_PROMPT_WARNING_BOOKMARKS, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 238 kHistory, "history", IDS_EXTENSION_PROMPT_WARNING_BROWSING_HISTORY, | 263 kHistory, "history", IDS_EXTENSION_PROMPT_WARNING_BROWSING_HISTORY, |
| 239 ExtensionPermissionMessage::kBrowsingHistory, | 264 ExtensionPermissionMessage::kBrowsingHistory, |
| 240 kFlagNone, kTypeDefault); | 265 kFlagNone, kTypeDefault); |
| 241 info->RegisterPermission( | 266 info->RegisterPermission( |
| 242 kIdle, "idle", 0, ExtensionPermissionMessage::kNone, | 267 kIdle, "idle", 0, ExtensionPermissionMessage::kNone, |
| 243 kFlagNone, kTypeDefault); | 268 kFlagNone, kTypeDefault); |
| 244 info->RegisterPermission( | 269 info->RegisterPermission( |
| 245 kInput, "input", 0, ExtensionPermissionMessage::kNone, | 270 kInput, "input", 0, ExtensionPermissionMessage::kNone, |
| 246 kFlagImpliesFullURLAccess, kTypeDefault); | 271 kFlagImpliesFullURLAccess, kTypeDefault); |
| 247 info->RegisterPermission( | 272 info->RegisterPermission( |
| 248 kInputMethodPrivate, "inputMethodPrivate", 0, | |
| 249 ExtensionPermissionMessage::kNone, kFlagCannotBeOptional, kTypeDefault); | |
| 250 info->RegisterPermission( | |
| 251 kManagement, "management", IDS_EXTENSION_PROMPT_WARNING_MANAGEMENT, | 273 kManagement, "management", IDS_EXTENSION_PROMPT_WARNING_MANAGEMENT, |
| 252 ExtensionPermissionMessage::kManagement, kFlagNone, kTypeDefault); | 274 ExtensionPermissionMessage::kManagement, kFlagNone, kTypeDefault); |
| 253 info->RegisterPermission( | 275 info->RegisterPermission( |
| 254 kPageCapture, "pageCapture", | 276 kPageCapture, "pageCapture", |
| 255 IDS_EXTENSION_PROMPT_WARNING_ALL_PAGES_CONTENT, | 277 IDS_EXTENSION_PROMPT_WARNING_ALL_PAGES_CONTENT, |
| 256 ExtensionPermissionMessage::kAllPageContent, kFlagNone, kTypeDefault); | 278 ExtensionPermissionMessage::kAllPageContent, kFlagNone, kTypeDefault); |
| 257 info->RegisterPermission( | 279 info->RegisterPermission( |
| 258 kPrivacy, "privacy", IDS_EXTENSION_PROMPT_WARNING_PRIVACY, | 280 kPrivacy, "privacy", IDS_EXTENSION_PROMPT_WARNING_PRIVACY, |
| 259 ExtensionPermissionMessage::kPrivacy, kFlagNone, kTypeDefault); | 281 ExtensionPermissionMessage::kPrivacy, kFlagNone, kTypeDefault); |
| 260 info->RegisterPermission( | 282 info->RegisterPermission( |
| 261 kStorage, "storage", 0, | 283 kStorage, "storage", 0, |
| 262 ExtensionPermissionMessage::kNone, kFlagNone, kTypeDefault); | 284 ExtensionPermissionMessage::kNone, kFlagNone, kTypeDefault); |
| 263 info->RegisterPermission( | 285 info->RegisterPermission( |
| 264 kTab, "tabs", IDS_EXTENSION_PROMPT_WARNING_TABS, | 286 kTab, "tabs", IDS_EXTENSION_PROMPT_WARNING_TABS, |
| 265 ExtensionPermissionMessage::kTabs, kFlagNone, | 287 ExtensionPermissionMessage::kTabs, kFlagNone, |
| 266 kTypeDefault - kTypePlatformApp); | 288 kTypeDefault - kTypePlatformApp); |
| 267 info->RegisterPermission( | 289 info->RegisterPermission( |
| 268 kTerminalPrivate, "terminalPrivate", 0, | |
| 269 ExtensionPermissionMessage::kNone, kFlagCannotBeOptional, kTypeDefault); | |
| 270 info->RegisterPermission( | |
| 271 kTts, "tts", 0, | 290 kTts, "tts", 0, |
| 272 ExtensionPermissionMessage::kNone, kFlagCannotBeOptional, kTypeDefault); | 291 ExtensionPermissionMessage::kNone, kFlagCannotBeOptional, kTypeDefault); |
| 273 info->RegisterPermission( | 292 info->RegisterPermission( |
| 274 kTtsEngine, "ttsEngine", IDS_EXTENSION_PROMPT_WARNING_TTS_ENGINE, | 293 kTtsEngine, "ttsEngine", IDS_EXTENSION_PROMPT_WARNING_TTS_ENGINE, |
| 275 ExtensionPermissionMessage::kTtsEngine, | 294 ExtensionPermissionMessage::kTtsEngine, |
| 276 kFlagCannotBeOptional, kTypeDefault); | 295 kFlagCannotBeOptional, kTypeDefault); |
| 277 info->RegisterPermission( | 296 info->RegisterPermission( |
| 278 kWebNavigation, "webNavigation", | 297 kWebNavigation, "webNavigation", |
| 279 IDS_EXTENSION_PROMPT_WARNING_TABS, ExtensionPermissionMessage::kTabs, | 298 IDS_EXTENSION_PROMPT_WARNING_TABS, ExtensionPermissionMessage::kTabs, |
| 280 kFlagNone, kTypeDefault - kTypePlatformApp); | 299 kFlagNone, kTypeDefault - kTypePlatformApp); |
| 281 info->RegisterPermission( | 300 info->RegisterPermission( |
| 282 kWebRequest, "webRequest", 0, ExtensionPermissionMessage::kNone, | 301 kWebRequest, "webRequest", 0, ExtensionPermissionMessage::kNone, |
| 283 kFlagNone, kTypeDefault - kTypePlatformApp); | 302 kFlagNone, kTypeDefault - kTypePlatformApp); |
| 284 info->RegisterPermission( | 303 info->RegisterPermission( |
| 285 kWebRequestBlocking, "webRequestBlocking", 0, | 304 kWebRequestBlocking, "webRequestBlocking", 0, |
| 286 ExtensionPermissionMessage::kNone, kFlagNone, | 305 ExtensionPermissionMessage::kNone, kFlagNone, |
| 287 kTypeDefault - kTypePlatformApp); | 306 kTypeDefault - kTypePlatformApp); |
| 288 info->RegisterPermission( | |
| 289 kWebSocketProxyPrivate, "webSocketProxyPrivate", 0, | |
| 290 ExtensionPermissionMessage::kNone, kFlagCannotBeOptional, | |
| 291 kTypeDefault - kTypePlatformApp); | |
| 292 | 307 |
| 293 // Register private permissions. | 308 // Register private permissions. |
| 309 ExtensionAPIPermission* chromeAuthPrivate = info->RegisterPermission( | |
| 310 kChromeAuthPrivate, "chromeAuthPrivate", 0, | |
| 311 ExtensionPermissionMessage::kNone, | |
| 312 kFlagCannotBeOptional, kTypeAll - kTypePlatformApp); | |
| 313 for (size_t i = 0; i < arraysize(kChromeAuthPrivateWhitelist); ++i) | |
| 314 chromeAuthPrivate->AddToWhitelist(kChromeAuthPrivateWhitelist[i]); | |
| 315 ExtensionAPIPermission* chromePrivate = info->RegisterPermission( | |
| 316 kChromePrivate, "chromePrivate", 0, ExtensionPermissionMessage::kNone, | |
| 317 kFlagCannotBeOptional, kTypeAll - kTypePlatformApp); | |
| 318 for (size_t i = 0; i < arraysize(kChromePrivateWhitelist); ++i) | |
| 319 chromePrivate->AddToWhitelist(kChromePrivateWhitelist[i]); | |
| 294 info->RegisterPermission( | 320 info->RegisterPermission( |
| 295 kChromeosInfoPrivate, "chromeosInfoPrivate", 0, | 321 kChromeosInfoPrivate, "chromeosInfoPrivate", 0, |
| 296 ExtensionPermissionMessage::kNone, | 322 ExtensionPermissionMessage::kNone, |
| 297 kFlagComponentOnly | kFlagCannotBeOptional, kTypeDefault); | 323 kFlagComponentOnly_Deprecated | kFlagCannotBeOptional, kTypeDefault); |
| 298 info->RegisterPermission( | 324 info->RegisterPermission( |
| 299 kFileBrowserPrivate, "fileBrowserPrivate", 0, | 325 kFileBrowserPrivate, "fileBrowserPrivate", 0, |
| 300 ExtensionPermissionMessage::kNone, | 326 ExtensionPermissionMessage::kNone, |
| 301 kFlagComponentOnly | kFlagCannotBeOptional, kTypeDefault); | 327 kFlagComponentOnly_Deprecated | kFlagCannotBeOptional, kTypeDefault); |
| 328 ExtensionAPIPermission* inputMethodPrivate = info->RegisterPermission( | |
| 329 kInputMethodPrivate, "inputMethodPrivate", 0, | |
| 330 ExtensionPermissionMessage::kNone, kFlagCannotBeOptional, kTypeDefault); | |
| 331 for (size_t i = 0; i < arraysize(kChromeOSWhitelist); ++i) | |
| 332 inputMethodPrivate->AddToWhitelist(kChromeOSWhitelist[i]); | |
| 302 info->RegisterPermission( | 333 info->RegisterPermission( |
| 303 kMediaPlayerPrivate, "mediaPlayerPrivate", 0, | 334 kMediaPlayerPrivate, "mediaPlayerPrivate", 0, |
| 304 ExtensionPermissionMessage::kNone, | 335 ExtensionPermissionMessage::kNone, |
| 305 kFlagComponentOnly | kFlagCannotBeOptional, kTypeDefault); | 336 kFlagComponentOnly_Deprecated | kFlagCannotBeOptional, kTypeDefault); |
| 306 info->RegisterPermission( | 337 info->RegisterPermission( |
| 307 kMetricsPrivate, "metricsPrivate", 0, | 338 kMetricsPrivate, "metricsPrivate", 0, |
| 308 ExtensionPermissionMessage::kNone, | 339 ExtensionPermissionMessage::kNone, |
| 309 kFlagComponentOnly | kFlagCannotBeOptional, kTypeDefault); | 340 kFlagComponentOnly_Deprecated | kFlagCannotBeOptional, kTypeDefault); |
| 310 info->RegisterPermission( | 341 info->RegisterPermission( |
| 311 kSystemPrivate, "systemPrivate", 0, | 342 kSystemPrivate, "systemPrivate", 0, |
| 312 ExtensionPermissionMessage::kNone, | 343 ExtensionPermissionMessage::kNone, |
| 313 kFlagComponentOnly | kFlagCannotBeOptional, kTypeDefault); | 344 kFlagComponentOnly_Deprecated | kFlagCannotBeOptional, kTypeDefault); |
| 345 ExtensionAPIPermission* terminalPrivate = info->RegisterPermission( | |
| 346 kTerminalPrivate, "terminalPrivate", 0, ExtensionPermissionMessage::kNone, | |
| 347 kFlagCannotBeOptional, kTypeDefault); | |
| 348 for (size_t i = 0; i < arraysize(kTerminalPrivateWhitelist); ++i) | |
|
Aaron Boodman
2012/02/02 18:17:31
Nit: instead of duplicating this loop everywhere,
jstritar
2012/02/03 14:33:17
Done.
| |
| 349 terminalPrivate->AddToWhitelist(kTerminalPrivateWhitelist[i]); | |
| 350 ExtensionAPIPermission* webSocketProxyPrivate = info->RegisterPermission( | |
|
Aaron Boodman
2012/02/02 18:17:31
Maybe also move the ones that have whitelists to t
jstritar
2012/02/03 14:33:17
Done.
| |
| 351 kWebSocketProxyPrivate, "webSocketProxyPrivate", 0, | |
| 352 ExtensionPermissionMessage::kNone, | |
| 353 kFlagCannotBeOptional, kTypeDefault - kTypePlatformApp); | |
| 354 for (size_t i = 0; i < arraysize(kChromeOSWhitelist); ++i) | |
| 355 webSocketProxyPrivate->AddToWhitelist(kChromeOSWhitelist[i]); | |
| 356 ExtensionAPIPermission* webstorePrivate = info->RegisterPermission( | |
| 357 kWebstorePrivate, "webstorePrivate", 0, | |
| 358 ExtensionPermissionMessage::kNone, | |
| 359 kFlagCannotBeOptional, kTypeAll - kTypePlatformApp); | |
| 360 for (size_t i = 0; i < arraysize(kWebstorePrivateWhitelist); ++i) | |
| 361 webstorePrivate->AddToWhitelist(kWebstorePrivateWhitelist[i]); | |
| 314 | 362 |
| 315 // Full url access permissions. | 363 // Full url access permissions. |
| 316 info->RegisterPermission( | 364 info->RegisterPermission( |
| 317 kProxy, "proxy", 0, ExtensionPermissionMessage::kNone, | 365 kProxy, "proxy", 0, ExtensionPermissionMessage::kNone, |
| 318 kFlagImpliesFullURLAccess | kFlagCannotBeOptional, kTypeDefault); | 366 kFlagImpliesFullURLAccess | kFlagCannotBeOptional, kTypeDefault); |
| 319 | 367 |
| 320 info->RegisterPermission( | 368 info->RegisterPermission( |
| 321 kDebugger, "debugger", IDS_EXTENSION_PROMPT_WARNING_DEBUGGER, | 369 kDebugger, "debugger", IDS_EXTENSION_PROMPT_WARNING_DEBUGGER, |
| 322 ExtensionPermissionMessage::kDebugger, | 370 ExtensionPermissionMessage::kDebugger, |
| 323 kFlagImpliesFullURLAccess | kFlagCannotBeOptional, kTypeDefault); | 371 kFlagImpliesFullURLAccess | kFlagCannotBeOptional, kTypeDefault); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 334 // Platform-app permissions. | 382 // Platform-app permissions. |
| 335 info->RegisterPermission( | 383 info->RegisterPermission( |
| 336 kSocket, "socket", 0, ExtensionPermissionMessage::kNone, | 384 kSocket, "socket", 0, ExtensionPermissionMessage::kNone, |
| 337 kFlagCannotBeOptional, kTypePlatformApp); | 385 kFlagCannotBeOptional, kTypePlatformApp); |
| 338 | 386 |
| 339 // Register aliases. | 387 // Register aliases. |
| 340 info->RegisterAlias("unlimitedStorage", kOldUnlimitedStoragePermission); | 388 info->RegisterAlias("unlimitedStorage", kOldUnlimitedStoragePermission); |
| 341 info->RegisterAlias("tabs", kWindowsPermission); | 389 info->RegisterAlias("tabs", kWindowsPermission); |
| 342 } | 390 } |
| 343 | 391 |
| 392 bool ExtensionAPIPermission::HasWhitelist() const { | |
| 393 return !whitelist_.empty(); | |
| 394 } | |
| 395 | |
| 396 bool ExtensionAPIPermission::IsWhitelisted( | |
| 397 const std::string& extension_id) const { | |
| 398 return whitelist_.find(extension_id) != whitelist_.end(); | |
| 399 } | |
| 400 | |
| 401 void ExtensionAPIPermission::AddToWhitelist(const std::string& extension_id) { | |
| 402 whitelist_.insert(extension_id); | |
| 403 } | |
| 404 | |
| 344 // | 405 // |
| 345 // ExtensionPermissionsInfo | 406 // ExtensionPermissionsInfo |
| 346 // | 407 // |
| 347 | 408 |
| 348 // static | 409 // static |
| 349 ExtensionPermissionsInfo* ExtensionPermissionsInfo::GetInstance() { | 410 ExtensionPermissionsInfo* ExtensionPermissionsInfo::GetInstance() { |
| 350 return Singleton<ExtensionPermissionsInfo>::get(); | 411 return Singleton<ExtensionPermissionsInfo>::get(); |
| 351 } | 412 } |
| 352 | 413 |
| 353 ExtensionAPIPermission* ExtensionPermissionsInfo::GetByID( | 414 ExtensionAPIPermission* ExtensionPermissionsInfo::GetByID( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 391 ExtensionAPIPermission::RegisterAllPermissions(this); | 452 ExtensionAPIPermission::RegisterAllPermissions(this); |
| 392 } | 453 } |
| 393 | 454 |
| 394 void ExtensionPermissionsInfo::RegisterAlias( | 455 void ExtensionPermissionsInfo::RegisterAlias( |
| 395 const char* name, const char* alias) { | 456 const char* name, const char* alias) { |
| 396 DCHECK(name_map_.find(name) != name_map_.end()); | 457 DCHECK(name_map_.find(name) != name_map_.end()); |
| 397 DCHECK(name_map_.find(alias) == name_map_.end()); | 458 DCHECK(name_map_.find(alias) == name_map_.end()); |
| 398 name_map_[alias] = name_map_[name]; | 459 name_map_[alias] = name_map_[name]; |
| 399 } | 460 } |
| 400 | 461 |
| 401 void ExtensionPermissionsInfo::RegisterPermission( | 462 ExtensionAPIPermission* ExtensionPermissionsInfo::RegisterPermission( |
| 402 ExtensionAPIPermission::ID id, | 463 ExtensionAPIPermission::ID id, |
| 403 const char* name, | 464 const char* name, |
| 404 int l10n_message_id, | 465 int l10n_message_id, |
| 405 ExtensionPermissionMessage::ID message_id, | 466 ExtensionPermissionMessage::ID message_id, |
| 406 int flags, | 467 int flags, |
| 407 int type_restrictions) { | 468 int type_restrictions) { |
| 408 DCHECK(id_map_.find(id) == id_map_.end()); | 469 DCHECK(id_map_.find(id) == id_map_.end()); |
| 409 DCHECK(name_map_.find(name) == name_map_.end()); | 470 DCHECK(name_map_.find(name) == name_map_.end()); |
| 410 | 471 |
| 411 ExtensionAPIPermission* permission = new ExtensionAPIPermission( | 472 ExtensionAPIPermission* permission = new ExtensionAPIPermission( |
| 412 id, name, l10n_message_id, message_id, flags, type_restrictions); | 473 id, name, l10n_message_id, message_id, flags, type_restrictions); |
| 413 | 474 |
| 414 id_map_[id] = permission; | 475 id_map_[id] = permission; |
| 415 name_map_[name] = permission; | 476 name_map_[name] = permission; |
| 416 | 477 |
| 417 permission_count_++; | 478 permission_count_++; |
| 479 | |
| 480 return permission; | |
| 418 } | 481 } |
| 419 | 482 |
| 420 // | 483 // |
| 421 // ExtensionPermissionSet | 484 // ExtensionPermissionSet |
| 422 // | 485 // |
| 423 | 486 |
| 424 ExtensionPermissionSet::ExtensionPermissionSet() { | 487 ExtensionPermissionSet::ExtensionPermissionSet() { |
| 425 } | 488 } |
| 426 | 489 |
| 427 ExtensionPermissionSet::ExtensionPermissionSet( | 490 ExtensionPermissionSet::ExtensionPermissionSet( |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 870 std::set<std::string> new_hosts_set(GetDistinctHosts(new_list, false, false)); | 933 std::set<std::string> new_hosts_set(GetDistinctHosts(new_list, false, false)); |
| 871 std::set<std::string> old_hosts_set(GetDistinctHosts(old_list, false, false)); | 934 std::set<std::string> old_hosts_set(GetDistinctHosts(old_list, false, false)); |
| 872 std::set<std::string> new_hosts_only; | 935 std::set<std::string> new_hosts_only; |
| 873 | 936 |
| 874 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), | 937 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), |
| 875 old_hosts_set.begin(), old_hosts_set.end(), | 938 old_hosts_set.begin(), old_hosts_set.end(), |
| 876 std::inserter(new_hosts_only, new_hosts_only.begin())); | 939 std::inserter(new_hosts_only, new_hosts_only.begin())); |
| 877 | 940 |
| 878 return !new_hosts_only.empty(); | 941 return !new_hosts_only.empty(); |
| 879 } | 942 } |
| OLD | NEW |