summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcourage@chromium.org <courage@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-20 23:44:44 +0000
committercourage@chromium.org <courage@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-20 23:44:44 +0000
commit9332044293a666d077a214b735a31ba9f3debed7 (patch)
tree6e25d3d4700c186199e80fd28745e445e0341f01
parent6a09bfd7e92ee13cc52d7e63860d92c73aa308eb (diff)
downloadchromium_src-9332044293a666d077a214b735a31ba9f3debed7.zip
chromium_src-9332044293a666d077a214b735a31ba9f3debed7.tar.gz
chromium_src-9332044293a666d077a214b735a31ba9f3debed7.tar.bz2
Enable identity.email permission and chrome.identity.getProfileUserInfo API in stable
This change makes some small tweaks to identity.email and getProfileUserInfo based on apps-dev feedback, and enables them in stable. The UI string for identity.email now reads "Know your email address". chrome.identity.getProfileUserInfo can be called without the email permission (in which case it returns an ID only). BUG=368343 Review URL: https://codereview.chromium.org/337423002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278867 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd2
-rw-r--r--chrome/browser/extensions/api/identity/identity_api.cc9
-rw-r--r--chrome/browser/extensions/api/identity/identity_apitest.cc43
-rw-r--r--chrome/common/extensions/api/_api_features.json5
-rw-r--r--chrome/common/extensions/api/_permission_features.json2
5 files changed, 50 insertions, 11 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 6ad5876..9f3efbc 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -4366,7 +4366,7 @@ Make sure you do not expose any sensitive information.
Open downloaded files
</message>
<message name="IDS_EXTENSION_PROMPT_WARNING_IDENTITY_EMAIL" desc="Permission string for access to profile email address.">
- View email addresses signed in to your profile
+ Know your email address
</message>
<message name="IDS_EXTENSION_PROMPT_WARNING_WALLPAPER" desc="Permission string for access to wallpaper.">
Change your wallpaper
diff --git a/chrome/browser/extensions/api/identity/identity_api.cc b/chrome/browser/extensions/api/identity/identity_api.cc
index 320a944..710678e 100644
--- a/chrome/browser/extensions/api/identity/identity_api.cc
+++ b/chrome/browser/extensions/api/identity/identity_api.cc
@@ -31,6 +31,8 @@
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_function_dispatcher.h"
#include "extensions/common/extension.h"
+#include "extensions/common/permissions/permission_set.h"
+#include "extensions/common/permissions/permissions_data.h"
#include "google_apis/gaia/gaia_urls.h"
#include "url/gurl.h"
@@ -768,8 +770,11 @@ ExtensionFunction::ResponseAction IdentityGetProfileUserInfoFunction::Run() {
}
api::identity::ProfileUserInfo profile_user_info;
- profile_user_info.email =
- GetProfile()->GetPrefs()->GetString(prefs::kGoogleServicesUsername);
+ if (GetExtension()->permissions_data()->HasAPIPermission(
+ APIPermission::kIdentityEmail)) {
+ profile_user_info.email =
+ GetProfile()->GetPrefs()->GetString(prefs::kGoogleServicesUsername);
+ }
profile_user_info.id =
GetProfile()->GetPrefs()->GetString(prefs::kGoogleServicesUserAccountId);
diff --git a/chrome/browser/extensions/api/identity/identity_apitest.cc b/chrome/browser/extensions/api/identity/identity_apitest.cc
index 7cc798f..737b330 100644
--- a/chrome/browser/extensions/api/identity/identity_apitest.cc
+++ b/chrome/browser/extensions/api/identity/identity_apitest.cc
@@ -595,10 +595,29 @@ class IdentityGetProfileUserInfoFunctionTest : public ExtensionBrowserTest {
utils::RunFunctionAndReturnSingleResult(func.get(), "[]", browser()));
return api::identity::ProfileUserInfo::FromValue(*value.get());
}
+
+ scoped_ptr<api::identity::ProfileUserInfo> RunGetProfileUserInfoWithEmail() {
+ scoped_refptr<IdentityGetProfileUserInfoFunction> func(
+ new IdentityGetProfileUserInfoFunction);
+ func->set_extension(CreateExtensionWithEmailPermission());
+ scoped_ptr<base::Value> value(
+ utils::RunFunctionAndReturnSingleResult(func.get(), "[]", browser()));
+ return api::identity::ProfileUserInfo::FromValue(*value.get());
+ }
+
+ private:
+ scoped_refptr<Extension> CreateExtensionWithEmailPermission() {
+ scoped_ptr<base::DictionaryValue> test_extension_value(
+ utils::ParseDictionary(
+ "{\"name\": \"Test\", \"version\": \"1.0\", "
+ "\"permissions\": [\"identity.email\"]}"));
+ return utils::CreateExtension(test_extension_value.get());
+ }
};
IN_PROC_BROWSER_TEST_F(IdentityGetProfileUserInfoFunctionTest, NotSignedIn) {
- scoped_ptr<api::identity::ProfileUserInfo> info = RunGetProfileUserInfo();
+ scoped_ptr<api::identity::ProfileUserInfo> info =
+ RunGetProfileUserInfoWithEmail();
EXPECT_TRUE(info->email.empty());
EXPECT_TRUE(info->id.empty());
}
@@ -609,11 +628,31 @@ IN_PROC_BROWSER_TEST_F(IdentityGetProfileUserInfoFunctionTest, SignedIn) {
profile()->GetPrefs()
->SetString(prefs::kGoogleServicesUserAccountId, "12345");
- scoped_ptr<api::identity::ProfileUserInfo> info = RunGetProfileUserInfo();
+ scoped_ptr<api::identity::ProfileUserInfo> info =
+ RunGetProfileUserInfoWithEmail();
EXPECT_EQ("president@example.com", info->email);
EXPECT_EQ("12345", info->id);
}
+IN_PROC_BROWSER_TEST_F(IdentityGetProfileUserInfoFunctionTest,
+ NotSignedInNoEmail) {
+ scoped_ptr<api::identity::ProfileUserInfo> info = RunGetProfileUserInfo();
+ EXPECT_TRUE(info->email.empty());
+ EXPECT_TRUE(info->id.empty());
+}
+
+IN_PROC_BROWSER_TEST_F(IdentityGetProfileUserInfoFunctionTest,
+ SignedInNoEmail) {
+ profile()->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
+ "president@example.com");
+ profile()->GetPrefs()->SetString(prefs::kGoogleServicesUserAccountId,
+ "12345");
+
+ scoped_ptr<api::identity::ProfileUserInfo> info = RunGetProfileUserInfo();
+ EXPECT_TRUE(info->email.empty());
+ EXPECT_EQ("12345", info->id);
+}
+
class GetAuthTokenFunctionTest : public AsyncExtensionBrowserTest {
public:
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
diff --git a/chrome/common/extensions/api/_api_features.json b/chrome/common/extensions/api/_api_features.json
index 317c71f..fd83c02 100644
--- a/chrome/common/extensions/api/_api_features.json
+++ b/chrome/common/extensions/api/_api_features.json
@@ -479,11 +479,6 @@
"dependencies": ["permission:identity"],
"contexts": ["blessed_extension"]
},
- "identity.getProfileUserInfo": {
- "channel": "dev",
- "dependencies": ["permission:identity.email"],
- "contexts": ["blessed_extension"]
- },
"identityPrivate": {
"dependencies": ["permission:identityPrivate"],
"contexts": ["blessed_extension"]
diff --git a/chrome/common/extensions/api/_permission_features.json b/chrome/common/extensions/api/_permission_features.json
index 478e5ac..f85657f 100644
--- a/chrome/common/extensions/api/_permission_features.json
+++ b/chrome/common/extensions/api/_permission_features.json
@@ -519,7 +519,7 @@
"extension_types": ["extension", "platform_app"]
},
"identity.email": {
- "channel": "dev",
+ "channel": "stable",
"extension_types": ["extension", "platform_app"]
},
"identityPrivate": {