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

Side by Side Diff: chrome/browser/resources/settings/people_page/manage_profile_browser_proxy.js

Issue 2954863003: MD Settings: Convert all browser proxies to use ES6 class syntax. (Closed)
Patch Set: Remove @constructor annotations. Created 3 years, 5 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 A helper object used from the "Manage Profile" subpage of 6 * @fileoverview A helper object used from the "Manage Profile" subpage of
7 * the People section to interact with the browser. Chrome Browser only. 7 * the People section to interact with the browser. Chrome Browser only.
8 */ 8 */
9 9
10 /** 10 /**
11 * Contains the possible profile shortcut statuses. These strings must be kept 11 * Contains the possible profile shortcut statuses. These strings must be kept
12 * in sync with the C++ Manage Profile handler. 12 * in sync with the C++ Manage Profile handler.
13 * @enum {string} 13 * @enum {string}
14 */ 14 */
15 var ProfileShortcutStatus = { 15 var ProfileShortcutStatus = {
16 PROFILE_SHORTCUT_SETTING_HIDDEN: 'profileShortcutSettingHidden', 16 PROFILE_SHORTCUT_SETTING_HIDDEN: 'profileShortcutSettingHidden',
17 PROFILE_SHORTCUT_NOT_FOUND: 'profileShortcutNotFound', 17 PROFILE_SHORTCUT_NOT_FOUND: 'profileShortcutNotFound',
18 PROFILE_SHORTCUT_FOUND: 'profileShortcutFound', 18 PROFILE_SHORTCUT_FOUND: 'profileShortcutFound',
19 }; 19 };
20 20
21 cr.define('settings', function() { 21 cr.define('settings', function() {
22 /** @interface */ 22 /** @interface */
23 function ManageProfileBrowserProxy() {} 23 class ManageProfileBrowserProxy {
24
25 ManageProfileBrowserProxy.prototype = {
26 /** 24 /**
27 * Gets the available profile icons to choose from. 25 * Gets the available profile icons to choose from.
28 * @return {!Promise<!Array<!AvatarIcon>>} 26 * @return {!Promise<!Array<!AvatarIcon>>}
29 */ 27 */
30 getAvailableIcons: function() {}, 28 getAvailableIcons() {}
31 29
32 /** 30 /**
33 * Sets the profile's icon to the GAIA avatar. 31 * Sets the profile's icon to the GAIA avatar.
34 */ 32 */
35 setProfileIconToGaiaAvatar: function() {}, 33 setProfileIconToGaiaAvatar() {}
36 34
37 /** 35 /**
38 * Sets the profile's icon to one of the default avatars. 36 * Sets the profile's icon to one of the default avatars.
39 * @param {string} iconUrl The new profile URL. 37 * @param {string} iconUrl The new profile URL.
40 */ 38 */
41 setProfileIconToDefaultAvatar: function(iconUrl) {}, 39 setProfileIconToDefaultAvatar(iconUrl) {}
42 40
43 /** 41 /**
44 * Sets the profile's name. 42 * Sets the profile's name.
45 * @param {string} name The new profile name. 43 * @param {string} name The new profile name.
46 */ 44 */
47 setProfileName: function(name) {}, 45 setProfileName(name) {}
48 46
49 /** 47 /**
50 * Returns whether the current profile has a shortcut. 48 * Returns whether the current profile has a shortcut.
51 * @return {!Promise<ProfileShortcutStatus>} 49 * @return {!Promise<ProfileShortcutStatus>}
52 */ 50 */
53 getProfileShortcutStatus: function() {}, 51 getProfileShortcutStatus() {}
54 52
55 /** 53 /**
56 * Adds a shortcut for the current profile. 54 * Adds a shortcut for the current profile.
57 */ 55 */
58 addProfileShortcut: function() {}, 56 addProfileShortcut() {}
59 57
60 /** 58 /**
61 * Removes the shortcut of the current profile. 59 * Removes the shortcut of the current profile.
62 */ 60 */
63 removeProfileShortcut: function() {}, 61 removeProfileShortcut() {}
64 }; 62 }
65 63
66 /** 64 /**
67 * @constructor
68 * @implements {settings.ManageProfileBrowserProxy} 65 * @implements {settings.ManageProfileBrowserProxy}
69 */ 66 */
70 function ManageProfileBrowserProxyImpl() {} 67 class ManageProfileBrowserProxyImpl {
68 /** @override */
69 getAvailableIcons() {
70 return cr.sendWithPromise('getAvailableIcons');
71 }
72
73 /** @override */
74 setProfileIconToGaiaAvatar() {
75 chrome.send('setProfileIconToGaiaAvatar');
76 }
77
78 /** @override */
79 setProfileIconToDefaultAvatar(iconUrl) {
80 chrome.send('setProfileIconToDefaultAvatar', [iconUrl]);
81 }
82
83 /** @override */
84 setProfileName(name) {
85 chrome.send('setProfileName', [name]);
86 }
87
88 /** @override */
89 getProfileShortcutStatus() {
90 return cr.sendWithPromise('requestProfileShortcutStatus');
91 }
92
93 /** @override */
94 addProfileShortcut() {
95 chrome.send('addProfileShortcut');
96 }
97
98 /** @override */
99 removeProfileShortcut() {
100 chrome.send('removeProfileShortcut');
101 }
102 }
103
71 // The singleton instance_ is replaced with a test version of this wrapper 104 // The singleton instance_ is replaced with a test version of this wrapper
72 // during testing. 105 // during testing.
73 cr.addSingletonGetter(ManageProfileBrowserProxyImpl); 106 cr.addSingletonGetter(ManageProfileBrowserProxyImpl);
74 107
75 ManageProfileBrowserProxyImpl.prototype = {
76 /** @override */
77 getAvailableIcons: function() {
78 return cr.sendWithPromise('getAvailableIcons');
79 },
80
81 /** @override */
82 setProfileIconToGaiaAvatar: function() {
83 chrome.send('setProfileIconToGaiaAvatar');
84 },
85
86 /** @override */
87 setProfileIconToDefaultAvatar: function(iconUrl) {
88 chrome.send('setProfileIconToDefaultAvatar', [iconUrl]);
89 },
90
91 /** @override */
92 setProfileName: function(name) {
93 chrome.send('setProfileName', [name]);
94 },
95
96 /** @override */
97 getProfileShortcutStatus: function() {
98 return cr.sendWithPromise('requestProfileShortcutStatus');
99 },
100
101 /** @override */
102 addProfileShortcut: function() {
103 chrome.send('addProfileShortcut');
104 },
105
106 /** @override */
107 removeProfileShortcut: function() {
108 chrome.send('removeProfileShortcut');
109 },
110 };
111
112 return { 108 return {
113 ManageProfileBrowserProxy: ManageProfileBrowserProxy, 109 ManageProfileBrowserProxy: ManageProfileBrowserProxy,
114 ManageProfileBrowserProxyImpl: ManageProfileBrowserProxyImpl, 110 ManageProfileBrowserProxyImpl: ManageProfileBrowserProxyImpl,
115 }; 111 };
116 }); 112 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698