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

Unified Diff: net/base/net_util.cc

Issue 11437: Port directory lister so test shell can view file directories. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/net_util.h ('k') | net/net_lib.scons » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/net_util.cc
===================================================================
--- net/base/net_util.cc (revision 5618)
+++ net/base/net_util.cc (working copy)
@@ -23,6 +23,7 @@
#include "net/base/net_util.h"
#include "base/basictypes.h"
+#include "base/file_path.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
@@ -798,12 +799,22 @@
return CanonicalizeHost(converted_host, is_ip_address);
}
-#ifdef OS_WIN
std::string GetDirectoryListingHeader(const std::string& title) {
+#if defined(OS_WIN)
std::string result = NetModule::GetResource(IDR_DIR_HEADER_HTML);
if (result.empty()) {
NOTREACHED() << "expected resource not found";
}
+#elif defined(OS_POSIX)
+ // TODO(estade): Temporary hack. Remove these platform #ifdefs when we
+ // have implemented resources for non-Windows platforms.
+ LOG(INFO) << "FIXME: hacked resource loading";
+ FilePath path;
+ PathService::Get(base::DIR_EXE, &path);
+ path = path.Append("../../net/base/dir_header.html");
+ std::string result;
+ file_util::ReadFileToString(path.ToWStringHack(), &result);
+#endif
result.append("<script>start(");
string_escape::JavascriptDoubleQuote(title, true, &result);
@@ -813,16 +824,16 @@
}
std::string GetDirectoryListingEntry(const std::string& name,
- DWORD attrib,
+ bool is_dir,
int64 size,
- const FILETIME* modified) {
+ const Time& modified) {
std::string result;
result.append("<script>addRow(");
string_escape::JavascriptDoubleQuote(name, true, &result);
result.append(",");
string_escape::JavascriptDoubleQuote(
EscapePath(name), true, &result);
- if (attrib & FILE_ATTRIBUTE_DIRECTORY) {
+ if (is_dir) {
result.append(",1,");
} else {
result.append(",0,");
@@ -835,9 +846,8 @@
std::wstring modified_str;
// |modified| can be NULL in FTP listings.
- if (modified) {
- Time time(Time::FromFileTime(*modified));
- modified_str = base::TimeFormatShortDateAndTime(time);
+ if (!modified.is_null()) {
+ modified_str = base::TimeFormatShortDateAndTime(modified);
}
string_escape::JavascriptDoubleQuote(modified_str, true, &result);
@@ -845,7 +855,6 @@
return result;
}
-#endif
std::wstring StripWWW(const std::wstring& text) {
const std::wstring www(L"www.");
« no previous file with comments | « net/base/net_util.h ('k') | net/net_lib.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698