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

Side by Side Diff: base/base_paths_android.cc

Issue 10910209: Add new PathService paths for Windows' All Users Desktop and Quick Launch folders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adjust links to pass presubmit Created 8 years, 3 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 | « base/base_paths_android.h ('k') | base/base_paths_mac.mm » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/base_paths.h" 5 // Defines base::PathProviderAndroid which replaces base::PathProviderPosix for
6 // Android in base/path_service.cc.
6 7
7 #include <unistd.h> 8 #include <unistd.h>
8 9
9 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
10 #include "base/android/path_utils.h" 11 #include "base/android/path_utils.h"
12 #include "base/base_paths.h"
11 #include "base/file_path.h" 13 #include "base/file_path.h"
12 #include "base/file_util.h" 14 #include "base/file_util.h"
13 #include "base/logging.h" 15 #include "base/logging.h"
14 #include "base/process_util.h" 16 #include "base/process_util.h"
15 17
16 namespace base { 18 namespace base {
17 19
18 bool PathProviderAndroid(int key, FilePath* result) { 20 bool PathProviderAndroid(int key, FilePath* result) {
19 switch (key) { 21 switch (key) {
20 case base::FILE_EXE: { 22 case base::FILE_EXE: {
21 char bin_dir[PATH_MAX + 1]; 23 char bin_dir[PATH_MAX + 1];
22 int bin_dir_size = readlink(kProcSelfExe, bin_dir, PATH_MAX); 24 int bin_dir_size = readlink(kProcSelfExe, bin_dir, PATH_MAX);
23 if (bin_dir_size < 0 || bin_dir_size > PATH_MAX) { 25 if (bin_dir_size < 0 || bin_dir_size > PATH_MAX) {
24 NOTREACHED() << "Unable to resolve " << kProcSelfExe << "."; 26 NOTREACHED() << "Unable to resolve " << kProcSelfExe << ".";
25 return false; 27 return false;
26 } 28 }
27 bin_dir[bin_dir_size] = 0; 29 bin_dir[bin_dir_size] = 0;
28 *result = FilePath(bin_dir); 30 *result = FilePath(bin_dir);
29 return true; 31 return true;
30 } 32 }
31 case base::FILE_MODULE: { 33 case base::FILE_MODULE:
32 // dladdr didn't work in Android as only the file name was returned. 34 // dladdr didn't work in Android as only the file name was returned.
33 NOTIMPLEMENTED(); 35 NOTIMPLEMENTED();
34 return false; 36 return false;
35 } 37 case base::DIR_MODULE:
36 case base::DIR_MODULE: {
37 *result = FilePath(base::android::GetNativeLibraryDirectory()); 38 *result = FilePath(base::android::GetNativeLibraryDirectory());
38 return true; 39 return true;
39 } 40 case base::DIR_SOURCE_ROOT:
40 case base::DIR_SOURCE_ROOT: {
41 // This const is only used for tests. 41 // This const is only used for tests.
42 *result = FilePath(base::android::GetExternalStorageDirectory()); 42 *result = FilePath(base::android::GetExternalStorageDirectory());
43 return true; 43 return true;
44 } 44 case base::DIR_USER_DESKTOP:
45 case base::DIR_CACHE: { 45 // Android doesn't support GetUserDesktop.
46 NOTIMPLEMENTED();
47 return false;
48 case base::DIR_CACHE:
46 *result = FilePath(base::android::GetCacheDirectory()); 49 *result = FilePath(base::android::GetCacheDirectory());
47 return true; 50 return true;
48 } 51 case base::DIR_ANDROID_APP_DATA:
49 case base::DIR_ANDROID_APP_DATA: {
50 *result = FilePath(base::android::GetDataDirectory()); 52 *result = FilePath(base::android::GetDataDirectory());
51 return true; 53 return true;
52 } 54 case base::DIR_HOME:
53 case base::DIR_HOME: {
54 *result = file_util::GetHomeDir(); 55 *result = file_util::GetHomeDir();
55 return true; 56 return true;
56 } 57 case base::DIR_ANDROID_EXTERNAL_STORAGE:
57 case base::DIR_ANDROID_EXTERNAL_STORAGE: {
58 *result = FilePath(base::android::GetExternalStorageDirectory()); 58 *result = FilePath(base::android::GetExternalStorageDirectory());
59 return true; 59 return true;
60 } 60 default:
61 default: {
62 // Note: the path system expects this function to override the default 61 // Note: the path system expects this function to override the default
63 // behavior. So no need to log an error if we don't support a given 62 // behavior. So no need to log an error if we don't support a given
64 // path. The system will just use the default. 63 // path. The system will just use the default.
65 return false; 64 return false;
66 }
67 } 65 }
68 } 66 }
69 67
70 } // namespace base 68 } // namespace base
OLDNEW
« no previous file with comments | « base/base_paths_android.h ('k') | base/base_paths_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698