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

Side by Side Diff: net/url_request/url_request_ftp_job.cc

Issue 11293: Port directory lister to posix. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 1 month 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 | « net/url_request/url_request_file_job.cc ('k') | no next file » | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "net/url_request/url_request_ftp_job.h" 5 #include "net/url_request/url_request_ftp_job.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <wininet.h> 8 #include <wininet.h>
9 9
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/time.h"
12 #include "net/base/auth.h" 13 #include "net/base/auth.h"
13 #include "net/base/load_flags.h" 14 #include "net/base/load_flags.h"
14 #include "net/base/net_util.h" 15 #include "net/base/net_util.h"
15 #include "net/base/wininet_util.h" 16 #include "net/base/wininet_util.h"
16 #include "net/url_request/url_request.h" 17 #include "net/url_request/url_request.h"
17 #include "net/url_request/url_request_error_job.h" 18 #include "net/url_request/url_request_error_job.h"
18 #include "net/base/escape.h" 19 #include "net/base/escape.h"
19 20
20 using std::string; 21 using std::string;
21 22
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 372
372 if (last_error == ERROR_SUCCESS) { 373 if (last_error == ERROR_SUCCESS) {
373 // TODO(jabdelmalek): need to add icons for files/folders. 374 // TODO(jabdelmalek): need to add icons for files/folders.
374 int64 size = 375 int64 size =
375 (static_cast<unsigned __int64>(find_data_.nFileSizeHigh) << 32) | 376 (static_cast<unsigned __int64>(find_data_.nFileSizeHigh) << 32) |
376 find_data_.nFileSizeLow; 377 find_data_.nFileSizeLow;
377 378
378 // We don't know the encoding, and can't assume utf8, so pass the 8bit 379 // We don't know the encoding, and can't assume utf8, so pass the 8bit
379 // directly to the browser for it to decide. 380 // directly to the browser for it to decide.
380 string file_entry = net::GetDirectoryListingEntry( 381 string file_entry = net::GetDirectoryListingEntry(
381 find_data_.cFileName, find_data_.dwFileAttributes, size, 382 find_data_.cFileName, false, size,
382 &find_data_.ftLastWriteTime); 383 base::Time::FromFileTime(find_data_.ftLastWriteTime));
383 WriteData(&file_entry, true); 384 WriteData(&file_entry, true);
384 385
385 FindNextFile(); 386 FindNextFile();
386 return; 387 return;
387 } 388 }
388 389
389 DCHECK(last_error == ERROR_NO_MORE_FILES); 390 DCHECK(last_error == ERROR_NO_MORE_FILES);
390 OnFinishDirectoryTraversal(); 391 OnFinishDirectoryTraversal();
391 } 392 }
392 393
393 void URLRequestFtpJob::OnStartDirectoryTraversal() { 394 void URLRequestFtpJob::OnStartDirectoryTraversal() {
394 state_ = GETTING_DIRECTORY; 395 state_ = GETTING_DIRECTORY;
395 396
396 // Unescape the URL path and pass the raw 8bit directly to the browser. 397 // Unescape the URL path and pass the raw 8bit directly to the browser.
397 string html = net::GetDirectoryListingHeader( 398 string html = net::GetDirectoryListingHeader(
398 UnescapeURLComponent(request_->url().path(), 399 UnescapeURLComponent(request_->url().path(),
399 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS)); 400 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS));
400 401
401 // If this isn't top level directory (i.e. the path isn't "/",) add a link to 402 // If this isn't top level directory (i.e. the path isn't "/",) add a link to
402 // the parent directory. 403 // the parent directory.
403 if (request_->url().path().length() > 1) 404 if (request_->url().path().length() > 1)
404 html.append(net::GetDirectoryListingEntry("..", 0, 0, NULL)); 405 html.append(net::GetDirectoryListingEntry("..", false, 0, base::Time()));
405 406
406 WriteData(&html, true); 407 WriteData(&html, true);
407 408
408 NotifyHeadersComplete(); 409 NotifyHeadersComplete();
409 } 410 }
410 411
411 void URLRequestFtpJob::OnFinishDirectoryTraversal() { 412 void URLRequestFtpJob::OnFinishDirectoryTraversal() {
412 state_ = DONE; 413 state_ = DONE;
413 } 414 }
414 415
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 520
520 *location = request_->url().ReplaceComponents(replacements); 521 *location = request_->url().ReplaceComponents(replacements);
521 *http_status_code = 301; // simulate a permanent redirect 522 *http_status_code = 301; // simulate a permanent redirect
522 return true; 523 return true;
523 } 524 }
524 } 525 }
525 526
526 return false; 527 return false;
527 } 528 }
528 529
OLDNEW
« no previous file with comments | « net/url_request/url_request_file_job.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698