0

457 Commits

Author SHA1 Message Date
38ac93c97d Make PrefStore::GetValues() return a base::Value::Dict.
And do the same for PrefValueMap::AsDictionaryValue(), which is renamed
to AsDict(). These methods were returning base::DictionaryValues, which
is deprecated.

Bug: 1187001
Change-Id: I191629bdb72ef62cf64a3cbea0f8a05a0758d230
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3832474
Reviewed-by: Maksim Ivanov <emaxx@chromium.org>
Commit-Queue: Matt Menke <mmenke@chromium.org>
Reviewed-by: Dan S <danan@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1035870}
2022-08-17 03:12:59 +00:00
a6b631458f Refactor unit tests to use PrefService::GetValue*
This is part of a larger migration effort based on
go/trust-your-prefs.

Bug: 1342019
Change-Id: I17bf467422005ad629112f3cab21e684f9d7cccd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3790858
Commit-Queue: Roland Bock <rbock@google.com>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1029841}
2022-07-29 17:23:19 +00:00
7b2bcde1e1 Remove unused method IsManaged in PrefChangeRegistrar.
Bug: 1345931
Change-Id: I1d901dbdb421b2859841e9f6551c2e8945c3e4a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3776577
Commit-Queue: Nohemi Fernandez <fernandex@chromium.org>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1026710}
2022-07-21 11:26:59 +00:00
6db0a97757 Remove base::Value::Equals() use in //components/prefs.
Bug: 646113
Change-Id: I503700fed715d423fc95c51f37e304496f45c223
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3759927
Auto-Submit: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Dominic Battré <battre@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1024514}
2022-07-15 00:53:39 +00:00
fe04f7d437 Add GetValue, GetDictValue, GetListValue to PrefService
The existing Get, GetDictionary, and GetList return base::Value pointers
but DCHECK the existence and the type before doing so. In other words,
they assert that the returned pointer is never null.

This CL introduces GetValue, GetDictValue, and GetListValue which return
references to base::Value, base::Value::Dict, and base::Value::List
respectively.

The goal is to migrate all call sites to the new functions and to remove
the old functions subsequently.

Bug: 1302561
Change-Id: Ia19c4da2754b3620b935f15a395c6ade354fe950
Tests: Existing tests
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3687964
Reviewed-by: Dominic Battré <battre@chromium.org>
Reviewed-by: Kristi Park <kristipark@chromium.org>
Commit-Queue: Roland Bock <rbock@google.com>
Cr-Commit-Position: refs/heads/main@{#1017026}
2022-06-23 05:08:29 +00:00
f0bc9eceb8 Remove unneeded testonly and robolectric deps from robolectric_library
robolectric_library already forces `testonly = true` and adds a dep onto
the robolectric jars automatically. This is a cleanup cl.

Bug: 1296632
Change-Id: Ib8b3e01cf1d1b253bd409ff79d5d90b9255f8bf6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3708934
Owners-Override: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Auto-Submit: Mohamed Heikal <mheikal@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1014752}
2022-06-16 01:42:28 +00:00
1b83653b29 Android: Create robolectric_library template for on host tests
- robolectric_library allows deps on android_library targets.
- Creates an robolectric test sdk target (that still has the @hide
  methods and constants that were removed from the normal sdk).
- robolectric_library and junit_binary now compile against the
  new robolectric test sdk.
- Robolectric targets now compile against the android 12 robolectric
  test sdk (previously android 10).


Bug: 1296632
Change-Id: I0782443a12cf2d4a8bf5bc3b8424a47400a83120
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3696549
Auto-Submit: Mohamed Heikal <mheikal@chromium.org>
Owners-Override: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Commit-Queue: Mohamed Heikal <mheikal@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1013712}
2022-06-13 23:20:59 +00:00
6de384232d PrefService: Add methods for new Dict and List types
This lets consumers call pref_service_->GetValueList() instead of
pref_service_->GetList()->GetList(), which improves code readability
and reduces callers' concerns around type safety.

Also add methods to PrefServiceSimple to set defaults by directly
passing in the new types.

Bug: 1187001,1334665
Change-Id: Id79bfa735512c081196699a91f51cb9205b382d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3690091
Commit-Queue: Matt Menke <mmenke@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1012123}
2022-06-08 20:17:21 +00:00
e175ac54ef Rewrite more raw pointer fields to use raw_ptr<T>
This reapplies the rewrite_raw_ptr_fields rewriter on Windows platform.

This change is a merge of the following changes:
PS4 CheckedPtr rewrite generated by
    rewrite-multiple-platforms.sh win
    on e53bae729d
PS5 manual build fixes
PS7 rebase

Bug: 1073933
Change-Id: Ibe9c70c9b77a24522cea1f197e50cf8180053354
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3682900
Reviewed-by: Bartek Nowierski <bartekn@chromium.org>
Commit-Queue: Keishi Hattori <keishi@chromium.org>
Owners-Override: Keishi Hattori <keishi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1011306}
2022-06-07 06:24:57 +00:00
6a1c29579a Fixes for C++20 support.
* Structs with user-declared constructors are no longer aggregates.
  Delete the declarations.
* u8"" no longer produces const char*.  Change to "", which also accepts
  UTF-8 literals.  This requires a few follow-on conversions/casts.
* Math between disparate enums is deprecated.  Use constexprs.
* Various algorithms' lambdas must fit tighter constraints.  Add consts.
* Remove some unnecessary qualifications in preparations for later
  constexpr changes.
* std::iterator is removed.  Expose the type aliases directly.
* Types on both sides of comparison operators should be the same.

Bug: 1284275
Change-Id: Icaed9c2ec7d914cc5aba156133ea34152d8ca606
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3632589
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Ted Choc <tedchoc@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1001773}
2022-05-10 23:03:15 +00:00
4748384399 Android: Remove unused base_java deps
Now that build_java and jni_java have been moved out of base_java's
public_deps and base_java no longer contains annotations, remove deps on
base_java that are now unnecessary (Removed 169/608 base_java deps or ~27.8%).

Bug: 1038372
Change-Id: I520f9cd849c9f142948941af5d7fe108b3d8c390
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3623861
Reviewed-by: Mohamed Heikal <mheikal@chromium.org>
Owners-Override: Peter Wen <wnwen@chromium.org>
Auto-Submit: Peter Wen <wnwen@chromium.org>
Commit-Queue: Mohamed Heikal <mheikal@chromium.org>
Cr-Commit-Position: refs/heads/main@{#998944}
2022-05-03 17:36:31 +00:00
8a196c163b Android: Depend on jni_java explicitly
This CL moves jni_java from base_java's public_dep to a regular dep.
This means that targets which only need jni_java do not need to depend
on the entirety of base_java. A future CL will remove base_java from
targets that no longer need it as a result of this CL and this other CL
for build_java: https://crrev.com/c/3606468

By using dep_operations.py split and then dep_operations.py remove, this
CL avoided adding 326 instances of jni_java across 201 files.

Bug: 1038372
Change-Id: Ifd411a923dc834d37e0a4c80daf5797c355c6f52
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3615049
Auto-Submit: Peter Wen <wnwen@chromium.org>
Commit-Queue: Peter Wen <wnwen@chromium.org>
Reviewed-by: Mohamed Heikal <mheikal@chromium.org>
Owners-Override: Peter Wen <wnwen@chromium.org>
Cr-Commit-Position: refs/heads/main@{#997965}
2022-04-29 22:55:06 +00:00
494cdd47f9 Android: Depend on build_java explicitly
This CL moves build_java from being a public_dep of base_java to a
regular dep. This means other targets that need to depend on build_java
must do so explicitly. Since build_java and base_java are not closely
related, this de-coupling (and when jni annotations are similarly moved)
will reduce the number of targets that depend on base_java only for its
annotations, thus speeding up builds when making changes to base_java.

By using dep_operations.py, this CL avoided adding build_java to 224+
targets that already depended on base_java across 194 files. There are
more opportunities to remove unnecessary dependencies on build_java, but
that is left for future CLs in order to prioritize removing build_java
from base_java's public_deps.

Initial estimate (after jni_java is similarly moved out of public_deps)
is that we can remove more than 265+ dependencies on base_java across
~153 files.

Bug: 1038372
Change-Id: Ia5acc70af449f10363bd7e123473e0823ce31bb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3606468
Reviewed-by: Mohamed Heikal <mheikal@chromium.org>
Commit-Queue: Peter Wen <wnwen@chromium.org>
Owners-Override: Peter Wen <wnwen@chromium.org>
Cr-Commit-Position: refs/heads/main@{#996885}
2022-04-27 21:12:52 +00:00
badee1190c components: Include chromeos_buildflags
Source files using OS_CHROME_... now include
build/chromeos_buildflags.h

Bug: 1246565
Change-Id: I3794aac06d79e4d8f3525bd7b7533d33261d8358
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3551782
Auto-Submit: Eric Willigers <ericwilligers@chromium.org>
Reviewed-by: Cait Phillips <caitkp@chromium.org>
Commit-Queue: Cait Phillips <caitkp@chromium.org>
Cr-Commit-Position: refs/heads/main@{#988656}
2022-04-04 20:53:58 +00:00
bdd68018e8 [base] Remove unused post_task.h includes
This CL is a no-op.

Bug: 1026641
AX-Relnotes: n/a
Change-Id: If45d30e748b65097bb6be666dc305c27183d83ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3555247
Commit-Queue: Gabriel Charette <gab@chromium.org>
Auto-Submit: Gabriel Charette <gab@chromium.org>
Reviewed-by: Francois Pierre Doray <fdoray@chromium.org>
Commit-Queue: Francois Pierre Doray <fdoray@chromium.org>
Owners-Override: Francois Pierre Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/main@{#987328}
2022-03-31 04:00:05 +00:00
1dcf647b10 [base] IWYU for Callback
Only fixing callsites that explicitly invoke operator= or the Callback
constructor (to avoid tweaking files that specify it in overrides/etc.)
outside of a comment.

i.e. matching this regex:
'\n *[^/\n][^/\n][^/\n]*base::(Once|Repeating)?(Callback|Closure)( =|\(\))'

and skipping any files that already has a fwd-decl as either:
 - 'class (Once|Repeating)?(Callback|Closure);'
 - 'base/callback_forward.h'

This is a prereq to remove unused base/task/post_task.h includes in
https://chromium-review.googlesource.com/c/chromium/src/+/3555247

Bug: 1026641
Change-Id: I20f661e4b388b83606359b7fcdebc8cd93095bf3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3554741
Commit-Queue: Gabriel Charette <gab@chromium.org>
Auto-Submit: Gabriel Charette <gab@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#986224}
2022-03-28 23:42:56 +00:00
00c5151dde Allow base::Value::Dict/base::Value::List to be used with PrefService.
Bug: 1302561
Change-Id: I562f36aa2378bcc9f6c17e489aebedf58625cdf6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3501611
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#978995}
2022-03-09 01:07:03 +00:00
3d9d2dd38b lacros - crosapi for extension controlled prefs
This change adds support for ChromeSetting extension-controlled prefs
to the existing Prefs crosapi, including get/set/clear functionality.
This allows these prefs to be set from lacros (lacros will use this
crosapi in a future change).

In lacros (outside of this change), we will compute the value of all
extension-controlled prefs. In this change, we write the computed value
inside of ash directly to the extension prefstore. This is OK for these
prefs, because all extensions which modify these prefs will run from
lacros.

Bug: 1218145
Change-Id: If328f40a1f940f23a87e0a9d1b5b540e1d976154
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3063958
Reviewed-by: Erik Chen <erikchen@chromium.org>
Reviewed-by: Devlin Cronin <rdevlin.cronin@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Ian Helmke <helmke@google.com>
Cr-Commit-Position: refs/heads/main@{#978920}
2022-03-08 23:01:42 +00:00
350a3408a8 Retire class ReadErrorHandler
ReadErrorHandler was introduced in
https://codereview.chromium.org/6894020/patch/36001/33019
and has been redundant since
https://crrev.com/c/3381696/20/components/prefs/pref_service.cc

Change-Id: Ia1f9e201961bb3a199384eda5be53a165fd424b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3494986
Reviewed-by: Gabriel Charette <gab@chromium.org>
Auto-Submit: Eric Willigers <ericwilligers@chromium.org>
Commit-Queue: Eric Willigers <ericwilligers@chromium.org>
Cr-Commit-Position: refs/heads/main@{#978105}
2022-03-07 00:31:12 +00:00
88b2443b34 Add missing includes of //base/observer_list.h
Bug: 1290552
Change-Id: I232c1c991e45de275f7c652b1ea191c6f096a559
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3492976
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Owners-Override: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#975612}
2022-02-28 01:10:02 +00:00
7b7aaecca4 Migrate base::{size,empty,data} to STL equivalents in //components.
Bug: 1299695
Change-Id: Ia2ef2239d649b2a50569cad9b3f293ca23510b68
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3491962
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Owners-Override: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#975484}
2022-02-26 17:57:25 +00:00
c1fc726d71 Remove observers when pref_service is destroyed
This fixes a bug where the observer may still be attached if
pref_service is destroyed before prefs are fully loaded.

Bug: 1218145
Change-Id: I305449469354c2da6511c85b39bd0e49890502e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3460869
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Ian Helmke <helmke@google.com>
Cr-Commit-Position: refs/heads/main@{#971293}
2022-02-15 17:37:01 +00:00
ca81109967 Use JsonPrefStore for standalone_browser_prefs
Persist standalone browser prefs in ash using json_pref_store.

Delete standalone_browser_pref_store, as it is now unneeded.

Initially it seemed like a standalone_browser_pref_store would be
necessary because, in the case of extension prefs, we write the
prefs to the user pref store. However, reusing json_pref_store seems
simpler in this case; it persists a pref_store to a file which is
exactly what is needed for standalone browser prefs.

Standalone browser prefs are initialised in roughly the same way
as the user_pref_store, as they are both loaded from files.

Bug: 1218145
Change-Id: Ic79c3bedc8164864cbcabe09256767cd7f4c3727
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3381696
Reviewed-by: Jenny Zhang <jennyz@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Ian Helmke <helmke@google.com>
Cr-Commit-Position: refs/heads/main@{#968848}
2022-02-09 11:51:16 +00:00
59caa8489d Introduce caching of the PlatformManagementService values
The PlatformManagementService returns information about the management
of the OS/platform using ManagementStatusProvider. These provider may
require IO or long operations to get the management state. Since that
information is required early at startup, those providers will cache
their values in the local state so that it is quickly accessible at
startup.

Bug: 1238355
Change-Id: I05940fd7897383d3def29b4cbc24070d1b597633
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3413935
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Owen Min <zmin@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Commit-Queue: Yann Dago <ydago@chromium.org>
Cr-Commit-Position: refs/heads/main@{#968425}
2022-02-08 18:19:30 +00:00
b7825cb95d Remove uses of Value::Equals
This CL removes uses of Value::Equals in
overlay_user_pref_store_unittest.cc.

Bug: 1187018
Change-Id: I95af7a75f48152ef23168a003c2827907946b526
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3442874
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Ghazale Hosseinabadi <ghazale@chromium.org>
Cr-Commit-Position: refs/heads/main@{#968308}
2022-02-08 14:21:07 +00:00
043803dd8c Remove uses of Value::Equals
This CL removes uses of Value::Equals in some //components unit tests.

Bug: 1187018
Change-Id: If86bbb769ff557b97c814a04bca7d3278a14ad62
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3443021
Reviewed-by: Yann Dago <ydago@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Ghazale Hosseinabadi <ghazale@chromium.org>
Cr-Commit-Position: refs/heads/main@{#968010}
2022-02-07 22:03:14 +00:00
91148c1c1e Migrate base::Value::GetList() to base::Value::GetListDeprecated(): 2/N.
GetList() will be reimplemented in a future CL with an updated
signature, so existing uses need to be renamed out of the way.

Unlike TakeList() and TakeDict(), GetList() is used quite widely. This
CL migrates a number of uses using the following set of automated steps:

sed -i "s|\.GetList()|.GetListDeprecated()|g" \
    $(git gs "GetList()" --name-only)
git checkout -- base/values.cc base/values.h
git checkout -- base/values_unittest.cc third_party/dom_distiller_js
git checkout -- tools/clang
git cl format

Bug: 1291666
Change-Id: I0413b4857cbf38943333988e36da53f44aab7a15
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3435727
Reviewed-by: danakj chromium <danakj@chromium.org>
Commit-Queue: danakj chromium <danakj@chromium.org>
Owners-Override: danakj chromium <danakj@chromium.org>
Cr-Commit-Position: refs/heads/main@{#966793}
2022-02-03 17:39:57 +00:00
354945de1f Migrate base::Value::GetList() to base::Value::GetListDeprecated(): 1/N.
GetList() will be reimplemented in a future CL with an updated
signature, so existing uses need to be renamed out of the way.

Unlike TakeList() and TakeDict(), GetList() is used quite widely. This
CL migrates a number of uses using the following set of automated steps:

sed -i "s|->GetList()|->GetListDeprecated()|g" \
    $(git gs "GetList()" --name-only)
git checkout -- base/values_unittest.cc third_party/dom_distiller_js
git cl format

Bug: 1291666
Change-Id: I1b7a92fcb4874e7afb82d4bd092c1c9de2cc3d05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3430698
Reviewed-by: danakj chromium <danakj@chromium.org>
Owners-Override: danakj chromium <danakj@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#966487}
2022-02-02 23:39:17 +00:00
a9033262f7 [Code health] Remove uses of Value::Equal
This CL removes uses of Value::Equal in pref_member_unittest.cc

Bug: 1187018
Change-Id: I8931a930e071fece58969d62b342f43d6dead0b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3425475
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Ghazale Hosseinabadi <ghazale@chromium.org>
Cr-Commit-Position: refs/heads/main@{#965527}
2022-02-01 04:44:56 +00:00
5e3c76f204 Finish ScopedUserPrefUpdate migration to modern base::Value
base::DictionaryValue and base::ListValue are deprecated. All users of
DictionaryPrefUpdateDeprecated and ListPrefUpdateDeprecated have been
migrated to the new forms that don't use those deprecated types. So,
this cl removes the old forms and does some consequential clean up.

Bug: 1285745
Change-Id: Ibd0f2417e7944ea6f3979ed2e85a34f60dfb5d41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3407603
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Alex Turner <alexmt@chromium.org>
Cr-Commit-Position: refs/heads/main@{#962143}
2022-01-21 23:35:54 +00:00
bca91f9c4a components: Use BUILDFLAG for OS checking
Use BUILDFLAG(IS_XXX) instead of defined(OS_XXX).

Generated by `os_buildflag_migration.py` (https://crrev.com/c/3311983).

Bug: 1234043
Test: No functionality change
Change-Id: I0b8d92c2fe79a3904bcb2d22f12032424e32d576
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3391443
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#959660}
2022-01-15 19:56:21 +00:00
7ff0c2a045 [Code Health Rotation] Remove Value::CreateDeepCopy
Bug: 1187013
Change-Id: Icb381646fa4dde6df306472a983b63c846f93ed8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3377063
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Stefano Duo <stefanoduo@google.com>
Cr-Commit-Position: refs/heads/main@{#958562}
2022-01-13 13:03:37 +00:00
223daa5d3b Use base::ValuesEquivalent outside of Blink code
This CL builds upon
https://chromium-review.googlesource.com/c/chromium/src/+/3361660
by making use of the newly upstreamed base::ValuesEquivalent() helper
function in Chromium code.

There are negligible behavioral changes in this CL.
Some comparisons now check pointer equality before checking value
equality.

Bug: 1283353
Change-Id: I49d639aa69bcc7ac4149d9602b68906a82c033bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3365147
Reviewed-by: Colin Blundell <blundell@chromium.org>
Reviewed-by: Denis Kuznetsov <antrim@chromium.org>
Reviewed-by: Min Qin <qinmin@chromium.org>
Reviewed-by: David Tseng <dtseng@chromium.org>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Nektarios Paisios <nektar@chromium.org>
Reviewed-by: Nick Burris <nburris@chromium.org>
Reviewed-by: Behdad Bakhshinategh <behdadb@chromium.org>
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Cr-Commit-Position: refs/heads/main@{#958381}
2022-01-13 01:09:47 +00:00
e61aa22c18 [Code Health Rotation] Remove Value::CreateDeepCopy
Bug: 1187013
Change-Id: I70b38b7050fcbe4744b37023616b28456acc9635
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3379989
Reviewed-by: Colin Blundell <blundell@chromium.org>
Commit-Queue: Stefano Duo <stefanoduo@google.com>
Cr-Commit-Position: refs/heads/main@{#958049}
2022-01-12 13:45:10 +00:00
82f2898b69 Begin ScopedUserPrefUpdate migration to modern base::Value
base::DictionaryValue and base::ListValue are deprecated. To allow for
incremental migration, a "Deprecated" suffix is added to the current
DictionaryPrefUpdate and ListPrefUpdate and new definitions using
base::Value are added. Future cls will convert uses from the old to new
typedefs.

Bug: 1285745
Change-Id: I05654d4ba4206691527f798dc12da3175aa4de37
AX-Relnotes: n/a.
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3376154
Reviewed-by: Dominic Battré <battre@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Owners-Override: Kentaro Hara <haraken@chromium.org>
Commit-Queue: Alex Turner <alexmt@chromium.org>
Cr-Commit-Position: refs/heads/main@{#957434}
2022-01-11 06:08:43 +00:00
01efe64eac [Prefs] Remove fixed DumpWithoutCrashing call.
crbug.com/945772 added a call to DumpWithoutCrashing for leaking
subscribers to default_search_provider_data.template_url_data. 945772
was fixed in M93. It appears iOS has a similar issue, but these reports
are only showing up for iOS in M97 now that iOS is experimenting with
Crashpad. There's another bug (1272165) tracking this new issue, and
given how often this happens triggering a DWC seems unnecessary.

Since the original bug is fixed, removing for now.

Bug: 1272165, 945772, 1283552
Change-Id: Id081be788651e2b9b0155360fced473e814140dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3362646
Auto-Submit: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/main@{#956021}
2022-01-06 03:23:52 +00:00
17c8f5f65c LSC: Replace FALLTHROUGH macro with C++17 [[fallthrough]] attribute
See go/chromium-lsc-fallthrough

This CL was uploaded by git cl split.

R=battre@chromium.org

Bug: 1283907
Change-Id: I3908a5188e65b205540bbef9d3afc95784fa7e49
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3366423
Auto-Submit: Roland Bock <rbock@google.com>
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/main@{#955130}
2022-01-04 15:25:54 +00:00
7d219a2536 [Code Health] Refactor PrefService GetDict + GetList to use base::Value
LSC doc: go/prefservice-value-refactor

All type  changes are commented.

Bug: 1187001, 1187061, 1187062
Change-Id: Iafefe56f769b7cb4a05ed4afbfb6e9a561b4704a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3343526
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Owners-Override: Kentaro Hara <haraken@chromium.org>
Commit-Queue: Austin Sullivan <asully@chromium.org>
Cr-Commit-Position: refs/heads/main@{#952919}
2021-12-20 14:55:31 +00:00
2ff27e52ab Add LacrosPrefStore for lacros settings
This change adds a LacrosPrefStore for ash. This PrefStore will exist
only in ash and holds prefs sent from lacros to ash. In particular, it
will be used to store extension-controlled prefs.

In a follow-up, this PrefStore will be persisted. It is not persisted or
used in this change.

Bug: 1218145
Change-Id: I4914bd4080841a7148259c368ae0610686d9f862
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3287323
Reviewed-by: Jenny Zhang <jennyz@chromium.org>
Reviewed-by: Devlin Cronin <rdevlin.cronin@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Ian Helmke <helmke@google.com>
Cr-Commit-Position: refs/heads/main@{#952575}
2021-12-16 23:44:56 +00:00
21f256b202 CodeHealth: Remove DictionaryValue::Get in components/
Bug: 1187032
Change-Id: I1a2a9a3a0b2ff13d0764a7decc0b85166859d3f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3325882
Auto-Submit: Li-Yu Yu <aaronyu@google.com>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Commit-Queue: Li-Yu Yu <aaronyu@google.com>
Cr-Commit-Position: refs/heads/main@{#950531}
2021-12-10 14:41:59 +00:00
9250cb6111 [headless] Avoid persisting local state.
Since headless introduced preferences support, it started saving
and reloading the local state automatically, thus persisting local
state changes. This changed the previous expectation that headless
always starts in a known state defined by the default profile.

This change prevents local state changes from being saved.

As a side effect, this change is expected to fix intermittent file
access violations that occur on Windows where headless saves OSCrypt
key in the local state.

Bug: 1237124
Change-Id: I628ef3f86250c436778488a611f2f86e35bf797d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3313465
Reviewed-by: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: Peter Kvitek <kvitekp@chromium.org>
Cr-Commit-Position: refs/heads/main@{#948103}
2021-12-03 19:34:02 +00:00
0e45c020c4 Rewrite most Foo* field_ pointer fields to raw_ptr<Foo> field_.
DO NOT REVERT (unless absolutely necessary)! Report build breaks to keishi@(APAC)/glazunov@(EMEA)/sebmarchand@(NA) as soon as you see them. Fixes are expected to be trivial.

This commit was generated automatically, by running the following script: tools/clang/rewrite_raw_ptr_fields/rewrite-multiple-platforms.sh on commit fe74bc434e

For more information, see MiraclePtr One Pager [1], the PSA at chromium-dev@ [2], and the raw_ptr documentation in //base/memory/raw_ptr.md.

FYI This CL does not enable MiraclePtr protection and we expect no behavior change from this.

[1] https://docs.google.com/document/d/1pnnOAIz_DMWDI4oIOFoMAqLnf_MZ2GsrJNb_dbQ3ZBg/edit?usp=sharing
[2] https://groups.google.com/a/chromium.org/g/chromium-dev/c/vAEeVifyf78/m/SkBUc6PhBAAJ

Binary-Size: Increase of around 500kb was approved for MiraclePtr
Include-Ci-Only-Tests: true
No-Tree-Checks: true
No-Presubmit: true
Bug: 1272324, 1073933
Change-Id: I05c86a83bbb4b3f4b017f361dd7f4e7437697f69
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3305132
Commit-Queue: Keishi Hattori <keishi@chromium.org>
Reviewed-by: Bartek Nowierski <bartekn@chromium.org>
Owners-Override: Bartek Nowierski <bartekn@chromium.org>
Cr-Commit-Position: refs/heads/main@{#945735}
2021-11-27 09:25:52 +00:00
b9e2c27ca6 Remove unused "base/macros.h" in components/
Removes `#include "base/macros.h"` from files in components/ that do not
contain `ignore_result(`.

Bug: 1010217
Change-Id: Ic1ea0c59d63652bc896e80638a7ff919c872f1c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3275012
Commit-Queue: Peter Boström <pbos@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Owners-Override: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#940666}
2021-11-11 05:31:49 +00:00
643cdf6190 Replace base/task/ temporary forward headers with their final locations
Note to QA: This merely changes includes and should not be blamed
for files it touched.

Bug: 1255932
Change-Id: I1ce4e31efd5792ebf2080812e665cae838a54972
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3226943
Reviewed-by: Gabriel Charette <gab@chromium.org>
Owners-Override: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#932153}
2021-10-15 19:13:42 +00:00
e66d3450bf Remove CommitPendingWriteSynchronously() functions and tests.
This function was added in crrev.com/c/2898323, and it stopped being
used in crrev/c/3210328.

Bug: 1241702
Change-Id: Ibb9303ba56c4851ae962701311491c4bea5c005e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3211629
Reviewed-by: Dominic Battré <battre@chromium.org>
Commit-Queue: Caitlin Fischer <caitlinfischer@google.com>
Cr-Commit-Position: refs/heads/main@{#930738}
2021-10-12 19:50:42 +00:00
3d7d70920a Replace task-related headers to their equivalent in base/task/
This CL was generated by using tools/git/move_source_file.py to change
the includes for those files:
base/bind_post_task.h
base/deferred_sequenced_task_runner.h
base/post_task_and_reply_with_result_internal.h
base/sequenced_task_runner.h
base/sequenced_task_runner_helpers.h
base/single_thread_task_runner.h
base/task_runner.h
base/task_runner_util.h
base/updateable_sequenced_task_runner.h

Then formatted using "git cl format". DEPS files were fixed with a
simple search and replace script.

Bug: 1255932
Change-Id: I0d9b5ddd9260fde5e4581e6c6e0080bdb0ed2c44
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3209175
Reviewed-by: Gabriel Charette <gab@chromium.org>
Owners-Override: Gabriel Charette <gab@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#929867}
2021-10-08 20:27:23 +00:00
f1aea0e441 Remove the PrefService experiment groups from the Safe Mode experiment.
The PrefService approach is slower than the base::WriteFile approach.

In this change, the study group names are also renamed and
Variations.ExtendedSafeMode.WritePrefsTime is emitted for the control
group.

Metrics:
https://uma.googleplex.com/p/chrome/variations?sid=e0c0d90b97dd3e65dd217473b3c7ac93
https://uma.googleplex.com/p/chrome/variations?sid=c740c9fefcabfe67fdd3e053d4d2055c

Bug: 1241702
Change-Id: I42b8d66cc3c6ccb72718887a87f67c5b5b5a83ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3210328
Commit-Queue: Caitlin Fischer <caitlinfischer@google.com>
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/main@{#929756}
2021-10-08 17:32:50 +00:00
e5a38eddbd Migrate "base::TimeDelta::FromX" to "base:X".
All changes were done automatically with git grep, sed, xargs, etc.

No-Presubmit: true
No-Try: true
Bug: 1243777
Change-Id: I7cc197e9027f7837cd36afc67a209079f85ec364
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3198824
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Owners-Override: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#927512}
2021-10-02 03:06:35 +00:00
9f667c3873 Remove DISALLOW_* macros from components/
This inlines all remaining DISALLOW_* macros in components/. This is
done manually (vim regex + manually finding insertion position).

IWYU cleanup is left as a separate pass that is easier when these macros
go away.

Bug: 1010217
Change-Id: I2409b6250d85e74e8c4b6863fbeeaaeacc37733c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3194821
Commit-Queue: Peter Boström <pbos@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Owners-Override: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#927361}
2021-10-01 20:09:31 +00:00
09c0182fae Replace DISALLOW_COPY_AND_ASSIGN in components/
This replaces DISALLOW_COPY_AND_ASSIGN with explicit constructor deletes
where a local script is able to detect its insertion place (~Foo() is
public => insert before this line).

This is incomplete as not all classes have a public ~Foo() declared, so
not all DISALLOW_COPY_AND_ASSIGN occurrences are replaced.

IWYU cleanup is left as a separate pass that is easier when these macros
go away.

Bug: 1010217
Change-Id: I917bfbff1357e9e2cfe330d242feff6bb73e1bce
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3167004
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#923103}
2021-09-20 22:43:27 +00:00