extension_paths.cc 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. // Copyright (c) 2013 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 "extensions/common/extension_paths.h"
  5. #include "base/files/file_util.h"
  6. #include "base/path_service.h"
  7. namespace extensions {
  8. bool PathProvider(int key, base::FilePath* result) {
  9. if (key != DIR_TEST_DATA)
  10. return false;
  11. base::FilePath cur;
  12. if (!base::PathService::Get(base::DIR_SOURCE_ROOT, &cur))
  13. return false;
  14. cur = cur.Append(FILE_PATH_LITERAL("extensions"));
  15. cur = cur.Append(FILE_PATH_LITERAL("test"));
  16. cur = cur.Append(FILE_PATH_LITERAL("data"));
  17. if (!base::PathExists(cur)) // we don't want to create this
  18. return false;
  19. *result = cur;
  20. return true;
  21. }
  22. // This cannot be done as a static initializer sadly since Visual Studio will
  23. // eliminate this object file if there is no direct entry point into it.
  24. void RegisterPathProvider() {
  25. base::PathService::RegisterProvider(PathProvider, PATH_START, PATH_END);
  26. }
  27. } // namespace extensions