OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** @suppress {duplicate} */ | 5 /** @suppress {duplicate} */ |
6 var remoting = remoting || {}; | 6 var remoting = remoting || {}; |
7 | 7 |
8 (function() { | 8 (function() { |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 base.dispose(this.networkDetector_); | 47 base.dispose(this.networkDetector_); |
48 this.networkDetector_ = null; | 48 this.networkDetector_ = null; |
49 }; | 49 }; |
50 | 50 |
51 remoting.Me2MeActivity.prototype.start = function() { | 51 remoting.Me2MeActivity.prototype.start = function() { |
52 var webappVersion = chrome.runtime.getManifest().version; | 52 var webappVersion = chrome.runtime.getManifest().version; |
53 var that = this; | 53 var that = this; |
54 | 54 |
55 var Event = remoting.ChromotingEvent; | 55 var Event = remoting.ChromotingEvent; |
56 this.logger_ = this.createLogger_(Event.SessionEntryPoint.CONNECT_BUTTON); | 56 this.logger_ = this.createLogger_(Event.SessionEntryPoint.CONNECT_BUTTON); |
57 this.logger_.logSessionStateChange(Event.SessionState.STARTED, | 57 this.logger_.logSessionStateChange(Event.SessionState.STARTED); |
58 Event.ConnectionError.NONE); | |
59 | |
60 var errorTag = Event.ConnectionError.NONE; | |
61 | 58 |
62 function handleError(/** remoting.Error */ error) { | 59 function handleError(/** remoting.Error */ error) { |
63 if (error.isCancel()) { | 60 if (error.isCancel()) { |
64 remoting.setMode(remoting.AppMode.HOME); | 61 remoting.setMode(remoting.AppMode.HOME); |
65 that.logger_.logSessionStateChange(Event.SessionState.CONNECTION_CANCELED, | 62 that.logger_.logSessionStateChange( |
66 errorTag); | 63 Event.SessionState.CONNECTION_CANCELED); |
67 } else { | 64 } else { |
68 that.logger_.logSessionStateChange(Event.SessionState.CONNECTION_FAILED, | 65 that.logger_.logSessionStateChange( |
69 error.toConnectionError()); | 66 Event.SessionState.CONNECTION_FAILED, error); |
70 that.showErrorMessage_(error); | 67 that.showErrorMessage_(error); |
71 } | 68 } |
72 } | 69 } |
73 | 70 |
74 this.hostUpdateDialog_.showIfNecessary(webappVersion).then(function() { | 71 this.hostUpdateDialog_.showIfNecessary(webappVersion).then(function() { |
75 return that.host_.options.load(); | 72 return that.host_.options.load(); |
76 }).catch(remoting.Error.handler(function(/** remoting.Error */ error) { | 73 }).catch(remoting.Error.handler(function(/** remoting.Error */ error) { |
77 // User cancels out of the Host upgrade dialog. Report it as bad version. | 74 // User cancels out of the Host upgrade dialog. Report it as bad version. |
78 errorTag = Event.ConnectionError.BAD_VERSION; | 75 throw new remoting.Error(remoting.Error.Tag.BAD_VERSION); |
79 throw error; | |
80 })).then( | 76 })).then( |
81 this.connect_.bind(this) | 77 this.connect_.bind(this) |
82 ).catch(remoting.Error.handler(handleError)); | 78 ).catch(remoting.Error.handler(handleError)); |
83 }; | 79 }; |
84 | 80 |
85 remoting.Me2MeActivity.prototype.stop = function() { | 81 remoting.Me2MeActivity.prototype.stop = function() { |
86 if (this.desktopActivity_) { | 82 if (this.desktopActivity_) { |
87 this.desktopActivity_.stop(); | 83 this.desktopActivity_.stop(); |
88 } | 84 } |
89 }; | 85 }; |
(...skipping 21 matching lines...) Expand all Loading... |
111 return logger; | 107 return logger; |
112 }; | 108 }; |
113 | 109 |
114 /** | 110 /** |
115 * @param {remoting.ChromotingEvent.SessionEntryPoint} entryPoint | 111 * @param {remoting.ChromotingEvent.SessionEntryPoint} entryPoint |
116 * @private | 112 * @private |
117 */ | 113 */ |
118 remoting.Me2MeActivity.prototype.reconnect_ = function(entryPoint) { | 114 remoting.Me2MeActivity.prototype.reconnect_ = function(entryPoint) { |
119 this.logger_ = this.createLogger_(entryPoint); | 115 this.logger_ = this.createLogger_(entryPoint); |
120 var Event = remoting.ChromotingEvent; | 116 var Event = remoting.ChromotingEvent; |
121 this.logger_.logSessionStateChange(Event.SessionState.STARTED, | 117 this.logger_.logSessionStateChange(Event.SessionState.STARTED); |
122 Event.ConnectionError.NONE); | |
123 this.connect_(); | 118 this.connect_(); |
124 }; | 119 }; |
125 | 120 |
126 /** | 121 /** |
127 * @private | 122 * @private |
128 */ | 123 */ |
129 remoting.Me2MeActivity.prototype.connect_ = function() { | 124 remoting.Me2MeActivity.prototype.connect_ = function() { |
130 base.dispose(this.desktopActivity_); | 125 base.dispose(this.desktopActivity_); |
131 this.desktopActivity_ = | 126 this.desktopActivity_ = |
132 new remoting.DesktopRemotingActivity(this, this.logger_); | 127 new remoting.DesktopRemotingActivity(this, this.logger_); |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 clientName = 'Linux'; | 412 clientName = 'Linux'; |
418 } else { | 413 } else { |
419 console.log('Unrecognized client platform. Using navigator.platform.'); | 414 console.log('Unrecognized client platform. Using navigator.platform.'); |
420 clientName = navigator.platform; | 415 clientName = navigator.platform; |
421 } | 416 } |
422 plugin.requestPairing(clientName, onPairingComplete); | 417 plugin.requestPairing(clientName, onPairingComplete); |
423 } | 418 } |
424 }; | 419 }; |
425 | 420 |
426 })(); | 421 })(); |
OLD | NEW |