Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: chrome/browser/chromeos/extensions/echo_private_api.cc

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: iwyu fixes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } else if (type == kGroupType) { 75 } else if (type == kGroupType) {
76 provider->GetMachineStatistic(chromeos::system::kOffersGroupCodeKey, 76 provider->GetMachineStatistic(chromeos::system::kOffersGroupCodeKey,
77 &result); 77 &result);
78 } 78 }
79 79
80 results_ = echo_api::GetRegistrationCode::Results::Create(result); 80 results_ = echo_api::GetRegistrationCode::Results::Create(result);
81 SendResponse(true); 81 SendResponse(true);
82 } 82 }
83 83
84 bool EchoPrivateGetRegistrationCodeFunction::RunSync() { 84 bool EchoPrivateGetRegistrationCodeFunction::RunSync() {
85 scoped_ptr<echo_api::GetRegistrationCode::Params> params = 85 std::unique_ptr<echo_api::GetRegistrationCode::Params> params =
86 echo_api::GetRegistrationCode::Params::Create(*args_); 86 echo_api::GetRegistrationCode::Params::Create(*args_);
87 EXTENSION_FUNCTION_VALIDATE(params); 87 EXTENSION_FUNCTION_VALIDATE(params);
88 GetRegistrationCode(params->type); 88 GetRegistrationCode(params->type);
89 return true; 89 return true;
90 } 90 }
91 91
92 EchoPrivateSetOfferInfoFunction::EchoPrivateSetOfferInfoFunction() {} 92 EchoPrivateSetOfferInfoFunction::EchoPrivateSetOfferInfoFunction() {}
93 93
94 EchoPrivateSetOfferInfoFunction::~EchoPrivateSetOfferInfoFunction() {} 94 EchoPrivateSetOfferInfoFunction::~EchoPrivateSetOfferInfoFunction() {}
95 95
96 bool EchoPrivateSetOfferInfoFunction::RunSync() { 96 bool EchoPrivateSetOfferInfoFunction::RunSync() {
97 scoped_ptr<echo_api::SetOfferInfo::Params> params = 97 std::unique_ptr<echo_api::SetOfferInfo::Params> params =
98 echo_api::SetOfferInfo::Params::Create(*args_); 98 echo_api::SetOfferInfo::Params::Create(*args_);
99 EXTENSION_FUNCTION_VALIDATE(params); 99 EXTENSION_FUNCTION_VALIDATE(params);
100 100
101 const std::string& service_id = params->id; 101 const std::string& service_id = params->id;
102 scoped_ptr<base::DictionaryValue> dict = 102 std::unique_ptr<base::DictionaryValue> dict =
103 params->offer_info.additional_properties.DeepCopyWithoutEmptyChildren(); 103 params->offer_info.additional_properties.DeepCopyWithoutEmptyChildren();
104 104
105 PrefService* local_state = g_browser_process->local_state(); 105 PrefService* local_state = g_browser_process->local_state();
106 DictionaryPrefUpdate offer_update(local_state, prefs::kEchoCheckedOffers); 106 DictionaryPrefUpdate offer_update(local_state, prefs::kEchoCheckedOffers);
107 offer_update->SetWithoutPathExpansion("echo." + service_id, std::move(dict)); 107 offer_update->SetWithoutPathExpansion("echo." + service_id, std::move(dict));
108 return true; 108 return true;
109 } 109 }
110 110
111 EchoPrivateGetOfferInfoFunction::EchoPrivateGetOfferInfoFunction() {} 111 EchoPrivateGetOfferInfoFunction::EchoPrivateGetOfferInfoFunction() {}
112 112
113 EchoPrivateGetOfferInfoFunction::~EchoPrivateGetOfferInfoFunction() {} 113 EchoPrivateGetOfferInfoFunction::~EchoPrivateGetOfferInfoFunction() {}
114 114
115 bool EchoPrivateGetOfferInfoFunction::RunSync() { 115 bool EchoPrivateGetOfferInfoFunction::RunSync() {
116 scoped_ptr<echo_api::GetOfferInfo::Params> params = 116 std::unique_ptr<echo_api::GetOfferInfo::Params> params =
117 echo_api::GetOfferInfo::Params::Create(*args_); 117 echo_api::GetOfferInfo::Params::Create(*args_);
118 EXTENSION_FUNCTION_VALIDATE(params); 118 EXTENSION_FUNCTION_VALIDATE(params);
119 119
120 const std::string& service_id = params->id; 120 const std::string& service_id = params->id;
121 PrefService* local_state = g_browser_process->local_state(); 121 PrefService* local_state = g_browser_process->local_state();
122 const base::DictionaryValue* offer_infos = local_state-> 122 const base::DictionaryValue* offer_infos = local_state->
123 GetDictionary(prefs::kEchoCheckedOffers); 123 GetDictionary(prefs::kEchoCheckedOffers);
124 124
125 const base::DictionaryValue* offer_info = NULL; 125 const base::DictionaryValue* offer_info = NULL;
126 if (!offer_infos->GetDictionaryWithoutPathExpansion( 126 if (!offer_infos->GetDictionaryWithoutPathExpansion(
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 chromeos::CrosSettings::Get()->GetBoolean( 224 chromeos::CrosSettings::Get()->GetBoolean(
225 chromeos::kAllowRedeemChromeOsRegistrationOffers, &allow); 225 chromeos::kAllowRedeemChromeOsRegistrationOffers, &allow);
226 226
227 OnRedeemOffersAllowedChecked(allow); 227 OnRedeemOffersAllowedChecked(allow);
228 } 228 }
229 229
230 void EchoPrivateGetUserConsentFunction::OnRedeemOffersAllowedChecked( 230 void EchoPrivateGetUserConsentFunction::OnRedeemOffersAllowedChecked(
231 bool is_allowed) { 231 bool is_allowed) {
232 redeem_offers_allowed_ = is_allowed; 232 redeem_offers_allowed_ = is_allowed;
233 233
234 scoped_ptr<echo_api::GetUserConsent::Params> params = 234 std::unique_ptr<echo_api::GetUserConsent::Params> params =
235 echo_api::GetUserConsent::Params::Create(*args_); 235 echo_api::GetUserConsent::Params::Create(*args_);
236 236
237 // Verify that the passed origin URL is valid. 237 // Verify that the passed origin URL is valid.
238 GURL service_origin = GURL(params->consent_requester.origin); 238 GURL service_origin = GURL(params->consent_requester.origin);
239 if (!service_origin.is_valid()) { 239 if (!service_origin.is_valid()) {
240 error_ = "Invalid origin."; 240 error_ = "Invalid origin.";
241 SendResponse(false); 241 SendResponse(false);
242 return; 242 return;
243 } 243 }
244 244
(...skipping 27 matching lines...) Expand all
272 void EchoPrivateGetUserConsentFunction::Finalize(bool consent) { 272 void EchoPrivateGetUserConsentFunction::Finalize(bool consent) {
273 // Consent should not be true if offers redeeming is disabled. 273 // Consent should not be true if offers redeeming is disabled.
274 CHECK(redeem_offers_allowed_ || !consent); 274 CHECK(redeem_offers_allowed_ || !consent);
275 results_ = echo_api::GetUserConsent::Results::Create(consent); 275 results_ = echo_api::GetUserConsent::Results::Create(consent);
276 SendResponse(true); 276 SendResponse(true);
277 277
278 // Release the reference added in |OnRedeemOffersAllowedChecked|, before 278 // Release the reference added in |OnRedeemOffersAllowedChecked|, before
279 // showing the dialog. 279 // showing the dialog.
280 Release(); 280 Release();
281 } 281 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698