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/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 2309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2320 // Although |source| is passed in as a const, it's still possible to modify | 2320 // Although |source| is passed in as a const, it's still possible to modify |
2321 // it. This is dangerous since the utility process re-uses |source| after | 2321 // it. This is dangerous since the utility process re-uses |source| after |
2322 // it calls InitFromValue, passing it up to the browser process which calls | 2322 // it calls InitFromValue, passing it up to the browser process which calls |
2323 // InitFromValue again. As a result, we need to make sure that nobody | 2323 // InitFromValue again. As a result, we need to make sure that nobody |
2324 // accidentally modifies it. | 2324 // accidentally modifies it. |
2325 DCHECK(source.Equals(manifest_value_.get())); | 2325 DCHECK(source.Equals(manifest_value_.get())); |
2326 | 2326 |
2327 return true; | 2327 return true; |
2328 } | 2328 } |
2329 | 2329 |
2330 // static | |
2331 std::string Extension::ChromeStoreLaunchURL() { | |
2332 std::string gallery_prefix = extension_urls::kGalleryBrowsePrefix; | |
2333 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAppsGalleryURL)) | |
2334 gallery_prefix = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
2335 switches::kAppsGalleryURL); | |
2336 if (EndsWith(gallery_prefix, "/", true)) | |
2337 gallery_prefix = gallery_prefix.substr(0, gallery_prefix.length() - 1); | |
2338 return gallery_prefix; | |
2339 } | |
2340 | |
2341 GURL Extension::GetHomepageURL() const { | 2330 GURL Extension::GetHomepageURL() const { |
2342 if (homepage_url_.is_valid()) | 2331 if (homepage_url_.is_valid()) |
2343 return homepage_url_; | 2332 return homepage_url_; |
2344 | 2333 |
2345 if (!UpdatesFromGallery()) | 2334 if (!UpdatesFromGallery()) |
2346 return GURL(); | 2335 return GURL(); |
2347 | 2336 |
2348 // TODO(erikkay): This may not be entirely correct with the webstore. | 2337 GURL url(extension_misc::GetWebstoreItemDetailURLPrefix() + id()); |
2349 // I think it will have a mixture of /extensions/detail and /webstore/detail | |
2350 // URLs. Perhaps they'll handle this nicely with redirects? | |
2351 GURL url(ChromeStoreLaunchURL() + std::string("/detail/") + id()); | |
2352 return url; | 2338 return url; |
2353 } | 2339 } |
2354 | 2340 |
2355 std::set<FilePath> Extension::GetBrowserImages() const { | 2341 std::set<FilePath> Extension::GetBrowserImages() const { |
2356 std::set<FilePath> image_paths; | 2342 std::set<FilePath> image_paths; |
2357 // TODO(viettrungluu): These |FilePath::FromWStringHack(UTF8ToWide())| | 2343 // TODO(viettrungluu): These |FilePath::FromWStringHack(UTF8ToWide())| |
2358 // indicate that we're doing something wrong. | 2344 // indicate that we're doing something wrong. |
2359 | 2345 |
2360 // Extension icons. | 2346 // Extension icons. |
2361 for (ExtensionIconSet::IconMap::const_iterator iter = icons().map().begin(); | 2347 for (ExtensionIconSet::IconMap::const_iterator iter = icons().map().begin(); |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2712 | 2698 |
2713 bool Extension::CanExecuteScriptOnPage(const GURL& page_url, | 2699 bool Extension::CanExecuteScriptOnPage(const GURL& page_url, |
2714 const UserScript* script, | 2700 const UserScript* script, |
2715 std::string* error) const { | 2701 std::string* error) const { |
2716 base::AutoLock auto_lock(runtime_data_lock_); | 2702 base::AutoLock auto_lock(runtime_data_lock_); |
2717 // The gallery is special-cased as a restricted URL for scripting to prevent | 2703 // The gallery is special-cased as a restricted URL for scripting to prevent |
2718 // access to special JS bindings we expose to the gallery (and avoid things | 2704 // access to special JS bindings we expose to the gallery (and avoid things |
2719 // like extensions removing the "report abuse" link). | 2705 // like extensions removing the "report abuse" link). |
2720 // TODO(erikkay): This seems like the wrong test. Shouldn't we we testing | 2706 // TODO(erikkay): This seems like the wrong test. Shouldn't we we testing |
2721 // against the store app extent? | 2707 // against the store app extent? |
2722 if ((page_url.host() == GURL(Extension::ChromeStoreLaunchURL()).host()) && | 2708 GURL store_url(extension_misc::GetWebstoreLaunchURL()); |
| 2709 if ((page_url.host() == store_url.host()) && |
2723 !CanExecuteScriptEverywhere() && | 2710 !CanExecuteScriptEverywhere() && |
2724 !CommandLine::ForCurrentProcess()->HasSwitch( | 2711 !CommandLine::ForCurrentProcess()->HasSwitch( |
2725 switches::kAllowScriptingGallery)) { | 2712 switches::kAllowScriptingGallery)) { |
2726 if (error) | 2713 if (error) |
2727 *error = errors::kCannotScriptGallery; | 2714 *error = errors::kCannotScriptGallery; |
2728 return false; | 2715 return false; |
2729 } | 2716 } |
2730 | 2717 |
2731 if (page_url.SchemeIs(chrome::kChromeUIScheme) && | 2718 if (page_url.SchemeIs(chrome::kChromeUIScheme) && |
2732 !CanExecuteScriptEverywhere()) | 2719 !CanExecuteScriptEverywhere()) |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2870 already_disabled(false), | 2857 already_disabled(false), |
2871 extension(extension) {} | 2858 extension(extension) {} |
2872 | 2859 |
2873 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 2860 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
2874 const Extension* extension, | 2861 const Extension* extension, |
2875 const ExtensionPermissionSet* permissions, | 2862 const ExtensionPermissionSet* permissions, |
2876 Reason reason) | 2863 Reason reason) |
2877 : reason(reason), | 2864 : reason(reason), |
2878 extension(extension), | 2865 extension(extension), |
2879 permissions(permissions) {} | 2866 permissions(permissions) {} |
OLD | NEW |