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

Side by Side Diff: net/base/net_util.cc

Issue 1696013: Makes FormatURL not strip http for view-source urls. (Closed)
Patch Set: Incorporated review feedback Created 10 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
« no previous file with comments | « no previous file | net/base/net_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "net/base/net_util.h" 5 #include "net/base/net_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <unicode/ucnv.h> 9 #include <unicode/ucnv.h>
10 #include <unicode/uidna.h> 10 #include <unicode/uidna.h>
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 const std::wstring& languages, 733 const std::wstring& languages,
734 net::FormatUrlTypes format_types, 734 net::FormatUrlTypes format_types,
735 UnescapeRule::Type unescape_rules, 735 UnescapeRule::Type unescape_rules,
736 url_parse::Parsed* new_parsed, 736 url_parse::Parsed* new_parsed,
737 size_t* prefix_end, 737 size_t* prefix_end,
738 size_t* offset_for_adjustment) { 738 size_t* offset_for_adjustment) {
739 DCHECK(new_parsed); 739 DCHECK(new_parsed);
740 const wchar_t* const kWideViewSource = L"view-source:"; 740 const wchar_t* const kWideViewSource = L"view-source:";
741 const size_t kViewSourceLengthPlus1 = 12; 741 const size_t kViewSourceLengthPlus1 = 12;
742 742
743 // 'view-source' requires http, so don't strip it.
744 format_types &= ~net::kFormatUrlOmitHTTP;
743 GURL real_url(url.possibly_invalid_spec().substr(kViewSourceLengthPlus1)); 745 GURL real_url(url.possibly_invalid_spec().substr(kViewSourceLengthPlus1));
744 size_t temp_offset = (*offset_for_adjustment == std::wstring::npos) ? 746 size_t temp_offset = (*offset_for_adjustment == std::wstring::npos) ?
745 std::wstring::npos : (*offset_for_adjustment - kViewSourceLengthPlus1); 747 std::wstring::npos : (*offset_for_adjustment - kViewSourceLengthPlus1);
746 size_t* temp_offset_ptr = (*offset_for_adjustment < kViewSourceLengthPlus1) ? 748 size_t* temp_offset_ptr = (*offset_for_adjustment < kViewSourceLengthPlus1) ?
747 NULL : &temp_offset; 749 NULL : &temp_offset;
748 std::wstring result = net::FormatUrl(real_url, languages, 750 std::wstring result = net::FormatUrl(real_url, languages,
749 format_types, unescape_rules, new_parsed, prefix_end, temp_offset_ptr); 751 format_types, unescape_rules, new_parsed, prefix_end, temp_offset_ptr);
750 result.insert(0, kWideViewSource); 752 result.insert(0, kWideViewSource);
751 753
752 // Adjust position values. 754 // Adjust position values.
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 1739
1738 IPv6SupportResults(IPV6_GLOBAL_ADDRESS_MISSING); 1740 IPv6SupportResults(IPV6_GLOBAL_ADDRESS_MISSING);
1739 return false; 1741 return false;
1740 #else 1742 #else
1741 NOTIMPLEMENTED(); 1743 NOTIMPLEMENTED();
1742 return true; 1744 return true;
1743 #endif // defined(various platforms) 1745 #endif // defined(various platforms)
1744 } 1746 }
1745 1747
1746 } // namespace net 1748 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/base/net_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698