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;
25 namespace extensions {
32 // Returns true if |extension_id| can run in an incognito window.
33 bool IsIncognitoEnabled(const std::string& extension_id,
34 content::BrowserContext* context);
36 // Sets whether |extension_id| can run in an incognito window. Reloads the
37 // extension if it's enabled since this permission is applied at loading time
38 // only. Note that an ExtensionService must exist.
39 void SetIsIncognitoEnabled(const std::string& extension_id,
40 content::BrowserContext* context,
43 // Returns true if |extension| can see events and data from another sub-profile
44 // (incognito to original profile, or vice versa).
45 bool CanCrossIncognito(const extensions::Extension* extension,
46 content::BrowserContext* context);
48 // Returns true if |extension| can be loaded in incognito.
49 bool CanLoadInIncognito(const extensions::Extension* extension,
50 content::BrowserContext* context);
52 // Returns true if this extension can inject scripts into pages with file URLs.
53 bool AllowFileAccess(const std::string& extension_id,
54 content::BrowserContext* context);
56 // Sets whether |extension_id| can inject scripts into pages with file URLs.
57 // Reloads the extension if it's enabled since this permission is applied at
58 // loading time only. Note than an ExtensionService must exist.
59 void SetAllowFileAccess(const std::string& extension_id,
60 content::BrowserContext* context,
63 // Returns true if |extension_id| can be launched (possibly only after being
65 bool IsAppLaunchable(const std::string& extension_id,
66 content::BrowserContext* context);
68 // Returns true if |extension_id| can be launched without being enabled first.
69 bool IsAppLaunchableWithoutEnabling(const std::string& extension_id,
70 content::BrowserContext* context);
72 // Returns true if |extension_id| is idle and it is safe to perform actions such
74 bool IsExtensionIdle(const std::string& extension_id,
75 content::BrowserContext* context);
77 // Returns true if |extension_id| is installed permanently and not ephemerally.
78 bool IsExtensionInstalledPermanently(const std::string& extension_id,
79 content::BrowserContext* context);
81 // Returns the site of the |extension_id|, given the associated |context|.
82 // Suitable for use with BrowserContext::GetStoragePartitionForSite().
83 GURL GetSiteForExtensionId(const std::string& extension_id,
84 content::BrowserContext* context);
86 // Sets the name, id, and icon resource path of the given extension into the
87 // returned dictionary.
88 scoped_ptr<base::DictionaryValue> GetExtensionInfo(const Extension* extension);
90 // Returns true if the extension has isolated storage.
91 bool HasIsolatedStorage(const ExtensionInfo& info);
93 // Returns true if the site URL corresponds to an extension or app and has
95 bool SiteHasIsolatedStorage(const GURL& extension_site_url,
96 content::BrowserContext* context);
98 // Returns the default extension/app icon (for extensions or apps that don't
100 const gfx::ImageSkia& GetDefaultExtensionIcon();
101 const gfx::ImageSkia& GetDefaultAppIcon();
104 } // namespace extensions
106 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UTIL_H_