OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/file_select_helper.h" | 5 #include "chrome/browser/file_select_helper.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 directory_lister_ = new net::DirectoryLister(path, | 89 directory_lister_ = new net::DirectoryLister(path, |
90 true, | 90 true, |
91 net::DirectoryLister::NO_SORT, | 91 net::DirectoryLister::NO_SORT, |
92 this); | 92 this); |
93 if (!directory_lister_->Start()) | 93 if (!directory_lister_->Start()) |
94 FileSelectionCanceled(NULL); | 94 FileSelectionCanceled(NULL); |
95 } | 95 } |
96 | 96 |
97 void FileSelectHelper::OnListFile( | 97 void FileSelectHelper::OnListFile( |
98 const net::DirectoryLister::DirectoryListerData& data) { | 98 const net::DirectoryLister::DirectoryListerData& data) { |
99 // Directory upload only cares about files. This util call just checks | 99 // Directory upload returns directories via a "." file, so that |
| 100 // empty directories are included. This util call just checks |
100 // the flags in the structure; there's no file I/O going on. | 101 // the flags in the structure; there's no file I/O going on. |
101 if (file_util::FileEnumerator::IsDirectory(data.info)) | 102 if (file_util::FileEnumerator::IsDirectory(data.info)) |
102 return; | 103 directory_lister_results_.push_back( |
103 | 104 data.path.Append(FILE_PATH_LITERAL("."))); |
104 directory_lister_results_.push_back(data.path); | 105 else |
| 106 directory_lister_results_.push_back(data.path); |
105 } | 107 } |
106 | 108 |
107 void FileSelectHelper::OnListDone(int error) { | 109 void FileSelectHelper::OnListDone(int error) { |
108 if (!render_view_host_) | 110 if (!render_view_host_) |
109 return; | 111 return; |
110 | 112 |
111 if (error) { | 113 if (error) { |
112 FileSelectionCanceled(NULL); | 114 FileSelectionCanceled(NULL); |
113 return; | 115 return; |
114 } | 116 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 NULL); | 239 NULL); |
238 } | 240 } |
239 | 241 |
240 void FileSelectHelper::Observe(NotificationType type, | 242 void FileSelectHelper::Observe(NotificationType type, |
241 const NotificationSource& source, | 243 const NotificationSource& source, |
242 const NotificationDetails& details) { | 244 const NotificationDetails& details) { |
243 DCHECK(type == NotificationType::RENDER_WIDGET_HOST_DESTROYED); | 245 DCHECK(type == NotificationType::RENDER_WIDGET_HOST_DESTROYED); |
244 DCHECK(Details<RenderViewHost>(details).ptr() == render_view_host_); | 246 DCHECK(Details<RenderViewHost>(details).ptr() == render_view_host_); |
245 render_view_host_ = NULL; | 247 render_view_host_ = NULL; |
246 } | 248 } |
OLD | NEW |