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; |
38 // TODO(oscarpan) update to use PrepareTrustedValues. | |
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 Loading... | |
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 if (chromeos::CrosSettingsProvider::TRUSTED != | |
Mattias Nissler (ping if slow)
2013/02/06 10:03:26
There's an edge case here: Devices that don't have
oscarpan
2013/02/07 00:26:12
I think we should only disable echo when we are ce
| |
112 chromeos::CrosSettings::Get()->PrepareTrustedValues( | |
113 base::Bind(&AllowRedeemOffersFunction::AllowRedeemOffersCallback, | |
114 base::Unretained(this)))) { | |
115 return; | |
xiyuan
2013/02/06 05:28:11
Let's add a AddRef() before return here to ensure
oscarpan
2013/02/07 00:26:12
This seems fixed by other my other changes. No lon
| |
116 } | |
117 bool allow; | |
118 if (!chromeos::CrosSettings::Get()->GetBoolean( | |
119 chromeos::kAllowRedeemChromeOsRegistrationOffers, &allow)) { | |
120 allow = true; | |
121 } | |
122 SetResult(new base::FundamentalValue(allow)); | |
123 SendResponse(true); | |
124 } | |
125 | |
126 // Check the enterprise policy kAllowRedeemChromeOsRegistrationOffers flag | |
127 // value. This policy is used to controll whether user can redeem offers using | |
Mattias Nissler (ping if slow)
2013/02/06 10:03:26
*control
oscarpan
2013/02/07 00:26:12
Done.
| |
128 // enterprise device. | |
129 bool AllowRedeemOffersFunction::RunImpl() { | |
130 AllowRedeemOffersCallback(); | |
131 return false; | |
xiyuan
2013/02/06 05:28:11
It does not matter result for AsyncExtensionFuncti
oscarpan
2013/02/07 00:26:12
Done.
| |
132 } | |
OLD | NEW |