OLD | NEW |
---|---|
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; |
37 if (!chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) { | 38 if (!chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) { |
Mattias Nissler (ping if slow)
2013/02/05 13:06:53
Reminder: Introduce a check here as well.
oscarpan
2013/02/06 04:34:54
Added a TODO, we'd like to get this cl in first, s
Mattias Nissler (ping if slow)
2013/02/06 10:03:26
Why? Checking whether the policy is on or off is t
| |
38 // In Kiosk mode, we effectively disable the registration API | 39 // In Kiosk mode, we effectively disable the registration API |
39 // by always returning an empty code. | 40 // by always returning an empty code. |
40 if (type == kCouponType) | 41 if (type == kCouponType) |
41 provider->GetMachineStatistic(kCouponCodeKey, &result); | 42 provider->GetMachineStatistic(kCouponCodeKey, &result); |
42 else if (type == kGroupType) | 43 else if (type == kGroupType) |
43 provider->GetMachineStatistic(kGroupCodeKey, &result); | 44 provider->GetMachineStatistic(kGroupCodeKey, &result); |
44 } | 45 } |
45 return new base::StringValue(result); | 46 return new base::StringValue(result); |
46 } | 47 } |
47 | 48 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 base::Time::Exploded ctime; | 92 base::Time::Exploded ctime; |
92 fileInfo.creation_time.UTCExplode(&ctime); | 93 fileInfo.creation_time.UTCExplode(&ctime); |
93 timestamp += base::StringPrintf("%u-%u-%u", | 94 timestamp += base::StringPrintf("%u-%u-%u", |
94 ctime.year, | 95 ctime.year, |
95 ctime.month, | 96 ctime.month, |
96 ctime.day_of_month); | 97 ctime.day_of_month); |
97 } | 98 } |
98 SetResult(new base::StringValue(timestamp)); | 99 SetResult(new base::StringValue(timestamp)); |
99 return true; | 100 return true; |
100 } | 101 } |
102 | |
103 AllowRedeemOffersFunction::AllowRedeemOffersFunction() { | |
104 } | |
105 | |
106 AllowRedeemOffersFunction::~AllowRedeemOffersFunction() { | |
107 } | |
108 | |
109 // Check the enterprise policy kAllowRedeemChromeOsRegistrationOffers flag | |
110 // value. This policy is used to controll whether user can redeem offers using | |
111 // enterprise device. | |
112 bool AllowRedeemOffersFunction::RunImpl() { | |
113 bool allow = true; | |
114 // If the policy is not provided, "allow" will not be modified by | |
115 // GetBoolean. | |
116 // TODO(oscarpan): Check if we need to use PreparedTrustedValues. | |
Mattias Nissler (ping if slow)
2013/02/05 13:06:53
You should be using this. As pointed out by Xiyuan
oscarpan
2013/02/06 04:34:54
Done.
| |
117 chromeos::CrosSettings::Get()->GetBoolean( | |
118 chromeos::kAllowRedeemChromeOsRegistrationOffers, &allow); | |
119 SetResult(new base::FundamentalValue(allow)); | |
120 return true; | |
121 } | |
OLD | NEW |