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

Side by Side Diff: chrome/browser/resources/gaia_auth/main.js

Issue 10440061: Remaining style fixes from http://codereview.chromium.org/10443024/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
1 function Authenticator() { 5 function Authenticator() {
2 } 6 }
3 7
4 Authenticator.getInstance = function() { 8 Authenticator.getInstance = function() {
5 if (!Authenticator.instance_) { 9 if (!Authenticator.instance_) {
6 Authenticator.instance_ = new Authenticator(); 10 Authenticator.instance_ = new Authenticator();
7 } 11 }
8 return Authenticator.instance_; 12 return Authenticator.instance_;
9 }; 13 };
10 14
11 Authenticator.prototype = { 15 Authenticator.prototype = {
12 email_: null, 16 email_: null,
13 password_: null, 17 password_: null,
14 attemptToken_: null, 18 attemptToken_: null,
15 19
16 // Input params from extension initialization URL. 20 // Input params from extension initialization URL.
17 inputLang_: undefined, 21 inputLang_: undefined,
18 intputEmail_: undefined, 22 intputEmail_: undefined,
19 23
20 GAIA_PAGE_ORIGIN: 'https://accounts.google.com', 24 GAIA_PAGE_ORIGIN: 'https://accounts.google.com',
21 GAIA_PAGE_PATH: '/ServiceLogin?service=chromeoslogin' + 25 GAIA_PAGE_PATH: '/ServiceLogin?service=chromeoslogin' +
22 '&skipvpage=true&sarp=1&rm=hide' + 26 '&skipvpage=true&sarp=1&rm=hide' +
23 '&continue=chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/' + 27 '&continue=chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/' +
24 'success.html', 28 'success.html',
25 THIS_EXTENSION_ORIGIN: 'chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik', 29 THIS_EXTENSION_ORIGIN: 'chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik',
26 PARENT_PAGE: 'chrome://oobe/', 30 PARENT_PAGE: 'chrome://oobe/',
27 31
28 initialize: function() { 32 initialize: function() {
29 console.log('### Authenticator.initialize');
30
31 var params = getUrlSearchParams(location.search); 33 var params = getUrlSearchParams(location.search);
32 this.gaiaOrigin_ = params['gaiaOrigin'] || this.GAIA_PAGE_ORIGIN; 34 this.gaiaOrigin_ = params['gaiaOrigin'] || this.GAIA_PAGE_ORIGIN;
33 this.gaiaUrlPath_ = params['gaiaUrlPath'] || ''; 35 this.gaiaUrlPath_ = params['gaiaUrlPath'] || '';
34 this.inputLang_ = params['hl']; 36 this.inputLang_ = params['hl'];
35 this.inputEmail_ = params['email']; 37 this.inputEmail_ = params['email'];
36 this.testEmail_ = params['test_email']; 38 this.testEmail_ = params['test_email'];
37 this.testPassword_ = params['test_password']; 39 this.testPassword_ = params['test_password'];
38 40
39 document.addEventListener('DOMContentLoaded', this.onPageLoad.bind(this)); 41 document.addEventListener('DOMContentLoaded', this.onPageLoad.bind(this));
40 }, 42 },
(...skipping 23 matching lines...) Expand all
64 if (this.inputEmail_) 66 if (this.inputEmail_)
65 url += '&Email=' + encodeURIComponent(this.inputEmail_); 67 url += '&Email=' + encodeURIComponent(this.inputEmail_);
66 if (this.testEmail_) 68 if (this.testEmail_)
67 url += '&test_email=' + encodeURIComponent(this.testEmail_); 69 url += '&test_email=' + encodeURIComponent(this.testEmail_);
68 if (this.testPassword_) 70 if (this.testPassword_)
69 url += '&test_pwd=' + encodeURIComponent(this.testPassword_); 71 url += '&test_pwd=' + encodeURIComponent(this.testPassword_);
70 return url; 72 return url;
71 }, 73 },
72 74
73 loadFrame_: function() { 75 loadFrame_: function() {
74 console.log('Authenticator loading GAIA frame from ' + this.getFrameUrl_());
75 $('gaia-frame').src = this.getFrameUrl_(); 76 $('gaia-frame').src = this.getFrameUrl_();
76 }, 77 },
77 78
78 onPageLoad: function(e) { 79 onPageLoad: function(e) {
79 window.addEventListener('message', this.onMessage.bind(this), false); 80 window.addEventListener('message', this.onMessage.bind(this), false);
80 this.loadFrame_(); 81 this.loadFrame_();
81 }, 82 },
82 83
83 onLoginUILoaded: function() { 84 onLoginUILoaded: function() {
84 var msg = { 85 var msg = {
85 'method': 'loginUILoaded' 86 'method': 'loginUILoaded'
86 }; 87 };
87 window.parent.postMessage(msg, this.PARENT_PAGE); 88 window.parent.postMessage(msg, this.PARENT_PAGE);
88 console.log('### Authenticator.onLoginUILoaded.');
89 }, 89 },
90 90
91 onMessage: function(e) { 91 onMessage: function(e) {
92 var msg = e.data; 92 var msg = e.data;
93 console.log('#### Authenticator.onMessage: method=' + msg.method);
94 if (msg.method == 'attemptLogin' && this.isGaiaMessage_(e)) { 93 if (msg.method == 'attemptLogin' && this.isGaiaMessage_(e)) {
95 this.email_ = msg.email; 94 this.email_ = msg.email;
96 this.password_ = msg.password; 95 this.password_ = msg.password;
97 this.attemptToken_ = msg.attemptToken; 96 this.attemptToken_ = msg.attemptToken;
98 } else if (msg.method == 'clearOldAttempts' && this.isGaiaMessage_(e)) { 97 } else if (msg.method == 'clearOldAttempts' && this.isGaiaMessage_(e)) {
99 this.email_ = null; 98 this.email_ = null;
100 this.password_ = null; 99 this.password_ = null;
101 this.attemptToken_ = null; 100 this.attemptToken_ = null;
102 this.onLoginUILoaded(); 101 this.onLoginUILoaded();
103 } else if (msg.method == 'confirmLogin' && this.isInternalMessage_(e)) { 102 } else if (msg.method == 'confirmLogin' && this.isInternalMessage_(e)) {
104 if (this.attemptToken_ == msg.attemptToken) { 103 if (this.attemptToken_ == msg.attemptToken) {
105 var msg = { 104 var msg = {
106 'method': 'completeLogin', 105 'method': 'completeLogin',
107 'email': this.email_, 106 'email': this.email_,
108 'password': this.password_ 107 'password': this.password_
109 }; 108 };
110 window.parent.postMessage(msg, this.PARENT_PAGE); 109 window.parent.postMessage(msg, this.PARENT_PAGE);
111 } else { 110 } else {
112 console.log('#### Authenticator.onMessage: unexpected attemptToken!?'); 111 console.log('#### Authenticator.onMessage: unexpected attemptToken!?');
113 } 112 }
114 } else { 113 } else {
115 console.log('#### Authenticator.onMessage: unknown message + origin!?'); 114 console.log('#### Authenticator.onMessage: unknown message + origin!?');
116 } 115 }
117 } 116 }
118 }; 117 };
119 118
120 console.log('#### main.html start');
121 Authenticator.getInstance().initialize(); 119 Authenticator.getInstance().initialize();
122 120
OLDNEW
« no previous file with comments | « chrome/browser/resources/gaia_auth/main.html ('k') | chrome/browser/resources/gaia_auth/offline.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698