forked from crosswalk-project/chromium-crosswalk
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the generation of Accept-Language headers.
We add the base language to the Accept-Language headers, if a corresponding language+region code is present. This change wants to address a long-standing bug that occasionally makes websites return resources in a non-preferred language. See design doc: https://docs.google.com/document/d/10eGUww_2Ufv-YyGwnmr9ke_89Q6By_94v02FM_NTU24 Bug: 737232 Change-Id: I67bea7cb368c744330ec11773fe4a6a69c0e3959 Reviewed-on: https://chromium-review.googlesource.com/625496 Commit-Queue: Claudio M <[email protected]> Reviewed-by: Dimitri Glazkov <[email protected]> Cr-Commit-Position: refs/heads/master@{#499136}
- Loading branch information
1 parent
4e4380d
commit 81326f9
Showing
12 changed files
with
173 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
chrome/browser/net/chrome_http_user_agent_settings_unittest.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) 2017 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/net/chrome_http_user_agent_settings.h" | ||
|
||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
// Test the expansion of the Language List. | ||
TEST(ChromeHttpUserAgentSettings, ExpandLanguageList) { | ||
std::string output = ChromeHttpUserAgentSettings::ExpandLanguageList(""); | ||
EXPECT_EQ("", output); | ||
|
||
output = ChromeHttpUserAgentSettings::ExpandLanguageList("en-US"); | ||
EXPECT_EQ("en-US,en", output); | ||
|
||
output = ChromeHttpUserAgentSettings::ExpandLanguageList("fr"); | ||
EXPECT_EQ("fr", output); | ||
|
||
// The base language is added after all regional codes... | ||
output = ChromeHttpUserAgentSettings::ExpandLanguageList("en-US,en-CA"); | ||
EXPECT_EQ("en-US,en-CA,en", output); | ||
|
||
// ... but before other language families. | ||
output = ChromeHttpUserAgentSettings::ExpandLanguageList("en-US,en-CA,fr"); | ||
EXPECT_EQ("en-US,en-CA,en,fr", output); | ||
|
||
output = | ||
ChromeHttpUserAgentSettings::ExpandLanguageList("en-US,en-CA,fr,en-AU"); | ||
EXPECT_EQ("en-US,en-CA,en,fr,en-AU", output); | ||
|
||
output = ChromeHttpUserAgentSettings::ExpandLanguageList("en-US,en-CA,fr-CA"); | ||
EXPECT_EQ("en-US,en-CA,en,fr-CA,fr", output); | ||
|
||
// Add a base language even if it's already in the list. | ||
output = ChromeHttpUserAgentSettings::ExpandLanguageList( | ||
"en-US,fr-CA,it,fr,es-AR,it-IT"); | ||
EXPECT_EQ("en-US,en,fr-CA,fr,it,es-AR,es,it-IT", output); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters