summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authormmentovai@google.com <mmentovai@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-02 18:13:34 +0000
committermmentovai@google.com <mmentovai@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-02 18:13:34 +0000
commit844cbe038fca95d8a5406f895704076c402e4e29 (patch)
tree15d719337cb5541af0b364ada93fc1e166533026 /net
parent368e2490bd7ac1ffeee85d246b98144ea6d92591 (diff)
downloadchromium_src-844cbe038fca95d8a5406f895704076c402e4e29.zip
chromium_src-844cbe038fca95d8a5406f895704076c402e4e29.tar.gz
chromium_src-844cbe038fca95d8a5406f895704076c402e4e29.tar.bz2
Normalize newlines to LF in net
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1647 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/SConstruct6
-rw-r--r--net/base/net_util_posix.cc92
-rw-r--r--net/base/net_util_win.cc174
-rw-r--r--net/base/platform_mime_util.h58
-rw-r--r--net/base/platform_mime_util_win.cc68
5 files changed, 199 insertions, 199 deletions
diff --git a/net/SConstruct b/net/SConstruct
index 6ea69a0..de24fa9 100644
--- a/net/SConstruct
+++ b/net/SConstruct
@@ -1,3 +1,3 @@
-build_component = 'net'
-SConscript('../build/SConscript.main',
- exports=['build_component'])
+build_component = 'net'
+SConscript('../build/SConscript.main',
+ exports=['build_component'])
diff --git a/net/base/net_util_posix.cc b/net/base/net_util_posix.cc
index b24fbad..2554e4b 100644
--- a/net/base/net_util_posix.cc
+++ b/net/base/net_util_posix.cc
@@ -1,46 +1,46 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/base/net_util.h"
-
-#include "base/string_util.h"
-#include "googleurl/src/gurl.h"
-#include "net/base/escape.h"
-
-namespace net {
-
-bool FileURLToFilePath(const GURL& url, std::wstring* file_path) {
- file_path->clear();
-
- if (!url.is_valid())
- return false;
-
- // Firefox seems to ignore the "host" of a file url if there is one. That is,
- // file://foo/bar.txt maps to /bar.txt.
- std::string path = url.path();
-
- if (path.empty())
- return false;
-
- // GURL stores strings as percent-encoded 8-bit, this will undo if possible.
- path = UnescapeURLComponent(path,
- UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS);
-
- // Collapse multiple path slashes into a single path slash.
- std::string new_path;
- do {
- new_path = path;
- ReplaceSubstringsAfterOffset(&new_path, 0, "//", "/");
- path.swap(new_path);
- } while (new_path != path);
-
- // TODO(tc): This should actually be 8-bit to wide. We may lose data if the
- // string isn't UTF-8.
- file_path->assign(UTF8ToWide(path));
-
- return !file_path->empty();
-}
-
-} // namespace net
-
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/base/net_util.h"
+
+#include "base/string_util.h"
+#include "googleurl/src/gurl.h"
+#include "net/base/escape.h"
+
+namespace net {
+
+bool FileURLToFilePath(const GURL& url, std::wstring* file_path) {
+ file_path->clear();
+
+ if (!url.is_valid())
+ return false;
+
+ // Firefox seems to ignore the "host" of a file url if there is one. That is,
+ // file://foo/bar.txt maps to /bar.txt.
+ std::string path = url.path();
+
+ if (path.empty())
+ return false;
+
+ // GURL stores strings as percent-encoded 8-bit, this will undo if possible.
+ path = UnescapeURLComponent(path,
+ UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS);
+
+ // Collapse multiple path slashes into a single path slash.
+ std::string new_path;
+ do {
+ new_path = path;
+ ReplaceSubstringsAfterOffset(&new_path, 0, "//", "/");
+ path.swap(new_path);
+ } while (new_path != path);
+
+ // TODO(tc): This should actually be 8-bit to wide. We may lose data if the
+ // string isn't UTF-8.
+ file_path->assign(UTF8ToWide(path));
+
+ return !file_path->empty();
+}
+
+} // namespace net
+
diff --git a/net/base/net_util_win.cc b/net/base/net_util_win.cc
index afc0f91..206f485 100644
--- a/net/base/net_util_win.cc
+++ b/net/base/net_util_win.cc
@@ -1,87 +1,87 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/base/net_util.h"
-
-#include "base/string_piece.h"
-#include "base/string_util.h"
-#include "base/sys_string_conversions.h"
-#include "googleurl/src/gurl.h"
-#include "net/base/escape.h"
-
-namespace net {
-
-bool FileURLToFilePath(const GURL& url, std::wstring* file_path) {
- file_path->clear();
-
- if (!url.is_valid())
- return false;
-
- std::string path;
- std::string host = url.host();
- if (host.empty()) {
- // URL contains no host, the path is the filename. In this case, the path
- // will probably be preceeded with a slash, as in "/C:/foo.txt", so we
- // trim out that here.
- path = url.path();
- size_t first_non_slash = path.find_first_not_of("/\\");
- if (first_non_slash != std::string::npos && first_non_slash > 0)
- path.erase(0, first_non_slash);
- } else {
- // URL contains a host: this means it's UNC. We keep the preceeding slash
- // on the path.
- path = "\\\\";
- path.append(host);
- path.append(url.path());
- }
-
- if (path.empty())
- return false;
- std::replace(path.begin(), path.end(), '/', '\\');
-
- // GURL stores strings as percent-encoded UTF-8, this will undo if possible.
- path = UnescapeURLComponent(path,
- UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS);
-
- if (!IsStringUTF8(path.c_str())) {
- // Not UTF-8, assume encoding is native codepage and we're done. We know we
- // are giving the conversion function a nonempty string, and it may fail if
- // the given string is not in the current encoding and give us an empty
- // string back. We detect this and report failure.
- *file_path = base::SysNativeMBToWide(path);
- return !file_path->empty();
- }
- file_path->assign(UTF8ToWide(path));
-
- // Now we have an unescaped filename, but are still not sure about its
- // encoding. For example, each character could be part of a UTF-8 string.
- if (file_path->empty() || !IsString8Bit(*file_path)) {
- // assume our 16-bit encoding is correct if it won't fit into an 8-bit
- // string
- return true;
- }
-
- // Convert our narrow string into the native wide path.
- std::string narrow;
- if (!WideToLatin1(*file_path, &narrow)) {
- NOTREACHED() << "Should have filtered out non-8-bit strings above.";
- return false;
- }
- if (IsStringUTF8(narrow.c_str())) {
- // Our string actually looks like it could be UTF-8, convert to 8-bit
- // UTF-8 and then to the corresponding wide string.
- *file_path = UTF8ToWide(narrow);
- } else {
- // Our wide string contains only 8-bit characters and it's not UTF-8, so
- // we assume it's in the native codepage.
- *file_path = base::SysNativeMBToWide(narrow);
- }
-
- // Fail if 8-bit -> wide conversion failed and gave us an empty string back
- // (we already filtered out empty strings above).
- return !file_path->empty();
-}
-
-} // namespace net
-
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/base/net_util.h"
+
+#include "base/string_piece.h"
+#include "base/string_util.h"
+#include "base/sys_string_conversions.h"
+#include "googleurl/src/gurl.h"
+#include "net/base/escape.h"
+
+namespace net {
+
+bool FileURLToFilePath(const GURL& url, std::wstring* file_path) {
+ file_path->clear();
+
+ if (!url.is_valid())
+ return false;
+
+ std::string path;
+ std::string host = url.host();
+ if (host.empty()) {
+ // URL contains no host, the path is the filename. In this case, the path
+ // will probably be preceeded with a slash, as in "/C:/foo.txt", so we
+ // trim out that here.
+ path = url.path();
+ size_t first_non_slash = path.find_first_not_of("/\\");
+ if (first_non_slash != std::string::npos && first_non_slash > 0)
+ path.erase(0, first_non_slash);
+ } else {
+ // URL contains a host: this means it's UNC. We keep the preceeding slash
+ // on the path.
+ path = "\\\\";
+ path.append(host);
+ path.append(url.path());
+ }
+
+ if (path.empty())
+ return false;
+ std::replace(path.begin(), path.end(), '/', '\\');
+
+ // GURL stores strings as percent-encoded UTF-8, this will undo if possible.
+ path = UnescapeURLComponent(path,
+ UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS);
+
+ if (!IsStringUTF8(path.c_str())) {
+ // Not UTF-8, assume encoding is native codepage and we're done. We know we
+ // are giving the conversion function a nonempty string, and it may fail if
+ // the given string is not in the current encoding and give us an empty
+ // string back. We detect this and report failure.
+ *file_path = base::SysNativeMBToWide(path);
+ return !file_path->empty();
+ }
+ file_path->assign(UTF8ToWide(path));
+
+ // Now we have an unescaped filename, but are still not sure about its
+ // encoding. For example, each character could be part of a UTF-8 string.
+ if (file_path->empty() || !IsString8Bit(*file_path)) {
+ // assume our 16-bit encoding is correct if it won't fit into an 8-bit
+ // string
+ return true;
+ }
+
+ // Convert our narrow string into the native wide path.
+ std::string narrow;
+ if (!WideToLatin1(*file_path, &narrow)) {
+ NOTREACHED() << "Should have filtered out non-8-bit strings above.";
+ return false;
+ }
+ if (IsStringUTF8(narrow.c_str())) {
+ // Our string actually looks like it could be UTF-8, convert to 8-bit
+ // UTF-8 and then to the corresponding wide string.
+ *file_path = UTF8ToWide(narrow);
+ } else {
+ // Our wide string contains only 8-bit characters and it's not UTF-8, so
+ // we assume it's in the native codepage.
+ *file_path = base::SysNativeMBToWide(narrow);
+ }
+
+ // Fail if 8-bit -> wide conversion failed and gave us an empty string back
+ // (we already filtered out empty strings above).
+ return !file_path->empty();
+}
+
+} // namespace net
+
diff --git a/net/base/platform_mime_util.h b/net/base/platform_mime_util.h
index bbce4c5..6b90994 100644
--- a/net/base/platform_mime_util.h
+++ b/net/base/platform_mime_util.h
@@ -1,29 +1,29 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef NET_BASE_PLATFORM_MIME_UTIL_H_
-#define NET_BASE_PLATFORM_MIME_UTIL_H_
-
-#include <string>
-
-namespace net {
-
-// Encapsulates the platform-specific functionality in mime_util
-class PlatformMimeUtil {
- public:
- // See documentation for base::GetPreferredExtensionForMimeType [mime_util.h]
- bool GetPreferredExtensionForMimeType(const std::string& mime_type,
- std::wstring* extension) const;
- protected:
-
- // Get the mime type (if any) that is associated with the file extension.
- // Returns true if a corresponding mime type exists.
- bool GetPlatformMimeTypeFromExtension(const std::wstring& ext,
- std::string* mime_type) const;
-};
-
-} // namespace net
-
-#endif // NET_BASE_PLATFORM_MIME_UTIL_H_
-
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_BASE_PLATFORM_MIME_UTIL_H_
+#define NET_BASE_PLATFORM_MIME_UTIL_H_
+
+#include <string>
+
+namespace net {
+
+// Encapsulates the platform-specific functionality in mime_util
+class PlatformMimeUtil {
+ public:
+ // See documentation for base::GetPreferredExtensionForMimeType [mime_util.h]
+ bool GetPreferredExtensionForMimeType(const std::string& mime_type,
+ std::wstring* extension) const;
+ protected:
+
+ // Get the mime type (if any) that is associated with the file extension.
+ // Returns true if a corresponding mime type exists.
+ bool GetPlatformMimeTypeFromExtension(const std::wstring& ext,
+ std::string* mime_type) const;
+};
+
+} // namespace net
+
+#endif // NET_BASE_PLATFORM_MIME_UTIL_H_
+
diff --git a/net/base/platform_mime_util_win.cc b/net/base/platform_mime_util_win.cc
index 9b62f30..c0219fc 100644
--- a/net/base/platform_mime_util_win.cc
+++ b/net/base/platform_mime_util_win.cc
@@ -1,34 +1,34 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <string>
-
-#include "net/base/platform_mime_util.h"
-
-#include "base/registry.h"
-#include "base/string_util.h"
-
-namespace net {
-
-bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension(
- const std::wstring& ext, std::string* result) const {
- // check windows registry for file extension's mime type (registry key
- // names are not case-sensitive).
- std::wstring value, key = L"." + ext;
- RegKey(HKEY_CLASSES_ROOT, key.c_str()).ReadValue(L"Content Type", &value);
- if (!value.empty()) {
- *result = WideToUTF8(value);
- return true;
- }
- return false;
-}
-
-bool PlatformMimeUtil::GetPreferredExtensionForMimeType(
- const std::string& mime_type, std::wstring* ext) const {
- std::wstring key(L"MIME\\Database\\Content Type\\" + UTF8ToWide(mime_type));
- return RegKey(HKEY_CLASSES_ROOT, key.c_str()).ReadValue(L"Extension", ext);
-}
-
-} // namespace net
-
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <string>
+
+#include "net/base/platform_mime_util.h"
+
+#include "base/registry.h"
+#include "base/string_util.h"
+
+namespace net {
+
+bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension(
+ const std::wstring& ext, std::string* result) const {
+ // check windows registry for file extension's mime type (registry key
+ // names are not case-sensitive).
+ std::wstring value, key = L"." + ext;
+ RegKey(HKEY_CLASSES_ROOT, key.c_str()).ReadValue(L"Content Type", &value);
+ if (!value.empty()) {
+ *result = WideToUTF8(value);
+ return true;
+ }
+ return false;
+}
+
+bool PlatformMimeUtil::GetPreferredExtensionForMimeType(
+ const std::string& mime_type, std::wstring* ext) const {
+ std::wstring key(L"MIME\\Database\\Content Type\\" + UTF8ToWide(mime_type));
+ return RegKey(HKEY_CLASSES_ROOT, key.c_str()).ReadValue(L"Extension", ext);
+}
+
+} // namespace net
+