OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
11 #endif | 11 #endif |
12 | 12 |
13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
14 | 14 |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/file_path.h" |
16 #include "base/file_util.h" | 17 #include "base/file_util.h" |
17 #include "base/logging.h" | 18 #include "base/logging.h" |
18 #include "base/path_service.h" | 19 #include "base/path_service.h" |
19 #include "base/sys_info.h" | 20 #include "base/sys_info.h" |
20 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
21 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
22 | 23 |
23 namespace chrome { | 24 namespace chrome { |
24 | 25 |
25 // Gets the default user data directory, regardless of whether | 26 // Gets the default user data directory, regardless of whether |
(...skipping 19 matching lines...) Expand all Loading... |
45 #ifndef NDEBUG | 46 #ifndef NDEBUG |
46 // for debugging, support a cmd line based override | 47 // for debugging, support a cmd line based override |
47 CommandLine command_line; | 48 CommandLine command_line; |
48 *path = command_line.GetSwitchValue(switches::kGearsPluginPathOverride); | 49 *path = command_line.GetSwitchValue(switches::kGearsPluginPathOverride); |
49 return !path->empty(); | 50 return !path->empty(); |
50 #else | 51 #else |
51 return false; | 52 return false; |
52 #endif | 53 #endif |
53 } | 54 } |
54 | 55 |
55 bool PathProvider(int key, std::wstring* result) { | 56 bool PathProvider(int key, FilePath* result) { |
56 // Some keys are just aliases... | 57 // Some keys are just aliases... |
57 switch (key) { | 58 switch (key) { |
58 case chrome::DIR_APP: | 59 case chrome::DIR_APP: |
59 return PathService::Get(base::DIR_MODULE, result); | 60 return PathService::Get(base::DIR_MODULE, result); |
60 case chrome::DIR_LOGS: | 61 case chrome::DIR_LOGS: |
61 #ifndef NDEBUG | 62 #ifndef NDEBUG |
62 return PathService::Get(chrome::DIR_USER_DATA, result); | 63 return PathService::Get(chrome::DIR_USER_DATA, result); |
63 #else | 64 #else |
64 return PathService::Get(base::DIR_EXE, result); | 65 return PathService::Get(base::DIR_EXE, result); |
65 #endif | 66 #endif |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 return false; | 255 return false; |
255 exists = true; | 256 exists = true; |
256 break; | 257 break; |
257 default: | 258 default: |
258 return false; | 259 return false; |
259 } | 260 } |
260 | 261 |
261 if (!exists && !file_util::PathExists(cur) && !file_util::CreateDirectory(cur)
) | 262 if (!exists && !file_util::PathExists(cur) && !file_util::CreateDirectory(cur)
) |
262 return false; | 263 return false; |
263 | 264 |
264 result->swap(cur); | 265 *result = FilePath::FromWStringHack(cur); |
265 return true; | 266 return true; |
266 } | 267 } |
267 | 268 |
268 // This cannot be done as a static initializer sadly since Visual Studio will | 269 // This cannot be done as a static initializer sadly since Visual Studio will |
269 // eliminate this object file if there is no direct entry point into it. | 270 // eliminate this object file if there is no direct entry point into it. |
270 void RegisterPathProvider() { | 271 void RegisterPathProvider() { |
271 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); | 272 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); |
272 } | 273 } |
273 | 274 |
274 } // namespace chrome | 275 } // namespace chrome |
275 | 276 |
OLD | NEW |