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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/chromeos/backloader/scripts/pages.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/chromeos/backloader/web/cros_validator.js
diff --git a/chrome/browser/resources/chromeos/backloader/web/cros_validator.js b/chrome/browser/resources/chromeos/backloader/web/cros_validator.js
new file mode 100644
index 0000000000000000000000000000000000000000..b849fcfe8a6dc4bb7261a660fdcbd183cfc7b061
--- /dev/null
+++ b/chrome/browser/resources/chromeos/backloader/web/cros_validator.js
@@ -0,0 +1,48 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function ChromeOSValidator() {
+}
+
+ChromeOSValidator.getInstance = function() {
+ if (!ChromeOSValidator.instance_) {
+ ChromeOSValidator.instance_ = new ChromeOSValidator();
+ }
+ return ChromeOSValidator.instance_;
+};
+
+ChromeOSValidator.prototype = {
+ LOADER_ORIGIN: 'chrome-extension://nbicjcbcmclhihdkigkjgkgafckdfcom',
+ LOADER_PAGE: '/background.html',
+ callback_: undefined,
+
+ validate: function(callback) {
+ this.callback_ = callback;
+ var msg = { method: 'validate' };
+ window.parent.postMessage(msg,
+ this.LOADER_ORIGIN + this.LOADER_PAGE);
+ },
+
+ initialize: function() {
+ window.addEventListener('message', this.onMessage.bind(this), false);
+ },
+
+ isValidMessage_: function(msg) {
+ return msg.origin == this.LOADER_ORIGIN;
+ },
+
+ onMessage: function(e) {
+ var msg = e.data;
+ if (msg.method == 'validationResults' && this.isValidMessage_(e)) {
+ if (this.callback_)
+ this.callback_(msg.os == 'ChromeOS');
+ } else {
+ console.log('#### ChromeOSValidator.onMessage: unknown message');
+ if (this.callback_)
+ this.callback_(false);
+ }
+ }
+};
+
+ChromeOSValidator.getInstance().initialize();
« 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