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