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 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 138 |
139 void ModifyGDataFileResourceUrl(Profile* profile, | 139 void ModifyGDataFileResourceUrl(Profile* profile, |
140 const FilePath& gdata_cache_path, | 140 const FilePath& gdata_cache_path, |
141 GURL* url) { | 141 GURL* url) { |
142 GDataFileSystem* file_system = GetGDataFileSystem(profile); | 142 GDataFileSystem* file_system = GetGDataFileSystem(profile); |
143 if (!file_system) | 143 if (!file_system) |
144 return; | 144 return; |
145 | 145 |
146 // Handle hosted documents. The edit url is in the temporary file, so we | 146 // Handle hosted documents. The edit url is in the temporary file, so we |
147 // read it on a blocking thread. | 147 // read it on a blocking thread. |
148 if (file_system->GetGDataTempDocumentFolderPath().IsParent( | 148 if (file_system->GetCacheDirectoryPath( |
| 149 GDataRootDirectory::CACHE_TYPE_TMP_DOCUMENTS).IsParent( |
149 gdata_cache_path)) { | 150 gdata_cache_path)) { |
150 GURL* edit_url = new GURL(); | 151 GURL* edit_url = new GURL(); |
151 content::BrowserThread::GetBlockingPool()->PostTaskAndReply(FROM_HERE, | 152 content::BrowserThread::GetBlockingPool()->PostTaskAndReply(FROM_HERE, |
152 base::Bind(&GetHostedDocumentURLBlockingThread, | 153 base::Bind(&GetHostedDocumentURLBlockingThread, |
153 gdata_cache_path, edit_url), | 154 gdata_cache_path, edit_url), |
154 base::Bind(&OpenEditURLUIThread, profile, base::Owned(edit_url))); | 155 base::Bind(&OpenEditURLUIThread, profile, base::Owned(edit_url))); |
155 *url = GURL(); | 156 *url = GURL(); |
156 return; | 157 return; |
157 } | 158 } |
158 | 159 |
159 // Handle all other gdata files. | 160 // Handle all other gdata files. |
160 if (file_system->GetGDataCacheTmpDirectory().IsParent(gdata_cache_path)) { | 161 if (file_system->GetCacheDirectoryPath( |
| 162 GDataRootDirectory::CACHE_TYPE_TMP).IsParent(gdata_cache_path)) { |
161 const std::string resource_id = | 163 const std::string resource_id = |
162 gdata_cache_path.BaseName().RemoveExtension().AsUTF8Unsafe(); | 164 gdata_cache_path.BaseName().RemoveExtension().AsUTF8Unsafe(); |
163 GetFileNameDelegate delegate; | 165 GetFileNameDelegate delegate; |
164 file_system->FindEntryByResourceIdSync(resource_id, &delegate); | 166 file_system->FindEntryByResourceIdSync(resource_id, &delegate); |
165 *url = gdata::util::GetFileResourceUrl(resource_id, delegate.file_name()); | 167 *url = gdata::util::GetFileResourceUrl(resource_id, delegate.file_name()); |
166 DVLOG(1) << "ModifyGDataFileResourceUrl " << *url; | 168 DVLOG(1) << "ModifyGDataFileResourceUrl " << *url; |
167 } | 169 } |
168 } | 170 } |
169 | 171 |
170 bool IsUnderGDataMountPoint(const FilePath& path) { | 172 bool IsUnderGDataMountPoint(const FilePath& path) { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 // Assign the extracted extensions to md5 and extra_extension. | 325 // Assign the extracted extensions to md5 and extra_extension. |
324 int extension_count = extensions.size(); | 326 int extension_count = extensions.size(); |
325 *md5 = (extension_count > 0) ? extensions[extension_count - 1] : | 327 *md5 = (extension_count > 0) ? extensions[extension_count - 1] : |
326 std::string(); | 328 std::string(); |
327 *extra_extension = (extension_count > 1) ? extensions[extension_count - 2] : | 329 *extra_extension = (extension_count > 1) ? extensions[extension_count - 2] : |
328 std::string(); | 330 std::string(); |
329 } | 331 } |
330 | 332 |
331 } // namespace util | 333 } // namespace util |
332 } // namespace gdata | 334 } // namespace gdata |
OLD | NEW |