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

Side by Side Diff: remoting/webapp/host_controller.js

Issue 15017006: Move test for enabling/disabling It2Me Share button (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nit Created 7 years, 7 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 | « no previous file | remoting/webapp/main.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 'use strict'; 5 'use strict';
6 6
7 /** @suppress {duplicate} */ 7 /** @suppress {duplicate} */
8 var remoting = remoting || {}; 8 var remoting = remoting || {};
9 9
10 /** @constructor */ 10 /** @constructor */
11 remoting.HostController = function() { 11 remoting.HostController = function() {
12 /** @type {remoting.HostController} */ 12 /** @type {remoting.HostController} */
13 var that = this; 13 var that = this;
14 14
15 /** @type {boolean} @private */
16 this.pluginSupported_ = true;
17
18 /** @type {remoting.HostNativeMessaging} @private */ 15 /** @type {remoting.HostNativeMessaging} @private */
19 this.plugin_ = new remoting.HostNativeMessaging(); 16 this.plugin_ = new remoting.HostNativeMessaging();
20 17
21 /** @param {boolean} success */ 18 /** @param {boolean} success */
22 var onNativeMessagingInit = function(success) { 19 var onNativeMessagingInit = function(success) {
23 if (success) { 20 if (success) {
24 console.log('Native Messaging supported.'); 21 console.log('Native Messaging supported.');
25 } else { 22 } else {
26 console.log('Native Messaging unsupported, falling back to NPAPI.'); 23 console.log('Native Messaging unsupported, falling back to NPAPI.');
27 var plugin = remoting.HostSession.createPlugin(); 24 var plugin = remoting.HostSession.createPlugin();
28 that.plugin_ = new remoting.HostPluginWrapper(plugin); 25 that.plugin_ = new remoting.HostPluginWrapper(plugin);
29 /** @type {HTMLElement} @private */ 26 /** @type {HTMLElement} @private */
30 var container = document.getElementById('daemon-plugin-container'); 27 var container = document.getElementById('daemon-plugin-container');
31 container.appendChild(plugin); 28 container.appendChild(plugin);
32 } 29 }
33 30
34 /** @param {string} version */ 31 /** @param {string} version */
35 var printVersion = function(version) { 32 var printVersion = function(version) {
36 if (version == '') { 33 if (version == '') {
37 console.log('Host not installed.'); 34 console.log('Host not installed.');
38 } else { 35 } else {
39 console.log('Host version: ' + version); 36 console.log('Host version: ' + version);
40 } 37 }
41 }; 38 };
42 that.pluginSupported_ = true;
43 try { 39 try {
44 that.plugin_.getDaemonVersion(printVersion); 40 that.plugin_.getDaemonVersion(printVersion);
45 } catch (err) { 41 } catch (err) {
46 console.log('Host version not available.'); 42 console.log('Host version not available.');
47 that.pluginSupported_ = false;
48 } 43 }
49 } 44 }
50 45
51 this.plugin_.initialize(onNativeMessagingInit); 46 this.plugin_.initialize(onNativeMessagingInit);
52 } 47 }
53 48
54 // Note that the values in the enums below are copied from 49 // Note that the values in the enums below are copied from
55 // daemon_controller.h and must be kept in sync. 50 // daemon_controller.h and must be kept in sync.
56 /** @enum {number} */ 51 /** @enum {number} */
57 remoting.HostController.State = { 52 remoting.HostController.State = {
58 NOT_IMPLEMENTED: -1, 53 NOT_IMPLEMENTED: -1,
59 NOT_INSTALLED: 0, 54 NOT_INSTALLED: 0,
60 INSTALLING: 1, 55 INSTALLING: 1,
61 STOPPED: 2, 56 STOPPED: 2,
62 STARTING: 3, 57 STARTING: 3,
63 STARTED: 4, 58 STARTED: 4,
64 STOPPING: 5, 59 STOPPING: 5,
65 UNKNOWN: 6 60 UNKNOWN: 6
66 }; 61 };
67 62
68 /** @enum {number} */ 63 /** @enum {number} */
69 remoting.HostController.AsyncResult = { 64 remoting.HostController.AsyncResult = {
70 OK: 0, 65 OK: 0,
71 FAILED: 1, 66 FAILED: 1,
72 CANCELLED: 2, 67 CANCELLED: 2,
73 FAILED_DIRECTORY: 3 68 FAILED_DIRECTORY: 3
74 }; 69 };
75 70
76 /** 71 /**
77 * Checks whether or not the host plugin is valid.
78 *
79 * @return {boolean} True if the plugin is supported and loaded; false
80 * otherwise.
81 */
82 remoting.HostController.prototype.isPluginSupported = function() {
83 return this.pluginSupported_;
84 };
85
86 /**
87 * @param {function(boolean, boolean, boolean):void} callback Callback to be 72 * @param {function(boolean, boolean, boolean):void} callback Callback to be
88 * called when done. 73 * called when done.
89 */ 74 */
90 remoting.HostController.prototype.getConsent = function(callback) { 75 remoting.HostController.prototype.getConsent = function(callback) {
91 this.plugin_.getUsageStatsConsent(callback); 76 this.plugin_.getUsageStatsConsent(callback);
92 }; 77 };
93 78
94 /** 79 /**
95 * Registers and starts the host. 80 * Registers and starts the host.
96 * 81 *
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 }; 342 };
358 try { 343 try {
359 this.plugin_.getDaemonConfig(onConfig); 344 this.plugin_.getDaemonConfig(onConfig);
360 } catch (err) { 345 } catch (err) {
361 onDone(null); 346 onDone(null);
362 } 347 }
363 }; 348 };
364 349
365 /** @type {remoting.HostController} */ 350 /** @type {remoting.HostController} */
366 remoting.hostController = null; 351 remoting.hostController = null;
OLDNEW
« no previous file with comments | « no previous file | remoting/webapp/main.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698