extension_urls.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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
  3. // found in the LICENSE file.
  4. #ifndef EXTENSIONS_COMMON_EXTENSION_URLS_H_
  5. #define EXTENSIONS_COMMON_EXTENSION_URLS_H_
  6. #include <string>
  7. #include "base/strings/string_piece.h"
  8. #include "url/gurl.h"
  9. namespace url {
  10. class Origin;
  11. }
  12. namespace extensions {
  13. // Determine whether or not a source came from an extension. |source| can link
  14. // to a page or a script, and can be external (e.g., "http://www.google.com"),
  15. // extension-related (e.g., "chrome-extension://<extension_id>/background.js"),
  16. // or internal (e.g., "event_bindings" or "schemaUtils").
  17. bool IsSourceFromAnExtension(const std::u16string& source);
  18. } // namespace extensions
  19. namespace extension_urls {
  20. // Canonical URLs for the Chrome Webstore. You probably want to use one of
  21. // the calls below rather than using one of these constants directly, since
  22. // the active extensions embedder may provide its own webstore URLs.
  23. extern const char kChromeWebstoreBaseURL[];
  24. extern const char kChromeWebstoreUpdateURL[];
  25. extern const char kNewChromeWebstoreBaseURL[];
  26. // Returns the URL prefix for the extension/apps gallery. Can be set via the
  27. // --apps-gallery-url switch. The URL returned will not contain a trailing
  28. // slash. Do not use this as a prefix/extent for the store.
  29. GURL GetWebstoreLaunchURL();
  30. GURL GetNewWebstoreLaunchURL();
  31. // Returns the URL to the extensions category on the Web Store. This is
  32. // derived from GetWebstoreLaunchURL().
  33. std::string GetWebstoreExtensionsCategoryURL();
  34. // Returns the URL prefix for an item in the extension/app gallery. This URL
  35. // will contain a trailing slash and should be concatenated with an item ID
  36. // to get the item detail URL.
  37. std::string GetWebstoreItemDetailURLPrefix();
  38. // Returns the URL used to get webstore data (ratings, manifest, icon URL,
  39. // etc.) about an extension from the webstore as JSON.
  40. GURL GetWebstoreItemJsonDataURL(const std::string& extension_id);
  41. // Returns the compile-time constant webstore update url specific to
  42. // Chrome. Usually you should prefer using GetWebstoreUpdateUrl.
  43. GURL GetDefaultWebstoreUpdateUrl();
  44. // Return the update URL used by gallery/webstore extensions/apps. This may
  45. // have been overridden by a command line flag for testing purposes.
  46. GURL GetWebstoreUpdateUrl();
  47. // Returns the url to visit to report abuse for the given |extension_id|
  48. // and |referrer_id|.
  49. GURL GetWebstoreReportAbuseUrl(const std::string& extension_id,
  50. const std::string& referrer_id);
  51. // Returns whether the URL is the webstore update URL (just considering host
  52. // and path, not scheme, query, etc.)
  53. bool IsWebstoreUpdateUrl(const GURL& update_url);
  54. // Returns true if the URL points to an extension blocklist.
  55. bool IsBlocklistUpdateUrl(const GURL& url);
  56. // Returns true if the origin points to an URL used for safebrowsing.
  57. // TODO(devlin): Update other methods to also take an url::Origin?
  58. bool IsSafeBrowsingUrl(const url::Origin& origin, base::StringPiece path);
  59. } // namespace extension_urls
  60. #endif // EXTENSIONS_COMMON_EXTENSION_URLS_H_