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(chrome.i18n.getMessage); | 75 this.plugin.localize( |
| 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 ); |
76 this.plugin.connect(email, 'oauth2:' + accessToken); | 85 this.plugin.connect(email, 'oauth2:' + accessToken); |
77 }; | 86 }; |
78 | 87 |
79 /** | 88 /** |
80 * Get the access code generated by the host plugin. Valid only after the | 89 * Get the access code generated by the host plugin. Valid only after the |
81 * plugin state is RECEIVED_ACCESS_CODE. | 90 * plugin state is RECEIVED_ACCESS_CODE. |
82 * @return {string} The access code. | 91 * @return {string} The access code. |
83 */ | 92 */ |
84 remoting.HostSession.prototype.getAccessCode = function() { | 93 remoting.HostSession.prototype.getAccessCode = function() { |
85 return this.plugin.accessCode; | 94 return this.plugin.accessCode; |
(...skipping 26 matching lines...) Expand all Loading... |
112 }; | 121 }; |
113 | 122 |
114 | 123 |
115 /** | 124 /** |
116 * Remove the plugin element from the document. | 125 * Remove the plugin element from the document. |
117 * @return {void} Nothing. | 126 * @return {void} Nothing. |
118 */ | 127 */ |
119 remoting.HostSession.prototype.removePlugin = function() { | 128 remoting.HostSession.prototype.removePlugin = function() { |
120 this.plugin.parentNode.removeChild(this.plugin); | 129 this.plugin.parentNode.removeChild(this.plugin); |
121 }; | 130 }; |
OLD | NEW |