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_
10 #include "base/memory/scoped_ptr.h"
14 class DictionaryValue
;
27 namespace extensions
{
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
,
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
,
66 // Returns true if the extension with |extension_id| is allowed to execute
67 // scripts on all urls (exempting chrome:// urls, etc) without explicit
69 // This should only be used with FeatureSwitch::scripts_require_action()
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()
81 void SetAllowedScriptingOnAllUrls(const std::string
& extension_id
,
82 content::BrowserContext
* context
,
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
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
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
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();
140 } // namespace extensions
142 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UTIL_H_