| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 /** | 5 /** |
| 6 * Processes select tag that contains list of available terms for different | 6 * Processes select tag that contains list of available terms for different |
| 7 * languages and zones. In case of initial load, tries to find terms that match | 7 * languages and zones. In case of initial load, tries to find terms that match |
| 8 * exactly current language and country code and automatically redirects the | 8 * exactly current language and country code and automatically redirects the |
| 9 * view in case such terms are found. Leaves terms in select tag that only match | 9 * view in case such terms are found. Leaves terms in select tag that only match |
| 10 * current language or country code or default English variant or currently | 10 * current language or country code or default English variant or currently |
| 11 * selected. Note that document.countryCode must be set before calling this | 11 * selected. Note that document.countryCode must be set before calling this |
| 12 * function. | 12 * function. |
| 13 */ | 13 */ |
| 14 function processLangZoneTerms() { | 14 function processLangZoneTerms() { |
| 15 var doc = document; | 15 var doc = document; |
| 16 var selectLangZoneTerms = doc.getElementById('play-footer'). | 16 var selectLangZoneTerms = |
| 17 getElementsByTagName('select')[0]; | 17 doc.getElementById('play-footer').getElementsByTagName('select')[0]; |
| 18 | 18 |
| 19 var initialLoad = window.location.href == | 19 var initialLoad = |
| 20 'https://play.google.com/about/play-terms.html'; | 20 window.location.href == 'https://play.google.com/about/play-terms.html'; |
| 21 var langSegments = navigator.language.split('-'); | 21 var langSegments = navigator.language.split('-'); |
| 22 if (initialLoad) { | 22 if (initialLoad) { |
| 23 var applyTermsForLangAndZone = function(termsLang) { | 23 var applyTermsForLangAndZone = function(termsLang) { |
| 24 var matchByLangZone = '/intl/' + termsLang + '_' + | 24 var matchByLangZone = '/intl/' + termsLang + '_' + document.countryCode + |
| 25 document.countryCode + '/about/play-terms.html'; | 25 '/about/play-terms.html'; |
| 26 for (var i = selectLangZoneTerms.options.length - 1; i >= 0; --i) { | 26 for (var i = selectLangZoneTerms.options.length - 1; i >= 0; --i) { |
| 27 var option = selectLangZoneTerms.options[i]; | 27 var option = selectLangZoneTerms.options[i]; |
| 28 if (option.value == matchByLangZone) { | 28 if (option.value == matchByLangZone) { |
| 29 window.location.href = option.value; | 29 window.location.href = option.value; |
| 30 return true; | 30 return true; |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 return false; | 33 return false; |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 // Try two versions of the language, full and short (if it exists, for | 36 // Try two versions of the language, full and short (if it exists, for |
| 37 // example en-GB -> en). Note, terms may contain entries for both types, for | 37 // example en-GB -> en). Note, terms may contain entries for both types, for |
| 38 // example: en_ie, es-419_ar, es_as, pt-PT_pt. | 38 // example: en_ie, es-419_ar, es_as, pt-PT_pt. |
| 39 if (applyTermsForLangAndZone(navigator.language)) { | 39 if (applyTermsForLangAndZone(navigator.language)) { |
| 40 return; | 40 return; |
| 41 } | 41 } |
| 42 if (langSegments.length == 2 && | 42 if (langSegments.length == 2 && applyTermsForLangAndZone(langSegments[0])) { |
| 43 applyTermsForLangAndZone(langSegments[0])) { | |
| 44 return; | 43 return; |
| 45 } | 44 } |
| 46 } | 45 } |
| 47 | 46 |
| 48 var matchByLang = '/intl/' + navigator.language + '_'; | 47 var matchByLang = '/intl/' + navigator.language + '_'; |
| 49 var matchByLangShort = null; | 48 var matchByLangShort = null; |
| 50 if (langSegments.length == 2) { | 49 if (langSegments.length == 2) { |
| 51 matchByLangShort = '/intl/' + langSegments[0] + '_'; | 50 matchByLangShort = '/intl/' + langSegments[0] + '_'; |
| 52 } | 51 } |
| 53 | 52 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 var targetURL = links[i].href; | 126 var targetURL = links[i].href; |
| 128 if (targetURL.endsWith('/policies/privacy/')) { | 127 if (targetURL.endsWith('/policies/privacy/')) { |
| 129 return targetURL; | 128 return targetURL; |
| 130 } | 129 } |
| 131 } | 130 } |
| 132 return 'https://www.google.com/policies/privacy/'; | 131 return 'https://www.google.com/policies/privacy/'; |
| 133 } | 132 } |
| 134 | 133 |
| 135 formatDocument(); | 134 formatDocument(); |
| 136 processLangZoneTerms(); | 135 processLangZoneTerms(); |
| OLD | NEW |