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

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

Issue 327403003: Identity API: add chrome.identity.getProfileUserInfo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add identity.email permission to stubs_app Created 6 years, 6 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 <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 757
758 // Component apps using auto_approve may use Chrome's client ID by 758 // Component apps using auto_approve may use Chrome's client ID by
759 // omitting the field. 759 // omitting the field.
760 if (client_id.empty() && GetExtension()->location() == Manifest::COMPONENT && 760 if (client_id.empty() && GetExtension()->location() == Manifest::COMPONENT &&
761 oauth2_info.auto_approve) { 761 oauth2_info.auto_approve) {
762 client_id = GaiaUrls::GetInstance()->oauth2_chrome_client_id(); 762 client_id = GaiaUrls::GetInstance()->oauth2_chrome_client_id();
763 } 763 }
764 return client_id; 764 return client_id;
765 } 765 }
766 766
767 IdentityGetProfileUserInfoFunction::IdentityGetProfileUserInfoFunction() {
768 }
769
770 IdentityGetProfileUserInfoFunction::~IdentityGetProfileUserInfoFunction() {
771 }
772
773 ExtensionFunction::ResponseAction IdentityGetProfileUserInfoFunction::Run() {
774 if (GetProfile()->IsOffTheRecord()) {
775 return RespondNow(Error(identity_constants::kOffTheRecord));
776 }
777
778 api::identity::ProfileUserInfo profile_user_info;
779 profile_user_info.email =
780 GetProfile()->GetPrefs()->GetString(prefs::kGoogleServicesUsername);
781 profile_user_info.id =
782 GetProfile()->GetPrefs()->GetString(prefs::kGoogleServicesUserAccountId);
783
784 return RespondNow(OneArgument(profile_user_info.ToValue().release()));
785 }
786
767 IdentityRemoveCachedAuthTokenFunction::IdentityRemoveCachedAuthTokenFunction() { 787 IdentityRemoveCachedAuthTokenFunction::IdentityRemoveCachedAuthTokenFunction() {
768 } 788 }
769 789
770 IdentityRemoveCachedAuthTokenFunction:: 790 IdentityRemoveCachedAuthTokenFunction::
771 ~IdentityRemoveCachedAuthTokenFunction() { 791 ~IdentityRemoveCachedAuthTokenFunction() {
772 } 792 }
773 793
774 bool IdentityRemoveCachedAuthTokenFunction::RunSync() { 794 bool IdentityRemoveCachedAuthTokenFunction::RunSync() {
775 if (GetProfile()->IsOffTheRecord()) { 795 if (GetProfile()->IsOffTheRecord()) {
776 error_ = identity_constants::kOffTheRecord; 796 error_ = identity_constants::kOffTheRecord;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 void IdentityLaunchWebAuthFlowFunction::OnAuthFlowURLChange( 875 void IdentityLaunchWebAuthFlowFunction::OnAuthFlowURLChange(
856 const GURL& redirect_url) { 876 const GURL& redirect_url) {
857 if (redirect_url.GetWithEmptyPath() == final_url_prefix_) { 877 if (redirect_url.GetWithEmptyPath() == final_url_prefix_) {
858 SetResult(new base::StringValue(redirect_url.spec())); 878 SetResult(new base::StringValue(redirect_url.spec()));
859 SendResponse(true); 879 SendResponse(true);
860 Release(); // Balanced in RunAsync. 880 Release(); // Balanced in RunAsync.
861 } 881 }
862 } 882 }
863 883
864 } // namespace extensions 884 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/identity/identity_api.h ('k') | chrome/browser/extensions/api/identity/identity_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698