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
5#ifndef EXTENSIONS_COMMON_EXTENSION_URLS_H_
6#define EXTENSIONS_COMMON_EXTENSION_URLS_H_
7
8#include <string>
9
10#include "base/strings/string16.h"
11
12class GURL;
13
14namespace extensions {
15
16// The name of the event_bindings module.
17extern const char kEventBindings[];
18
19// The name of the schemaUtils module.
20extern const char kSchemaUtils[];
21
22// Determine whether or not a source came from an extension. |source| can link
23// to a page or a script, and can be external (e.g., "http://www.google.com"),
24// extension-related (e.g., "chrome-extension://<extension_id>/background.js"),
25// or internal (e.g., "event_bindings" or "schemaUtils").
26bool IsSourceFromAnExtension(const base::string16& source);
27
28}  // namespace extensions
29
30namespace extension_urls {
31
32// Canonical URLs for the Chrome Webstore. You probably want to use one of
33// the calls below rather than using one of these constants directly, since
34// the active extensions embedder may provide its own webstore URLs.
35extern const char kChromeWebstoreBaseURL[];
36extern const char kChromeWebstoreUpdateURL[];
37
38// Returns the URL prefix for the extension/apps gallery. Can be set via the
39// --apps-gallery-url switch. The URL returned will not contain a trailing
40// slash. Do not use this as a prefix/extent for the store.
41std::string GetWebstoreLaunchURL();
42
43// Returns the URL to the extensions category on the Web Store. This is
44// derived from GetWebstoreLaunchURL().
45std::string GetWebstoreExtensionsCategoryURL();
46
47// Returns the URL prefix for an item in the extension/app gallery. This URL
48// will contain a trailing slash and should be concatenated with an item ID
49// to get the item detail URL.
50std::string GetWebstoreItemDetailURLPrefix();
51
52// Returns the URL used to get webstore data (ratings, manifest, icon URL,
53// etc.) about an extension from the webstore as JSON.
54GURL GetWebstoreItemJsonDataURL(const std::string& extension_id);
55
56// Returns the URL used to get webstore search results in JSON format. The URL
57// returns a JSON dictionary that has the search results (under "results").
58// Each entry in the array is a dictionary as the data returned for
59// GetWebstoreItemJsonDataURL above. |query| is the user typed query string.
60// |host_language_code| is the host language code, e.g. en_US. Both arguments
61// will be escaped and added as a query parameter to the returned web store
62// json search URL.
63GURL GetWebstoreJsonSearchUrl(const std::string& query,
64                              const std::string& host_language_code);
65
66// Returns the URL of the web store search results page for |query|.
67GURL GetWebstoreSearchPageUrl(const std::string& query);
68
69// Return the update URL used by gallery/webstore extensions/apps. This may
70// have been overridden by a command line flag for testing purposes.
71GURL GetWebstoreUpdateUrl();
72
73// Returns whether the URL is the webstore update URL (just considering host
74// and path, not scheme, query, etc.)
75bool IsWebstoreUpdateUrl(const GURL& update_url);
76
77// Returns true if the URL points to an extension blacklist.
78bool IsBlacklistUpdateUrl(const GURL& url);
79
80}  // namespace extension_urls
81
82#endif  // EXTENSIONS_COMMON_EXTENSION_URLS_H_
83