[email protected] | 411f8ae | 2014-05-22 11:12:23 | [diff] [blame] | 1 | // Copyright 2014 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. |
| 4 | |
| 5 | #ifndef EXTENSIONS_BROWSER_EXTENSION_UTIL_H_ |
| 6 | #define EXTENSIONS_BROWSER_EXTENSION_UTIL_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
Michael Giuffrida | 7efeed14 | 2017-06-07 06:29:21 | [diff] [blame] | 10 | #include "url/gurl.h" |
tfarina | 01710e3 | 2015-07-13 21:53:22 | [diff] [blame] | 11 | |
Clark DuVall | e2bdd33 | 2019-08-07 18:32:13 | [diff] [blame] | 12 | namespace base { |
| 13 | class FilePath; |
| 14 | } |
| 15 | |
[email protected] | 411f8ae | 2014-05-22 11:12:23 | [diff] [blame] | 16 | namespace content { |
| 17 | class BrowserContext; |
lazyboy | 4c82177a | 2016-10-18 00:04:09 | [diff] [blame] | 18 | class StoragePartition; |
[email protected] | 411f8ae | 2014-05-22 11:12:23 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | namespace extensions { |
kundaji | e548e744 | 2015-09-18 23:19:09 | [diff] [blame] | 22 | class Extension; |
Clark DuVall | e2bdd33 | 2019-08-07 18:32:13 | [diff] [blame] | 23 | class ExtensionSet; |
tfarina | 01710e3 | 2015-07-13 21:53:22 | [diff] [blame] | 24 | |
[email protected] | 411f8ae | 2014-05-22 11:12:23 | [diff] [blame] | 25 | namespace util { |
| 26 | |
benwells | 1dd4acd | 2015-12-09 02:20:24 | [diff] [blame] | 27 | // TODO(benwells): Move functions from |
tfarina | 01710e3 | 2015-07-13 21:53:22 | [diff] [blame] | 28 | // chrome/browser/extensions/extension_util.h/cc that are only dependent on |
| 29 | // extensions/ here. |
[email protected] | 411f8ae | 2014-05-22 11:12:23 | [diff] [blame] | 30 | |
kundaji | e548e744 | 2015-09-18 23:19:09 | [diff] [blame] | 31 | // Returns true if the extension can be enabled in incognito mode. |
| 32 | bool CanBeIncognitoEnabled(const Extension* extension); |
| 33 | |
karandeepb | 810e3340 | 2017-04-05 23:41:22 | [diff] [blame] | 34 | // Returns true if |extension_id| can run in an incognito window. |
| 35 | bool IsIncognitoEnabled(const std::string& extension_id, |
| 36 | content::BrowserContext* context); |
| 37 | |
Clark DuVall | 1d81619 | 2019-07-19 19:54:42 | [diff] [blame] | 38 | // Returns true if |extension| can see events and data from another sub-profile |
| 39 | // (incognito to original profile, or vice versa). |
| 40 | bool CanCrossIncognito(const extensions::Extension* extension, |
| 41 | content::BrowserContext* context); |
| 42 | |
Michael Giuffrida | 7efeed14 | 2017-06-07 06:29:21 | [diff] [blame] | 43 | // Returns the site of the |extension_id|, given the associated |context|. |
| 44 | // Suitable for use with BrowserContext::GetStoragePartitionForSite(). |
| 45 | GURL GetSiteForExtensionId(const std::string& extension_id, |
| 46 | content::BrowserContext* context); |
| 47 | |
lazyboy | 4c82177a | 2016-10-18 00:04:09 | [diff] [blame] | 48 | content::StoragePartition* GetStoragePartitionForExtensionId( |
| 49 | const std::string& extension_id, |
| 50 | content::BrowserContext* browser_context); |
| 51 | |
Clark DuVall | e2bdd33 | 2019-08-07 18:32:13 | [diff] [blame] | 52 | // Maps a |file_url| to a |file_path| on the local filesystem, including |
| 53 | // resources in extensions. Returns true on success. See NaClBrowserDelegate for |
| 54 | // full details. If |use_blocking_api| is false, only a subset of URLs will be |
| 55 | // handled. If |use_blocking_api| is true, blocking file operations may be used, |
| 56 | // and this must be called on threads that allow blocking. Otherwise this can be |
| 57 | // called on any thread. |
| 58 | bool MapUrlToLocalFilePath(const ExtensionSet* extensions, |
| 59 | const GURL& file_url, |
| 60 | bool use_blocking_api, |
| 61 | base::FilePath* file_path); |
| 62 | |
[email protected] | 411f8ae | 2014-05-22 11:12:23 | [diff] [blame] | 63 | } // namespace util |
| 64 | } // namespace extensions |
| 65 | |
| 66 | #endif // EXTENSIONS_BROWSER_EXTENSION_UTIL_H_ |