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_proxy.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_file_system_proxy.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/platform_file.h" | 11 #include "base/platform_file.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/chromeos/gdata/gdata.pb.h" | 14 #include "chrome/browser/chromeos/gdata/gdata.pb.h" |
15 #include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" | 15 #include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" |
16 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | 16 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" |
17 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 17 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
18 #include "chrome/browser/prefs/pref_service.h" | |
19 #include "chrome/browser/profiles/profile.h" | |
20 #include "chrome/common/pref_names.h" | |
21 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
22 #include "webkit/blob/shareable_file_reference.h" | 19 #include "webkit/blob/shareable_file_reference.h" |
23 #include "webkit/fileapi/file_system_file_util_proxy.h" | 20 #include "webkit/fileapi/file_system_file_util_proxy.h" |
24 #include "webkit/fileapi/file_system_types.h" | 21 #include "webkit/fileapi/file_system_types.h" |
25 #include "webkit/fileapi/file_system_url.h" | 22 #include "webkit/fileapi/file_system_url.h" |
26 #include "webkit/fileapi/file_system_util.h" | 23 #include "webkit/fileapi/file_system_util.h" |
27 | 24 |
28 using base::MessageLoopProxy; | 25 using base::MessageLoopProxy; |
29 using content::BrowserThread; | 26 using content::BrowserThread; |
30 using fileapi::FileSystemURL; | 27 using fileapi::FileSystemURL; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 entry.name = proto.base_name(); | 170 entry.name = proto.base_name(); |
174 entry.is_directory = file_info.is_directory; | 171 entry.is_directory = file_info.is_directory; |
175 entry.size = file_info.size; | 172 entry.size = file_info.size; |
176 entry.last_modified_time = file_info.last_modified; | 173 entry.last_modified_time = file_info.last_modified; |
177 return entry; | 174 return entry; |
178 } | 175 } |
179 | 176 |
180 // GDataFileSystemProxy class implementation. | 177 // GDataFileSystemProxy class implementation. |
181 | 178 |
182 GDataFileSystemProxy::GDataFileSystemProxy( | 179 GDataFileSystemProxy::GDataFileSystemProxy( |
183 GDataFileSystemInterface* file_system, | 180 GDataFileSystemInterface* file_system) |
184 Profile* profile) | 181 : file_system_(file_system) { |
185 : file_system_(file_system), | |
186 profile_(profile) { | |
187 // Should be created from the file browser extension API (AddMountFunction) | 182 // Should be created from the file browser extension API (AddMountFunction) |
188 // on UI thread. | 183 // on UI thread. |
189 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 184 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
190 } | 185 } |
191 | 186 |
192 void GDataFileSystemProxy::GetFileInfo(const FileSystemURL& file_url, | 187 void GDataFileSystemProxy::GetFileInfo(const FileSystemURL& file_url, |
193 const FileSystemOperationInterface::GetMetadataCallback& callback) { | 188 const FileSystemOperationInterface::GetMetadataCallback& callback) { |
194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 189 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
195 FilePath file_path; | 190 FilePath file_path; |
196 if (!ValidateUrl(file_url, &file_path)) { | 191 if (!ValidateUrl(file_url, &file_path)) { |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 entry_proto->file_info(), | 669 entry_proto->file_info(), |
675 &file_info); | 670 &file_info); |
676 | 671 |
677 callback.Run(base::PLATFORM_FILE_OK, file_info, file_path); | 672 callback.Run(base::PLATFORM_FILE_OK, file_info, file_path); |
678 } | 673 } |
679 | 674 |
680 void GDataFileSystemProxy::OnReadDirectory( | 675 void GDataFileSystemProxy::OnReadDirectory( |
681 const FileSystemOperationInterface::ReadDirectoryCallback& | 676 const FileSystemOperationInterface::ReadDirectoryCallback& |
682 callback, | 677 callback, |
683 GDataFileError error, | 678 GDataFileError error, |
| 679 bool hide_hosted_documents, |
684 scoped_ptr<gdata::GDataEntryProtoVector> proto_entries) { | 680 scoped_ptr<gdata::GDataEntryProtoVector> proto_entries) { |
685 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 681 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
686 | 682 |
687 PrefService* pref_service = profile_->GetPrefs(); | |
688 const bool hide_hosted_documents = | |
689 pref_service->GetBoolean(prefs::kDisableGDataHostedFiles); | |
690 | |
691 if (error != GDATA_FILE_OK) { | 683 if (error != GDATA_FILE_OK) { |
692 callback.Run(util::GDataFileErrorToPlatformError(error), | 684 callback.Run(util::GDataFileErrorToPlatformError(error), |
693 std::vector<base::FileUtilProxy::Entry>(), | 685 std::vector<base::FileUtilProxy::Entry>(), |
694 false); | 686 false); |
695 return; | 687 return; |
696 } | 688 } |
697 DCHECK(proto_entries.get()); | 689 DCHECK(proto_entries.get()); |
698 | 690 |
699 std::vector<base::FileUtilProxy::Entry> entries; | 691 std::vector<base::FileUtilProxy::Entry> entries; |
700 // Convert gdata files to something File API stack can understand. | 692 // Convert gdata files to something File API stack can understand. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 | 729 |
738 void GDataFileSystemProxy::CloseWritableSnapshotFile( | 730 void GDataFileSystemProxy::CloseWritableSnapshotFile( |
739 const FilePath& virtual_path, | 731 const FilePath& virtual_path, |
740 const FilePath& local_path) { | 732 const FilePath& local_path) { |
741 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 733 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
742 | 734 |
743 file_system_->CloseFile(virtual_path, base::Bind(&OnClose, virtual_path)); | 735 file_system_->CloseFile(virtual_path, base::Bind(&OnClose, virtual_path)); |
744 } | 736 } |
745 | 737 |
746 } // namespace gdata | 738 } // namespace gdata |
OLD | NEW |