summaryrefslogtreecommitdiff
blob: dccdff76f15d7d4ed2b2b595334bad95047025c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
https://github.com/google/mozc/issues/470

--- /src/base/system_util.cc
+++ /src/base/system_util.cc
@@ -226,6 +226,11 @@
 
 std::string UserProfileDirectoryImpl::GetUserProfileDirectory() const {
 #if defined(OS_CHROMEOS)
+  const char *configuration_directory_env = Environ::GetEnv("MOZC_CONFIGURATION_DIRECTORY");
+  if (configuration_directory_env) {
+    return configuration_directory_env;
+  }
+
   // TODO(toka): Must use passed in user profile dir which passed in. If mojo
   // platform the user profile is determined on runtime.
   // It's hack, the user profile dir should be passed in. Although the value in
@@ -245,13 +250,23 @@
 #elif defined(OS_IOS)
   // OS_IOS block must be placed before __APPLE__ because both macros are
   // currently defined on iOS.
-  //
+
+  const char *configuration_directory_env = Environ::GetEnv("MOZC_CONFIGURATION_DIRECTORY");
+  if (configuration_directory_env) {
+    return configuration_directory_env;
+  }
+
   // On iOS, use Caches directory instead of Application Spport directory
   // because the support directory doesn't exist by default.  Also, it is backed
   // up by iTunes and iCloud.
   return FileUtil::JoinPath({MacUtil::GetCachesDirectory(), kProductPrefix});
 
 #elif defined(OS_WIN)
+  const char *configuration_directory_env = Environ::GetEnv("MOZC_CONFIGURATION_DIRECTORY");
+  if (configuration_directory_env) {
+    return configuration_directory_env;
+  }
+
   DCHECK(SUCCEEDED(Singleton<LocalAppDataDirectoryCache>::get()->result()));
   std::string dir = Singleton<LocalAppDataDirectoryCache>::get()->path();
 
@@ -263,6 +278,11 @@
 
 
 #elif defined(__APPLE__)
+  const char *configuration_directory_env = Environ::GetEnv("MOZC_CONFIGURATION_DIRECTORY");
+  if (configuration_directory_env) {
+    return configuration_directory_env;
+  }
+
   std::string dir = MacUtil::GetApplicationSupportDirectory();
 # ifdef GOOGLE_JAPANESE_INPUT_BUILD
   dir = FileUtil::JoinPath(dir, "Google");
@@ -276,6 +296,11 @@
 
 
 #elif defined(OS_LINUX)
+  const char *configuration_directory_env = Environ::GetEnv("MOZC_CONFIGURATION_DIRECTORY");
+  if (configuration_directory_env) {
+    return configuration_directory_env;
+  }
+
   // 1. If "$HOME/.mozc" already exists,
   //    use "$HOME/.mozc" for backward compatibility.
   // 2. If $XDG_CONFIG_HOME is defined
@@ -395,6 +420,11 @@
 #endif  // OS_WIN
 
 std::string SystemUtil::GetServerDirectory() {
+  const char *server_directory_env = Environ::GetEnv("MOZC_SERVER_DIRECTORY");
+  if (server_directory_env) {
+    return server_directory_env;
+  }
+
 #ifdef OS_WIN
   DCHECK(SUCCEEDED(Singleton<ProgramFilesX86Cache>::get()->result()));
 # if defined(GOOGLE_JAPANESE_INPUT_BUILD)
@@ -453,6 +483,11 @@
 }
 
 std::string SystemUtil::GetDocumentDirectory() {
+  const char *documents_directory_env = Environ::GetEnv("MOZC_DOCUMENTS_DIRECTORY");
+  if (documents_directory_env) {
+    return documents_directory_env;
+  }
+
 #if defined(__APPLE__)
   return GetServerDirectory();
 #elif defined(MOZC_DOCUMENT_DIRECTORY)