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

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

Issue 2038613003: Revert of ExtensionFunction: don't pass ownership of base::Value by raw pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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>
10 #include <set> 9 #include <set>
11 #include <string> 10 #include <string>
12 #include <utility> 11 #include <utility>
13 #include <vector> 12 #include <vector>
14 13
15 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
16 #include "base/macros.h" 15 #include "base/macros.h"
17 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
18 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 285
287 ExtensionFunction::ResponseAction IdentityGetAccountsFunction::Run() { 286 ExtensionFunction::ResponseAction IdentityGetAccountsFunction::Run() {
288 if (GetProfile()->IsOffTheRecord()) { 287 if (GetProfile()->IsOffTheRecord()) {
289 return RespondNow(Error(identity_constants::kOffTheRecord)); 288 return RespondNow(Error(identity_constants::kOffTheRecord));
290 } 289 }
291 290
292 std::vector<std::string> gaia_ids = 291 std::vector<std::string> gaia_ids =
293 IdentityAPI::GetFactoryInstance()->Get(GetProfile())->GetAccounts(); 292 IdentityAPI::GetFactoryInstance()->Get(GetProfile())->GetAccounts();
294 DCHECK(gaia_ids.size() < 2 || switches::IsExtensionsMultiAccount()); 293 DCHECK(gaia_ids.size() < 2 || switches::IsExtensionsMultiAccount());
295 294
296 std::unique_ptr<base::ListValue> infos(new base::ListValue()); 295 base::ListValue* infos = new base::ListValue();
297 296
298 for (std::vector<std::string>::const_iterator it = gaia_ids.begin(); 297 for (std::vector<std::string>::const_iterator it = gaia_ids.begin();
299 it != gaia_ids.end(); 298 it != gaia_ids.end();
300 ++it) { 299 ++it) {
301 api::identity::AccountInfo account_info; 300 api::identity::AccountInfo account_info;
302 account_info.id = *it; 301 account_info.id = *it;
303 infos->Append(account_info.ToValue().release()); 302 infos->Append(account_info.ToValue().release());
304 } 303 }
305 304
306 return RespondNow(OneArgument(std::move(infos))); 305 return RespondNow(OneArgument(infos));
307 } 306 }
308 307
309 IdentityGetAuthTokenFunction::IdentityGetAuthTokenFunction() 308 IdentityGetAuthTokenFunction::IdentityGetAuthTokenFunction()
310 : OAuth2TokenService::Consumer("extensions_identity_api"), 309 : OAuth2TokenService::Consumer("extensions_identity_api"),
311 interactive_(false), 310 interactive_(false),
312 should_prompt_for_scopes_(false), 311 should_prompt_for_scopes_(false),
313 should_prompt_for_signin_(false) { 312 should_prompt_for_signin_(false) {
314 } 313 }
315 314
316 IdentityGetAuthTokenFunction::~IdentityGetAuthTokenFunction() { 315 IdentityGetAuthTokenFunction::~IdentityGetAuthTokenFunction() {
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 AccountInfo account = 910 AccountInfo account =
912 AccountTrackerServiceFactory::GetForProfile(GetProfile()) 911 AccountTrackerServiceFactory::GetForProfile(GetProfile())
913 ->GetAccountInfo(GetPrimaryAccountId(GetProfile())); 912 ->GetAccountInfo(GetPrimaryAccountId(GetProfile()));
914 api::identity::ProfileUserInfo profile_user_info; 913 api::identity::ProfileUserInfo profile_user_info;
915 if (extension()->permissions_data()->HasAPIPermission( 914 if (extension()->permissions_data()->HasAPIPermission(
916 APIPermission::kIdentityEmail)) { 915 APIPermission::kIdentityEmail)) {
917 profile_user_info.email = account.email; 916 profile_user_info.email = account.email;
918 profile_user_info.id = account.gaia; 917 profile_user_info.id = account.gaia;
919 } 918 }
920 919
921 return RespondNow(OneArgument(profile_user_info.ToValue())); 920 return RespondNow(OneArgument(profile_user_info.ToValue().release()));
922 } 921 }
923 922
924 IdentityRemoveCachedAuthTokenFunction::IdentityRemoveCachedAuthTokenFunction() { 923 IdentityRemoveCachedAuthTokenFunction::IdentityRemoveCachedAuthTokenFunction() {
925 } 924 }
926 925
927 IdentityRemoveCachedAuthTokenFunction:: 926 IdentityRemoveCachedAuthTokenFunction::
928 ~IdentityRemoveCachedAuthTokenFunction() { 927 ~IdentityRemoveCachedAuthTokenFunction() {
929 } 928 }
930 929
931 bool IdentityRemoveCachedAuthTokenFunction::RunSync() { 930 bool IdentityRemoveCachedAuthTokenFunction::RunSync() {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 if (redirect_url.GetWithEmptyPath() == final_url_prefix_) { 1015 if (redirect_url.GetWithEmptyPath() == final_url_prefix_) {
1017 SetResult(base::MakeUnique<base::StringValue>(redirect_url.spec())); 1016 SetResult(base::MakeUnique<base::StringValue>(redirect_url.spec()));
1018 SendResponse(true); 1017 SendResponse(true);
1019 if (auth_flow_) 1018 if (auth_flow_)
1020 auth_flow_.release()->DetachDelegateAndDelete(); 1019 auth_flow_.release()->DetachDelegateAndDelete();
1021 Release(); // Balanced in RunAsync. 1020 Release(); // Balanced in RunAsync.
1022 } 1021 }
1023 } 1022 }
1024 1023
1025 } // namespace extensions 1024 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698