| 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_constants.h" | 5 #include "chrome/common/extensions/extension_constants.h" |
| 6 | 6 |
| 7 #include <vector> |
| 8 |
| 7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 8 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 9 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 #include "net/base/escape.h" |
| 10 | 13 |
| 11 namespace extension_manifest_keys { | 14 namespace extension_manifest_keys { |
| 12 | 15 |
| 13 const char* kAllFrames = "all_frames"; | 16 const char* kAllFrames = "all_frames"; |
| 14 const char* kAltKey = "altKey"; | 17 const char* kAltKey = "altKey"; |
| 15 const char* kApp = "app"; | 18 const char* kApp = "app"; |
| 16 const char* kBackground = "background_page"; | 19 const char* kBackground = "background_page"; |
| 17 const char* kBrowserAction = "browser_action"; | 20 const char* kBrowserAction = "browser_action"; |
| 18 const char* kChromeURLOverrides = "chrome_url_overrides"; | 21 const char* kChromeURLOverrides = "chrome_url_overrides"; |
| 19 const char* kContentScripts = "content_scripts"; | 22 const char* kContentScripts = "content_scripts"; |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 " Sidebar API."; | 404 " Sidebar API."; |
| 402 const char* kThemesCannotContainExtensions = | 405 const char* kThemesCannotContainExtensions = |
| 403 "A theme cannot contain extensions code."; | 406 "A theme cannot contain extensions code."; |
| 404 #if defined(OS_CHROMEOS) | 407 #if defined(OS_CHROMEOS) |
| 405 const char* kIllegalPlugins = | 408 const char* kIllegalPlugins = |
| 406 "Extensions cannot install plugins on Chrome OS"; | 409 "Extensions cannot install plugins on Chrome OS"; |
| 407 #endif | 410 #endif |
| 408 } // namespace extension_manifest_errors | 411 } // namespace extension_manifest_errors |
| 409 | 412 |
| 410 namespace extension_urls { | 413 namespace extension_urls { |
| 414 std::string GetWebstoreLaunchURL() { |
| 415 std::string gallery_prefix = kGalleryBrowsePrefix; |
| 416 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAppsGalleryURL)) |
| 417 gallery_prefix = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 418 switches::kAppsGalleryURL); |
| 419 if (EndsWith(gallery_prefix, "/", true)) |
| 420 gallery_prefix = gallery_prefix.substr(0, gallery_prefix.length() - 1); |
| 421 return gallery_prefix; |
| 422 } |
| 423 |
| 424 std::string GetWebstoreItemDetailURLPrefix() { |
| 425 return GetWebstoreLaunchURL() + "/detail/"; |
| 426 } |
| 427 |
| 428 const char* kGalleryUpdateHttpUrl = |
| 429 "http://clients2.google.com/service/update2/crx"; |
| 430 const char* kGalleryUpdateHttpsUrl = |
| 431 "https://clients2.google.com/service/update2/crx"; |
| 432 |
| 433 GURL GetWebstoreUpdateUrl(bool secure) { |
| 434 CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
| 435 if (cmdline->HasSwitch(switches::kAppsGalleryUpdateURL)) |
| 436 return GURL(cmdline->GetSwitchValueASCII(switches::kAppsGalleryUpdateURL)); |
| 437 else |
| 438 return GURL(secure ? kGalleryUpdateHttpsUrl : kGalleryUpdateHttpUrl); |
| 439 } |
| 440 |
| 441 GURL GetWebstoreInstallUrl(const std::string& extension_id, |
| 442 const std::string& locale) { |
| 443 std::vector<std::string> params; |
| 444 params.push_back("id=" + extension_id); |
| 445 params.push_back("lang=" + locale); |
| 446 params.push_back("uc"); |
| 447 std::string url_string = extension_urls::GetWebstoreUpdateUrl(true).spec(); |
| 448 |
| 449 GURL url(url_string + "?response=redirect&x=" + |
| 450 EscapeQueryParamValue(JoinString(params, '&'), true)); |
| 451 DCHECK(url.is_valid()); |
| 452 |
| 453 return url; |
| 454 } |
| 455 |
| 411 const char* kGalleryBrowsePrefix = "https://chrome.google.com/webstore"; | 456 const char* kGalleryBrowsePrefix = "https://chrome.google.com/webstore"; |
| 412 const char* kMiniGalleryBrowsePrefix = "https://tools.google.com/chrome/"; | 457 const char* kMiniGalleryBrowsePrefix = "https://tools.google.com/chrome/"; |
| 413 const char* kMiniGalleryDownloadPrefix = "https://dl-ssl.google.com/chrome/"; | 458 const char* kMiniGalleryDownloadPrefix = "https://dl-ssl.google.com/chrome/"; |
| 414 } | 459 } |
| 415 | 460 |
| 416 namespace extension_filenames { | 461 namespace extension_filenames { |
| 417 const char* kTempExtensionName = "CRX_INSTALL"; | 462 const char* kTempExtensionName = "CRX_INSTALL"; |
| 418 | 463 |
| 419 // The file to write our decoded images to, relative to the extension_path. | 464 // The file to write our decoded images to, relative to the extension_path. |
| 420 const char* kDecodedImagesFilename = "DECODED_IMAGES"; | 465 const char* kDecodedImagesFilename = "DECODED_IMAGES"; |
| 421 | 466 |
| 422 // The file to write our decoded message catalogs to, relative to the | 467 // The file to write our decoded message catalogs to, relative to the |
| 423 // extension_path. | 468 // extension_path. |
| 424 const char* kDecodedMessageCatalogsFilename = "DECODED_MESSAGE_CATALOGS"; | 469 const char* kDecodedMessageCatalogsFilename = "DECODED_MESSAGE_CATALOGS"; |
| 425 } | 470 } |
| 426 | 471 |
| 427 namespace extension_misc { | 472 namespace extension_misc { |
| 428 const char* kBookmarkManagerId = "eemcgdkfndhakfknompkggombfjjjeno"; | 473 const char* kBookmarkManagerId = "eemcgdkfndhakfknompkggombfjjjeno"; |
| 429 const char* kWebStoreAppId = "ahfgeienlihckogmohjhadlkjgocpleb"; | 474 const char* kWebStoreAppId = "ahfgeienlihckogmohjhadlkjgocpleb"; |
| 430 const char* kCloudPrintAppId = "mfehgcgbbipciphmccgaenjidiccnmng"; | 475 const char* kCloudPrintAppId = "mfehgcgbbipciphmccgaenjidiccnmng"; |
| 431 const char* kAppsPromoHistogram = "Extensions.AppsPromo"; | 476 const char* kAppsPromoHistogram = "Extensions.AppsPromo"; |
| 432 const char* kAppLaunchHistogram = "Extensions.AppLaunch"; | 477 const char* kAppLaunchHistogram = "Extensions.AppLaunch"; |
| 433 #if defined(OS_CHROMEOS) | 478 #if defined(OS_CHROMEOS) |
| 434 const char* kAccessExtensionPath = | 479 const char* kAccessExtensionPath = |
| 435 "/usr/share/chromeos-assets/accessibility/extensions"; | 480 "/usr/share/chromeos-assets/accessibility/extensions"; |
| 436 const char* kChromeVoxDirectoryName = "access_chromevox"; | 481 const char* kChromeVoxDirectoryName = "access_chromevox"; |
| 437 #endif | 482 #endif |
| 438 | 483 |
| 439 std::string GetWebstoreLaunchURL() { | |
| 440 std::string gallery_prefix = extension_urls::kGalleryBrowsePrefix; | |
| 441 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAppsGalleryURL)) | |
| 442 gallery_prefix = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
| 443 switches::kAppsGalleryURL); | |
| 444 if (EndsWith(gallery_prefix, "/", true)) | |
| 445 gallery_prefix = gallery_prefix.substr(0, gallery_prefix.length() - 1); | |
| 446 return gallery_prefix; | |
| 447 } | 484 } |
| 448 | |
| 449 std::string GetWebstoreItemDetailURLPrefix() { | |
| 450 return GetWebstoreLaunchURL() + "/detail/"; | |
| 451 } | |
| 452 | |
| 453 } | |
| OLD | NEW |