diff options
16 files changed, 350 insertions, 0 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 8af9875..ffa572a 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -4541,6 +4541,9 @@ Even if you have downloaded files from this website before, the website might ha <message name="IDS_EXTENSION_PROMPT_WARNING_PASSWORDS_PRIVATE" desc="Permission string for access to passwords settings."> Read and change saved password settings </message> + <message name="IDS_EXTENSION_PROMPT_WARNING_USERS_PRIVATE" desc="Permission string for access to user accounts."> + Read and change whitelisted users + </message> <!-- Extension/App error messages --> <message name="IDS_EXTENSION_CANT_GET_ABSOLUTE_PATH" desc="Warning displayed in pack dialog when the absolute path to the extension directory can not be found."> diff --git a/chrome/browser/extensions/api/users_private/OWNERS b/chrome/browser/extensions/api/users_private/OWNERS new file mode 100644 index 0000000..b106158 --- /dev/null +++ b/chrome/browser/extensions/api/users_private/OWNERS @@ -0,0 +1,2 @@ +orenb@chromium.org +stevenjb@chromium.org diff --git a/chrome/browser/extensions/api/users_private/users_private_api.cc b/chrome/browser/extensions/api/users_private/users_private_api.cc new file mode 100644 index 0000000..b6c80d3 --- /dev/null +++ b/chrome/browser/extensions/api/users_private/users_private_api.cc @@ -0,0 +1,93 @@ +// 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. + +#include "chrome/browser/extensions/api/users_private/users_private_api.h" + +#include "base/values.h" +#include "chrome/browser/extensions/chrome_extension_function.h" +#include "extensions/browser/extension_function_registry.h" + +namespace extensions { + +//////////////////////////////////////////////////////////////////////////////// +// UsersPrivateGetWhitelistedUsersFunction + +UsersPrivateGetWhitelistedUsersFunction:: + UsersPrivateGetWhitelistedUsersFunction() { +} + +UsersPrivateGetWhitelistedUsersFunction:: + ~UsersPrivateGetWhitelistedUsersFunction() { +} + +ExtensionFunction::ResponseAction +UsersPrivateGetWhitelistedUsersFunction::Run() { + return RespondNow(OneArgument(new base::ListValue())); +} + +//////////////////////////////////////////////////////////////////////////////// +// UsersPrivateAddWhitelistedUserFunction + +UsersPrivateAddWhitelistedUserFunction:: + UsersPrivateAddWhitelistedUserFunction() { +} + +UsersPrivateAddWhitelistedUserFunction:: + ~UsersPrivateAddWhitelistedUserFunction() { +} + +ExtensionFunction::ResponseAction +UsersPrivateAddWhitelistedUserFunction::Run() { + return RespondNow(OneArgument(new base::FundamentalValue(true))); +} + +//////////////////////////////////////////////////////////////////////////////// +// UsersPrivateRemoveWhitelistedUserFunction + +UsersPrivateRemoveWhitelistedUserFunction:: + UsersPrivateRemoveWhitelistedUserFunction() { +} + +UsersPrivateRemoveWhitelistedUserFunction:: + ~UsersPrivateRemoveWhitelistedUserFunction() { +} + +ExtensionFunction::ResponseAction +UsersPrivateRemoveWhitelistedUserFunction::Run() { + return RespondNow(OneArgument(new base::FundamentalValue(true))); +} + +//////////////////////////////////////////////////////////////////////////////// +// UsersPrivateIsCurrentUserOwnerFunction + +UsersPrivateIsCurrentUserOwnerFunction:: + UsersPrivateIsCurrentUserOwnerFunction() { +} + +UsersPrivateIsCurrentUserOwnerFunction:: + ~UsersPrivateIsCurrentUserOwnerFunction() { +} + +ExtensionFunction::ResponseAction +UsersPrivateIsCurrentUserOwnerFunction::Run() { + return RespondNow(OneArgument(new base::FundamentalValue(true))); +} + +//////////////////////////////////////////////////////////////////////////////// +// UsersPrivateIsWhitelistManagedFunction + +UsersPrivateIsWhitelistManagedFunction:: + UsersPrivateIsWhitelistManagedFunction() { +} + +UsersPrivateIsWhitelistManagedFunction:: + ~UsersPrivateIsWhitelistManagedFunction() { +} + +ExtensionFunction::ResponseAction +UsersPrivateIsWhitelistManagedFunction::Run() { + return RespondNow(OneArgument(new base::FundamentalValue(true))); +} + +} // namespace extensions diff --git a/chrome/browser/extensions/api/users_private/users_private_api.h b/chrome/browser/extensions/api/users_private/users_private_api.h new file mode 100644 index 0000000..b1fd34d --- /dev/null +++ b/chrome/browser/extensions/api/users_private/users_private_api.h @@ -0,0 +1,107 @@ +// 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. + +#ifndef CHROME_BROWSER_EXTENSIONS_API_USERS_PRIVATE_USERS_PRIVATE_API_H_ +#define CHROME_BROWSER_EXTENSIONS_API_USERS_PRIVATE_USERS_PRIVATE_API_H_ + +#include <string> + +#include "base/macros.h" +#include "extensions/browser/extension_function.h" + +namespace extensions { + +// Implements the chrome.usersPrivate.getWhitelistedUsers method. +class UsersPrivateGetWhitelistedUsersFunction + : public UIThreadExtensionFunction { + public: + UsersPrivateGetWhitelistedUsersFunction(); + DECLARE_EXTENSION_FUNCTION("usersPrivate.getWhitelistedUsers", + USERSPRIVATE_GETWHITELISTEDUSERS); + + protected: + ~UsersPrivateGetWhitelistedUsersFunction() override; + + // ExtensionFunction overrides. + ResponseAction Run() override; + + private: + DISALLOW_COPY_AND_ASSIGN(UsersPrivateGetWhitelistedUsersFunction); +}; + +// Implements the chrome.usersPrivate.addWhitelistedUser method. +class UsersPrivateAddWhitelistedUserFunction + : public UIThreadExtensionFunction { + public: + UsersPrivateAddWhitelistedUserFunction(); + DECLARE_EXTENSION_FUNCTION("usersPrivate.addWhitelistedUser", + USERSPRIVATE_ADDWHITELISTEDUSER); + + protected: + ~UsersPrivateAddWhitelistedUserFunction() override; + + // AsyncExtensionFunction overrides. + ResponseAction Run() override; + + private: + DISALLOW_COPY_AND_ASSIGN(UsersPrivateAddWhitelistedUserFunction); +}; + +// Implements the chrome.usersPrivate.removeWhitelistedUser method. +class UsersPrivateRemoveWhitelistedUserFunction + : public UIThreadExtensionFunction { + public: + UsersPrivateRemoveWhitelistedUserFunction(); + DECLARE_EXTENSION_FUNCTION("usersPrivate.removeWhitelistedUser", + USERSPRIVATE_REMOVEWHITELISTEDUSER); + + protected: + ~UsersPrivateRemoveWhitelistedUserFunction() override; + + // ExtensionFunction overrides. + ResponseAction Run() override; + + private: + DISALLOW_COPY_AND_ASSIGN(UsersPrivateRemoveWhitelistedUserFunction); +}; + +// Implements the chrome.usersPrivate.isCurrentUserOwner method. +class UsersPrivateIsCurrentUserOwnerFunction + : public UIThreadExtensionFunction { + public: + UsersPrivateIsCurrentUserOwnerFunction(); + DECLARE_EXTENSION_FUNCTION("usersPrivate.isCurrentUserOwner", + USERSPRIVATE_ISCURRENTUSEROWNER); + + protected: + ~UsersPrivateIsCurrentUserOwnerFunction() override; + + // ExtensionFunction overrides. + ResponseAction Run() override; + + private: + DISALLOW_COPY_AND_ASSIGN(UsersPrivateIsCurrentUserOwnerFunction); +}; + +// Implements the chrome.usersPrivate.isWhitelistManaged method. +class UsersPrivateIsWhitelistManagedFunction + : public UIThreadExtensionFunction { + public: + UsersPrivateIsWhitelistManagedFunction(); + DECLARE_EXTENSION_FUNCTION("usersPrivate.isWhitelistManaged", + USERSPRIVATE_ISWHITELISTMANAGED); + + protected: + ~UsersPrivateIsWhitelistManagedFunction() override; + + // ExtensionFunction overrides. + ResponseAction Run() override; + + private: + DISALLOW_COPY_AND_ASSIGN(UsersPrivateIsWhitelistManagedFunction); +}; + +} // namespace extensions + +#endif // CHROME_BROWSER_EXTENSIONS_API_USERS_PRIVATE_USERS_PRIVATE_API_H_ diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi index 355ec47..4d6038d 100644 --- a/chrome/chrome_browser_extensions.gypi +++ b/chrome/chrome_browser_extensions.gypi @@ -487,6 +487,8 @@ 'browser/extensions/api/tabs/windows_util.h', 'browser/extensions/api/top_sites/top_sites_api.cc', 'browser/extensions/api/top_sites/top_sites_api.h', + 'browser/extensions/api/users_private/users_private_api.cc', + 'browser/extensions/api/users_private/users_private_api.h', 'browser/extensions/api/web_navigation/frame_navigation_state.cc', 'browser/extensions/api/web_navigation/frame_navigation_state.h', 'browser/extensions/api/web_navigation/web_navigation_api.cc', diff --git a/chrome/common/extensions/api/_api_features.json b/chrome/common/extensions/api/_api_features.json index e24ff6d..3f688b7 100644 --- a/chrome/common/extensions/api/_api_features.json +++ b/chrome/common/extensions/api/_api_features.json @@ -721,6 +721,18 @@ "dependencies": ["permission:ttsEngine"], "contexts": ["blessed_extension"] }, + "usersPrivate": [{ + "dependencies": ["permission:usersPrivate"], + "contexts": ["blessed_extension"] + }, { + "channel": "trunk", + "contexts": ["webui"], + "matches": [ + "chrome://md-settings/*", + "chrome://settings/*", + "chrome://settings-frame/*" + ] + }], "virtualKeyboardPrivate": { "dependencies": ["permission:virtualKeyboardPrivate"], "contexts": ["blessed_extension"] diff --git a/chrome/common/extensions/api/_permission_features.json b/chrome/common/extensions/api/_permission_features.json index 02db378..4d5159c 100644 --- a/chrome/common/extensions/api/_permission_features.json +++ b/chrome/common/extensions/api/_permission_features.json @@ -963,6 +963,11 @@ "channel": "stable", "extension_types": ["extension", "legacy_packaged_app"] }, + "usersPrivate": { + "channel": "trunk", + "extension_types": ["extension", "platform_app"], + "location": "component" + }, "wallpaper": { "channel": "stable", "extension_types": ["platform_app", "extension"], diff --git a/chrome/common/extensions/api/schemas.gypi b/chrome/common/extensions/api/schemas.gypi index 93d1cf3..4468870 100644 --- a/chrome/common/extensions/api/schemas.gypi +++ b/chrome/common/extensions/api/schemas.gypi @@ -79,6 +79,7 @@ 'tab_capture.idl', 'tabs.json', 'types.json', + 'users_private.idl', 'web_navigation.json', # Despite the name, this API does not rely on any # WebRTC-specific bits and as such does not belong in diff --git a/chrome/common/extensions/api/users_private.idl b/chrome/common/extensions/api/users_private.idl new file mode 100644 index 0000000..73fcf9a --- /dev/null +++ b/chrome/common/extensions/api/users_private.idl @@ -0,0 +1,44 @@ +// 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. + +// Use the <code>chrome.usersPrivate</code> API to manage users. +namespace usersPrivate { + + dictionary User { + // Email for the user. + DOMString email; + + // Whether this user is the device owner. + boolean isOwner; + }; + + callback UsersCallback = void (User[] users); + callback UserAddedCallback = void (boolean success); + callback UserRemovedCallback = void (boolean success); + callback IsOwnerCallback = void (boolean isOwner); + callback ManagedCallback = void (boolean managed); + + interface Functions { + // Gets a list of the currently whitelisted users. + static void getWhitelistedUsers(UsersCallback callback); + + // Adds a new user with the given email to the whitelist. + // The callback is called with true if the user was added succesfully, or + // with false if not (e.g. because the user was already present, or the + // current user isn't the owner). + static void addWhitelistedUser(DOMString email, UserAddedCallback callback); + + // Removes the user with the given email from the whitelist. + // The callback is called with true if the user was removed succesfully, or + // with false if not (e.g. because the user was not already present, or + // the current user isn't the owner). + static void removeWhitelistedUser(DOMString email, UserRemovedCallback callback); + + // Whether the current user is the owner of the device. + static void isCurrentUserOwner(IsOwnerCallback callback); + + // Whether the whitelist is managed by enterprise. + static void isWhitelistManaged(ManagedCallback callback); + }; +}; diff --git a/chrome/common/extensions/permissions/chrome_api_permissions.cc b/chrome/common/extensions/permissions/chrome_api_permissions.cc index 2fbacdd..0abdefd 100644 --- a/chrome/common/extensions/permissions/chrome_api_permissions.cc +++ b/chrome/common/extensions/permissions/chrome_api_permissions.cc @@ -362,6 +362,11 @@ std::vector<APIPermissionInfo*> ChromeAPIPermissions::GetAllPermissions() APIPermissionInfo::kFlagCannotBeOptional, IDS_EXTENSION_PROMPT_WARNING_PASSWORDS_PRIVATE, PermissionMessage::kPasswordsPrivate}, + {APIPermission::kUsersPrivate, + "usersPrivate", + APIPermissionInfo::kFlagCannotBeOptional, + IDS_EXTENSION_PROMPT_WARNING_USERS_PRIVATE, + PermissionMessage::kUsersPrivate}, // Full url access permissions. {APIPermission::kDebugger, diff --git a/chrome/common/extensions/permissions/chrome_permission_message_rules.cc b/chrome/common/extensions/permissions/chrome_permission_message_rules.cc index 1ae7995..6b22aad 100644 --- a/chrome/common/extensions/permissions/chrome_permission_message_rules.cc +++ b/chrome/common/extensions/permissions/chrome_permission_message_rules.cc @@ -507,6 +507,9 @@ ChromePermissionMessageRule::GetAllRules() { {IDS_EXTENSION_PROMPT_WARNING_PASSWORDS_PRIVATE, {APIPermission::kPasswordsPrivate}, {}}, + {IDS_EXTENSION_PROMPT_WARNING_USERS_PRIVATE, + {APIPermission::kUsersPrivate}, + {}}, // Platform-app permission messages. diff --git a/extensions/browser/extension_function_histogram_value.h b/extensions/browser/extension_function_histogram_value.h index 67d5ea9..a6d4b00 100644 --- a/extensions/browser/extension_function_histogram_value.h +++ b/extensions/browser/extension_function_histogram_value.h @@ -1103,6 +1103,11 @@ enum HistogramValue { DEVELOPERPRIVATE_SETSHORTCUTHANDLINGSUSPENDED, DEVELOPERPRIVATE_UPDATEEXTENSIONCOMMAND, INPUTMETHODPRIVATE_GETENCRYPTSYNCENABLED, + USERSPRIVATE_GETWHITELISTEDUSERS, + USERSPRIVATE_ADDWHITELISTEDUSER, + USERSPRIVATE_REMOVEWHITELISTEDUSER, + USERSPRIVATE_ISCURRENTUSEROWNER, + USERSPRIVATE_ISWHITELISTMANAGED, // Last entry: Add new entries above and ensure to update // tools/metrics/histograms/histograms.xml. ENUM_BOUNDARY diff --git a/extensions/common/permissions/api_permission.h b/extensions/common/permissions/api_permission.h index 8fbc636..aee2853 100644 --- a/extensions/common/permissions/api_permission.h +++ b/extensions/common/permissions/api_permission.h @@ -240,6 +240,7 @@ class APIPermission { kUsbDeviceList, kUsbDeviceUnknownProduct, kUsbDeviceUnknownVendor, + kUsersPrivate, // Last entry: Add new entries above and ensure to update the // "ExtensionPermission3" enum in tools/metrics/histograms/histograms.xml // (by running update_extension_permission.py). diff --git a/extensions/common/permissions/permission_message.h b/extensions/common/permissions/permission_message.h index e04679d..a4e62b5 100644 --- a/extensions/common/permissions/permission_message.h +++ b/extensions/common/permissions/permission_message.h @@ -108,6 +108,7 @@ class PermissionMessage { kSearchEnginesPrivate, kAutofillPrivate, kPasswordsPrivate, + kUsersPrivate, // Last entry: Add new entries above and ensure to update the // "ExtensionPermission2" enum in tools/metrics/histograms/histograms.xml // (by running update_extension_permission.py). diff --git a/third_party/closure_compiler/externs/users_private.js b/third_party/closure_compiler/externs/users_private.js new file mode 100644 index 0000000..733ac6e --- /dev/null +++ b/third_party/closure_compiler/externs/users_private.js @@ -0,0 +1,61 @@ +// 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. + +/** @fileoverview Externs generated from namespace: usersPrivate */ + +/** + * @const + */ +chrome.usersPrivate = {}; + +/** + * @typedef {{ + * email: string, + * isOwner: boolean + * }} + * @see https://developer.chrome.com/extensions/usersPrivate#type-User + */ +var User; + +/** + * Gets a list of the currently whitelisted users. + * @param {function(!Array<User>):void} callback + * @see https://developer.chrome.com/extensions/usersPrivate#method-getWhitelistedUsers + */ +chrome.usersPrivate.getWhitelistedUsers = function(callback) {}; + +/** + * Adds a new user with the given email to the whitelist. The callback is called + * with true if the user was added succesfully, or with false if not (e.g. + * because the user was already present, or the current user isn't the owner). + * @param {string} email + * @param {function(boolean):void} callback + * @see https://developer.chrome.com/extensions/usersPrivate#method-addWhitelistedUser + */ +chrome.usersPrivate.addWhitelistedUser = function(email, callback) {}; + +/** + * Removes the user with the given email from the whitelist. The callback is + * called with true if the user was removed succesfully, or with false if not + * (e.g. because the user was not already present, or the current user isn't the + * owner). + * @param {string} email + * @param {function(boolean):void} callback + * @see https://developer.chrome.com/extensions/usersPrivate#method-removeWhitelistedUser + */ +chrome.usersPrivate.removeWhitelistedUser = function(email, callback) {}; + +/** + * Whether the current user is the owner of the device. + * @param {function(boolean):void} callback + * @see https://developer.chrome.com/extensions/usersPrivate#method-isCurrentUserOwner + */ +chrome.usersPrivate.isCurrentUserOwner = function(callback) {}; + +/** + * Whether the whitelist is managed by enterprise. + * @param {function(boolean):void} callback + * @see https://developer.chrome.com/extensions/usersPrivate#method-isWhitelistManaged + */ +chrome.usersPrivate.isWhitelistManaged = function(callback) {}; diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 4cd6fc8..4b7565f 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -53376,6 +53376,11 @@ Therefore, the affected-histogram name has to have at least one dot in it. <int value="1042" label="DEVELOPERPRIVATE_SETSHORTCUTHANDLINGSUSPENDED"/> <int value="1043" label="DEVELOPERPRIVATE_UPDATEEXTENSIONCOMMAND"/> <int value="1044" label="INPUTMETHODPRIVATE_GETENCRYPTSYNCENABLED"/> + <int value="1045" label="USERSPRIVATE_GETWHITELISTEDUSERS"/> + <int value="1046" label="USERSPRIVATE_ADDWHITELISTEDUSER"/> + <int value="1047" label="USERSPRIVATE_REMOVEWHITELISTEDUSER"/> + <int value="1048" label="USERSPRIVATE_ISCURRENTUSEROWNER"/> + <int value="1049" label="USERSPRIVATE_ISWHITELISTMANAGED"/> </enum> <enum name="ExtensionInstallCause" type="int"> |