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

Side by Side Diff: chrome/browser/language_usage_metrics.h

Issue 7348004: Record language usage as UMA histograms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add DCHECK Created 9 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_main.cc ('k') | chrome/browser/language_usage_metrics.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_LANGUAGE_USAGE_METRICS_H_
6 #define CHROME_BROWSER_LANGUAGE_USAGE_METRICS_H_
7 #pragma once
8
9 #include <set>
10 #include <string>
11
12 #include "base/gtest_prod_util.h"
13 #include "third_party/cld/languages/public/languages.h"
14
15 // Methods to record language usage as UMA histograms.
16 // Language codes are defined in third_party/cld/languages/proto/languages.pb.h
17 class LanguageUsageMetrics {
18 public:
19 // Records accept languages as a UMA histogram. |accept_languages| is a
20 // case-insensitive comma-separated list of languages/locales of either xx,
21 // xx-YY, or xx_YY format where xx is iso-639 language code and YY is iso-3166
22 // country code. Country code is ignored. That is, xx and XX-YY are considered
23 // identical and recorded once.
24 static void RecordAcceptLanguages(const std::string& accept_languages);
25
26 // Records the application language as a UMA histogram. |application_locale|
27 // is a case-insensitive locale string of either xx, xx-YY, or xx_YY format.
28 // Only the language part (xx in the example) is considered.
29 static void RecordApplicationLanguage(const std::string& application_locale);
30
31 private:
32 // This class must not be instantiated.
33 LanguageUsageMetrics();
34
35 // Parses |accept_languages| and returns a set of language codes in
36 // |languages|.
37 static void ParseAcceptLanguages(const std::string& accept_languages,
38 std::set<Language>* languages);
39
40 // Parses |locale| and returns the language code. Returns UNKNOWN_LANGUAGE in
41 // case of errors.
42 static Language ToLanguage(const std::string& locale);
43
44 FRIEND_TEST_ALL_PREFIXES(LanguageUsageMetricsTest, ParseAcceptLanguages);
45 FRIEND_TEST_ALL_PREFIXES(LanguageUsageMetricsTest, ToLanguage);
46 };
47
48 #endif // CHROME_BROWSER_LANGUAGE_USAGE_METRICS_H_
OLDNEW
« no previous file with comments | « chrome/browser/browser_main.cc ('k') | chrome/browser/language_usage_metrics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698