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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } else if (type == kGroupType) { | 83 } else if (type == kGroupType) { |
84 provider->GetMachineStatistic(chromeos::system::kOffersGroupCodeKey, | 84 provider->GetMachineStatistic(chromeos::system::kOffersGroupCodeKey, |
85 &result); | 85 &result); |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 results_ = echo_api::GetRegistrationCode::Results::Create(result); | 89 results_ = echo_api::GetRegistrationCode::Results::Create(result); |
90 SendResponse(true); | 90 SendResponse(true); |
91 } | 91 } |
92 | 92 |
93 bool EchoPrivateGetRegistrationCodeFunction::RunImpl() { | 93 bool EchoPrivateGetRegistrationCodeFunction::RunSync() { |
94 scoped_ptr<echo_api::GetRegistrationCode::Params> params = | 94 scoped_ptr<echo_api::GetRegistrationCode::Params> params = |
95 echo_api::GetRegistrationCode::Params::Create(*args_); | 95 echo_api::GetRegistrationCode::Params::Create(*args_); |
96 EXTENSION_FUNCTION_VALIDATE(params); | 96 EXTENSION_FUNCTION_VALIDATE(params); |
97 GetRegistrationCode(params->type); | 97 GetRegistrationCode(params->type); |
98 return true; | 98 return true; |
99 } | 99 } |
100 | 100 |
101 EchoPrivateSetOfferInfoFunction::EchoPrivateSetOfferInfoFunction() {} | 101 EchoPrivateSetOfferInfoFunction::EchoPrivateSetOfferInfoFunction() {} |
102 | 102 |
103 EchoPrivateSetOfferInfoFunction::~EchoPrivateSetOfferInfoFunction() {} | 103 EchoPrivateSetOfferInfoFunction::~EchoPrivateSetOfferInfoFunction() {} |
104 | 104 |
105 bool EchoPrivateSetOfferInfoFunction::RunImpl() { | 105 bool EchoPrivateSetOfferInfoFunction::RunSync() { |
106 scoped_ptr<echo_api::SetOfferInfo::Params> params = | 106 scoped_ptr<echo_api::SetOfferInfo::Params> params = |
107 echo_api::SetOfferInfo::Params::Create(*args_); | 107 echo_api::SetOfferInfo::Params::Create(*args_); |
108 EXTENSION_FUNCTION_VALIDATE(params); | 108 EXTENSION_FUNCTION_VALIDATE(params); |
109 | 109 |
110 const std::string& service_id = params->id; | 110 const std::string& service_id = params->id; |
111 base::DictionaryValue* dict = params->offer_info. | 111 base::DictionaryValue* dict = params->offer_info. |
112 additional_properties.DeepCopyWithoutEmptyChildren(); | 112 additional_properties.DeepCopyWithoutEmptyChildren(); |
113 | 113 |
114 PrefService* local_state = g_browser_process->local_state(); | 114 PrefService* local_state = g_browser_process->local_state(); |
115 DictionaryPrefUpdate offer_update(local_state, prefs::kEchoCheckedOffers); | 115 DictionaryPrefUpdate offer_update(local_state, prefs::kEchoCheckedOffers); |
116 offer_update->SetWithoutPathExpansion("echo." + service_id, dict); | 116 offer_update->SetWithoutPathExpansion("echo." + service_id, dict); |
117 return true; | 117 return true; |
118 } | 118 } |
119 | 119 |
120 EchoPrivateGetOfferInfoFunction::EchoPrivateGetOfferInfoFunction() {} | 120 EchoPrivateGetOfferInfoFunction::EchoPrivateGetOfferInfoFunction() {} |
121 | 121 |
122 EchoPrivateGetOfferInfoFunction::~EchoPrivateGetOfferInfoFunction() {} | 122 EchoPrivateGetOfferInfoFunction::~EchoPrivateGetOfferInfoFunction() {} |
123 | 123 |
124 bool EchoPrivateGetOfferInfoFunction::RunImpl() { | 124 bool EchoPrivateGetOfferInfoFunction::RunSync() { |
125 scoped_ptr<echo_api::GetOfferInfo::Params> params = | 125 scoped_ptr<echo_api::GetOfferInfo::Params> params = |
126 echo_api::GetOfferInfo::Params::Create(*args_); | 126 echo_api::GetOfferInfo::Params::Create(*args_); |
127 EXTENSION_FUNCTION_VALIDATE(params); | 127 EXTENSION_FUNCTION_VALIDATE(params); |
128 | 128 |
129 const std::string& service_id = params->id; | 129 const std::string& service_id = params->id; |
130 PrefService* local_state = g_browser_process->local_state(); | 130 PrefService* local_state = g_browser_process->local_state(); |
131 const base::DictionaryValue* offer_infos = local_state-> | 131 const base::DictionaryValue* offer_infos = local_state-> |
132 GetDictionary(prefs::kEchoCheckedOffers); | 132 GetDictionary(prefs::kEchoCheckedOffers); |
133 | 133 |
134 const base::DictionaryValue* offer_info = NULL; | 134 const base::DictionaryValue* offer_info = NULL; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 void EchoPrivateGetUserConsentFunction::Finalize(bool consent) { | 274 void EchoPrivateGetUserConsentFunction::Finalize(bool consent) { |
275 // Consent should not be true if offers redeeming is disabled. | 275 // Consent should not be true if offers redeeming is disabled. |
276 CHECK(redeem_offers_allowed_ || !consent); | 276 CHECK(redeem_offers_allowed_ || !consent); |
277 results_ = echo_api::GetUserConsent::Results::Create(consent); | 277 results_ = echo_api::GetUserConsent::Results::Create(consent); |
278 SendResponse(true); | 278 SendResponse(true); |
279 | 279 |
280 // Release the reference added in |OnRedeemOffersAllowedChecked|, before | 280 // Release the reference added in |OnRedeemOffersAllowedChecked|, before |
281 // showing the dialog. | 281 // showing the dialog. |
282 Release(); | 282 Release(); |
283 } | 283 } |
OLD | NEW |