OLD | NEW |
1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
5 <title>Register your computer with Google</title> | 5 <title>Register your computer with Google</title> |
6 <style> | 6 <style> |
7 #form { | 7 #form { |
8 position: absolute; | 8 position: absolute; |
9 left: 0; | 9 left: 0; |
10 right: 0; | 10 right: 0; |
11 top: 0; | 11 top: 0; |
12 bottom: 0; | 12 bottom: 0; |
13 overflow: hidden; | 13 overflow: hidden; |
14 width: 100%; | 14 width: 100%; |
15 height: 100%; | 15 height: 100%; |
16 background: -webkit-linear-gradient(#FAFBFB, #CCD1D4); | 16 background: -webkit-linear-gradient(#FAFBFB, #CCD1D4); |
17 } | 17 } |
18 | 18 |
19 </style> | 19 </style> |
20 <script> | 20 <script> |
21 document.addEventListener('DOMContentLoaded', load); | 21 document.addEventListener('DOMContentLoaded', load); |
22 window.addEventListener('message', processMessage); | 22 window.addEventListener('message', processMessage); |
23 var hostPageDomain = 'chrome://register'; | 23 var hostPageDomain = 'chrome://register'; |
24 var registerDoneUrl = 'cros://register/success'; | 24 var registerDoneUrl = 'cros://register/success'; |
25 var registerSkipUrl = 'cros://register/skipped'; | 25 var registerSkipUrl = 'cros://register/skipped'; |
26 var registrationUrl = ''; | 26 var registrationUrl = ''; |
27 | 27 |
28 function load() { | 28 function load() { |
29 chrome.send('getRegistrationUrl', []); | 29 chrome.send('getRegistrationUrl'); |
30 } | 30 } |
31 function $(o) { | 31 function $(o) { |
32 return document.getElementById(o); | 32 return document.getElementById(o); |
33 } | 33 } |
34 | 34 |
35 function processMessage(e) { | 35 function processMessage(e) { |
36 if (e.data.domain != registrationUrl){ | 36 if (e.data.domain != registrationUrl){ |
37 skipRegistration(); | 37 skipRegistration(); |
38 return; | 38 return; |
39 } | 39 } |
40 | 40 |
41 if (e.data.type == 'get_user_info') { | 41 if (e.data.type == 'get_user_info') { |
42 chrome.send('getUserInfo', []); | 42 chrome.send('getUserInfo'); |
43 } else if (e.data.type == 'complete_registration') { | 43 } else if (e.data.type == 'complete_registration') { |
44 location.replace(e.data.payload.registration_status ? registerDoneUrl : | 44 location.replace(e.data.payload.registration_status ? registerDoneUrl : |
45 registerSkipUrl); | 45 registerSkipUrl); |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 function setRegistrationUrl(url) { | 49 function setRegistrationUrl(url) { |
50 registrationUrl = url; | 50 registrationUrl = url; |
51 $('form').contentWindow.location.href = url; | 51 $('form').contentWindow.location.href = url; |
52 } | 52 } |
53 | 53 |
54 function setUserInfo(userInfo) { | 54 function setUserInfo(userInfo) { |
55 var msg = { | 55 var msg = { |
56 type: 'set_user_info', | 56 type: 'set_user_info', |
57 domain: hostPageDomain, | 57 domain: hostPageDomain, |
58 payload: userInfo | 58 payload: userInfo |
59 }; | 59 }; |
60 $('form').contentWindow.postMessage(msg, registrationUrl); | 60 $('form').contentWindow.postMessage(msg, registrationUrl); |
61 } | 61 } |
62 | 62 |
63 // Called by WebUI handler when startup manifest is not defined. | 63 // Called by WebUI handler when startup manifest is not defined. |
64 function skipRegistration() { | 64 function skipRegistration() { |
65 location.replace(registerSkipUrl); | 65 location.replace(registerSkipUrl); |
66 } | 66 } |
67 </script> | 67 </script> |
68 </head> | 68 </head> |
69 <body><iframe id="form" frameborder="0"></iframe></body> | 69 <body><iframe id="form" frameborder="0"></iframe></body> |
70 </html> | 70 </html> |
OLD | NEW |