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

Side by Side Diff: chrome/common/extensions/api/extension_api.cc

Issue 15091002: Lazily load API schemas from resource files and convert all APIs to features (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: convert all APIs to features Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
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/api/extension_api.h" 5 #include "chrome/common/extensions/api/extension_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 { 245 {
246 Value* value = NULL; 246 Value* value = NULL;
247 schema_list->Remove(schema_list->GetSize() - 1, &value); 247 schema_list->Remove(schema_list->GetSize() - 1, &value);
248 CHECK(value->IsType(Value::TYPE_DICTIONARY)); 248 CHECK(value->IsType(Value::TYPE_DICTIONARY));
249 schema = static_cast<DictionaryValue*>(value); 249 schema = static_cast<DictionaryValue*>(value);
250 } 250 }
251 251
252 CHECK(schema->GetString("namespace", &schema_namespace)); 252 CHECK(schema->GetString("namespace", &schema_namespace));
253 PrefixWithNamespace(schema_namespace, schema); 253 PrefixWithNamespace(schema_namespace, schema);
254 schemas_[schema_namespace] = make_linked_ptr(schema); 254 schemas_[schema_namespace] = make_linked_ptr(schema);
255 CHECK_EQ(1u, unloaded_schemas_.erase(schema_namespace)); 255 if (!GeneratedSchemas::IsGenerated(schema_namespace)) {
256 CHECK_EQ(1u, unloaded_schemas_.erase(schema_namespace));
257 }
256 258
257 // Populate |{completely,partially}_unprivileged_apis_|. 259 // Populate |{completely,partially}_unprivileged_apis_|.
258 260
259 // For "partially", only need to look at functions/events; even though 261 // For "partially", only need to look at functions/events; even though
260 // there are unprivileged properties (e.g. in extensions), access to those 262 // there are unprivileged properties (e.g. in extensions), access to those
261 // never reaches C++ land. 263 // never reaches C++ land.
262 bool unprivileged = false; 264 bool unprivileged = false;
263 if (schema->GetBoolean("unprivileged", &unprivileged) && unprivileged) { 265 if (schema->GetBoolean("unprivileged", &unprivileged) && unprivileged) {
264 completely_unprivileged_apis_.insert(schema_namespace); 266 completely_unprivileged_apis_.insert(schema_namespace);
265 } else if (HasUnprivilegedChild(schema, "functions") || 267 } else if (HasUnprivilegedChild(schema, "functions") ||
(...skipping 13 matching lines...) Expand all
279 void ExtensionAPI::InitDefaultConfiguration() { 281 void ExtensionAPI::InitDefaultConfiguration() {
280 RegisterDependencyProvider( 282 RegisterDependencyProvider(
281 "api", BaseFeatureProvider::GetByName("api")); 283 "api", BaseFeatureProvider::GetByName("api"));
282 RegisterDependencyProvider( 284 RegisterDependencyProvider(
283 "manifest", BaseFeatureProvider::GetByName("manifest")); 285 "manifest", BaseFeatureProvider::GetByName("manifest"));
284 RegisterDependencyProvider( 286 RegisterDependencyProvider(
285 "permission", BaseFeatureProvider::GetByName("permission")); 287 "permission", BaseFeatureProvider::GetByName("permission"));
286 288
287 // Schemas to be loaded from resources. 289 // Schemas to be loaded from resources.
288 CHECK(unloaded_schemas_.empty()); 290 CHECK(unloaded_schemas_.empty());
289 RegisterSchema("app", ReadFromResource( 291 RegisterSchemaResource("app", IDR_EXTENSION_API_JSON_APP);
290 IDR_EXTENSION_API_JSON_APP)); 292 RegisterSchemaResource("browserAction", IDR_EXTENSION_API_JSON_BROWSERACTION);
291 RegisterSchema("browserAction", ReadFromResource( 293 RegisterSchemaResource("browsingData", IDR_EXTENSION_API_JSON_BROWSINGDATA);
292 IDR_EXTENSION_API_JSON_BROWSERACTION)); 294 RegisterSchemaResource("commands", IDR_EXTENSION_API_JSON_COMMANDS);
293 RegisterSchema("browsingData", ReadFromResource( 295 RegisterSchemaResource("declarativeContent",
294 IDR_EXTENSION_API_JSON_BROWSINGDATA)); 296 IDR_EXTENSION_API_JSON_DECLARATIVE_CONTENT);
295 RegisterSchema("commands", ReadFromResource( 297 RegisterSchemaResource("declarativeWebRequest",
296 IDR_EXTENSION_API_JSON_COMMANDS)); 298 IDR_EXTENSION_API_JSON_DECLARATIVE_WEBREQUEST);
297 RegisterSchema("declarativeContent", ReadFromResource( 299 RegisterSchemaResource("experimental.input.virtualKeyboard",
298 IDR_EXTENSION_API_JSON_DECLARATIVE_CONTENT)); 300 IDR_EXTENSION_API_JSON_EXPERIMENTAL_INPUT_VIRTUALKEYBOARD);
299 RegisterSchema("declarativeWebRequest", ReadFromResource( 301 RegisterSchemaResource("experimental.processes",
300 IDR_EXTENSION_API_JSON_DECLARATIVE_WEBREQUEST)); 302 IDR_EXTENSION_API_JSON_EXPERIMENTAL_PROCESSES);
301 RegisterSchema("experimental.input.virtualKeyboard", ReadFromResource( 303 RegisterSchemaResource("experimental.rlz",
302 IDR_EXTENSION_API_JSON_EXPERIMENTAL_INPUT_VIRTUALKEYBOARD)); 304 IDR_EXTENSION_API_JSON_EXPERIMENTAL_RLZ);
303 RegisterSchema("experimental.processes", ReadFromResource( 305 RegisterSchemaResource("runtime", IDR_EXTENSION_API_JSON_RUNTIME);
304 IDR_EXTENSION_API_JSON_EXPERIMENTAL_PROCESSES)); 306 RegisterSchemaResource("fileBrowserHandler",
305 RegisterSchema("experimental.rlz", ReadFromResource( 307 IDR_EXTENSION_API_JSON_FILEBROWSERHANDLER);
306 IDR_EXTENSION_API_JSON_EXPERIMENTAL_RLZ)); 308 RegisterSchemaResource("fileBrowserPrivate",
307 RegisterSchema("runtime", ReadFromResource( 309 IDR_EXTENSION_API_JSON_FILEBROWSERPRIVATE);
308 IDR_EXTENSION_API_JSON_RUNTIME)); 310 RegisterSchemaResource("input.ime", IDR_EXTENSION_API_JSON_INPUT_IME);
309 RegisterSchema("fileBrowserHandler", ReadFromResource( 311 RegisterSchemaResource("inputMethodPrivate",
310 IDR_EXTENSION_API_JSON_FILEBROWSERHANDLER)); 312 IDR_EXTENSION_API_JSON_INPUTMETHODPRIVATE);
311 RegisterSchema("fileBrowserPrivate", ReadFromResource( 313 RegisterSchemaResource("pageAction", IDR_EXTENSION_API_JSON_PAGEACTION);
312 IDR_EXTENSION_API_JSON_FILEBROWSERPRIVATE)); 314 RegisterSchemaResource("pageActions", IDR_EXTENSION_API_JSON_PAGEACTIONS);
313 RegisterSchema("input.ime", ReadFromResource( 315 RegisterSchemaResource("privacy", IDR_EXTENSION_API_JSON_PRIVACY);
314 IDR_EXTENSION_API_JSON_INPUT_IME)); 316 RegisterSchemaResource("proxy", IDR_EXTENSION_API_JSON_PROXY);
315 RegisterSchema("inputMethodPrivate", ReadFromResource( 317 RegisterSchemaResource("scriptBadge", IDR_EXTENSION_API_JSON_SCRIPTBADGE);
316 IDR_EXTENSION_API_JSON_INPUTMETHODPRIVATE)); 318 RegisterSchemaResource("streamsPrivate",
317 RegisterSchema("pageAction", ReadFromResource( 319 IDR_EXTENSION_API_JSON_STREAMSPRIVATE);
318 IDR_EXTENSION_API_JSON_PAGEACTION)); 320 RegisterSchemaResource("ttsEngine", IDR_EXTENSION_API_JSON_TTSENGINE);
319 RegisterSchema("pageActions", ReadFromResource( 321 RegisterSchemaResource("tts", IDR_EXTENSION_API_JSON_TTS);
320 IDR_EXTENSION_API_JSON_PAGEACTIONS)); 322 RegisterSchemaResource("types", IDR_EXTENSION_API_JSON_TYPES);
321 RegisterSchema("privacy", ReadFromResource( 323 RegisterSchemaResource("webRequestInternal",
322 IDR_EXTENSION_API_JSON_PRIVACY)); 324 IDR_EXTENSION_API_JSON_WEBREQUESTINTERNAL);
323 RegisterSchema("proxy", ReadFromResource( 325 RegisterSchemaResource("webstore", IDR_EXTENSION_API_JSON_WEBSTORE);
324 IDR_EXTENSION_API_JSON_PROXY)); 326 RegisterSchemaResource("webstorePrivate",
325 RegisterSchema("scriptBadge", ReadFromResource( 327 IDR_EXTENSION_API_JSON_WEBSTOREPRIVATE);
326 IDR_EXTENSION_API_JSON_SCRIPTBADGE));
327 RegisterSchema("streamsPrivate", ReadFromResource(
328 IDR_EXTENSION_API_JSON_STREAMSPRIVATE));
329 RegisterSchema("ttsEngine", ReadFromResource(
330 IDR_EXTENSION_API_JSON_TTSENGINE));
331 RegisterSchema("tts", ReadFromResource(
332 IDR_EXTENSION_API_JSON_TTS));
333 RegisterSchema("types", ReadFromResource(
334 IDR_EXTENSION_API_JSON_TYPES));
335 RegisterSchema("webRequestInternal", ReadFromResource(
336 IDR_EXTENSION_API_JSON_WEBREQUESTINTERNAL));
337 RegisterSchema("webstore", ReadFromResource(
338 IDR_EXTENSION_API_JSON_WEBSTORE));
339 RegisterSchema("webstorePrivate", ReadFromResource(
340 IDR_EXTENSION_API_JSON_WEBSTOREPRIVATE));
341
342 // Schemas to be loaded via JSON generated from IDL files.
343 GeneratedSchemas::Get(&unloaded_schemas_);
344 } 328 }
345 329
346 void ExtensionAPI::RegisterSchema(const std::string& name, 330 void ExtensionAPI::RegisterSchemaResource(const std::string& name,
347 const base::StringPiece& source) { 331 int resource_id) {
348 unloaded_schemas_[name] = source; 332 unloaded_schemas_[name] = resource_id;
349 } 333 }
350 334
351 void ExtensionAPI::RegisterDependencyProvider(const std::string& name, 335 void ExtensionAPI::RegisterDependencyProvider(const std::string& name,
352 FeatureProvider* provider) { 336 FeatureProvider* provider) {
353 dependency_providers_[name] = provider; 337 dependency_providers_[name] = provider;
354 } 338 }
355 339
356 bool ExtensionAPI::IsAnyFeatureAvailableToContext(const std::string& api_name, 340 bool ExtensionAPI::IsAnyFeatureAvailableToContext(const std::string& api_name,
357 Feature::Context context, 341 Feature::Context context,
358 const GURL& url) { 342 const GURL& url) {
(...skipping 19 matching lines...) Expand all
378 Feature::Context context, 362 Feature::Context context,
379 const GURL& url) { 363 const GURL& url) {
380 std::string feature_type; 364 std::string feature_type;
381 std::string feature_name; 365 std::string feature_name;
382 SplitDependencyName(full_name, &feature_type, &feature_name); 366 SplitDependencyName(full_name, &feature_type, &feature_name);
383 367
384 std::string child_name; 368 std::string child_name;
385 std::string api_name = GetAPINameFromFullName(feature_name, &child_name); 369 std::string api_name = GetAPINameFromFullName(feature_name, &child_name);
386 370
387 Feature* feature = GetFeatureDependency(full_name); 371 Feature* feature = GetFeatureDependency(full_name);
388 372 CHECK(feature);
389 // Check APIs not using the feature system first.
390 if (!feature) {
391 return IsNonFeatureAPIAvailable(api_name, context, extension, url)
392 ? Feature::CreateAvailability(Feature::IS_AVAILABLE,
393 std::string())
394 : Feature::CreateAvailability(Feature::INVALID_CONTEXT,
395 kUnavailableMessage);
396 }
397 373
398 Feature::Availability availability = 374 Feature::Availability availability =
399 feature->IsAvailableToContext(extension, context, url); 375 feature->IsAvailableToContext(extension, context, url);
400 if (!availability.is_available()) 376 if (!availability.is_available())
401 return availability; 377 return availability;
402 378
403 for (std::set<std::string>::iterator iter = feature->dependencies().begin(); 379 for (std::set<std::string>::iterator iter = feature->dependencies().begin();
404 iter != feature->dependencies().end(); ++iter) { 380 iter != feature->dependencies().end(); ++iter) {
405 Feature::Availability dependency_availability = 381 Feature::Availability dependency_availability =
406 IsAvailable(*iter, extension, context, url); 382 IsAvailable(*iter, extension, context, url);
407 if (!dependency_availability.is_available()) 383 if (!dependency_availability.is_available())
408 return dependency_availability; 384 return dependency_availability;
409 } 385 }
410 386
411 return Feature::CreateAvailability(Feature::IS_AVAILABLE, std::string()); 387 return Feature::CreateAvailability(Feature::IS_AVAILABLE, std::string());
412 } 388 }
413 389
414 bool ExtensionAPI::IsPrivileged(const std::string& full_name) { 390 bool ExtensionAPI::IsPrivileged(const std::string& full_name) {
415 std::string child_name; 391 std::string child_name;
416 std::string api_name = GetAPINameFromFullName(full_name, &child_name); 392 std::string api_name = GetAPINameFromFullName(full_name, &child_name);
417 Feature* feature = GetFeatureDependency(full_name); 393 Feature* feature = GetFeatureDependency(full_name);
418 394
419 // First try to use the feature system. 395 // First try to use the feature system.
not at google - send to devlin 2013/05/20 17:19:04 I think this method only need to do what's here. A
cduvall 2013/05/22 03:19:56 Done.
420 if (feature) { 396 if (feature) {
421 // An API is 'privileged' if it can only be run in a blessed context. 397 // An API is 'privileged' if it can only be run in a blessed context.
422 return feature->GetContexts()->size() == 398 return feature->GetContexts()->size() ==
423 feature->GetContexts()->count(Feature::BLESSED_EXTENSION_CONTEXT); 399 feature->GetContexts()->count(Feature::BLESSED_EXTENSION_CONTEXT);
424 } 400 }
425 401
426 // Get the schema now to populate |completely_unprivileged_apis_|. 402 // Get the schema now to populate |completely_unprivileged_apis_|.
427 const DictionaryValue* schema = GetSchema(api_name); 403 const DictionaryValue* schema = GetSchema(api_name);
428 // If this API hasn't been converted yet, fall back to the old system. 404 // If this API hasn't been converted yet, fall back to the old system.
429 if (completely_unprivileged_apis_.count(api_name)) 405 if (completely_unprivileged_apis_.count(api_name))
(...skipping 18 matching lines...) Expand all
448 const DictionaryValue* ExtensionAPI::GetSchema(const std::string& full_name) { 424 const DictionaryValue* ExtensionAPI::GetSchema(const std::string& full_name) {
449 std::string child_name; 425 std::string child_name;
450 std::string api_name = GetAPINameFromFullName(full_name, &child_name); 426 std::string api_name = GetAPINameFromFullName(full_name, &child_name);
451 427
452 const DictionaryValue* result = NULL; 428 const DictionaryValue* result = NULL;
453 SchemaMap::iterator maybe_schema = schemas_.find(api_name); 429 SchemaMap::iterator maybe_schema = schemas_.find(api_name);
454 if (maybe_schema != schemas_.end()) { 430 if (maybe_schema != schemas_.end()) {
455 result = maybe_schema->second.get(); 431 result = maybe_schema->second.get();
456 } else { 432 } else {
457 // Might not have loaded yet; or might just not exist. 433 // Might not have loaded yet; or might just not exist.
458 std::map<std::string, base::StringPiece>::iterator maybe_schema_resource = 434 UnloadedSchemaMap::iterator maybe_schema_resource =
459 unloaded_schemas_.find(api_name); 435 unloaded_schemas_.find(api_name);
460 if (maybe_schema_resource == unloaded_schemas_.end()) 436 if (maybe_schema_resource != unloaded_schemas_.end()) {
437 LoadSchema(maybe_schema_resource->first,
438 ReadFromResource(maybe_schema_resource->second));
439 } else if (GeneratedSchemas::IsGenerated(api_name)) {
440 LoadSchema(api_name, GeneratedSchemas::Get(api_name));
441 } else {
461 return NULL; 442 return NULL;
443 }
462 444
463 LoadSchema(maybe_schema_resource->first, maybe_schema_resource->second);
464 maybe_schema = schemas_.find(api_name); 445 maybe_schema = schemas_.find(api_name);
465 CHECK(schemas_.end() != maybe_schema); 446 CHECK(schemas_.end() != maybe_schema);
466 result = maybe_schema->second.get(); 447 result = maybe_schema->second.get();
467 } 448 }
468 449
469 if (!child_name.empty()) 450 if (!child_name.empty())
470 result = GetSchemaChild(result, child_name); 451 result = GetSchemaChild(result, child_name);
471 452
472 return result; 453 return result;
473 } 454 }
474 455
475 namespace {
476
477 const char* kDisallowedPlatformAppFeatures[] = {
478 // "app" refers to the the legacy app namespace for hosted apps.
479 "app",
480 "extension",
481 "tabs",
482 "windows"
483 };
484
485 bool IsFeatureAllowedForExtension(const std::string& feature,
486 const extensions::Extension& extension) {
487 if (extension.is_platform_app()) {
488 for (size_t i = 0; i < arraysize(kDisallowedPlatformAppFeatures); ++i) {
489 if (feature == kDisallowedPlatformAppFeatures[i])
490 return false;
491 }
492 }
493
494 return true;
495 }
496
497 } // namespace
498
499 bool ExtensionAPI::IsNonFeatureAPIAvailable(const std::string& name,
500 Feature::Context context,
501 const Extension* extension,
502 const GURL& url) {
503 // Make sure schema is loaded.
504 GetSchema(name);
505 switch (context) {
506 case Feature::UNSPECIFIED_CONTEXT:
507 break;
508
509 case Feature::BLESSED_EXTENSION_CONTEXT:
510 if (extension) {
511 // Availability is determined by the permissions of the extension.
512 if (!IsAPIAllowed(name, extension))
513 return false;
514 if (!IsFeatureAllowedForExtension(name, *extension))
515 return false;
516 }
517 break;
518
519 case Feature::UNBLESSED_EXTENSION_CONTEXT:
520 case Feature::CONTENT_SCRIPT_CONTEXT:
521 if (extension) {
522 // Same as BLESSED_EXTENSION_CONTEXT, but only those APIs that are
523 // unprivileged.
524 if (!IsAPIAllowed(name, extension))
525 return false;
526 if (!IsPrivilegedAPI(name))
527 return false;
528 }
529 break;
530
531 case Feature::WEB_PAGE_CONTEXT:
532 return false;
533 }
534
535 return true;
536 }
537
538 std::set<std::string> ExtensionAPI::GetAllAPINames() { 456 std::set<std::string> ExtensionAPI::GetAllAPINames() {
not at google - send to devlin 2013/05/20 17:19:04 If all APIs are in the feature files, this can jus
cduvall 2013/05/22 03:19:56 I ended up removing this and just using the BaseFe
not at google - send to devlin 2013/05/23 00:09:40 good call.
539 std::set<std::string> result; 457 std::set<std::string> result;
540 for (SchemaMap::iterator i = schemas_.begin(); i != schemas_.end(); ++i) 458 for (SchemaMap::iterator i = schemas_.begin(); i != schemas_.end(); ++i)
541 result.insert(i->first); 459 result.insert(i->first);
542 for (UnloadedSchemaMap::iterator i = unloaded_schemas_.begin(); 460 for (UnloadedSchemaMap::iterator i = unloaded_schemas_.begin();
543 i != unloaded_schemas_.end(); ++i) { 461 i != unloaded_schemas_.end(); ++i) {
544 result.insert(i->first); 462 result.insert(i->first);
545 } 463 }
464 std::set<std::string> generated_names;
465 GeneratedSchemas::GetNames(&generated_names);
466 result.insert(generated_names.begin(), generated_names.end());
546 return result; 467 return result;
547 } 468 }
548 469
549 Feature* ExtensionAPI::GetFeatureDependency(const std::string& full_name) { 470 Feature* ExtensionAPI::GetFeatureDependency(const std::string& full_name) {
550 std::string feature_type; 471 std::string feature_type;
551 std::string feature_name; 472 std::string feature_name;
552 SplitDependencyName(full_name, &feature_type, &feature_name); 473 SplitDependencyName(full_name, &feature_type, &feature_name);
553 474
554 FeatureProviderMap::iterator provider = 475 FeatureProviderMap::iterator provider =
555 dependency_providers_.find(feature_type); 476 dependency_providers_.find(feature_type);
556 if (provider == dependency_providers_.end()) 477 if (provider == dependency_providers_.end())
557 return NULL; 478 return NULL;
558 479
559 Feature* feature = provider->second->GetFeature(feature_name); 480 Feature* feature = provider->second->GetFeature(feature_name);
560 // Try getting the feature for the parent API, if this was a child. 481 // Try getting the feature for the parent API, if this was a child.
561 if (!feature) { 482 if (!feature) {
562 std::string child_name; 483 std::string child_name;
563 feature = provider->second->GetFeature( 484 feature = provider->second->GetFeature(
564 GetAPINameFromFullName(feature_name, &child_name)); 485 GetAPINameFromFullName(feature_name, &child_name));
565 } 486 }
566 return feature; 487 return feature;
567 } 488 }
568 489
569 std::string ExtensionAPI::GetAPINameFromFullName(const std::string& full_name, 490 std::string ExtensionAPI::GetAPINameFromFullName(const std::string& full_name,
570 std::string* child_name) { 491 std::string* child_name) {
571 std::string api_name_candidate = full_name; 492 std::string api_name_candidate = full_name;
572 while (true) { 493 while (true) {
573 if (schemas_.find(api_name_candidate) != schemas_.end() || 494 if (schemas_.find(api_name_candidate) != schemas_.end() ||
495 GeneratedSchemas::IsGenerated(api_name_candidate) ||
574 unloaded_schemas_.find(api_name_candidate) != unloaded_schemas_.end()) { 496 unloaded_schemas_.find(api_name_candidate) != unloaded_schemas_.end()) {
575 std::string result = api_name_candidate; 497 std::string result = api_name_candidate;
576 498
577 if (child_name) { 499 if (child_name) {
578 if (result.length() < full_name.length()) 500 if (result.length() < full_name.length())
579 *child_name = full_name.substr(result.length() + 1); 501 *child_name = full_name.substr(result.length() + 1);
580 else 502 else
581 *child_name = ""; 503 *child_name = "";
582 } 504 }
583 505
584 return result; 506 return result;
585 } 507 }
586 508
587 size_t last_dot_index = api_name_candidate.rfind('.'); 509 size_t last_dot_index = api_name_candidate.rfind('.');
588 if (last_dot_index == std::string::npos) 510 if (last_dot_index == std::string::npos)
589 break; 511 break;
590 512
591 api_name_candidate = api_name_candidate.substr(0, last_dot_index); 513 api_name_candidate = api_name_candidate.substr(0, last_dot_index);
592 } 514 }
593 515
594 *child_name = ""; 516 *child_name = "";
595 return std::string(); 517 return std::string();
596 } 518 }
597 519
598 bool ExtensionAPI::IsAPIAllowed(const std::string& name,
599 const Extension* extension) {
600 return PermissionsData::GetRequiredPermissions(extension)->
601 HasAnyAccessToAPI(name) ||
602 PermissionsData::GetOptionalPermissions(extension)->
603 HasAnyAccessToAPI(name);
604 }
605
606 bool ExtensionAPI::IsPrivilegedAPI(const std::string& name) {
607 return completely_unprivileged_apis_.count(name) ||
608 partially_unprivileged_apis_.count(name);
609 }
610
611 } // namespace extensions 520 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698