OLD | NEW |
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 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * Class handling creation and teardown of a remoting host session. | 7 * Class handling creation and teardown of a remoting host session. |
8 * | 8 * |
9 * This abstracts a <embed> element and controls the plugin which does the | 9 * This abstracts a <embed> element and controls the plugin which does the |
10 * actual remoting work. There should be no UI code inside this class. It | 10 * actual remoting work. There should be no UI code inside this class. It |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 * to log messages to the debug log. | 65 * to log messages to the debug log. |
66 */ | 66 */ |
67 remoting.HostSession.prototype.createPluginAndConnect = | 67 remoting.HostSession.prototype.createPluginAndConnect = |
68 function(container, email, accessToken, | 68 function(container, email, accessToken, |
69 onNatTraversalPolicyChanged, onStateChanged, logDebugInfo) { | 69 onNatTraversalPolicyChanged, onStateChanged, logDebugInfo) { |
70 this.plugin = remoting.HostSession.createPlugin(); | 70 this.plugin = remoting.HostSession.createPlugin(); |
71 container.appendChild(this.plugin); | 71 container.appendChild(this.plugin); |
72 this.plugin.onNatTraversalPolicyChanged = onNatTraversalPolicyChanged; | 72 this.plugin.onNatTraversalPolicyChanged = onNatTraversalPolicyChanged; |
73 this.plugin.onStateChanged = onStateChanged; | 73 this.plugin.onStateChanged = onStateChanged; |
74 this.plugin.logDebugInfo = logDebugInfo; | 74 this.plugin.logDebugInfo = logDebugInfo; |
75 this.plugin.localize( | 75 this.plugin.localize(chrome.i18n.getMessage); |
76 /** @param {string} id */ | |
77 function(id) { | |
78 // Plugin takes care of string substitution, so we just keep | |
79 // $ placeholders. | |
80 // TODO(sergeyu): Refactor plugin location so that it | |
81 // doesn't need to do any substitutions. crbug.com/132370 . | |
82 return chrome.i18n.getMessage(id, ["$1", "$2", "$3"]); | |
83 } | |
84 ); | |
85 this.plugin.connect(email, 'oauth2:' + accessToken); | 76 this.plugin.connect(email, 'oauth2:' + accessToken); |
86 }; | 77 }; |
87 | 78 |
88 /** | 79 /** |
89 * Get the access code generated by the host plugin. Valid only after the | 80 * Get the access code generated by the host plugin. Valid only after the |
90 * plugin state is RECEIVED_ACCESS_CODE. | 81 * plugin state is RECEIVED_ACCESS_CODE. |
91 * @return {string} The access code. | 82 * @return {string} The access code. |
92 */ | 83 */ |
93 remoting.HostSession.prototype.getAccessCode = function() { | 84 remoting.HostSession.prototype.getAccessCode = function() { |
94 return this.plugin.accessCode; | 85 return this.plugin.accessCode; |
(...skipping 26 matching lines...) Expand all Loading... |
121 }; | 112 }; |
122 | 113 |
123 | 114 |
124 /** | 115 /** |
125 * Remove the plugin element from the document. | 116 * Remove the plugin element from the document. |
126 * @return {void} Nothing. | 117 * @return {void} Nothing. |
127 */ | 118 */ |
128 remoting.HostSession.prototype.removePlugin = function() { | 119 remoting.HostSession.prototype.removePlugin = function() { |
129 this.plugin.parentNode.removeChild(this.plugin); | 120 this.plugin.parentNode.removeChild(this.plugin); |
130 }; | 121 }; |
OLD | NEW |