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

Side by Side 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: Address comments. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/extensions/echo_private_api.h" 5 #include "chrome/browser/chromeos/extensions/echo_private_api.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" 16 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
17 #include "chrome/browser/chromeos/settings/cros_settings.h"
17 #include "chrome/browser/chromeos/system/statistics_provider.h" 18 #include "chrome/browser/chromeos/system/statistics_provider.h"
18 #include "chrome/common/extensions/extension.h" 19 #include "chrome/common/extensions/extension.h"
19 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
20 21
21 using content::BrowserThread; 22 using content::BrowserThread;
22 23
23 namespace { 24 namespace {
24 25
25 // For a given registration code type, returns the code value from the 26 // For a given registration code type, returns the code value from the
26 // underlying system. Caller owns the returned pointer. 27 // underlying system. Caller owns the returned pointer.
27 base::Value* GetValueForRegistrationCodeType(std::string& type) { 28 base::Value* GetValueForRegistrationCodeType(std::string& type) {
28 // Possible ECHO code type and corresponding key name in StatisticsProvider. 29 // Possible ECHO code type and corresponding key name in StatisticsProvider.
29 const std::string kCouponType = "COUPON_CODE"; 30 const std::string kCouponType = "COUPON_CODE";
30 const std::string kCouponCodeKey = "ubind_attribute"; 31 const std::string kCouponCodeKey = "ubind_attribute";
31 const std::string kGroupType = "GROUP_CODE"; 32 const std::string kGroupType = "GROUP_CODE";
32 const std::string kGroupCodeKey = "gbind_attribute"; 33 const std::string kGroupCodeKey = "gbind_attribute";
33 34
34 chromeos::system::StatisticsProvider* provider = 35 chromeos::system::StatisticsProvider* provider =
35 chromeos::system::StatisticsProvider::GetInstance(); 36 chromeos::system::StatisticsProvider::GetInstance();
36 std::string result; 37 std::string result;
38 // TODO(oscarpan) update to use PrepareTrustedValues.
Mattias Nissler (ping if slow) 2013/02/07 10:45:57 still missing a policy check here?
oscarpan 2013/02/07 13:10:56 Done.
37 if (!chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) { 39 if (!chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) {
38 // In Kiosk mode, we effectively disable the registration API 40 // In Kiosk mode, we effectively disable the registration API
39 // by always returning an empty code. 41 // by always returning an empty code.
40 if (type == kCouponType) 42 if (type == kCouponType)
41 provider->GetMachineStatistic(kCouponCodeKey, &result); 43 provider->GetMachineStatistic(kCouponCodeKey, &result);
42 else if (type == kGroupType) 44 else if (type == kGroupType)
43 provider->GetMachineStatistic(kGroupCodeKey, &result); 45 provider->GetMachineStatistic(kGroupCodeKey, &result);
44 } 46 }
45 return new base::StringValue(result); 47 return new base::StringValue(result);
46 } 48 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 base::Time::Exploded ctime; 93 base::Time::Exploded ctime;
92 fileInfo.creation_time.UTCExplode(&ctime); 94 fileInfo.creation_time.UTCExplode(&ctime);
93 timestamp += base::StringPrintf("%u-%u-%u", 95 timestamp += base::StringPrintf("%u-%u-%u",
94 ctime.year, 96 ctime.year,
95 ctime.month, 97 ctime.month,
96 ctime.day_of_month); 98 ctime.day_of_month);
97 } 99 }
98 SetResult(new base::StringValue(timestamp)); 100 SetResult(new base::StringValue(timestamp));
99 return true; 101 return true;
100 } 102 }
103
104 AllowRedeemOffersFunction::AllowRedeemOffersFunction() {
105 }
106
107 AllowRedeemOffersFunction::~AllowRedeemOffersFunction() {
108 }
109
110 void AllowRedeemOffersFunction::AllowRedeemOffersCallback() {
111 chromeos::CrosSettingsProvider::TrustedStatus status =
112 chromeos::CrosSettings::Get()->PrepareTrustedValues(
113 base::Bind(&AllowRedeemOffersFunction::AllowRedeemOffersCallback,
114 base::Unretained(this)));
115 if (status == chromeos::CrosSettingsProvider::TEMPORARILY_UNTRUSTED) {
Mattias Nissler (ping if slow) 2013/02/07 10:45:57 nit: no need for curly braces.
oscarpan 2013/02/07 13:10:56 Done.
116 return;
117 }
118 bool allow;
119 if (!chromeos::CrosSettings::Get()->GetBoolean(
120 chromeos::kAllowRedeemChromeOsRegistrationOffers, &allow)) {
121 allow = true;
122 }
123 SetResult(new base::FundamentalValue(allow));
124 SendResponse(true);
125 }
126
127 // Check the enterprise policy kAllowRedeemChromeOsRegistrationOffers flag
128 // value. This policy is used to control whether user can redeem offers using
129 // enterprise device.
130 bool AllowRedeemOffersFunction::RunImpl() {
131 AllowRedeemOffersCallback();
132 return true;
133 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698