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

Unified Diff: chrome/browser/resources/settings/people_page/change_picture_private_api.js

Issue 1575543003: Settings People Revamp: Implement parts of ChromeOS Change Picture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix change_picture_handler to accomodate origin/master changes Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/people_page/change_picture_private_api.js
diff --git a/chrome/browser/resources/settings/people_page/change_picture_private_api.js b/chrome/browser/resources/settings/people_page/change_picture_private_api.js
new file mode 100644
index 0000000000000000000000000000000000000000..208a3cdd5c384ac212704d89bbffb62cb36e9e32
--- /dev/null
+++ b/chrome/browser/resources/settings/people_page/change_picture_private_api.js
@@ -0,0 +1,74 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.exportPath('settings');
+
+/**
+ * An object describing a default image.
+ * @typedef {{
+ * author: string,
+ * title: string,
+ * url: string,
+ * website: string
+ * }}
+ */
+settings.DefaultImage;
+
+cr.define('settings', function() {
+ /**
+ * API which encapsulates messaging between JS and C++ for the ChromeOS
+ * Change Picture subpage.
+ * @constructor
+ */
+ function ChangePicturePrivateApi() {}
+
+ /**
+ * URLs of special button images.
+ * @enum {string}
+ */
+ ChangePicturePrivateApi.ButtonImages = {
+ TAKE_PHOTO: 'chrome://theme/IDR_BUTTON_USER_IMAGE_TAKE_PHOTO',
+ CHOOSE_FILE: 'chrome://theme/IDR_BUTTON_USER_IMAGE_CHOOSE_FILE',
+ PROFILE_PICTURE: 'chrome://theme/IDR_PROFILE_PICTURE_LOADING'
+ };
+
+ /**
+ * Called from JavaScript. Retrieves the initial set of default images,
+ * profile image, etc. As a response, the C++ calls these ChangePicturePage
+ * methods as callbacks: receiveDefaultImages, receiveOldImage,
+ * receiveProfileImage, and receiveSelectedImage.
+ */
+ ChangePicturePrivateApi.initialize = function() {
+ chrome.send('onChangePicturePageInitialized');
+ };
+
+ /**
+ * Called from JavaScript. Sets the user image to one of the default images.
+ * As a response, the C++ calls ChangePicturePage.receiveSelectedImage.
+ * @param {string} imageUrl
+ */
+ ChangePicturePrivateApi.selectDefaultImage = function(imageUrl) {
+ chrome.send('selectImage', [imageUrl, 'default']);
+ };
+
+ /**
+ * Called from JavaScript. Sets the user image to the 'old' image.
+ * As a response, the C++ calls ChangePicturePage.receiveSelectedImage.
+ */
+ ChangePicturePrivateApi.selectOldImage = function() {
+ chrome.send('selectImage', ['', 'old']);
+ };
+
+ /**
+ * Called from JavaScript. Sets the user image to the profile image.
+ * As a response, the C++ calls ChangePicturePage.receiveSelectedImage.
+ */
+ ChangePicturePrivateApi.selectProfileImage = function() {
+ chrome.send('selectImage', ['', 'profile']);
+ };
+
+ return {
+ ChangePicturePrivateApi: ChangePicturePrivateApi,
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698