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

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

Issue 10702017: Revert r 144574 "Modify experimental identity flow to display scope descriptions and details." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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
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_install_prompt.h"
9 #include "chrome/browser/extensions/extension_function_dispatcher.h" 8 #include "chrome/browser/extensions/extension_function_dispatcher.h"
10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/signin/token_service.h" 9 #include "chrome/browser/signin/token_service.h"
12 #include "chrome/browser/signin/token_service_factory.h" 10 #include "chrome/browser/signin/token_service_factory.h"
13 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/tab_contents/tab_contents.h" 12 #include "chrome/browser/ui/tab_contents/tab_contents.h"
15 #include "chrome/common/extensions/extension.h" 13 #include "chrome/common/extensions/extension.h"
16 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
17 15
18 namespace extensions { 16 namespace extensions {
19 17
20 namespace { 18 namespace {
21 19
22 const char kInvalidClientId[] = "Invalid OAuth2 Client ID."; 20 const char kInvalidClientId[] = "Invalid OAuth2 Client ID.";
23 const char kInvalidScopes[] = "Invalid OAuth2 scopes."; 21 const char kInvalidScopes[] = "Invalid OAuth2 scopes.";
24 const char kInvalidRedirect[] = "Did not redirect to the right URL."; 22 const char kInvalidRedirect[] = "Did not redirect to the right URL.";
25 const char kAuthFailure[] = "OAuth2 request failed: ";
26 const char kGrantRevoked[] = "OAuth2 not granted or revoked.";
27 23
28 } // namespace 24 } // namespace
29 25
30 GetAuthTokenFunction::GetAuthTokenFunction() {} 26 GetAuthTokenFunction::GetAuthTokenFunction() {}
31 GetAuthTokenFunction::~GetAuthTokenFunction() {} 27 GetAuthTokenFunction::~GetAuthTokenFunction() {}
32 28
33 bool GetAuthTokenFunction::RunImpl() { 29 bool GetAuthTokenFunction::RunImpl() {
34 const Extension* extension = GetExtension(); 30 const Extension* extension = GetExtension();
35 Extension::OAuth2Info oauth2_info = extension->oauth2_info(); 31 Extension::OAuth2Info oauth2_info = extension->oauth2_info();
36 32
(...skipping 12 matching lines...) Expand all
49 TokenService* token_service = TokenServiceFactory::GetForProfile(profile()); 45 TokenService* token_service = TokenServiceFactory::GetForProfile(profile());
50 46
51 flow_.reset(new OAuth2MintTokenFlow( 47 flow_.reset(new OAuth2MintTokenFlow(
52 profile()->GetRequestContext(), 48 profile()->GetRequestContext(),
53 this, 49 this,
54 OAuth2MintTokenFlow::Parameters( 50 OAuth2MintTokenFlow::Parameters(
55 token_service->GetOAuth2LoginRefreshToken(), 51 token_service->GetOAuth2LoginRefreshToken(),
56 extension->id(), 52 extension->id(),
57 oauth2_info.client_id, 53 oauth2_info.client_id,
58 oauth2_info.scopes, 54 oauth2_info.scopes,
59 ExtensionInstallPrompt::ShouldAutomaticallyApproveScopes() ? 55 OAuth2MintTokenFlow::MODE_MINT_TOKEN_FORCE)));
60 OAuth2MintTokenFlow::MODE_MINT_TOKEN_FORCE :
61 OAuth2MintTokenFlow::MODE_MINT_TOKEN_NO_FORCE)));
62 flow_->Start(); 56 flow_->Start();
63 57
64 return true; 58 return true;
65 } 59 }
66 60
67 void GetAuthTokenFunction::OnMintTokenSuccess(const std::string& access_token) { 61 void GetAuthTokenFunction::OnMintTokenSuccess(const std::string& access_token) {
68 result_.reset(Value::CreateStringValue(access_token)); 62 result_.reset(Value::CreateStringValue(access_token));
69 SendResponse(true); 63 SendResponse(true);
70 Release(); // Balanced in RunImpl. 64 Release(); // Balanced in RunImpl.
71 } 65 }
72 66
73 void GetAuthTokenFunction::OnMintTokenFailure( 67 void GetAuthTokenFunction::OnMintTokenFailure(
74 const GoogleServiceAuthError& error) { 68 const GoogleServiceAuthError& error) {
75 error_ = std::string(kAuthFailure) + error.ToString(); 69 error_ = error.ToString();
76 SendResponse(false); 70 SendResponse(false);
77 Release(); // Balanced in RunImpl. 71 Release(); // Balanced in RunImpl.
78 } 72 }
79
80 void GetAuthTokenFunction::OnIssueAdviceSuccess(
81 const IssueAdviceInfo& issue_advice) {
82 // Existing grant was revoked and we used NO_FORCE, so we got info back
83 // instead.
84 error_ = kGrantRevoked;
85
86 // Remove the oauth2 scopes from the extension's granted permissions, if
87 // revoked server-side.
88 scoped_refptr<PermissionSet> scopes =
89 new PermissionSet(GetExtension()->GetActivePermissions()->scopes());
90 profile()->GetExtensionService()->extension_prefs()->RemoveGrantedPermissions(
91 GetExtension()->id(), scopes);
92
93 // TODO(estade): need to prompt the user for scope permissions.
94
95 SendResponse(false);
96 Release(); // Balanced in RunImpl.
97 }
98 73
99 LaunchWebAuthFlowFunction::LaunchWebAuthFlowFunction() {} 74 LaunchWebAuthFlowFunction::LaunchWebAuthFlowFunction() {}
100 LaunchWebAuthFlowFunction::~LaunchWebAuthFlowFunction() {} 75 LaunchWebAuthFlowFunction::~LaunchWebAuthFlowFunction() {}
101 76
102 bool LaunchWebAuthFlowFunction::RunImpl() { 77 bool LaunchWebAuthFlowFunction::RunImpl() {
103 DictionaryValue* arg = NULL; 78 DictionaryValue* arg = NULL;
104 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &arg)); 79 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &arg));
105 80
106 std::string url; 81 std::string url;
107 EXTENSION_FUNCTION_VALIDATE(arg->GetString("url", &url)); 82 EXTENSION_FUNCTION_VALIDATE(arg->GetString("url", &url));
(...skipping 19 matching lines...) Expand all
127 Release(); // Balanced in RunImpl. 102 Release(); // Balanced in RunImpl.
128 } 103 }
129 104
130 void LaunchWebAuthFlowFunction::OnAuthFlowFailure() { 105 void LaunchWebAuthFlowFunction::OnAuthFlowFailure() {
131 error_ = kInvalidRedirect; 106 error_ = kInvalidRedirect;
132 SendResponse(false); 107 SendResponse(false);
133 Release(); // Balanced in RunImpl. 108 Release(); // Balanced in RunImpl.
134 } 109 }
135 110
136 } // namespace extensions 111 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698