Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: chrome/browser/dom_ui/filebrowse_ui.cc

Issue 3175023: Allow net::DirectoryLister to be used to recursively list the directory, and ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/dom_ui/slideshow_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/dom_ui/filebrowse_ui.h" 5 #include "chrome/browser/dom_ui/filebrowse_ui.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 public DownloadManager::Observer, 100 public DownloadManager::Observer,
101 public DownloadItem::Observer { 101 public DownloadItem::Observer {
102 public: 102 public:
103 FilebrowseHandler(); 103 FilebrowseHandler();
104 virtual ~FilebrowseHandler(); 104 virtual ~FilebrowseHandler();
105 105
106 // Init work after Attach. 106 // Init work after Attach.
107 void Init(); 107 void Init();
108 108
109 // DirectoryLister::DirectoryListerDelegate methods: 109 // DirectoryLister::DirectoryListerDelegate methods:
110 virtual void OnListFile(const file_util::FileEnumerator::FindInfo& data); 110 virtual void OnListFile(
111 const net::DirectoryLister::DirectoryListerData& data);
111 virtual void OnListDone(int error); 112 virtual void OnListDone(int error);
112 113
113 // DOMMessageHandler implementation. 114 // DOMMessageHandler implementation.
114 virtual DOMMessageHandler* Attach(DOMUI* dom_ui); 115 virtual DOMMessageHandler* Attach(DOMUI* dom_ui);
115 virtual void RegisterMessages(); 116 virtual void RegisterMessages();
116 117
117 #if defined(OS_CHROMEOS) 118 #if defined(OS_CHROMEOS)
118 void MountChanged(chromeos::MountLibrary* obj, 119 void MountChanged(chromeos::MountLibrary* obj,
119 chromeos::MountEventType evt, 120 chromeos::MountEventType evt,
120 const std::string& path); 121 const std::string& path);
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 } 760 }
760 761
761 is_refresh_ = is_refresh; 762 is_refresh_ = is_refresh;
762 FilePath default_download_path; 763 FilePath default_download_path;
763 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, 764 if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS,
764 &default_download_path)) { 765 &default_download_path)) {
765 NOTREACHED(); 766 NOTREACHED();
766 } 767 }
767 if (currentpath_ == default_download_path) { 768 if (currentpath_ == default_download_path) {
768 lister_ = new net::DirectoryLister(currentpath_, 769 lister_ = new net::DirectoryLister(currentpath_,
770 false,
769 net::DirectoryLister::DATE, 771 net::DirectoryLister::DATE,
770 this); 772 this);
771 } else { 773 } else {
772 lister_ = new net::DirectoryLister(currentpath_, this); 774 lister_ = new net::DirectoryLister(currentpath_, this);
773 } 775 }
774 lister_->Start(); 776 lister_->Start();
775 } 777 }
776 778
777 void FilebrowseHandler::HandleGetChildren(const ListValue* args) { 779 void FilebrowseHandler::HandleGetChildren(const ListValue* args) {
778 #if defined(OS_CHROMEOS) 780 #if defined(OS_CHROMEOS)
779 std::string path = WideToUTF8(ExtractStringValue(args)); 781 std::string path = WideToUTF8(ExtractStringValue(args));
780 FilePath currentpath(path); 782 FilePath currentpath(path);
781 filelist_value_.reset(new ListValue()); 783 filelist_value_.reset(new ListValue());
782 784
783 GetChildrenForPath(currentpath, false); 785 GetChildrenForPath(currentpath, false);
784 #endif 786 #endif
785 } 787 }
786 788
787 void FilebrowseHandler::OnListFile( 789 void FilebrowseHandler::OnListFile(
788 const file_util::FileEnumerator::FindInfo& data) { 790 const net::DirectoryLister::DirectoryListerData& data) {
789 #if defined(OS_WIN) 791 #if defined(OS_WIN)
790 if (data.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) { 792 if (data.info.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) {
791 return; 793 return;
792 } 794 }
793 #elif defined(OS_POSIX) 795 #elif defined(OS_POSIX)
794 if (data.filename[0] == '.') { 796 if (data.info.filename[0] == '.') {
795 return; 797 return;
796 } 798 }
797 #endif 799 #endif
798 800
799 DictionaryValue* file_value = new DictionaryValue(); 801 DictionaryValue* file_value = new DictionaryValue();
800 802
801 #if defined(OS_WIN) 803 #if defined(OS_WIN)
802 int64 size = (static_cast<int64>(data.nFileSizeHigh) << 32) | 804 int64 size = (static_cast<int64>(data.info.nFileSizeHigh) << 32) |
803 data.nFileSizeLow; 805 data.info.nFileSizeLow;
804 file_value->SetString(kPropertyTitle, data.cFileName); 806 file_value->SetString(kPropertyTitle, data.info.cFileName);
805 file_value->SetString(kPropertyPath, 807 file_value->SetString(kPropertyPath,
806 currentpath_.Append(data.cFileName).value()); 808 currentpath_.Append(data.info.cFileName).value());
807 file_value->SetBoolean(kPropertyDirectory, 809 file_value->SetBoolean(kPropertyDirectory,
808 (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? true : false); 810 (data.info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? true : false);
809 #elif defined(OS_POSIX) 811 #elif defined(OS_POSIX)
810 file_value->SetString(kPropertyTitle, data.filename); 812 file_value->SetString(kPropertyTitle, data.info.filename);
811 file_value->SetString(kPropertyPath, 813 file_value->SetString(kPropertyPath,
812 currentpath_.Append(data.filename).value()); 814 currentpath_.Append(data.info.filename).value());
813 file_value->SetBoolean(kPropertyDirectory, S_ISDIR(data.stat.st_mode)); 815 file_value->SetBoolean(kPropertyDirectory, S_ISDIR(data.info.stat.st_mode));
814 #endif 816 #endif
815 filelist_value_->Append(file_value); 817 filelist_value_->Append(file_value);
816 } 818 }
817 819
818 void FilebrowseHandler::OnListDone(int error) { 820 void FilebrowseHandler::OnListDone(int error) {
819 DictionaryValue info_value; 821 DictionaryValue info_value;
820 if (is_refresh_) { 822 if (is_refresh_) {
821 info_value.SetString("functionCall", "refresh"); 823 info_value.SetString("functionCall", "refresh");
822 } else { 824 } else {
823 info_value.SetString("functionCall", "getChildren"); 825 info_value.SetString("functionCall", "getChildren");
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 } 1030 }
1029 } 1031 }
1030 1032
1031 return NULL; 1033 return NULL;
1032 } 1034 }
1033 1035
1034 const int FileBrowseUI::kPopupWidth = 250; 1036 const int FileBrowseUI::kPopupWidth = 250;
1035 const int FileBrowseUI::kPopupHeight = 300; 1037 const int FileBrowseUI::kPopupHeight = 300;
1036 const int FileBrowseUI::kSmallPopupWidth = 250; 1038 const int FileBrowseUI::kSmallPopupWidth = 250;
1037 const int FileBrowseUI::kSmallPopupHeight = 50; 1039 const int FileBrowseUI::kSmallPopupHeight = 50;
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/dom_ui/slideshow_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698