Permalink
Browse files

remove dead old PIN code

  • Loading branch information...
1 parent 43332e0 commit 5fff9c79ecde00dcc2d087983af3812dabc88f5e @psawaya psawaya committed Dec 31, 2012
@@ -3,7 +3,6 @@
<script src="../lib/jsuri.js"></script>
<script src="../infobar/manager.js"></script>
<script src="util.js"></script>
-<script src="pin_ui.js"></script>
<script src="browser_action_interface.js"></script>
<script src="clipboard.js"></script>
<script src="infobar_hooks.js"></script>
@@ -16,10 +16,6 @@ var infobarHooks = {
case 'pin_lock':
notificationObj.notification.pin_locked = true;
saveToStorage(notificationObj.notification);
-
- if (loginsLock.type != 'pin') {
- createPIN();
- }
break;
case 'never_for_this_site':
View
@@ -201,18 +201,9 @@ function testInfobarNotification() {
}
//
-// PIN creation and validation
+// PIN validation
//
-// Prompts the user to create a new PIN in a popup window. We should be able to
-// remove this soon, since PIN creation now happens in the first run flow.
-function createPIN() {
- promptUserForPIN("Please enter a 4-digit PIN code to lock your sites.", true, function(newPIN) {
- setAndSavePIN(newPIN);
- });
-}
-
-
function validatePIN(_pin) {
// If there's no PIN set, accept.
if (!loginsLock || !loginsLock.pin) return true;
View
@@ -1,57 +0,0 @@
-/*
-* pin_ui.js
-*
-*
-* Manages PIN entry in popup browser windows (code to do it in iframes is elsewhere, in browser_action.js).
-* Also manages callbacks.
-*
-*/
-
-// Maps popup IDs to callback functions
-var callbackMap = {};
-var lastPopupID = 0;
-
-function promptUserForPIN(prompt,repeat,callback) {
- console.log('promptUserForPIN');
- chrome.windows.create({
- url: '../common/pin_entry.html',
- type: 'popup',
- width: 300,
- height: 300,
- top: screen.height/2 - 300/2,
- left: screen.width/2 - 300/2
- }, function(win) {
- var tabID = win.tabs[0].id;
- // Wait a beat for the page to load.
- setTimeout(function() {
- callbackMap[lastPopupID] = {
- 'callback': callback,
- 'tab_id': tabID
- };
- chrome.tabs.sendMessage(tabID, {
- type: 'set_callbackid',
- callback_id: lastPopupID++
- });
- chrome.tabs.sendMessage(tabID,{
- type: 'set_prompt',
- prompt: prompt,
- repeat: repeat
- });
- },1);
- });
-}
-
-chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
- console.log('What was sent: ',request);
- if (request.type == 'submit_pin') {
- // Callback ID will be missing if the call comes from inside of an iframe.
- // In that case, the PIN entry was created outside of pin_ui.js, and we don't
- // need to do any handling here.
- // FIXME: callback_id is null inside of iframe
- if (request.callback_id === undefined) return;
- chrome.tabs.remove(callbackMap[request.callback_id].tab_id);
- var callbackFunc = callbackMap[request.callback_id].callback;
- if (callbackFunc === undefined) return;
- callbackFunc(request.pin);
- }
-});
@@ -4,7 +4,6 @@
<meta charset="UTF-8">
<link href="../lib/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="/pages/common/x-tags/pin/pin.css" media="screen" />
- <link href="../common/pin_entry.css" rel="stylesheet">
<link href="browser_action.css" rel="stylesheet">
<script src="../lib/jquery.js"></script>
<script src="/pages/common/js/libs/x-tag.js"></script>
View
@@ -1,29 +0,0 @@
-body {
- width:300px;
-}
-
-#pin-entry input {
- font-size:48pt;
- width:50px;
-}
-
-#clipboard-sandbox {
-/* visibility:hidden;*/
- width:1px;
- height:1px;
- opacity:0;
-}
-
-#pin-entry {
- margin-left:auto;
- margin-right:auto;
-}
-
-#pin-repeat-message {
- display:none;
-}
-
-#pin-error-message {
- display:none;
- color:red;
-}
View
@@ -1,29 +0,0 @@
-<!doctype html>
-<html>
-<head>
- <link href="../lib/bootstrap.css" rel="stylesheet">
- <link href="pin_entry.css" rel="stylesheet">
- <script src="../lib/jquery.js"></script>
- <script src="pin_entry.js"></script>
-</head>
-
-<body>
- <div id="pin-entry-message">
-
- </div>
- <div id="pin-repeat-message">
- Please enter your PIN again.
- </div>
- <div id="pin-error-message">
- Those PINs didn't match. Please try entering again.
- </div>
- <div id="pin-entry">
- <input id="digit1" maxlength="1" type="password" tabindex="1"/>
- <input id="digit2" maxlength="1" type="password" tabindex="2"/>
- <input id="digit3" maxlength="1" type="password" tabindex="3"/>
- <input id="digit4" maxlength="1" type="password" tabindex="4"/>
- </div>
- <button id="submit-pin" class="btn" tabindex="5">Submit</button>
-</body>
-
-</html>
View
@@ -1,127 +0,0 @@
-/*
-* pin_entry.js
-*
-*
-* Contains the code that runs inside of the PIN entry interface, either
-* inside of an iframe or a new browser window.
-*
-*/
-
- // PIN the user entered previously.
-var previousPIN = null;
-
-// Should we ask the user to repeat their PIN after entry?
-var repeatPIN = false;
-// Is this the repeat step, or the first time?
-var repeatingPIN = false;
-
-// Callback ID to send back up to pin_ui.js
-var callbackID = null;
-
-var IN_IFRAME = false;
-
-function sendMessage(msg) {
- // console.log('sendMessage: ', msg);
- // Don't use regular window.postMessage if we're running in popup mode.
- if (IN_IFRAME) {
- window.postMessage(msg,'*');
- }
- else {
- chrome.extension.sendMessage(msg);
- }
-}
-
-function initializePINEntry() {
- // Start focus on first PIN digit.
- $('#digit1').focus();
-
- $('input').keypress(function(evt) {
- var input = this;
- // Did the user type a digit?
- if (evt.charCode >= '0'.charCodeAt(0) && evt.charCode <= '9'.charCodeAt(0)) {
- // Wait a beat so that we have what the user entered.
- setTimeout(function() {
- if ($(input).val().length == 1) {
- // Advance focus to the element with the next tabindex.
- $('[tabindex="'+ ($(input).attr('tabindex')+1) + '"]').focus();
- }
- },1);
- }
- else {
- // Make sure this character won't get typed.
- evt.preventDefault();
- }
- });
-
- $('#submit-pin').click(function() {
- // Ensure we have four characters
- if (getEnteredPIN().length != 4) return;
- if (repeatPIN) {
- if (repeatingPIN) {
- if (previousPIN == getEnteredPIN()) {
- submitPIN();
- }
- else {
- $('#pin-repeat-message').hide();
- $('#pin-error-message').show();
- repeatingPIN = false;
- }
- }
- else {
- previousPIN = getEnteredPIN();
- repeatingPIN = true;
- // Show the user the repeat PIN message.
- $('#pin-entry-message').hide();
- $('#pin-repeat-message').show();
- }
- $('input').val('');
- $('#digit1').focus();
- } else {
- submitPIN();
- }
- });
-
- function onMessage(msg) {
- console.log('in pin_entry.js, got message of type ', msg.type, msg);
- switch (msg.type) {
- case 'set_prompt':
- $('#pin-entry-message').html(msg.prompt);
- repeatPIN = Boolean(msg.repeat);
- console.log('repeatPIN = ', repeatPIN);
- break;
- case 'set_callbackid':
- callbackID = msg.callback_id;
- break;
- case 'set_container':
- IN_IFRAME = msg.in_iframe;
- break;
- case 'reset_entry':
- $('input').val('');
- $('#digit1').focus();
- break;
- }
- }
-
- function getEnteredPIN() {
- // Using .get() because jQuery .map returns an object and not an array.
- return $('input').get().map(function(x) { return x.value; } ).join('');
- }
-
- function submitPIN() {
- // We're done, submit the PIN.
- sendMessage({
- 'type': 'submit_pin',
- 'pin': getEnteredPIN(),
- 'callback_id': callbackID
- });
- }
-
- // Attach message handler for both browser chrome and for when
- // we're running in an iframe.
- chrome.extension.onMessage.addListener(onMessage);
- window.addEventListener('message',function(e){
- onMessage(e.data);
- },false);
-};
-
-$(document).ready(initializePINEntry);
@@ -1,4 +1,4 @@
-// TODO: Unite this, common/pin_entry.js, and pages/common/x-tags/pin/pin.js into something
+// TODO: Unite this and pages/common/x-tags/pin/pin.js into something
// reusable and not jQuery dependant.
$(document).ready(function() {
View
@@ -30,9 +30,6 @@
},
"update_url": "http://dev.tobmog.org/downloads/updates.xml",
"web_accessible_resources": [
- "common/pin_entry.html",
- "common/pin_entry.js",
- "common/pin_entry.css",
"infobars/*"
]
}

0 comments on commit 5fff9c7

Please sign in to comment.