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

Side by Side Diff: chrome/browser/resources/chromeos/backloader/web/cros_validator.js

Issue 10832240: Added background page loader component extension. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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
(Empty)
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
5 function ChromeOSValidator() {
6 }
7
8 ChromeOSValidator.getInstance = function() {
9 if (!ChromeOSValidator.instance_) {
10 ChromeOSValidator.instance_ = new ChromeOSValidator();
11 }
12 return ChromeOSValidator.instance_;
13 };
14
15 ChromeOSValidator.prototype = {
16 LOADER_ORIGIN: 'chrome-extension://nbicjcbcmclhihdkigkjgkgafckdfcom',
17 LOADER_PAGE: '/background.html',
18 callback_: null,
xiyuan 2012/08/16 16:55:38 nit: prefer to use undefined
zel 2012/08/16 17:17:22 Done.
19
20 validate: function(callback) {
21 this.callback_ = callback;
22 var msg = { method: 'validate' };
23 window.parent.postMessage(msg,
24 this.LOADER_ORIGIN + this.LOADER_PAGE);
25 },
26
27 initialize: function() {
28 document.addEventListener('DOMContentLoaded', this.onPageLoad.bind(this));
xiyuan 2012/08/16 16:55:38 This really depends on how ChromeOSValidator is in
zel 2012/08/16 17:17:22 Done.
29 },
30
31 isValidMessage_: function(msg) {
32 return msg.origin == this.LOADER_ORIGIN;
33 },
34
35 onPageLoad: function(e) {
36 window.addEventListener('message', this.onMessage.bind(this), false);
37 },
38
39 onMessage: function(e) {
40 var msg = e.data;
41 if (msg.method == 'validationResults' && this.isValidMessage_(e)) {
42 if (this.callback_)
43 this.callback_(msg.os == 'ChromeOS');
44 } else {
45 console.log('#### ChromeOSValidator.onMessage: unknown message');
46 if (this.callback_)
47 this.callback_(false);
48 }
49 }
50 };
51
52 ChromeOSValidator.getInstance().initialize();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698