Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Issue 1004733003: Split the default content settings into syncable and nonsyncable. (Closed)

Created:
5 years, 9 months ago by msramek
Modified:
5 years, 9 months ago
CC:
chromium-reviews, raymes
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Split the default content settings into syncable and nonsyncable. Parallel to the default content setting dictionary pref, I added N individual integer prefs. Syncable preferences are kept in sync with the matching dictionary entries, so that they can be synced to/from old versions of Chrome. Default provider used the following, somewhat complicated, logic: - when we read from a dictionary and there is no value for a particular content type, we reset the value to default, except if default=CONTENT_SETTING_DEFAULT, then we reset it to NULL - when someone calls SetWebsiteSetting() with value NULL, we reset the value to default, except if default=CONTENT_SETTING_DEFAULT, then we keep NULL I kept this logic when working with the individual preferences, which explains why there are a lot of "if NULL" and "if default==..." checks. To make sure that we don't forget these checks on any read/write, I added two pairs of methods for reading to/writing from individual prefs/dictionary pref: (Read|Write)(Individual|Dictionary)Pref\(\) and a wrapper for writing to the cache ChangeSetting(). BUG=452388 TESTED=Between trunk and old M40 stable. Syncable settings are synced both ways. Nonsyncable settings are not synced either way. Committed: https://crrev.com/4e9ea92c1cdcb084be89748a08f5b2e05b37c950 Cr-Commit-Position: refs/heads/master@{#321988}

Patch Set 1 #

Patch Set 2 : Renamed pref, changed one check. #

Patch Set 3 : Notifying the default as well. #

Patch Set 4 : Refactored, tests seem to pass. #

Patch Set 5 : NULL in SetWebsiteSetting must be converted to the default. #

Patch Set 6 : Migration code. #

Patch Set 7 : Changing APP_BANNER to unsyncable (recent decision). #

Total comments: 16

Patch Set 8 : Fixes, rewrote OnPreferenceUpdate. #

Total comments: 2

Patch Set 9 : Reset PMI, reacting to unsyncable pref changes as well. #

Total comments: 14
Unified diffs Side-by-side diffs Delta from patch set Stats (+449 lines, -111 lines) Patch
M chrome/browser/content_settings/content_settings_default_provider_unittest.cc View 1 2 3 2 chunks +51 lines, -0 lines 0 comments Download
M components/content_settings/core/browser/content_settings_default_provider.h View 1 2 3 4 5 2 chunks +42 lines, -11 lines 0 comments Download
M components/content_settings/core/browser/content_settings_default_provider.cc View 1 2 3 4 5 6 7 8 7 chunks +269 lines, -100 lines 14 comments Download
M components/content_settings/core/common/pref_names.h View 1 2 3 4 5 2 chunks +30 lines, -0 lines 0 comments Download
M components/content_settings/core/common/pref_names.cc View 1 2 3 4 5 1 chunk +57 lines, -0 lines 0 comments Download

Messages

Total messages: 36 (10 generated)
msramek
Hi Markus, could you PTAL? This CL splits the default content settings dictionary to individual ...
5 years, 9 months ago (2015-03-17 10:00:42 UTC) #2
markusheintz_
On 2015/03/17 10:00:42, msramek wrote: > Hi Markus, > > could you PTAL? > > ...
5 years, 9 months ago (2015-03-17 10:08:06 UTC) #3
msramek
On 2015/03/17 10:08:06, markusheintz_ wrote: > On 2015/03/17 10:00:42, msramek wrote: > > Hi Markus, ...
5 years, 9 months ago (2015-03-17 10:10:31 UTC) #4
msramek
On 2015/03/17 10:10:31, msramek wrote: > On 2015/03/17 10:08:06, markusheintz_ wrote: > > On 2015/03/17 ...
5 years, 9 months ago (2015-03-17 10:20:05 UTC) #5
msramek
On 2015/03/17 10:20:05, msramek wrote: > On 2015/03/17 10:10:31, msramek wrote: > > On 2015/03/17 ...
5 years, 9 months ago (2015-03-17 12:02:53 UTC) #6
msramek
+xhwang@: FYI, my CL for un-syncing the default settings (exceptions are separate). The MigrateDefaultSettings() method ...
5 years, 9 months ago (2015-03-18 13:43:37 UTC) #7
markusheintz_
https://codereview.chromium.org/1004733003/diff/120001/components/content_settings/core/browser/content_settings_default_provider.cc File components/content_settings/core/browser/content_settings_default_provider.cc (right): https://codereview.chromium.org/1004733003/diff/120001/components/content_settings/core/browser/content_settings_default_provider.cc#newcode32 components/content_settings/core/browser/content_settings_default_provider.cc:32: const ContentSetting default_value; This does not work if we ...
5 years, 9 months ago (2015-03-18 14:39:49 UTC) #8
msramek
https://codereview.chromium.org/1004733003/diff/120001/components/content_settings/core/browser/content_settings_default_provider.cc File components/content_settings/core/browser/content_settings_default_provider.cc (right): https://codereview.chromium.org/1004733003/diff/120001/components/content_settings/core/browser/content_settings_default_provider.cc#newcode32 components/content_settings/core/browser/content_settings_default_provider.cc:32: const ContentSetting default_value; On 2015/03/18 14:39:49, markusheintz_ wrote: > ...
5 years, 9 months ago (2015-03-18 16:39:41 UTC) #10
markusheintz_
On 2015/03/18 16:39:41, msramek wrote: > https://codereview.chromium.org/1004733003/diff/120001/components/content_settings/core/browser/content_settings_default_provider.cc > File > components/content_settings/core/browser/content_settings_default_provider.cc > (right): > > ...
5 years, 9 months ago (2015-03-18 16:40:31 UTC) #11
xhwang
On 2015/03/18 13:43:37, msramek wrote: > +xhwang@: FYI, my CL for un-syncing the default settings ...
5 years, 9 months ago (2015-03-18 20:32:11 UTC) #12
xhwang
Please see my comment about questions on the migration plan: https://code.google.com/p/chromium/issues/detail?id=466715#c7
5 years, 9 months ago (2015-03-18 20:39:35 UTC) #14
msramek
On 2015/03/18 20:32:11, xhwang wrote: > On 2015/03/18 13:43:37, msramek wrote: > > +xhwang@: FYI, ...
5 years, 9 months ago (2015-03-19 10:02:59 UTC) #15
msramek
raymes@: FYI. We discussed the design with markusheintz@ offline, so here's a brief explanation. 1. ...
5 years, 9 months ago (2015-03-19 10:22:27 UTC) #16
raymes
https://codereview.chromium.org/1004733003/diff/140001/components/content_settings/core/browser/content_settings_default_provider.cc File components/content_settings/core/browser/content_settings_default_provider.cc (right): https://codereview.chromium.org/1004733003/diff/140001/components/content_settings/core/browser/content_settings_default_provider.cc#newcode365 components/content_settings/core/browser/content_settings_default_provider.cc:365: // this after two stable releases. Hmm, is there ...
5 years, 9 months ago (2015-03-19 23:45:22 UTC) #18
msramek
https://codereview.chromium.org/1004733003/diff/140001/components/content_settings/core/browser/content_settings_default_provider.cc File components/content_settings/core/browser/content_settings_default_provider.cc (right): https://codereview.chromium.org/1004733003/diff/140001/components/content_settings/core/browser/content_settings_default_provider.cc#newcode365 components/content_settings/core/browser/content_settings_default_provider.cc:365: // this after two stable releases. On 2015/03/19 23:45:21, ...
5 years, 9 months ago (2015-03-20 15:57:46 UTC) #20
xhwang
https://codereview.chromium.org/1004733003/diff/200001/components/content_settings/core/browser/content_settings_default_provider.cc File components/content_settings/core/browser/content_settings_default_provider.cc (right): https://codereview.chromium.org/1004733003/diff/200001/components/content_settings/core/browser/content_settings_default_provider.cc#newcode502 components/content_settings/core/browser/content_settings_default_provider.cc:502: WriteIndividualPref(CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, NULL); Thank you!
5 years, 9 months ago (2015-03-20 16:23:30 UTC) #21
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1004733003/200001
5 years, 9 months ago (2015-03-24 12:27:55 UTC) #24
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1004733003/200001
5 years, 9 months ago (2015-03-24 13:13:53 UTC) #27
commit-bot: I haz the power
Committed patchset #9 (id:200001)
5 years, 9 months ago (2015-03-24 13:27:17 UTC) #28
commit-bot: I haz the power
Patchset 9 (id:??) landed as https://crrev.com/4e9ea92c1cdcb084be89748a08f5b2e05b37c950 Cr-Commit-Position: refs/heads/master@{#321988}
5 years, 9 months ago (2015-03-24 13:27:57 UTC) #29
xhwang
https://codereview.chromium.org/1004733003/diff/200001/components/content_settings/core/browser/content_settings_default_provider.cc File components/content_settings/core/browser/content_settings_default_provider.cc (right): https://codereview.chromium.org/1004733003/diff/200001/components/content_settings/core/browser/content_settings_default_provider.cc#newcode502 components/content_settings/core/browser/content_settings_default_provider.cc:502: WriteIndividualPref(CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, NULL); Just to double check. Will this only ...
5 years, 9 months ago (2015-03-24 22:28:49 UTC) #30
msramek
On 2015/03/24 22:28:49, xhwang wrote: > https://codereview.chromium.org/1004733003/diff/200001/components/content_settings/core/browser/content_settings_default_provider.cc > File > components/content_settings/core/browser/content_settings_default_provider.cc > (right): > > ...
5 years, 9 months ago (2015-03-25 09:21:52 UTC) #31
xhwang
On 2015/03/25 09:21:52, msramek wrote: > On 2015/03/24 22:28:49, xhwang wrote: > > > https://codereview.chromium.org/1004733003/diff/200001/components/content_settings/core/browser/content_settings_default_provider.cc ...
5 years, 9 months ago (2015-03-25 16:08:15 UTC) #32
Bernhard Bauer
Post-commit drive-by review! There are some style nits in here: https://codereview.chromium.org/1004733003/diff/200001/components/content_settings/core/browser/content_settings_default_provider.cc File components/content_settings/core/browser/content_settings_default_provider.cc (right): https://codereview.chromium.org/1004733003/diff/200001/components/content_settings/core/browser/content_settings_default_provider.cc#newcode42 ...
5 years, 9 months ago (2015-03-26 10:12:35 UTC) #34
msramek
On 2015/03/26 10:12:35, Bernhard Bauer wrote: > Post-commit drive-by review! There are some style nits ...
5 years, 9 months ago (2015-03-26 10:20:53 UTC) #35
msramek
5 years, 9 months ago (2015-03-27 16:17:46 UTC) #36
Message was sent while issue was closed.
Hi Bernhard, I addressed your comments in a follow-up CL 1038203003.

https://codereview.chromium.org/1004733003/diff/200001/components/content_set...
File
components/content_settings/core/browser/content_settings_default_provider.cc
(right):

https://codereview.chromium.org/1004733003/diff/200001/components/content_set...
components/content_settings/core/browser/content_settings_default_provider.cc:42:
{prefs::kDefaultCookiesSetting, CONTENT_SETTING_ALLOW, true},
On 2015/03/26 10:12:34, Bernhard (OOO) wrote:
> Indent these lines by two spaces, and add a space after the opening brace and
> before the closing brace.

Done.

https://codereview.chromium.org/1004733003/diff/200001/components/content_set...
components/content_settings/core/browser/content_settings_default_provider.cc:121:
for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
On 2015/03/26 10:12:34, Bernhard (OOO) wrote:
> Use an int unless you really really need size_t.
> 
> Also, I *think* you might be able to iterate over the array with the C++11
> syntax, then you don't need the index variable at all.

Ah. This is a leftover. I originally used size_t, because I had i <
arraysize(kDefaultSettings). But there is no need, as we have the assert anyway.

All the code doing something "for all content types" I encountered seems to use
normal "for(int ...)", so I'll keep that.

https://codereview.chromium.org/1004733003/diff/200001/components/content_set...
components/content_settings/core/browser/content_settings_default_provider.cc:305:
return (value == NULL ||
On 2015/03/26 10:12:34, Bernhard (OOO) wrote:
> Use nullptr, or just `!value` (which would also be consistent with the style
in
> ChangeSetting).

Done.

https://codereview.chromium.org/1004733003/diff/200001/components/content_set...
components/content_settings/core/browser/content_settings_default_provider.cc:377:
for (ValueMap::iterator it = dictionary->begin();
On 2015/03/26 10:12:34, Bernhard (OOO) wrote:
> Use a C++11-style loop?

Done.

https://codereview.chromium.org/1004733003/diff/200001/components/content_set...
components/content_settings/core/browser/content_settings_default_provider.cc:428:
return make_scoped_ptr((base::Value*)NULL);
On 2015/03/26 10:12:35, Bernhard (OOO) wrote:
> Use nullptr; that might even allow you to get rid of the cast. (Also, if you
> were to keep the cast, it should be static_cast<base::Value*>.)
> 
> Also also, it might make sense to extract this logic into a function that
> creates a base::Value from a ContentSetting (we do this in a couple of other
> places as well).

Done.

Cast is necessary here even with nullptr. Anyway, I made a separate function.

https://codereview.chromium.org/1004733003/diff/200001/components/content_set...
components/content_settings/core/browser/content_settings_default_provider.cc:460:
ValueMap* value_map = new ValueMap();
On 2015/03/26 10:12:34, Bernhard (OOO) wrote:
> Put this into a scoped_ptr, and return it immediately if !dictionary?

Done. I just found it more elegant to create the scoped_ptr on return than to
Pass() it on return.

Powered by Google App Engine
This is Rietveld 408576698