OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/extensions/api/sync_file_system/sync_file_system_api_he
lpers.h" | 5 #include "chrome/browser/extensions/api/sync_file_system/sync_file_system_api_he
lpers.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "webkit/browser/fileapi/file_system_url.h" | 8 #include "storage/browser/fileapi/file_system_url.h" |
9 #include "webkit/common/fileapi/file_system_util.h" | 9 #include "storage/common/fileapi/file_system_util.h" |
10 | 10 |
11 namespace extensions { | 11 namespace extensions { |
12 | 12 |
13 api::sync_file_system::ServiceStatus SyncServiceStateToExtensionEnum( | 13 api::sync_file_system::ServiceStatus SyncServiceStateToExtensionEnum( |
14 sync_file_system::SyncServiceState state) { | 14 sync_file_system::SyncServiceState state) { |
15 switch (state) { | 15 switch (state) { |
16 case sync_file_system::SYNC_SERVICE_RUNNING: | 16 case sync_file_system::SYNC_SERVICE_RUNNING: |
17 return api::sync_file_system::SERVICE_STATUS_RUNNING; | 17 return api::sync_file_system::SERVICE_STATUS_RUNNING; |
18 case sync_file_system::SYNC_SERVICE_AUTHENTICATION_REQUIRED: | 18 case sync_file_system::SYNC_SERVICE_AUTHENTICATION_REQUIRED: |
19 return api::sync_file_system::SERVICE_STATUS_AUTHENTICATION_REQUIRED; | 19 return api::sync_file_system::SERVICE_STATUS_AUTHENTICATION_REQUIRED; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 return api::sync_file_system::CONFLICT_RESOLUTION_POLICY_MANUAL; | 99 return api::sync_file_system::CONFLICT_RESOLUTION_POLICY_MANUAL; |
100 case sync_file_system::CONFLICT_RESOLUTION_POLICY_MAX: | 100 case sync_file_system::CONFLICT_RESOLUTION_POLICY_MAX: |
101 NOTREACHED(); | 101 NOTREACHED(); |
102 return api::sync_file_system::CONFLICT_RESOLUTION_POLICY_NONE; | 102 return api::sync_file_system::CONFLICT_RESOLUTION_POLICY_NONE; |
103 } | 103 } |
104 NOTREACHED() << "Invalid conflict resolution policy: " << policy; | 104 NOTREACHED() << "Invalid conflict resolution policy: " << policy; |
105 return api::sync_file_system::CONFLICT_RESOLUTION_POLICY_NONE; | 105 return api::sync_file_system::CONFLICT_RESOLUTION_POLICY_NONE; |
106 } | 106 } |
107 | 107 |
108 base::DictionaryValue* CreateDictionaryValueForFileSystemEntry( | 108 base::DictionaryValue* CreateDictionaryValueForFileSystemEntry( |
109 const fileapi::FileSystemURL& url, | 109 const storage::FileSystemURL& url, |
110 sync_file_system::SyncFileType file_type) { | 110 sync_file_system::SyncFileType file_type) { |
111 if (!url.is_valid() || file_type == sync_file_system::SYNC_FILE_TYPE_UNKNOWN) | 111 if (!url.is_valid() || file_type == sync_file_system::SYNC_FILE_TYPE_UNKNOWN) |
112 return NULL; | 112 return NULL; |
113 | 113 |
114 std::string file_path = base::FilePath( | 114 std::string file_path = |
115 fileapi::VirtualPath::GetNormalizedFilePath(url.path())).AsUTF8Unsafe(); | 115 base::FilePath(storage::VirtualPath::GetNormalizedFilePath(url.path())) |
| 116 .AsUTF8Unsafe(); |
116 | 117 |
117 std::string root_url = fileapi::GetFileSystemRootURI( | 118 std::string root_url = |
118 url.origin(), url.mount_type()).spec(); | 119 storage::GetFileSystemRootURI(url.origin(), url.mount_type()).spec(); |
119 if (!url.filesystem_id().empty()) { | 120 if (!url.filesystem_id().empty()) { |
120 root_url.append(url.filesystem_id()); | 121 root_url.append(url.filesystem_id()); |
121 root_url.append("/"); | 122 root_url.append("/"); |
122 } | 123 } |
123 | 124 |
124 base::DictionaryValue* dict = new base::DictionaryValue; | 125 base::DictionaryValue* dict = new base::DictionaryValue; |
125 dict->SetString("fileSystemType", | 126 dict->SetString("fileSystemType", |
126 fileapi::GetFileSystemTypeString(url.mount_type())); | 127 storage::GetFileSystemTypeString(url.mount_type())); |
127 dict->SetString("fileSystemName", | 128 dict->SetString("fileSystemName", |
128 fileapi::GetFileSystemName(url.origin(), url.type())); | 129 storage::GetFileSystemName(url.origin(), url.type())); |
129 dict->SetString("rootUrl", root_url); | 130 dict->SetString("rootUrl", root_url); |
130 dict->SetString("filePath", file_path); | 131 dict->SetString("filePath", file_path); |
131 dict->SetBoolean("isDirectory", | 132 dict->SetBoolean("isDirectory", |
132 (file_type == sync_file_system::SYNC_FILE_TYPE_DIRECTORY)); | 133 (file_type == sync_file_system::SYNC_FILE_TYPE_DIRECTORY)); |
133 | 134 |
134 return dict; | 135 return dict; |
135 } | 136 } |
136 | 137 |
137 } // namespace extensions | 138 } // namespace extensions |
OLD | NEW |