OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/common/content_paths.h" | 5 #include "content/common/content_paths.h" |
6 | 6 |
| 7 #include "base/file_util.h" |
7 #include "base/path_service.h" | 8 #include "base/path_service.h" |
8 | 9 |
9 namespace content { | 10 namespace content { |
10 | 11 |
11 bool PathProvider(int key, FilePath* result) { | 12 bool PathProvider(int key, FilePath* result) { |
12 switch (key) { | 13 switch (key) { |
13 case CHILD_PROCESS_EXE: | 14 case CHILD_PROCESS_EXE: |
14 return PathService::Get(base::FILE_EXE, result); | 15 return PathService::Get(base::FILE_EXE, result); |
| 16 case DIR_TEST_DATA: { |
| 17 FilePath cur; |
| 18 if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) |
| 19 return false; |
| 20 cur = cur.Append(FILE_PATH_LITERAL("content")); |
| 21 cur = cur.Append(FILE_PATH_LITERAL("test")); |
| 22 cur = cur.Append(FILE_PATH_LITERAL("data")); |
| 23 if (!file_util::PathExists(cur)) // we don't want to create this |
| 24 return false; |
| 25 |
| 26 *result = cur; |
| 27 return true; |
| 28 break; |
| 29 } |
15 default: | 30 default: |
16 break; | 31 return false; |
17 } | 32 } |
18 | 33 |
19 return false; | 34 return false; |
20 } | 35 } |
21 | 36 |
22 // This cannot be done as a static initializer sadly since Visual Studio will | 37 // 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. | 38 // eliminate this object file if there is no direct entry point into it. |
24 void RegisterPathProvider() { | 39 void RegisterPathProvider() { |
25 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); | 40 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); |
26 } | 41 } |
27 | 42 |
28 } // namespace content | 43 } // namespace content |
OLD | NEW |