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

Unified Diff: chrome/browser/chromeos/extensions/echo_private_api.cc

Issue 12147004: Disable/enable echo for enterprise device. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 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 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
index 51f195dbf4e0e44638fb24e52fb98891c716a1bf..89acffe89688904d9fd62ac4bfc272b7e7066f91 100644
--- a/chrome/browser/chromeos/extensions/echo_private_api.cc
+++ b/chrome/browser/chromeos/extensions/echo_private_api.cc
@@ -14,17 +14,28 @@
#include "base/time.h"
#include "base/values.h"
#include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
+#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/system/statistics_provider.h"
#include "chrome/common/extensions/extension.h"
#include "content/public/browser/browser_thread.h"
using content::BrowserThread;
-namespace {
+GetRegistrationCodeFunction::GetRegistrationCodeFunction() {
+}
+
+GetRegistrationCodeFunction::~GetRegistrationCodeFunction() {
+}
+
+void GetRegistrationCodeFunction::GetRegistrationCode(const std::string& type) {
+ chromeos::CrosSettingsProvider::TrustedStatus status =
+ chromeos::CrosSettings::Get()->PrepareTrustedValues(
+ base::Bind(&GetRegistrationCodeFunction::GetRegistrationCode,
+ base::Unretained(this),
+ type));
+ if (status == chromeos::CrosSettingsProvider::TEMPORARILY_UNTRUSTED)
+ return;
-// 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";
@@ -42,22 +53,13 @@ base::Value* GetValueForRegistrationCodeType(std::string& type) {
else if (type == kGroupType)
provider->GetMachineStatistic(kGroupCodeKey, &result);
}
- return new base::StringValue(result);
-}
-
-} // namespace
-
-
-GetRegistrationCodeFunction::GetRegistrationCodeFunction() {
-}
-
-GetRegistrationCodeFunction::~GetRegistrationCodeFunction() {
+ SetResult(new base::StringValue(result));
}
bool GetRegistrationCodeFunction::RunImpl() {
std::string type;
EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &type));
- SetResult(GetValueForRegistrationCodeType(type));
+ GetRegistrationCode(type);
return true;
}
@@ -98,3 +100,34 @@ bool GetOobeTimestampFunction::GetOobeTimestampOnFileThread() {
SetResult(new base::StringValue(timestamp));
return true;
}
+
+AllowRedeemOffersFunction::AllowRedeemOffersFunction() {
+}
+
+AllowRedeemOffersFunction::~AllowRedeemOffersFunction() {
+}
+
+void AllowRedeemOffersFunction::AllowRedeemOffersCallback() {
+ chromeos::CrosSettingsProvider::TrustedStatus status =
+ chromeos::CrosSettings::Get()->PrepareTrustedValues(
+ base::Bind(&AllowRedeemOffersFunction::AllowRedeemOffersCallback,
+ base::Unretained(this)));
+ if (status == chromeos::CrosSettingsProvider::TEMPORARILY_UNTRUSTED)
+ return;
+
+ bool allow;
+ if (!chromeos::CrosSettings::Get()->GetBoolean(
+ chromeos::kAllowRedeemChromeOsRegistrationOffers, &allow)) {
+ allow = true;
+ }
+ SetResult(new base::FundamentalValue(allow));
+ SendResponse(true);
+}
+
+// Check the enterprise policy kAllowRedeemChromeOsRegistrationOffers flag
+// value. This policy is used to control whether user can redeem offers using
+// enterprise device.
+bool AllowRedeemOffersFunction::RunImpl() {
+ AllowRedeemOffersCallback();
+ return true;
+}

Powered by Google App Engine
This is Rietveld 408576698