OLD | NEW |
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 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UTIL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UTIL_H_ |
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UTIL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // Examples: ExtractGDatPath("/special/gdata/foo.txt") => "gdata/foo.txt" | 46 // Examples: ExtractGDatPath("/special/gdata/foo.txt") => "gdata/foo.txt" |
47 FilePath ExtractGDataPath(const FilePath& path); | 47 FilePath ExtractGDataPath(const FilePath& path); |
48 | 48 |
49 // Returns vector of all possible cache paths for a given path on gdata mount | 49 // Returns vector of all possible cache paths for a given path on gdata mount |
50 // point. | 50 // point. |
51 void InsertGDataCachePathsPermissions( | 51 void InsertGDataCachePathsPermissions( |
52 Profile* profile_, | 52 Profile* profile_, |
53 const FilePath& gdata_path, | 53 const FilePath& gdata_path, |
54 std::vector<std::pair<FilePath, int> >* cache_paths); | 54 std::vector<std::pair<FilePath, int> >* cache_paths); |
55 | 55 |
56 // Grants read-only file access permissions to the process whose id is |pid| | |
57 // with ChildProcessSecurityPolicy for all possible cache paths that may be | |
58 // given to the specified file. | |
59 void SetPermissionsForGDataCacheFiles(Profile* profile, | |
60 int pid, | |
61 const FilePath& path); | |
62 | |
63 // Returns true if gdata is currently active with the specified profile. | 56 // Returns true if gdata is currently active with the specified profile. |
64 bool IsGDataAvailable(Profile* profile); | 57 bool IsGDataAvailable(Profile* profile); |
65 | 58 |
66 // Escapes a file name in GData cache. | 59 // Escapes a file name in GData cache. |
67 // Replaces percent ('%'), period ('.') and slash ('/') with %XX (hex) | 60 // Replaces percent ('%'), period ('.') and slash ('/') with %XX (hex) |
68 std::string EscapeCacheFileName(const std::string& filename); | 61 std::string EscapeCacheFileName(const std::string& filename); |
69 | 62 |
70 // Unescapes a file path in GData cache. | 63 // Unescapes a file path in GData cache. |
71 // This is the inverse of EscapeCacheFileName. | 64 // This is the inverse of EscapeCacheFileName. |
72 std::string UnescapeCacheFileName(const std::string& filename); | 65 std::string UnescapeCacheFileName(const std::string& filename); |
73 | 66 |
74 // Extracts resource_id, md5, and extra_extension from cache path. | 67 // Extracts resource_id, md5, and extra_extension from cache path. |
75 // Case 1: Pinned and outgoing symlinks only have resource_id. | 68 // Case 1: Pinned and outgoing symlinks only have resource_id. |
76 // Example: path="/user/GCache/v1/pinned/pdf:a1b2" => | 69 // Example: path="/user/GCache/v1/pinned/pdf:a1b2" => |
77 // resource_id="pdf:a1b2", md5="", extra_extension=""; | 70 // resource_id="pdf:a1b2", md5="", extra_extension=""; |
78 // Case 2: Normal files have both resource_id and md5. | 71 // Case 2: Normal files have both resource_id and md5. |
79 // Example: path="/user/GCache/v1/tmp/pdf:a1b2.01234567" => | 72 // Example: path="/user/GCache/v1/tmp/pdf:a1b2.01234567" => |
80 // resource_id="pdf:a1b2", md5="01234567", extra_extension=""; | 73 // resource_id="pdf:a1b2", md5="01234567", extra_extension=""; |
81 // Case 3: Mounted files have all three parts. | 74 // Case 3: Mounted files have all three parts. |
82 // Example: path="/user/GCache/v1/persistent/pdf:a1b2.01234567.mounted" => | 75 // Example: path="/user/GCache/v1/persistent/pdf:a1b2.01234567.mounted" => |
83 // resource_id="pdf:a1b2", md5="01234567", extra_extension="mounted". | 76 // resource_id="pdf:a1b2", md5="01234567", extra_extension="mounted". |
84 void ParseCacheFilePath(const FilePath& path, | 77 void ParseCacheFilePath(const FilePath& path, |
85 std::string* resource_id, | 78 std::string* resource_id, |
86 std::string* md5, | 79 std::string* md5, |
87 std::string* extra_extension); | 80 std::string* extra_extension); |
88 } // namespace util | 81 } // namespace util |
89 } // namespace gdata | 82 } // namespace gdata |
90 | 83 |
91 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UTIL_H_ | 84 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UTIL_H_ |
OLD | NEW |