[email protected] | 4575961 | 2012-07-10 17:21:23 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | d8c8f25f | 2011-11-02 18:18:01 | [diff] [blame] | 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 CHROME_BROWSER_EXTENSIONS_INSTALLED_LOADER_H_ |
| 6 | #define CHROME_BROWSER_EXTENSIONS_INSTALLED_LOADER_H_ |
[email protected] | d8c8f25f | 2011-11-02 18:18:01 | [diff] [blame] | 7 | |
macourteau | 55a41a6 | 2015-05-27 00:23:16 | [diff] [blame] | 8 | #include <set> |
| 9 | |
| 10 | #include "base/files/file_path.h" |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 11 | #include "base/memory/raw_ptr.h" |
macourteau | 55a41a6 | 2015-05-27 00:23:16 | [diff] [blame] | 12 | |
[email protected] | d8c8f25f | 2011-11-02 18:18:01 | [diff] [blame] | 13 | namespace extensions { |
| 14 | |
[email protected] | 4575961 | 2012-07-10 17:21:23 | [diff] [blame] | 15 | class ExtensionPrefs; |
[email protected] | 284ffac | 2014-02-12 01:08:58 | [diff] [blame] | 16 | class ExtensionRegistry; |
Devlin Cronin | eea1b7a | 2018-05-26 02:46:21 | [diff] [blame] | 17 | class ExtensionService; |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 18 | struct ExtensionInfo; |
| 19 | |
Emilia Paz | f807e6e | 2021-07-15 03:02:02 | [diff] [blame] | 20 | // Used in histogram Extensions.HostPermissions.GrantedAccess, |
| 21 | // Extensions.HostPermissions.GrantedAccessForBroadRequests and |
| 22 | // Extensions.HostPermissions.GrantedAccessForTargetedRequests. |
Emilia Paz | b6e41bf | 2021-07-07 14:38:19 | [diff] [blame] | 23 | // Entries should not be renumbered and numeric values should never be reused. |
| 24 | // If you are adding to this enum, update HostPermissionAccess enum in |
| 25 | // tools/metrics/histograms/enums.xml. |
| 26 | enum class HostPermissionsAccess { |
| 27 | kCannotAffect = 0, |
| 28 | kNotRequested = 1, |
| 29 | kOnClick = 2, |
| 30 | kOnSpecificSites = 3, |
| 31 | kOnAllRequestedSites = 4, |
| 32 | kOnActiveTabOnly = 5, |
| 33 | kMaxValue = kOnActiveTabOnly, |
| 34 | }; |
| 35 | |
[email protected] | d8c8f25f | 2011-11-02 18:18:01 | [diff] [blame] | 36 | // Loads installed extensions from the prefs. |
| 37 | class InstalledLoader { |
| 38 | public: |
| 39 | explicit InstalledLoader(ExtensionService* extension_service); |
| 40 | virtual ~InstalledLoader(); |
| 41 | |
| 42 | // Loads extension from prefs. |
| 43 | void Load(const ExtensionInfo& info, bool write_to_prefs); |
| 44 | |
| 45 | // Loads all installed extensions (used by startup and testing code). |
| 46 | void LoadAllExtensions(); |
| 47 | |
Devlin Cronin | 9a9206e | 2018-09-28 23:39:51 | [diff] [blame] | 48 | // Allows tests to verify metrics without needing to go through |
| 49 | // LoadAllExtensions(). |
| 50 | void RecordExtensionsMetricsForTesting(); |
| 51 | |
[email protected] | d8c8f25f | 2011-11-02 18:18:01 | [diff] [blame] | 52 | private: |
| 53 | // Returns the flags that should be used with Extension::Create() for an |
| 54 | // extension that is already installed. |
| 55 | int GetCreationFlags(const ExtensionInfo* info); |
| 56 | |
rkaplow | a8fd8d3 | 2015-02-25 21:27:56 | [diff] [blame] | 57 | // Record metrics related to the loaded extensions. |
| 58 | void RecordExtensionsMetrics(); |
| 59 | |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 60 | raw_ptr<ExtensionService> extension_service_; |
| 61 | raw_ptr<ExtensionRegistry> extension_registry_; |
[email protected] | d8c8f25f | 2011-11-02 18:18:01 | [diff] [blame] | 62 | |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 63 | raw_ptr<ExtensionPrefs> extension_prefs_; |
macourteau | 55a41a6 | 2015-05-27 00:23:16 | [diff] [blame] | 64 | |
| 65 | // Paths to invalid extension manifests, which should not be loaded. |
| 66 | std::set<base::FilePath> invalid_extensions_; |
[email protected] | d8c8f25f | 2011-11-02 18:18:01 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | } // namespace extensions |
| 70 | |
| 71 | #endif // CHROME_BROWSER_EXTENSIONS_INSTALLED_LOADER_H_ |