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

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

Issue 270183002: Move IsStringUTF8/ASCII to base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more minor nit Created 6 years, 7 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 base::UTF8ToUTF16(before_component_string); 45 base::UTF8ToUTF16(before_component_string);
46 base::string16 component_string_16 = base::UTF8ToUTF16(component_string); 46 base::string16 component_string_16 = base::UTF8ToUTF16(component_string);
47 url::Component component_16(before_component_string_16.length(), 47 url::Component component_16(before_component_string_16.length(),
48 component_string_16.length()); 48 component_string_16.length());
49 return component_16; 49 return component_16;
50 } 50 }
51 51
52 void UTF8PartsToUTF16Parts(const std::string& text_utf8, 52 void UTF8PartsToUTF16Parts(const std::string& text_utf8,
53 const url::Parsed& parts_utf8, 53 const url::Parsed& parts_utf8,
54 url::Parsed* parts) { 54 url::Parsed* parts) {
55 if (IsStringASCII(text_utf8)) { 55 if (base::IsStringASCII(text_utf8)) {
56 *parts = parts_utf8; 56 *parts = parts_utf8;
57 return; 57 return;
58 } 58 }
59 59
60 parts->scheme = 60 parts->scheme =
61 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.scheme); 61 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.scheme);
62 parts ->username = 62 parts ->username =
63 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.username); 63 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.username);
64 parts->password = 64 parts->password =
65 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.password); 65 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.password);
66 parts->host = 66 parts->host =
67 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.host); 67 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.host);
68 parts->port = 68 parts->port =
69 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.port); 69 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.port);
70 parts->path = 70 parts->path =
71 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.path); 71 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.path);
72 parts->query = 72 parts->query =
73 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.query); 73 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.query);
74 parts->ref = 74 parts->ref =
75 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.ref); 75 UTF8ComponentToUTF16Component(text_utf8, parts_utf8.ref);
76 } 76 }
77 77
78 base::TrimPositions TrimWhitespaceUTF8(const std::string& input, 78 base::TrimPositions TrimWhitespaceUTF8(const std::string& input,
79 base::TrimPositions positions, 79 base::TrimPositions positions,
80 std::string* output) { 80 std::string* output) {
81 // This implementation is not so fast since it converts the text encoding 81 // This implementation is not so fast since it converts the text encoding
82 // twice. Please feel free to file a bug if this function hurts the 82 // twice. Please feel free to file a bug if this function hurts the
83 // performance of Chrome. 83 // performance of Chrome.
84 DCHECK(IsStringUTF8(input)); 84 DCHECK(base::IsStringUTF8(input));
85 base::string16 input16 = base::UTF8ToUTF16(input); 85 base::string16 input16 = base::UTF8ToUTF16(input);
86 base::string16 output16; 86 base::string16 output16;
87 base::TrimPositions result = 87 base::TrimPositions result =
88 base::TrimWhitespace(input16, positions, &output16); 88 base::TrimWhitespace(input16, positions, &output16);
89 *output = base::UTF16ToUTF8(output16); 89 *output = base::UTF16ToUTF8(output16);
90 return result; 90 return result;
91 } 91 }
92 92
93 // does some basic fixes for input that we want to test for file-ness 93 // does some basic fixes for input that we want to test for file-ness
94 void PrepareStringForFileOps(const base::FilePath& text, 94 void PrepareStringForFileOps(const base::FilePath& text,
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 646
647 if (part->is_valid()) { 647 if (part->is_valid()) {
648 // Offset the location of this component. 648 // Offset the location of this component.
649 part->begin += offset; 649 part->begin += offset;
650 650
651 // This part might not have existed in the original text. 651 // This part might not have existed in the original text.
652 if (part->begin < 0) 652 if (part->begin < 0)
653 part->reset(); 653 part->reset();
654 } 654 }
655 } 655 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/manifest_handlers/content_scripts_handler.cc ('k') | chrome/installer/util/installer_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698