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 "base/memory/ptr_util.h" | |
jdoerrie
2017/04/06 14:25:50
#include "base/values.h"
vabr (Chromium)
2017/04/07 20:40:40
Done.
| |
8 #include "storage/browser/fileapi/file_system_url.h" | 9 #include "storage/browser/fileapi/file_system_url.h" |
9 #include "storage/common/fileapi/file_system_util.h" | 10 #include "storage/common/fileapi/file_system_util.h" |
10 | 11 |
11 namespace extensions { | 12 namespace extensions { |
12 | 13 |
13 api::sync_file_system::ServiceStatus SyncServiceStateToExtensionEnum( | 14 api::sync_file_system::ServiceStatus SyncServiceStateToExtensionEnum( |
14 sync_file_system::SyncServiceState state) { | 15 sync_file_system::SyncServiceState state) { |
15 switch (state) { | 16 switch (state) { |
16 case sync_file_system::SYNC_SERVICE_RUNNING: | 17 case sync_file_system::SYNC_SERVICE_RUNNING: |
17 return api::sync_file_system::SERVICE_STATUS_RUNNING; | 18 return api::sync_file_system::SERVICE_STATUS_RUNNING; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 case sync_file_system::CONFLICT_RESOLUTION_POLICY_MANUAL: | 99 case sync_file_system::CONFLICT_RESOLUTION_POLICY_MANUAL: |
99 return api::sync_file_system::CONFLICT_RESOLUTION_POLICY_MANUAL; | 100 return api::sync_file_system::CONFLICT_RESOLUTION_POLICY_MANUAL; |
100 case sync_file_system::CONFLICT_RESOLUTION_POLICY_MAX: | 101 case sync_file_system::CONFLICT_RESOLUTION_POLICY_MAX: |
101 NOTREACHED(); | 102 NOTREACHED(); |
102 return api::sync_file_system::CONFLICT_RESOLUTION_POLICY_NONE; | 103 return api::sync_file_system::CONFLICT_RESOLUTION_POLICY_NONE; |
103 } | 104 } |
104 NOTREACHED() << "Invalid conflict resolution policy: " << policy; | 105 NOTREACHED() << "Invalid conflict resolution policy: " << policy; |
105 return api::sync_file_system::CONFLICT_RESOLUTION_POLICY_NONE; | 106 return api::sync_file_system::CONFLICT_RESOLUTION_POLICY_NONE; |
106 } | 107 } |
107 | 108 |
108 base::DictionaryValue* CreateDictionaryValueForFileSystemEntry( | 109 std::unique_ptr<base::DictionaryValue> CreateDictionaryValueForFileSystemEntry( |
109 const storage::FileSystemURL& url, | 110 const storage::FileSystemURL& url, |
110 sync_file_system::SyncFileType file_type) { | 111 sync_file_system::SyncFileType file_type) { |
111 if (!url.is_valid() || file_type == sync_file_system::SYNC_FILE_TYPE_UNKNOWN) | 112 if (!url.is_valid() || file_type == sync_file_system::SYNC_FILE_TYPE_UNKNOWN) |
112 return NULL; | 113 return nullptr; |
113 | 114 |
114 std::string file_path = | 115 std::string file_path = |
115 base::FilePath(storage::VirtualPath::GetNormalizedFilePath(url.path())) | 116 base::FilePath(storage::VirtualPath::GetNormalizedFilePath(url.path())) |
116 .AsUTF8Unsafe(); | 117 .AsUTF8Unsafe(); |
117 | 118 |
118 std::string root_url = | 119 std::string root_url = |
119 storage::GetFileSystemRootURI(url.origin(), url.mount_type()).spec(); | 120 storage::GetFileSystemRootURI(url.origin(), url.mount_type()).spec(); |
120 if (!url.filesystem_id().empty()) { | 121 if (!url.filesystem_id().empty()) { |
121 root_url.append(url.filesystem_id()); | 122 root_url.append(url.filesystem_id()); |
122 root_url.append("/"); | 123 root_url.append("/"); |
123 } | 124 } |
124 | 125 |
125 base::DictionaryValue* dict = new base::DictionaryValue; | 126 auto dict = base::MakeUnique<base::DictionaryValue>(); |
126 dict->SetString("fileSystemType", | 127 dict->SetString("fileSystemType", |
127 storage::GetFileSystemTypeString(url.mount_type())); | 128 storage::GetFileSystemTypeString(url.mount_type())); |
128 dict->SetString("fileSystemName", | 129 dict->SetString("fileSystemName", |
129 storage::GetFileSystemName(url.origin(), url.type())); | 130 storage::GetFileSystemName(url.origin(), url.type())); |
130 dict->SetString("rootUrl", root_url); | 131 dict->SetString("rootUrl", root_url); |
131 dict->SetString("filePath", file_path); | 132 dict->SetString("filePath", file_path); |
132 dict->SetBoolean("isDirectory", | 133 dict->SetBoolean("isDirectory", |
133 (file_type == sync_file_system::SYNC_FILE_TYPE_DIRECTORY)); | 134 (file_type == sync_file_system::SYNC_FILE_TYPE_DIRECTORY)); |
134 | 135 |
135 return dict; | 136 return dict; |
136 } | 137 } |
137 | 138 |
138 } // namespace extensions | 139 } // namespace extensions |
OLD | NEW |