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

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
« no previous file with comments | « chrome/browser/resources/chromeos/backloader/scripts/pages.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_: undefined,
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 window.addEventListener('message', this.onMessage.bind(this), false);
29 },
30
31 isValidMessage_: function(msg) {
32 return msg.origin == this.LOADER_ORIGIN;
33 },
34
35 onMessage: function(e) {
36 var msg = e.data;
37 if (msg.method == 'validationResults' && this.isValidMessage_(e)) {
38 if (this.callback_)
39 this.callback_(msg.os == 'ChromeOS');
40 } else {
41 console.log('#### ChromeOSValidator.onMessage: unknown message');
42 if (this.callback_)
43 this.callback_(false);
44 }
45 }
46 };
47
48 ChromeOSValidator.getInstance().initialize();
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/backloader/scripts/pages.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698