| 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 #include "components/ntp_snippets/remote/ntp_snippets_fetcher.h" | 5 #include "components/ntp_snippets/remote/ntp_snippets_fetcher.h" |
| 6 | 6 |
| 7 #include <cstdlib> | 7 #include <cstdlib> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 | 538 |
| 539 params->ui_language.language_code = ISO639FromPosixLocale(locale_); | 539 params->ui_language.language_code = ISO639FromPosixLocale(locale_); |
| 540 params->ui_language.frequency = | 540 params->ui_language.frequency = |
| 541 language_model_->GetLanguageFrequency(params->ui_language.language_code); | 541 language_model_->GetLanguageFrequency(params->ui_language.language_code); |
| 542 | 542 |
| 543 std::vector<LanguageModel::LanguageInfo> top_languages = | 543 std::vector<LanguageModel::LanguageInfo> top_languages = |
| 544 language_model_->GetTopLanguages(); | 544 language_model_->GetTopLanguages(); |
| 545 for (const LanguageModel::LanguageInfo& info : top_languages) { | 545 for (const LanguageModel::LanguageInfo& info : top_languages) { |
| 546 if (info.language_code != params->ui_language.language_code) { | 546 if (info.language_code != params->ui_language.language_code) { |
| 547 params->other_top_language = info; | 547 params->other_top_language = info; |
| 548 |
| 549 // Report to UMA how important the UI language is. |
| 550 DCHECK_GT(params->other_top_language.frequency, 0) |
| 551 << "GetTopLanguages() should not return languages with 0 frequency"; |
| 552 float ratio_ui_in_both_languages = params->ui_language.frequency / |
| 553 (params->ui_language.frequency + |
| 554 params->other_top_language.frequency); |
| 555 UMA_HISTOGRAM_PERCENTAGE( |
| 556 "NewTabPage.Languages.UILanguageRatioInTwoTopLanguages", |
| 557 ratio_ui_in_both_languages * 100); |
| 548 break; | 558 break; |
| 549 } | 559 } |
| 550 } | 560 } |
| 551 } | 561 } |
| 552 | 562 |
| 553 void NTPSnippetsFetcher::FetchSnippetsNonAuthenticated() { | 563 void NTPSnippetsFetcher::FetchSnippetsNonAuthenticated() { |
| 554 // When not providing OAuth token, we need to pass the Google API key. | 564 // When not providing OAuth token, we need to pass the Google API key. |
| 555 GURL url(base::StringPrintf(kSnippetsServerNonAuthorizedFormat, | 565 GURL url(base::StringPrintf(kSnippetsServerNonAuthorizedFormat, |
| 556 fetch_url_.spec().c_str(), api_key_.c_str())); | 566 fetch_url_.spec().c_str(), api_key_.c_str())); |
| 557 | 567 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 interactive_request); | 793 interactive_request); |
| 784 case UserClassifier::UserClass::ACTIVE_SUGGESTIONS_CONSUMER: | 794 case UserClassifier::UserClass::ACTIVE_SUGGESTIONS_CONSUMER: |
| 785 return request_throttler_active_suggestions_consumer_ | 795 return request_throttler_active_suggestions_consumer_ |
| 786 .DemandQuotaForRequest(interactive_request); | 796 .DemandQuotaForRequest(interactive_request); |
| 787 } | 797 } |
| 788 NOTREACHED(); | 798 NOTREACHED(); |
| 789 return false; | 799 return false; |
| 790 } | 800 } |
| 791 | 801 |
| 792 } // namespace ntp_snippets | 802 } // namespace ntp_snippets |
| OLD | NEW |