Chromium Code Reviews| Index: chrome/browser/resources/quota_internals/quota-internals.js |
| diff --git a/chrome/browser/resources/quota_internals/quota-internals.js b/chrome/browser/resources/quota_internals/quota-internals.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8d0f85c252b36e470c630a5c1e0c4deee84ebdd3 |
| --- /dev/null |
| +++ b/chrome/browser/resources/quota_internals/quota-internals.js |
| @@ -0,0 +1,52 @@ |
| +// Copyright (c) 2011 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. |
| + |
| +// require cr.js |
| +// require cr/event_target.js |
| +// require cr/util.js |
| + |
| +cr.define('cr.quota', function() { |
| + 'use strict'; |
| + return { |
| + onAvailableSpaceUpdated: new cr.EventTarget(), |
| + onGlobalDataUpdated: new cr.EventTarget(), |
| + onHostDataUpdated: new cr.EventTarget(), |
| + onOriginDataUpdated: new cr.EventTarget(), |
| + onStatisticsUpdated: new cr.EventTarget(), |
| + |
| + requestData: function() { |
|
Evan Stade
2011/06/04 02:43:17
can you define these function first and then just
tzik
2011/06/06 10:57:44
Done.
|
| + chrome.send('requestData'); |
| + }, |
| + |
| + // Chrome Message Handler |
| + messageHandler_: function(message, detail) { |
|
Evan Stade
2011/06/04 02:43:17
every function needs a comment. Every parameter ne
|
| + var target = null; |
| + switch (message) { |
| + case 'AvailableSpaceUpdated': |
| + target = cr.quota.onAvailableSpaceUpdated; |
| + break; |
| + case 'GlobalDataUpdated': |
| + target = cr.quota.onGlobalDataUpdated; |
| + break; |
| + case 'HostDataUpdated': |
| + target = cr.quota.onHostDataUpdated; |
| + break; |
| + case 'OriginDataUpdated': |
| + target = cr.quota.onOriginDataUpdated; |
| + break; |
| + case 'StatisticsUpdated': |
| + target = cr.quota.onStatisticsUpdated; |
| + break; |
| + default: |
| + console.log('Unknown Message'); |
| + break; |
| + } |
| + var event = cr.doc.createEvent('CustomEvent'); |
| + if (target) { |
| + event.initCustomEvent('update', false, false, detail); |
| + target.dispatchEvent(event); |
| + } |
| + } |
| + }; |
| +}); |