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

Side by Side Diff: chrome/common/extensions/extension.cc

Issue 2855009: Only allow installation of extensions/apps with gallery update url via download from gallery (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: name change Created 10 years, 6 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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/common/extensions/extension.h" 5 #include "chrome/common/extensions/extension.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 // Although |source| is passed in as a const, it's still possible to modify 1481 // Although |source| is passed in as a const, it's still possible to modify
1482 // it. This is dangerous since the utility process re-uses |source| after 1482 // it. This is dangerous since the utility process re-uses |source| after
1483 // it calls InitFromValue, passing it up to the browser process which calls 1483 // it calls InitFromValue, passing it up to the browser process which calls
1484 // InitFromValue again. As a result, we need to make sure that nobody 1484 // InitFromValue again. As a result, we need to make sure that nobody
1485 // accidentally modifies it. 1485 // accidentally modifies it.
1486 DCHECK(source.Equals(manifest_value_.get())); 1486 DCHECK(source.Equals(manifest_value_.get()));
1487 1487
1488 return true; 1488 return true;
1489 } 1489 }
1490 1490
1491 // static
1492 std::string Extension::ChromeStoreURL() {
1493 std::string gallery_prefix = extension_urls::kGalleryBrowsePrefix;
1494 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAppsGalleryURL))
1495 gallery_prefix = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
1496 switches::kAppsGalleryURL);
1497 return gallery_prefix;
1498 }
1499
1491 GURL Extension::GalleryUrl() const { 1500 GURL Extension::GalleryUrl() const {
1492 if (!update_url_.DomainIs("google.com")) 1501 if (!update_url_.DomainIs("google.com"))
1493 return GURL(); 1502 return GURL();
1494 1503
1495 GURL url(std::string(extension_urls::kGalleryBrowsePrefix) + 1504 GURL url(ChromeStoreURL() + std::string("/detail/") + id_);
1496 std::string("/detail/") + id_);
1497 1505
1498 return url; 1506 return url;
1499 } 1507 }
1500 1508
1501 std::set<FilePath> Extension::GetBrowserImages() { 1509 std::set<FilePath> Extension::GetBrowserImages() {
1502 std::set<FilePath> image_paths; 1510 std::set<FilePath> image_paths;
1503 1511
1504 // Extension icons. 1512 // Extension icons.
1505 for (std::map<int, std::string>::iterator iter = icons_.begin(); 1513 for (std::map<int, std::string>::iterator iter = icons_.begin();
1506 iter != icons_.end(); ++iter) { 1514 iter != icons_.end(); ++iter) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1638 if (host->MatchesUrl(url)) 1646 if (host->MatchesUrl(url))
1639 return true; 1647 return true;
1640 } 1648 }
1641 return false; 1649 return false;
1642 } 1650 }
1643 1651
1644 bool Extension::CanExecuteScriptOnHost(const GURL& url, 1652 bool Extension::CanExecuteScriptOnHost(const GURL& url,
1645 std::string* error) const { 1653 std::string* error) const {
1646 // No extensions are allowed to execute script on the gallery because that 1654 // No extensions are allowed to execute script on the gallery because that
1647 // would allow extensions to manipulate their own install pages. 1655 // would allow extensions to manipulate their own install pages.
1648 if (url.host() == GURL(extension_urls::kGalleryBrowsePrefix).host()) { 1656 if (url.host() == GURL(ChromeStoreURL()).host()) {
1649 if (error) 1657 if (error)
1650 *error = errors::kCannotScriptGallery; 1658 *error = errors::kCannotScriptGallery;
1651 return false; 1659 return false;
1652 } 1660 }
1653 1661
1654 if (HasHostPermission(url)) 1662 if (HasHostPermission(url))
1655 return true; 1663 return true;
1656 1664
1657 if (error) { 1665 if (error) {
1658 *error = ExtensionErrorUtils::FormatErrorMessage(errors::kCannotAccessPage, 1666 *error = ExtensionErrorUtils::FormatErrorMessage(errors::kCannotAccessPage,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 } else { 1722 } else {
1715 return false; 1723 return false;
1716 } 1724 }
1717 } else { 1725 } else {
1718 return true; 1726 return true;
1719 } 1727 }
1720 } 1728 }
1721 } 1729 }
1722 return false; 1730 return false;
1723 } 1731 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698