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

Side by Side Diff: chrome/browser/services/gcm/gcm_product_util.cc

Issue 2657823005: Move //c/b/services/gcm/ to //c/b/gcm/ (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/services/gcm/gcm_product_util.h"
6
7 #include "base/strings/string_piece.h"
8 #include "base/strings/string_util.h"
9 #include "chrome/common/chrome_version.h"
10 #include "chrome/common/pref_names.h"
11 #include "components/pref_registry/pref_registry_syncable.h"
12 #include "components/prefs/pref_registry_simple.h"
13 #include "components/prefs/pref_service.h"
14 #include "components/version_info/version_info.h"
15
16 namespace gcm {
17
18 namespace {
19
20 std::string ToLowerAlphaNum(base::StringPiece in) {
21 std::string out;
22 out.reserve(in.size());
23 for (char ch : in) {
24 if (base::IsAsciiAlpha(ch) || base::IsAsciiDigit(ch))
25 out.push_back(base::ToLowerASCII(ch));
26 }
27 return out;
28 }
29
30 } // namespace
31
32 std::string GetProductCategoryForSubtypes(PrefService* prefs) {
33 std::string product_category_for_subtypes =
34 prefs->GetString(prefs::kGCMProductCategoryForSubtypes);
35 if (!product_category_for_subtypes.empty())
36 return product_category_for_subtypes;
37
38 std::string product = ToLowerAlphaNum(PRODUCT_SHORTNAME_STRING);
39 std::string ns = product == "chromium" ? "org" : "com";
40 std::string platform = ToLowerAlphaNum(version_info::GetOSType());
41 product_category_for_subtypes = ns + '.' + product + '.' + platform;
42
43 prefs->SetString(prefs::kGCMProductCategoryForSubtypes,
44 product_category_for_subtypes);
45 return product_category_for_subtypes;
46 }
47
48 void RegisterPrefs(PrefRegistrySimple* registry) {
49 registry->RegisterStringPref(prefs::kGCMProductCategoryForSubtypes,
50 std::string() /* default_value */);
51 }
52
53 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
54 RegisterPrefs(registry);
55 }
56
57 } // namespace gcm
OLDNEW
« no previous file with comments | « chrome/browser/services/gcm/gcm_product_util.h ('k') | chrome/browser/services/gcm/gcm_profile_service_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698