base::Time multiplicative operator overloading
[chromium-blink-merge.git] / chrome / browser / extensions / extension_util.h
blob49fa599c9055935b265579e883c055b0d637d423
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 namespace extensions {
27 class Extension;
28 struct ExtensionInfo;
29 class PermissionSet;
31 namespace util {
33 // Returns true if |extension_id| can run in an incognito window.
34 bool IsIncognitoEnabled(const std::string& extension_id,
35 content::BrowserContext* context);
37 // Sets whether |extension_id| can run in an incognito window. Reloads the
38 // extension if it's enabled since this permission is applied at loading time
39 // only. Note that an ExtensionService must exist.
40 void SetIsIncognitoEnabled(const std::string& extension_id,
41 content::BrowserContext* context,
42 bool enabled);
44 // Returns true if |extension| can see events and data from another sub-profile
45 // (incognito to original profile, or vice versa).
46 bool CanCrossIncognito(const extensions::Extension* extension,
47 content::BrowserContext* context);
49 // Returns true if |extension| can be loaded in incognito.
50 bool CanLoadInIncognito(const extensions::Extension* extension,
51 content::BrowserContext* context);
53 // Returns true if this extension can inject scripts into pages with file URLs.
54 bool AllowFileAccess(const std::string& extension_id,
55 content::BrowserContext* context);
57 // Sets whether |extension_id| can inject scripts into pages with file URLs.
58 // Reloads the extension if it's enabled since this permission is applied at
59 // loading time only. Note than an ExtensionService must exist.
60 void SetAllowFileAccess(const std::string& extension_id,
61 content::BrowserContext* context,
62 bool allow);
64 // Returns true if the extension with |extension_id| is allowed to execute
65 // scripts on all urls (exempting chrome:// urls, etc) without explicit
66 // user consent.
67 // This should only be used with FeatureSwitch::scripts_require_action()
68 // enabled.
69 bool AllowedScriptingOnAllUrls(const std::string& extension_id,
70 content::BrowserContext* context);
72 // Returns the default value for being allowed to script on all urls.
73 bool DefaultAllowedScriptingOnAllUrls();
75 // Sets whether the extension with |extension_id| is allowed to execute scripts
76 // on all urls (exempting chrome:// urls, etc) without explicit user consent.
77 // This should only be used with FeatureSwitch::scripts_require_action()
78 // enabled.
79 void SetAllowedScriptingOnAllUrls(const std::string& extension_id,
80 content::BrowserContext* context,
81 bool allowed);
83 // Returns true if the user has set an explicit preference for the specified
84 // extension being allowed to script on all urls; this is set to be true
85 // whenever SetAllowedScriptingOnAllUrls() is called.
86 bool HasSetAllowedScriptingOnAllUrls(const std::string& extension_id,
87 content::BrowserContext* context);
89 // Returns true if |extension_id| can be launched (possibly only after being
90 // enabled).
91 bool IsAppLaunchable(const std::string& extension_id,
92 content::BrowserContext* context);
94 // Returns true if |extension_id| can be launched without being enabled first.
95 bool IsAppLaunchableWithoutEnabling(const std::string& extension_id,
96 content::BrowserContext* context);
98 // Returns true if |extension| should be synced.
99 bool ShouldSyncExtension(const Extension* extension,
100 content::BrowserContext* context);
102 // Returns true if |app| should be synced.
103 bool ShouldSyncApp(const Extension* app, content::BrowserContext* context);
105 // Returns true if |extension_id| is idle and it is safe to perform actions such
106 // as updating.
107 bool IsExtensionIdle(const std::string& extension_id,
108 content::BrowserContext* context);
110 // Returns the site of the |extension_id|, given the associated |context|.
111 // Suitable for use with BrowserContext::GetStoragePartitionForSite().
112 GURL GetSiteForExtensionId(const std::string& extension_id,
113 content::BrowserContext* context);
115 // Sets the name, id, and icon resource path of the given extension into the
116 // returned dictionary.
117 scoped_ptr<base::DictionaryValue> GetExtensionInfo(const Extension* extension);
119 // Returns true if the extension has isolated storage.
120 bool HasIsolatedStorage(const ExtensionInfo& info);
122 // Returns true if the site URL corresponds to an extension or app and has
123 // isolated storage.
124 bool SiteHasIsolatedStorage(const GURL& extension_site_url,
125 content::BrowserContext* context);
127 // Returns the default extension/app icon (for extensions or apps that don't
128 // have one).
129 const gfx::ImageSkia& GetDefaultExtensionIcon();
130 const gfx::ImageSkia& GetDefaultAppIcon();
132 // Returns true if the bookmark apps feature is enabled.
134 // TODO(benwells): http://crbug.com/441128: Remove this entirely once the
135 // feature is stable.
136 bool IsNewBookmarkAppsEnabled();
138 } // namespace util
139 } // namespace extensions
141 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UTIL_H_