OLD | NEW |
---|---|
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 <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/debug/alias.h" | 12 #include "base/debug/alias.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/sha1.h" | 14 #include "base/sha1.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
18 #include "extensions/common/extension_api.h" | 18 #include "extensions/common/extension_api.h" |
19 #include "extensions/common/features/feature_provider.h" | 19 #include "extensions/common/features/feature_provider.h" |
20 #include "extensions/common/permissions/permissions_data.h" | |
20 #include "extensions/common/switches.h" | 21 #include "extensions/common/switches.h" |
21 | 22 |
22 namespace extensions { | 23 namespace extensions { |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 Feature::Availability IsAvailableToManifestForBind( | 27 Feature::Availability IsAvailableToManifestForBind( |
27 const std::string& extension_id, | 28 const std::string& extension_id, |
28 Manifest::Type type, | 29 Manifest::Type type, |
29 Manifest::Location location, | 30 Manifest::Location location, |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
399 return result; | 400 return result; |
400 } | 401 } |
401 | 402 |
402 if (!contexts_.empty() && contexts_.find(context) == contexts_.end()) | 403 if (!contexts_.empty() && contexts_.find(context) == contexts_.end()) |
403 return CreateAvailability(INVALID_CONTEXT, context); | 404 return CreateAvailability(INVALID_CONTEXT, context); |
404 | 405 |
405 // TODO(kalman): Consider checking |matches_| regardless of context type. | 406 // TODO(kalman): Consider checking |matches_| regardless of context type. |
406 // Fewer surprises, and if the feature configuration wants to isolate | 407 // Fewer surprises, and if the feature configuration wants to isolate |
407 // "matches" from say "blessed_extension" then they can use complex features. | 408 // "matches" from say "blessed_extension" then they can use complex features. |
408 if ((context == WEB_PAGE_CONTEXT || context == WEBUI_CONTEXT) && | 409 if ((context == WEB_PAGE_CONTEXT || context == WEBUI_CONTEXT) && |
409 !matches_.MatchesURL(url)) { | 410 (!matches_.MatchesURL(url) || |
411 (url.is_valid() && | |
sadrul
2014/08/06 18:51:51
The check for url.is_valid() is here because Exten
not at google - send to devlin
2014/08/06 22:10:28
damn, it looks like this check is breaking the web
| |
412 PermissionsData::IsRestrictedUrl(url, url, extension, NULL)))) { | |
410 return CreateAvailability(INVALID_URL, url); | 413 return CreateAvailability(INVALID_URL, url); |
411 } | 414 } |
412 | 415 |
413 for (FilterList::const_iterator filter_iter = filters_.begin(); | 416 for (FilterList::const_iterator filter_iter = filters_.begin(); |
414 filter_iter != filters_.end(); | 417 filter_iter != filters_.end(); |
415 ++filter_iter) { | 418 ++filter_iter) { |
416 Availability availability = | 419 Availability availability = |
417 (*filter_iter)->IsAvailableToContext(extension, context, url, platform); | 420 (*filter_iter)->IsAvailableToContext(extension, context, url, platform); |
418 if (!availability.is_available()) | 421 if (!availability.is_available()) |
419 return availability; | 422 return availability; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
572 if (!dependency) | 575 if (!dependency) |
573 return CreateAvailability(NOT_PRESENT); | 576 return CreateAvailability(NOT_PRESENT); |
574 Availability dependency_availability = checker.Run(dependency); | 577 Availability dependency_availability = checker.Run(dependency); |
575 if (!dependency_availability.is_available()) | 578 if (!dependency_availability.is_available()) |
576 return dependency_availability; | 579 return dependency_availability; |
577 } | 580 } |
578 return CreateAvailability(IS_AVAILABLE); | 581 return CreateAvailability(IS_AVAILABLE); |
579 } | 582 } |
580 | 583 |
581 } // namespace extensions | 584 } // namespace extensions |
OLD | NEW |