| OLD | NEW |
| 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 "Change Picture" subpage of | 6 * @fileoverview A helper object used from the "Change Picture" subpage of |
| 7 * the People section to interact with the browser. ChromeOS only. | 7 * the People section to interact with the browser. ChromeOS only. |
| 8 */ | 8 */ |
| 9 cr.exportPath('settings'); | 9 cr.exportPath('settings'); |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * An object describing a default image. | 12 * An object describing a default image. |
| 13 * @typedef {{ | 13 * @typedef {{ |
| 14 * author: string, | 14 * author: string, |
| 15 * title: string, | 15 * title: string, |
| 16 * url: string, | 16 * url: string, |
| 17 * website: string | 17 * website: string |
| 18 * }} | 18 * }} |
| 19 */ | 19 */ |
| 20 settings.DefaultImage; | 20 settings.DefaultImage; |
| 21 | 21 |
| 22 cr.define('settings', function() { | 22 cr.define('settings', function() { |
| 23 /** @interface */ | 23 /** @interface */ |
| 24 function ChangePictureBrowserProxy() {} | 24 class ChangePictureBrowserProxy { |
| 25 | |
| 26 ChangePictureBrowserProxy.prototype = { | |
| 27 /** | 25 /** |
| 28 * Retrieves the initial set of default images, profile image, etc. As a | 26 * Retrieves the initial set of default images, profile image, etc. As a |
| 29 * response, the C++ sends these WebUIListener events: | 27 * response, the C++ sends these WebUIListener events: |
| 30 * 'default-images-changed', 'profile-image-changed', 'old-image-changed', | 28 * 'default-images-changed', 'profile-image-changed', 'old-image-changed', |
| 31 * and 'selected-image-changed' | 29 * and 'selected-image-changed' |
| 32 */ | 30 */ |
| 33 initialize: function() {}, | 31 initialize() {} |
| 34 | 32 |
| 35 /** | 33 /** |
| 36 * Sets the user image to one of the default images. As a response, the C++ | 34 * Sets the user image to one of the default images. As a response, the C++ |
| 37 * sends the 'default-images-changed' WebUIListener event. | 35 * sends the 'default-images-changed' WebUIListener event. |
| 38 * @param {string} imageUrl | 36 * @param {string} imageUrl |
| 39 */ | 37 */ |
| 40 selectDefaultImage: function(imageUrl) {}, | 38 selectDefaultImage(imageUrl) {} |
| 41 | 39 |
| 42 /** | 40 /** |
| 43 * Sets the user image to the 'old' image. As a response, the C++ sends the | 41 * Sets the user image to the 'old' image. As a response, the C++ sends the |
| 44 * 'old-image-changed' WebUIListener event. | 42 * 'old-image-changed' WebUIListener event. |
| 45 */ | 43 */ |
| 46 selectOldImage: function() {}, | 44 selectOldImage() {} |
| 47 | 45 |
| 48 /** | 46 /** |
| 49 * Sets the user image to the profile image. As a response, the C++ sends | 47 * Sets the user image to the profile image. As a response, the C++ sends |
| 50 * the 'profile-image-changed' WebUIListener event. | 48 * the 'profile-image-changed' WebUIListener event. |
| 51 */ | 49 */ |
| 52 selectProfileImage: function() {}, | 50 selectProfileImage() {} |
| 53 | 51 |
| 54 /** | 52 /** |
| 55 * Provides the taken photo as a data URL to the C++. No response is | 53 * Provides the taken photo as a data URL to the C++. No response is |
| 56 * expected. | 54 * expected. |
| 57 * @param {string} photoDataUrl | 55 * @param {string} photoDataUrl |
| 58 */ | 56 */ |
| 59 photoTaken: function(photoDataUrl) {}, | 57 photoTaken(photoDataUrl) {} |
| 60 | 58 |
| 61 /** | 59 /** |
| 62 * Requests a file chooser to select a new user image. No response is | 60 * Requests a file chooser to select a new user image. No response is |
| 63 * expected. | 61 * expected. |
| 64 */ | 62 */ |
| 65 chooseFile: function() {}, | 63 chooseFile() {} |
| 66 }; | 64 } |
| 67 | 65 |
| 68 /** | 66 /** |
| 69 * @constructor | |
| 70 * @implements {settings.ChangePictureBrowserProxy} | 67 * @implements {settings.ChangePictureBrowserProxy} |
| 71 */ | 68 */ |
| 72 function ChangePictureBrowserProxyImpl() {} | 69 class ChangePictureBrowserProxyImpl { |
| 70 /** @override */ |
| 71 initialize() { |
| 72 chrome.send('onChangePicturePageInitialized'); |
| 73 } |
| 74 |
| 75 /** @override */ |
| 76 selectDefaultImage(imageUrl) { |
| 77 chrome.send('selectImage', [imageUrl, 'default']); |
| 78 } |
| 79 |
| 80 /** @override */ |
| 81 selectOldImage() { |
| 82 chrome.send('selectImage', ['', 'old']); |
| 83 } |
| 84 |
| 85 /** @override */ |
| 86 selectProfileImage() { |
| 87 chrome.send('selectImage', ['', 'profile']); |
| 88 } |
| 89 |
| 90 /** @override */ |
| 91 photoTaken(photoDataUrl) { |
| 92 chrome.send('photoTaken', [photoDataUrl]); |
| 93 } |
| 94 |
| 95 /** @override */ |
| 96 chooseFile() { |
| 97 chrome.send('chooseFile'); |
| 98 } |
| 99 } |
| 100 |
| 73 // The singleton instance_ is replaced with a test version of this wrapper | 101 // The singleton instance_ is replaced with a test version of this wrapper |
| 74 // during testing. | 102 // during testing. |
| 75 cr.addSingletonGetter(ChangePictureBrowserProxyImpl); | 103 cr.addSingletonGetter(ChangePictureBrowserProxyImpl); |
| 76 | 104 |
| 77 ChangePictureBrowserProxyImpl.prototype = { | |
| 78 /** @override */ | |
| 79 initialize: function() { | |
| 80 chrome.send('onChangePicturePageInitialized'); | |
| 81 }, | |
| 82 | |
| 83 /** @override */ | |
| 84 selectDefaultImage: function(imageUrl) { | |
| 85 chrome.send('selectImage', [imageUrl, 'default']); | |
| 86 }, | |
| 87 | |
| 88 /** @override */ | |
| 89 selectOldImage: function() { | |
| 90 chrome.send('selectImage', ['', 'old']); | |
| 91 }, | |
| 92 | |
| 93 /** @override */ | |
| 94 selectProfileImage: function() { | |
| 95 chrome.send('selectImage', ['', 'profile']); | |
| 96 }, | |
| 97 | |
| 98 /** @override */ | |
| 99 photoTaken: function(photoDataUrl) { | |
| 100 chrome.send('photoTaken', [photoDataUrl]); | |
| 101 }, | |
| 102 | |
| 103 /** @override */ | |
| 104 chooseFile: function() { | |
| 105 chrome.send('chooseFile'); | |
| 106 }, | |
| 107 }; | |
| 108 | |
| 109 return { | 105 return { |
| 110 ChangePictureBrowserProxy: ChangePictureBrowserProxy, | 106 ChangePictureBrowserProxy: ChangePictureBrowserProxy, |
| 111 ChangePictureBrowserProxyImpl: ChangePictureBrowserProxyImpl, | 107 ChangePictureBrowserProxyImpl: ChangePictureBrowserProxyImpl, |
| 112 }; | 108 }; |
| 113 }); | 109 }); |
| OLD | NEW |