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/drive/resource_entry_conversion.h" | 5 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 entry_proto.set_download_url(entry.download_url().spec()); | 48 entry_proto.set_download_url(entry.download_url().spec()); |
49 | 49 |
50 const google_apis::Link* edit_link = | 50 const google_apis::Link* edit_link = |
51 entry.GetLinkByType(google_apis::Link::LINK_EDIT); | 51 entry.GetLinkByType(google_apis::Link::LINK_EDIT); |
52 if (edit_link) | 52 if (edit_link) |
53 entry_proto.set_edit_url(edit_link->href().spec()); | 53 entry_proto.set_edit_url(edit_link->href().spec()); |
54 | 54 |
55 const google_apis::Link* parent_link = | 55 const google_apis::Link* parent_link = |
56 entry.GetLinkByType(google_apis::Link::LINK_PARENT); | 56 entry.GetLinkByType(google_apis::Link::LINK_PARENT); |
57 if (parent_link) { | 57 if (parent_link) { |
58 // TODO(haruki): Apply mapping from an empty parent to special dummy | |
59 // directory. See http://crbug.com/174233. Until we implement it, | |
60 // ChangeListProcessor ignores such "no parent" entries. | |
61 entry_proto.set_parent_resource_id( | 58 entry_proto.set_parent_resource_id( |
62 util::ExtractResourceIdFromUrl(parent_link->href())); | 59 util::ExtractResourceIdFromUrl(parent_link->href())); |
63 } | 60 } |
64 | 61 |
62 // Apply mapping from an empty parent to the special dummy directory. | |
63 if (entry_proto.parent_resource_id().empty()) | |
64 entry_proto.set_parent_resource_id(util::kDriveOtherDirSpecialResourceId); | |
kinaba
2013/04/03 05:39:33
I'm not sure if this is the right place for this m
kinaba
2013/04/03 05:59:55
Chatted offline, and inclined to feel ok to put it
Haruki Sato
2013/04/03 06:49:43
Done.
| |
65 | |
65 entry_proto.set_deleted(entry.deleted()); | 66 entry_proto.set_deleted(entry.deleted()); |
66 entry_proto.set_kind(entry.kind()); | 67 entry_proto.set_kind(entry.kind()); |
67 entry_proto.set_shared_with_me(HasSharedWithMeLabel(entry)); | 68 entry_proto.set_shared_with_me(HasSharedWithMeLabel(entry)); |
68 | 69 |
69 PlatformFileInfoProto* file_info = entry_proto.mutable_file_info(); | 70 PlatformFileInfoProto* file_info = entry_proto.mutable_file_info(); |
70 | 71 |
71 file_info->set_last_modified(entry.updated_time().ToInternalValue()); | 72 file_info->set_last_modified(entry.updated_time().ToInternalValue()); |
72 // If the file has never been viewed (last_viewed_time().is_null() == true), | 73 // If the file has never been viewed (last_viewed_time().is_null() == true), |
73 // then we will set the last_accessed field in the protocol buffer to 0. | 74 // then we will set the last_accessed field in the protocol buffer to 0. |
74 file_info->set_last_accessed(entry.last_viewed_time().ToInternalValue()); | 75 file_info->set_last_accessed(entry.last_viewed_time().ToInternalValue()); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 entry_proto.set_upload_url(upload_link->href().spec()); | 128 entry_proto.set_upload_url(upload_link->href().spec()); |
128 } else { | 129 } else { |
129 // Some resource entries don't map into files (i.e. sites). | 130 // Some resource entries don't map into files (i.e. sites). |
130 return DriveEntryProto(); | 131 return DriveEntryProto(); |
131 } | 132 } |
132 | 133 |
133 return entry_proto; | 134 return entry_proto; |
134 } | 135 } |
135 | 136 |
136 } // namespace drive | 137 } // namespace drive |
OLD | NEW |