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_file_system.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 DCHECK(doc->is_hosted_document() || doc->is_file()); | 157 DCHECK(doc->is_hosted_document() || doc->is_file()); |
158 GDataFile* file = new GDataFile(parent); | 158 GDataFile* file = new GDataFile(parent); |
159 // Check if this entry is a true file, or... | 159 // Check if this entry is a true file, or... |
160 if (doc->is_file()) { | 160 if (doc->is_file()) { |
161 file->original_file_name_ = UTF16ToUTF8(doc->filename()); | 161 file->original_file_name_ = UTF16ToUTF8(doc->filename()); |
162 file->file_name_ = | 162 file->file_name_ = |
163 EscapeFileName(file->original_file_name_); | 163 EscapeFileName(file->original_file_name_); |
164 file->file_info_.size = doc->file_size(); | 164 file->file_info_.size = doc->file_size(); |
165 file->file_md5_ = doc->file_md5(); | 165 file->file_md5_ = doc->file_md5(); |
166 } else { | 166 } else { |
| 167 DCHECK(doc->is_hosted_document()); |
167 // ... a hosted document. | 168 // ... a hosted document. |
168 file->original_file_name_ = UTF16ToUTF8(doc->title()); | 169 file->original_file_name_ = UTF16ToUTF8(doc->title()); |
169 // Attach .g<something> extension to hosted documents so we can special | 170 // Attach .g<something> extension to hosted documents so we can special |
170 // case their handling in UI. | 171 // case their handling in UI. |
171 // TODO(zelidrag): Figure out better way how to pass entry info like kind | 172 // TODO(zelidrag): Figure out better way how to pass entry info like kind |
172 // to UI through the File API stack. | 173 // to UI through the File API stack. |
173 file->file_name_ = EscapeFileName( | 174 file->file_name_ = EscapeFileName( |
174 base::StringPrintf("%s.g%s", | 175 file->original_file_name_ + doc->GetHostedDocumentExtension()); |
175 file->original_file_name_.c_str(), | |
176 doc->GetEntryKindText().c_str())); | |
177 // We don't know the size of hosted docs and it does not matter since | 176 // We don't know the size of hosted docs and it does not matter since |
178 // is has no effect on the quota. | 177 // is has no effect on the quota. |
179 file->file_info_.size = 0; | 178 file->file_info_.size = 0; |
180 } | 179 } |
181 file->kind_ = doc->kind(); | 180 file->kind_ = doc->kind(); |
182 const Link* self_link = doc->GetLinkByType(Link::SELF); | 181 const Link* self_link = doc->GetLinkByType(Link::SELF); |
183 if (self_link) | 182 if (self_link) |
184 file->self_url_ = self_link->href(); | 183 file->self_url_ = self_link->href(); |
185 file->content_url_ = doc->content_url(); | 184 file->content_url_ = doc->content_url(); |
186 file->content_mime_type_ = doc->content_mime_type(); | 185 file->content_mime_type_ = doc->content_mime_type(); |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 | 853 |
855 GDataFileSystemFactory::~GDataFileSystemFactory() { | 854 GDataFileSystemFactory::~GDataFileSystemFactory() { |
856 } | 855 } |
857 | 856 |
858 ProfileKeyedService* GDataFileSystemFactory::BuildServiceInstanceFor( | 857 ProfileKeyedService* GDataFileSystemFactory::BuildServiceInstanceFor( |
859 Profile* profile) const { | 858 Profile* profile) const { |
860 return new GDataFileSystem(profile); | 859 return new GDataFileSystem(profile); |
861 } | 860 } |
862 | 861 |
863 } // namespace gdata | 862 } // namespace gdata |
OLD | NEW |