| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 cr.define('options.accounts', function() { | 5 cr.define('options.accounts', function() { |
| 6 const Event = cr.Event; | 6 const Event = cr.Event; |
| 7 | 7 |
| 8 // Email alias only, assuming it's a gmail address. | 8 // Email alias only, assuming it's a gmail address. |
| 9 // e.g. 'john' | 9 // e.g. 'john' |
| 10 // {name: 'john', email: 'john@gmail.com'} | 10 // {name: 'john', email: 'john@gmail.com'} |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 * IMA (Internationalized Email Address). We take only the following chars | 53 * IMA (Internationalized Email Address). We take only the following chars |
| 54 * as valid for an email alias (aka local-part): | 54 * as valid for an email alias (aka local-part): |
| 55 * - Letters: a–z, A–Z | 55 * - Letters: a–z, A–Z |
| 56 * - Digits: 0-9 | 56 * - Digits: 0-9 |
| 57 * - Characters: ! # $ % & ' * + - / = ? ^ _ ` { | } ~ | 57 * - Characters: ! # $ % & ' * + - / = ? ^ _ ` { | } ~ |
| 58 * - Dot: . (Note that we did not cover the cases that dot should not | 58 * - Dot: . (Note that we did not cover the cases that dot should not |
| 59 * appear as first or last character and should not appear two or | 59 * appear as first or last character and should not appear two or |
| 60 * more times in a row.) | 60 * more times in a row.) |
| 61 * | 61 * |
| 62 * @param {string} str A string to parse. | 62 * @param {string} str A string to parse. |
| 63 * @return {Object} User info parsed from the string. | 63 * @return {{name: string, email: string}} User info parsed from the string. |
| 64 */ | 64 */ |
| 65 parse: function(str) { | 65 parse: function(str) { |
| 66 const format1 = new RegExp(format1String); | 66 const format1 = new RegExp(format1String); |
| 67 const format2 = new RegExp(format2String); | 67 const format2 = new RegExp(format2String); |
| 68 const format3 = new RegExp(format3String); | 68 const format3 = new RegExp(format3String); |
| 69 | 69 |
| 70 var matches = format1.exec(str); | 70 var matches = format1.exec(str); |
| 71 if (matches) { | 71 if (matches) { |
| 72 return { | 72 return { |
| 73 name: matches[1], | 73 name: matches[1], |
| 74 email: matches[1] + '@gmail.com', | 74 email: matches[1] + '@gmail.com' |
| 75 owner:false | |
| 76 }; | 75 }; |
| 77 } | 76 } |
| 78 | 77 |
| 79 matches = format2.exec(str); | 78 matches = format2.exec(str); |
| 80 if (matches) { | 79 if (matches) { |
| 81 return { | 80 return { |
| 82 name: matches[1], | 81 name: matches[1], |
| 83 email: matches[1] + '@' + matches[2], | 82 email: matches[1] + '@' + matches[2] |
| 84 owner:false | |
| 85 }; | 83 }; |
| 86 } | 84 } |
| 87 | 85 |
| 88 matches = format3.exec(str); | 86 matches = format3.exec(str); |
| 89 if (matches) { | 87 if (matches) { |
| 90 return { | 88 return { |
| 91 name: matches[1], | 89 name: matches[1], |
| 92 email: matches[2], | 90 email: matches[2] |
| 93 owner:false | |
| 94 }; | 91 }; |
| 95 } | 92 } |
| 96 | 93 |
| 97 return null; | 94 return null; |
| 98 }, | 95 }, |
| 99 | 96 |
| 100 /** | 97 /** |
| 101 * Handler for key press event. | 98 * Handler for key press event. |
| 102 * @private | 99 * @private |
| 103 * @param {!Event} e The keypress event object. | 100 * @param {!Event} e The keypress event object. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 115 this.select(); | 112 this.select(); |
| 116 } | 113 } |
| 117 } | 114 } |
| 118 }; | 115 }; |
| 119 | 116 |
| 120 return { | 117 return { |
| 121 UserNameEdit: UserNameEdit | 118 UserNameEdit: UserNameEdit |
| 122 }; | 119 }; |
| 123 }); | 120 }); |
| 124 | 121 |
| OLD | NEW |