| 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/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 void EchoPrivateGetRegistrationCodeFunction::GetRegistrationCode( | 44 void EchoPrivateGetRegistrationCodeFunction::GetRegistrationCode( |
| 45 const std::string& type) { | 45 const std::string& type) { |
| 46 if (!chromeos::KioskModeSettings::Get()->is_initialized()) { | 46 if (!chromeos::KioskModeSettings::Get()->is_initialized()) { |
| 47 chromeos::KioskModeSettings::Get()->Initialize(base::Bind( | 47 chromeos::KioskModeSettings::Get()->Initialize(base::Bind( |
| 48 &EchoPrivateGetRegistrationCodeFunction::GetRegistrationCode, | 48 &EchoPrivateGetRegistrationCodeFunction::GetRegistrationCode, |
| 49 this, type)); | 49 this, type)); |
| 50 return; | 50 return; |
| 51 } | 51 } |
| 52 // Possible ECHO code type and corresponding key name in StatisticsProvider. | 52 // Possible ECHO code type and corresponding key name in StatisticsProvider. |
| 53 const std::string kCouponType = "COUPON_CODE"; | 53 const std::string kCouponType = "COUPON_CODE"; |
| 54 const std::string kCouponCodeKey = "ubind_attribute"; | |
| 55 const std::string kGroupType = "GROUP_CODE"; | 54 const std::string kGroupType = "GROUP_CODE"; |
| 56 const std::string kGroupCodeKey = "gbind_attribute"; | |
| 57 | 55 |
| 58 chromeos::system::StatisticsProvider* provider = | 56 chromeos::system::StatisticsProvider* provider = |
| 59 chromeos::system::StatisticsProvider::GetInstance(); | 57 chromeos::system::StatisticsProvider::GetInstance(); |
| 60 std::string result; | 58 std::string result; |
| 61 if (!chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) { | 59 if (!chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) { |
| 62 // In Kiosk mode, we effectively disable the registration API | 60 // In Kiosk mode, we effectively disable the registration API |
| 63 // by always returning an empty code. | 61 // by always returning an empty code. |
| 64 if (type == kCouponType) | 62 if (type == kCouponType) { |
| 65 provider->GetMachineStatistic(kCouponCodeKey, &result); | 63 provider->GetMachineStatistic(chromeos::system::kOffersCouponCodeKey, |
| 66 else if (type == kGroupType) | 64 &result); |
| 67 provider->GetMachineStatistic(kGroupCodeKey, &result); | 65 } else if (type == kGroupType) { |
| 66 provider->GetMachineStatistic(chromeos::system::kOffersGroupCodeKey, |
| 67 &result); |
| 68 } |
| 68 } | 69 } |
| 69 | 70 |
| 70 results_ = echo_api::GetRegistrationCode::Results::Create(result); | 71 results_ = echo_api::GetRegistrationCode::Results::Create(result); |
| 71 SendResponse(true); | 72 SendResponse(true); |
| 72 } | 73 } |
| 73 | 74 |
| 74 bool EchoPrivateGetRegistrationCodeFunction::RunImpl() { | 75 bool EchoPrivateGetRegistrationCodeFunction::RunImpl() { |
| 75 scoped_ptr<echo_api::GetRegistrationCode::Params> params = | 76 scoped_ptr<echo_api::GetRegistrationCode::Params> params = |
| 76 echo_api::GetRegistrationCode::Params::Create(*args_); | 77 echo_api::GetRegistrationCode::Params::Create(*args_); |
| 77 EXTENSION_FUNCTION_VALIDATE(params); | 78 EXTENSION_FUNCTION_VALIDATE(params); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 void EchoPrivateGetUserConsentFunction::Finalize(bool consent) { | 242 void EchoPrivateGetUserConsentFunction::Finalize(bool consent) { |
| 242 // Consent should not be true if offers redeeming is disabled. | 243 // Consent should not be true if offers redeeming is disabled. |
| 243 CHECK(redeem_offers_allowed_ || !consent); | 244 CHECK(redeem_offers_allowed_ || !consent); |
| 244 results_ = echo_api::GetUserConsent::Results::Create(consent); | 245 results_ = echo_api::GetUserConsent::Results::Create(consent); |
| 245 SendResponse(true); | 246 SendResponse(true); |
| 246 | 247 |
| 247 // Release the reference added in |OnRedeemOffersAllowedChecked|, before | 248 // Release the reference added in |OnRedeemOffersAllowedChecked|, before |
| 248 // showing the dialog. | 249 // showing the dialog. |
| 249 Release(); | 250 Release(); |
| 250 } | 251 } |
| OLD | NEW |