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

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

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/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 <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 240 }
241 241
242 void IdentityAPI::OnAccountRemoved(const gaia::AccountIds& ids) { 242 void IdentityAPI::OnAccountRemoved(const gaia::AccountIds& ids) {
243 } 243 }
244 244
245 void IdentityAPI::OnAccountSignInChanged(const gaia::AccountIds& ids, 245 void IdentityAPI::OnAccountSignInChanged(const gaia::AccountIds& ids,
246 bool is_signed_in) { 246 bool is_signed_in) {
247 api::identity::AccountInfo account_info; 247 api::identity::AccountInfo account_info;
248 account_info.id = ids.gaia; 248 account_info.id = ids.gaia;
249 249
250 scoped_ptr<base::ListValue> args = 250 std::unique_ptr<base::ListValue> args =
251 api::identity::OnSignInChanged::Create(account_info, is_signed_in); 251 api::identity::OnSignInChanged::Create(account_info, is_signed_in);
252 scoped_ptr<Event> event(new Event(events::IDENTITY_ON_SIGN_IN_CHANGED, 252 std::unique_ptr<Event> event(
253 api::identity::OnSignInChanged::kEventName, 253 new Event(events::IDENTITY_ON_SIGN_IN_CHANGED,
254 std::move(args), browser_context_)); 254 api::identity::OnSignInChanged::kEventName, std::move(args),
255 browser_context_));
255 256
256 EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event)); 257 EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event));
257 } 258 }
258 259
259 void IdentityAPI::AddShutdownObserver(ShutdownObserver* observer) { 260 void IdentityAPI::AddShutdownObserver(ShutdownObserver* observer) {
260 shutdown_observer_list_.AddObserver(observer); 261 shutdown_observer_list_.AddObserver(observer);
261 } 262 }
262 263
263 void IdentityAPI::RemoveShutdownObserver(ShutdownObserver* observer) { 264 void IdentityAPI::RemoveShutdownObserver(ShutdownObserver* observer) {
264 shutdown_observer_list_.RemoveObserver(observer); 265 shutdown_observer_list_.RemoveObserver(observer);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 "IdentityGetAuthTokenFunction", 320 "IdentityGetAuthTokenFunction",
320 this, 321 this,
321 "extension", 322 "extension",
322 extension()->id()); 323 extension()->id());
323 324
324 if (GetProfile()->IsOffTheRecord()) { 325 if (GetProfile()->IsOffTheRecord()) {
325 error_ = identity_constants::kOffTheRecord; 326 error_ = identity_constants::kOffTheRecord;
326 return false; 327 return false;
327 } 328 }
328 329
329 scoped_ptr<identity::GetAuthToken::Params> params( 330 std::unique_ptr<identity::GetAuthToken::Params> params(
330 identity::GetAuthToken::Params::Create(*args_)); 331 identity::GetAuthToken::Params::Create(*args_));
331 EXTENSION_FUNCTION_VALIDATE(params.get()); 332 EXTENSION_FUNCTION_VALIDATE(params.get());
332 interactive_ = params->details.get() && 333 interactive_ = params->details.get() &&
333 params->details->interactive.get() && 334 params->details->interactive.get() &&
334 *params->details->interactive; 335 *params->details->interactive;
335 336
336 should_prompt_for_scopes_ = interactive_; 337 should_prompt_for_scopes_ = interactive_;
337 should_prompt_for_signin_ = interactive_; 338 should_prompt_for_signin_ = interactive_;
338 339
339 const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension()); 340 const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension());
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 IdentityRemoveCachedAuthTokenFunction:: 926 IdentityRemoveCachedAuthTokenFunction::
926 ~IdentityRemoveCachedAuthTokenFunction() { 927 ~IdentityRemoveCachedAuthTokenFunction() {
927 } 928 }
928 929
929 bool IdentityRemoveCachedAuthTokenFunction::RunSync() { 930 bool IdentityRemoveCachedAuthTokenFunction::RunSync() {
930 if (GetProfile()->IsOffTheRecord()) { 931 if (GetProfile()->IsOffTheRecord()) {
931 error_ = identity_constants::kOffTheRecord; 932 error_ = identity_constants::kOffTheRecord;
932 return false; 933 return false;
933 } 934 }
934 935
935 scoped_ptr<identity::RemoveCachedAuthToken::Params> params( 936 std::unique_ptr<identity::RemoveCachedAuthToken::Params> params(
936 identity::RemoveCachedAuthToken::Params::Create(*args_)); 937 identity::RemoveCachedAuthToken::Params::Create(*args_));
937 EXTENSION_FUNCTION_VALIDATE(params.get()); 938 EXTENSION_FUNCTION_VALIDATE(params.get());
938 IdentityAPI::GetFactoryInstance()->Get(GetProfile())->EraseCachedToken( 939 IdentityAPI::GetFactoryInstance()->Get(GetProfile())->EraseCachedToken(
939 extension()->id(), params->details.token); 940 extension()->id(), params->details.token);
940 return true; 941 return true;
941 } 942 }
942 943
943 IdentityLaunchWebAuthFlowFunction::IdentityLaunchWebAuthFlowFunction() {} 944 IdentityLaunchWebAuthFlowFunction::IdentityLaunchWebAuthFlowFunction() {}
944 945
945 IdentityLaunchWebAuthFlowFunction::~IdentityLaunchWebAuthFlowFunction() { 946 IdentityLaunchWebAuthFlowFunction::~IdentityLaunchWebAuthFlowFunction() {
946 if (auth_flow_) 947 if (auth_flow_)
947 auth_flow_.release()->DetachDelegateAndDelete(); 948 auth_flow_.release()->DetachDelegateAndDelete();
948 } 949 }
949 950
950 bool IdentityLaunchWebAuthFlowFunction::RunAsync() { 951 bool IdentityLaunchWebAuthFlowFunction::RunAsync() {
951 if (GetProfile()->IsOffTheRecord()) { 952 if (GetProfile()->IsOffTheRecord()) {
952 error_ = identity_constants::kOffTheRecord; 953 error_ = identity_constants::kOffTheRecord;
953 return false; 954 return false;
954 } 955 }
955 956
956 scoped_ptr<identity::LaunchWebAuthFlow::Params> params( 957 std::unique_ptr<identity::LaunchWebAuthFlow::Params> params(
957 identity::LaunchWebAuthFlow::Params::Create(*args_)); 958 identity::LaunchWebAuthFlow::Params::Create(*args_));
958 EXTENSION_FUNCTION_VALIDATE(params.get()); 959 EXTENSION_FUNCTION_VALIDATE(params.get());
959 960
960 GURL auth_url(params->details.url); 961 GURL auth_url(params->details.url);
961 WebAuthFlow::Mode mode = 962 WebAuthFlow::Mode mode =
962 params->details.interactive && *params->details.interactive ? 963 params->details.interactive && *params->details.interactive ?
963 WebAuthFlow::INTERACTIVE : WebAuthFlow::SILENT; 964 WebAuthFlow::INTERACTIVE : WebAuthFlow::SILENT;
964 965
965 // Set up acceptable target URLs. (Does not include chrome-extension 966 // Set up acceptable target URLs. (Does not include chrome-extension
966 // scheme for this version of the API.) 967 // scheme for this version of the API.)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 if (redirect_url.GetWithEmptyPath() == final_url_prefix_) { 1015 if (redirect_url.GetWithEmptyPath() == final_url_prefix_) {
1015 SetResult(new base::StringValue(redirect_url.spec())); 1016 SetResult(new base::StringValue(redirect_url.spec()));
1016 SendResponse(true); 1017 SendResponse(true);
1017 if (auth_flow_) 1018 if (auth_flow_)
1018 auth_flow_.release()->DetachDelegateAndDelete(); 1019 auth_flow_.release()->DetachDelegateAndDelete();
1019 Release(); // Balanced in RunAsync. 1020 Release(); // Balanced in RunAsync.
1020 } 1021 }
1021 } 1022 }
1022 1023
1023 } // namespace extensions 1024 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698