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

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

Issue 2773593003: Revert of Extensions: Only create Web request rules registry if Declarative Web Request is enabled. (Closed)
Patch Set: Created 3 years, 9 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
61 // Gets a human-readable name for the given extension type, suitable for giving 56 // Gets a human-readable name for the given extension type, suitable for giving
62 // to developers in an error message. 57 // to developers in an error message.
63 std::string GetDisplayName(Manifest::Type type) { 58 std::string GetDisplayName(Manifest::Type type) {
64 switch (type) { 59 switch (type) {
65 case Manifest::TYPE_UNKNOWN: 60 case Manifest::TYPE_UNKNOWN:
66 return "unknown"; 61 return "unknown";
67 case Manifest::TYPE_EXTENSION: 62 case Manifest::TYPE_EXTENSION:
68 return "extension"; 63 return "extension";
69 case Manifest::TYPE_HOSTED_APP: 64 case Manifest::TYPE_HOSTED_APP:
70 return "hosted app"; 65 return "hosted app";
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 } 448 }
454 449
455 bool SimpleFeature::IsIdInBlacklist(const std::string& extension_id) const { 450 bool SimpleFeature::IsIdInBlacklist(const std::string& extension_id) const {
456 return IsIdInList(extension_id, blacklist_); 451 return IsIdInList(extension_id, blacklist_);
457 } 452 }
458 453
459 bool SimpleFeature::IsIdInWhitelist(const std::string& extension_id) const { 454 bool SimpleFeature::IsIdInWhitelist(const std::string& extension_id) const {
460 return IsIdInList(extension_id, whitelist_); 455 return IsIdInList(extension_id, whitelist_);
461 } 456 }
462 457
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
470 // static 458 // static
471 bool SimpleFeature::IsIdInArray(const std::string& extension_id, 459 bool SimpleFeature::IsIdInArray(const std::string& extension_id,
472 const char* const array[], 460 const char* const array[],
473 size_t array_length) { 461 size_t array_length) {
474 if (!IsValidExtensionId(extension_id)) 462 if (!IsValidExtensionId(extension_id))
475 return false; 463 return false;
476 464
477 const char* const* start = array; 465 const char* const* start = array;
478 const char* const* end = array + array_length; 466 const char* const* end = array + array_length;
479 467
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 void SimpleFeature::set_platforms(std::initializer_list<Platform> platforms) { 573 void SimpleFeature::set_platforms(std::initializer_list<Platform> platforms) {
586 platforms_ = platforms; 574 platforms_ = platforms;
587 } 575 }
588 576
589 void SimpleFeature::set_whitelist( 577 void SimpleFeature::set_whitelist(
590 std::initializer_list<const char* const> whitelist) { 578 std::initializer_list<const char* const> whitelist) {
591 whitelist_.assign(whitelist.begin(), whitelist.end()); 579 whitelist_.assign(whitelist.begin(), whitelist.end());
592 } 580 }
593 581
594 } // namespace extensions 582 } // 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