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

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

Issue 337423002: Enable identity.email permission and chrome.identity.getProfileUserInfo API in stable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update permission string, getProfileUserInfo without email permission 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 13 matching lines...) Expand all
24 #include "chrome/common/extensions/api/identity.h" 24 #include "chrome/common/extensions/api/identity.h"
25 #include "chrome/common/extensions/api/identity/oauth2_manifest_handler.h" 25 #include "chrome/common/extensions/api/identity/oauth2_manifest_handler.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
28 #include "components/signin/core/browser/profile_oauth2_token_service.h" 28 #include "components/signin/core/browser/profile_oauth2_token_service.h"
29 #include "components/signin/core/browser/signin_manager.h" 29 #include "components/signin/core/browser/signin_manager.h"
30 #include "components/signin/core/common/profile_management_switches.h" 30 #include "components/signin/core/common/profile_management_switches.h"
31 #include "extensions/browser/event_router.h" 31 #include "extensions/browser/event_router.h"
32 #include "extensions/browser/extension_function_dispatcher.h" 32 #include "extensions/browser/extension_function_dispatcher.h"
33 #include "extensions/common/extension.h" 33 #include "extensions/common/extension.h"
34 #include "extensions/common/permissions/permission_set.h"
35 #include "extensions/common/permissions/permissions_data.h"
34 #include "google_apis/gaia/gaia_urls.h" 36 #include "google_apis/gaia/gaia_urls.h"
35 #include "url/gurl.h" 37 #include "url/gurl.h"
36 38
37 #if defined(OS_CHROMEOS) 39 #if defined(OS_CHROMEOS)
38 #include "chrome/browser/chromeos/login/users/user_manager.h" 40 #include "chrome/browser/chromeos/login/users/user_manager.h"
39 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 41 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
40 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" 42 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
41 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h " 43 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h "
42 #include "google_apis/gaia/gaia_constants.h" 44 #include "google_apis/gaia/gaia_constants.h"
43 #endif 45 #endif
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 769
768 IdentityGetProfileUserInfoFunction::~IdentityGetProfileUserInfoFunction() { 770 IdentityGetProfileUserInfoFunction::~IdentityGetProfileUserInfoFunction() {
769 } 771 }
770 772
771 ExtensionFunction::ResponseAction IdentityGetProfileUserInfoFunction::Run() { 773 ExtensionFunction::ResponseAction IdentityGetProfileUserInfoFunction::Run() {
772 if (GetProfile()->IsOffTheRecord()) { 774 if (GetProfile()->IsOffTheRecord()) {
773 return RespondNow(Error(identity_constants::kOffTheRecord)); 775 return RespondNow(Error(identity_constants::kOffTheRecord));
774 } 776 }
775 777
776 api::identity::ProfileUserInfo profile_user_info; 778 api::identity::ProfileUserInfo profile_user_info;
777 profile_user_info.email = 779 if (GetExtension()->permissions_data()->HasAPIPermission(
778 GetProfile()->GetPrefs()->GetString(prefs::kGoogleServicesUsername); 780 APIPermission::kIdentityEmail)) {
781 profile_user_info.email =
782 GetProfile()->GetPrefs()->GetString(prefs::kGoogleServicesUsername);
783 }
779 profile_user_info.id = 784 profile_user_info.id =
780 GetProfile()->GetPrefs()->GetString(prefs::kGoogleServicesUserAccountId); 785 GetProfile()->GetPrefs()->GetString(prefs::kGoogleServicesUserAccountId);
781 786
782 return RespondNow(OneArgument(profile_user_info.ToValue().release())); 787 return RespondNow(OneArgument(profile_user_info.ToValue().release()));
783 } 788 }
784 789
785 IdentityRemoveCachedAuthTokenFunction::IdentityRemoveCachedAuthTokenFunction() { 790 IdentityRemoveCachedAuthTokenFunction::IdentityRemoveCachedAuthTokenFunction() {
786 } 791 }
787 792
788 IdentityRemoveCachedAuthTokenFunction:: 793 IdentityRemoveCachedAuthTokenFunction::
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 void IdentityLaunchWebAuthFlowFunction::OnAuthFlowURLChange( 878 void IdentityLaunchWebAuthFlowFunction::OnAuthFlowURLChange(
874 const GURL& redirect_url) { 879 const GURL& redirect_url) {
875 if (redirect_url.GetWithEmptyPath() == final_url_prefix_) { 880 if (redirect_url.GetWithEmptyPath() == final_url_prefix_) {
876 SetResult(new base::StringValue(redirect_url.spec())); 881 SetResult(new base::StringValue(redirect_url.spec()));
877 SendResponse(true); 882 SendResponse(true);
878 Release(); // Balanced in RunAsync. 883 Release(); // Balanced in RunAsync.
879 } 884 }
880 } 885 }
881 886
882 } // namespace extensions 887 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/extensions/api/identity/identity_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698