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

Side by Side Diff: remoting/webapp/base/js/application.js

Issue 1070223003: [Webapp Refactor] Remove remoting.js. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's feedback Created 5 years, 8 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
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/base/js/base.js » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 * Interface abstracting the Application functionality. 7 * Interface abstracting the Application functionality.
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
11 11
12 /** @suppress {duplicate} */ 12 /** @suppress {duplicate} */
13 var remoting = remoting || {}; 13 var remoting = remoting || {};
14 14
15 /** 15 /**
16 * @type {base.EventSourceImpl} An event source object for handling global
17 * events. This is an interim hack. Eventually, we should move
18 * functionalities away from the remoting namespace and into smaller objects.
19 */
20 remoting.testEvents;
21
22 /**
16 * @constructor 23 * @constructor
17 */ 24 */
18 remoting.Application = function() { 25 remoting.Application = function() {
19 // Create global factories. 26 // Create global factories.
20 remoting.ClientPlugin.factory = new remoting.DefaultClientPluginFactory(); 27 remoting.ClientPlugin.factory = new remoting.DefaultClientPluginFactory();
21 remoting.SessionConnector.factory = 28 remoting.SessionConnector.factory =
22 new remoting.DefaultSessionConnectorFactory(); 29 new remoting.DefaultSessionConnectorFactory();
23 30
24 /** @protected {remoting.Application.Mode} */ 31 /** @protected {remoting.Application.Mode} */
25 this.connectionMode_ = remoting.Application.Mode.ME2ME; 32 this.connectionMode_ = remoting.Application.Mode.ME2ME;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 80
74 /** 81 /**
75 * Initialize the application and register all event handlers. After this 82 * Initialize the application and register all event handlers. After this
76 * is called, the app is running and waiting for user events. 83 * is called, the app is running and waiting for user events.
77 */ 84 */
78 remoting.Application.prototype.start = function() { 85 remoting.Application.prototype.start = function() {
79 // TODO(garykac): This should be owned properly rather than living in the 86 // TODO(garykac): This should be owned properly rather than living in the
80 // global 'remoting' namespace. 87 // global 'remoting' namespace.
81 remoting.settings = new remoting.Settings(); 88 remoting.settings = new remoting.Settings();
82 89
83 remoting.initGlobalObjects(); 90 this.initGlobalObjects_();
84 remoting.initIdentity(); 91 remoting.initIdentity();
85 92
86 this.initApplication_(); 93 this.initApplication_();
87 94
88 var that = this; 95 var that = this;
89 remoting.identity.getToken().then( 96 remoting.identity.getToken().then(
90 this.startApplication_.bind(this) 97 this.startApplication_.bind(this)
91 ).catch(function(/** !remoting.Error */ error) { 98 ).catch(function(/** !remoting.Error */ error) {
92 if (error.hasTag(remoting.Error.Tag.CANCELLED)) { 99 if (error.hasTag(remoting.Error.Tag.CANCELLED)) {
93 that.exitApplication_(); 100 that.exitApplication_();
94 } else { 101 } else {
95 that.signInFailed_(error); 102 that.signInFailed_(error);
96 } 103 }
97 }); 104 });
98 }; 105 };
99 106
107 /** @private */
108 remoting.Application.prototype.initGlobalObjects_ = function() {
109 if (base.isAppsV2()) {
110 var htmlNode = /** @type {HTMLElement} */ (document.body.parentNode);
111 htmlNode.classList.add('apps-v2');
112 }
113
114 console.log(this.getExtensionInfo());
115 l10n.localize();
116 var sandbox =
117 /** @type {HTMLIFrameElement} */ (document.getElementById('wcs-sandbox'));
118 remoting.wcsSandbox = new remoting.WcsSandboxContainer(sandbox.contentWindow);
119 remoting.initModalDialogs();
120
121 remoting.testEvents = new base.EventSourceImpl();
122 /** @enum {string} */
123 remoting.testEvents.Names = {
124 uiModeChanged: 'uiModeChanged'
125 };
126 remoting.testEvents.defineEvents(base.values(remoting.testEvents.Names));
127 };
128
129 /**
130 * @return {string} Information about the current extension.
131 */
132 remoting.Application.prototype.getExtensionInfo = function() {
133 var v2OrLegacy = base.isAppsV2() ? " (v2)" : " (legacy)";
134 var manifest = chrome.runtime.getManifest();
135 if (manifest && manifest.version) {
136 var name = this.getApplicationName();
137 return name + ' version: ' + manifest.version + v2OrLegacy;
138 } else {
139 return 'Failed to get product version. Corrupt manifest?';
140 }
141 };
142
100 /** 143 /**
101 * These functions must be overridden in the subclass. 144 * These functions must be overridden in the subclass.
102 */ 145 */
103 146
104 /** @return {string} */ 147 /** @return {string} */
105 remoting.Application.prototype.getApplicationName = function() { 148 remoting.Application.prototype.getApplicationName = function() {
106 base.debug.assert(false, 'Subclass must override'); 149 base.debug.assert(false, 'Subclass must override');
107 }; 150 };
108 151
109 /** 152 /**
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 */ 222 */
180 remoting.ApplicationInterface.prototype.startApplication_ = function(token) {}; 223 remoting.ApplicationInterface.prototype.startApplication_ = function(token) {};
181 224
182 /** 225 /**
183 * Close down the application before exiting. 226 * Close down the application before exiting.
184 */ 227 */
185 remoting.ApplicationInterface.prototype.exitApplication_ = function() {}; 228 remoting.ApplicationInterface.prototype.exitApplication_ = function() {};
186 229
187 /** @type {remoting.Application} */ 230 /** @type {remoting.Application} */
188 remoting.app = null; 231 remoting.app = null;
OLDNEW
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/base/js/base.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698