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 <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 if (oauth2_info.scopes.size() == 0) { | 318 if (oauth2_info.scopes.size() == 0) { |
319 error_ = identity_constants::kInvalidScopes; | 319 error_ = identity_constants::kInvalidScopes; |
320 return false; | 320 return false; |
321 } | 321 } |
322 | 322 |
323 std::set<std::string> scopes(oauth2_info.scopes.begin(), | 323 std::set<std::string> scopes(oauth2_info.scopes.begin(), |
324 oauth2_info.scopes.end()); | 324 oauth2_info.scopes.end()); |
325 | 325 |
326 std::string account_key = GetPrimaryAccountId(GetProfile()); | 326 std::string account_key = GetPrimaryAccountId(GetProfile()); |
327 | 327 |
328 if (params->details->account.get()) { | 328 if (params->details.get() && params->details->account.get()) { |
329 std::string detail_key = | 329 std::string detail_key = |
330 extensions::IdentityAPI::GetFactoryInstance() | 330 extensions::IdentityAPI::GetFactoryInstance() |
331 ->Get(GetProfile()) | 331 ->Get(GetProfile()) |
332 ->FindAccountKeyByGaiaId(params->details->account->id); | 332 ->FindAccountKeyByGaiaId(params->details->account->id); |
333 | 333 |
334 if (detail_key != account_key) { | 334 if (detail_key != account_key) { |
335 if (detail_key.empty() || !switches::IsExtensionsMultiAccount()) { | 335 if (detail_key.empty() || !switches::IsExtensionsMultiAccount()) { |
336 // TODO(courage): should this be a different error? | 336 // TODO(courage): should this be a different error? |
337 error_ = identity_constants::kUserNotSignedIn; | 337 error_ = identity_constants::kUserNotSignedIn; |
338 return false; | 338 return false; |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 void IdentityLaunchWebAuthFlowFunction::OnAuthFlowURLChange( | 855 void IdentityLaunchWebAuthFlowFunction::OnAuthFlowURLChange( |
856 const GURL& redirect_url) { | 856 const GURL& redirect_url) { |
857 if (redirect_url.GetWithEmptyPath() == final_url_prefix_) { | 857 if (redirect_url.GetWithEmptyPath() == final_url_prefix_) { |
858 SetResult(new base::StringValue(redirect_url.spec())); | 858 SetResult(new base::StringValue(redirect_url.spec())); |
859 SendResponse(true); | 859 SendResponse(true); |
860 Release(); // Balanced in RunAsync. | 860 Release(); // Balanced in RunAsync. |
861 } | 861 } |
862 } | 862 } |
863 | 863 |
864 } // namespace extensions | 864 } // namespace extensions |
OLD | NEW |