blob: a24eae01fe47df49ae05cf901e7db3d921033f2d [file] [log] [blame]
[email protected]45759612012-07-10 17:21:231// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]d8c8f25f2011-11-02 18:18:012// 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]d8c8f25f2011-11-02 18:18:017
macourteau55a41a62015-05-27 00:23:168#include <set>
9
10#include "base/files/file_path.h"
Keishi Hattori0e45c022021-11-27 09:25:5211#include "base/memory/raw_ptr.h"
macourteau55a41a62015-05-27 00:23:1612
[email protected]d8c8f25f2011-11-02 18:18:0113namespace extensions {
14
[email protected]45759612012-07-10 17:21:2315class ExtensionPrefs;
[email protected]284ffac2014-02-12 01:08:5816class ExtensionRegistry;
Devlin Cronineea1b7a2018-05-26 02:46:2117class ExtensionService;
[email protected]1c321ee2012-05-21 03:02:3418struct ExtensionInfo;
19
Emilia Pazf807e6e2021-07-15 03:02:0220// Used in histogram Extensions.HostPermissions.GrantedAccess,
21// Extensions.HostPermissions.GrantedAccessForBroadRequests and
22// Extensions.HostPermissions.GrantedAccessForTargetedRequests.
Emilia Pazb6e41bf2021-07-07 14:38:1923// 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.
26enum 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]d8c8f25f2011-11-02 18:18:0136// Loads installed extensions from the prefs.
37class 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 Cronin9a9206e2018-09-28 23:39:5148 // Allows tests to verify metrics without needing to go through
49 // LoadAllExtensions().
50 void RecordExtensionsMetricsForTesting();
51
[email protected]d8c8f25f2011-11-02 18:18:0152 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
rkaplowa8fd8d32015-02-25 21:27:5657 // Record metrics related to the loaded extensions.
58 void RecordExtensionsMetrics();
59
Keishi Hattori0e45c022021-11-27 09:25:5260 raw_ptr<ExtensionService> extension_service_;
61 raw_ptr<ExtensionRegistry> extension_registry_;
[email protected]d8c8f25f2011-11-02 18:18:0162
Keishi Hattori0e45c022021-11-27 09:25:5263 raw_ptr<ExtensionPrefs> extension_prefs_;
macourteau55a41a62015-05-27 00:23:1664
65 // Paths to invalid extension manifests, which should not be loaded.
66 std::set<base::FilePath> invalid_extensions_;
[email protected]d8c8f25f2011-11-02 18:18:0167};
68
69} // namespace extensions
70
71#endif // CHROME_BROWSER_EXTENSIONS_INSTALLED_LOADER_H_