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

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

Issue 150423003: Add a minimum required version to the webapp manifest to ensure that native messaging is supported. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | « remoting/webapp/appsv2.patch ('k') | remoting/webapp/manifest.json » ('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 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 * @fileoverview 6 * @fileoverview
7 * Class to communicate with the Host components via Native Messaging. 7 * Class to communicate with the Host components via Native Messaging.
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 * @constructor 49 * @constructor
50 */ 50 */
51 remoting.HostNativeMessaging.PendingReply = function(type, onDone, onError) { 51 remoting.HostNativeMessaging.PendingReply = function(type, onDone, onError) {
52 this.type = type; 52 this.type = type;
53 this.onDone = onDone; 53 this.onDone = onDone;
54 this.onError = onError; 54 this.onError = onError;
55 }; 55 };
56 56
57 /** 57 /**
58 * Sets up connection to the Native Messaging host process and exchanges 58 * Sets up connection to the Native Messaging host process and exchanges
59 * 'hello' messages. If Native Messaging is not available or the host 59 * 'hello' messages. Invokes onDone on success and onError on failure (the
60 * process is not installed, this returns false to the callback. 60 * native messaging host is probably not installed).
61 * 61 *
62 * @param {function(): void} onDone Called after successful initialization. 62 * @param {function(): void} onDone Called after successful initialization.
63 * @param {function(remoting.Error): void} onError Called if initialization 63 * @param {function(remoting.Error): void} onError Called if initialization
64 * failed. 64 * failed.
65 * @return {void} Nothing. 65 * @return {void} Nothing.
66 */ 66 */
67 remoting.HostNativeMessaging.prototype.initialize = function(onDone, onError) { 67 remoting.HostNativeMessaging.prototype.initialize = function(onDone, onError) {
68 if (!chrome.runtime.connectNative) {
69 console.log('Native Messaging API not available');
70 onError(remoting.Error.UNEXPECTED);
71 return;
72 }
73
74 // NativeMessaging API exists on Chrome 26.xxx but fails to notify
75 // onDisconnect in the case where the Host components are not installed. Need
76 // to blacklist these versions of Chrome.
77 var majorVersion = navigator.appVersion.match('Chrome/(\\d+)\.')[1];
78 if (!majorVersion || majorVersion <= 26) {
79 console.log('Native Messaging not supported on this version of Chrome');
80 onError(remoting.Error.UNEXPECTED);
81 return;
82 }
83
84 try { 68 try {
85 this.port_ = chrome.runtime.connectNative( 69 this.port_ = chrome.runtime.connectNative(
86 'com.google.chrome.remote_desktop'); 70 'com.google.chrome.remote_desktop');
87 this.port_.onMessage.addListener(this.onIncomingMessage_.bind(this)); 71 this.port_.onMessage.addListener(this.onIncomingMessage_.bind(this));
88 this.port_.onDisconnect.addListener(this.onDisconnect_.bind(this)); 72 this.port_.onDisconnect.addListener(this.onDisconnect_.bind(this));
89 this.postMessage_({type: 'hello'}, onDone, 73 this.postMessage_({type: 'hello'}, onDone,
90 onError.bind(null, remoting.Error.UNEXPECTED)); 74 onError.bind(null, remoting.Error.UNEXPECTED));
91 } catch (err) { 75 } catch (err) {
92 console.log('Native Messaging initialization failed: ', 76 console.log('Native Messaging initialization failed: ',
93 /** @type {*} */ (err)); 77 /** @type {*} */ (err));
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 * on error. 589 * on error.
606 * @return {void} Nothing. 590 * @return {void} Nothing.
607 */ 591 */
608 remoting.HostNativeMessaging.prototype.getCredentialsFromAuthCode = 592 remoting.HostNativeMessaging.prototype.getCredentialsFromAuthCode =
609 function(authorizationCode, onDone, onError) { 593 function(authorizationCode, onDone, onError) {
610 this.postMessage_({ 594 this.postMessage_({
611 type: 'getCredentialsFromAuthCode', 595 type: 'getCredentialsFromAuthCode',
612 authorizationCode: authorizationCode 596 authorizationCode: authorizationCode
613 }, onDone, onError); 597 }, onDone, onError);
614 }; 598 };
OLDNEW
« no previous file with comments | « remoting/webapp/appsv2.patch ('k') | remoting/webapp/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698