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

Side by Side Diff: extensions/common/features/simple_feature.cc

Issue 2705513002: Extensions: Only create Web request rules registry if Declarative Web Request is enabled. (Closed)
Patch Set: Correct comment. Created 3 years, 10 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/common/features/simple_feature.h" 5 #include "extensions/common/features/simple_feature.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 } 46 }
47 47
48 Feature::Availability IsAvailableToContextForBind(const Extension* extension, 48 Feature::Availability IsAvailableToContextForBind(const Extension* extension,
49 Feature::Context context, 49 Feature::Context context,
50 const GURL& url, 50 const GURL& url,
51 Feature::Platform platform, 51 Feature::Platform platform,
52 const Feature* feature) { 52 const Feature* feature) {
53 return feature->IsAvailableToContext(extension, context, url, platform); 53 return feature->IsAvailableToContext(extension, context, url, platform);
54 } 54 }
55 55
56 Feature::Availability IsAvailableToChannelForBind(version_info::Channel channel,
57 const Feature* feature) {
58 return feature->IsAvailableToChannel(channel);
59 }
60
56 // Gets a human-readable name for the given extension type, suitable for giving 61 // Gets a human-readable name for the given extension type, suitable for giving
57 // to developers in an error message. 62 // to developers in an error message.
58 std::string GetDisplayName(Manifest::Type type) { 63 std::string GetDisplayName(Manifest::Type type) {
59 switch (type) { 64 switch (type) {
60 case Manifest::TYPE_UNKNOWN: 65 case Manifest::TYPE_UNKNOWN:
61 return "unknown"; 66 return "unknown";
62 case Manifest::TYPE_EXTENSION: 67 case Manifest::TYPE_EXTENSION:
63 return "extension"; 68 return "extension";
64 case Manifest::TYPE_HOSTED_APP: 69 case Manifest::TYPE_HOSTED_APP:
65 return "hosted app"; 70 return "hosted app";
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 } 453 }
449 454
450 bool SimpleFeature::IsIdInBlacklist(const std::string& extension_id) const { 455 bool SimpleFeature::IsIdInBlacklist(const std::string& extension_id) const {
451 return IsIdInList(extension_id, blacklist_); 456 return IsIdInList(extension_id, blacklist_);
452 } 457 }
453 458
454 bool SimpleFeature::IsIdInWhitelist(const std::string& extension_id) const { 459 bool SimpleFeature::IsIdInWhitelist(const std::string& extension_id) const {
455 return IsIdInList(extension_id, whitelist_); 460 return IsIdInList(extension_id, whitelist_);
456 } 461 }
457 462
463 Feature::Availability SimpleFeature::IsAvailableToChannel(
464 version_info::Channel channel) const {
465 if (channel_ && *channel_ < channel)
466 return CreateAvailability(UNSUPPORTED_CHANNEL, *channel_);
467 return CheckDependencies(base::Bind(&IsAvailableToChannelForBind, channel));
468 }
469
458 // static 470 // static
459 bool SimpleFeature::IsIdInArray(const std::string& extension_id, 471 bool SimpleFeature::IsIdInArray(const std::string& extension_id,
460 const char* const array[], 472 const char* const array[],
461 size_t array_length) { 473 size_t array_length) {
462 if (!IsValidExtensionId(extension_id)) 474 if (!IsValidExtensionId(extension_id))
463 return false; 475 return false;
464 476
465 const char* const* start = array; 477 const char* const* start = array;
466 const char* const* end = array + array_length; 478 const char* const* end = array + array_length;
467 479
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 void SimpleFeature::set_platforms(std::initializer_list<Platform> platforms) { 585 void SimpleFeature::set_platforms(std::initializer_list<Platform> platforms) {
574 platforms_ = platforms; 586 platforms_ = platforms;
575 } 587 }
576 588
577 void SimpleFeature::set_whitelist( 589 void SimpleFeature::set_whitelist(
578 std::initializer_list<const char* const> whitelist) { 590 std::initializer_list<const char* const> whitelist) {
579 whitelist_.assign(whitelist.begin(), whitelist.end()); 591 whitelist_.assign(whitelist.begin(), whitelist.end());
580 } 592 }
581 593
582 } // namespace extensions 594 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/features/simple_feature.h ('k') | extensions/common/features/simple_feature_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698