OLD | NEW |
---|---|
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 // The rules for parsing content-types were borrowed from Firefox: | 5 // The rules for parsing content-types were borrowed from Firefox: |
6 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834 | 6 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834 |
7 | 7 |
8 #include "net/http/http_util.h" | 8 #include "net/http/http_util.h" |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
748 } | 748 } |
749 | 749 |
750 // TODO(jungshik): 1. If the list is 'fr-CA,fr-FR,en,de', we have to add | 750 // TODO(jungshik): 1. If the list is 'fr-CA,fr-FR,en,de', we have to add |
751 // 'fr' after 'fr-CA' with the same q-value as 'fr-CA' because | 751 // 'fr' after 'fr-CA' with the same q-value as 'fr-CA' because |
752 // web servers, in general, do not fall back to 'fr' and may end up picking | 752 // web servers, in general, do not fall back to 'fr' and may end up picking |
753 // 'en' which has a lower preference than 'fr-CA' and 'fr-FR'. | 753 // 'en' which has a lower preference than 'fr-CA' and 'fr-FR'. |
754 // 2. This function assumes that the input is a comma separated list | 754 // 2. This function assumes that the input is a comma separated list |
755 // without any whitespace. As long as it comes from the preference and | 755 // without any whitespace. As long as it comes from the preference and |
756 // a user does not manually edit the preference file, it's the case. Still, | 756 // a user does not manually edit the preference file, it's the case. Still, |
757 // we may have to make it more robust. | 757 // we may have to make it more robust. |
758 // 3. The logic here is duplicated by generateAcceptLanguageHeader in | |
759 // chrome/android/java/src/org/chromium/chrome/browser/ | |
760 // physicalweb/PwsClientImpl.java | |
761 // The two implementations should be kept in sync. | |
asanka
2016/05/27 16:57:59
Let's remove this comment. I don't think its feasi
mattreynolds
2016/05/27 17:24:11
The Physical Web client in Chrome for Android is b
asanka
2016/06/01 20:10:26
Understood. Thanks for removing the comment.
Woul
mattreynolds
2016/06/01 22:02:48
Yes, we could store it in SharedPreferences and up
| |
758 std::string HttpUtil::GenerateAcceptLanguageHeader( | 762 std::string HttpUtil::GenerateAcceptLanguageHeader( |
759 const std::string& raw_language_list) { | 763 const std::string& raw_language_list) { |
760 // We use integers for qvalue and qvalue decrement that are 10 times | 764 // We use integers for qvalue and qvalue decrement that are 10 times |
761 // larger than actual values to avoid a problem with comparing | 765 // larger than actual values to avoid a problem with comparing |
762 // two floating point numbers. | 766 // two floating point numbers. |
763 const unsigned int kQvalueDecrement10 = 2; | 767 const unsigned int kQvalueDecrement10 = 2; |
764 unsigned int qvalue10 = 10; | 768 unsigned int qvalue10 = 10; |
765 base::StringTokenizer t(raw_language_list, ","); | 769 base::StringTokenizer t(raw_language_list, ","); |
766 std::string lang_list_with_q; | 770 std::string lang_list_with_q; |
767 while (t.GetNext()) { | 771 while (t.GetNext()) { |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1072 return true; | 1076 return true; |
1073 } | 1077 } |
1074 | 1078 |
1075 bool HttpUtil::NameValuePairsIterator::IsQuote(char c) const { | 1079 bool HttpUtil::NameValuePairsIterator::IsQuote(char c) const { |
1076 if (strict_quotes_) | 1080 if (strict_quotes_) |
1077 return c == '"'; | 1081 return c == '"'; |
1078 return HttpUtil::IsQuote(c); | 1082 return HttpUtil::IsQuote(c); |
1079 } | 1083 } |
1080 | 1084 |
1081 } // namespace net | 1085 } // namespace net |
OLD | NEW |