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

Side by Side Diff: chrome/browser/extensions/api/identity/identity_api.cc

Issue 2671653004: Move impl of identity.GetAccounts() extension API to its own file (Closed)
Patch Set: nit Created 3 years, 10 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/extensions/api/identity/identity_api.h" 5 #include "chrome/browser/extensions/api/identity/identity_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 bool is_signed_in) { 217 bool is_signed_in) {
218 account_tracker_.SetAccountStateForTest(ids, is_signed_in); 218 account_tracker_.SetAccountStateForTest(ids, is_signed_in);
219 } 219 }
220 220
221 template <> 221 template <>
222 void BrowserContextKeyedAPIFactory<IdentityAPI>::DeclareFactoryDependencies() { 222 void BrowserContextKeyedAPIFactory<IdentityAPI>::DeclareFactoryDependencies() {
223 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); 223 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
224 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); 224 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
225 } 225 }
226 226
227 IdentityGetAccountsFunction::IdentityGetAccountsFunction() {
228 }
229
230 IdentityGetAccountsFunction::~IdentityGetAccountsFunction() {
231 }
232
233 ExtensionFunction::ResponseAction IdentityGetAccountsFunction::Run() {
234 if (GetProfile()->IsOffTheRecord()) {
235 return RespondNow(Error(identity_constants::kOffTheRecord));
236 }
237
238 std::vector<std::string> gaia_ids =
239 IdentityAPI::GetFactoryInstance()->Get(GetProfile())->GetAccounts();
240 DCHECK(gaia_ids.size() < 2 || switches::IsExtensionsMultiAccount());
241
242 std::unique_ptr<base::ListValue> infos(new base::ListValue());
243
244 for (std::vector<std::string>::const_iterator it = gaia_ids.begin();
245 it != gaia_ids.end();
246 ++it) {
247 api::identity::AccountInfo account_info;
248 account_info.id = *it;
249 infos->Append(account_info.ToValue());
250 }
251
252 return RespondNow(OneArgument(std::move(infos)));
253 }
254
255 } // namespace extensions 227 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/identity/identity_api.h ('k') | chrome/browser/extensions/api/identity/identity_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698