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

Side by Side Diff: chrome/browser/chromeos/extensions/echo_private_api.cc

Issue 10086011: [Chrome OS ECHO]: Rename API and method names (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: address tbarzic's comments Created 8 years, 8 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 (c) 2012 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/chromeos/extensions/echo_private_api.h"
6
7 #include <string>
8
9 #include "base/compiler_specific.h"
10 #include "base/values.h"
11 #include "chrome/browser/chromeos/system/statistics_provider.h"
12 #include "chrome/common/extensions/extension.h"
13
14 namespace {
15
16 // For a given registration code type, returns the code value from the
17 // underlying system. Caller owns the returned pointer.
18 base::Value* GetValueForRegistrationCodeType(std::string& type) {
19 // Possible ECHO code type and corresponding key name in StatisticsProvider.
20 const std::string kCouponType = "COUPON_CODE";
21 const std::string kCouponCodeKey = "ubind_attribute";
22 const std::string kGroupType = "GROUP_CODE";
23 const std::string kGroupCodeKey = "gbind_attribute";
24
25 chromeos::system::StatisticsProvider* provider =
26 chromeos::system::StatisticsProvider::GetInstance();
27 std::string result;
28 if (type == kCouponType)
29 provider->GetMachineStatistic(kCouponCodeKey, &result);
30 else if (type == kGroupType)
31 provider->GetMachineStatistic(kGroupCodeKey, &result);
32 return Value::CreateStringValue(result);
33 }
34
35 } // namespace
36
37
38 GetRegistrationCodeFunction::GetRegistrationCodeFunction() {
39 }
40
41 GetRegistrationCodeFunction::~GetRegistrationCodeFunction() {
42 }
43
44 bool GetRegistrationCodeFunction::RunImpl() {
45 std::string type;
46 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &type));
47 result_.reset(GetValueForRegistrationCodeType(type));
48 return true;
49 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/echo_private_api.h ('k') | chrome/browser/chromeos/extensions/echo_private_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698