Permalink
Browse files

Munjal's changes for users that aren't signed in

  • Loading branch information...
1 parent ff4867a commit f36c76fb766339da02bcfb6069bd9590e51a979d @ebidel ebidel committed Aug 24, 2012
Showing with 15 additions and 1 deletion.
  1. +14 −1 identity/identity.js
  2. +1 −0 identity/index.html
View
@@ -33,10 +33,19 @@ function onUserInfoFetched(e) {
}
function onGetAuthToken(auth_token) {
+ var userInfoDiv = document.getElementById('user_info');
if (!auth_token) {
- document.getElementById('user_info').innerHTML = "Not signed in to Chrome, Sign in to Chrome first";
+ var signinButton = document.createElement('button');
+ signinButton.id = 'signin';
+ signinButton.appendChild(document.createTextNode('Sign In'));
+ signinButton.onclick = getUserInfoInteractive;
+ userInfoDiv.appendChild(signinButton);
return;
}
+ // Remove the sign in button if it exists.
+ if (userInfoDiv.firstChild) {
+ userInfoDiv.removeChild(userInfoDiv.firstChild);
+ }
// Use the auth token to do an XHR to get the user information.
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://www.googleapis.com/oauth2/v1/userinfo?alt=json');
@@ -49,4 +58,8 @@ function getUserInfo() {
chrome.experimental.identity.getAuthToken({ 'interactive': false }, onGetAuthToken);
}
+function getUserInfoInteractive() {
+ chrome.experimental.identity.getAuthToken({ 'interactive': true }, onGetAuthToken);
+}
+
window.onload = getUserInfo;
View
@@ -5,5 +5,6 @@
</head>
<body>
<div id="user_info"></div>
+ <button id="signin" style="display:none">Sign in</button>
</body>
</html>

0 comments on commit f36c76f

Please sign in to comment.