| 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" |
| 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" |
| 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 |
| 26 namespace ids = extension_misc; |
| 24 namespace { | 27 namespace { |
| 25 | 28 |
| 26 // Helper for GetDistinctHosts(): com > net > org > everything else. | 29 // Helper for GetDistinctHosts(): com > net > org > everything else. |
| 27 bool RcdBetterThan(std::string a, std::string b) { | 30 bool RcdBetterThan(std::string a, std::string b) { |
| 28 if (a == b) | 31 if (a == b) |
| 29 return false; | 32 return false; |
| 30 if (a == "com") | 33 if (a == "com") |
| 31 return true; | 34 return true; |
| 32 if (a == "net") | 35 if (a == "net") |
| 33 return b != "com"; | 36 return b != "com"; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 kGeolocation, "geolocation", IDS_EXTENSION_PROMPT_WARNING_GEOLOCATION, | 192 kGeolocation, "geolocation", IDS_EXTENSION_PROMPT_WARNING_GEOLOCATION, |
| 190 ExtensionPermissionMessage::kGeolocation, | 193 ExtensionPermissionMessage::kGeolocation, |
| 191 kFlagCannotBeOptional, kTypeAll); | 194 kFlagCannotBeOptional, kTypeAll); |
| 192 info->RegisterPermission( | 195 info->RegisterPermission( |
| 193 kNotification, "notifications", 0, | 196 kNotification, "notifications", 0, |
| 194 ExtensionPermissionMessage::kNone, kFlagNone, kTypeAll); | 197 ExtensionPermissionMessage::kNone, kFlagNone, kTypeAll); |
| 195 info->RegisterPermission( | 198 info->RegisterPermission( |
| 196 kUnlimitedStorage, "unlimitedStorage", 0, | 199 kUnlimitedStorage, "unlimitedStorage", 0, |
| 197 ExtensionPermissionMessage::kNone, kFlagCannotBeOptional, kTypeAll); | 200 ExtensionPermissionMessage::kNone, kFlagCannotBeOptional, kTypeAll); |
| 198 | 201 |
| 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 | 202 |
| 213 // Register hosted and packaged app permissions. | 203 // Register hosted and packaged app permissions. |
| 214 info->RegisterPermission( | 204 info->RegisterPermission( |
| 215 kAppNotifications, "appNotifications", 0, | 205 kAppNotifications, "appNotifications", 0, |
| 216 ExtensionPermissionMessage::kNone, kFlagNone, | 206 ExtensionPermissionMessage::kNone, kFlagNone, |
| 217 kTypeHostedApp | kTypePackagedApp); | 207 kTypeHostedApp | kTypePackagedApp); |
| 218 | 208 |
| 219 // Register extension permissions. | 209 // Register extension permissions. |
| 220 info->RegisterPermission( | 210 info->RegisterPermission( |
| 221 kBookmark, "bookmarks", IDS_EXTENSION_PROMPT_WARNING_BOOKMARKS, | 211 kBookmark, "bookmarks", IDS_EXTENSION_PROMPT_WARNING_BOOKMARKS, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 238 kHistory, "history", IDS_EXTENSION_PROMPT_WARNING_BROWSING_HISTORY, | 228 kHistory, "history", IDS_EXTENSION_PROMPT_WARNING_BROWSING_HISTORY, |
| 239 ExtensionPermissionMessage::kBrowsingHistory, | 229 ExtensionPermissionMessage::kBrowsingHistory, |
| 240 kFlagNone, kTypeDefault); | 230 kFlagNone, kTypeDefault); |
| 241 info->RegisterPermission( | 231 info->RegisterPermission( |
| 242 kIdle, "idle", 0, ExtensionPermissionMessage::kNone, | 232 kIdle, "idle", 0, ExtensionPermissionMessage::kNone, |
| 243 kFlagNone, kTypeDefault); | 233 kFlagNone, kTypeDefault); |
| 244 info->RegisterPermission( | 234 info->RegisterPermission( |
| 245 kInput, "input", 0, ExtensionPermissionMessage::kNone, | 235 kInput, "input", 0, ExtensionPermissionMessage::kNone, |
| 246 kFlagImpliesFullURLAccess, kTypeDefault); | 236 kFlagImpliesFullURLAccess, kTypeDefault); |
| 247 info->RegisterPermission( | 237 info->RegisterPermission( |
| 248 kInputMethodPrivate, "inputMethodPrivate", 0, | |
| 249 ExtensionPermissionMessage::kNone, kFlagCannotBeOptional, kTypeDefault); | |
| 250 info->RegisterPermission( | |
| 251 kManagement, "management", IDS_EXTENSION_PROMPT_WARNING_MANAGEMENT, | 238 kManagement, "management", IDS_EXTENSION_PROMPT_WARNING_MANAGEMENT, |
| 252 ExtensionPermissionMessage::kManagement, kFlagNone, kTypeDefault); | 239 ExtensionPermissionMessage::kManagement, kFlagNone, kTypeDefault); |
| 253 info->RegisterPermission( | 240 info->RegisterPermission( |
| 254 kPageCapture, "pageCapture", | 241 kPageCapture, "pageCapture", |
| 255 IDS_EXTENSION_PROMPT_WARNING_ALL_PAGES_CONTENT, | 242 IDS_EXTENSION_PROMPT_WARNING_ALL_PAGES_CONTENT, |
| 256 ExtensionPermissionMessage::kAllPageContent, kFlagNone, kTypeDefault); | 243 ExtensionPermissionMessage::kAllPageContent, kFlagNone, kTypeDefault); |
| 257 info->RegisterPermission( | 244 info->RegisterPermission( |
| 258 kPrivacy, "privacy", IDS_EXTENSION_PROMPT_WARNING_PRIVACY, | 245 kPrivacy, "privacy", IDS_EXTENSION_PROMPT_WARNING_PRIVACY, |
| 259 ExtensionPermissionMessage::kPrivacy, kFlagNone, kTypeDefault); | 246 ExtensionPermissionMessage::kPrivacy, kFlagNone, kTypeDefault); |
| 260 info->RegisterPermission( | 247 info->RegisterPermission( |
| 261 kStorage, "storage", 0, | 248 kStorage, "storage", 0, |
| 262 ExtensionPermissionMessage::kNone, kFlagNone, kTypeDefault); | 249 ExtensionPermissionMessage::kNone, kFlagNone, kTypeDefault); |
| 263 info->RegisterPermission( | 250 info->RegisterPermission( |
| 264 kTab, "tabs", IDS_EXTENSION_PROMPT_WARNING_TABS, | 251 kTab, "tabs", IDS_EXTENSION_PROMPT_WARNING_TABS, |
| 265 ExtensionPermissionMessage::kTabs, kFlagNone, | 252 ExtensionPermissionMessage::kTabs, kFlagNone, |
| 266 kTypeDefault - kTypePlatformApp); | 253 kTypeDefault - kTypePlatformApp); |
| 267 info->RegisterPermission( | 254 info->RegisterPermission( |
| 268 kTerminalPrivate, "terminalPrivate", 0, | |
| 269 ExtensionPermissionMessage::kNone, kFlagCannotBeOptional, kTypeDefault); | |
| 270 info->RegisterPermission( | |
| 271 kTts, "tts", 0, | 255 kTts, "tts", 0, |
| 272 ExtensionPermissionMessage::kNone, kFlagCannotBeOptional, kTypeDefault); | 256 ExtensionPermissionMessage::kNone, kFlagCannotBeOptional, kTypeDefault); |
| 273 info->RegisterPermission( | 257 info->RegisterPermission( |
| 274 kTtsEngine, "ttsEngine", IDS_EXTENSION_PROMPT_WARNING_TTS_ENGINE, | 258 kTtsEngine, "ttsEngine", IDS_EXTENSION_PROMPT_WARNING_TTS_ENGINE, |
| 275 ExtensionPermissionMessage::kTtsEngine, | 259 ExtensionPermissionMessage::kTtsEngine, |
| 276 kFlagCannotBeOptional, kTypeDefault); | 260 kFlagCannotBeOptional, kTypeDefault); |
| 277 info->RegisterPermission( | 261 info->RegisterPermission( |
| 278 kWebNavigation, "webNavigation", | 262 kWebNavigation, "webNavigation", |
| 279 IDS_EXTENSION_PROMPT_WARNING_TABS, ExtensionPermissionMessage::kTabs, | 263 IDS_EXTENSION_PROMPT_WARNING_TABS, ExtensionPermissionMessage::kTabs, |
| 280 kFlagNone, kTypeDefault - kTypePlatformApp); | 264 kFlagNone, kTypeDefault - kTypePlatformApp); |
| 281 info->RegisterPermission( | 265 info->RegisterPermission( |
| 282 kWebRequest, "webRequest", 0, ExtensionPermissionMessage::kNone, | 266 kWebRequest, "webRequest", 0, ExtensionPermissionMessage::kNone, |
| 283 kFlagNone, kTypeDefault - kTypePlatformApp); | 267 kFlagNone, kTypeDefault - kTypePlatformApp); |
| 284 info->RegisterPermission( | 268 info->RegisterPermission( |
| 285 kWebRequestBlocking, "webRequestBlocking", 0, | 269 kWebRequestBlocking, "webRequestBlocking", 0, |
| 286 ExtensionPermissionMessage::kNone, kFlagNone, | 270 ExtensionPermissionMessage::kNone, kFlagNone, |
| 287 kTypeDefault - kTypePlatformApp); | 271 kTypeDefault - kTypePlatformApp); |
| 288 info->RegisterPermission( | |
| 289 kWebSocketProxyPrivate, "webSocketProxyPrivate", 0, | |
| 290 ExtensionPermissionMessage::kNone, kFlagCannotBeOptional, | |
| 291 kTypeDefault - kTypePlatformApp); | |
| 292 | 272 |
| 293 // Register private permissions. | 273 // Register private permissions. |
| 294 info->RegisterPermission( | 274 info->RegisterPermission( |
| 295 kChromeosInfoPrivate, "chromeosInfoPrivate", 0, | 275 kChromeosInfoPrivate, "chromeosInfoPrivate", 0, |
| 296 ExtensionPermissionMessage::kNone, | 276 ExtensionPermissionMessage::kNone, |
| 297 kFlagComponentOnly | kFlagCannotBeOptional, kTypeDefault); | 277 kFlagComponentOnly_Deprecated | kFlagCannotBeOptional, kTypeDefault); |
| 298 info->RegisterPermission( | 278 info->RegisterPermission( |
| 299 kFileBrowserPrivate, "fileBrowserPrivate", 0, | 279 kFileBrowserPrivate, "fileBrowserPrivate", 0, |
| 300 ExtensionPermissionMessage::kNone, | 280 ExtensionPermissionMessage::kNone, |
| 301 kFlagComponentOnly | kFlagCannotBeOptional, kTypeDefault); | 281 kFlagComponentOnly_Deprecated | kFlagCannotBeOptional, kTypeDefault); |
| 302 info->RegisterPermission( | 282 info->RegisterPermission( |
| 303 kMediaPlayerPrivate, "mediaPlayerPrivate", 0, | 283 kMediaPlayerPrivate, "mediaPlayerPrivate", 0, |
| 304 ExtensionPermissionMessage::kNone, | 284 ExtensionPermissionMessage::kNone, |
| 305 kFlagComponentOnly | kFlagCannotBeOptional, kTypeDefault); | 285 kFlagComponentOnly_Deprecated | kFlagCannotBeOptional, kTypeDefault); |
| 306 info->RegisterPermission( | 286 info->RegisterPermission( |
| 307 kMetricsPrivate, "metricsPrivate", 0, | 287 kMetricsPrivate, "metricsPrivate", 0, |
| 308 ExtensionPermissionMessage::kNone, | 288 ExtensionPermissionMessage::kNone, |
| 309 kFlagComponentOnly | kFlagCannotBeOptional, kTypeDefault); | 289 kFlagComponentOnly_Deprecated | kFlagCannotBeOptional, kTypeDefault); |
| 310 info->RegisterPermission( | 290 info->RegisterPermission( |
| 311 kSystemPrivate, "systemPrivate", 0, | 291 kSystemPrivate, "systemPrivate", 0, |
| 312 ExtensionPermissionMessage::kNone, | 292 ExtensionPermissionMessage::kNone, |
| 313 kFlagComponentOnly | kFlagCannotBeOptional, kTypeDefault); | 293 kFlagComponentOnly_Deprecated | kFlagCannotBeOptional, kTypeDefault); |
| 294 |
| 295 ExtensionAPIPermission* chromeAuthPrivate = info->RegisterPermission( |
| 296 kChromeAuthPrivate, "chromeAuthPrivate", 0, |
| 297 ExtensionPermissionMessage::kNone, |
| 298 kFlagCannotBeOptional, kTypeAll - kTypePlatformApp); |
| 299 chromeAuthPrivate->AddToWhitelist(ids::kCloudPrintAppId); |
| 300 |
| 301 ExtensionAPIPermission* chromePrivate = info->RegisterPermission( |
| 302 kChromePrivate, "chromePrivate", 0, ExtensionPermissionMessage::kNone, |
| 303 kFlagCannotBeOptional, kTypeAll - kTypePlatformApp); |
| 304 chromePrivate->AddToWhitelist(ids::kCitrixReceiverAppId); |
| 305 chromePrivate->AddToWhitelist(ids::kCitrixReceiverAppBetaId); |
| 306 chromePrivate->AddToWhitelist(ids::kCitrixReceiverAppDevId); |
| 307 |
| 308 ExtensionAPIPermission* inputMethodPrivate = info->RegisterPermission( |
| 309 kInputMethodPrivate, "inputMethodPrivate", 0, |
| 310 ExtensionPermissionMessage::kNone, kFlagCannotBeOptional, kTypeDefault); |
| 311 inputMethodPrivate->AddToWhitelist(ids::kCitrixReceiverAppId); |
| 312 inputMethodPrivate->AddToWhitelist(ids::kCitrixReceiverAppBetaId); |
| 313 inputMethodPrivate->AddToWhitelist(ids::kCitrixReceiverAppDevId); |
| 314 inputMethodPrivate->AddToWhitelist(ids::kHTermAppId); |
| 315 inputMethodPrivate->AddToWhitelist(ids::kHTermDevAppId); |
| 316 |
| 317 ExtensionAPIPermission* terminalPrivate = info->RegisterPermission( |
| 318 kTerminalPrivate, "terminalPrivate", 0, ExtensionPermissionMessage::kNone, |
| 319 kFlagCannotBeOptional, kTypeDefault); |
| 320 terminalPrivate->AddToWhitelist(ids::kHTermAppId); |
| 321 terminalPrivate->AddToWhitelist(ids::kHTermDevAppId); |
| 322 |
| 323 ExtensionAPIPermission* webSocketProxyPrivate = info->RegisterPermission( |
| 324 kWebSocketProxyPrivate, "webSocketProxyPrivate", 0, |
| 325 ExtensionPermissionMessage::kNone, |
| 326 kFlagCannotBeOptional, kTypeDefault - kTypePlatformApp); |
| 327 webSocketProxyPrivate->AddToWhitelist(ids::kCitrixReceiverAppId); |
| 328 webSocketProxyPrivate->AddToWhitelist(ids::kCitrixReceiverAppBetaId); |
| 329 webSocketProxyPrivate->AddToWhitelist(ids::kCitrixReceiverAppDevId); |
| 330 webSocketProxyPrivate->AddToWhitelist(ids::kHTermAppId); |
| 331 webSocketProxyPrivate->AddToWhitelist(ids::kHTermDevAppId); |
| 332 |
| 333 ExtensionAPIPermission* webstorePrivate = info->RegisterPermission( |
| 334 kWebstorePrivate, "webstorePrivate", 0, |
| 335 ExtensionPermissionMessage::kNone, |
| 336 kFlagCannotBeOptional, kTypeAll - kTypePlatformApp); |
| 337 webstorePrivate->AddToWhitelist(ids::kEnterpriseWebStoreAppId); |
| 338 webstorePrivate->AddToWhitelist(ids::kWebStoreAppId); |
| 314 | 339 |
| 315 // Full url access permissions. | 340 // Full url access permissions. |
| 316 info->RegisterPermission( | 341 info->RegisterPermission( |
| 317 kProxy, "proxy", 0, ExtensionPermissionMessage::kNone, | 342 kProxy, "proxy", 0, ExtensionPermissionMessage::kNone, |
| 318 kFlagImpliesFullURLAccess | kFlagCannotBeOptional, kTypeDefault); | 343 kFlagImpliesFullURLAccess | kFlagCannotBeOptional, kTypeDefault); |
| 319 | 344 |
| 320 info->RegisterPermission( | 345 info->RegisterPermission( |
| 321 kDebugger, "debugger", IDS_EXTENSION_PROMPT_WARNING_DEBUGGER, | 346 kDebugger, "debugger", IDS_EXTENSION_PROMPT_WARNING_DEBUGGER, |
| 322 ExtensionPermissionMessage::kDebugger, | 347 ExtensionPermissionMessage::kDebugger, |
| 323 kFlagImpliesFullURLAccess | kFlagCannotBeOptional, kTypeDefault); | 348 kFlagImpliesFullURLAccess | kFlagCannotBeOptional, kTypeDefault); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 334 // Platform-app permissions. | 359 // Platform-app permissions. |
| 335 info->RegisterPermission( | 360 info->RegisterPermission( |
| 336 kSocket, "socket", 0, ExtensionPermissionMessage::kNone, | 361 kSocket, "socket", 0, ExtensionPermissionMessage::kNone, |
| 337 kFlagCannotBeOptional, kTypePlatformApp); | 362 kFlagCannotBeOptional, kTypePlatformApp); |
| 338 | 363 |
| 339 // Register aliases. | 364 // Register aliases. |
| 340 info->RegisterAlias("unlimitedStorage", kOldUnlimitedStoragePermission); | 365 info->RegisterAlias("unlimitedStorage", kOldUnlimitedStoragePermission); |
| 341 info->RegisterAlias("tabs", kWindowsPermission); | 366 info->RegisterAlias("tabs", kWindowsPermission); |
| 342 } | 367 } |
| 343 | 368 |
| 369 bool ExtensionAPIPermission::HasWhitelist() const { |
| 370 return !whitelist_.empty(); |
| 371 } |
| 372 |
| 373 bool ExtensionAPIPermission::IsWhitelisted( |
| 374 const std::string& extension_id) const { |
| 375 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 376 if (command_line->HasSwitch(switches::kWhitelistedExtensionID)) { |
| 377 if (extension_id == command_line->GetSwitchValueASCII( |
| 378 switches::kWhitelistedExtensionID)) |
| 379 return true; |
| 380 } |
| 381 return whitelist_.find(extension_id) != whitelist_.end(); |
| 382 } |
| 383 |
| 384 void ExtensionAPIPermission::AddToWhitelist(const std::string& extension_id) { |
| 385 whitelist_.insert(extension_id); |
| 386 } |
| 387 |
| 344 // | 388 // |
| 345 // ExtensionPermissionsInfo | 389 // ExtensionPermissionsInfo |
| 346 // | 390 // |
| 347 | 391 |
| 348 // static | 392 // static |
| 349 ExtensionPermissionsInfo* ExtensionPermissionsInfo::GetInstance() { | 393 ExtensionPermissionsInfo* ExtensionPermissionsInfo::GetInstance() { |
| 350 return Singleton<ExtensionPermissionsInfo>::get(); | 394 return Singleton<ExtensionPermissionsInfo>::get(); |
| 351 } | 395 } |
| 352 | 396 |
| 353 ExtensionAPIPermission* ExtensionPermissionsInfo::GetByID( | 397 ExtensionAPIPermission* ExtensionPermissionsInfo::GetByID( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 ExtensionAPIPermission::RegisterAllPermissions(this); | 435 ExtensionAPIPermission::RegisterAllPermissions(this); |
| 392 } | 436 } |
| 393 | 437 |
| 394 void ExtensionPermissionsInfo::RegisterAlias( | 438 void ExtensionPermissionsInfo::RegisterAlias( |
| 395 const char* name, const char* alias) { | 439 const char* name, const char* alias) { |
| 396 DCHECK(name_map_.find(name) != name_map_.end()); | 440 DCHECK(name_map_.find(name) != name_map_.end()); |
| 397 DCHECK(name_map_.find(alias) == name_map_.end()); | 441 DCHECK(name_map_.find(alias) == name_map_.end()); |
| 398 name_map_[alias] = name_map_[name]; | 442 name_map_[alias] = name_map_[name]; |
| 399 } | 443 } |
| 400 | 444 |
| 401 void ExtensionPermissionsInfo::RegisterPermission( | 445 ExtensionAPIPermission* ExtensionPermissionsInfo::RegisterPermission( |
| 402 ExtensionAPIPermission::ID id, | 446 ExtensionAPIPermission::ID id, |
| 403 const char* name, | 447 const char* name, |
| 404 int l10n_message_id, | 448 int l10n_message_id, |
| 405 ExtensionPermissionMessage::ID message_id, | 449 ExtensionPermissionMessage::ID message_id, |
| 406 int flags, | 450 int flags, |
| 407 int type_restrictions) { | 451 int type_restrictions) { |
| 408 DCHECK(id_map_.find(id) == id_map_.end()); | 452 DCHECK(id_map_.find(id) == id_map_.end()); |
| 409 DCHECK(name_map_.find(name) == name_map_.end()); | 453 DCHECK(name_map_.find(name) == name_map_.end()); |
| 410 | 454 |
| 411 ExtensionAPIPermission* permission = new ExtensionAPIPermission( | 455 ExtensionAPIPermission* permission = new ExtensionAPIPermission( |
| 412 id, name, l10n_message_id, message_id, flags, type_restrictions); | 456 id, name, l10n_message_id, message_id, flags, type_restrictions); |
| 413 | 457 |
| 414 id_map_[id] = permission; | 458 id_map_[id] = permission; |
| 415 name_map_[name] = permission; | 459 name_map_[name] = permission; |
| 416 | 460 |
| 417 permission_count_++; | 461 permission_count_++; |
| 462 |
| 463 return permission; |
| 418 } | 464 } |
| 419 | 465 |
| 420 // | 466 // |
| 421 // ExtensionPermissionSet | 467 // ExtensionPermissionSet |
| 422 // | 468 // |
| 423 | 469 |
| 424 ExtensionPermissionSet::ExtensionPermissionSet() { | 470 ExtensionPermissionSet::ExtensionPermissionSet() { |
| 425 } | 471 } |
| 426 | 472 |
| 427 ExtensionPermissionSet::ExtensionPermissionSet( | 473 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)); | 916 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)); | 917 std::set<std::string> old_hosts_set(GetDistinctHosts(old_list, false, false)); |
| 872 std::set<std::string> new_hosts_only; | 918 std::set<std::string> new_hosts_only; |
| 873 | 919 |
| 874 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), | 920 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), |
| 875 old_hosts_set.begin(), old_hosts_set.end(), | 921 old_hosts_set.begin(), old_hosts_set.end(), |
| 876 std::inserter(new_hosts_only, new_hosts_only.begin())); | 922 std::inserter(new_hosts_only, new_hosts_only.begin())); |
| 877 | 923 |
| 878 return !new_hosts_only.empty(); | 924 return !new_hosts_only.empty(); |
| 879 } | 925 } |
| OLD | NEW |