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" |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 value->GetBoolean("noparent", &no_parent_); | 284 value->GetBoolean("noparent", &no_parent_); |
285 | 285 |
286 component_extensions_auto_granted_ = true; | 286 component_extensions_auto_granted_ = true; |
287 value->GetBoolean("component_extensions_auto_granted", | 287 value->GetBoolean("component_extensions_auto_granted", |
288 &component_extensions_auto_granted_); | 288 &component_extensions_auto_granted_); |
289 | 289 |
290 if (matches_.is_empty() && contexts_.count(WEB_PAGE_CONTEXT) != 0) { | 290 if (matches_.is_empty() && contexts_.count(WEB_PAGE_CONTEXT) != 0) { |
291 return name() + ": Allowing web_page contexts requires supplying a value " + | 291 return name() + ": Allowing web_page contexts requires supplying a value " + |
292 "for matches."; | 292 "for matches."; |
293 } | 293 } |
294 if (!matches_.is_empty() && contexts_.count(WEB_PAGE_CONTEXT) == 0) { | |
295 return name() + ": \"matches\" only makes sense for web page contexts"; | |
296 } | |
294 | 297 |
295 for (FilterList::iterator filter_iter = filters_.begin(); | 298 for (FilterList::iterator filter_iter = filters_.begin(); |
296 filter_iter != filters_.end(); | 299 filter_iter != filters_.end(); |
297 ++filter_iter) { | 300 ++filter_iter) { |
298 std::string result = (*filter_iter)->Parse(value); | 301 std::string result = (*filter_iter)->Parse(value); |
299 if (!result.empty()) { | 302 if (!result.empty()) { |
300 return result; | 303 return result; |
301 } | 304 } |
302 } | 305 } |
303 | 306 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 extension->location(), | 391 extension->location(), |
389 extension->manifest_version(), | 392 extension->manifest_version(), |
390 platform); | 393 platform); |
391 if (!result.is_available()) | 394 if (!result.is_available()) |
392 return result; | 395 return result; |
393 } | 396 } |
394 | 397 |
395 if (!contexts_.empty() && contexts_.find(context) == contexts_.end()) | 398 if (!contexts_.empty() && contexts_.find(context) == contexts_.end()) |
396 return CreateAvailability(INVALID_CONTEXT, context); | 399 return CreateAvailability(INVALID_CONTEXT, context); |
397 | 400 |
398 if (!matches_.is_empty() && !matches_.MatchesURL(url)) | 401 if (context == WEB_PAGE_CONTEXT && !matches_.MatchesURL(url)) |
not at google - send to devlin
2014/07/07 22:25:05
it's either this change or plumbing through the UR
Ken Rockot(use gerrit already)
2014/07/09 16:24:16
this seems fair to me
| |
399 return CreateAvailability(INVALID_URL, url); | 402 return CreateAvailability(INVALID_URL, url); |
400 | 403 |
401 for (FilterList::const_iterator filter_iter = filters_.begin(); | 404 for (FilterList::const_iterator filter_iter = filters_.begin(); |
402 filter_iter != filters_.end(); | 405 filter_iter != filters_.end(); |
403 ++filter_iter) { | 406 ++filter_iter) { |
404 Availability availability = | 407 Availability availability = |
405 (*filter_iter)->IsAvailableToContext(extension, context, url, platform); | 408 (*filter_iter)->IsAvailableToContext(extension, context, url, platform); |
406 if (!availability.is_available()) | 409 if (!availability.is_available()) |
407 return availability; | 410 return availability; |
408 } | 411 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 } | 498 } |
496 | 499 |
497 Feature::Availability SimpleFeature::CreateAvailability( | 500 Feature::Availability SimpleFeature::CreateAvailability( |
498 AvailabilityResult result, | 501 AvailabilityResult result, |
499 Context context) const { | 502 Context context) const { |
500 return Availability( | 503 return Availability( |
501 result, GetAvailabilityMessage(result, Manifest::TYPE_UNKNOWN, GURL(), | 504 result, GetAvailabilityMessage(result, Manifest::TYPE_UNKNOWN, GURL(), |
502 context)); | 505 context)); |
503 } | 506 } |
504 | 507 |
505 std::set<Feature::Context>* SimpleFeature::GetContexts() { | |
506 return &contexts_; | |
507 } | |
508 | |
509 bool SimpleFeature::IsInternal() const { | 508 bool SimpleFeature::IsInternal() const { |
510 return false; | 509 return false; |
511 } | 510 } |
512 | 511 |
513 bool SimpleFeature::IsBlockedInServiceWorker() const { return false; } | 512 bool SimpleFeature::IsBlockedInServiceWorker() const { return false; } |
514 | 513 |
515 bool SimpleFeature::IsIdInBlacklist(const std::string& extension_id) const { | 514 bool SimpleFeature::IsIdInBlacklist(const std::string& extension_id) const { |
516 return IsIdInList(extension_id, blacklist_); | 515 return IsIdInList(extension_id, blacklist_); |
517 } | 516 } |
518 | 517 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
564 if (!dependency) | 563 if (!dependency) |
565 return CreateAvailability(NOT_PRESENT); | 564 return CreateAvailability(NOT_PRESENT); |
566 Availability dependency_availability = checker.Run(dependency); | 565 Availability dependency_availability = checker.Run(dependency); |
567 if (!dependency_availability.is_available()) | 566 if (!dependency_availability.is_available()) |
568 return dependency_availability; | 567 return dependency_availability; |
569 } | 568 } |
570 return CreateAvailability(IS_AVAILABLE); | 569 return CreateAvailability(IS_AVAILABLE); |
571 } | 570 } |
572 | 571 |
573 } // namespace extensions | 572 } // namespace extensions |
OLD | NEW |