shell_global_set_property_mutable: Remove
All introspection properties are now writable; See https://bugzilla.gnome.org/show_bug.cgi?id=646633 https://bugzilla.gnome.org/show_bug.cgi?id=652597
This commit is contained in:
parent
04d2b0d282
commit
26aa4333a5
@ -70,12 +70,6 @@ function init() {
|
|||||||
return base;
|
return base;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Now close the back door to prevent extensions from trying to
|
|
||||||
// abuse it. We can't actually delete it since
|
|
||||||
// Shell.Global.prototype itself is read-only.
|
|
||||||
global.set_property_mutable('imports.gi.Shell.Global.prototype', 'set_property_mutable', true);
|
|
||||||
Shell.Global.prototype.set_property_mutable = undefined;
|
|
||||||
|
|
||||||
// Work around https://bugzilla.mozilla.org/show_bug.cgi?id=508783
|
// Work around https://bugzilla.mozilla.org/show_bug.cgi?id=508783
|
||||||
Date.prototype.toLocaleFormat = function(format) {
|
Date.prototype.toLocaleFormat = function(format) {
|
||||||
return Shell.util_format_date(format, this.getTime());
|
return Shell.util_format_date(format, this.getTime());
|
||||||
|
@ -1482,73 +1482,6 @@ shell_global_create_app_launch_context (ShellGlobal *global)
|
|||||||
return (GAppLaunchContext *)context;
|
return (GAppLaunchContext *)context;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* shell_global_set_property_mutable:
|
|
||||||
* @global: the #ShellGlobal
|
|
||||||
* @object: the "path" to a JS object, starting from the root object.
|
|
||||||
* (Eg, "global.stage" or "imports.gi.Gtk.Window.prototype")
|
|
||||||
* @property: a property on @object
|
|
||||||
* @mutable: %TRUE or %FALSE
|
|
||||||
*
|
|
||||||
* If @mutable is %TRUE, this clears the "permanent" and "readonly" flags
|
|
||||||
* on @property of @object. If @mutable is %FALSE, it sets them.
|
|
||||||
*
|
|
||||||
* You can use this to make it possible to modify properties that
|
|
||||||
* would otherwise be read-only from JavaScript.
|
|
||||||
*
|
|
||||||
* Return value: success or failure.
|
|
||||||
*/
|
|
||||||
gboolean
|
|
||||||
shell_global_set_property_mutable (ShellGlobal *global,
|
|
||||||
const char *object,
|
|
||||||
const char *property,
|
|
||||||
gboolean mutable)
|
|
||||||
{
|
|
||||||
JSContext *context = gjs_context_get_native_context (global->js_context);
|
|
||||||
char **parts;
|
|
||||||
JSObject *obj;
|
|
||||||
jsval val = JSVAL_VOID;
|
|
||||||
int i;
|
|
||||||
jsuint attrs;
|
|
||||||
JSBool found;
|
|
||||||
|
|
||||||
JS_BeginRequest (context);
|
|
||||||
JS_AddValueRoot (context, &val);
|
|
||||||
|
|
||||||
parts = g_strsplit (object, ".", -1);
|
|
||||||
obj = JS_GetGlobalObject (context);
|
|
||||||
for (i = 0; parts[i]; i++)
|
|
||||||
{
|
|
||||||
if (!JS_GetProperty (context, obj, parts[i], &val))
|
|
||||||
{
|
|
||||||
g_strfreev (parts);
|
|
||||||
goto out_error;
|
|
||||||
}
|
|
||||||
obj = JSVAL_TO_OBJECT (val);
|
|
||||||
}
|
|
||||||
g_strfreev (parts);
|
|
||||||
|
|
||||||
if (!JS_GetPropertyAttributes (context, obj, property, &attrs, &found) || !found)
|
|
||||||
goto out_error;
|
|
||||||
|
|
||||||
if (mutable)
|
|
||||||
attrs &= ~(JSPROP_PERMANENT | JSPROP_READONLY);
|
|
||||||
else
|
|
||||||
attrs |= (JSPROP_PERMANENT | JSPROP_READONLY);
|
|
||||||
|
|
||||||
if (!JS_SetPropertyAttributes (context, obj, property, attrs, &found))
|
|
||||||
goto out_error;
|
|
||||||
|
|
||||||
JS_RemoveValueRoot (context, &val);
|
|
||||||
JS_EndRequest (context);
|
|
||||||
return TRUE;
|
|
||||||
out_error:
|
|
||||||
gjs_log_exception (context, NULL);
|
|
||||||
JS_RemoveValueRoot (context, &val);
|
|
||||||
JS_EndRequest (context);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
ShellLeisureFunction func;
|
ShellLeisureFunction func;
|
||||||
|
@ -105,12 +105,6 @@ void shell_global_get_memory_info (ShellGlobal *global,
|
|||||||
ShellMemoryInfo *meminfo);
|
ShellMemoryInfo *meminfo);
|
||||||
|
|
||||||
|
|
||||||
gboolean shell_global_set_property_mutable (ShellGlobal *global,
|
|
||||||
const char *object,
|
|
||||||
const char *property,
|
|
||||||
gboolean mutable);
|
|
||||||
|
|
||||||
|
|
||||||
/* Run-at-leisure API */
|
/* Run-at-leisure API */
|
||||||
void shell_global_begin_work (ShellGlobal *global);
|
void shell_global_begin_work (ShellGlobal *global);
|
||||||
void shell_global_end_work (ShellGlobal *global);
|
void shell_global_end_work (ShellGlobal *global);
|
||||||
|
Loading…
Reference in New Issue
Block a user