Commit bf915e21 authored by Albert Chaulk's avatar Albert Chaulk Committed by Commit Bot

[chromecast] Add stubs for chrome.settingsPrivate for chromevox

Bug: b/119185871
Test: local build

Change-Id: Id3f86cf28fe789008a479c30b916b1da64c61e9e
Reviewed-on: https://chromium-review.googlesource.com/c/1330688Reviewed-by: default avatarRandy Rossi <rmrossi@chromium.org>
Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611298}
parent 9d1a7a54
...@@ -263,6 +263,8 @@ cast_source_set("browser") { ...@@ -263,6 +263,8 @@ cast_source_set("browser") {
"extensions/api/identity/identity_api.h", "extensions/api/identity/identity_api.h",
"extensions/api/notifications/notifications_api.cc", "extensions/api/notifications/notifications_api.cc",
"extensions/api/notifications/notifications_api.h", "extensions/api/notifications/notifications_api.h",
"extensions/api/settings_private/settings_private_api.cc",
"extensions/api/settings_private/settings_private_api.h",
"extensions/api/tabs/tabs_api.cc", "extensions/api/tabs/tabs_api.cc",
"extensions/api/tabs/tabs_api.h", "extensions/api/tabs/tabs_api.h",
"extensions/api/tabs/tabs_constants.cc", "extensions/api/tabs/tabs_constants.cc",
......
// Copyright (c) 2018 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 "chromecast/browser/extensions/api/settings_private/settings_private_api.h"
namespace extensions {
namespace cast {
namespace {
const char kErrorNotSupported[] = "This API is not supported on this platform.";
} // namespace
SettingsPrivateSetPrefFunction::~SettingsPrivateSetPrefFunction() {}
ExtensionFunction::ResponseAction SettingsPrivateSetPrefFunction::Run() {
return RespondNow(Error(kErrorNotSupported));
}
SettingsPrivateGetAllPrefsFunction::~SettingsPrivateGetAllPrefsFunction() {}
ExtensionFunction::ResponseAction SettingsPrivateGetAllPrefsFunction::Run() {
return RespondNow(Error(kErrorNotSupported));
}
SettingsPrivateGetPrefFunction::~SettingsPrivateGetPrefFunction() {}
ExtensionFunction::ResponseAction SettingsPrivateGetPrefFunction::Run() {
return RespondNow(Error(kErrorNotSupported));
}
SettingsPrivateGetDefaultZoomFunction::
~SettingsPrivateGetDefaultZoomFunction() {}
ExtensionFunction::ResponseAction SettingsPrivateGetDefaultZoomFunction::Run() {
return RespondNow(Error(kErrorNotSupported));
}
SettingsPrivateSetDefaultZoomFunction::
~SettingsPrivateSetDefaultZoomFunction() {}
ExtensionFunction::ResponseAction SettingsPrivateSetDefaultZoomFunction::Run() {
return RespondNow(Error(kErrorNotSupported));
}
} // namespace cast
} // namespace extensions
// Copyright 2018 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 CHROMECAST_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_SETTINGS_PRIVATE_API_H_
#define CHROMECAST_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_SETTINGS_PRIVATE_API_H_
#include <string>
#include "base/macros.h"
#include "extensions/browser/extension_function.h"
namespace extensions {
namespace cast {
// Implements the chrome.settingsPrivate.setPref method.
class SettingsPrivateSetPrefFunction : public UIThreadExtensionFunction {
public:
SettingsPrivateSetPrefFunction() {}
DECLARE_EXTENSION_FUNCTION("settingsPrivate.setPref",
SETTINGSPRIVATE_SETPREF);
protected:
~SettingsPrivateSetPrefFunction() override;
// UIThreadExtensionFunction overrides.
ResponseAction Run() override;
DISALLOW_COPY_AND_ASSIGN(SettingsPrivateSetPrefFunction);
};
// Implements the chrome.settingsPrivate.getAllPrefs method.
class SettingsPrivateGetAllPrefsFunction : public UIThreadExtensionFunction {
public:
SettingsPrivateGetAllPrefsFunction() {}
DECLARE_EXTENSION_FUNCTION("settingsPrivate.getAllPrefs",
SETTINGSPRIVATE_GETALLPREFS);
protected:
~SettingsPrivateGetAllPrefsFunction() override;
// UIThreadExtensionFunction overrides.
ResponseAction Run() override;
DISALLOW_COPY_AND_ASSIGN(SettingsPrivateGetAllPrefsFunction);
};
// Implements the chrome.settingsPrivate.getPref method.
class SettingsPrivateGetPrefFunction : public UIThreadExtensionFunction {
public:
SettingsPrivateGetPrefFunction() {}
DECLARE_EXTENSION_FUNCTION("settingsPrivate.getPref",
SETTINGSPRIVATE_GETPREF);
protected:
~SettingsPrivateGetPrefFunction() override;
// UIThreadExtensionFunction overrides.
ResponseAction Run() override;
DISALLOW_COPY_AND_ASSIGN(SettingsPrivateGetPrefFunction);
};
// Implements the chrome.settingsPrivate.getDefaultZoom method.
class SettingsPrivateGetDefaultZoomFunction : public UIThreadExtensionFunction {
public:
SettingsPrivateGetDefaultZoomFunction() {}
DECLARE_EXTENSION_FUNCTION("settingsPrivate.getDefaultZoom",
SETTINGSPRIVATE_GETDEFAULTZOOMFUNCTION);
protected:
~SettingsPrivateGetDefaultZoomFunction() override;
// UIThreadExtensionFunction overrides.
ResponseAction Run() override;
DISALLOW_COPY_AND_ASSIGN(SettingsPrivateGetDefaultZoomFunction);
};
// Implements the chrome.settingsPrivate.setDefaultZoom method.
class SettingsPrivateSetDefaultZoomFunction : public UIThreadExtensionFunction {
public:
SettingsPrivateSetDefaultZoomFunction() {}
DECLARE_EXTENSION_FUNCTION("settingsPrivate.setDefaultZoom",
SETTINGSPRIVATE_SETDEFAULTZOOMFUNCTION);
protected:
~SettingsPrivateSetDefaultZoomFunction() override;
// UIThreadExtensionFunction overrides.
ResponseAction Run() override;
DISALLOW_COPY_AND_ASSIGN(SettingsPrivateSetDefaultZoomFunction);
};
} // namespace cast
} // namespace extensions
#endif // CHROMECAST_BROWSER_EXTENSIONS_API_SETTINGS_PRIVATE_SETTINGS_PRIVATE_API_H_
...@@ -23,6 +23,7 @@ schema_sources = [ ...@@ -23,6 +23,7 @@ schema_sources = [
"identity.idl", "identity.idl",
"i18n.json", "i18n.json",
"notifications.idl", "notifications.idl",
"settings_private.idl",
"tabs.json", "tabs.json",
"windows.json", "windows.json",
] ]
......
...@@ -94,6 +94,16 @@ ...@@ -94,6 +94,16 @@
"chrome://bookmarks/*" "chrome://bookmarks/*"
] ]
}], }],
"settingsPrivate": [{
"dependencies": ["permission:settingsPrivate"],
"contexts": ["blessed_extension"]
}, {
"channel": "stable",
"contexts": ["webui"],
"matches": [
"chrome://settings/*"
]
}],
"tabs": [{ "tabs": [{
"channel": "stable", "channel": "stable",
"extension_types": ["extension", "legacy_packaged_app"], "extension_types": ["extension", "legacy_packaged_app"],
......
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
"channel": "stable", "channel": "stable",
"extension_types": ["extension", "legacy_packaged_app"] "extension_types": ["extension", "legacy_packaged_app"]
}, },
"settingsPrivate": {
"channel": "stable",
"extension_types": ["extension", "legacy_packaged_app", "platform_app"]
},
"tts": { "tts": {
"channel": "stable", "channel": "stable",
"extension_types": ["extension", "legacy_packaged_app", "platform_app"] "extension_types": ["extension", "legacy_packaged_app", "platform_app"]
......
...@@ -55,6 +55,8 @@ APIPermissionInfo::InitInfo permissions_to_register[] = { ...@@ -55,6 +55,8 @@ APIPermissionInfo::InitInfo permissions_to_register[] = {
APIPermissionInfo::kFlagCannotBeOptional}, APIPermissionInfo::kFlagCannotBeOptional},
{APIPermission::kVirtualKeyboardPrivate, "virtualKeyboardPrivate", {APIPermission::kVirtualKeyboardPrivate, "virtualKeyboardPrivate",
APIPermissionInfo::kFlagCannotBeOptional}, APIPermissionInfo::kFlagCannotBeOptional},
{APIPermission::kSettingsPrivate, "settingsPrivate",
APIPermissionInfo::kFlagCannotBeOptional},
}; };
} // namespace } // namespace
......
// 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.settingsPrivate</code> API to get or set preferences
// from the settings UI. Access is restricted to a whitelisted set of user
// facing preferences.
namespace settingsPrivate {
enum PrefType { BOOLEAN, NUMBER, STRING, URL, LIST, DICTIONARY };
enum ControlledBy {
DEVICE_POLICY,
USER_POLICY,
OWNER,
PRIMARY_USER,
EXTENSION
};
enum Enforcement { ENFORCED, RECOMMENDED };
dictionary PrefObject {
// The key for the pref.
DOMString key;
// The type of the pref (e.g., boolean, string, etc.).
PrefType type;
// The current value of the pref.
any value;
// The policy source of the pref; an undefined value means there is no
// policy.
ControlledBy? controlledBy;
// The owner name if controlledBy == OWNER.
// The primary user name if controlledBy == PRIMARY_USER.
// The extension name if controlledBy == EXTENSION.
DOMString? controlledByName;
// The policy enforcement of the pref; must be specified if controlledBy is
// also present.
Enforcement? enforcement;
// The recommended value if enforcement == RECOMMENDED.
any? recommendedValue;
// The extension ID if controlledBy == EXTENSION.
DOMString? extensionId;
// Whether the controlling extension can be disabled if controlledBy ==
// EXTENSION.
boolean? extensionCanBeDisabled;
};
callback OnPrefSetCallback = void (boolean success);
callback GetAllPrefsCallback = void (PrefObject[] prefs);
callback GetPrefCallback = void (PrefObject pref);
callback GetDefaultZoomCallback = void (double zoom);
callback SetDefaultZoomCallback = void (boolean success);
interface Functions {
// Sets a pref value.
// |name|: The name of the pref.
// |value|: The new value of the pref.
// |pageId|: An optional user metrics identifier.
// |callback|: The callback for whether the pref was set or not.
static void setPref(DOMString name, any value,
optional DOMString pageId, optional OnPrefSetCallback callback);
// Gets an array of all the prefs.
static void getAllPrefs(GetAllPrefsCallback callback);
// Gets the value of a specific pref.
static void getPref(DOMString name, GetPrefCallback callback);
// Gets the default page zoom factor. Possible values are currently between
// 0.25 and 5. For a full list, see zoom::kPresetZoomFactors.
static void getDefaultZoom(GetDefaultZoomCallback callback);
// Sets the page zoom factor. Must be less than 0.001 different than a value
// in zoom::kPresetZoomFactors.
static void setDefaultZoom(
double zoom, optional SetDefaultZoomCallback callback);
};
interface Events {
// Fired when a set of prefs has changed.
//
// |prefs| The prefs that changed.
static void onPrefsChanged(PrefObject[] prefs);
};
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment