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

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

Issue 10012051: Add a mode to OAuth2MintTokenFlow that fetches the messages to show to the user. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/common/net/gaia/oauth2_access_token_fetcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/extensions/extension_function_dispatcher.h" 8 #include "chrome/browser/extensions/extension_function_dispatcher.h"
9 #include "chrome/browser/signin/token_service.h" 9 #include "chrome/browser/signin/token_service.h"
10 #include "chrome/browser/signin/token_service_factory.h" 10 #include "chrome/browser/signin/token_service_factory.h"
(...skipping 25 matching lines...) Expand all
36 36
37 if (oauth2_info.scopes.size() == 0) { 37 if (oauth2_info.scopes.size() == 0) {
38 error_ = kInvalidScopes; 38 error_ = kInvalidScopes;
39 return false; 39 return false;
40 } 40 }
41 41
42 AddRef(); // Balanced in OnMintTokenSuccess|Failure. 42 AddRef(); // Balanced in OnMintTokenSuccess|Failure.
43 43
44 TokenService* token_service = TokenServiceFactory::GetForProfile(profile()); 44 TokenService* token_service = TokenServiceFactory::GetForProfile(profile());
45 45
46 flow_.reset( 46 flow_.reset(new OAuth2MintTokenFlow(
47 new OAuth2MintTokenFlow(profile()->GetRequestContext(), this)); 47 profile()->GetRequestContext(),
48 flow_->Start(token_service->GetOAuth2LoginRefreshToken(), 48 this,
49 extension->id(), oauth2_info.client_id, oauth2_info.scopes); 49 OAuth2MintTokenFlow::Parameters(
50 token_service->GetOAuth2LoginRefreshToken(),
51 extension->id(),
52 oauth2_info.client_id,
53 oauth2_info.scopes,
54 OAuth2MintTokenFlow::MODE_MINT_TOKEN_FORCE)));
55 flow_->Start();
50 56
51 return true; 57 return true;
52 } 58 }
53 59
54 void GetAuthTokenFunction::OnMintTokenSuccess(const std::string& access_token) { 60 void GetAuthTokenFunction::OnMintTokenSuccess(const std::string& access_token) {
55 result_.reset(Value::CreateStringValue(access_token)); 61 result_.reset(Value::CreateStringValue(access_token));
56 SendResponse(true); 62 SendResponse(true);
57 Release(); // Balanced in RunImpl. 63 Release(); // Balanced in RunImpl.
58 } 64 }
59 65
60 void GetAuthTokenFunction::OnMintTokenFailure( 66 void GetAuthTokenFunction::OnMintTokenFailure(
61 const GoogleServiceAuthError& error) { 67 const GoogleServiceAuthError& error) {
62 error_ = error.ToString(); 68 error_ = error.ToString();
63 SendResponse(false); 69 SendResponse(false);
64 Release(); // Balanced in RunImpl. 70 Release(); // Balanced in RunImpl.
65 } 71 }
66 72
67 } // namespace extensions 73 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/common/net/gaia/oauth2_access_token_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698