resource_loader.cc 1.0 KB

1234567891011121314151617181920212223242526272829
  1. // Copyright 2021 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. #include "ash/webui/file_manager/resource_loader.h"
  5. #include "base/strings/string_util.h"
  6. namespace ash {
  7. namespace file_manager {
  8. void AddFilesAppResources(content::WebUIDataSource* source,
  9. const webui::ResourcePath* entries,
  10. size_t size) {
  11. for (size_t i = 0; i < size; ++i) {
  12. std::string path(entries[i].path);
  13. // Only load resources for Files app.
  14. if (base::StartsWith(path, "file_manager/") &&
  15. path.find("untrusted_resources/") == std::string::npos) {
  16. // Files app UI has all paths relative to //ui/file_manager/file_manager/
  17. // so we remove the leading file_manager/ to match the existing paths.
  18. base::ReplaceFirstSubstringAfterOffset(&path, 0, "file_manager/", "");
  19. source->AddResourcePath(path, entries[i].id);
  20. }
  21. }
  22. }
  23. } // namespace file_manager
  24. } // namespace ash