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

Side by Side Diff: components/url_formatter/url_fixer.cc

Issue 1841653003: Drop |languages| from {Format,Elide}Url* and IDNToUnicode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo in elide_url.cc Created 4 years, 8 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
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 "components/url_formatter/url_fixer.h" 5 #include "components/url_formatter/url_fixer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 base::FilePath input_path(text); 180 base::FilePath input_path(text);
181 PrepareStringForFileOps(input_path, &filename); 181 PrepareStringForFileOps(input_path, &filename);
182 if (filename.length() > 0 && filename[0] == '~') 182 if (filename.length() > 0 && filename[0] == '~')
183 filename = FixupHomedir(filename); 183 filename = FixupHomedir(filename);
184 #endif 184 #endif
185 185
186 // Here, we know the input looks like a file. 186 // Here, we know the input looks like a file.
187 GURL file_url = net::FilePathToFileURL(base::FilePath(filename)); 187 GURL file_url = net::FilePathToFileURL(base::FilePath(filename));
188 if (file_url.is_valid()) { 188 if (file_url.is_valid()) {
189 return base::UTF16ToUTF8(url_formatter::FormatUrl( 189 return base::UTF16ToUTF8(url_formatter::FormatUrl(
190 file_url, std::string(), url_formatter::kFormatUrlOmitUsernamePassword, 190 file_url, url_formatter::kFormatUrlOmitUsernamePassword,
191 net::UnescapeRule::NORMAL, nullptr, nullptr, nullptr)); 191 net::UnescapeRule::NORMAL, nullptr, nullptr, nullptr));
192 } 192 }
193 193
194 // Invalid file URL, just return the input. 194 // Invalid file URL, just return the input.
195 return text; 195 return text;
196 } 196 }
197 197
198 // Checks |domain| to see if a valid TLD is already present. If not, appends 198 // Checks |domain| to see if a valid TLD is already present. If not, appends
199 // |desired_tld| to the domain, and prepends "www." unless it's already present. 199 // |desired_tld| to the domain, and prepends "www." unless it's already present.
200 void AddDesiredTLD(const std::string& desired_tld, std::string* domain) { 200 void AddDesiredTLD(const std::string& desired_tld, std::string* domain) {
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 } 634 }
635 635
636 // Put back the current directory if we saved it. 636 // Put back the current directory if we saved it.
637 if (!base_dir.empty()) 637 if (!base_dir.empty())
638 base::SetCurrentDirectory(old_cur_directory); 638 base::SetCurrentDirectory(old_cur_directory);
639 639
640 if (is_file) { 640 if (is_file) {
641 GURL file_url = net::FilePathToFileURL(full_path); 641 GURL file_url = net::FilePathToFileURL(full_path);
642 if (file_url.is_valid()) 642 if (file_url.is_valid())
643 return GURL(base::UTF16ToUTF8(url_formatter::FormatUrl( 643 return GURL(base::UTF16ToUTF8(url_formatter::FormatUrl(
644 file_url, std::string(), 644 file_url, url_formatter::kFormatUrlOmitUsernamePassword,
645 url_formatter::kFormatUrlOmitUsernamePassword,
646 net::UnescapeRule::NORMAL, nullptr, nullptr, nullptr))); 645 net::UnescapeRule::NORMAL, nullptr, nullptr, nullptr)));
647 // Invalid files fall through to regular processing. 646 // Invalid files fall through to regular processing.
648 } 647 }
649 648
650 // Fall back on regular fixup for this input. 649 // Fall back on regular fixup for this input.
651 #if defined(OS_WIN) 650 #if defined(OS_WIN)
652 std::string text_utf8 = base::WideToUTF8(text.value()); 651 std::string text_utf8 = base::WideToUTF8(text.value());
653 #elif defined(OS_POSIX) 652 #elif defined(OS_POSIX)
654 std::string text_utf8 = text.value(); 653 std::string text_utf8 = text.value();
655 #endif 654 #endif
(...skipping 14 matching lines...) Expand all
670 } 669 }
671 670
672 bool IsEquivalentScheme(const std::string& scheme1, 671 bool IsEquivalentScheme(const std::string& scheme1,
673 const std::string& scheme2) { 672 const std::string& scheme2) {
674 return scheme1 == scheme2 || 673 return scheme1 == scheme2 ||
675 (scheme1 == url::kAboutScheme && scheme2 == kChromeUIScheme) || 674 (scheme1 == url::kAboutScheme && scheme2 == kChromeUIScheme) ||
676 (scheme1 == kChromeUIScheme && scheme2 == url::kAboutScheme); 675 (scheme1 == kChromeUIScheme && scheme2 == url::kAboutScheme);
677 } 676 }
678 677
679 } // namespace url_formatter 678 } // namespace url_formatter
OLDNEW
« no previous file with comments | « components/url_formatter/elide_url_unittest.cc ('k') | components/url_formatter/url_formatter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698