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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/extensions/echo_private_api.cc
diff --git a/chrome/browser/chromeos/extensions/echo_private_api.cc b/chrome/browser/chromeos/extensions/echo_private_api.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a48c704b25e081ae092f24c6993930717c43c6ad
--- /dev/null
+++ b/chrome/browser/chromeos/extensions/echo_private_api.cc
@@ -0,0 +1,49 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/extensions/echo_private_api.h"
+
+#include <string>
+
+#include "base/compiler_specific.h"
+#include "base/values.h"
+#include "chrome/browser/chromeos/system/statistics_provider.h"
+#include "chrome/common/extensions/extension.h"
+
+namespace {
+
+// For a given registration code type, returns the code value from the
+// underlying system. Caller owns the returned pointer.
+base::Value* GetValueForRegistrationCodeType(std::string& type) {
+ // Possible ECHO code type and corresponding key name in StatisticsProvider.
+ const std::string kCouponType = "COUPON_CODE";
+ const std::string kCouponCodeKey = "ubind_attribute";
+ const std::string kGroupType = "GROUP_CODE";
+ const std::string kGroupCodeKey = "gbind_attribute";
+
+ chromeos::system::StatisticsProvider* provider =
+ chromeos::system::StatisticsProvider::GetInstance();
+ std::string result;
+ if (type == kCouponType)
+ provider->GetMachineStatistic(kCouponCodeKey, &result);
+ else if (type == kGroupType)
+ provider->GetMachineStatistic(kGroupCodeKey, &result);
+ return Value::CreateStringValue(result);
+}
+
+} // namespace
+
+
+GetRegistrationCodeFunction::GetRegistrationCodeFunction() {
+}
+
+GetRegistrationCodeFunction::~GetRegistrationCodeFunction() {
+}
+
+bool GetRegistrationCodeFunction::RunImpl() {
+ std::string type;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &type));
+ result_.reset(GetValueForRegistrationCodeType(type));
+ return true;
+}
« 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