File: extension_urls.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (125 lines) | stat: -rw-r--r-- 5,138 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef EXTENSIONS_COMMON_EXTENSION_URLS_H_
#define EXTENSIONS_COMMON_EXTENSION_URLS_H_

#include <string>
#include <string_view>

#include "base/auto_reset.h"
#include "build/branding_buildflags.h"
#include "extensions/common/extension_id.h"
#include "url/gurl.h"

namespace url {
class Origin;
}

namespace extensions {

// Determine whether or not a source came from an extension. `source` can link
// to a page or a script, and can be external (e.g., "http://www.google.com"),
// extension-related (e.g., "chrome-extension://<extension_id>/background.js"),
// or internal (e.g., "event_bindings" or "schemaUtils").
bool IsSourceFromAnExtension(const std::u16string& source);

}  // namespace extensions

namespace extension_urls {

// Canonical URLs for the Chrome Webstore. You probably want to use one of
// the calls below rather than using one of these constants directly, since
// the active extensions embedder may provide its own webstore URLs.
extern const char kChromeWebstoreBaseURL[];
extern const char kChromeWebstoreUpdateURL[];
extern const char kNewChromeWebstoreBaseURL[];
extern const char kExtensionsDocsWhatsNewURL[];

// Various utm attribution sources for web store URLs.
// From the sub-menu item in the extension menu inside the 3-dot menu.
extern const char kAppMenuUtmSource[];
// From the button in the puzzle-piece extensions menu in the toolbar.
extern const char kExtensionsMenuUtmSource[];
// From the link in the sidebar in the chrome://extensions page.
extern const char kExtensionsSidebarUtmSource[];
// From the Extensions Zero State Promo custom action IPH.
extern const char kCustomActionIphUtmSource[];
// From the Extensions Zero State Promo, custom UI IPH, chips variant.
extern const char kCustomUiChipIphUtmSource[];
// From the Extensions Zero State Promo, custom UI IPH, text link variant.
extern const char kCustomUiPlainLinkIphUtmSource[];

// Returns the URL prefix for the extension/apps gallery. Can be set via the
// --apps-gallery-url switch. The URL returned will not contain a trailing
// slash. Do not use this as a prefix/extent for the store.
GURL GetWebstoreLaunchURL();
GURL GetNewWebstoreLaunchURL();

// Returns the URL to the Chrome Web Store's "What's New" page for extensions.
GURL GetDocsWhatsNewURL();

// Returns a url with a utm_source query param value of `utm_source_value`
// appended.
GURL AppendUtmSource(const GURL& url, std::string_view utm_source_value);

// Returns the URL to the extensions category on the Web Store.
GURL GetWebstoreExtensionsCategoryURL();

// Returns the URL prefix for an item in the extension/app gallery. This URL
// will contain a trailing slash and should be concatenated with an item ID
// to get the item detail URL.
std::string GetWebstoreItemDetailURLPrefix();

// Returns the URL used to get webstore data (ratings, manifest, icon URL,
// etc.) about an extension from the webstore using the new itemSnippets API.
GURL GetWebstoreItemSnippetURL(const extensions::ExtensionId& extension_id);

// Sets the itemSnippets API URL to `test_url`.
base::AutoReset<const GURL*> SetItemSnippetURLForTesting(const GURL* test_url);

// Returns the compile-time constant webstore update url specific to
// Chrome. Usually you should prefer using GetWebstoreUpdateUrl.
GURL GetDefaultWebstoreUpdateUrl();

// Return the update URL used by gallery/webstore extensions/apps. This may
// have been overridden by a command line flag for testing purposes.
GURL GetWebstoreUpdateUrl();

// Returns the url to visit to report abuse for the given `extension_id`
// and `referrer_id`.
GURL GetWebstoreReportAbuseUrl(const extensions::ExtensionId& extension_id,
                               const std::string& referrer_id);

// Returns the URL with extension recommendations related to `extension_id` in
// the new Web Store.
GURL GetNewWebstoreItemRecommendationsUrl(
    const extensions::ExtensionId& extension_id);

// Returns whether the URL's host matches or is in the same domain as any of the
// webstore URLs. Note: This includes any subdomains of the webstore URLs.
// TODO(crbug.com/40235977): We should move the domain checks for the webstore
// to use the IsSameOrigin version below where appropriate.
bool IsWebstoreDomain(const GURL& url);

// Returns whether the origin is the same origin as any of the webstore URLs.
bool IsWebstoreOrigin(const url::Origin& origin);

// Returns whether the URL is the webstore update URL (just considering host
// and path, not scheme, query, etc.)
bool IsWebstoreUpdateUrl(const GURL& update_url);

// Returns whether the URL is the same origin with the Webstore API URL
// (https://chromewebstore.googleapis.com/).
bool IsWebstoreApiUrl(const GURL& url);

// Returns true if the URL points to an extension blocklist.
bool IsBlocklistUpdateUrl(const GURL& url);

// Returns true if the origin points to an URL used for safebrowsing.
bool IsSafeBrowsingUrl(const GURL& url);

}  // namespace extension_urls

#endif  // EXTENSIONS_COMMON_EXTENSION_URLS_H_