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 #include <utility> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
11 #include "base/location.h" | 12 #include "base/location.h" |
12 #include "base/prefs/pref_registry_simple.h" | 13 #include "base/prefs/pref_registry_simple.h" |
13 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
14 #include "base/prefs/scoped_user_pref_update.h" | 15 #include "base/prefs/scoped_user_pref_update.h" |
15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 scoped_ptr<echo_api::SetOfferInfo::Params> params = | 97 scoped_ptr<echo_api::SetOfferInfo::Params> params = |
97 echo_api::SetOfferInfo::Params::Create(*args_); | 98 echo_api::SetOfferInfo::Params::Create(*args_); |
98 EXTENSION_FUNCTION_VALIDATE(params); | 99 EXTENSION_FUNCTION_VALIDATE(params); |
99 | 100 |
100 const std::string& service_id = params->id; | 101 const std::string& service_id = params->id; |
101 scoped_ptr<base::DictionaryValue> dict = | 102 scoped_ptr<base::DictionaryValue> dict = |
102 params->offer_info.additional_properties.DeepCopyWithoutEmptyChildren(); | 103 params->offer_info.additional_properties.DeepCopyWithoutEmptyChildren(); |
103 | 104 |
104 PrefService* local_state = g_browser_process->local_state(); | 105 PrefService* local_state = g_browser_process->local_state(); |
105 DictionaryPrefUpdate offer_update(local_state, prefs::kEchoCheckedOffers); | 106 DictionaryPrefUpdate offer_update(local_state, prefs::kEchoCheckedOffers); |
106 offer_update->SetWithoutPathExpansion("echo." + service_id, dict.Pass()); | 107 offer_update->SetWithoutPathExpansion("echo." + service_id, std::move(dict)); |
107 return true; | 108 return true; |
108 } | 109 } |
109 | 110 |
110 EchoPrivateGetOfferInfoFunction::EchoPrivateGetOfferInfoFunction() {} | 111 EchoPrivateGetOfferInfoFunction::EchoPrivateGetOfferInfoFunction() {} |
111 | 112 |
112 EchoPrivateGetOfferInfoFunction::~EchoPrivateGetOfferInfoFunction() {} | 113 EchoPrivateGetOfferInfoFunction::~EchoPrivateGetOfferInfoFunction() {} |
113 | 114 |
114 bool EchoPrivateGetOfferInfoFunction::RunSync() { | 115 bool EchoPrivateGetOfferInfoFunction::RunSync() { |
115 scoped_ptr<echo_api::GetOfferInfo::Params> params = | 116 scoped_ptr<echo_api::GetOfferInfo::Params> params = |
116 echo_api::GetOfferInfo::Params::Create(*args_); | 117 echo_api::GetOfferInfo::Params::Create(*args_); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 void EchoPrivateGetUserConsentFunction::Finalize(bool consent) { | 272 void EchoPrivateGetUserConsentFunction::Finalize(bool consent) { |
272 // Consent should not be true if offers redeeming is disabled. | 273 // Consent should not be true if offers redeeming is disabled. |
273 CHECK(redeem_offers_allowed_ || !consent); | 274 CHECK(redeem_offers_allowed_ || !consent); |
274 results_ = echo_api::GetUserConsent::Results::Create(consent); | 275 results_ = echo_api::GetUserConsent::Results::Create(consent); |
275 SendResponse(true); | 276 SendResponse(true); |
276 | 277 |
277 // Release the reference added in |OnRedeemOffersAllowedChecked|, before | 278 // Release the reference added in |OnRedeemOffersAllowedChecked|, before |
278 // showing the dialog. | 279 // showing the dialog. |
279 Release(); | 280 Release(); |
280 } | 281 } |
OLD | NEW |