OLD | NEW |
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> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" |
16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
18 #include "base/trace_event/trace_event.h" | 19 #include "base/trace_event/trace_event.h" |
19 #include "base/values.h" | 20 #include "base/values.h" |
20 #include "build/build_config.h" | 21 #include "build/build_config.h" |
21 #include "chrome/browser/app_mode/app_mode_utils.h" | 22 #include "chrome/browser/app_mode/app_mode_utils.h" |
22 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
23 #include "chrome/browser/chrome_notification_types.h" | 24 #include "chrome/browser/chrome_notification_types.h" |
24 #include "chrome/browser/extensions/extension_service.h" | 25 #include "chrome/browser/extensions/extension_service.h" |
25 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 extensions::IdentityAPI::GetFactoryInstance() | 431 extensions::IdentityAPI::GetFactoryInstance() |
431 ->Get(GetProfile()) | 432 ->Get(GetProfile()) |
432 ->RemoveShutdownObserver(this); | 433 ->RemoveShutdownObserver(this); |
433 | 434 |
434 SendResponse(success); | 435 SendResponse(success); |
435 Release(); // Balanced in StartAsyncRun | 436 Release(); // Balanced in StartAsyncRun |
436 } | 437 } |
437 | 438 |
438 void IdentityGetAuthTokenFunction::CompleteFunctionWithResult( | 439 void IdentityGetAuthTokenFunction::CompleteFunctionWithResult( |
439 const std::string& access_token) { | 440 const std::string& access_token) { |
440 | 441 SetResult(base::MakeUnique<base::StringValue>(access_token)); |
441 SetResult(new base::StringValue(access_token)); | |
442 CompleteAsyncRun(true); | 442 CompleteAsyncRun(true); |
443 } | 443 } |
444 | 444 |
445 void IdentityGetAuthTokenFunction::CompleteFunctionWithError( | 445 void IdentityGetAuthTokenFunction::CompleteFunctionWithError( |
446 const std::string& error) { | 446 const std::string& error) { |
447 TRACE_EVENT_ASYNC_STEP_PAST1("identity", | 447 TRACE_EVENT_ASYNC_STEP_PAST1("identity", |
448 "IdentityGetAuthTokenFunction", | 448 "IdentityGetAuthTokenFunction", |
449 this, | 449 this, |
450 "CompleteFunctionWithError", | 450 "CompleteFunctionWithError", |
451 "error", | 451 "error", |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 } | 1006 } |
1007 SendResponse(false); | 1007 SendResponse(false); |
1008 if (auth_flow_) | 1008 if (auth_flow_) |
1009 auth_flow_.release()->DetachDelegateAndDelete(); | 1009 auth_flow_.release()->DetachDelegateAndDelete(); |
1010 Release(); // Balanced in RunAsync. | 1010 Release(); // Balanced in RunAsync. |
1011 } | 1011 } |
1012 | 1012 |
1013 void IdentityLaunchWebAuthFlowFunction::OnAuthFlowURLChange( | 1013 void IdentityLaunchWebAuthFlowFunction::OnAuthFlowURLChange( |
1014 const GURL& redirect_url) { | 1014 const GURL& redirect_url) { |
1015 if (redirect_url.GetWithEmptyPath() == final_url_prefix_) { | 1015 if (redirect_url.GetWithEmptyPath() == final_url_prefix_) { |
1016 SetResult(new base::StringValue(redirect_url.spec())); | 1016 SetResult(base::MakeUnique<base::StringValue>(redirect_url.spec())); |
1017 SendResponse(true); | 1017 SendResponse(true); |
1018 if (auth_flow_) | 1018 if (auth_flow_) |
1019 auth_flow_.release()->DetachDelegateAndDelete(); | 1019 auth_flow_.release()->DetachDelegateAndDelete(); |
1020 Release(); // Balanced in RunAsync. | 1020 Release(); // Balanced in RunAsync. |
1021 } | 1021 } |
1022 } | 1022 } |
1023 | 1023 |
1024 } // namespace extensions | 1024 } // namespace extensions |
OLD | NEW |