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

Side by Side Diff: chrome/browser/extensions/api/identity/identity_get_accounts_function.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
« no previous file with comments | « chrome/browser/extensions/api/identity/identity_get_accounts_function.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/api/identity/identity_get_accounts_function. h"
6
7 #include "chrome/browser/extensions/api/identity/identity_api.h"
8 #include "chrome/browser/extensions/api/identity/identity_constants.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/extensions/api/identity.h"
11 #include "components/signin/core/common/profile_management_switches.h"
12
13 namespace extensions {
14
15 IdentityGetAccountsFunction::IdentityGetAccountsFunction() {
16 }
17
18 IdentityGetAccountsFunction::~IdentityGetAccountsFunction() {
19 }
20
21 ExtensionFunction::ResponseAction IdentityGetAccountsFunction::Run() {
22 if (GetProfile()->IsOffTheRecord()) {
23 return RespondNow(Error(identity_constants::kOffTheRecord));
24 }
25
26 std::vector<std::string> gaia_ids =
27 IdentityAPI::GetFactoryInstance()->Get(GetProfile())->GetAccounts();
28 DCHECK(gaia_ids.size() < 2 || switches::IsExtensionsMultiAccount());
29
30 std::unique_ptr<base::ListValue> infos(new base::ListValue());
31
32 for (std::vector<std::string>::const_iterator it = gaia_ids.begin();
33 it != gaia_ids.end();
34 ++it) {
35 api::identity::AccountInfo account_info;
36 account_info.id = *it;
37 infos->Append(account_info.ToValue());
38 }
39
40 return RespondNow(OneArgument(std::move(infos)));
41 }
42
43 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/identity/identity_get_accounts_function.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698