OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/extensions/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 | 449 |
450 // If a download url matches one of these patterns and has a referrer of the | 450 // If a download url matches one of these patterns and has a referrer of the |
451 // webstore, then we're willing to treat that as a gallery download. | 451 // webstore, then we're willing to treat that as a gallery download. |
452 static const char* kAllowedDownloadURLPatterns[] = { | 452 static const char* kAllowedDownloadURLPatterns[] = { |
453 "https://clients2.google.com/service/update2*", | 453 "https://clients2.google.com/service/update2*", |
454 "https://clients2.googleusercontent.com/crx/*" | 454 "https://clients2.googleusercontent.com/crx/*" |
455 }; | 455 }; |
456 | 456 |
457 bool ExtensionService::IsDownloadFromGallery(const GURL& download_url, | 457 bool ExtensionService::IsDownloadFromGallery(const GURL& download_url, |
458 const GURL& referrer_url) { | 458 const GURL& referrer_url) { |
459 // Special-case the themes mini-gallery. | |
460 // TODO(erikkay) When that gallery goes away, remove this code. | |
461 if (IsDownloadFromMiniGallery(download_url) && | |
462 StartsWithASCII(referrer_url.spec(), | |
463 extension_urls::kMiniGalleryBrowsePrefix, false)) { | |
464 return true; | |
465 } | |
466 | |
467 const Extension* download_extension = GetExtensionByWebExtent(download_url); | 459 const Extension* download_extension = GetExtensionByWebExtent(download_url); |
468 const Extension* referrer_extension = GetExtensionByWebExtent(referrer_url); | 460 const Extension* referrer_extension = GetExtensionByWebExtent(referrer_url); |
469 const Extension* webstore_app = GetWebStoreApp(); | 461 const Extension* webstore_app = GetWebStoreApp(); |
470 | 462 |
471 bool referrer_valid = (referrer_extension == webstore_app); | 463 bool referrer_valid = (referrer_extension == webstore_app); |
472 bool download_valid = (download_extension == webstore_app); | 464 bool download_valid = (download_extension == webstore_app); |
473 | 465 |
474 // We also allow the download to be from a small set of trusted paths. | 466 // We also allow the download to be from a small set of trusted paths. |
475 if (!download_valid) { | 467 if (!download_valid) { |
476 for (size_t i = 0; i < arraysize(kAllowedDownloadURLPatterns); i++) { | 468 for (size_t i = 0; i < arraysize(kAllowedDownloadURLPatterns); i++) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 download_url); | 500 download_url); |
509 | 501 |
510 // Otherwise, the TLD must match the TLD of the command-line url. | 502 // Otherwise, the TLD must match the TLD of the command-line url. |
511 download_valid = (download_tld == store_tld); | 503 download_valid = (download_tld == store_tld); |
512 } | 504 } |
513 } | 505 } |
514 | 506 |
515 return (referrer_valid && download_valid); | 507 return (referrer_valid && download_valid); |
516 } | 508 } |
517 | 509 |
518 bool ExtensionService::IsDownloadFromMiniGallery(const GURL& download_url) { | |
519 return StartsWithASCII(download_url.spec(), | |
520 extension_urls::kMiniGalleryDownloadPrefix, | |
521 false); // case_sensitive | |
522 } | |
523 | |
524 const Extension* ExtensionService::GetInstalledApp(const GURL& url) { | 510 const Extension* ExtensionService::GetInstalledApp(const GURL& url) { |
525 // Check for hosted app. | 511 // Check for hosted app. |
526 const Extension* app = GetExtensionByWebExtent(url); | 512 const Extension* app = GetExtensionByWebExtent(url); |
527 if (app) | 513 if (app) |
528 return app; | 514 return app; |
529 | 515 |
530 // Check for packaged app. | 516 // Check for packaged app. |
531 app = GetExtensionByURL(url); | 517 app = GetExtensionByURL(url); |
532 if (app && app->is_app()) | 518 if (app && app->is_app()) |
533 return app; | 519 return app; |
(...skipping 2490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3024 | 3010 |
3025 ExtensionService::NaClModuleInfoList::iterator | 3011 ExtensionService::NaClModuleInfoList::iterator |
3026 ExtensionService::FindNaClModule(const GURL& url) { | 3012 ExtensionService::FindNaClModule(const GURL& url) { |
3027 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | 3013 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); |
3028 iter != nacl_module_list_.end(); ++iter) { | 3014 iter != nacl_module_list_.end(); ++iter) { |
3029 if (iter->url == url) | 3015 if (iter->url == url) |
3030 return iter; | 3016 return iter; |
3031 } | 3017 } |
3032 return nacl_module_list_.end(); | 3018 return nacl_module_list_.end(); |
3033 } | 3019 } |
OLD | NEW |