|
| 1 | +diff --git a/chrome/browser/extensions/browseros_extension_constants.h b/chrome/browser/extensions/browseros_extension_constants.h |
| 2 | +new file mode 100644 |
| 3 | +index 0000000000000..5a3b518b224a7 |
| 4 | +--- /dev/null |
| 5 | ++++ b/chrome/browser/extensions/browseros_extension_constants.h |
| 6 | +@@ -0,0 +1,120 @@ |
| 7 | ++// Copyright 2024 The Chromium Authors |
| 8 | ++// Use of this source code is governed by a BSD-style license that can be |
| 9 | ++// found in the LICENSE file. |
| 10 | ++ |
| 11 | ++#ifndef CHROME_BROWSER_EXTENSIONS_BROWSEROS_EXTENSION_CONSTANTS_H_ |
| 12 | ++#define CHROME_BROWSER_EXTENSIONS_BROWSEROS_EXTENSION_CONSTANTS_H_ |
| 13 | ++ |
| 14 | ++#include <cstddef> |
| 15 | ++#include <optional> |
| 16 | ++#include <string> |
| 17 | ++#include <vector> |
| 18 | ++ |
| 19 | ++namespace extensions { |
| 20 | ++namespace browseros { |
| 21 | ++ |
| 22 | ++// AI Agent Extension ID |
| 23 | ++inline constexpr char kAISidePanelExtensionId[] = |
| 24 | ++ "djhdjhlnljbjgejbndockeedocneiaei"; |
| 25 | ++ |
| 26 | ++// Agent V2 Extension ID |
| 27 | ++inline constexpr char kAgentV2ExtensionId[] = |
| 28 | ++ "bflpfmnmnokmjhmgnolecpppdbdophmk"; |
| 29 | ++ |
| 30 | ++// BrowserOS extension config URLs |
| 31 | ++inline constexpr char kBrowserOSConfigUrl[] = |
| 32 | ++ "https://cdn.browseros.com/extensions/extensions.json"; |
| 33 | ++inline constexpr char kBrowserOSAlphaConfigUrl[] = |
| 34 | ++ "https://cdn.browseros.com/extensions/extensions.alpha.json"; |
| 35 | ++ |
| 36 | ++// Bug Reporter Extension ID |
| 37 | ++inline constexpr char kBugReporterExtensionId[] = |
| 38 | ++ "adlpneommgkgeanpaekgoaolcpncohkf"; |
| 39 | ++ |
| 40 | ++// Controller Extension ID |
| 41 | ++inline constexpr char kControllerExtensionId[] = |
| 42 | ++ "nlnihljpboknmfagkikhkdblbedophja"; |
| 43 | ++ |
| 44 | ++// BrowserOS CDN update manifest URL |
| 45 | ++// Used for extensions installed from local .crx files that don't have |
| 46 | ++// an update_url in their manifest |
| 47 | ++inline constexpr char kBrowserOSUpdateUrl[] = |
| 48 | ++ "https://cdn.browseros.com/extensions/update-manifest.xml"; |
| 49 | ++ |
| 50 | ++struct BrowserOSExtensionInfo { |
| 51 | ++ const char* id; |
| 52 | ++ const char* display_name; |
| 53 | ++ bool is_pinned; |
| 54 | ++ bool is_labelled; |
| 55 | ++}; |
| 56 | ++ |
| 57 | ++inline constexpr BrowserOSExtensionInfo kBrowserOSExtensions[] = { |
| 58 | ++ {kAISidePanelExtensionId, "BrowserOS", true, true}, |
| 59 | ++ {kBugReporterExtensionId, "BrowserOS/bug-reporter", true, false}, |
| 60 | ++ {kControllerExtensionId, "BrowserOS/controller", false, false}, |
| 61 | ++ {kAgentV2ExtensionId, "BrowserOS", true, true}, |
| 62 | ++}; |
| 63 | ++ |
| 64 | ++// Allowlist of BrowserOS extension IDs that are permitted to be installed. |
| 65 | ++// Only extensions with these IDs will be loaded from the config. |
| 66 | ++inline constexpr const char* kAllowedExtensions[] = { |
| 67 | ++ kBrowserOSExtensions[0].id, |
| 68 | ++ kBrowserOSExtensions[1].id, |
| 69 | ++ kBrowserOSExtensions[2].id, |
| 70 | ++ kBrowserOSExtensions[3].id, |
| 71 | ++}; |
| 72 | ++ |
| 73 | ++inline constexpr size_t kBrowserOSExtensionsCount = |
| 74 | ++ sizeof(kBrowserOSExtensions) / sizeof(kBrowserOSExtensions[0]); |
| 75 | ++ |
| 76 | ++inline const BrowserOSExtensionInfo* FindBrowserOSExtensionInfo( |
| 77 | ++ const std::string& extension_id) { |
| 78 | ++ for (const auto& info : kBrowserOSExtensions) { |
| 79 | ++ if (extension_id == info.id) |
| 80 | ++ return &info; |
| 81 | ++ } |
| 82 | ++ return nullptr; |
| 83 | ++} |
| 84 | ++ |
| 85 | ++// Check if an extension is a BrowserOS extension |
| 86 | ++inline bool IsBrowserOSExtension(const std::string& extension_id) { |
| 87 | ++ return FindBrowserOSExtensionInfo(extension_id) != nullptr; |
| 88 | ++} |
| 89 | ++ |
| 90 | ++inline bool IsBrowserOSPinnedExtension(const std::string& extension_id) { |
| 91 | ++ const BrowserOSExtensionInfo* info = |
| 92 | ++ FindBrowserOSExtensionInfo(extension_id); |
| 93 | ++ return info && info->is_pinned; |
| 94 | ++} |
| 95 | ++ |
| 96 | ++inline bool IsBrowserOSLabelledExtension(const std::string& extension_id) { |
| 97 | ++ const BrowserOSExtensionInfo* info = |
| 98 | ++ FindBrowserOSExtensionInfo(extension_id); |
| 99 | ++ return info && info->is_labelled; |
| 100 | ++} |
| 101 | ++ |
| 102 | ++// Get all BrowserOS extension IDs |
| 103 | ++inline std::vector<std::string> GetBrowserOSExtensionIds() { |
| 104 | ++ std::vector<std::string> ids; |
| 105 | ++ ids.reserve(kBrowserOSExtensionsCount); |
| 106 | ++ for (const auto& info : kBrowserOSExtensions) |
| 107 | ++ ids.push_back(info.id); |
| 108 | ++ return ids; |
| 109 | ++} |
| 110 | ++ |
| 111 | ++// Get display name for BrowserOS extensions in omnibox |
| 112 | ++// Returns the display name if extension_id is a BrowserOS extension, |
| 113 | ++// otherwise returns std::nullopt |
| 114 | ++inline std::optional<std::string> GetExtensionDisplayName( |
| 115 | ++ const std::string& extension_id) { |
| 116 | ++ if (const BrowserOSExtensionInfo* info = |
| 117 | ++ FindBrowserOSExtensionInfo(extension_id)) { |
| 118 | ++ return info->display_name; |
| 119 | ++ } |
| 120 | ++ return std::nullopt; |
| 121 | ++} |
| 122 | ++ |
| 123 | ++} // namespace browseros |
| 124 | ++} // namespace extensions |
| 125 | ++ |
| 126 | ++#endif // CHROME_BROWSER_EXTENSIONS_BROWSEROS_EXTENSION_CONSTANTS_H_ |
0 commit comments