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

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

Issue 1163023002: [AppRemoting] Implements LicenseManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's feedback Created 5 years, 6 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
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 * This class implements the functionality that is specific to application 7 * This class implements the functionality that is specific to application
8 * remoting ("AppRemoting" or AR). 8 * remoting ("AppRemoting" or AR).
9 */ 9 */
10 10
11 'use strict'; 11 'use strict';
12 12
13 /** @suppress {duplicate} */ 13 /** @suppress {duplicate} */
14 var remoting = remoting || {}; 14 var remoting = remoting || {};
15 15
16 /** 16 /**
17 * @param {Array<string>} appCapabilities Array of application capabilities. 17 * @param {Array<string>} appCapabilities Array of application capabilities.
18 * @param {remoting.LicenseManager=} opt_licenseManager
18 * @constructor 19 * @constructor
19 * @implements {remoting.ApplicationInterface} 20 * @implements {remoting.ApplicationInterface}
20 * @extends {remoting.Application} 21 * @extends {remoting.Application}
21 */ 22 */
22 remoting.AppRemoting = function(appCapabilities) { 23 remoting.AppRemoting = function(appCapabilities, opt_licenseManager) {
23 base.inherits(this, remoting.Application); 24 base.inherits(this, remoting.Application);
24 25
25 /** @private {remoting.Activity} */ 26 /** @private {remoting.Activity} */
26 this.activity_ = null; 27 this.activity_ = null;
27 28
28 /** @private */ 29 /** @private */
30 this.licenseManager_ = (opt_licenseManager) ?
31 opt_licenseManager :
32 new remoting.GaiaLicenseManager();
33
34 /** @private */
29 this.appCapabilities_ = appCapabilities; 35 this.appCapabilities_ = appCapabilities;
30 }; 36 };
31 37
32 /** 38 /**
33 * @return {string} Application product name to be used in UI. 39 * @return {string} Application product name to be used in UI.
34 * @override {remoting.ApplicationInterface} 40 * @override {remoting.ApplicationInterface}
35 */ 41 */
36 remoting.AppRemoting.prototype.getApplicationName = function() { 42 remoting.AppRemoting.prototype.getApplicationName = function() {
37 var manifest = chrome.runtime.getManifest(); 43 var manifest = chrome.runtime.getManifest();
38 return manifest.name; 44 return manifest.name;
39 }; 45 };
40 46
41 remoting.AppRemoting.prototype.getActivity = function() { 47 remoting.AppRemoting.prototype.getActivity = function() {
42 return this.activity_; 48 return this.activity_;
43 }; 49 };
44 50
45 /** 51 /**
46 * @param {!remoting.Error} error The failure reason. 52 * @param {!remoting.Error} error The failure reason.
47 * @override {remoting.ApplicationInterface} 53 * @override {remoting.ApplicationInterface}
48 */ 54 */
49 remoting.AppRemoting.prototype.signInFailed_ = function(error) { 55 remoting.AppRemoting.prototype.signInFailed_ = function(error) {
50 remoting.MessageWindow.showErrorMessage( 56 remoting.MessageWindow.showErrorMessage(
51 this.getApplicationName(), 57 this.getApplicationName(),
52 chrome.i18n.getMessage(error.getTag())); 58 chrome.i18n.getMessage(error.getTag()));
53 }; 59 };
54 60
55 /** 61 /**
56 * @override {remoting.ApplicationInterface} 62 * @override {remoting.ApplicationInterface}
57 */ 63 */
58 remoting.AppRemoting.prototype.initApplication_ = function() { 64 remoting.AppRemoting.prototype.initApplication_ = function() {};
59 var windowShape = new remoting.WindowShape();
60 windowShape.updateClientWindowShape();
61
62 this.activity_ = new remoting.AppRemotingActivity(this.appCapabilities_, this,
63 windowShape);
64 };
65 65
66 /** 66 /**
67 * @param {string} token An OAuth access token. 67 * @param {string} token An OAuth access token.
68 * @override {remoting.ApplicationInterface} 68 * @override {remoting.ApplicationInterface}
69 */ 69 */
70 remoting.AppRemoting.prototype.startApplication_ = function(token) { 70 remoting.AppRemoting.prototype.startApplication_ = function(token) {
71 this.activity_.start(); 71 var windowShape = new remoting.WindowShape();
72 windowShape.updateClientWindowShape();
73 var that = this;
74
75 this.licenseManager_.getSubscriptionToken(token).then(
76 function(/** string*/ subscriptionToken) {
77 that.activity_ = new remoting.AppRemotingActivity(
78 that.appCapabilities_, that, windowShape, subscriptionToken);
79 that.activity_.start();
80 });
72 }; 81 };
73 82
74 /** 83 /**
75 * @override {remoting.ApplicationInterface} 84 * @override {remoting.ApplicationInterface}
76 */ 85 */
77 remoting.AppRemoting.prototype.exitApplication_ = function() { 86 remoting.AppRemoting.prototype.exitApplication_ = function() {
78 this.activity_.dispose(); 87 this.activity_.dispose();
79 this.closeMainWindow_(); 88 this.closeMainWindow_();
80 }; 89 };
OLDNEW
« no previous file with comments | « remoting/app_remoting_webapp_files.gypi ('k') | remoting/webapp/app_remoting/js/app_remoting_activity.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698