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