| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 PermissionsInfo::GetInstance()->AddProvider(extensions_api_permissions_, | 125 PermissionsInfo::GetInstance()->AddProvider(extensions_api_permissions_, |
| 126 GetExtensionsPermissionAliases()); | 126 GetExtensionsPermissionAliases()); |
| 127 | 127 |
| 128 // Set up the scripting whitelist. | 128 // Set up the scripting whitelist. |
| 129 // Whitelist ChromeVox, an accessibility extension from Google that needs | 129 // Whitelist ChromeVox, an accessibility extension from Google that needs |
| 130 // the ability to script webui pages. This is temporary and is not | 130 // the ability to script webui pages. This is temporary and is not |
| 131 // meant to be a general solution. | 131 // meant to be a general solution. |
| 132 // TODO(dmazzoni): remove this once we have an extension API that | 132 // TODO(dmazzoni): remove this once we have an extension API that |
| 133 // allows any extension to request read-only access to webui pages. | 133 // allows any extension to request read-only access to webui pages. |
| 134 scripting_whitelist_.push_back(extension_misc::kChromeVoxExtensionId); | 134 scripting_whitelist_.push_back(extension_misc::kChromeVoxExtensionId); |
| 135 |
| 136 webstore_base_url_ = GURL(extension_urls::kChromeWebstoreBaseURL); |
| 137 webstore_update_url_ = GURL(extension_urls::GetDefaultWebstoreUpdateUrl()); |
| 135 } | 138 } |
| 136 | 139 |
| 137 const PermissionMessageProvider& | 140 const PermissionMessageProvider& |
| 138 ChromeExtensionsClient::GetPermissionMessageProvider() const { | 141 ChromeExtensionsClient::GetPermissionMessageProvider() const { |
| 139 return permission_message_provider_; | 142 return permission_message_provider_; |
| 140 } | 143 } |
| 141 | 144 |
| 142 const std::string ChromeExtensionsClient::GetProductName() { | 145 const std::string ChromeExtensionsClient::GetProductName() { |
| 143 return l10n_util::GetStringUTF8(IDS_PRODUCT_NAME); | 146 return l10n_util::GetStringUTF8(IDS_PRODUCT_NAME); |
| 144 } | 147 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 // return GetCurrentChannel() > version_info::Channel::DEV; | 265 // return GetCurrentChannel() > version_info::Channel::DEV; |
| 263 return true; | 266 return true; |
| 264 } | 267 } |
| 265 | 268 |
| 266 void ChromeExtensionsClient::RecordDidSuppressFatalError() { | 269 void ChromeExtensionsClient::RecordDidSuppressFatalError() { |
| 267 UMA_HISTOGRAM_ENUMERATION("Extensions.DidSuppressJavaScriptException", | 270 UMA_HISTOGRAM_ENUMERATION("Extensions.DidSuppressJavaScriptException", |
| 268 GetChromeChannelForHistogram(GetCurrentChannel()), | 271 GetChromeChannelForHistogram(GetCurrentChannel()), |
| 269 NUM_CHANNELS_FOR_HISTOGRAM); | 272 NUM_CHANNELS_FOR_HISTOGRAM); |
| 270 } | 273 } |
| 271 | 274 |
| 272 std::string ChromeExtensionsClient::GetWebstoreBaseURL() const { | 275 const GURL& ChromeExtensionsClient::GetWebstoreBaseURL() const { |
| 273 std::string gallery_prefix = extension_urls::kChromeWebstoreBaseURL; | 276 // Browser tests like to alter the command line at runtime with new update |
| 274 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 277 // URLs. Just update the cached value of the base url (to avoid reparsing |
| 275 switches::kAppsGalleryURL)) | 278 // it) if the value has changed. |
| 276 gallery_prefix = | 279 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 277 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 280 if (cmdline->HasSwitch(switches::kAppsGalleryURL)) { |
| 278 switches::kAppsGalleryURL); | 281 std::string url = cmdline->GetSwitchValueASCII(switches::kAppsGalleryURL); |
| 279 if (base::EndsWith(gallery_prefix, "/", base::CompareCase::SENSITIVE)) | 282 if (webstore_base_url_.possibly_invalid_spec() != url) |
| 280 gallery_prefix = gallery_prefix.substr(0, gallery_prefix.length() - 1); | 283 webstore_base_url_ = GURL(url); |
| 281 return gallery_prefix; | 284 } |
| 285 return webstore_base_url_; |
| 282 } | 286 } |
| 283 | 287 |
| 284 const GURL& ChromeExtensionsClient::GetWebstoreUpdateURL() const { | 288 const GURL& ChromeExtensionsClient::GetWebstoreUpdateURL() const { |
| 285 // Browser tests like to alter the command line at runtime with new update | 289 // Browser tests like to alter the command line at runtime with new update |
| 286 // URLs. Just update the cached value of the update url (to avoid reparsing | 290 // URLs. Just update the cached value of the update url (to avoid reparsing |
| 287 // it) if the value has changed. | 291 // it) if the value has changed. |
| 288 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | 292 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 289 if (cmdline->HasSwitch(switches::kAppsGalleryUpdateURL)) { | 293 if (cmdline->HasSwitch(switches::kAppsGalleryUpdateURL)) { |
| 290 std::string url = | 294 std::string url = |
| 291 cmdline->GetSwitchValueASCII(switches::kAppsGalleryUpdateURL); | 295 cmdline->GetSwitchValueASCII(switches::kAppsGalleryUpdateURL); |
| 292 if (webstore_update_url_ != url) | 296 if (webstore_update_url_.possibly_invalid_spec() != url) |
| 293 webstore_update_url_ = GURL(url); | 297 webstore_update_url_ = GURL(url); |
| 294 } else if (webstore_update_url_.is_empty()) { | |
| 295 webstore_update_url_ = GURL(extension_urls::GetDefaultWebstoreUpdateUrl()); | |
| 296 } | 298 } |
| 297 return webstore_update_url_; | 299 return webstore_update_url_; |
| 298 } | 300 } |
| 299 | 301 |
| 300 bool ChromeExtensionsClient::IsBlacklistUpdateURL(const GURL& url) const { | 302 bool ChromeExtensionsClient::IsBlacklistUpdateURL(const GURL& url) const { |
| 301 // The extension blacklist URL is returned from the update service and | 303 // The extension blacklist URL is returned from the update service and |
| 302 // therefore not determined by Chromium. If the location of the blacklist file | 304 // therefore not determined by Chromium. If the location of the blacklist file |
| 303 // ever changes, we need to update this function. A DCHECK in the | 305 // ever changes, we need to update this function. A DCHECK in the |
| 304 // ExtensionUpdater ensures that we notice a change. This is the full URL | 306 // ExtensionUpdater ensures that we notice a change. This is the full URL |
| 305 // of a blacklist: | 307 // of a blacklist: |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 const { | 344 const { |
| 343 return GetCurrentChannel() == version_info::Channel::UNKNOWN; | 345 return GetCurrentChannel() == version_info::Channel::UNKNOWN; |
| 344 } | 346 } |
| 345 | 347 |
| 346 // static | 348 // static |
| 347 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() { | 349 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() { |
| 348 return g_client.Pointer(); | 350 return g_client.Pointer(); |
| 349 } | 351 } |
| 350 | 352 |
| 351 } // namespace extensions | 353 } // namespace extensions |
| OLD | NEW |