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 CEF_LIBCEF_BROWSER_EXTENSIONS_COMPONENT_EXTENSION_RESOURCE_MANAGER_H_ 6 #define CEF_LIBCEF_BROWSER_EXTENSIONS_COMPONENT_EXTENSION_RESOURCE_MANAGER_H_ 7 8 #include <map> 9 10 #include "base/files/file_path.h" 11 #include "extensions/browser/component_extension_resource_manager.h" 12 13 namespace webui { 14 struct ResourcePath; 15 } 16 17 namespace extensions { 18 19 class CefComponentExtensionResourceManager 20 : public ComponentExtensionResourceManager { 21 public: 22 CefComponentExtensionResourceManager(); 23 24 CefComponentExtensionResourceManager( 25 const CefComponentExtensionResourceManager&) = delete; 26 CefComponentExtensionResourceManager& operator=( 27 const CefComponentExtensionResourceManager&) = delete; 28 29 ~CefComponentExtensionResourceManager() override; 30 31 // Overridden from ComponentExtensionResourceManager: 32 bool IsComponentExtensionResource(const base::FilePath& extension_path, 33 const base::FilePath& resource_path, 34 int* resource_id) const override; 35 const ui::TemplateReplacements* GetTemplateReplacementsForExtension( 36 const std::string& extension_id) const override; 37 38 private: 39 void AddComponentResourceEntries(const webui::ResourcePath* entries, 40 size_t size); 41 42 // A map from a resource path to the resource ID. Used by 43 // IsComponentExtensionResource. 44 std::map<base::FilePath, int> path_to_resource_info_; 45 46 // A map from an extension ID to its i18n template replacements. 47 using TemplateReplacementMap = 48 std::map<std::string, ui::TemplateReplacements>; 49 TemplateReplacementMap template_replacements_; 50 }; 51 52 } // namespace extensions 53 54 #endif // CEF_LIBCEF_BROWSER_EXTENSIONS_COMPONENT_EXTENSION_RESOURCE_MANAGER_H_ 55