New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 706061 link

Starred by 1 user

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug
Team-Security-UX



Sign in to add a comment

content_settings::Observers should get the actual changed value when a setting changes

Project Member Reported by csharrison@chromium.org, Mar 28 2017

Issue description

Proposed nrew API:

virtual void OnContentSettingChanged(
    const ContentSettingsPattern& primary_pattern,
    const ContentSettingsPattern& secondary_pattern,
    ContentSettingsType content_type,
    std::string resource_identifier,
    ContentSetting changed_setting) = 0;

The use case this fixes is observers who want to observe changes where the pattern is a wildcard, and is not matched by e.g. the web contents' current URL.

Note: I am not sure at this point if the observer also tracks website settings. If so, the changed_setting would likely need to be a base::Value or std::unique_ptr<base::Value>.

 
Cc: dullweber@chromium.org
I think it should be "const base::Value&". The caller who iterates over the base::ObserverList can retrieve a value and let every observer read it. Observers can always base::Value::DeepCopy() it for themselves if they need to change it.
Cc: raymes@chromium.org
Owner: csharrison@chromium.org
Status: Assigned (was: Untriaged)
Seems legit. Assigning back to reporter to get out of triage queue.
Labels: OS-All
Owner: ----
Status: Available (was: Assigned)
Changing to available. I asked csharrison@ to document this problem, but he should feel no obligation to fix it :)

Comment 4 by est...@chromium.org, Nov 10 2017

Labels: Hotlist-EnamelAndFriendsFixIt
Owner: dominickn@chromium.org
Status: Assigned (was: Available)
I'll take this one. I'll replace the existing content_settings::Observer::OnContentSettingChanged method in-place.
Owner: ----
Status: Available (was: Assigned)
Due to a recent reorg, I'm unlikely to be able to take this now.

Comment 7 by est...@chromium.org, Feb 18 2018

Labels: -Hotlist-EnamelAndFriendsFixIt
Circling back to this one.
My new proposed API is this:
virtual void OnContentSettingChanged(
    const ContentSettingsPattern& primary_pattern,
    const ContentSettingsPattern& secondary_pattern,
    ContentSettingsType content_type,
    std::string resource_identifier,
    const base::Value& old_value,
    const base::Value& new_value) = 0;

It seems that this API is called quite often if a setting is "changed" to the same exact value, so my use-case would first compare old_value to new_value and make sure the change was semantically meaningful.
Some OnContentSettingChanged calls don't correspond to individual changes. old_value and new_value wouldn't be defined in these cases. How could we represent this? base::Optional<base::Value>? 
If we are only interested in changed values of actual ContentSettings, we could also pass base::Optional<ContentSetting>?

E.g.
https://cs.chromium.org/chromium/src/chrome/browser/extensions/api/content_settings/content_settings_custom_extension_provider.cc?l=49&rcl=974d9b8cd88fdb46a4f9a783311696253f183edc
or
https://cs.chromium.org/chromium/src/components/content_settings/core/browser/content_settings_policy_provider.cc?l=461&rcl=f355f667c9ec1f618568af2e60d755f74cefe903

dullweber: Yeah I'm not 100% confident about the internal implementation of the API, but for changes which span multiple content settings types, I could imagine a separate observer method.

It looks like in the two links you posted, we are changing the default setting type, but I'm not sure exactly what that means :)
I think these calls just mean "something might have changed" e.g. because an extension was uninstalled that controlled content settings or a policy was changed.

Sign in to add a comment