Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / extensions / extension_util.h
blobaa8f613d3ecc98891623d21bf27c8d4c3df09315
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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_UTIL_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_UTIL_H_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "url/gurl.h"
13 namespace base {
14 class DictionaryValue;
17 namespace content {
18 class BrowserContext;
21 namespace gfx {
22 class ImageSkia;
25 class Profile;
27 namespace extensions {
29 class Extension;
30 struct ExtensionInfo;
31 class PermissionSet;
33 namespace util {
35 // Returns true if |extension_id| can run in an incognito window.
36 bool IsIncognitoEnabled(const std::string& extension_id,
37 content::BrowserContext* context);
39 // Sets whether |extension_id| can run in an incognito window. Reloads the
40 // extension if it's enabled since this permission is applied at loading time
41 // only. Note that an ExtensionService must exist.
42 void SetIsIncognitoEnabled(const std::string& extension_id,
43 content::BrowserContext* context,
44 bool enabled);
46 // Returns true if |extension| can see events and data from another sub-profile
47 // (incognito to original profile, or vice versa).
48 bool CanCrossIncognito(const extensions::Extension* extension,
49 content::BrowserContext* context);
51 // Returns true if |extension| can be loaded in incognito.
52 bool CanLoadInIncognito(const extensions::Extension* extension,
53 content::BrowserContext* context);
55 // Returns true if this extension can inject scripts into pages with file URLs.
56 bool AllowFileAccess(const std::string& extension_id,
57 content::BrowserContext* context);
59 // Sets whether |extension_id| can inject scripts into pages with file URLs.
60 // Reloads the extension if it's enabled since this permission is applied at
61 // loading time only. Note than an ExtensionService must exist.
62 void SetAllowFileAccess(const std::string& extension_id,
63 content::BrowserContext* context,
64 bool allow);
66 // Returns true if the extension with |extension_id| is allowed to execute
67 // scripts on all urls (exempting chrome:// urls, etc) without explicit
68 // user consent.
69 // This should only be used with FeatureSwitch::scripts_require_action()
70 // enabled.
71 bool AllowedScriptingOnAllUrls(const std::string& extension_id,
72 content::BrowserContext* context);
74 // Returns the default value for being allowed to script on all urls.
75 bool DefaultAllowedScriptingOnAllUrls();
77 // Sets whether the extension with |extension_id| is allowed to execute scripts
78 // on all urls (exempting chrome:// urls, etc) without explicit user consent.
79 // This should only be used with FeatureSwitch::scripts_require_action()
80 // enabled.
81 void SetAllowedScriptingOnAllUrls(const std::string& extension_id,
82 content::BrowserContext* context,
83 bool allowed);
85 // Returns true if the user has set an explicit preference for the specified
86 // extension being allowed to script on all urls; this is set to be true
87 // whenever SetAllowedScriptingOnAllUrls() is called.
88 bool HasSetAllowedScriptingOnAllUrls(const std::string& extension_id,
89 content::BrowserContext* context);
91 // Returns true if |extension_id| can be launched (possibly only after being
92 // enabled).
93 bool IsAppLaunchable(const std::string& extension_id,
94 content::BrowserContext* context);
96 // Returns true if |extension_id| can be launched without being enabled first.
97 bool IsAppLaunchableWithoutEnabling(const std::string& extension_id,
98 content::BrowserContext* context);
100 // Returns true if |extension| should be synced.
101 bool ShouldSync(const Extension* extension, content::BrowserContext* context);
103 // Returns true if |extension_id| is idle and it is safe to perform actions such
104 // as updating.
105 bool IsExtensionIdle(const std::string& extension_id,
106 content::BrowserContext* context);
108 // Returns the site of the |extension_id|, given the associated |context|.
109 // Suitable for use with BrowserContext::GetStoragePartitionForSite().
110 GURL GetSiteForExtensionId(const std::string& extension_id,
111 content::BrowserContext* context);
113 // Sets the name, id, and icon resource path of the given extension into the
114 // returned dictionary.
115 scoped_ptr<base::DictionaryValue> GetExtensionInfo(const Extension* extension);
117 // Returns the default extension/app icon (for extensions or apps that don't
118 // have one).
119 const gfx::ImageSkia& GetDefaultExtensionIcon();
120 const gfx::ImageSkia& GetDefaultAppIcon();
122 // Returns true if the bookmark apps feature is enabled.
124 // TODO(benwells): http://crbug.com/441128: Remove this entirely once the
125 // feature is stable.
126 bool IsNewBookmarkAppsEnabled();
128 // TODO(dominickn): http://crbug.com/517682: Remove this entirely once
129 // open in window is stable on Mac.
130 bool CanHostedAppsOpenInWindows();
132 // Returns true for custodian-installed extensions in a supervised profile.
133 bool IsExtensionSupervised(const Extension* extension, Profile* profile);
135 // Returns true if supervised users need approval from their custodian for
136 // approving escalated permissions on updated extensions.
137 bool NeedCustodianApprovalForPermissionIncrease();
139 } // namespace util
140 } // namespace extensions
142 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UTIL_H_