Comment 19 for bug 875266

Revision history for this message
In , Karlt (karlt) wrote :

Comment on attachment 578249
gsettings proxy patch v3

>+ nsCOMPtr<nsIGSettingsCollection> proxy_settings;
>+
>+ // Check if proxy is enabled, flag is only in schema org.gnome.system.proxy.http,
>+ // there is no separate flag for each schema.
>+ nsresult rv = mGSettings->GetCollectionForSchema(NS_LITERAL_CSTRING("org.gnome.system.proxy.http"),
>+ getter_AddRefs(proxy_settings));
>+ NS_ENSURE_SUCCESS(rv, rv);
>+
>+ rv = mGSettings->GetCollectionForSchema(NS_LITERAL_CSTRING("org.gnome.system.proxy"),
>+ getter_AddRefs(proxy_settings));

The "org.gnome.system.proxy.http" schema is now not needed here.

>- if (!mGConf)
>+ if (!mGConf || !mGSettings)
> return GetProxyFromEnvironment(scheme, host, port, aResult);

This isn't what we want. This will use the environment unless GSettings and
GConf are available. Best to treat this as a fallback after the GSettings and
GConf code.

>+ /* Check for org.gnome.syste.proxy schema */
>+ nsCOMPtr<nsIGSettingsCollection> proxy_settings;
>+ mGSettings->GetCollectionForSchema(NS_LITERAL_CSTRING("org.gnome.system.proxy"),
>+ getter_AddRefs(proxy_settings));
>+ /* If schema is found let GSettings determine the right proxy, otherwise fallback to gconf. */
>+ if (proxy_settings)
>+ return GetProxyFromGSettings(scheme, host, port, aResult);

GetCollectionForSchema is an expensive operation, so I don't want the
"org.gnome.system.proxy" schema fetched both here and in GetProxyFromGSettings.

I think it should be fine to fall back to GConf and/or environment variables
when GetProxyFromGSettings returns a failure code.