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

Side by Side Diff: trunk/src/chrome/common/net/url_fixer_upper.cc

Issue 198163004: Revert 257524 "Move IsStringASCII/UTF8 to base namespace." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/common/net/url_fixer_upper.h" 5 #include "chrome/common/net/url_fixer_upper.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #if defined(OS_POSIX) 9 #if defined(OS_POSIX)
10 #include "base/environment.h" 10 #include "base/environment.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 base::UTF8ToUTF16(before_component_string); 44 base::UTF8ToUTF16(before_component_string);
45 base::string16 component_string_16 = base::UTF8ToUTF16(component_string); 45 base::string16 component_string_16 = base::UTF8ToUTF16(component_string);
46 url_parse::Component component_16(before_component_string_16.length(), 46 url_parse::Component component_16(before_component_string_16.length(),
47 component_string_16.length()); 47 component_string_16.length());
48 return component_16; 48 return component_16;
49 } 49 }
50 50
51 void UTF8PartsToUTF16Parts(const std::string& text_utf8, 51 void UTF8PartsToUTF16Parts(const std::string& text_utf8,
52 const url_parse::Parsed& parts_utf8, 52 const url_parse::Parsed& parts_utf8,
53 url_parse::Parsed* parts) { 53 url_parse::Parsed* parts) {
54 if (base::IsStringASCII(text_utf8)) { 54 if (IsStringASCII(text_utf8)) {
55 *parts = parts_utf8; 55 *parts = parts_utf8;
56 return; 56 return;
57 } 57 }
58 58
59 parts->scheme = 59 parts->scheme =
60 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.scheme); 60 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.scheme);
61 parts ->username = 61 parts ->username =
62 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.username); 62 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.username);
63 parts->password = 63 parts->password =
64 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.password); 64 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.password);
65 parts->host = 65 parts->host =
66 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.host); 66 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.host);
67 parts->port = 67 parts->port =
68 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.port); 68 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.port);
69 parts->path = 69 parts->path =
70 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.path); 70 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.path);
71 parts->query = 71 parts->query =
72 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.query); 72 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.query);
73 parts->ref = 73 parts->ref =
74 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.ref); 74 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.ref);
75 } 75 }
76 76
77 base::TrimPositions TrimWhitespaceUTF8(const std::string& input, 77 base::TrimPositions TrimWhitespaceUTF8(const std::string& input,
78 base::TrimPositions positions, 78 base::TrimPositions positions,
79 std::string* output) { 79 std::string* output) {
80 // This implementation is not so fast since it converts the text encoding 80 // This implementation is not so fast since it converts the text encoding
81 // twice. Please feel free to file a bug if this function hurts the 81 // twice. Please feel free to file a bug if this function hurts the
82 // performance of Chrome. 82 // performance of Chrome.
83 DCHECK(base::IsStringUTF8(input)); 83 DCHECK(IsStringUTF8(input));
84 base::string16 input16 = base::UTF8ToUTF16(input); 84 base::string16 input16 = base::UTF8ToUTF16(input);
85 base::string16 output16; 85 base::string16 output16;
86 base::TrimPositions result = 86 base::TrimPositions result =
87 base::TrimWhitespace(input16, positions, &output16); 87 base::TrimWhitespace(input16, positions, &output16);
88 *output = base::UTF16ToUTF8(output16); 88 *output = base::UTF16ToUTF8(output16);
89 return result; 89 return result;
90 } 90 }
91 91
92 // does some basic fixes for input that we want to test for file-ness 92 // does some basic fixes for input that we want to test for file-ness
93 void PrepareStringForFileOps(const base::FilePath& text, 93 void PrepareStringForFileOps(const base::FilePath& text,
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 644
645 if (part->is_valid()) { 645 if (part->is_valid()) {
646 // Offset the location of this component. 646 // Offset the location of this component.
647 part->begin += offset; 647 part->begin += offset;
648 648
649 // This part might not have existed in the original text. 649 // This part might not have existed in the original text.
650 if (part->begin < 0) 650 if (part->begin < 0)
651 part->reset(); 651 part->reset();
652 } 652 }
653 } 653 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698