Chromium Code Reviews| 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/04 09:06:19
You should check the policy value here too - we wa
| |
| 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 IsEchoDisabledFunction::IsEchoDisabledFunction() { | |
| 104 } | |
| 105 | |
| 106 IsEchoDisabledFunction::~IsEchoDisabledFunction() { | |
| 107 } | |
| 108 | |
| 109 // Check the enterprise policy kChromeOsRegistrationEnabled flag value. | |
| 110 // This policy is used to enable/disable Echo for enterprise device. | |
| 111 bool IsEchoDisabledFunction::RunImpl() { | |
| 112 bool isEnabled = true; | |
| 113 // If the policy is not provided, isEnabled will not be modified by | |
| 114 // GetBoolean. | |
|
oscarpan
2013/02/02 01:50:56
I assume this comment is correct and seems so from
xiyuan
2013/02/02 07:49:27
I think the comment is correct. If not confortable
Mattias Nissler (ping if slow)
2013/02/04 09:06:19
It should be you convincing the reviewers ;) In th
| |
| 115 chromeos::CrosSettings::Get()->GetBoolean( | |
| 116 chromeos::kChromeOsRegistrationEnabled, &isEnabled); | |
|
xiyuan
2013/02/02 07:49:27
nit: 4-space indent
xiyuan
2013/02/02 07:49:27
Do we need to worry that this value might not be t
oscarpan
2013/02/02 21:52:35
I'm not sure when this value is unreliable. Is the
xiyuan
2013/02/02 22:44:16
I am not worrying about extension code being chang
oscarpan
2013/02/05 00:17:47
Done.
oscarpan
2013/02/05 00:17:47
How about we postpone this feature to later cls.
| |
| 117 SetResult(new base::FundamentalValue(!isEnabled)); | |
| 118 return true; | |
| 119 } | |
| OLD | NEW |