OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 cr.exportPath('settings'); |
| 6 |
| 7 /** |
| 8 * An object describing a default image. |
| 9 * @typedef {{ |
| 10 * author: string, |
| 11 * title: string, |
| 12 * url: string, |
| 13 * website: string |
| 14 * }} |
| 15 */ |
| 16 settings.DefaultImage; |
| 17 |
| 18 cr.define('settings', function() { |
| 19 /** |
| 20 * API which encapsulates messaging between JS and C++ for the ChromeOS |
| 21 * Change Picture subpage. |
| 22 * @constructor |
| 23 */ |
| 24 function ChangePicturePrivateApi() {} |
| 25 |
| 26 /** |
| 27 * URLs of special button images. |
| 28 * @enum {string} |
| 29 */ |
| 30 ChangePicturePrivateApi.ButtonImages = { |
| 31 TAKE_PHOTO: 'chrome://theme/IDR_BUTTON_USER_IMAGE_TAKE_PHOTO', |
| 32 CHOOSE_FILE: 'chrome://theme/IDR_BUTTON_USER_IMAGE_CHOOSE_FILE', |
| 33 PROFILE_PICTURE: 'chrome://theme/IDR_PROFILE_PICTURE_LOADING' |
| 34 }; |
| 35 |
| 36 /** |
| 37 * Called from JavaScript. Retrieves the initial set of default images, |
| 38 * profile image, etc. As a response, the C++ calls these ChangePicturePage |
| 39 * methods as callbacks: receiveDefaultImages, receiveOldImage, |
| 40 * receiveProfileImage, and receiveSelectedImage. |
| 41 */ |
| 42 ChangePicturePrivateApi.initialize = function() { |
| 43 chrome.send('onChangePicturePageInitialized'); |
| 44 }; |
| 45 |
| 46 /** |
| 47 * Called from JavaScript. Sets the user image to one of the default images. |
| 48 * As a response, the C++ calls ChangePicturePage.receiveSelectedImage. |
| 49 * @param {string} imageUrl |
| 50 */ |
| 51 ChangePicturePrivateApi.selectDefaultImage = function(imageUrl) { |
| 52 chrome.send('selectImage', [imageUrl, 'default']); |
| 53 }; |
| 54 |
| 55 /** |
| 56 * Called from JavaScript. Sets the user image to the 'old' image. |
| 57 * As a response, the C++ calls ChangePicturePage.receiveSelectedImage. |
| 58 */ |
| 59 ChangePicturePrivateApi.selectOldImage = function() { |
| 60 chrome.send('selectImage', ['', 'old']); |
| 61 }; |
| 62 |
| 63 /** |
| 64 * Called from JavaScript. Sets the user image to the profile image. |
| 65 * As a response, the C++ calls ChangePicturePage.receiveSelectedImage. |
| 66 */ |
| 67 ChangePicturePrivateApi.selectProfileImage = function() { |
| 68 chrome.send('selectImage', ['', 'profile']); |
| 69 }; |
| 70 |
| 71 return { |
| 72 ChangePicturePrivateApi: ChangePicturePrivateApi, |
| 73 }; |
| 74 }); |
OLD | NEW |