Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Side by Side Diff: app/app_paths.cc

Issue 6263008: Move ResourceBundle, DataPack to ui/base (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « app/app_paths.h ('k') | app/app_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "app/app_paths.h" 5 #include "app/app_paths.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 12
13 namespace app { 13 namespace app {
14 14
15 bool PathProvider(int key, FilePath* result) { 15 bool PathProvider(int key, FilePath* result) {
16 // Assume that we will not need to create the directory if it does not exist. 16 // Assume that we will not need to create the directory if it does not exist.
17 // This flag can be set to true for the cases where we want to create it. 17 // This flag can be set to true for the cases where we want to create it.
18 bool create_dir = false; 18 bool create_dir = false;
19 19
20 FilePath cur; 20 FilePath cur;
21 switch (key) { 21 switch (key) {
22 case app::DIR_LOCALES:
23 if (!PathService::Get(base::DIR_MODULE, &cur))
24 return false;
25 #if defined(OS_MACOSX)
26 // On Mac, locale files are in Contents/Resources, a sibling of the
27 // App dir.
28 cur = cur.DirName();
29 cur = cur.Append(FILE_PATH_LITERAL("Resources"));
30 #else
31 cur = cur.Append(FILE_PATH_LITERAL("locales"));
32 #endif
33 create_dir = true;
34 break;
35 case app::DIR_EXTERNAL_EXTENSIONS: 22 case app::DIR_EXTERNAL_EXTENSIONS:
36 if (!PathService::Get(base::DIR_MODULE, &cur)) 23 if (!PathService::Get(base::DIR_MODULE, &cur))
37 return false; 24 return false;
38 #if defined(OS_MACOSX) 25 #if defined(OS_MACOSX)
39 // On Mac, built-in extensions are in Contents/Extensions, a sibling of 26 // On Mac, built-in extensions are in Contents/Extensions, a sibling of
40 // the App dir. If there are none, it may not exist. 27 // the App dir. If there are none, it may not exist.
41 cur = cur.DirName(); 28 cur = cur.DirName();
42 cur = cur.Append(FILE_PATH_LITERAL("Extensions")); 29 cur = cur.Append(FILE_PATH_LITERAL("Extensions"));
43 create_dir = false; 30 create_dir = false;
44 #else 31 #else
45 cur = cur.Append(FILE_PATH_LITERAL("extensions")); 32 cur = cur.Append(FILE_PATH_LITERAL("extensions"));
46 create_dir = true; 33 create_dir = true;
47 #endif 34 #endif
48 break; 35 break;
49 case app::FILE_RESOURCES_PAK:
50 #if defined(OS_POSIX) && !defined(OS_MACOSX)
51 if (!PathService::Get(base::DIR_EXE, &cur))
52 return false;
53 // TODO(tony): We shouldn't be referencing chrome here.
54 cur = cur.AppendASCII("chrome.pak");
55 #else
56 NOTREACHED();
57 #endif
58 break;
59 // The following are only valid in the development environment, and
60 // will fail if executed from an installed executable (because the
61 // generated path won't exist).
62 case app::DIR_TEST_DATA:
63 if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur))
64 return false;
65 cur = cur.Append(FILE_PATH_LITERAL("app"));
66 cur = cur.Append(FILE_PATH_LITERAL("test"));
67 cur = cur.Append(FILE_PATH_LITERAL("data"));
68 if (!file_util::PathExists(cur)) // we don't want to create this
69 return false;
70 break;
71 default: 36 default:
72 return false; 37 return false;
73 } 38 }
74 39
75 if (create_dir && !file_util::PathExists(cur) && 40 if (create_dir && !file_util::PathExists(cur) &&
76 !file_util::CreateDirectory(cur)) 41 !file_util::CreateDirectory(cur))
77 return false; 42 return false;
78 43
79 *result = cur; 44 *result = cur;
80 return true; 45 return true;
81 } 46 }
82 47
83 // This cannot be done as a static initializer sadly since Visual Studio will 48 // This cannot be done as a static initializer sadly since Visual Studio will
84 // eliminate this object file if there is no direct entry point into it. 49 // eliminate this object file if there is no direct entry point into it.
85 void RegisterPathProvider() { 50 void RegisterPathProvider() {
86 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); 51 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END);
87 } 52 }
88 53
89 } // namespace app 54 } // namespace app
OLDNEW
« no previous file with comments | « app/app_paths.h ('k') | app/app_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698