OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * Javascript for local_discovery.html, served from chrome://devices/ | 6 * Javascript for local_discovery.html, served from chrome://devices/ |
7 * This is used to show discoverable devices near the user as well as | 7 * This is used to show discoverable devices near the user as well as |
8 * cloud devices registered to them. | 8 * cloud devices registered to them. |
9 * | 9 * |
10 * The object defined in this javascript file listens for callbacks from the | 10 * The object defined in this javascript file listens for callbacks from the |
11 * C++ code saying that a new device is available as well as manages the UI for | 11 * C++ code saying that a new device is available as well as manages the UI for |
12 * registering a device on the local network. | 12 * registering a device on the local network. |
13 */ | 13 */ |
14 | 14 |
15 cr.define('local_discovery', function() { | 15 cr.define('local_discovery', function() { |
16 'use strict'; | 16 'use strict'; |
17 | 17 |
18 /** | |
19 * Prefix for printer management page URLs, relative to base cloud print URL. | |
20 * @type {string} | |
21 */ | |
22 var PRINTER_MANAGEMENT_PAGE_PREFIX = '#printers/'; | |
23 | |
24 // Histogram buckets for UMA tracking. | 18 // Histogram buckets for UMA tracking. |
25 /** @const */ var DEVICES_PAGE_EVENTS = { | 19 /** @const */ var DEVICES_PAGE_EVENTS = { |
26 OPENED: 0, | 20 OPENED: 0, |
27 LOG_IN_STARTED_FROM_REGISTER_PROMO: 1, | 21 LOG_IN_STARTED_FROM_REGISTER_PROMO: 1, |
28 LOG_IN_STARTED_FROM_DEVICE_LIST_PROMO: 2, | 22 LOG_IN_STARTED_FROM_DEVICE_LIST_PROMO: 2, |
29 ADD_PRINTER_CLICKED: 3, | 23 ADD_PRINTER_CLICKED: 3, |
30 REGISTER_CLICKED: 4, | 24 REGISTER_CLICKED: 4, |
31 REGISTER_CONFIRMED: 5, | 25 REGISTER_CONFIRMED: 5, |
32 REGISTER_SUCCESS: 6, | 26 REGISTER_SUCCESS: 6, |
33 REGISTER_CANCEL: 7, | 27 REGISTER_CANCEL: 7, |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 chrome.send('requestPrinterList'); | 437 chrome.send('requestPrinterList'); |
444 } | 438 } |
445 } | 439 } |
446 | 440 |
447 /** | 441 /** |
448 * Go to management page for a cloud device. | 442 * Go to management page for a cloud device. |
449 * @param {string} device_id ID of device. | 443 * @param {string} device_id ID of device. |
450 */ | 444 */ |
451 function manageCloudDevice(device_id) { | 445 function manageCloudDevice(device_id) { |
452 recordUmaEvent(DEVICES_PAGE_EVENTS.MANAGE_CLICKED); | 446 recordUmaEvent(DEVICES_PAGE_EVENTS.MANAGE_CLICKED); |
453 chrome.send('openCloudPrintURL', | 447 chrome.send('openCloudPrintURL', [device_id]); |
454 [PRINTER_MANAGEMENT_PAGE_PREFIX + device_id]); | |
455 } | 448 } |
456 | 449 |
457 /** | 450 /** |
458 * Record an event in the UMA histogram. | 451 * Record an event in the UMA histogram. |
459 * @param {number} eventId The id of the event to be recorded. | 452 * @param {number} eventId The id of the event to be recorded. |
460 * @private | 453 * @private |
461 */ | 454 */ |
462 function recordUmaEvent(eventId) { | 455 function recordUmaEvent(eventId) { |
463 chrome.send('metricsHandler:recordInHistogram', | 456 chrome.send('metricsHandler:recordInHistogram', |
464 ['LocalDiscovery.DevicesPage', eventId, DEVICES_PAGE_EVENTS.MAX_EVENT]); | 457 ['LocalDiscovery.DevicesPage', eventId, DEVICES_PAGE_EVENTS.MAX_EVENT]); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 onCloudDeviceListAvailable: onCloudDeviceListAvailable, | 615 onCloudDeviceListAvailable: onCloudDeviceListAvailable, |
623 onCloudDeviceListUnavailable: onCloudDeviceListUnavailable, | 616 onCloudDeviceListUnavailable: onCloudDeviceListUnavailable, |
624 onDeviceCacheFlushed: onDeviceCacheFlushed, | 617 onDeviceCacheFlushed: onDeviceCacheFlushed, |
625 onRegistrationCanceledPrinter: onRegistrationCanceledPrinter, | 618 onRegistrationCanceledPrinter: onRegistrationCanceledPrinter, |
626 onRegistrationTimeout: onRegistrationTimeout, | 619 onRegistrationTimeout: onRegistrationTimeout, |
627 setUserLoggedIn: setUserLoggedIn, | 620 setUserLoggedIn: setUserLoggedIn, |
628 setupCloudPrintConnectorSection: setupCloudPrintConnectorSection, | 621 setupCloudPrintConnectorSection: setupCloudPrintConnectorSection, |
629 removeCloudPrintConnectorSection: removeCloudPrintConnectorSection | 622 removeCloudPrintConnectorSection: removeCloudPrintConnectorSection |
630 }; | 623 }; |
631 }); | 624 }); |
OLD | NEW |