OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chrome_extensions_client.h" | 5 #include "chrome/common/extensions/chrome_extensions_client.h" |
6 | 6 |
| 7 #include "base/command_line.h" |
7 #include "chrome/common/extensions/chrome_manifest_handlers.h" | 8 #include "chrome/common/extensions/chrome_manifest_handlers.h" |
8 #include "chrome/common/extensions/extension.h" | 9 #include "chrome/common/extensions/extension.h" |
9 #include "chrome/common/extensions/extension_constants.h" | 10 #include "chrome/common/extensions/extension_constants.h" |
10 #include "chrome/common/extensions/features/base_feature_provider.h" | 11 #include "chrome/common/extensions/features/base_feature_provider.h" |
11 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
12 #include "content/public/common/url_constants.h" | 13 #include "content/public/common/url_constants.h" |
| 14 #include "extensions/common/manifest_constants.h" |
13 #include "extensions/common/permissions/api_permission_set.h" | 15 #include "extensions/common/permissions/api_permission_set.h" |
14 #include "extensions/common/permissions/permission_message.h" | 16 #include "extensions/common/permissions/permission_message.h" |
| 17 #include "extensions/common/switches.h" |
15 #include "extensions/common/url_pattern.h" | 18 #include "extensions/common/url_pattern.h" |
16 #include "extensions/common/url_pattern_set.h" | 19 #include "extensions/common/url_pattern_set.h" |
17 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
18 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
19 #include "url/gurl.h" | 22 #include "url/gurl.h" |
20 | 23 |
21 namespace { | 24 namespace { |
22 const char kThumbsWhiteListedExtension[] = "khopmbdjffemhegeeobelklnbglcdgfh"; | 25 const char kThumbsWhiteListedExtension[] = "khopmbdjffemhegeeobelklnbglcdgfh"; |
23 } // namespace | 26 } // namespace |
24 | 27 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 if ((api_permissions.find(APIPermission::kExperimental) != | 119 if ((api_permissions.find(APIPermission::kExperimental) != |
117 api_permissions.end()) || | 120 api_permissions.end()) || |
118 (extension->id() == kThumbsWhiteListedExtension && | 121 (extension->id() == kThumbsWhiteListedExtension && |
119 extension->from_webstore())) { | 122 extension->from_webstore())) { |
120 hosts.AddPattern(URLPattern(URLPattern::SCHEME_CHROMEUI, | 123 hosts.AddPattern(URLPattern(URLPattern::SCHEME_CHROMEUI, |
121 chrome::kChromeUIThumbnailURL)); | 124 chrome::kChromeUIThumbnailURL)); |
122 } | 125 } |
123 return hosts; | 126 return hosts; |
124 } | 127 } |
125 | 128 |
| 129 bool ChromeExtensionsClient::IsScriptableURL( |
| 130 const GURL& url, std::string* error) const { |
| 131 // The gallery is special-cased as a restricted URL for scripting to prevent |
| 132 // access to special JS bindings we expose to the gallery (and avoid things |
| 133 // like extensions removing the "report abuse" link). |
| 134 // TODO(erikkay): This seems like the wrong test. Shouldn't we we testing |
| 135 // against the store app extent? |
| 136 GURL store_url(extension_urls::GetWebstoreLaunchURL()); |
| 137 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 138 switches::kAllowScriptingGallery)) { |
| 139 return true; |
| 140 } |
| 141 if (url.host() == store_url.host()) { |
| 142 if (error) |
| 143 *error = manifest_errors::kCannotScriptGallery; |
| 144 return false; |
| 145 } |
| 146 return true; |
| 147 } |
| 148 |
126 // static | 149 // static |
127 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() { | 150 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() { |
128 return g_client.Pointer(); | 151 return g_client.Pointer(); |
129 } | 152 } |
130 | 153 |
131 } // namespace extensions | 154 } // namespace extensions |
OLD | NEW |