diff --git a/.gn b/.gn index 5356717..5a11496 100644 --- a/.gn +++ b/.gn
@@ -82,6 +82,12 @@ "//v8:cppgc_base", # 1 error "//v8:v8_internal_headers", # 11 errors "//v8:v8_libplatform", # 2 errors + + # After making partition_alloc a standalone library, remove partition_alloc + # target from the skip list, because partition_aloc will depend on its own + # base. + # partition alloc standalone library bug is https://crbug.com/1151236. + "//base/allocator/partition_allocator:partition_alloc", # 292 errors ] # These are the list of GN files that run exec_script. This whitelist exists
diff --git a/AUTHORS b/AUTHORS index 20e1d24..03531bc 100644 --- a/AUTHORS +++ b/AUTHORS
@@ -1235,6 +1235,7 @@ Xiaoshu Zhang <xiaoshu@amazon.com> Xiaoyin Liu <xiaoyin.l@outlook.com> Xinchao He <hexinchao@gmail.com> +Xinchao Tian <tianxinchao@360.cn> Xing Zhang <xzhang@adobe.com> Xinghua Cao <xinghua.cao@intel.com> Xu Samuel <samuel.xu@intel.com>
diff --git a/DEPS b/DEPS index 9fc2888..e59d393 100644 --- a/DEPS +++ b/DEPS
@@ -213,7 +213,7 @@ # luci-go CIPD package version. # Make sure the revision is uploaded by infra-packagers builder. # https://ci.chromium.org/p/infra-internal/g/infra-packagers/console - 'luci_go': 'git_revision:cb424e70e75136736a86359ef070aa96425fe7a3', + 'luci_go': 'git_revision:6da0608e4fa8a3c6d1fa4f855485c0038b05bf72', # This can be overridden, e.g. with custom_vars, to build clang from HEAD # instead of downloading the prebuilt pinned revision. @@ -253,19 +253,19 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling Skia # and whatever else without interference from each other. - 'skia_revision': '357881bc95a9bea30591a380df18ac8235c432fe', + 'skia_revision': 'fd96fb27a906329bcf7a004152a0744611413597', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling V8 # and whatever else without interference from each other. - 'v8_revision': '3e31b8b72432ea5bb72c6947c7340d456637ee88', + 'v8_revision': '2f8f521e1bd109e2ae6db70e8076402bbfaaf5e6', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling ANGLE # and whatever else without interference from each other. - 'angle_revision': '73ec28af7ab9cef5624474ea975daa2c2c10cb5c', + 'angle_revision': 'fa5c349dc73cd4cc3e015d6e2da3ba0eb57ffe4e', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling SwiftShader # and whatever else without interference from each other. - 'swiftshader_revision': '33b068cc682bfb0034d9f552e7a6858acd21199a', + 'swiftshader_revision': '040e2534e06f68933ee6ddeb75dbef9ee3798fd0', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling PDFium # and whatever else without interference from each other. @@ -284,7 +284,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling googletest # and whatever else without interference from each other. - 'googletest_revision': '0affd45b62371c1de44064a5a5f8817242208442', + 'googletest_revision': 'af29db7ec28d6df1c7f0f745186884091e602e07', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling lighttpd # and whatever else without interference from each other. @@ -328,7 +328,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling devtools-frontend # and whatever else without interference from each other. - 'devtools_frontend_revision': 'd4240f8bc96a3ebd2dc2a5b316fd41c24e20fb3c', + 'devtools_frontend_revision': 'fca20258b576a52d244bd4bfd6adc4d9f3400c90', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling libprotobuf-mutator # and whatever else without interference from each other. @@ -368,7 +368,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. - 'dawn_revision': '7cff75ad59224f224c2c574dca5e32b764b943b0', + 'dawn_revision': 'c63ce343fd61623e4b254f9ec656543c30e3df6f', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. @@ -724,7 +724,7 @@ Var('chromium_git') + '/external/github.com/toji/webvr.info.git' + '@' + 'c58ae99b9ff9e2aa4c524633519570bf33536248', 'src/docs/website': { - 'url': Var('chromium_git') + '/website.git' + '@' + 'bcb3b2b76610f16202a3e702c86b89c3f2d93b5a', + 'url': Var('chromium_git') + '/website.git' + '@' + '326bd0e693eef75d6b10294e6acbfd3bfed3636b', }, 'src/ios/third_party/earl_grey2/src': { @@ -1140,7 +1140,7 @@ }, 'src/third_party/depot_tools': - Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '4de5deacd4a7cb46637a3d446b9c0dc258be1159', + Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '62396c5a83595ec985578fe3e163fde931062615', 'src/third_party/devtools-frontend/src': Var('chromium_git') + '/devtools/devtools-frontend' + '@' + Var('devtools_frontend_revision'), @@ -1523,7 +1523,7 @@ }, 'src/third_party/perfetto': - Var('android_git') + '/platform/external/perfetto.git' + '@' + 'ae44ad76bdf06db6f4e11186dd30cfdbc7d852b0', + Var('android_git') + '/platform/external/perfetto.git' + '@' + 'a8f0cd2c06fe26eb10b280c3c25db17b5d45519e', 'src/third_party/perl': { 'url': Var('chromium_git') + '/chromium/deps/perl.git' + '@' + '6f3e5028eb65d0b4c5fdd792106ac4c84eee1eb3', @@ -1601,7 +1601,7 @@ 'packages': [ { 'package': 'fuchsia/third_party/android/aemu/release/linux-amd64', - 'version': 'VM4C_VX_E3_djO4b_7MWuQRqaKy4BHG-XIcIxZOaHjMC' + 'version': 'Ll1K_vgpqMalp4Cpe2QyiKtTn_QVfKMNpuLLAitRCyQC' }, ], 'condition': 'host_os == "linux" and checkout_fuchsia', @@ -1744,7 +1744,7 @@ Var('chromium_git') + '/external/github.com/gpuweb/cts.git' + '@' + '981b513154230fb38aaa1d999d4c30bd7a3c3966', 'src/third_party/webrtc': - Var('webrtc_git') + '/src.git' + '@' + 'b9c636506bbee5ca6b7494888dc1fe6cb92009ce', + Var('webrtc_git') + '/src.git' + '@' + 'ccc9d979a5291e62096ac645c4ce9873afc40496', 'src/third_party/libgifcodec': Var('skia_git') + '/libgifcodec' + '@'+ Var('libgifcodec_revision'), @@ -1814,7 +1814,7 @@ Var('chromium_git') + '/v8/v8.git' + '@' + Var('v8_revision'), 'src-internal': { - 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@bdd9ffebf5fdfb6a17c7047a6cf0401cc1e10667', + 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@6d18923631141835e0adc754887039dce6e5c730', 'condition': 'checkout_src_internal', }, @@ -1833,7 +1833,7 @@ 'packages': [ { 'package': 'chromeos_internal/apps/eche_app/app', - 'version': 'ZpuWWOZwhn4j7SwQMvPc-NJOqV4p32nHSxVOFDH3a3MC', + 'version': 'uDlRPAgtM1_YcvXT8TfcsJHXdQnwg_BAKJOa_xQ5Oo4C', }, ], 'condition': 'checkout_chromeos and checkout_src_internal', @@ -1866,7 +1866,7 @@ 'packages': [ { 'package': 'chromeos_internal/apps/projector_app/app', - 'version': 'hhaZ4wwFvw_EnAvJ4FOqnRKI9HtEMM1JQyyv3LfgXJwC', + 'version': 'm6aN2ekWTaAVwwBuO5aNNFk78J5LvfrmeFg0mX_Dk6cC', }, ], 'condition': 'checkout_chromeos and checkout_src_internal',
diff --git a/android_webview/system_webview_apk_tmpl.gni b/android_webview/system_webview_apk_tmpl.gni index 1434ca3..86f8504 100644 --- a/android_webview/system_webview_apk_tmpl.gni +++ b/android_webview/system_webview_apk_tmpl.gni
@@ -231,6 +231,13 @@ # Shortens resource file names in apk eg: res/drawable/button.xml -> res/a.xml short_resource_paths = !is_java_debug + + # Removes unused resources from the apk. Only enabled on official builds + # since it adds a slow step and serializes the build graph causing fewer + # expensive tasks (eg: proguarding, resource optimization) to be run in + # parallel by adding dependencies between them (adds around 10-20 + # seconds on my machine). + strip_unused_resources = is_official_build } if (!_is_bundle_module) {
diff --git a/android_webview/system_webview_bundle.gni b/android_webview/system_webview_bundle.gni index b73c49f..e218277 100644 --- a/android_webview/system_webview_bundle.gni +++ b/android_webview/system_webview_bundle.gni
@@ -88,6 +88,9 @@ proguard_android_sdk_dep = webview_framework_dep } + # For this to be respected, it must also be set on the base module target. + strip_unused_resources = is_official_build + forward_variables_from(invoker, "*") } }
diff --git a/ash/ash_strings.grd b/ash/ash_strings.grd index 7d0ef96..2c45f08 100644 --- a/ash/ash_strings.grd +++ b/ash/ash_strings.grd
@@ -4649,6 +4649,9 @@ <message name="IDS_APP_LIST_OPEN_TAB_HINT" desc="Shown alongside launcher search results which will take the user to an open tab when clicked."> Go to this tab </message> + <message name="IDS_APP_LIST_SEARCH_GAME_PLATFORMS_PREFIX" desc="Shown next to a video game search result, begins a list of cloud gaming platforms the game is playable on."> + on + </message> <message name="IDS_APP_LIST_START_ASSISTANT" desc="Tooltip for the button that starts Google Assistant from the search box in the app list."> Google Assistant </message>
diff --git a/ash/ash_strings_grd/IDS_APP_LIST_SEARCH_GAME_PLATFORMS_PREFIX.png.sha1 b/ash/ash_strings_grd/IDS_APP_LIST_SEARCH_GAME_PLATFORMS_PREFIX.png.sha1 new file mode 100644 index 0000000..baccdde --- /dev/null +++ b/ash/ash_strings_grd/IDS_APP_LIST_SEARCH_GAME_PLATFORMS_PREFIX.png.sha1
@@ -0,0 +1 @@ +2098bdec94d7cc66c749c8caa9127e2ffd1115f2 \ No newline at end of file
diff --git a/ash/constants/ash_features.cc b/ash/constants/ash_features.cc index c821ec5..2c83ccf 100644 --- a/ash/constants/ash_features.cc +++ b/ash/constants/ash_features.cc
@@ -1384,6 +1384,10 @@ const base::Feature kVirtualKeyboardBorderedKey{ "VirtualKeyboardBorderedKey", base::FEATURE_ENABLED_BY_DEFAULT}; +// Enable or disable multitouch for virtual keyboard on Chrome OS. +const base::Feature kVirtualKeyboardMultitouch{ + "kVirtualKeyboardMultitouch", base::FEATURE_DISABLED_BY_DEFAULT}; + // Controls whether to allow enabling wake on WiFi features in shill. const base::Feature kWakeOnWifiAllowed{"WakeOnWifiAllowed", base::FEATURE_DISABLED_BY_DEFAULT};
diff --git a/ash/constants/ash_features.h b/ash/constants/ash_features.h index 0e945d3..a8478d3 100644 --- a/ash/constants/ash_features.h +++ b/ash/constants/ash_features.h
@@ -540,7 +540,10 @@ extern const base::Feature kUserActivityPrediction; COMPONENT_EXPORT(ASH_CONSTANTS) extern const base::Feature kVirtualKeyboardBorderedKey; -COMPONENT_EXPORT(ASH_CONSTANTS) extern const base::Feature kWakeOnWifiAllowed; +COMPONENT_EXPORT(ASH_CONSTANTS) +extern const base::Feature kVirtualKeyboardMultitouch; +COMPONENT_EXPORT(ASH_CONSTANTS) +extern const base::Feature kWakeOnWifiAllowed; COMPONENT_EXPORT(ASH_CONSTANTS) extern const base::Feature kWallpaperWebUI; COMPONENT_EXPORT(ASH_CONSTANTS) extern const base::Feature kWallpaperFullScreenPreview;
diff --git a/ash/public/cpp/app_list/app_list_features.cc b/ash/public/cpp/app_list/app_list_features.cc index 0f3f962..4aed15f7 100644 --- a/ash/public/cpp/app_list/app_list_features.cc +++ b/ash/public/cpp/app_list/app_list_features.cc
@@ -43,6 +43,8 @@ base::FEATURE_ENABLED_BY_DEFAULT}; const base::Feature kDynamicSearchUpdateAnimation{ "DynamicSearchUpdateAnimation", base::FEATURE_DISABLED_BY_DEFAULT}; +const base::Feature kLauncherLacrosIntegration{ + "LauncherLacrosIntegration", base::FEATURE_DISABLED_BY_DEFAULT}; bool IsAppRankerEnabled() { return base::FeatureList::IsEnabled(kEnableAppRanker); @@ -118,6 +120,11 @@ base::FeatureList::IsEnabled(kDynamicSearchUpdateAnimation); } +bool IsLauncherLacrosIntegrationEnabled() { + return base::FeatureList::IsEnabled(chromeos::features::kLacrosSupport) && + base::FeatureList::IsEnabled(kLauncherLacrosIntegration); +} + std::string CategoricalSearchType() { return GetFieldTrialParamValueByFeature(kCategoricalSearch, "ranking"); }
diff --git a/ash/public/cpp/app_list/app_list_features.h b/ash/public/cpp/app_list/app_list_features.h index 8c1dd299..5cb68f6b 100644 --- a/ash/public/cpp/app_list/app_list_features.h +++ b/ash/public/cpp/app_list/app_list_features.h
@@ -74,6 +74,10 @@ // are interrupted by search model updates. ASH_PUBLIC_EXPORT extern const base::Feature kDynamicSearchUpdateAnimation; +// Forces the Launcher provider to send Omnibox search queries to the lacros +// browser. If disabled, queries are sent to the ash browser. +ASH_PUBLIC_EXPORT extern const base::Feature kLauncherLacrosIntegration; + ASH_PUBLIC_EXPORT bool IsAppRankerEnabled(); ASH_PUBLIC_EXPORT bool IsZeroStateAppsRankerEnabled(); ASH_PUBLIC_EXPORT bool IsQueryBasedMixedTypesRankerEnabled(); @@ -92,6 +96,7 @@ ASH_PUBLIC_EXPORT bool IsSearchResultInlineIconEnabled(); ASH_PUBLIC_EXPORT bool IsDynamicSearchUpdateAnimationEnabled(); ASH_PUBLIC_EXPORT base::TimeDelta DynamicSearchUpdateAnimationDuration(); +ASH_PUBLIC_EXPORT bool IsLauncherLacrosIntegrationEnabled(); ASH_PUBLIC_EXPORT std::string AnswerServerUrl(); ASH_PUBLIC_EXPORT std::string AnswerServerQuerySuffix();
diff --git a/ash/services/BUILD.gn b/ash/services/BUILD.gn index bb9a4e84..b17963b 100644 --- a/ash/services/BUILD.gn +++ b/ash/services/BUILD.gn
@@ -17,6 +17,7 @@ testonly = true deps = [ "//ash/services/cellular_setup:unit_tests", + "//ash/services/chromebox_for_meetings/public/cpp:unit_tests", "//ash/services/device_sync:unit_tests", "//ash/services/ime:services_unittests", "//ash/services/ime:unit_tests",
diff --git a/chromeos/services/chromebox_for_meetings/DEPS b/ash/services/chromebox_for_meetings/DEPS similarity index 100% rename from chromeos/services/chromebox_for_meetings/DEPS rename to ash/services/chromebox_for_meetings/DEPS
diff --git a/chromeos/services/chromebox_for_meetings/OWNERS b/ash/services/chromebox_for_meetings/OWNERS similarity index 100% rename from chromeos/services/chromebox_for_meetings/OWNERS rename to ash/services/chromebox_for_meetings/OWNERS
diff --git a/chromeos/services/chromebox_for_meetings/README.md b/ash/services/chromebox_for_meetings/README.md similarity index 100% rename from chromeos/services/chromebox_for_meetings/README.md rename to ash/services/chromebox_for_meetings/README.md
diff --git a/chromeos/services/chromebox_for_meetings/public/cpp/BUILD.gn b/ash/services/chromebox_for_meetings/public/cpp/BUILD.gn similarity index 82% rename from chromeos/services/chromebox_for_meetings/public/cpp/BUILD.gn rename to ash/services/chromebox_for_meetings/public/cpp/BUILD.gn index c007576..e010a74 100644 --- a/chromeos/services/chromebox_for_meetings/public/cpp/BUILD.gn +++ b/ash/services/chromebox_for_meetings/public/cpp/BUILD.gn
@@ -2,9 +2,10 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/config/chromeos/ui_mode.gni") import("//chromeos/components/chromebox_for_meetings/buildflags/buildflags.gni") -assert(is_chromeos, "Non-ChromeOS builds cannot depend on //chromeos") +assert(is_chromeos_ash, "Non-ChromeOS builds cannot depend on //ash") source_set("cpp") { sources = [ @@ -12,8 +13,8 @@ "appid_util.h", ] deps = [ + "//ash/services/chromebox_for_meetings/public/mojom", "//base", - "//chromeos/services/chromebox_for_meetings/public/mojom", ] if (is_cfm) { sources += [ @@ -39,9 +40,9 @@ ] deps = [ ":cpp", + "//ash/services/chromebox_for_meetings/public/mojom", "//base", "//chromeos/dbus/chromebox_for_meetings", - "//chromeos/services/chromebox_for_meetings/public/mojom", "//mojo/public/cpp/bindings", ] } @@ -52,8 +53,8 @@ sources = [ "appid_util_unittest.cc" ] deps = [ ":cpp", + "//ash/services/chromebox_for_meetings/public/mojom", "//base/test:test_support", - "//chromeos/services/chromebox_for_meetings/public/mojom", "//mojo/core/embedder", "//mojo/public/cpp/bindings", "//testing/gtest",
diff --git a/chromeos/services/chromebox_for_meetings/public/cpp/appid_util.cc b/ash/services/chromebox_for_meetings/public/cpp/appid_util.cc similarity index 95% rename from chromeos/services/chromebox_for_meetings/public/cpp/appid_util.cc rename to ash/services/chromebox_for_meetings/public/cpp/appid_util.cc index fb39bb78..d61acf4b 100644 --- a/chromeos/services/chromebox_for_meetings/public/cpp/appid_util.cc +++ b/ash/services/chromebox_for_meetings/public/cpp/appid_util.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/services/chromebox_for_meetings/public/cpp/appid_util.h" +#include "ash/services/chromebox_for_meetings/public/cpp/appid_util.h" #include "base/containers/contains.h"
diff --git a/chromeos/services/chromebox_for_meetings/public/cpp/appid_util.h b/ash/services/chromebox_for_meetings/public/cpp/appid_util.h similarity index 64% rename from chromeos/services/chromebox_for_meetings/public/cpp/appid_util.h rename to ash/services/chromebox_for_meetings/public/cpp/appid_util.h index cf1352f3..a677f29c 100644 --- a/chromeos/services/chromebox_for_meetings/public/cpp/appid_util.h +++ b/ash/services/chromebox_for_meetings/public/cpp/appid_util.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_APPID_UTIL_H_ -#define CHROMEOS_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_APPID_UTIL_H_ +#ifndef ASH_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_APPID_UTIL_H_ +#define ASH_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_APPID_UTIL_H_ #include <string> @@ -16,4 +16,4 @@ } // namespace cfm } // namespace chromeos -#endif // CHROMEOS_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_APPID_UTIL_H_ +#endif // ASH_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_APPID_UTIL_H_
diff --git a/chromeos/services/chromebox_for_meetings/public/cpp/appid_util_unittest.cc b/ash/services/chromebox_for_meetings/public/cpp/appid_util_unittest.cc similarity index 89% rename from chromeos/services/chromebox_for_meetings/public/cpp/appid_util_unittest.cc rename to ash/services/chromebox_for_meetings/public/cpp/appid_util_unittest.cc index 57c194a..f3b7722 100644 --- a/chromeos/services/chromebox_for_meetings/public/cpp/appid_util_unittest.cc +++ b/ash/services/chromebox_for_meetings/public/cpp/appid_util_unittest.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/services/chromebox_for_meetings/public/cpp/appid_util.h" +#include "ash/services/chromebox_for_meetings/public/cpp/appid_util.h" #include "testing/gtest/include/gtest/gtest.h"
diff --git a/chromeos/services/chromebox_for_meetings/public/cpp/fake_service_connection.cc b/ash/services/chromebox_for_meetings/public/cpp/fake_service_connection.cc similarity index 95% rename from chromeos/services/chromebox_for_meetings/public/cpp/fake_service_connection.cc rename to ash/services/chromebox_for_meetings/public/cpp/fake_service_connection.cc index b03806f..fda513e 100644 --- a/chromeos/services/chromebox_for_meetings/public/cpp/fake_service_connection.cc +++ b/ash/services/chromebox_for_meetings/public/cpp/fake_service_connection.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/services/chromebox_for_meetings/public/cpp/fake_service_connection.h" +#include "ash/services/chromebox_for_meetings/public/cpp/fake_service_connection.h" #include "base/bind.h" #include "base/files/file.h"
diff --git a/chromeos/services/chromebox_for_meetings/public/cpp/fake_service_connection.h b/ash/services/chromebox_for_meetings/public/cpp/fake_service_connection.h similarity index 76% rename from chromeos/services/chromebox_for_meetings/public/cpp/fake_service_connection.h rename to ash/services/chromebox_for_meetings/public/cpp/fake_service_connection.h index 0f83d7a8..9a17d2c 100644 --- a/chromeos/services/chromebox_for_meetings/public/cpp/fake_service_connection.h +++ b/ash/services/chromebox_for_meetings/public/cpp/fake_service_connection.h
@@ -2,16 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_FAKE_SERVICE_CONNECTION_H_ -#define CHROMEOS_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_FAKE_SERVICE_CONNECTION_H_ +#ifndef ASH_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_FAKE_SERVICE_CONNECTION_H_ +#define ASH_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_FAKE_SERVICE_CONNECTION_H_ +#include "ash/services/chromebox_for_meetings/public/cpp/service_connection.h" +#include "ash/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" #include "base/bind.h" -#include "chromeos/services/chromebox_for_meetings/public/cpp/service_connection.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/receiver.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" - namespace chromeos { namespace cfm { @@ -50,4 +49,4 @@ using ::chromeos::cfm::FakeServiceConnectionImpl; } -#endif // CHROMEOS_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_FAKE_SERVICE_CONNECTION_H_ +#endif // ASH_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_FAKE_SERVICE_CONNECTION_H_
diff --git a/chromeos/services/chromebox_for_meetings/public/cpp/fake_service_context.cc b/ash/services/chromebox_for_meetings/public/cpp/fake_service_context.cc similarity index 93% rename from chromeos/services/chromebox_for_meetings/public/cpp/fake_service_context.cc rename to ash/services/chromebox_for_meetings/public/cpp/fake_service_context.cc index 4a6547e..eea0944 100644 --- a/chromeos/services/chromebox_for_meetings/public/cpp/fake_service_context.cc +++ b/ash/services/chromebox_for_meetings/public/cpp/fake_service_context.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/services/chromebox_for_meetings/public/cpp/fake_service_context.h" +#include "ash/services/chromebox_for_meetings/public/cpp/fake_service_context.h" namespace chromeos { namespace cfm {
diff --git a/chromeos/services/chromebox_for_meetings/public/cpp/fake_service_context.h b/ash/services/chromebox_for_meetings/public/cpp/fake_service_context.h similarity index 84% rename from chromeos/services/chromebox_for_meetings/public/cpp/fake_service_context.h rename to ash/services/chromebox_for_meetings/public/cpp/fake_service_context.h index b6ea7e7..fee8c379b 100644 --- a/chromeos/services/chromebox_for_meetings/public/cpp/fake_service_context.h +++ b/ash/services/chromebox_for_meetings/public/cpp/fake_service_context.h
@@ -2,15 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_FAKE_SERVICE_CONTEXT_H_ -#define CHROMEOS_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_FAKE_SERVICE_CONTEXT_H_ +#ifndef ASH_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_FAKE_SERVICE_CONTEXT_H_ +#define ASH_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_FAKE_SERVICE_CONTEXT_H_ +#include "ash/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" #include "base/bind.h" #include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/remote.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" - namespace chromeos { namespace cfm { @@ -58,4 +57,4 @@ using ::chromeos::cfm::FakeCfmServiceContext; } -#endif // CHROMEOS_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_FAKE_SERVICE_CONTEXT_H_ +#endif // ASH_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_FAKE_SERVICE_CONTEXT_H_
diff --git a/chromeos/services/chromebox_for_meetings/public/cpp/service_connection.cc b/ash/services/chromebox_for_meetings/public/cpp/service_connection.cc similarity index 98% rename from chromeos/services/chromebox_for_meetings/public/cpp/service_connection.cc rename to ash/services/chromebox_for_meetings/public/cpp/service_connection.cc index 845fa803..ac5e99b 100644 --- a/chromeos/services/chromebox_for_meetings/public/cpp/service_connection.cc +++ b/ash/services/chromebox_for_meetings/public/cpp/service_connection.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/services/chromebox_for_meetings/public/cpp/service_connection.h" +#include "ash/services/chromebox_for_meetings/public/cpp/service_connection.h" #include <memory>
diff --git a/chromeos/services/chromebox_for_meetings/public/cpp/service_connection.h b/ash/services/chromebox_for_meetings/public/cpp/service_connection.h similarity index 78% rename from chromeos/services/chromebox_for_meetings/public/cpp/service_connection.h rename to ash/services/chromebox_for_meetings/public/cpp/service_connection.h index ad825665..49496857 100644 --- a/chromeos/services/chromebox_for_meetings/public/cpp/service_connection.h +++ b/ash/services/chromebox_for_meetings/public/cpp/service_connection.h
@@ -2,15 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROMEOS_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_SERVICE_CONNECTION_H_ -#define CHROMEOS_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_SERVICE_CONNECTION_H_ +#ifndef ASH_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_SERVICE_CONNECTION_H_ +#define ASH_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_SERVICE_CONNECTION_H_ +#include "ash/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" #include "base/bind.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/receiver.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" - namespace chromeos { namespace cfm { @@ -44,4 +43,4 @@ using ::chromeos::cfm::ServiceConnection; } -#endif // CHROMEOS_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_SERVICE_CONNECTION_H_ +#endif // ASH_SERVICES_CHROMEBOX_FOR_MEETINGS_PUBLIC_CPP_SERVICE_CONNECTION_H_
diff --git a/chromeos/services/chromebox_for_meetings/public/cpp/service_connection_unittest.cc b/ash/services/chromebox_for_meetings/public/cpp/service_connection_unittest.cc similarity index 89% rename from chromeos/services/chromebox_for_meetings/public/cpp/service_connection_unittest.cc rename to ash/services/chromebox_for_meetings/public/cpp/service_connection_unittest.cc index 645395c..a49db1f 100644 --- a/chromeos/services/chromebox_for_meetings/public/cpp/service_connection_unittest.cc +++ b/ash/services/chromebox_for_meetings/public/cpp/service_connection_unittest.cc
@@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/services/chromebox_for_meetings/public/cpp/service_connection.h" +#include "ash/services/chromebox_for_meetings/public/cpp/service_connection.h" #include <utility> #include <vector> +#include "ash/services/chromebox_for_meetings/public/cpp/fake_service_connection.h" +#include "ash/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" #include "base/bind.h" #include "base/run_loop.h" #include "base/test/bind.h" #include "base/test/mock_callback.h" #include "base/test/task_environment.h" #include "chromeos/dbus/chromebox_for_meetings/cfm_hotline_client.h" -#include "chromeos/services/chromebox_for_meetings/public/cpp/fake_service_connection.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" #include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/remote.h" #include "testing/gmock/include/gmock/gmock.h"
diff --git a/chromeos/services/chromebox_for_meetings/public/mojom/BUILD.gn b/ash/services/chromebox_for_meetings/public/mojom/BUILD.gn similarity index 86% rename from chromeos/services/chromebox_for_meetings/public/mojom/BUILD.gn rename to ash/services/chromebox_for_meetings/public/mojom/BUILD.gn index baef010..6d8c58e 100644 --- a/chromeos/services/chromebox_for_meetings/public/mojom/BUILD.gn +++ b/ash/services/chromebox_for_meetings/public/mojom/BUILD.gn
@@ -2,9 +2,12 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/config/chromeos/ui_mode.gni") import("//chromeos/components/chromebox_for_meetings/buildflags/buildflags.gni") import("//mojo/public/tools/bindings/mojom.gni") +assert(is_chromeos_ash, "Non-ChromeOS builds cannot depend on //ash") + mojom("mojom") { sources = [ "cfm_service_manager.mojom" ]
diff --git a/chromeos/services/chromebox_for_meetings/public/mojom/OWNERS b/ash/services/chromebox_for_meetings/public/mojom/OWNERS similarity index 100% rename from chromeos/services/chromebox_for_meetings/public/mojom/OWNERS rename to ash/services/chromebox_for_meetings/public/mojom/OWNERS
diff --git a/chromeos/services/chromebox_for_meetings/public/mojom/README.md b/ash/services/chromebox_for_meetings/public/mojom/README.md similarity index 63% rename from chromeos/services/chromebox_for_meetings/public/mojom/README.md rename to ash/services/chromebox_for_meetings/public/mojom/README.md index 212d76b2..e10992c5 100644 --- a/chromeos/services/chromebox_for_meetings/public/mojom/README.md +++ b/ash/services/chromebox_for_meetings/public/mojom/README.md
@@ -1,7 +1,7 @@ These mojoms are for a service that exists outside of chromium. Implementation for CfmServiceContext are found in the private CrOS repo. -Note: //chromeos/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom +Note: //ash/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom is copied as is from its chromeos version as such the original file should be edited before changing this file. @@ -11,8 +11,8 @@ Hot-tip: Generate Js w/ ``` -$ ninja -C out_${BOARD}/Release/chromeos/services/chromebox_for_meetings/public/mojom:mojom_js +$ ninja -C out_${BOARD}/Release/ash/services/chromebox_for_meetings/public/mojom:mojom_js ``` These files can be found in: -`out_${BOARD}/Release/gen/chromeos/services/chromebox_for_meetings/public/mojom` +`out_${BOARD}/Release/gen/ash/services/chromebox_for_meetings/public/mojom`
diff --git a/chromeos/services/chromebox_for_meetings/public/mojom/cfm_browser.mojom b/ash/services/chromebox_for_meetings/public/mojom/cfm_browser.mojom similarity index 100% rename from chromeos/services/chromebox_for_meetings/public/mojom/cfm_browser.mojom rename to ash/services/chromebox_for_meetings/public/mojom/cfm_browser.mojom
diff --git a/chromeos/services/chromebox_for_meetings/public/mojom/cfm_network_settings.mojom b/ash/services/chromebox_for_meetings/public/mojom/cfm_network_settings.mojom similarity index 100% rename from chromeos/services/chromebox_for_meetings/public/mojom/cfm_network_settings.mojom rename to ash/services/chromebox_for_meetings/public/mojom/cfm_network_settings.mojom
diff --git a/chromeos/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom b/ash/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom similarity index 96% rename from chromeos/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom rename to ash/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom index c4d8ff8a..d906d9f 100644 --- a/chromeos/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom +++ b/ash/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom
@@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // +// See ash/services/chromebox_for_meetings/public/mojom/README.md before +// changing this file. +// // Next MinVersion: 1 module chromeos.cfm.mojom;
diff --git a/chromeos/services/chromebox_for_meetings/public/mojom/external_display_brightness.mojom b/ash/services/chromebox_for_meetings/public/mojom/external_display_brightness.mojom similarity index 100% rename from chromeos/services/chromebox_for_meetings/public/mojom/external_display_brightness.mojom rename to ash/services/chromebox_for_meetings/public/mojom/external_display_brightness.mojom
diff --git a/chromeos/services/chromebox_for_meetings/public/mojom/meet_devices_diagnostics.mojom b/ash/services/chromebox_for_meetings/public/mojom/meet_devices_diagnostics.mojom similarity index 100% rename from chromeos/services/chromebox_for_meetings/public/mojom/meet_devices_diagnostics.mojom rename to ash/services/chromebox_for_meetings/public/mojom/meet_devices_diagnostics.mojom
diff --git a/chromeos/services/chromebox_for_meetings/public/mojom/meet_devices_info.mojom b/ash/services/chromebox_for_meetings/public/mojom/meet_devices_info.mojom similarity index 100% rename from chromeos/services/chromebox_for_meetings/public/mojom/meet_devices_info.mojom rename to ash/services/chromebox_for_meetings/public/mojom/meet_devices_info.mojom
diff --git a/chromeos/services/chromebox_for_meetings/public/mojom/meet_devices_logger.mojom b/ash/services/chromebox_for_meetings/public/mojom/meet_devices_logger.mojom similarity index 100% rename from chromeos/services/chromebox_for_meetings/public/mojom/meet_devices_logger.mojom rename to ash/services/chromebox_for_meetings/public/mojom/meet_devices_logger.mojom
diff --git a/ash/services/device_sync/async_execution_time_metrics_logger.h b/ash/services/device_sync/async_execution_time_metrics_logger.h index 5e56713..e3df69ad 100644 --- a/ash/services/device_sync/async_execution_time_metrics_logger.h +++ b/ash/services/device_sync/async_execution_time_metrics_logger.h
@@ -24,4 +24,10 @@ } // namespace chromeos +// TODO(https://crbug.com/1164001): remove when it moved to ash. +namespace ash::device_sync { +using ::chromeos::device_sync::kMaxAsyncExecutionTime; +using ::chromeos::device_sync::LogAsyncExecutionTimeMetric; +} // namespace ash::device_sync + #endif // ASH_SERVICES_DEVICE_SYNC_ASYNC_EXECUTION_TIME_METRICS_LOGGER_H_
diff --git a/ash/services/device_sync/cryptauth_api_call_flow.cc b/ash/services/device_sync/cryptauth_api_call_flow.cc index 4eca841..92d85875 100644 --- a/ash/services/device_sync/cryptauth_api_call_flow.cc +++ b/ash/services/device_sync/cryptauth_api_call_flow.cc
@@ -11,7 +11,7 @@ #include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/mojom/url_response_head.mojom.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -156,4 +156,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_api_call_flow.h b/ash/services/device_sync/cryptauth_api_call_flow.h index a7ecd7b5..6bfaa5f 100644 --- a/ash/services/device_sync/cryptauth_api_call_flow.h +++ b/ash/services/device_sync/cryptauth_api_call_flow.h
@@ -15,7 +15,7 @@ #include "services/network/public/mojom/url_response_head.mojom.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -126,6 +126,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_API_CALL_FLOW_H_
diff --git a/ash/services/device_sync/cryptauth_api_call_flow_unittest.cc b/ash/services/device_sync/cryptauth_api_call_flow_unittest.cc index 6043040b..a34e0de0b 100644 --- a/ash/services/device_sync/cryptauth_api_call_flow_unittest.cc +++ b/ash/services/device_sync/cryptauth_api_call_flow_unittest.cc
@@ -22,7 +22,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -308,4 +308,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_client.h b/ash/services/device_sync/cryptauth_client.h index 86e685e4..2bdfc3e 100644 --- a/ash/services/device_sync/cryptauth_client.h +++ b/ash/services/device_sync/cryptauth_client.h
@@ -48,7 +48,7 @@ class GetDevicesActivityStatusResponse; } // namespace cryptauthv2 -namespace chromeos { +namespace ash { namespace device_sync { @@ -210,6 +210,12 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash + +// TODO(https://crbug.com/1164001): remove when the migration is finished. +namespace chromeos::device_sync { +using ash::device_sync::CryptAuthClient; +using ash::device_sync::CryptAuthClientFactory; +} // namespace chromeos::device_sync #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_CLIENT_H_
diff --git a/ash/services/device_sync/cryptauth_client_impl.cc b/ash/services/device_sync/cryptauth_client_impl.cc index 6232b0a..29e557c 100644 --- a/ash/services/device_sync/cryptauth_client_impl.cc +++ b/ash/services/device_sync/cryptauth_client_impl.cc
@@ -20,7 +20,7 @@ #include "components/signin/public/identity_manager/primary_account_access_token_fetcher.h" #include "services/network/public/cpp/shared_url_loader_factory.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -764,4 +764,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_client_impl.h b/ash/services/device_sync/cryptauth_client_impl.h index 3372fc5..41ad9ef5 100644 --- a/ash/services/device_sync/cryptauth_client_impl.h +++ b/ash/services/device_sync/cryptauth_client_impl.h
@@ -28,7 +28,7 @@ class GoogleServiceAuthError; -namespace chromeos { +namespace ash { namespace device_sync { @@ -230,6 +230,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_CLIENT_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_client_impl_unittest.cc b/ash/services/device_sync/cryptauth_client_impl_unittest.cc index 30d1e7d..1cc0748 100644 --- a/ash/services/device_sync/cryptauth_client_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_client_impl_unittest.cc
@@ -37,7 +37,7 @@ using testing::SaveArg; using testing::StrictMock; -namespace chromeos { +namespace ash { namespace device_sync { @@ -1167,4 +1167,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_device.cc b/ash/services/device_sync/cryptauth_device.cc index adf2235..d41291cc 100644 --- a/ash/services/device_sync/cryptauth_device.cc +++ b/ash/services/device_sync/cryptauth_device.cc
@@ -13,7 +13,7 @@ #include "base/json/values_util.h" #include "base/strings/string_number_conversions.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -224,4 +224,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_device.h b/ash/services/device_sync/cryptauth_device.h index bbb9f30..aab5aa0 100644 --- a/ash/services/device_sync/cryptauth_device.h +++ b/ash/services/device_sync/cryptauth_device.h
@@ -16,7 +16,7 @@ #include "base/values.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -100,6 +100,11 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash + +// TODO(https://crbug.com/1164001): remove when the migration is finished. +namespace chromeos::device_sync { +using ::ash::device_sync::CryptAuthDevice; +} #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_DEVICE_H_
diff --git a/ash/services/device_sync/cryptauth_device_activity_getter.cc b/ash/services/device_sync/cryptauth_device_activity_getter.cc index 510fd13..5722239d 100644 --- a/ash/services/device_sync/cryptauth_device_activity_getter.cc +++ b/ash/services/device_sync/cryptauth_device_activity_getter.cc
@@ -6,7 +6,7 @@ #include <utility> -namespace chromeos { +namespace ash { namespace device_sync { @@ -41,4 +41,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_device_activity_getter.h b/ash/services/device_sync/cryptauth_device_activity_getter.h index 59b0a718..b4db313 100644 --- a/ash/services/device_sync/cryptauth_device_activity_getter.h +++ b/ash/services/device_sync/cryptauth_device_activity_getter.h
@@ -11,7 +11,7 @@ #include "ash/services/device_sync/public/mojom/device_sync.mojom.h" #include "base/callback.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -24,7 +24,7 @@ class CryptAuthDeviceActivityGetter { public: using DeviceActivityStatusResult = - std::vector<ash::device_sync::mojom::DeviceActivityStatusPtr>; + std::vector<mojom::DeviceActivityStatusPtr>; using GetDeviceActivityStatusAttemptFinishedCallback = base::OnceCallback<void(DeviceActivityStatusResult)>; using GetDeviceActivityStatusAttemptErrorCallback = @@ -59,6 +59,11 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash + +// TODO(https://crbug.com/1164001): remove when the migration is finished. +namespace chromeos::device_sync { +using ::ash::device_sync::CryptAuthDeviceActivityGetter; +} #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_DEVICE_ACTIVITY_GETTER_H_
diff --git a/ash/services/device_sync/cryptauth_device_activity_getter_impl.cc b/ash/services/device_sync/cryptauth_device_activity_getter_impl.cc index 4d2cd29b..e43a6c8 100644 --- a/ash/services/device_sync/cryptauth_device_activity_getter_impl.cc +++ b/ash/services/device_sync/cryptauth_device_activity_getter_impl.cc
@@ -21,15 +21,12 @@ #include "base/metrics/histogram_functions.h" #include "base/time/time.h" -namespace chromeos { +namespace ash { namespace device_sync { namespace { -// TODO(https://crbug.com/1164001): remove after migrating to ash. -namespace mojom = ::ash::device_sync::mojom; - // TODO(https://crbug.com/933656): Use async execution time metrics to tune // these timeout values. constexpr base::TimeDelta kWaitingForGetDevicesActivityStatusResponseTimeout = @@ -224,4 +221,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_device_activity_getter_impl.h b/ash/services/device_sync/cryptauth_device_activity_getter_impl.h index 6a5097f..ef25b9d2 100644 --- a/ash/services/device_sync/cryptauth_device_activity_getter_impl.h +++ b/ash/services/device_sync/cryptauth_device_activity_getter_impl.h
@@ -16,7 +16,7 @@ #include "base/timer/timer.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -104,6 +104,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_DEVICE_ACTIVITY_GETTER_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_device_activity_getter_impl_unittest.cc b/ash/services/device_sync/cryptauth_device_activity_getter_impl_unittest.cc index 0c3c853a..672a55d7 100644 --- a/ash/services/device_sync/cryptauth_device_activity_getter_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_device_activity_getter_impl_unittest.cc
@@ -30,15 +30,12 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { namespace { -// TODO(https://crbug.com/1164001): remove after migrating to ash. -namespace mojom = ::ash::device_sync::mojom; - const char kAccessTokenUsed[] = "access token used by CryptAuthClient"; const char kDeviceId[] = "device_id1"; const int kLastActivityTimeSecs = 111; @@ -247,4 +244,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_device_manager.cc b/ash/services/device_sync/cryptauth_device_manager.cc index e23dcac2..3b54bff 100644 --- a/ash/services/device_sync/cryptauth_device_manager.cc +++ b/ash/services/device_sync/cryptauth_device_manager.cc
@@ -7,7 +7,7 @@ #include "ash/services/device_sync/pref_names.h" #include "components/prefs/pref_registry_simple.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -48,4 +48,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_device_manager.h b/ash/services/device_sync/cryptauth_device_manager.h index 1bb61b4..59612b6 100644 --- a/ash/services/device_sync/cryptauth_device_manager.h +++ b/ash/services/device_sync/cryptauth_device_manager.h
@@ -17,7 +17,7 @@ class TimeDelta; } // namespace base -namespace chromeos { +namespace ash { namespace device_sync { @@ -121,13 +121,11 @@ } // namespace device_sync -} // namespace chromeos - -// TODO(https://crbug.com/1164001): remove when this file is moved to ash. -namespace ash { -namespace device_sync { -using ::chromeos::device_sync::CryptAuthDeviceManager; -} // namespace device_sync } // namespace ash +// TODO(https://crbug.com/1164001): remove when the migration is finished. +namespace chromeos::device_sync { +using ::ash::device_sync::CryptAuthDeviceManager; +} + #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_DEVICE_MANAGER_H_
diff --git a/ash/services/device_sync/cryptauth_device_manager_impl.cc b/ash/services/device_sync/cryptauth_device_manager_impl.cc index 165a012..dacbc65 100644 --- a/ash/services/device_sync/cryptauth_device_manager_impl.cc +++ b/ash/services/device_sync/cryptauth_device_manager_impl.cc
@@ -28,7 +28,7 @@ #include "components/prefs/scoped_user_pref_update.h" #include "net/traffic_annotation/network_traffic_annotation.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -846,4 +846,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_device_manager_impl.h b/ash/services/device_sync/cryptauth_device_manager_impl.h index d34b66f..29a7ec2 100644 --- a/ash/services/device_sync/cryptauth_device_manager_impl.h +++ b/ash/services/device_sync/cryptauth_device_manager_impl.h
@@ -19,7 +19,7 @@ class PrefService; -namespace chromeos { +namespace ash { namespace device_sync { @@ -141,6 +141,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_DEVICE_MANAGER_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_device_manager_impl_unittest.cc b/ash/services/device_sync/cryptauth_device_manager_impl_unittest.cc index 6fa5229..2b7a2e0f 100644 --- a/ash/services/device_sync/cryptauth_device_manager_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_device_manager_impl_unittest.cc
@@ -37,7 +37,7 @@ using ::testing::Return; using ::testing::SaveArg; -namespace chromeos { +namespace ash { namespace device_sync { @@ -1320,4 +1320,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_device_notifier.h b/ash/services/device_sync/cryptauth_device_notifier.h index 7c8b5e4..49be26a4 100644 --- a/ash/services/device_sync/cryptauth_device_notifier.h +++ b/ash/services/device_sync/cryptauth_device_notifier.h
@@ -13,7 +13,7 @@ #include "base/callback.h" #include "base/containers/flat_set.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -44,6 +44,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_DEVICE_NOTIFIER_H_
diff --git a/ash/services/device_sync/cryptauth_device_notifier_impl.cc b/ash/services/device_sync/cryptauth_device_notifier_impl.cc index 26382e4..c38d1ac6 100644 --- a/ash/services/device_sync/cryptauth_device_notifier_impl.cc +++ b/ash/services/device_sync/cryptauth_device_notifier_impl.cc
@@ -15,7 +15,7 @@ #include "base/memory/ptr_util.h" #include "base/metrics/histogram_functions.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -248,4 +248,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_device_notifier_impl.h b/ash/services/device_sync/cryptauth_device_notifier_impl.h index a388cd0c..cdde0bc 100644 --- a/ash/services/device_sync/cryptauth_device_notifier_impl.h +++ b/ash/services/device_sync/cryptauth_device_notifier_impl.h
@@ -19,7 +19,7 @@ #include "base/containers/queue.h" #include "base/timer/timer.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -122,6 +122,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_DEVICE_NOTIFIER_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_device_notifier_impl_unittest.cc b/ash/services/device_sync/cryptauth_device_notifier_impl_unittest.cc index ee9c849..71503dd 100644 --- a/ash/services/device_sync/cryptauth_device_notifier_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_device_notifier_impl_unittest.cc
@@ -25,7 +25,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -268,4 +268,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_device_registry.cc b/ash/services/device_sync/cryptauth_device_registry.cc index 3f88a2f4d..43c926a8 100644 --- a/ash/services/device_sync/cryptauth_device_registry.cc +++ b/ash/services/device_sync/cryptauth_device_registry.cc
@@ -8,7 +8,7 @@ #include "base/containers/contains.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -83,4 +83,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_device_registry.h b/ash/services/device_sync/cryptauth_device_registry.h index 4c1b3c5..08547cc 100644 --- a/ash/services/device_sync/cryptauth_device_registry.h +++ b/ash/services/device_sync/cryptauth_device_registry.h
@@ -12,7 +12,7 @@ #include "base/containers/flat_map.h" #include "base/values.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -64,6 +64,11 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash + +// TODO(https://crbug.com/1164001): remove when the migration is finished. +namespace chromeos::device_sync { +using ash::device_sync::CryptAuthDeviceRegistry; +} #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_DEVICE_REGISTRY_H_
diff --git a/ash/services/device_sync/cryptauth_device_registry_impl.cc b/ash/services/device_sync/cryptauth_device_registry_impl.cc index 6b35072b..f8af4682 100644 --- a/ash/services/device_sync/cryptauth_device_registry_impl.cc +++ b/ash/services/device_sync/cryptauth_device_registry_impl.cc
@@ -16,7 +16,7 @@ #include "components/prefs/pref_service.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -88,4 +88,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_device_registry_impl.h b/ash/services/device_sync/cryptauth_device_registry_impl.h index 8c88e1c..d7ba92e 100644 --- a/ash/services/device_sync/cryptauth_device_registry_impl.h +++ b/ash/services/device_sync/cryptauth_device_registry_impl.h
@@ -13,7 +13,7 @@ class PrefRegistrySimple; class PrefService; -namespace chromeos { +namespace ash { namespace device_sync { @@ -65,11 +65,6 @@ } // namespace device_sync -} // namespace chromeos - -// TODO(https://crbug.com/1164001): remove when it moved to ash. -namespace ash::device_sync { -using ::chromeos::device_sync::CryptAuthDeviceRegistryImpl; -} +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_DEVICE_REGISTRY_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_device_registry_impl_unittest.cc b/ash/services/device_sync/cryptauth_device_registry_impl_unittest.cc index a808fbe4..9dd481b 100644 --- a/ash/services/device_sync/cryptauth_device_registry_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_device_registry_impl_unittest.cc
@@ -22,7 +22,7 @@ #include "components/prefs/testing_pref_service.h" #include "testing/gtest/include/gtest/gtest.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -190,4 +190,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_device_sync_result.cc b/ash/services/device_sync/cryptauth_device_sync_result.cc index e33a85e..41e7a79 100644 --- a/ash/services/device_sync/cryptauth_device_sync_result.cc +++ b/ash/services/device_sync/cryptauth_device_sync_result.cc
@@ -4,7 +4,7 @@ #include "ash/services/device_sync/cryptauth_device_sync_result.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -213,4 +213,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_device_sync_result.h b/ash/services/device_sync/cryptauth_device_sync_result.h index bc0d53e8..b9236e7 100644 --- a/ash/services/device_sync/cryptauth_device_sync_result.h +++ b/ash/services/device_sync/cryptauth_device_sync_result.h
@@ -10,7 +10,7 @@ #include "ash/services/device_sync/proto/cryptauth_directive.pb.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -121,6 +121,11 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash + +// TODO(https://crbug.com/1164001): remove when the migration is finished. +namespace chromeos::device_sync { +using ::ash::device_sync::CryptAuthDeviceSyncResult; +} #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_DEVICE_SYNC_RESULT_H_
diff --git a/ash/services/device_sync/cryptauth_device_syncer.cc b/ash/services/device_sync/cryptauth_device_syncer.cc index 41e5b49..0fc8aa1 100644 --- a/ash/services/device_sync/cryptauth_device_syncer.cc +++ b/ash/services/device_sync/cryptauth_device_syncer.cc
@@ -6,7 +6,7 @@ #include <utility> -namespace chromeos { +namespace ash { namespace device_sync { @@ -35,4 +35,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_device_syncer.h b/ash/services/device_sync/cryptauth_device_syncer.h index fdd9b95..c1cf6ce 100644 --- a/ash/services/device_sync/cryptauth_device_syncer.h +++ b/ash/services/device_sync/cryptauth_device_syncer.h
@@ -13,7 +13,7 @@ class ClientAppMetadata; } // namespace cryptauthv2 -namespace chromeos { +namespace ash { namespace device_sync { @@ -103,6 +103,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_DEVICE_SYNCER_H_
diff --git a/ash/services/device_sync/cryptauth_device_syncer_impl.cc b/ash/services/device_sync/cryptauth_device_syncer_impl.cc index b3586da98a..7d991261 100644 --- a/ash/services/device_sync/cryptauth_device_syncer_impl.cc +++ b/ash/services/device_sync/cryptauth_device_syncer_impl.cc
@@ -25,7 +25,7 @@ #include "base/memory/ptr_util.h" #include "base/metrics/histogram_functions.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -770,4 +770,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_device_syncer_impl.h b/ash/services/device_sync/cryptauth_device_syncer_impl.h index d8f3128..17c8993 100644 --- a/ash/services/device_sync/cryptauth_device_syncer_impl.h +++ b/ash/services/device_sync/cryptauth_device_syncer_impl.h
@@ -23,6 +23,8 @@ #include "ash/services/device_sync/proto/cryptauth_better_together_device_metadata.pb.h" #include "ash/services/device_sync/proto/cryptauth_devicesync.pb.h" #include "ash/services/device_sync/proto/cryptauth_directive.pb.h" +// TODO(https://crbug.com/1164001): move to forward declaration +#include "ash/services/device_sync/synced_bluetooth_address_tracker.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" #include "base/timer/timer.h" @@ -35,14 +37,13 @@ class ClientMetadata; } // namespace cryptauthv2 -namespace chromeos { +namespace ash { namespace device_sync { class CryptAuthClient; class CryptAuthClientFactory; class CryptAuthKeyRegistry; -class SyncedBluetoothAddressTracker; // An implementation of CryptAuthDeviceSyncer, using instances of // CryptAuthClient to make the API calls to CryptAuth. This implementation @@ -231,6 +232,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_DEVICE_SYNCER_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_device_syncer_impl_unittest.cc b/ash/services/device_sync/cryptauth_device_syncer_impl_unittest.cc index 1298030..c735b8e 100644 --- a/ash/services/device_sync/cryptauth_device_syncer_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_device_syncer_impl_unittest.cc
@@ -44,7 +44,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -1485,4 +1485,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_device_unittest.cc b/ash/services/device_sync/cryptauth_device_unittest.cc index db50f10..54d9195 100644 --- a/ash/services/device_sync/cryptauth_device_unittest.cc +++ b/ash/services/device_sync/cryptauth_device_unittest.cc
@@ -14,7 +14,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -54,4 +54,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_ecies_encryptor.cc b/ash/services/device_sync/cryptauth_ecies_encryptor.cc index 4b4b0df..2898254 100644 --- a/ash/services/device_sync/cryptauth_ecies_encryptor.cc +++ b/ash/services/device_sync/cryptauth_ecies_encryptor.cc
@@ -8,7 +8,7 @@ #include "base/bind.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -102,4 +102,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_ecies_encryptor.h b/ash/services/device_sync/cryptauth_ecies_encryptor.h index 93ebd4a1..ce5d6070 100644 --- a/ash/services/device_sync/cryptauth_ecies_encryptor.h +++ b/ash/services/device_sync/cryptauth_ecies_encryptor.h
@@ -11,7 +11,7 @@ #include "base/containers/flat_map.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -86,6 +86,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_ECIES_ENCRYPTOR_H_
diff --git a/ash/services/device_sync/cryptauth_ecies_encryptor_impl.cc b/ash/services/device_sync/cryptauth_ecies_encryptor_impl.cc index 9c1e39b..30f7395 100644 --- a/ash/services/device_sync/cryptauth_ecies_encryptor_impl.cc +++ b/ash/services/device_sync/cryptauth_ecies_encryptor_impl.cc
@@ -14,7 +14,7 @@ #include "base/memory/ptr_util.h" #include "third_party/securemessage/proto/securemessage.pb.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -233,4 +233,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_ecies_encryptor_impl.h b/ash/services/device_sync/cryptauth_ecies_encryptor_impl.h index 63ce160..6be8266 100644 --- a/ash/services/device_sync/cryptauth_ecies_encryptor_impl.h +++ b/ash/services/device_sync/cryptauth_ecies_encryptor_impl.h
@@ -8,6 +8,8 @@ #include <memory> #include <string> +// TODO(https://crbug.com/1164001): move to forward declaration +#include "ash/components/multidevice/secure_message_delegate.h" #include "ash/services/device_sync/cryptauth_ecies_encryptor.h" #include "third_party/abseil-cpp/absl/types/optional.h" @@ -15,11 +17,7 @@ class Header; } // namespace securemessage -namespace chromeos { - -namespace multidevice { -class SecureMessageDelegate; -} // namespace multidevice +namespace ash { namespace device_sync { @@ -106,6 +104,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_ECIES_ENCRYPTOR_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_ecies_encryptor_impl_unittest.cc b/ash/services/device_sync/cryptauth_ecies_encryptor_impl_unittest.cc index 7c6ea35..01deeb2 100644 --- a/ash/services/device_sync/cryptauth_ecies_encryptor_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_ecies_encryptor_impl_unittest.cc
@@ -17,7 +17,7 @@ #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/securemessage/proto/securemessage.pb.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -371,4 +371,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_enroller.h b/ash/services/device_sync/cryptauth_enroller.h index 3a824d93..8162142 100644 --- a/ash/services/device_sync/cryptauth_enroller.h +++ b/ash/services/device_sync/cryptauth_enroller.h
@@ -11,7 +11,7 @@ #include "ash/services/device_sync/proto/cryptauth_api.pb.h" #include "base/callback_forward.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -46,6 +46,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_ENROLLER_H_
diff --git a/ash/services/device_sync/cryptauth_enroller_factory_impl.cc b/ash/services/device_sync/cryptauth_enroller_factory_impl.cc index fed3df94..154022f 100644 --- a/ash/services/device_sync/cryptauth_enroller_factory_impl.cc +++ b/ash/services/device_sync/cryptauth_enroller_factory_impl.cc
@@ -9,7 +9,7 @@ #include "ash/components/multidevice/secure_message_delegate_impl.h" #include "ash/services/device_sync/cryptauth_enroller_impl.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -28,4 +28,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_enroller_factory_impl.h b/ash/services/device_sync/cryptauth_enroller_factory_impl.h index 6866c0e..135656b 100644 --- a/ash/services/device_sync/cryptauth_enroller_factory_impl.h +++ b/ash/services/device_sync/cryptauth_enroller_factory_impl.h
@@ -7,7 +7,7 @@ #include "ash/services/device_sync/cryptauth_enroller.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -29,6 +29,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_ENROLLER_FACTORY_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_enroller_impl.cc b/ash/services/device_sync/cryptauth_enroller_impl.cc index f1f8c70..31c4a07 100644 --- a/ash/services/device_sync/cryptauth_enroller_impl.cc +++ b/ash/services/device_sync/cryptauth_enroller_impl.cc
@@ -13,7 +13,7 @@ #include "base/metrics/histogram_macros.h" #include "crypto/sha2.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -242,4 +242,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_enroller_impl.h b/ash/services/device_sync/cryptauth_enroller_impl.h index 2a9bfaf..f2b4127d0 100644 --- a/ash/services/device_sync/cryptauth_enroller_impl.h +++ b/ash/services/device_sync/cryptauth_enroller_impl.h
@@ -7,17 +7,15 @@ #include <memory> +// TODO(https://crbug.com/1164001): move to forward declaration +#include "ash/components/multidevice/secure_message_delegate.h" #include "ash/services/device_sync/cryptauth_enroller.h" #include "ash/services/device_sync/network_request_error.h" #include "ash/services/device_sync/proto/cryptauth_api.pb.h" #include "base/callback.h" #include "base/memory/weak_ptr.h" -namespace chromeos { - -namespace multidevice { -class SecureMessageDelegate; -} // namespace multidevice +namespace ash { namespace device_sync { @@ -110,6 +108,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_ENROLLER_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_enroller_impl_unittest.cc b/ash/services/device_sync/cryptauth_enroller_impl_unittest.cc index 4f79738..cf44706 100644 --- a/ash/services/device_sync/cryptauth_enroller_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_enroller_impl_unittest.cc
@@ -16,7 +16,7 @@ using ::testing::_; using ::testing::Return; -namespace chromeos { +namespace ash { namespace device_sync { @@ -366,4 +366,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_enrollment_constants.cc b/ash/services/device_sync/cryptauth_enrollment_constants.cc index 44982d0e..7377be8 100644 --- a/ash/services/device_sync/cryptauth_enrollment_constants.cc +++ b/ash/services/device_sync/cryptauth_enrollment_constants.cc
@@ -4,7 +4,7 @@ #include "ash/services/device_sync/cryptauth_enrollment_constants.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -19,4 +19,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_enrollment_constants.h b/ash/services/device_sync/cryptauth_enrollment_constants.h index 37687466..0ce35ab 100644 --- a/ash/services/device_sync/cryptauth_enrollment_constants.h +++ b/ash/services/device_sync/cryptauth_enrollment_constants.h
@@ -5,7 +5,7 @@ #ifndef ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_ENROLLMENT_CONSTANTS_H_ #define ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_ENROLLMENT_CONSTANTS_H_ -namespace chromeos { +namespace ash { namespace device_sync { @@ -34,6 +34,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_ENROLLMENT_CONSTANTS_H_
diff --git a/ash/services/device_sync/cryptauth_enrollment_manager.cc b/ash/services/device_sync/cryptauth_enrollment_manager.cc index 71b5732..7956f9b 100644 --- a/ash/services/device_sync/cryptauth_enrollment_manager.cc +++ b/ash/services/device_sync/cryptauth_enrollment_manager.cc
@@ -4,7 +4,7 @@ #include "ash/services/device_sync/cryptauth_enrollment_manager.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -32,4 +32,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_enrollment_manager.h b/ash/services/device_sync/cryptauth_enrollment_manager.h index a98ad6ca..7f525bc 100644 --- a/ash/services/device_sync/cryptauth_enrollment_manager.h +++ b/ash/services/device_sync/cryptauth_enrollment_manager.h
@@ -13,7 +13,7 @@ #include "base/time/time.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -99,6 +99,11 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash + +// TODO(https://crbug.com/1164001): remove when the migration is finished. +namespace chromeos::device_sync { +using ::ash::device_sync::CryptAuthEnrollmentManager; +} #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_ENROLLMENT_MANAGER_H_
diff --git a/ash/services/device_sync/cryptauth_enrollment_manager_impl.cc b/ash/services/device_sync/cryptauth_enrollment_manager_impl.cc index 8721ac3..0e86dac 100644 --- a/ash/services/device_sync/cryptauth_enrollment_manager_impl.cc +++ b/ash/services/device_sync/cryptauth_enrollment_manager_impl.cc
@@ -23,7 +23,7 @@ #include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_service.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -353,4 +353,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_enrollment_manager_impl.h b/ash/services/device_sync/cryptauth_enrollment_manager_impl.h index 1a9abc1..ddfdc18 100644 --- a/ash/services/device_sync/cryptauth_enrollment_manager_impl.h +++ b/ash/services/device_sync/cryptauth_enrollment_manager_impl.h
@@ -8,6 +8,8 @@ #include <memory> #include <string> +// TODO(https://crbug.com/1164001): move to forward declaration +#include "ash/components/multidevice/secure_message_delegate.h" #include "ash/services/device_sync/cryptauth_enrollment_manager.h" #include "ash/services/device_sync/cryptauth_feature_type.h" #include "ash/services/device_sync/cryptauth_gcm_manager.h" @@ -24,11 +26,7 @@ class Clock; } -namespace chromeos { - -namespace multidevice { -class SecureMessageDelegate; -} // namespace multidevice +namespace ash { namespace device_sync { @@ -196,11 +194,6 @@ } // namespace device_sync -} // namespace chromeos - -// TODO(https://crbug.com/1164001): remove when it moved to ash. -namespace ash::device_sync { -using ::chromeos::device_sync::CryptAuthEnrollmentManagerImpl; -} +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_ENROLLMENT_MANAGER_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_enrollment_manager_impl_unittest.cc b/ash/services/device_sync/cryptauth_enrollment_manager_impl_unittest.cc index fcbfd2f0..b58a8f6d 100644 --- a/ash/services/device_sync/cryptauth_enrollment_manager_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_enrollment_manager_impl_unittest.cc
@@ -27,7 +27,7 @@ using ::testing::NiceMock; using ::testing::Return; -namespace chromeos { +namespace ash { namespace device_sync { @@ -474,4 +474,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_enrollment_result.cc b/ash/services/device_sync/cryptauth_enrollment_result.cc index da36ace..1b82f8f 100644 --- a/ash/services/device_sync/cryptauth_enrollment_result.cc +++ b/ash/services/device_sync/cryptauth_enrollment_result.cc
@@ -4,7 +4,7 @@ #include "ash/services/device_sync/cryptauth_enrollment_result.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -167,4 +167,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_enrollment_result.h b/ash/services/device_sync/cryptauth_enrollment_result.h index 028a401..23a2aaa9 100644 --- a/ash/services/device_sync/cryptauth_enrollment_result.h +++ b/ash/services/device_sync/cryptauth_enrollment_result.h
@@ -10,7 +10,7 @@ #include "ash/services/device_sync/proto/cryptauth_directive.pb.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -144,6 +144,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_ENROLLMENT_RESULT_H_
diff --git a/ash/services/device_sync/cryptauth_feature_status_getter.cc b/ash/services/device_sync/cryptauth_feature_status_getter.cc index 48a5d496..7d3bf91c 100644 --- a/ash/services/device_sync/cryptauth_feature_status_getter.cc +++ b/ash/services/device_sync/cryptauth_feature_status_getter.cc
@@ -6,7 +6,7 @@ #include <utility> -namespace chromeos { +namespace ash { namespace device_sync { @@ -53,4 +53,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_feature_status_getter.h b/ash/services/device_sync/cryptauth_feature_status_getter.h index 622a464..77923b9 100644 --- a/ash/services/device_sync/cryptauth_feature_status_getter.h +++ b/ash/services/device_sync/cryptauth_feature_status_getter.h
@@ -20,7 +20,7 @@ class RequestContext; } // namespace cryptauthv2 -namespace chromeos { +namespace ash { namespace device_sync { @@ -90,6 +90,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_FEATURE_STATUS_GETTER_H_
diff --git a/ash/services/device_sync/cryptauth_feature_status_getter_impl.cc b/ash/services/device_sync/cryptauth_feature_status_getter_impl.cc index 427a9e84..933686a 100644 --- a/ash/services/device_sync/cryptauth_feature_status_getter_impl.cc +++ b/ash/services/device_sync/cryptauth_feature_status_getter_impl.cc
@@ -19,7 +19,7 @@ #include "base/memory/ptr_util.h" #include "base/metrics/histogram_functions.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -328,4 +328,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_feature_status_getter_impl.h b/ash/services/device_sync/cryptauth_feature_status_getter_impl.h index 48659201..d79489c 100644 --- a/ash/services/device_sync/cryptauth_feature_status_getter_impl.h +++ b/ash/services/device_sync/cryptauth_feature_status_getter_impl.h
@@ -16,7 +16,7 @@ #include "base/time/time.h" #include "base/timer/timer.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -87,6 +87,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_FEATURE_STATUS_GETTER_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_feature_status_getter_impl_unittest.cc b/ash/services/device_sync/cryptauth_feature_status_getter_impl_unittest.cc index 44428f0..031afcd 100644 --- a/ash/services/device_sync/cryptauth_feature_status_getter_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_feature_status_getter_impl_unittest.cc
@@ -28,7 +28,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -436,4 +436,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_feature_status_setter.h b/ash/services/device_sync/cryptauth_feature_status_setter.h index aa617983..ec0ebec 100644 --- a/ash/services/device_sync/cryptauth_feature_status_setter.h +++ b/ash/services/device_sync/cryptauth_feature_status_setter.h
@@ -12,7 +12,7 @@ #include "ash/services/device_sync/network_request_error.h" #include "base/callback.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -42,6 +42,11 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash + +// TODO(https://crbug.com/1164001): remove when the migration is finished. +namespace chromeos::device_sync { +using ::ash::device_sync::CryptAuthFeatureStatusSetter; +} #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_FEATURE_STATUS_SETTER_H_
diff --git a/ash/services/device_sync/cryptauth_feature_status_setter_impl.cc b/ash/services/device_sync/cryptauth_feature_status_setter_impl.cc index bbe3888d..97f958e 100644 --- a/ash/services/device_sync/cryptauth_feature_status_setter_impl.cc +++ b/ash/services/device_sync/cryptauth_feature_status_setter_impl.cc
@@ -17,7 +17,7 @@ #include "base/memory/ptr_util.h" #include "base/metrics/histogram_functions.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -267,4 +267,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_feature_status_setter_impl.h b/ash/services/device_sync/cryptauth_feature_status_setter_impl.h index 738da3d..8624f88 100644 --- a/ash/services/device_sync/cryptauth_feature_status_setter_impl.h +++ b/ash/services/device_sync/cryptauth_feature_status_setter_impl.h
@@ -20,7 +20,7 @@ #include "base/timer/timer.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -126,6 +126,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_FEATURE_STATUS_SETTER_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_feature_status_setter_impl_unittest.cc b/ash/services/device_sync/cryptauth_feature_status_setter_impl_unittest.cc index 28b919da..b4a9576 100644 --- a/ash/services/device_sync/cryptauth_feature_status_setter_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_feature_status_setter_impl_unittest.cc
@@ -24,7 +24,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -293,4 +293,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_feature_type.cc b/ash/services/device_sync/cryptauth_feature_type.cc index 4aded75..9860fca 100644 --- a/ash/services/device_sync/cryptauth_feature_type.cc +++ b/ash/services/device_sync/cryptauth_feature_type.cc
@@ -10,7 +10,7 @@ #include "base/no_destructor.h" #include "crypto/sha2.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -507,4 +507,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_feature_type.h b/ash/services/device_sync/cryptauth_feature_type.h index c452009..515c6fde 100644 --- a/ash/services/device_sync/cryptauth_feature_type.h +++ b/ash/services/device_sync/cryptauth_feature_type.h
@@ -12,7 +12,7 @@ #include "base/containers/flat_set.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -143,6 +143,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_FEATURE_TYPE_H_
diff --git a/ash/services/device_sync/cryptauth_feature_type_unittest.cc b/ash/services/device_sync/cryptauth_feature_type_unittest.cc index 1b1a31c..cc43ff9 100644 --- a/ash/services/device_sync/cryptauth_feature_type_unittest.cc +++ b/ash/services/device_sync/cryptauth_feature_type_unittest.cc
@@ -6,7 +6,7 @@ #include "testing/gtest/include/gtest/gtest.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -53,4 +53,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_gcm_manager.cc b/ash/services/device_sync/cryptauth_gcm_manager.cc index 438197c3..40f70c7 100644 --- a/ash/services/device_sync/cryptauth_gcm_manager.cc +++ b/ash/services/device_sync/cryptauth_gcm_manager.cc
@@ -7,7 +7,7 @@ #include "ash/services/device_sync/pref_names.h" #include "components/prefs/pref_registry_simple.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -31,4 +31,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_gcm_manager.h b/ash/services/device_sync/cryptauth_gcm_manager.h index 04eeea65..b387f4b 100644 --- a/ash/services/device_sync/cryptauth_gcm_manager.h +++ b/ash/services/device_sync/cryptauth_gcm_manager.h
@@ -12,7 +12,7 @@ class PrefRegistrySimple; -namespace chromeos { +namespace ash { namespace device_sync { @@ -83,11 +83,11 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash -// TODO(https://crbug.com/1164001): remove when it moved to ash. -namespace ash::device_sync { -using ::chromeos::device_sync::CryptAuthGCMManager; +// TODO(https://crbug.com/1164001): remove when the migration is finished. +namespace chromeos::device_sync { +using ::ash::device_sync::CryptAuthGCMManager; } #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_GCM_MANAGER_H_
diff --git a/ash/services/device_sync/cryptauth_gcm_manager_impl.cc b/ash/services/device_sync/cryptauth_gcm_manager_impl.cc index 6fb5910..872cd37 100644 --- a/ash/services/device_sync/cryptauth_gcm_manager_impl.cc +++ b/ash/services/device_sync/cryptauth_gcm_manager_impl.cc
@@ -18,7 +18,7 @@ #include "components/gcm_driver/gcm_driver.h" #include "components/prefs/pref_service.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -364,4 +364,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_gcm_manager_impl.h b/ash/services/device_sync/cryptauth_gcm_manager_impl.h index 9235509..5848fda 100644 --- a/ash/services/device_sync/cryptauth_gcm_manager_impl.h +++ b/ash/services/device_sync/cryptauth_gcm_manager_impl.h
@@ -19,7 +19,7 @@ class GCMDriver; } -namespace chromeos { +namespace ash { namespace device_sync { @@ -106,6 +106,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_GCM_MANAGER_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_gcm_manager_impl_unittest.cc b/ash/services/device_sync/cryptauth_gcm_manager_impl_unittest.cc index 25bac8d..3cfd764 100644 --- a/ash/services/device_sync/cryptauth_gcm_manager_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_gcm_manager_impl_unittest.cc
@@ -18,7 +18,7 @@ using ::testing::_; using ::testing::SaveArg; -namespace chromeos { +namespace ash { namespace device_sync { @@ -468,4 +468,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_group_private_key_sharer.cc b/ash/services/device_sync/cryptauth_group_private_key_sharer.cc index 88d7e1c5..3b3ddec 100644 --- a/ash/services/device_sync/cryptauth_group_private_key_sharer.cc +++ b/ash/services/device_sync/cryptauth_group_private_key_sharer.cc
@@ -8,7 +8,7 @@ #include "ash/services/device_sync/cryptauth_key.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -41,4 +41,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_group_private_key_sharer.h b/ash/services/device_sync/cryptauth_group_private_key_sharer.h index 2515b59..a0796305 100644 --- a/ash/services/device_sync/cryptauth_group_private_key_sharer.h +++ b/ash/services/device_sync/cryptauth_group_private_key_sharer.h
@@ -15,7 +15,7 @@ class RequestContext; } // namespace cryptauthv2 -namespace chromeos { +namespace ash { namespace device_sync { @@ -71,6 +71,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_GROUP_PRIVATE_KEY_SHARER_H_
diff --git a/ash/services/device_sync/cryptauth_group_private_key_sharer_impl.cc b/ash/services/device_sync/cryptauth_group_private_key_sharer_impl.cc index b8d9f91..44203fb 100644 --- a/ash/services/device_sync/cryptauth_group_private_key_sharer_impl.cc +++ b/ash/services/device_sync/cryptauth_group_private_key_sharer_impl.cc
@@ -17,7 +17,7 @@ #include "base/metrics/histogram_functions.h" #include "crypto/sha2.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -377,4 +377,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_group_private_key_sharer_impl.h b/ash/services/device_sync/cryptauth_group_private_key_sharer_impl.h index a817ee3..55af7c9 100644 --- a/ash/services/device_sync/cryptauth_group_private_key_sharer_impl.h +++ b/ash/services/device_sync/cryptauth_group_private_key_sharer_impl.h
@@ -17,7 +17,7 @@ #include "base/time/time.h" #include "base/timer/timer.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -111,6 +111,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_GROUP_PRIVATE_KEY_SHARER_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_group_private_key_sharer_impl_unittest.cc b/ash/services/device_sync/cryptauth_group_private_key_sharer_impl_unittest.cc index 5d4caa75..0a297ed 100644 --- a/ash/services/device_sync/cryptauth_group_private_key_sharer_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_group_private_key_sharer_impl_unittest.cc
@@ -30,7 +30,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -429,4 +429,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_key.cc b/ash/services/device_sync/cryptauth_key.cc index 2d220fc..4f95c3a 100644 --- a/ash/services/device_sync/cryptauth_key.cc +++ b/ash/services/device_sync/cryptauth_key.cc
@@ -8,7 +8,7 @@ #include "base/base64url.h" #include "crypto/sha2.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -161,4 +161,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_key.h b/ash/services/device_sync/cryptauth_key.h index cda9aee..3982f13 100644 --- a/ash/services/device_sync/cryptauth_key.h +++ b/ash/services/device_sync/cryptauth_key.h
@@ -9,7 +9,7 @@ #include "base/values.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -100,6 +100,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_KEY_H_
diff --git a/ash/services/device_sync/cryptauth_key_bundle.cc b/ash/services/device_sync/cryptauth_key_bundle.cc index d82ac6c..b910d9d 100644 --- a/ash/services/device_sync/cryptauth_key_bundle.cc +++ b/ash/services/device_sync/cryptauth_key_bundle.cc
@@ -11,7 +11,7 @@ #include "base/no_destructor.h" #include "base/values.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -218,4 +218,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_key_bundle.h b/ash/services/device_sync/cryptauth_key_bundle.h index 275a6e3..b19cf5c 100644 --- a/ash/services/device_sync/cryptauth_key_bundle.h +++ b/ash/services/device_sync/cryptauth_key_bundle.h
@@ -12,7 +12,7 @@ #include "base/values.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -115,6 +115,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_KEY_BUNDLE_H_
diff --git a/ash/services/device_sync/cryptauth_key_bundle_unittest.cc b/ash/services/device_sync/cryptauth_key_bundle_unittest.cc index a4eb226..0eaad6a 100644 --- a/ash/services/device_sync/cryptauth_key_bundle_unittest.cc +++ b/ash/services/device_sync/cryptauth_key_bundle_unittest.cc
@@ -7,7 +7,7 @@ #include "ash/services/device_sync/cryptauth_enrollment_constants.h" #include "testing/gtest/include/gtest/gtest.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -266,4 +266,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_key_creator.cc b/ash/services/device_sync/cryptauth_key_creator.cc index 08943dd..1e0226c 100644 --- a/ash/services/device_sync/cryptauth_key_creator.cc +++ b/ash/services/device_sync/cryptauth_key_creator.cc
@@ -4,7 +4,7 @@ #include "ash/services/device_sync/cryptauth_key_creator.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -41,4 +41,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_key_creator.h b/ash/services/device_sync/cryptauth_key_creator.h index 03b6ecf..c0870537 100644 --- a/ash/services/device_sync/cryptauth_key_creator.h +++ b/ash/services/device_sync/cryptauth_key_creator.h
@@ -14,7 +14,7 @@ #include "base/containers/flat_map.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -92,6 +92,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_KEY_CREATOR_H_
diff --git a/ash/services/device_sync/cryptauth_key_creator_impl.cc b/ash/services/device_sync/cryptauth_key_creator_impl.cc index 8fd69f8d..30b9780 100644 --- a/ash/services/device_sync/cryptauth_key_creator_impl.cc +++ b/ash/services/device_sync/cryptauth_key_creator_impl.cc
@@ -12,7 +12,7 @@ #include "base/strings/string_util.h" #include "crypto/hkdf.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -242,4 +242,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_key_creator_impl.h b/ash/services/device_sync/cryptauth_key_creator_impl.h index 2c2c772..a683060 100644 --- a/ash/services/device_sync/cryptauth_key_creator_impl.h +++ b/ash/services/device_sync/cryptauth_key_creator_impl.h
@@ -9,6 +9,8 @@ #include <string> #include <utility> +// TODO(https://crbug.com/1164001): move to forward declaration +#include "ash/components/multidevice/secure_message_delegate.h" #include "ash/services/device_sync/cryptauth_key.h" #include "ash/services/device_sync/cryptauth_key_bundle.h" #include "ash/services/device_sync/cryptauth_key_creator.h" @@ -17,11 +19,7 @@ #include "base/memory/weak_ptr.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { - -namespace multidevice { -class SecureMessageDelegate; -} // namespace multidevice +namespace ash { namespace device_sync { @@ -84,6 +82,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_KEY_CREATOR_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_key_creator_impl_unittest.cc b/ash/services/device_sync/cryptauth_key_creator_impl_unittest.cc index ef77593d..8083dd7 100644 --- a/ash/services/device_sync/cryptauth_key_creator_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_key_creator_impl_unittest.cc
@@ -21,7 +21,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -295,4 +295,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_key_proof_computer.h b/ash/services/device_sync/cryptauth_key_proof_computer.h index ee1bf4b..803bb8d 100644 --- a/ash/services/device_sync/cryptauth_key_proof_computer.h +++ b/ash/services/device_sync/cryptauth_key_proof_computer.h
@@ -9,7 +9,7 @@ #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -64,6 +64,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_KEY_PROOF_COMPUTER_H_
diff --git a/ash/services/device_sync/cryptauth_key_proof_computer_impl.cc b/ash/services/device_sync/cryptauth_key_proof_computer_impl.cc index ffcfca6..0dbe7c8 100644 --- a/ash/services/device_sync/cryptauth_key_proof_computer_impl.cc +++ b/ash/services/device_sync/cryptauth_key_proof_computer_impl.cc
@@ -17,7 +17,7 @@ #include "crypto/hkdf.h" #include "crypto/hmac.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -154,4 +154,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_key_proof_computer_impl.h b/ash/services/device_sync/cryptauth_key_proof_computer_impl.h index 41a92e0..e10c48c 100644 --- a/ash/services/device_sync/cryptauth_key_proof_computer_impl.h +++ b/ash/services/device_sync/cryptauth_key_proof_computer_impl.h
@@ -11,7 +11,7 @@ #include "ash/services/device_sync/cryptauth_key_proof_computer.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -61,6 +61,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_KEY_PROOF_COMPUTER_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_key_proof_computer_impl_unittest.cc b/ash/services/device_sync/cryptauth_key_proof_computer_impl_unittest.cc index 5508c76c..dd53a25 100644 --- a/ash/services/device_sync/cryptauth_key_proof_computer_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_key_proof_computer_impl_unittest.cc
@@ -17,7 +17,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -172,4 +172,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_key_registry.cc b/ash/services/device_sync/cryptauth_key_registry.cc index 694b76d..1830e541 100644 --- a/ash/services/device_sync/cryptauth_key_registry.cc +++ b/ash/services/device_sync/cryptauth_key_registry.cc
@@ -4,7 +4,7 @@ #include "ash/services/device_sync/cryptauth_key_registry.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -100,4 +100,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_key_registry.h b/ash/services/device_sync/cryptauth_key_registry.h index fe13ee8..8b561800 100644 --- a/ash/services/device_sync/cryptauth_key_registry.h +++ b/ash/services/device_sync/cryptauth_key_registry.h
@@ -9,7 +9,7 @@ #include "ash/services/device_sync/proto/cryptauth_enrollment.pb.h" #include "base/containers/flat_map.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -73,6 +73,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_KEY_REGISTRY_H_
diff --git a/ash/services/device_sync/cryptauth_key_registry_impl.cc b/ash/services/device_sync/cryptauth_key_registry_impl.cc index 019dea06..d71cc87 100644 --- a/ash/services/device_sync/cryptauth_key_registry_impl.cc +++ b/ash/services/device_sync/cryptauth_key_registry_impl.cc
@@ -10,7 +10,7 @@ #include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_service.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -83,4 +83,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_key_registry_impl.h b/ash/services/device_sync/cryptauth_key_registry_impl.h index cf9ff02..75af5b8a 100644 --- a/ash/services/device_sync/cryptauth_key_registry_impl.h +++ b/ash/services/device_sync/cryptauth_key_registry_impl.h
@@ -11,7 +11,7 @@ class PrefRegistrySimple; class PrefService; -namespace chromeos { +namespace ash { namespace device_sync { @@ -62,11 +62,6 @@ } // namespace device_sync -} // namespace chromeos - -// TODO(https://crbug.com/1164001): remove when it moved to ash. -namespace ash::device_sync { -using ::chromeos::device_sync::CryptAuthKeyRegistryImpl; -} +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_KEY_REGISTRY_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_key_registry_impl_unittest.cc b/ash/services/device_sync/cryptauth_key_registry_impl_unittest.cc index 451fdcb1..dffef501 100644 --- a/ash/services/device_sync/cryptauth_key_registry_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_key_registry_impl_unittest.cc
@@ -10,7 +10,7 @@ #include "components/prefs/testing_pref_service.h" #include "testing/gtest/include/gtest/gtest.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -273,4 +273,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_key_unittest.cc b/ash/services/device_sync/cryptauth_key_unittest.cc index 7c06362..9efcb1ce 100644 --- a/ash/services/device_sync/cryptauth_key_unittest.cc +++ b/ash/services/device_sync/cryptauth_key_unittest.cc
@@ -7,7 +7,7 @@ #include "ash/services/device_sync/value_string_encoding.h" #include "testing/gtest/include/gtest/gtest.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -222,4 +222,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_metadata_syncer.cc b/ash/services/device_sync/cryptauth_metadata_syncer.cc index 9a49051..910dfe1 100644 --- a/ash/services/device_sync/cryptauth_metadata_syncer.cc +++ b/ash/services/device_sync/cryptauth_metadata_syncer.cc
@@ -6,7 +6,7 @@ #include <utility> -namespace chromeos { +namespace ash { namespace device_sync { @@ -44,4 +44,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_metadata_syncer.h b/ash/services/device_sync/cryptauth_metadata_syncer.h index 670f29b..887f5088 100644 --- a/ash/services/device_sync/cryptauth_metadata_syncer.h +++ b/ash/services/device_sync/cryptauth_metadata_syncer.h
@@ -19,7 +19,7 @@ class BetterTogetherDeviceMetadata; } // namespace cryptauthv2 -namespace chromeos { +namespace ash { namespace device_sync { @@ -113,6 +113,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_METADATA_SYNCER_H_
diff --git a/ash/services/device_sync/cryptauth_metadata_syncer_impl.cc b/ash/services/device_sync/cryptauth_metadata_syncer_impl.cc index b4c4c715..3a096d2 100644 --- a/ash/services/device_sync/cryptauth_metadata_syncer_impl.cc +++ b/ash/services/device_sync/cryptauth_metadata_syncer_impl.cc
@@ -22,7 +22,7 @@ #include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_service.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -728,4 +728,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_metadata_syncer_impl.h b/ash/services/device_sync/cryptauth_metadata_syncer_impl.h index f9e85f6..2f981fb 100644 --- a/ash/services/device_sync/cryptauth_metadata_syncer_impl.h +++ b/ash/services/device_sync/cryptauth_metadata_syncer_impl.h
@@ -25,7 +25,7 @@ class PrefRegistrySimple; class PrefService; -namespace chromeos { +namespace ash { namespace device_sync { @@ -194,11 +194,6 @@ } // namespace device_sync -} // namespace chromeos - -// TODO(https://crbug.com/1164001): remove when it moved to ash. -namespace ash::device_sync { -using ::chromeos::device_sync::CryptAuthMetadataSyncerImpl; -} +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_METADATA_SYNCER_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_metadata_syncer_impl_unittest.cc b/ash/services/device_sync/cryptauth_metadata_syncer_impl_unittest.cc index 6368637..360057ca 100644 --- a/ash/services/device_sync/cryptauth_metadata_syncer_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_metadata_syncer_impl_unittest.cc
@@ -36,7 +36,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -1262,4 +1262,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_scheduler.cc b/ash/services/device_sync/cryptauth_scheduler.cc index dd22fccf..f7ea832 100644 --- a/ash/services/device_sync/cryptauth_scheduler.cc +++ b/ash/services/device_sync/cryptauth_scheduler.cc
@@ -4,7 +4,7 @@ #include "ash/services/device_sync/cryptauth_scheduler.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -68,4 +68,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_scheduler.h b/ash/services/device_sync/cryptauth_scheduler.h index a0c05bfb..91d4b40f 100644 --- a/ash/services/device_sync/cryptauth_scheduler.h +++ b/ash/services/device_sync/cryptauth_scheduler.h
@@ -14,7 +14,7 @@ #include "base/time/time.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -150,6 +150,11 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash + +// TODO(https://crbug.com/1164001): remove when the migration is finished. +namespace chromeos::device_sync { +using ::ash::device_sync::CryptAuthScheduler; +} #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_SCHEDULER_H_
diff --git a/ash/services/device_sync/cryptauth_scheduler_impl.cc b/ash/services/device_sync/cryptauth_scheduler_impl.cc index 6dbe3e4..e0eea655 100644 --- a/ash/services/device_sync/cryptauth_scheduler_impl.cc +++ b/ash/services/device_sync/cryptauth_scheduler_impl.cc
@@ -18,7 +18,7 @@ #include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_service.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -581,4 +581,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_scheduler_impl.h b/ash/services/device_sync/cryptauth_scheduler_impl.h index 5239cb1..62d679d 100644 --- a/ash/services/device_sync/cryptauth_scheduler_impl.h +++ b/ash/services/device_sync/cryptauth_scheduler_impl.h
@@ -18,15 +18,15 @@ #include "base/time/default_clock.h" #include "base/timer/timer.h" #include "chromeos/network/network_handler.h" +// TODO(https://crbug.com/1164001): move to forward declaration +#include "chromeos/network/network_state_handler.h" #include "chromeos/network/network_state_handler_observer.h" #include "third_party/abseil-cpp/absl/types/optional.h" class PrefRegistrySimple; class PrefService; -namespace chromeos { - -class NetworkStateHandler; +namespace ash { namespace device_sync { @@ -185,11 +185,6 @@ } // namespace device_sync -} // namespace chromeos - -// TODO(https://crbug.com/1164001): remove when it moved to ash. -namespace ash::device_sync { -using ::chromeos::device_sync::CryptAuthSchedulerImpl; -} +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_SCHEDULER_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_scheduler_impl_unittest.cc b/ash/services/device_sync/cryptauth_scheduler_impl_unittest.cc index 4c9fec1..db926e41 100644 --- a/ash/services/device_sync/cryptauth_scheduler_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_scheduler_impl_unittest.cc
@@ -23,7 +23,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/cros_system_api/dbus/shill/dbus-constants.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -1026,4 +1026,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_task_metrics_logger.cc b/ash/services/device_sync/cryptauth_task_metrics_logger.cc index 5d6dc973..8b1dd9c 100644 --- a/ash/services/device_sync/cryptauth_task_metrics_logger.cc +++ b/ash/services/device_sync/cryptauth_task_metrics_logger.cc
@@ -6,7 +6,7 @@ #include "base/metrics/histogram_functions.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -42,4 +42,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_task_metrics_logger.h b/ash/services/device_sync/cryptauth_task_metrics_logger.h index 5891db0c..0c679c4 100644 --- a/ash/services/device_sync/cryptauth_task_metrics_logger.h +++ b/ash/services/device_sync/cryptauth_task_metrics_logger.h
@@ -9,7 +9,7 @@ #include "ash/services/device_sync/network_request_error.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -53,6 +53,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_TASK_METRICS_LOGGER_H_
diff --git a/ash/services/device_sync/cryptauth_v2_device_manager.cc b/ash/services/device_sync/cryptauth_v2_device_manager.cc index c9d68fc..b5579fa 100644 --- a/ash/services/device_sync/cryptauth_v2_device_manager.cc +++ b/ash/services/device_sync/cryptauth_v2_device_manager.cc
@@ -4,7 +4,7 @@ #include "ash/services/device_sync/cryptauth_v2_device_manager.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -34,4 +34,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_v2_device_manager.h b/ash/services/device_sync/cryptauth_v2_device_manager.h index b6e5e0d..8617a5f5 100644 --- a/ash/services/device_sync/cryptauth_v2_device_manager.h +++ b/ash/services/device_sync/cryptauth_v2_device_manager.h
@@ -16,7 +16,7 @@ #include "base/time/time.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -89,13 +89,11 @@ } // namespace device_sync -} // namespace chromeos - -// TODO(https://crbug.com/1164001): remove when this file is moved to ash. -namespace ash { -namespace device_sync { -using ::chromeos::device_sync::CryptAuthV2DeviceManager; -} // namespace device_sync } // namespace ash +// TODO(https://crbug.com/1164001): remove when the migration is finished. +namespace chromeos::device_sync { +using ::ash::device_sync::CryptAuthV2DeviceManager; +} + #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_V2_DEVICE_MANAGER_H_
diff --git a/ash/services/device_sync/cryptauth_v2_device_manager_impl.cc b/ash/services/device_sync/cryptauth_v2_device_manager_impl.cc index 5efedf7..32ecb76 100644 --- a/ash/services/device_sync/cryptauth_v2_device_manager_impl.cc +++ b/ash/services/device_sync/cryptauth_v2_device_manager_impl.cc
@@ -15,7 +15,7 @@ #include "base/memory/ptr_util.h" #include "base/metrics/histogram_functions.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -211,4 +211,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_v2_device_manager_impl.h b/ash/services/device_sync/cryptauth_v2_device_manager_impl.h index 8e842cb0..618ec9f 100644 --- a/ash/services/device_sync/cryptauth_v2_device_manager_impl.h +++ b/ash/services/device_sync/cryptauth_v2_device_manager_impl.h
@@ -16,20 +16,21 @@ #include "ash/services/device_sync/cryptauth_v2_device_manager.h" #include "ash/services/device_sync/proto/cryptauth_client_app_metadata.pb.h" #include "ash/services/device_sync/proto/cryptauth_common.pb.h" +// TODO(https://crbug.com/1164001): move to forward declaration +#include "ash/services/device_sync/synced_bluetooth_address_tracker.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" #include "third_party/abseil-cpp/absl/types/optional.h" class PrefService; -namespace chromeos { +namespace ash { namespace device_sync { class CryptAuthClientFactory; class CryptAuthDeviceSyncer; class CryptAuthKeyRegistry; -class SyncedBluetoothAddressTracker; // Implementation of CryptAuthV2DeviceManager that considers three sources of // DeviceSync requests: @@ -131,6 +132,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_V2_DEVICE_MANAGER_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_v2_device_manager_impl_unittest.cc b/ash/services/device_sync/cryptauth_v2_device_manager_impl_unittest.cc index 670c32f..6c435693 100644 --- a/ash/services/device_sync/cryptauth_v2_device_manager_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_v2_device_manager_impl_unittest.cc
@@ -20,7 +20,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -387,4 +387,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_v2_device_sync_test_devices.cc b/ash/services/device_sync/cryptauth_v2_device_sync_test_devices.cc index 78734f30..20f13f8 100644 --- a/ash/services/device_sync/cryptauth_v2_device_sync_test_devices.cc +++ b/ash/services/device_sync/cryptauth_v2_device_sync_test_devices.cc
@@ -13,7 +13,7 @@ #include "base/check_op.h" #include "base/no_destructor.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -328,4 +328,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_v2_device_sync_test_devices.h b/ash/services/device_sync/cryptauth_v2_device_sync_test_devices.h index 6105d51..a926a8d 100644 --- a/ash/services/device_sync/cryptauth_v2_device_sync_test_devices.h +++ b/ash/services/device_sync/cryptauth_v2_device_sync_test_devices.h
@@ -14,7 +14,7 @@ class DeviceMetadataPacket; } // namespace cryptauthv2 -namespace chromeos { +namespace ash { namespace device_sync { @@ -72,6 +72,11 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash + +// TODO(https://crbug.com/1164001): remove when the migration is finished. +namespace chromeos::device_sync { +using ::ash::device_sync::kDefaultLocalDeviceBluetoothAddress; +} #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_V2_DEVICE_SYNC_TEST_DEVICES_H_
diff --git a/ash/services/device_sync/cryptauth_v2_enroller.cc b/ash/services/device_sync/cryptauth_v2_enroller.cc index dd24561..6972cba 100644 --- a/ash/services/device_sync/cryptauth_v2_enroller.cc +++ b/ash/services/device_sync/cryptauth_v2_enroller.cc
@@ -6,7 +6,7 @@ #include <utility> -namespace chromeos { +namespace ash { namespace device_sync { @@ -38,4 +38,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_v2_enroller.h b/ash/services/device_sync/cryptauth_v2_enroller.h index 5c11c907..ef82eae 100644 --- a/ash/services/device_sync/cryptauth_v2_enroller.h +++ b/ash/services/device_sync/cryptauth_v2_enroller.h
@@ -14,7 +14,7 @@ class PolicyReference; } // namespace cryptauthv2 -namespace chromeos { +namespace ash { namespace device_sync { @@ -96,6 +96,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_V2_ENROLLER_H_
diff --git a/ash/services/device_sync/cryptauth_v2_enroller_impl.cc b/ash/services/device_sync/cryptauth_v2_enroller_impl.cc index f003a38..6920fe2 100644 --- a/ash/services/device_sync/cryptauth_v2_enroller_impl.cc +++ b/ash/services/device_sync/cryptauth_v2_enroller_impl.cc
@@ -21,7 +21,7 @@ #include "base/memory/ptr_util.h" #include "base/no_destructor.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -881,4 +881,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_v2_enroller_impl.h b/ash/services/device_sync/cryptauth_v2_enroller_impl.h index 9d2c104..b31d9b1 100644 --- a/ash/services/device_sync/cryptauth_v2_enroller_impl.h +++ b/ash/services/device_sync/cryptauth_v2_enroller_impl.h
@@ -29,7 +29,7 @@ class PolicyReference; } // namespace cryptauthv2 -namespace chromeos { +namespace ash { namespace device_sync { @@ -195,6 +195,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_V2_ENROLLER_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_v2_enroller_impl_unittest.cc b/ash/services/device_sync/cryptauth_v2_enroller_impl_unittest.cc index 160f694..0d3da01b 100644 --- a/ash/services/device_sync/cryptauth_v2_enroller_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_v2_enroller_impl_unittest.cc
@@ -33,7 +33,7 @@ #include "components/prefs/testing_pref_service.h" #include "testing/gtest/include/gtest/gtest.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -1209,4 +1209,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_v2_enrollment_manager_impl.cc b/ash/services/device_sync/cryptauth_v2_enrollment_manager_impl.cc index a97402c..1fbb21a 100644 --- a/ash/services/device_sync/cryptauth_v2_enrollment_manager_impl.cc +++ b/ash/services/device_sync/cryptauth_v2_enrollment_manager_impl.cc
@@ -22,7 +22,7 @@ #include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_service.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -443,4 +443,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/cryptauth_v2_enrollment_manager_impl.h b/ash/services/device_sync/cryptauth_v2_enrollment_manager_impl.h index 900a7ee..e93b432 100644 --- a/ash/services/device_sync/cryptauth_v2_enrollment_manager_impl.h +++ b/ash/services/device_sync/cryptauth_v2_enrollment_manager_impl.h
@@ -22,7 +22,7 @@ class PrefService; class PrefRegistrySimple; -namespace chromeos { +namespace ash { namespace device_sync { @@ -169,11 +169,6 @@ } // namespace device_sync -} // namespace chromeos - -// TODO(https://crbug.com/1164001): remove when it moved to ash. -namespace ash::device_sync { -using ::chromeos::device_sync::CryptAuthV2EnrollmentManagerImpl; -} +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_CRYPTAUTH_V2_ENROLLMENT_MANAGER_IMPL_H_
diff --git a/ash/services/device_sync/cryptauth_v2_enrollment_manager_impl_unittest.cc b/ash/services/device_sync/cryptauth_v2_enrollment_manager_impl_unittest.cc index f1fb24d..ff28eaa 100644 --- a/ash/services/device_sync/cryptauth_v2_enrollment_manager_impl_unittest.cc +++ b/ash/services/device_sync/cryptauth_v2_enrollment_manager_impl_unittest.cc
@@ -38,7 +38,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -881,4 +881,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/device_sync_base.cc b/ash/services/device_sync/device_sync_base.cc index a8e8fd2..8fff157a 100644 --- a/ash/services/device_sync/device_sync_base.cc +++ b/ash/services/device_sync/device_sync_base.cc
@@ -9,13 +9,10 @@ #include "base/bind.h" #include "base/callback.h" -namespace chromeos { +namespace ash { namespace device_sync { -// TODO(https://crbug.com/1164001): remove after migrating to ash. -namespace mojom = ::ash::device_sync::mojom; - DeviceSyncBase::DeviceSyncBase() { receivers_.set_disconnect_handler(base::BindRepeating( &DeviceSyncBase::OnDisconnection, base::Unretained(this))); @@ -57,4 +54,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/device_sync_base.h b/ash/services/device_sync/device_sync_base.h index b9fcb97c..ba15edc 100644 --- a/ash/services/device_sync/device_sync_base.h +++ b/ash/services/device_sync/device_sync_base.h
@@ -11,27 +11,25 @@ #include "mojo/public/cpp/bindings/receiver_set.h" #include "mojo/public/cpp/bindings/remote_set.h" -namespace chromeos { +namespace ash { namespace device_sync { // Base DeviceSync implementation. -class DeviceSyncBase : public ash::device_sync::mojom::DeviceSync { +class DeviceSyncBase : public mojom::DeviceSync { public: DeviceSyncBase(const DeviceSyncBase&) = delete; DeviceSyncBase& operator=(const DeviceSyncBase&) = delete; ~DeviceSyncBase() override; - // ash::device_sync::mojom::DeviceSync: - void AddObserver( - mojo::PendingRemote<ash::device_sync::mojom::DeviceSyncObserver> observer, - AddObserverCallback callback) override; + // device_sync::mojom::DeviceSync: + void AddObserver(mojo::PendingRemote<mojom::DeviceSyncObserver> observer, + AddObserverCallback callback) override; // Binds a receiver to this implementation. Should be called each time that // the service receives a receiver. - void BindReceiver( - mojo::PendingReceiver<ash::device_sync::mojom::DeviceSync> receiver); + void BindReceiver(mojo::PendingReceiver<mojom::DeviceSync> receiver); void CloseAllReceivers(); @@ -48,19 +46,17 @@ private: void OnDisconnection(); - mojo::RemoteSet<ash::device_sync::mojom::DeviceSyncObserver> observers_; - mojo::ReceiverSet<ash::device_sync::mojom::DeviceSync> receivers_; + mojo::RemoteSet<mojom::DeviceSyncObserver> observers_; + mojo::ReceiverSet<mojom::DeviceSync> receivers_; }; } // namespace device_sync -} // namespace chromeos - -// TODO(https://crbug.com/1164001): remove after the migration is finished. -namespace ash { -namespace device_sync { -using ::chromeos::device_sync::DeviceSyncBase; -} } // namespace ash +// TODO(https://crbug.com/1164001): remove when the migration is finished. +namespace chromeos::device_sync { +using ::ash::device_sync::DeviceSyncBase; +} + #endif // ASH_SERVICES_DEVICE_SYNC_DEVICE_SYNC_BASE_H_
diff --git a/ash/services/device_sync/device_sync_impl.cc b/ash/services/device_sync/device_sync_impl.cc index 70a1e3f..4e59a172 100644 --- a/ash/services/device_sync/device_sync_impl.cc +++ b/ash/services/device_sync/device_sync_impl.cc
@@ -46,15 +46,12 @@ #include "services/network/public/cpp/shared_url_loader_factory.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { namespace { -// TODO(https://crbug.com/1164001): remove after migrating to ash. -namespace mojom = ::ash::device_sync::mojom; - constexpr base::TimeDelta kSetFeatureEnabledTimeout = base::Seconds(5); // Timeout value for asynchronous operation. @@ -1344,4 +1341,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/device_sync_impl.h b/ash/services/device_sync/device_sync_impl.h index 39e9bf8..9fee0ea 100644 --- a/ash/services/device_sync/device_sync_impl.h +++ b/ash/services/device_sync/device_sync_impl.h
@@ -22,6 +22,8 @@ #include "ash/services/device_sync/public/cpp/gcm_device_info_provider.h" #include "ash/services/device_sync/public/mojom/device_sync.mojom.h" #include "ash/services/device_sync/remote_device_provider.h" +// TODO(https://crbug.com/1164001): move to forward declaration +#include "ash/services/device_sync/software_feature_manager.h" #include "base/containers/flat_map.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" @@ -44,7 +46,7 @@ class SharedURLLoaderFactory; } // namespace network -namespace chromeos { +namespace ash { namespace device_sync { @@ -56,7 +58,6 @@ class CryptAuthKeyRegistry; class CryptAuthScheduler; class CryptAuthV2DeviceManager; -class SoftwareFeatureManager; // Concrete DeviceSync implementation. When DeviceSyncImpl is constructed, it // starts an initialization flow with the following steps: @@ -109,7 +110,7 @@ ~DeviceSyncImpl() override; protected: - // ash::device_sync::mojom::DeviceSync: + // device_sync::mojom::DeviceSync: void ForceEnrollmentNow(ForceEnrollmentNowCallback callback) override; void ForceSyncNow(ForceSyncNowCallback callback) override; void GetLocalDeviceMetadata(GetLocalDeviceMetadataCallback callback) override; @@ -169,7 +170,7 @@ // feature has been set according to the parameters used). bool IsFulfilled() const; - void InvokeCallback(ash::device_sync::mojom::NetworkRequestResult result); + void InvokeCallback(mojom::NetworkRequestResult result); multidevice::SoftwareFeature software_feature() const { return software_feature_; @@ -199,7 +200,7 @@ // agrees with the device data returned by CryptAuth. bool IsFulfilled() const; - void InvokeCallback(ash::device_sync::mojom::NetworkRequestResult result); + void InvokeCallback(mojom::NetworkRequestResult result); private: std::string device_instance_id_; @@ -251,15 +252,14 @@ void OnSetFeatureStatusError(const base::UnguessableToken& request_id, NetworkRequestError error); void OnFindEligibleDevicesSuccess( - base::OnceCallback<void( - ash::device_sync::mojom::NetworkRequestResult, - ash::device_sync::mojom::FindEligibleDevicesResponsePtr)> callback, + base::OnceCallback<void(mojom::NetworkRequestResult, + mojom::FindEligibleDevicesResponsePtr)> callback, const std::vector<cryptauth::ExternalDeviceInfo>& eligible_devices, const std::vector<cryptauth::IneligibleDevice>& ineligible_devices); void OnFindEligibleDevicesError( - const base::OnceCallback<void( - ash::device_sync::mojom::NetworkRequestResult, - ash::device_sync::mojom::FindEligibleDevicesResponsePtr)> callback, + const base::OnceCallback<void(mojom::NetworkRequestResult, + mojom::FindEligibleDevicesResponsePtr)> + callback, NetworkRequestError error); void OnNotifyDevicesSuccess(const base::UnguessableToken& request_id); void OnNotifyDevicesError(const base::UnguessableToken& request_id, @@ -331,13 +331,11 @@ } // namespace device_sync -} // namespace chromeos - -// TODO(https://crbug.com/1164001): remove after the migration is finished. -namespace ash { -namespace device_sync { -using ::chromeos::device_sync::DeviceSyncImpl; -} } // namespace ash +// TODO(https://crbug.com/1164001): remove when the migration is finished. +namespace chromeos::device_sync { +using ::ash::device_sync::DeviceSyncImpl; +} + #endif // ASH_SERVICES_DEVICE_SYNC_DEVICE_SYNC_IMPL_H_
diff --git a/ash/services/device_sync/device_sync_service_unittest.cc b/ash/services/device_sync/device_sync_service_unittest.cc index 0d4d279..3959a522 100644 --- a/ash/services/device_sync/device_sync_service_unittest.cc +++ b/ash/services/device_sync/device_sync_service_unittest.cc
@@ -63,15 +63,12 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { namespace { -// TODO(https://crbug.com/1164001): remove after migrating to ash. -namespace mojom = ::ash::device_sync::mojom; - const char kTestEmail[] = "example@gmail.com"; const char kTestGcmDeviceInfoLongDeviceId[] = "longDeviceId"; const char kTestCryptAuthGCMRegistrationId[] = "cryptAuthRegistrationId"; @@ -2478,4 +2475,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/fake_cryptauth_device_manager.cc b/ash/services/device_sync/fake_cryptauth_device_manager.cc index 5b43d18c..52dc3db 100644 --- a/ash/services/device_sync/fake_cryptauth_device_manager.cc +++ b/ash/services/device_sync/fake_cryptauth_device_manager.cc
@@ -6,7 +6,7 @@ #include <memory> -namespace chromeos { +namespace ash { namespace device_sync { @@ -84,4 +84,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/fake_cryptauth_device_manager.h b/ash/services/device_sync/fake_cryptauth_device_manager.h index 773a38f..16ceaa4 100644 --- a/ash/services/device_sync/fake_cryptauth_device_manager.h +++ b/ash/services/device_sync/fake_cryptauth_device_manager.h
@@ -11,7 +11,7 @@ #include "ash/services/device_sync/proto/cryptauth_api.pb.h" #include "base/time/time.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -131,6 +131,11 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash + +// TODO(https://crbug.com/1164001): remove when the migration is finished. +namespace chromeos::device_sync { +using ::ash::device_sync::FakeCryptAuthDeviceManager; +} #endif // ASH_SERVICES_DEVICE_SYNC_FAKE_CRYPTAUTH_DEVICE_MANAGER_H_
diff --git a/ash/services/device_sync/fake_cryptauth_device_notifier.cc b/ash/services/device_sync/fake_cryptauth_device_notifier.cc index 8e73197..c2e0962 100644 --- a/ash/services/device_sync/fake_cryptauth_device_notifier.cc +++ b/ash/services/device_sync/fake_cryptauth_device_notifier.cc
@@ -6,7 +6,7 @@ #include "ash/services/device_sync/fake_cryptauth_device_notifier.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -73,4 +73,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/fake_cryptauth_device_notifier.h b/ash/services/device_sync/fake_cryptauth_device_notifier.h index 63208956..69c7dc5 100644 --- a/ash/services/device_sync/fake_cryptauth_device_notifier.h +++ b/ash/services/device_sync/fake_cryptauth_device_notifier.h
@@ -17,7 +17,7 @@ #include "base/containers/flat_set.h" #include "base/timer/timer.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -116,6 +116,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_FAKE_CRYPTAUTH_DEVICE_NOTIFIER_H_
diff --git a/ash/services/device_sync/fake_cryptauth_device_syncer.cc b/ash/services/device_sync/fake_cryptauth_device_syncer.cc index 86ceea96..3b22db7e 100644 --- a/ash/services/device_sync/fake_cryptauth_device_syncer.cc +++ b/ash/services/device_sync/fake_cryptauth_device_syncer.cc
@@ -6,7 +6,7 @@ #include "ash/services/device_sync/cryptauth_device_sync_result.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -54,4 +54,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/fake_cryptauth_device_syncer.h b/ash/services/device_sync/fake_cryptauth_device_syncer.h index 9892803..f02bdc6a 100644 --- a/ash/services/device_sync/fake_cryptauth_device_syncer.h +++ b/ash/services/device_sync/fake_cryptauth_device_syncer.h
@@ -15,7 +15,7 @@ class PrefService; -namespace chromeos { +namespace ash { namespace device_sync { @@ -104,6 +104,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_FAKE_CRYPTAUTH_DEVICE_SYNCER_H_
diff --git a/ash/services/device_sync/fake_cryptauth_ecies_encryptor.cc b/ash/services/device_sync/fake_cryptauth_ecies_encryptor.cc index 1eda1726..23de832 100644 --- a/ash/services/device_sync/fake_cryptauth_ecies_encryptor.cc +++ b/ash/services/device_sync/fake_cryptauth_ecies_encryptor.cc
@@ -4,7 +4,7 @@ #include "ash/services/device_sync/fake_cryptauth_ecies_encryptor.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -44,4 +44,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/fake_cryptauth_ecies_encryptor.h b/ash/services/device_sync/fake_cryptauth_ecies_encryptor.h index 8a36cbb7..60273c9 100644 --- a/ash/services/device_sync/fake_cryptauth_ecies_encryptor.h +++ b/ash/services/device_sync/fake_cryptauth_ecies_encryptor.h
@@ -10,7 +10,7 @@ #include "ash/services/device_sync/cryptauth_ecies_encryptor.h" #include "ash/services/device_sync/cryptauth_ecies_encryptor_impl.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -62,6 +62,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_FAKE_CRYPTAUTH_ECIES_ENCRYPTOR_H_
diff --git a/ash/services/device_sync/fake_cryptauth_enrollment_manager.cc b/ash/services/device_sync/fake_cryptauth_enrollment_manager.cc index 95535d2a..dc10aec 100644 --- a/ash/services/device_sync/fake_cryptauth_enrollment_manager.cc +++ b/ash/services/device_sync/fake_cryptauth_enrollment_manager.cc
@@ -4,7 +4,7 @@ #include "ash/services/device_sync/fake_cryptauth_enrollment_manager.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -71,4 +71,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/fake_cryptauth_enrollment_manager.h b/ash/services/device_sync/fake_cryptauth_enrollment_manager.h index 5db4f33..74a1dac 100644 --- a/ash/services/device_sync/fake_cryptauth_enrollment_manager.h +++ b/ash/services/device_sync/fake_cryptauth_enrollment_manager.h
@@ -13,7 +13,7 @@ #include "base/time/time.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -101,6 +101,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_FAKE_CRYPTAUTH_ENROLLMENT_MANAGER_H_
diff --git a/ash/services/device_sync/fake_cryptauth_feature_status_getter.cc b/ash/services/device_sync/fake_cryptauth_feature_status_getter.cc index decca5b..b4634aed 100644 --- a/ash/services/device_sync/fake_cryptauth_feature_status_getter.cc +++ b/ash/services/device_sync/fake_cryptauth_feature_status_getter.cc
@@ -4,7 +4,7 @@ #include "ash/services/device_sync/fake_cryptauth_feature_status_getter.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -50,4 +50,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/fake_cryptauth_feature_status_getter.h b/ash/services/device_sync/fake_cryptauth_feature_status_getter.h index 9ac4485..3096ad7 100644 --- a/ash/services/device_sync/fake_cryptauth_feature_status_getter.h +++ b/ash/services/device_sync/fake_cryptauth_feature_status_getter.h
@@ -17,7 +17,7 @@ #include "base/timer/timer.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -96,6 +96,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_FAKE_CRYPTAUTH_FEATURE_STATUS_GETTER_H_
diff --git a/ash/services/device_sync/fake_cryptauth_feature_status_setter.cc b/ash/services/device_sync/fake_cryptauth_feature_status_setter.cc index 457f328..91a12359 100644 --- a/ash/services/device_sync/fake_cryptauth_feature_status_setter.cc +++ b/ash/services/device_sync/fake_cryptauth_feature_status_setter.cc
@@ -4,7 +4,7 @@ #include "ash/services/device_sync/fake_cryptauth_feature_status_setter.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -71,4 +71,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/fake_cryptauth_feature_status_setter.h b/ash/services/device_sync/fake_cryptauth_feature_status_setter.h index 5a013db..7a3ada0 100644 --- a/ash/services/device_sync/fake_cryptauth_feature_status_setter.h +++ b/ash/services/device_sync/fake_cryptauth_feature_status_setter.h
@@ -16,7 +16,7 @@ #include "base/callback.h" #include "base/timer/timer.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -116,6 +116,11 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash + +// TODO(https://crbug.com/1164001): remove when the migration is finished. +namespace chromeos::device_sync { +using ::ash::device_sync::FakeCryptAuthFeatureStatusSetter; +} #endif // ASH_SERVICES_DEVICE_SYNC_FAKE_CRYPTAUTH_FEATURE_STATUS_SETTER_H_
diff --git a/ash/services/device_sync/fake_cryptauth_gcm_manager.cc b/ash/services/device_sync/fake_cryptauth_gcm_manager.cc index 3be850a..1b4f4b1 100644 --- a/ash/services/device_sync/fake_cryptauth_gcm_manager.cc +++ b/ash/services/device_sync/fake_cryptauth_gcm_manager.cc
@@ -4,7 +4,7 @@ #include "ash/services/device_sync/fake_cryptauth_gcm_manager.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -64,4 +64,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/fake_cryptauth_gcm_manager.h b/ash/services/device_sync/fake_cryptauth_gcm_manager.h index 1cea8ed..4e6c5b2fe 100644 --- a/ash/services/device_sync/fake_cryptauth_gcm_manager.h +++ b/ash/services/device_sync/fake_cryptauth_gcm_manager.h
@@ -12,7 +12,7 @@ #include "base/observer_list.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -72,6 +72,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_FAKE_CRYPTAUTH_GCM_MANAGER_H_
diff --git a/ash/services/device_sync/fake_cryptauth_group_private_key_sharer.cc b/ash/services/device_sync/fake_cryptauth_group_private_key_sharer.cc index d56c98c..3c7e2d0 100644 --- a/ash/services/device_sync/fake_cryptauth_group_private_key_sharer.cc +++ b/ash/services/device_sync/fake_cryptauth_group_private_key_sharer.cc
@@ -6,7 +6,7 @@ #include "ash/services/device_sync/cryptauth_key.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -54,4 +54,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/fake_cryptauth_group_private_key_sharer.h b/ash/services/device_sync/fake_cryptauth_group_private_key_sharer.h index 1e64585..1eccd65 100644 --- a/ash/services/device_sync/fake_cryptauth_group_private_key_sharer.h +++ b/ash/services/device_sync/fake_cryptauth_group_private_key_sharer.h
@@ -15,7 +15,7 @@ #include "base/timer/timer.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { class CryptAuthClientFactory; @@ -99,6 +99,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_FAKE_CRYPTAUTH_GROUP_PRIVATE_KEY_SHARER_H_
diff --git a/ash/services/device_sync/fake_cryptauth_key_creator.cc b/ash/services/device_sync/fake_cryptauth_key_creator.cc index 65f211eb..768efae4 100644 --- a/ash/services/device_sync/fake_cryptauth_key_creator.cc +++ b/ash/services/device_sync/fake_cryptauth_key_creator.cc
@@ -6,7 +6,7 @@ #include <utility> -namespace chromeos { +namespace ash { namespace device_sync { @@ -40,4 +40,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/fake_cryptauth_key_creator.h b/ash/services/device_sync/fake_cryptauth_key_creator.h index b7444e5..fbc5856 100644 --- a/ash/services/device_sync/fake_cryptauth_key_creator.h +++ b/ash/services/device_sync/fake_cryptauth_key_creator.h
@@ -12,7 +12,7 @@ #include "base/containers/flat_map.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -70,6 +70,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_FAKE_CRYPTAUTH_KEY_CREATOR_H_
diff --git a/ash/services/device_sync/fake_cryptauth_key_proof_computer.cc b/ash/services/device_sync/fake_cryptauth_key_proof_computer.cc index f1311d5..d933c2c 100644 --- a/ash/services/device_sync/fake_cryptauth_key_proof_computer.cc +++ b/ash/services/device_sync/fake_cryptauth_key_proof_computer.cc
@@ -13,7 +13,7 @@ } // namespace -namespace chromeos { +namespace ash { namespace device_sync { @@ -35,4 +35,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/fake_cryptauth_key_proof_computer.h b/ash/services/device_sync/fake_cryptauth_key_proof_computer.h index 55c5941..3ae4b32 100644 --- a/ash/services/device_sync/fake_cryptauth_key_proof_computer.h +++ b/ash/services/device_sync/fake_cryptauth_key_proof_computer.h
@@ -11,7 +11,7 @@ #include "ash/services/device_sync/cryptauth_key_proof_computer.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -46,6 +46,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_FAKE_CRYPTAUTH_KEY_PROOF_COMPUTER_H_
diff --git a/ash/services/device_sync/fake_cryptauth_metadata_syncer.cc b/ash/services/device_sync/fake_cryptauth_metadata_syncer.cc index 4ac4caf..23c9737 100644 --- a/ash/services/device_sync/fake_cryptauth_metadata_syncer.cc +++ b/ash/services/device_sync/fake_cryptauth_metadata_syncer.cc
@@ -4,7 +4,7 @@ #include "ash/services/device_sync/fake_cryptauth_metadata_syncer.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -59,4 +59,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/fake_cryptauth_metadata_syncer.h b/ash/services/device_sync/fake_cryptauth_metadata_syncer.h index 2216bf0f..13dc2675 100644 --- a/ash/services/device_sync/fake_cryptauth_metadata_syncer.h +++ b/ash/services/device_sync/fake_cryptauth_metadata_syncer.h
@@ -19,7 +19,7 @@ class PrefService; -namespace chromeos { +namespace ash { namespace device_sync { @@ -116,6 +116,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_FAKE_CRYPTAUTH_METADATA_SYNCER_H_
diff --git a/ash/services/device_sync/fake_cryptauth_scheduler.cc b/ash/services/device_sync/fake_cryptauth_scheduler.cc index c0bdb25a..402d6e47 100644 --- a/ash/services/device_sync/fake_cryptauth_scheduler.cc +++ b/ash/services/device_sync/fake_cryptauth_scheduler.cc
@@ -6,7 +6,7 @@ #include "base/check.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -143,4 +143,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/fake_cryptauth_scheduler.h b/ash/services/device_sync/fake_cryptauth_scheduler.h index e119ffc..a8a2e4ad 100644 --- a/ash/services/device_sync/fake_cryptauth_scheduler.h +++ b/ash/services/device_sync/fake_cryptauth_scheduler.h
@@ -15,7 +15,7 @@ #include "base/time/time.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -201,6 +201,12 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash + +// TODO(https://crbug.com/1164001): remove when the migration is finished. +namespace chromeos::device_sync { +using ::ash::device_sync::FakeCryptAuthScheduler; +using ::ash::device_sync::FakeCryptAuthSchedulerDeviceSyncDelegate; +} // namespace chromeos::device_sync #endif // ASH_SERVICES_DEVICE_SYNC_FAKE_CRYPTAUTH_SCHEDULER_H_
diff --git a/ash/services/device_sync/fake_cryptauth_v2_device_manager.cc b/ash/services/device_sync/fake_cryptauth_v2_device_manager.cc index e605e44..2e914fc 100644 --- a/ash/services/device_sync/fake_cryptauth_v2_device_manager.cc +++ b/ash/services/device_sync/fake_cryptauth_v2_device_manager.cc
@@ -4,7 +4,7 @@ #include "ash/services/device_sync/fake_cryptauth_v2_device_manager.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -73,4 +73,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/fake_cryptauth_v2_device_manager.h b/ash/services/device_sync/fake_cryptauth_v2_device_manager.h index 9f60c6ec..150a574e 100644 --- a/ash/services/device_sync/fake_cryptauth_v2_device_manager.h +++ b/ash/services/device_sync/fake_cryptauth_v2_device_manager.h
@@ -16,7 +16,7 @@ #include "base/time/time.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -87,6 +87,11 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash + +// TODO(https://crbug.com/1164001): remove when the migration is finished. +namespace chromeos::device_sync { +using ::ash::device_sync::FakeCryptAuthV2DeviceManager; +} #endif // ASH_SERVICES_DEVICE_SYNC_FAKE_CRYPTAUTH_V2_DEVICE_MANAGER_H_
diff --git a/ash/services/device_sync/fake_cryptauth_v2_enroller.cc b/ash/services/device_sync/fake_cryptauth_v2_enroller.cc index 6b366943..23790e0 100644 --- a/ash/services/device_sync/fake_cryptauth_v2_enroller.cc +++ b/ash/services/device_sync/fake_cryptauth_v2_enroller.cc
@@ -6,7 +6,7 @@ #include "ash/components/multidevice/logging/logging.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -31,4 +31,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/fake_cryptauth_v2_enroller.h b/ash/services/device_sync/fake_cryptauth_v2_enroller.h index ec0a9deb..4a5d6a0e 100644 --- a/ash/services/device_sync/fake_cryptauth_v2_enroller.h +++ b/ash/services/device_sync/fake_cryptauth_v2_enroller.h
@@ -12,7 +12,7 @@ #include "base/callback.h" #include "third_party/abseil-cpp/absl/types/optional.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -64,6 +64,6 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash #endif // ASH_SERVICES_DEVICE_SYNC_FAKE_CRYPTAUTH_V2_ENROLLER_H_
diff --git a/ash/services/device_sync/fake_device_sync_observer.h b/ash/services/device_sync/fake_device_sync_observer.h index 73aaaf1c..e3d5be2 100644 --- a/ash/services/device_sync/fake_device_sync_observer.h +++ b/ash/services/device_sync/fake_device_sync_observer.h
@@ -45,4 +45,9 @@ } // namespace chromeos +// TODO(https://crbug.com/1164001): remove when it moved to ash. +namespace ash::device_sync { +using ::chromeos::device_sync::FakeDeviceSyncObserver; +} + #endif // ASH_SERVICES_DEVICE_SYNC_FAKE_DEVICE_SYNC_OBSERVER_H_
diff --git a/ash/services/device_sync/fake_ecies_encryption.h b/ash/services/device_sync/fake_ecies_encryption.h index ec6e8970..6b22a9ca 100644 --- a/ash/services/device_sync/fake_ecies_encryption.h +++ b/ash/services/device_sync/fake_ecies_encryption.h
@@ -41,4 +41,11 @@ } // namespace chromeos +// TODO(https://crbug.com/1164001): remove when it moved to ash. +namespace ash::device_sync { +using ::chromeos::device_sync::DecryptFakeEncryptedString; +using ::chromeos::device_sync::GetPrivateKeyFromPublicKeyForTest; +using ::chromeos::device_sync::MakeFakeEncryptedString; +} // namespace ash::device_sync + #endif // ASH_SERVICES_DEVICE_SYNC_FAKE_ECIES_ENCRYPTION_H_
diff --git a/ash/services/device_sync/fake_software_feature_manager.h b/ash/services/device_sync/fake_software_feature_manager.h index 97240c94..164f7834 100644 --- a/ash/services/device_sync/fake_software_feature_manager.h +++ b/ash/services/device_sync/fake_software_feature_manager.h
@@ -153,4 +153,9 @@ } // namespace chromeos +// TODO(https://crbug.com/1164001): remove when it moved to ash. +namespace ash::device_sync { +using ::chromeos::device_sync::FakeSoftwareFeatureManager; +} + #endif // ASH_SERVICES_DEVICE_SYNC_FAKE_SOFTWARE_FEATURE_MANAGER_H_
diff --git a/ash/services/device_sync/fake_synced_bluetooth_address_tracker.h b/ash/services/device_sync/fake_synced_bluetooth_address_tracker.h index d556edaf..48d0559 100644 --- a/ash/services/device_sync/fake_synced_bluetooth_address_tracker.h +++ b/ash/services/device_sync/fake_synced_bluetooth_address_tracker.h
@@ -57,4 +57,10 @@ } // namespace chromeos +// TODO(https://crbug.com/1164001): remove when it moved to ash. +namespace ash::device_sync { +using ::chromeos::device_sync::FakeSyncedBluetoothAddressTracker; +using ::chromeos::device_sync::FakeSyncedBluetoothAddressTrackerFactory; +} // namespace ash::device_sync + #endif // ASH_SERVICES_DEVICE_SYNC_FAKE_SYNCED_BLUETOOTH_ADDRESS_TRACKER_H_
diff --git a/ash/services/device_sync/mock_cryptauth_client.cc b/ash/services/device_sync/mock_cryptauth_client.cc index ec7a1422..6638a432 100644 --- a/ash/services/device_sync/mock_cryptauth_client.cc +++ b/ash/services/device_sync/mock_cryptauth_client.cc
@@ -9,7 +9,7 @@ #include "base/callback.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -44,4 +44,4 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash
diff --git a/ash/services/device_sync/mock_cryptauth_client.h b/ash/services/device_sync/mock_cryptauth_client.h index bbfb4c7c..06ab8d4 100644 --- a/ash/services/device_sync/mock_cryptauth_client.h +++ b/ash/services/device_sync/mock_cryptauth_client.h
@@ -13,7 +13,7 @@ #include "base/observer_list.h" #include "testing/gmock/include/gmock/gmock.h" -namespace chromeos { +namespace ash { namespace device_sync { @@ -142,6 +142,12 @@ } // namespace device_sync -} // namespace chromeos +} // namespace ash + +// TODO(https://crbug.com/1164001): remove when the migration is finished. +namespace chromeos::device_sync { +using ::ash::device_sync::MockCryptAuthClient; +using ::ash::device_sync::MockCryptAuthClientFactory; +} // namespace chromeos::device_sync #endif // ASH_SERVICES_DEVICE_SYNC_MOCK_CRYPTAUTH_CLIENT_H_
diff --git a/ash/services/device_sync/mock_sync_scheduler.h b/ash/services/device_sync/mock_sync_scheduler.h index efd1177..43a37f9 100644 --- a/ash/services/device_sync/mock_sync_scheduler.h +++ b/ash/services/device_sync/mock_sync_scheduler.h
@@ -37,4 +37,9 @@ } // namespace chromeos +// TODO(https://crbug.com/1164001): remove when it moved to ash. +namespace ash::device_sync { +using ::chromeos::device_sync::MockSyncScheduler; +} + #endif // ASH_SERVICES_DEVICE_SYNC_MOCK_SYNC_SCHEDULER_H_
diff --git a/ash/services/device_sync/network_request_error.h b/ash/services/device_sync/network_request_error.h index 215569ba..d8c5b55 100644 --- a/ash/services/device_sync/network_request_error.h +++ b/ash/services/device_sync/network_request_error.h
@@ -42,4 +42,9 @@ } // namespace chromeos +// TODO(https://crbug.com/1164001): remove when it moved to ash. +namespace ash::device_sync { +using ::chromeos::device_sync::NetworkRequestError; +} + #endif // ASH_SERVICES_DEVICE_SYNC_NETWORK_REQUEST_ERROR_H_
diff --git a/ash/services/device_sync/pref_names.h b/ash/services/device_sync/pref_names.h index 720c8fe..90b7750 100644 --- a/ash/services/device_sync/pref_names.h +++ b/ash/services/device_sync/pref_names.h
@@ -49,4 +49,9 @@ } // namespace chromeos +// TODO(https://crbug.com/1164001): remove when it moved to ash. +namespace ash::device_sync { +namespace prefs = ::chromeos::device_sync::prefs; +} + #endif // ASH_SERVICES_DEVICE_SYNC_PREF_NAMES_H_
diff --git a/ash/services/device_sync/proto/device_classifier_util.h b/ash/services/device_sync/proto/device_classifier_util.h index edfa759..8698f689 100644 --- a/ash/services/device_sync/proto/device_classifier_util.h +++ b/ash/services/device_sync/proto/device_classifier_util.h
@@ -21,4 +21,9 @@ } // namespace chromeos +// TODO(https://crbug.com/1164001): remove when it moved to ash. +namespace ash::device_sync::device_classifier_util { +using ::chromeos::device_sync::device_classifier_util::GetDeviceClassifier; +} + #endif // ASH_SERVICES_DEVICE_SYNC_PROTO_DEVICE_CLASSIFIER_UTIL_H_
diff --git a/ash/services/device_sync/proto/enum_util.h b/ash/services/device_sync/proto/enum_util.h index 364d8a2c..c55905445 100644 --- a/ash/services/device_sync/proto/enum_util.h +++ b/ash/services/device_sync/proto/enum_util.h
@@ -60,4 +60,12 @@ } // namespace chromeos +// TODO(https://crbug.com/1164001): remove when it moved to ash. +namespace ash::device_sync { +using ::chromeos::device_sync::DeviceTypeEnumToString; +using ::chromeos::device_sync::DeviceTypeStringToEnum; +using ::chromeos::device_sync::SoftwareFeatureEnumToString; +using ::chromeos::device_sync::SoftwareFeatureStringToEnum; +} // namespace ash::device_sync + #endif // ASH_SERVICES_DEVICE_SYNC_PROTO_ENUM_UTIL_H_
diff --git a/ash/services/device_sync/remote_device_provider_impl.h b/ash/services/device_sync/remote_device_provider_impl.h index 6af380c..e3fe8af 100644 --- a/ash/services/device_sync/remote_device_provider_impl.h +++ b/ash/services/device_sync/remote_device_provider_impl.h
@@ -9,6 +9,8 @@ #include <string> #include "ash/services/device_sync/cryptauth_device_manager.h" +// TODO(https://crbug.com/1164001): move to forward declaration +#include "ash/services/device_sync/cryptauth_device_sync_result.h" #include "ash/services/device_sync/cryptauth_v2_device_manager.h" #include "ash/services/device_sync/remote_device_provider.h" #include "google_apis/gaia/core_account_id.h" @@ -17,7 +19,6 @@ namespace device_sync { -class CryptAuthDeviceSyncResult; class RemoteDeviceLoader; class RemoteDeviceV2Loader;
diff --git a/ash/services/device_sync/software_feature_manager.h b/ash/services/device_sync/software_feature_manager.h index 07707c4..90bc6659 100644 --- a/ash/services/device_sync/software_feature_manager.h +++ b/ash/services/device_sync/software_feature_manager.h
@@ -65,4 +65,9 @@ } // namespace chromeos +// TODO(https://crbug.com/1164001): remove when it moved to ash. +namespace ash::device_sync { +using ::chromeos::device_sync::SoftwareFeatureManager; +} + #endif // ASH_SERVICES_DEVICE_SYNC_SOFTWARE_FEATURE_MANAGER_H_
diff --git a/ash/services/device_sync/software_feature_manager_impl.h b/ash/services/device_sync/software_feature_manager_impl.h index f724801b..9f76823 100644 --- a/ash/services/device_sync/software_feature_manager_impl.h +++ b/ash/services/device_sync/software_feature_manager_impl.h
@@ -10,6 +10,10 @@ #include <vector> #include "ash/components/multidevice/software_feature.h" +// TODO(https://crbug.com/1164001): move to forward declaration +#include "ash/services/device_sync/cryptauth_client.h" +// TODO(https://crbug.com/1164001): move to forward declaration +#include "ash/services/device_sync/cryptauth_feature_status_setter.h" #include "ash/services/device_sync/feature_status_change.h" #include "ash/services/device_sync/network_request_error.h" #include "ash/services/device_sync/proto/cryptauth_api.pb.h" @@ -23,10 +27,6 @@ namespace device_sync { -class CryptAuthClient; -class CryptAuthClientFactory; -class CryptAuthFeatureStatusSetter; - // Concrete SoftwareFeatureManager implementation. To query and/or set // MultiDevice hosts, this class makes network requests to the CryptAuth // back-end. @@ -163,4 +163,9 @@ } // namespace chromeos +// TODO(https://crbug.com/1164001): remove when it moved to ash. +namespace ash::device_sync { +using ::chromeos::device_sync::SoftwareFeatureManagerImpl; +} + #endif // ASH_SERVICES_DEVICE_SYNC_SOFTWARE_FEATURE_MANAGER_IMPL_H_
diff --git a/ash/services/device_sync/stub_device_sync.cc b/ash/services/device_sync/stub_device_sync.cc index 1cde263..4745f3cc4 100644 --- a/ash/services/device_sync/stub_device_sync.cc +++ b/ash/services/device_sync/stub_device_sync.cc
@@ -193,14 +193,13 @@ absl::optional<multidevice::RemoteDevice> local_device_metadata_; }; -class StubDeviceSyncImplFactory - : public chromeos::device_sync::DeviceSyncImpl::Factory { +class StubDeviceSyncImplFactory : public DeviceSyncImpl::Factory { public: StubDeviceSyncImplFactory() = default; ~StubDeviceSyncImplFactory() override = default; - // chromeos::device_sync::DeviceSyncImpl::Factory: - std::unique_ptr<chromeos::device_sync::DeviceSyncBase> CreateInstance( + // ash::device_sync::DeviceSyncImpl::Factory: + std::unique_ptr<DeviceSyncBase> CreateInstance( signin::IdentityManager* identity_manager, gcm::GCMDriver* gcm_driver, PrefService* profile_prefs,
diff --git a/ash/services/device_sync/switches.h b/ash/services/device_sync/switches.h index 0349ac4..c37070540 100644 --- a/ash/services/device_sync/switches.h +++ b/ash/services/device_sync/switches.h
@@ -23,4 +23,11 @@ } // namespace chromeos +// TODO(https://crbug.com/1164001): remove when it moved to ash. +namespace ash::device_sync::switches { +using ::chromeos::device_sync::switches::kCryptAuthHTTPHost; +using ::chromeos::device_sync::switches::kCryptAuthV2DeviceSyncHTTPHost; +using ::chromeos::device_sync::switches::kCryptAuthV2EnrollmentHTTPHost; +} // namespace ash::device_sync::switches + #endif // ASH_SERVICES_DEVICE_SYNC_SWITCHES_H_
diff --git a/ash/services/device_sync/sync_scheduler.h b/ash/services/device_sync/sync_scheduler.h index 67fc312..dfb52a8 100644 --- a/ash/services/device_sync/sync_scheduler.h +++ b/ash/services/device_sync/sync_scheduler.h
@@ -101,4 +101,9 @@ } // namespace chromeos +// TODO(https://crbug.com/1164001): remove when it moved to ash. +namespace ash::device_sync { +using ::chromeos::device_sync::SyncScheduler; +} + #endif // ASH_SERVICES_DEVICE_SYNC_SYNC_SCHEDULER_H_
diff --git a/ash/services/device_sync/sync_scheduler_impl.h b/ash/services/device_sync/sync_scheduler_impl.h index fcd3fd37..ed2d5c5 100644 --- a/ash/services/device_sync/sync_scheduler_impl.h +++ b/ash/services/device_sync/sync_scheduler_impl.h
@@ -105,4 +105,9 @@ } // namespace chromeos +// TODO(https://crbug.com/1164001): remove when it moved to ash. +namespace ash { +using ::chromeos::device_sync::SyncSchedulerImpl; +} + #endif // ASH_SERVICES_DEVICE_SYNC_SYNC_SCHEDULER_IMPL_H_
diff --git a/ash/services/device_sync/synced_bluetooth_address_tracker.h b/ash/services/device_sync/synced_bluetooth_address_tracker.h index 27de2dd..398f65d 100644 --- a/ash/services/device_sync/synced_bluetooth_address_tracker.h +++ b/ash/services/device_sync/synced_bluetooth_address_tracker.h
@@ -42,4 +42,9 @@ } // namespace chromeos +// TODO(https://crbug.com/1164001): remove when it moved to ash. +namespace ash::device_sync { +using ::chromeos::device_sync::SyncedBluetoothAddressTracker; +} + #endif // ASH_SERVICES_DEVICE_SYNC_SYNCED_BLUETOOTH_ADDRESS_TRACKER_H_
diff --git a/ash/services/device_sync/synced_bluetooth_address_tracker_impl.h b/ash/services/device_sync/synced_bluetooth_address_tracker_impl.h index 194127c..abcc0906 100644 --- a/ash/services/device_sync/synced_bluetooth_address_tracker_impl.h +++ b/ash/services/device_sync/synced_bluetooth_address_tracker_impl.h
@@ -8,6 +8,8 @@ #include <memory> #include <vector> +// TODO(https://crbug.com/1164001): move to forward declaration +#include "ash/services/device_sync/cryptauth_scheduler.h" #include "ash/services/device_sync/synced_bluetooth_address_tracker.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" @@ -24,8 +26,6 @@ namespace device_sync { -class CryptAuthScheduler; - // SyncedBluetoothAddressTracker implementation which uses profile prefs to // store the last synced Bluetooth address. If the address changes, it triggers // a new DeviceSync attempt via CryptAuthScheduler.
diff --git a/ash/services/device_sync/value_string_encoding.h b/ash/services/device_sync/value_string_encoding.h index 894b2d2151..56f4ef7 100644 --- a/ash/services/device_sync/value_string_encoding.h +++ b/ash/services/device_sync/value_string_encoding.h
@@ -67,4 +67,9 @@ } // namespace chromeos +// TODO(https://crbug.com/1164001): remove when it moved to ash. +namespace ash::device_sync { +namespace util = ::chromeos::device_sync::util; +} + #endif // ASH_SERVICES_DEVICE_SYNC_VALUE_STRING_ENCODING_H_
diff --git a/ash/webui/eche_app_ui/system_info_provider_unittest.cc b/ash/webui/eche_app_ui/system_info_provider_unittest.cc index 366348d..1257bcc1 100644 --- a/ash/webui/eche_app_ui/system_info_provider_unittest.cc +++ b/ash/webui/eche_app_ui/system_info_provider_unittest.cc
@@ -59,6 +59,20 @@ debug_mode = debug_mode_opt.value(); } +class TaskRunner { + public: + TaskRunner() = default; + ~TaskRunner() = default; + + void WaitForResult() { run_loop_.Run(); } + + void Finish() { run_loop_.Quit(); } + + private: + base::test::SingleThreadTaskEnvironment task_environment_; + base::RunLoop run_loop_; +}; + class FakeTabletMode : public ash::TabletMode { public: FakeTabletMode() = default; @@ -98,6 +112,45 @@ bool in_tablet_mode = false; }; +class FakeObserver : public mojom::SystemInfoObserver { + public: + FakeObserver() = default; + ~FakeObserver() override = default; + + size_t num_backlight_state_calls() const { + return num_backlight_state_calls_; + } + size_t num_tablet_state_calls() const { return num_tablet_state_calls_; } + + // mojom::SystemInfoObserver: + void OnScreenBacklightStateChanged( + ash::ScreenBacklightState screen_state) override { + ++num_backlight_state_calls_; + if (task_runner_) { + task_runner_->Finish(); + } + } + + // mojom::SystemInfoObserver: + void OnReceivedTabletModeChanged(bool is_tablet_mode) override { + ++num_tablet_state_calls_; + if (task_runner_) { + task_runner_->Finish(); + } + } + + static void setTaskRunner(TaskRunner* task_runner) { + task_runner_ = task_runner; + } + + mojo::Receiver<mojom::SystemInfoObserver> receiver{this}; + + private: + size_t num_backlight_state_calls_ = 0; + size_t num_tablet_state_calls_ = 0; + static TaskRunner* task_runner_; +}; + class Callback { public: static void GetSystemInfoCallback(const std::string& system_info) { @@ -110,13 +163,12 @@ static std::string system_info_; }; +ash::eche_app::TaskRunner* ash::eche_app::FakeObserver::task_runner_ = nullptr; std::string ash::eche_app::Callback::system_info_ = ""; class SystemInfoProviderTest : public testing::Test { protected: - SystemInfoProviderTest() - : task_environment_(base::test::TaskEnvironment::MainThreadType::DEFAULT, - base::test::TaskEnvironment::TimeSource::MOCK_TIME) { + SystemInfoProviderTest() { ash::GetNetworkConfigService( remote_cros_network_config_.BindNewPipeAndPassReceiver()); } @@ -124,6 +176,7 @@ SystemInfoProviderTest& operator=(const SystemInfoProviderTest&) = delete; ~SystemInfoProviderTest() override = default; std::unique_ptr<FakeTabletMode> tablet_mode_controller_; + std::unique_ptr<FakeObserver> fake_observer_; // testing::Test: void SetUp() override { @@ -135,19 +188,35 @@ .SetBoardName(kFakeBoardName) .Build(), remote_cros_network_config_.get()); + fake_observer_ = std::make_unique<FakeObserver>(); + system_info_provider_->SetSystemInfoObserver( + fake_observer_->receiver.BindNewPipeAndPassRemote()); SetWifiConnectionStateList(); } + void TearDown() override { system_info_provider_.reset(); Callback::resetSystemInfo(); } + void GetSystemInfo() { system_info_provider_->GetSystemInfo( base::BindOnce(&Callback::GetSystemInfoCallback)); } + void SetWifiConnectionStateList() { system_info_provider_->OnWifiNetworkList(GetWifiNetworkStateList()); } + + void SetOnScreenBacklightStateChanged() { + system_info_provider_->OnScreenBacklightStateChanged( + ash::ScreenBacklightState::OFF); + } + + void OnTabletModeStarted() { system_info_provider_->OnTabletModeStarted(); } + + void OnTabletModeEnded() { system_info_provider_->OnTabletModeEnded(); } + std::vector<network_config::mojom::NetworkStatePropertiesPtr> GetWifiNetworkStateList() { std::vector<network_config::mojom::NetworkStatePropertiesPtr> result; @@ -159,9 +228,16 @@ return result; } - private: - base::test::TaskEnvironment task_environment_; + size_t GetNumTabletStateObserverCalls() const { + return fake_observer_->num_tablet_state_calls(); + } + size_t GetNumBacklightStateObserverCalls() const { + return fake_observer_->num_backlight_state_calls(); + } + TaskRunner task_runner_; + private: + // base::test::TaskEnvironment task_environment_; std::unique_ptr<SystemInfoProvider> system_info_provider_; mojo::Remote<chromeos::network_config::mojom::CrosNetworkConfig> remote_cros_network_config_; @@ -186,5 +262,29 @@ EXPECT_EQ(debug_mode, kFakeDebugMode); } +TEST_F(SystemInfoProviderTest, ObserverCalledWhenBacklightChanged) { + FakeObserver::setTaskRunner(&task_runner_); + SetOnScreenBacklightStateChanged(); + task_runner_.WaitForResult(); + + EXPECT_EQ(1u, GetNumBacklightStateObserverCalls()); +} + +TEST_F(SystemInfoProviderTest, ObserverCalledWhenTabletModeStarted) { + FakeObserver::setTaskRunner(&task_runner_); + OnTabletModeStarted(); + task_runner_.WaitForResult(); + + EXPECT_EQ(1u, GetNumTabletStateObserverCalls()); +} + +TEST_F(SystemInfoProviderTest, ObserverCalledWhenTabletModeEnded) { + FakeObserver::setTaskRunner(&task_runner_); + OnTabletModeEnded(); + task_runner_.WaitForResult(); + + EXPECT_EQ(1u, GetNumTabletStateObserverCalls()); +} + } // namespace eche_app } // namespace ash
diff --git a/base/BUILD.gn b/base/BUILD.gn index 4b4eb780..46d1d5c 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn
@@ -117,22 +117,6 @@ ] } -config("memory_tagging") { - if (current_cpu == "arm64" && is_clang && - (is_linux || is_chromeos || is_android || is_fuchsia)) { - # base/ has access to the MTE intrinsics because it needs to use them, - # but they're not backwards compatible. Use base::CPU::has_mte() - # beforehand to confirm or use indirect functions (ifuncs) to select - # an MTE-specific implementation at dynamic link-time. - cflags = [ - "-Xclang", - "-target-feature", - "-Xclang", - "+mte", - ] - } -} - config("base_implementation") { defines = [ "BASE_IMPLEMENTATION" ] configs = [ "//build/config/compiler:wexit_time_destructors" ] @@ -1418,7 +1402,6 @@ configs += [ ":base_implementation", - ":memory_tagging", "//build/config:precompiled_headers", "//build/config/compiler:wglobal_constructors", ] @@ -1502,10 +1485,14 @@ sources += [ "allocator/allocator_shim.cc", "allocator/allocator_shim.h", - "allocator/allocator_shim_default_dispatch_to_partition_alloc.cc", - "allocator/allocator_shim_default_dispatch_to_partition_alloc.h", "allocator/allocator_shim_internals.h", ] + if (use_partition_alloc) { + sources += [ + "allocator/allocator_shim_default_dispatch_to_partition_alloc.cc", + "allocator/allocator_shim_default_dispatch_to_partition_alloc.h", + ] + } if (is_android) { sources += [ "allocator/allocator_shim_override_cpp_symbols.h", @@ -2002,127 +1989,14 @@ "allocator/partition_alloc_features.h", "allocator/partition_alloc_support.cc", "allocator/partition_alloc_support.h", - "allocator/partition_allocator/address_pool_manager.cc", - "allocator/partition_allocator/address_pool_manager.h", - "allocator/partition_allocator/address_pool_manager_bitmap.cc", - "allocator/partition_allocator/address_pool_manager_bitmap.h", - "allocator/partition_allocator/address_pool_manager_types.h", - "allocator/partition_allocator/address_space_randomization.cc", - "allocator/partition_allocator/address_space_randomization.h", - "allocator/partition_allocator/address_space_stats.h", - "allocator/partition_allocator/allocation_guard.cc", - "allocator/partition_allocator/allocation_guard.h", - "allocator/partition_allocator/dangling_raw_ptr_checks.cc", - "allocator/partition_allocator/dangling_raw_ptr_checks.h", - "allocator/partition_allocator/extended_api.cc", - "allocator/partition_allocator/extended_api.h", - "allocator/partition_allocator/memory_reclaimer.cc", - "allocator/partition_allocator/memory_reclaimer.h", - "allocator/partition_allocator/oom.cc", - "allocator/partition_allocator/oom.h", - "allocator/partition_allocator/oom_callback.cc", - "allocator/partition_allocator/oom_callback.h", - "allocator/partition_allocator/page_allocator.cc", - "allocator/partition_allocator/page_allocator.h", - "allocator/partition_allocator/page_allocator_constants.h", - "allocator/partition_allocator/page_allocator_internal.h", - "allocator/partition_allocator/partition_address_space.cc", - "allocator/partition_allocator/partition_address_space.h", - "allocator/partition_allocator/partition_alloc-inl.h", - "allocator/partition_allocator/partition_alloc.cc", - "allocator/partition_allocator/partition_alloc.h", - "allocator/partition_allocator/partition_alloc_check.h", - "allocator/partition_allocator/partition_alloc_config.h", - "allocator/partition_allocator/partition_alloc_constants.h", - "allocator/partition_allocator/partition_alloc_forward.h", - "allocator/partition_allocator/partition_alloc_hooks.cc", - "allocator/partition_allocator/partition_alloc_hooks.h", - "allocator/partition_allocator/partition_alloc_notreached.h", - "allocator/partition_allocator/partition_bucket.cc", - "allocator/partition_allocator/partition_bucket.h", - "allocator/partition_allocator/partition_bucket_lookup.h", - "allocator/partition_allocator/partition_cookie.h", - "allocator/partition_allocator/partition_direct_map_extent.h", - "allocator/partition_allocator/partition_freelist_entry.h", - "allocator/partition_allocator/partition_lock.h", - "allocator/partition_allocator/partition_oom.cc", - "allocator/partition_allocator/partition_oom.h", - "allocator/partition_allocator/partition_page.cc", - "allocator/partition_allocator/partition_page.h", - "allocator/partition_allocator/partition_ref_count.h", - "allocator/partition_allocator/partition_root.cc", - "allocator/partition_allocator/partition_root.h", - "allocator/partition_allocator/partition_stats.cc", - "allocator/partition_allocator/partition_stats.h", - "allocator/partition_allocator/partition_tag.h", - "allocator/partition_allocator/partition_tag_bitmap.h", - "allocator/partition_allocator/partition_tls.h", - "allocator/partition_allocator/random.cc", - "allocator/partition_allocator/random.h", - "allocator/partition_allocator/reservation_offset_table.cc", - "allocator/partition_allocator/reservation_offset_table.h", - "allocator/partition_allocator/spinning_mutex.cc", - "allocator/partition_allocator/spinning_mutex.h", - "allocator/partition_allocator/starscan/logging.h", - "allocator/partition_allocator/starscan/metadata_allocator.cc", - "allocator/partition_allocator/starscan/metadata_allocator.h", - "allocator/partition_allocator/starscan/pcscan.cc", - "allocator/partition_allocator/starscan/pcscan.h", - "allocator/partition_allocator/starscan/pcscan_internal.cc", - "allocator/partition_allocator/starscan/pcscan_internal.h", - "allocator/partition_allocator/starscan/pcscan_scheduling.cc", - "allocator/partition_allocator/starscan/pcscan_scheduling.h", - "allocator/partition_allocator/starscan/raceful_worklist.h", - "allocator/partition_allocator/starscan/scan_loop.h", - "allocator/partition_allocator/starscan/snapshot.cc", - "allocator/partition_allocator/starscan/snapshot.h", - "allocator/partition_allocator/starscan/stack/stack.cc", - "allocator/partition_allocator/starscan/stack/stack.h", - "allocator/partition_allocator/starscan/starscan_fwd.h", - "allocator/partition_allocator/starscan/state_bitmap.h", - "allocator/partition_allocator/starscan/stats_collector.cc", - "allocator/partition_allocator/starscan/stats_collector.h", - "allocator/partition_allocator/starscan/stats_reporter.h", - "allocator/partition_allocator/starscan/write_protector.cc", - "allocator/partition_allocator/starscan/write_protector.h", - "allocator/partition_allocator/tagging.cc", - "allocator/partition_allocator/tagging.h", - "allocator/partition_allocator/thread_cache.cc", - "allocator/partition_allocator/thread_cache.h", - "allocator/partition_allocator/yield_processor.h", ] - if (is_win) { - sources += [ - "allocator/partition_allocator/page_allocator_internals_win.h", - "allocator/partition_allocator/partition_tls_win.cc", - ] - } else if (is_posix) { - sources += [ - "allocator/partition_allocator/page_allocator_internals_posix.cc", - "allocator/partition_allocator/page_allocator_internals_posix.h", - ] - } else if (is_fuchsia) { - sources += [ - "allocator/partition_allocator/page_allocator_internals_fuchsia.h", - ] - } - - if (current_cpu == "x64") { - defines += [ "PA_PCSCAN_STACK_SUPPORTED" ] - sources += [ "allocator/partition_allocator/starscan/stack/asm/x64/push_registers_asm.cc" ] - } else if (current_cpu == "x86") { - defines += [ "PA_PCSCAN_STACK_SUPPORTED" ] - sources += [ "allocator/partition_allocator/starscan/stack/asm/x86/push_registers_asm.cc" ] - } else if (current_cpu == "arm") { - defines += [ "PA_PCSCAN_STACK_SUPPORTED" ] - sources += [ "allocator/partition_allocator/starscan/stack/asm/arm/push_registers_asm.cc" ] - } else if (current_cpu == "arm64") { - defines += [ "PA_PCSCAN_STACK_SUPPORTED" ] - sources += [ "allocator/partition_allocator/starscan/stack/asm/arm64/push_registers_asm.cc" ] - } else { - # To support a trampoline for another arch, please refer to v8/src/heap/base. - } } + + # Need this to pass gn check, because gn check doesn't see + # BUILDFLAG(USE_PARTITION_ALLOC). A linker will remove all + # partition_alloc code if use_partition_alloc = false because no code uses + # partition_alloc. + public_deps += [ "allocator/partition_allocator:partition_alloc" ] } # Windows. @@ -3934,8 +3808,6 @@ ] deps += [ "//build/rust:cxx_cppdeps" ] } - - configs += [ ":memory_tagging" ] } action("build_date") {
diff --git a/base/allocator/partition_alloc_support.cc b/base/allocator/partition_alloc_support.cc index 2e71c4b1..068e77a 100644 --- a/base/allocator/partition_alloc_support.cc +++ b/base/allocator/partition_alloc_support.cc
@@ -148,7 +148,7 @@ void RunThreadCachePeriodicPurge() { TRACE_EVENT0("memory", "PeriodicPurge"); - auto& instance = internal::ThreadCacheRegistry::Instance(); + auto& instance = ::partition_alloc::ThreadCacheRegistry::Instance(); instance.RunPeriodicPurge(); TimeDelta delay = Microseconds(instance.GetPeriodicPurgeNextIntervalInMicroseconds()); @@ -175,7 +175,7 @@ } // namespace void StartThreadCachePeriodicPurge() { - auto& instance = internal::ThreadCacheRegistry::Instance(); + auto& instance = ::partition_alloc::ThreadCacheRegistry::Instance(); TimeDelta delay = Microseconds(instance.GetPeriodicPurgeNextIntervalInMicroseconds()); ThreadTaskRunnerHandle::Get()->PostDelayedTask(
diff --git a/base/allocator/partition_allocator/BUILD.gn b/base/allocator/partition_allocator/BUILD.gn new file mode 100644 index 0000000..4dc1d884 --- /dev/null +++ b/base/allocator/partition_allocator/BUILD.gn
@@ -0,0 +1,204 @@ +# Copyright (c) 2022 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//base/allocator/allocator.gni") + +# Add partition_alloc.gni and import it for partition_alloc configs. + +config("partition_alloc_implementation") { + # After introducing partition_alloc_export, replace BASE_IMPLEMENTATION with + # PARTITION_ALLOC_IMPLEMENTATION. + defines = [ "BASE_IMPLEMENTATION" ] +} + +config("memory_tagging") { + if (current_cpu == "arm64" && is_clang && + (is_linux || is_chromeos || is_android || is_fuchsia)) { + # base/ has access to the MTE intrinsics because it needs to use them, + # but they're not backwards compatible. Use base::CPU::has_mte() + # beforehand to confirm or use indirect functions (ifuncs) to select + # an MTE-specific implementation at dynamic link-time. + cflags = [ + "-Xclang", + "-target-feature", + "-Xclang", + "+mte", + ] + } +} + +if (is_fuchsia) { + config("fuchsia_sync_lib") { + libs = [ + "sync", # Used by spinning_mutex.h. + ] + } +} + +# TODO(crbug.com/1151236): Add component("base") for partition_alloc +# base, and make partition_alloc standalone library depend on it. + +# TODO(crbug.com/1151236): Add component("partition_alloc") to build +# partition_alloc as a standalone_library. +source_set("partition_alloc") { + sources = [ + "address_pool_manager.cc", + "address_pool_manager.h", + "address_pool_manager_bitmap.cc", + "address_pool_manager_bitmap.h", + "address_pool_manager_types.h", + "address_space_randomization.cc", + "address_space_randomization.h", + "address_space_stats.h", + "allocation_guard.cc", + "allocation_guard.h", + "dangling_raw_ptr_checks.cc", + "dangling_raw_ptr_checks.h", + "extended_api.cc", + "extended_api.h", + "memory_reclaimer.cc", + "memory_reclaimer.h", + "oom.cc", + "oom.h", + "oom_callback.cc", + "oom_callback.h", + "page_allocator.cc", + "page_allocator.h", + "page_allocator_constants.h", + "page_allocator_internal.h", + "partition_address_space.cc", + "partition_address_space.h", + "partition_alloc-inl.h", + "partition_alloc.cc", + "partition_alloc.h", + "partition_alloc_check.h", + "partition_alloc_config.h", + "partition_alloc_constants.h", + "partition_alloc_forward.h", + "partition_alloc_hooks.cc", + "partition_alloc_hooks.h", + "partition_alloc_notreached.h", + "partition_bucket.cc", + "partition_bucket.h", + "partition_bucket_lookup.h", + "partition_cookie.h", + "partition_direct_map_extent.h", + "partition_freelist_entry.h", + "partition_lock.h", + "partition_oom.cc", + "partition_oom.h", + "partition_page.cc", + "partition_page.h", + "partition_ref_count.h", + "partition_root.cc", + "partition_root.h", + "partition_stats.cc", + "partition_stats.h", + "partition_tag.h", + "partition_tag_bitmap.h", + "partition_tls.h", + "random.cc", + "random.h", + "reservation_offset_table.cc", + "reservation_offset_table.h", + "spinning_mutex.cc", + "spinning_mutex.h", + "starscan/logging.h", + "starscan/metadata_allocator.cc", + "starscan/metadata_allocator.h", + "starscan/pcscan.cc", + "starscan/pcscan.h", + "starscan/pcscan_internal.cc", + "starscan/pcscan_internal.h", + "starscan/pcscan_scheduling.cc", + "starscan/pcscan_scheduling.h", + "starscan/raceful_worklist.h", + "starscan/scan_loop.h", + "starscan/snapshot.cc", + "starscan/snapshot.h", + "starscan/stack/stack.cc", + "starscan/stack/stack.h", + "starscan/starscan_fwd.h", + "starscan/state_bitmap.h", + "starscan/stats_collector.cc", + "starscan/stats_collector.h", + "starscan/stats_reporter.h", + "starscan/write_protector.cc", + "starscan/write_protector.h", + "tagging.cc", + "tagging.h", + "thread_cache.cc", + "thread_cache.h", + "yield_processor.h", + ] + defines = [] + if (is_win) { + sources += [ + "page_allocator_internals_win.h", + "partition_tls_win.cc", + ] + } else if (is_posix) { + sources += [ + "page_allocator_internals_posix.cc", + "page_allocator_internals_posix.h", + ] + } else if (is_fuchsia) { + sources += [ "page_allocator_internals_fuchsia.h" ] + } + if (current_cpu == "x64") { + defines += [ "PA_PCSCAN_STACK_SUPPORTED" ] + sources += [ "starscan/stack/asm/x64/push_registers_asm.cc" ] + } else if (current_cpu == "x86") { + defines += [ "PA_PCSCAN_STACK_SUPPORTED" ] + sources += [ "starscan/stack/asm/x86/push_registers_asm.cc" ] + } else if (current_cpu == "arm") { + defines += [ "PA_PCSCAN_STACK_SUPPORTED" ] + sources += [ "starscan/stack/asm/arm/push_registers_asm.cc" ] + } else if (current_cpu == "arm64") { + defines += [ "PA_PCSCAN_STACK_SUPPORTED" ] + sources += [ "starscan/stack/asm/arm64/push_registers_asm.cc" ] + } else { + # To support a trampoline for another arch, please refer to v8/src/heap/base. + } + public_deps = [ + "//base:debugging_buildflags", + "//base:synchronization_buildflags", + "//base/allocator:buildflags", + "//build:branding_buildflags", + "//build:chromecast_buildflags", + "//build:chromeos_buildflags", + "//build/config/compiler:compiler_buildflags", + ] + deps = [] + configs += [ + ":partition_alloc_implementation", + ":memory_tagging", + ] + public_configs = [] + if (is_android) { + # tagging.cc requires __arm_mte_set_* functions. + deps += [ "//third_party/android_ndk:cpu_features" ] + } + if (is_fuchsia) { + public_deps += [ + "//third_party/fuchsia-sdk/sdk/pkg/fit", + "//third_party/fuchsia-sdk/sdk/pkg/sync", + "//third_party/fuchsia-sdk/sdk/pkg/zx", + ] + + # Needed for users of spinning_mutex.h, which for performance reasons, + # contains inlined calls to `libsync` inside the header file. + # It appends an entry to the "libs" section of the dependent target. + public_configs += [ ":fuchsia_sync_lib" ] + } + + frameworks = [] + if (is_mac) { + # SecTaskGetCodeSignStatus needs: + frameworks += [ "Security.framework" ] + } +} +# TODO(crbug.com/1151236): After making partition_alloc a standalone library, +# move test code here. i.e. test("partition_alloc_tests") { ... } and +# test("partition_alloc_perftests").
diff --git a/base/allocator/partition_allocator/allocation_guard.h b/base/allocator/partition_allocator/allocation_guard.h index c05f5974..ebbe83bf 100644 --- a/base/allocator/partition_allocator/allocation_guard.h +++ b/base/allocator/partition_allocator/allocation_guard.h
@@ -6,6 +6,7 @@ #define BASE_ALLOCATOR_PARTITION_ALLOCATOR_ALLOCATION_GUARD_H_ #include "base/allocator/partition_allocator/partition_alloc_config.h" +#include "base/base_export.h" #include "build/build_config.h" namespace partition_alloc { @@ -13,14 +14,14 @@ #if defined(PA_HAS_ALLOCATION_GUARD) // Disallow allocations in the scope. Does not nest. -class ScopedDisallowAllocations { +class BASE_EXPORT ScopedDisallowAllocations { public: ScopedDisallowAllocations(); ~ScopedDisallowAllocations(); }; // Disallow allocations in the scope. Does not nest. -class ScopedAllowAllocations { +class BASE_EXPORT ScopedAllowAllocations { public: ScopedAllowAllocations(); ~ScopedAllowAllocations();
diff --git a/base/allocator/partition_allocator/memory_reclaimer.cc b/base/allocator/partition_allocator/memory_reclaimer.cc index 60a33e1..d871cee 100644 --- a/base/allocator/partition_allocator/memory_reclaimer.cc +++ b/base/allocator/partition_allocator/memory_reclaimer.cc
@@ -81,7 +81,7 @@ // as there is periodic purge which makes sure that it doesn't take too much // space. if (flags & PurgeFlags::kAggressiveReclaim) - base::internal::ThreadCacheRegistry::Instance().PurgeAll(); + ThreadCacheRegistry::Instance().PurgeAll(); #endif for (auto* partition : partitions_)
diff --git a/base/allocator/partition_allocator/memory_reclaimer_unittest.cc b/base/allocator/partition_allocator/memory_reclaimer_unittest.cc index efe27eab..f9cf944 100644 --- a/base/allocator/partition_allocator/memory_reclaimer_unittest.cc +++ b/base/allocator/partition_allocator/memory_reclaimer_unittest.cc
@@ -118,12 +118,12 @@ base::internal::PartitionAllocMalloc::Allocator() ->EnableThreadCacheIfSupported(); - for (size_t i = 0; i < internal::ThreadCache::kDefaultSizeThreshold; i++) { + for (size_t i = 0; i < ThreadCache::kDefaultSizeThreshold; i++) { void* data = malloc(i); FreeForTest(data); } - auto* tcache = internal::ThreadCache::Get(); + auto* tcache = ThreadCache::Get(); ASSERT_TRUE(tcache); size_t cached_size = tcache->CachedMemory();
diff --git a/base/allocator/partition_allocator/partition_alloc_check.h b/base/allocator/partition_allocator/partition_alloc_check.h index a4aef54..5cffaa4c 100644 --- a/base/allocator/partition_allocator/partition_alloc_check.h +++ b/base/allocator/partition_allocator/partition_alloc_check.h
@@ -12,6 +12,7 @@ #include "base/check.h" #include "base/debug/alias.h" #include "base/immediate_crash.h" +#include "build/build_config.h" #define PA_STRINGIFY_IMPL(s) #s #define PA_STRINGIFY(s) PA_STRINGIFY_IMPL(s) @@ -96,10 +97,19 @@ #endif +// alignas(16) DebugKv causes breakpad_unittests and sandbox_linux_unittests +// failures on android-marshmallow-x86-rel because of SIGSEGV. +#if BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_X86_FAMILY) && \ + defined(ARCH_CPU_32_BITS) +#define DEBUGKV_ALIGN alignas(8) +#else +#define DEBUGKV_ALIGN alignas(16) +#endif + namespace partition_alloc::internal { // Used for PA_DEBUG_DATA_ON_STACK, below. -struct alignas(16) DebugKv { +struct DEBUGKV_ALIGN DebugKv { // 16 bytes object aligned on 16 bytes, to make it easier to see in crash // reports. char k[8] = {}; // Not necessarily 0-terminated.
diff --git a/base/allocator/partition_allocator/partition_alloc_perftest.cc b/base/allocator/partition_allocator/partition_alloc_perftest.cc index 705e16e..ec8eb9c 100644 --- a/base/allocator/partition_allocator/partition_alloc_perftest.cc +++ b/base/allocator/partition_allocator/partition_alloc_perftest.cc
@@ -28,7 +28,8 @@ #define MEMORY_CONSTRAINED #endif -namespace base { +namespace partition_alloc::internal { + namespace { // Change kTimeLimit to something higher if you need more time to capture a @@ -118,7 +119,7 @@ PartitionOptions::UseConfigurablePool::kNo, }); } - internal::ThreadCacheRegistry::Instance().PurgeAll(); + ThreadCacheRegistry::Instance().PurgeAll(); if (!use_alternate_bucket_dist) g_partition_root->SwitchToDenserBucketDistribution(); } @@ -131,22 +132,22 @@ void Free(void* data) override { ThreadSafePartitionRoot::FreeNoHooks(data); } }; -class TestLoopThread : public PlatformThread::Delegate { +class TestLoopThread : public base::PlatformThread::Delegate { public: - explicit TestLoopThread(OnceCallback<float()> test_fn) + explicit TestLoopThread(base::OnceCallback<float()> test_fn) : test_fn_(std::move(test_fn)) { - PA_CHECK(PlatformThread::Create(0, this, &thread_handle_)); + PA_CHECK(base::PlatformThread::Create(0, this, &thread_handle_)); } float Run() { - PlatformThread::Join(thread_handle_); + base::PlatformThread::Join(thread_handle_); return laps_per_second_; } void ThreadMain() override { laps_per_second_ = std::move(test_fn_).Run(); } - OnceCallback<float()> test_fn_; - PlatformThreadHandle thread_handle_; + base::OnceCallback<float()> test_fn_; + base::PlatformThreadHandle thread_handle_; std::atomic<float> laps_per_second_; }; @@ -181,7 +182,7 @@ reinterpret_cast<MemoryAllocationPerfNode*>(allocator->Alloc(kAllocSize)); size_t allocated_memory = kAllocSize; - LapTimer timer(kWarmupRuns, kTimeLimit, kTimeCheckInterval); + base::LapTimer timer(kWarmupRuns, kTimeLimit, kTimeCheckInterval); MemoryAllocationPerfNode* cur = first; do { auto* next = reinterpret_cast<MemoryAllocationPerfNode*>( @@ -214,7 +215,7 @@ // Allocate an initial element to make sure the bucket stays set up. void* elem = allocator->Alloc(kAllocSize); - LapTimer timer(kWarmupRuns, kTimeLimit, kTimeCheckInterval); + base::LapTimer timer(kWarmupRuns, kTimeLimit, kTimeCheckInterval); do { void* cur = allocator->Alloc(kAllocSize); CHECK_NE(cur, nullptr); @@ -233,7 +234,7 @@ MemoryAllocationPerfNode* cur = first; size_t allocated_memory = kAllocSize; - LapTimer timer(kWarmupRuns, kTimeLimit, kTimeCheckInterval); + base::LapTimer timer(kWarmupRuns, kTimeLimit, kTimeCheckInterval); do { for (int i = 0; i < kMultiBucketRounds; i++) { size_t size = kMultiBucketMinimumSize + (i * kMultiBucketIncrement); @@ -275,7 +276,7 @@ elems.push_back(cur); } - LapTimer timer(kWarmupRuns, kTimeLimit, kTimeCheckInterval); + base::LapTimer timer(kWarmupRuns, kTimeLimit, kTimeCheckInterval); do { for (int i = 0; i < kMultiBucketRounds; i++) { void* cur = allocator->Alloc(kMultiBucketMinimumSize + @@ -296,7 +297,7 @@ float DirectMapped(Allocator* allocator) { constexpr size_t kSize = 2 * 1000 * 1000; - LapTimer timer(kWarmupRuns, kTimeLimit, kTimeCheckInterval); + base::LapTimer timer(kWarmupRuns, kTimeLimit, kTimeCheckInterval); do { void* cur = allocator->Alloc(kSize); CHECK_NE(cur, nullptr); @@ -340,13 +341,13 @@ std::unique_ptr<TestLoopThread> noisy_neighbor_thread = nullptr; if (noisy_neighbor_fn) { noisy_neighbor_thread = std::make_unique<TestLoopThread>( - BindOnce(noisy_neighbor_fn, Unretained(alloc.get()))); + base::BindOnce(noisy_neighbor_fn, base::Unretained(alloc.get()))); } std::vector<std::unique_ptr<TestLoopThread>> threads; for (int i = 0; i < thread_count; ++i) { threads.push_back(std::make_unique<TestLoopThread>( - BindOnce(test_fn, Unretained(alloc.get())))); + base::BindOnce(test_fn, base::Unretained(alloc.get())))); } uint64_t total_laps_per_second = 0; @@ -452,4 +453,4 @@ } // namespace -} // namespace base +} // namespace partition_alloc::internal
diff --git a/base/allocator/partition_allocator/partition_root.h b/base/allocator/partition_allocator/partition_root.h index 4779db8..30f1943 100644 --- a/base/allocator/partition_allocator/partition_root.h +++ b/base/allocator/partition_allocator/partition_root.h
@@ -1949,6 +1949,7 @@ // the migration to the new namespaces gets done. using ::base::PartitionOptions; using ::base::PurgeFlags; +using ::base::ThreadSafePartitionRoot; namespace internal {
diff --git a/base/allocator/partition_allocator/thread_cache.cc b/base/allocator/partition_allocator/thread_cache.cc index 0761a810..9c51065 100644 --- a/base/allocator/partition_allocator/thread_cache.cc +++ b/base/allocator/partition_allocator/thread_cache.cc
@@ -5,6 +5,7 @@ #include "base/allocator/partition_allocator/thread_cache.h" #include <sys/types.h> + #include <algorithm> #include <atomic> #include <cstdint> @@ -20,24 +21,24 @@ #include "base/dcheck_is_on.h" #include "build/build_config.h" -namespace base::internal { +namespace partition_alloc { + namespace { ThreadCacheRegistry g_instance; } // namespace -} // namespace base::internal -namespace partition_alloc::internal::tools { +namespace internal { + +namespace tools { uintptr_t kThreadCacheNeedleArray[kThreadCacheNeedleArraySize] = { - kNeedle1, reinterpret_cast<uintptr_t>(&::base::internal::g_instance), + kNeedle1, reinterpret_cast<uintptr_t>(&g_instance), #if BUILDFLAG(RECORD_ALLOC_INFO) - reinterpret_cast<uintptr_t>(&partition_alloc::internal::g_allocs), + reinterpret_cast<uintptr_t>(&g_allocs), #else 0, #endif kNeedle2}; -} // namespace partition_alloc::internal::tools - -namespace base::internal { +} // namespace tools BASE_EXPORT PartitionTlsKey g_thread_cache_key; #if defined(PA_THREAD_CACHE_FAST_TLS) @@ -45,6 +46,8 @@ thread_local ThreadCache* g_thread_cache; #endif +} // namespace internal + namespace { // Since |g_thread_cache_key| is shared, make sure that no more than one // PartitionRoot can use it. @@ -74,7 +77,7 @@ // Start with the normal size, not the maximum one. uint16_t ThreadCache::largest_active_bucket_index_ = - BucketIndexLookup::GetIndex(ThreadCache::kDefaultSizeThreshold); + internal::BucketIndexLookup::GetIndex(ThreadCache::kDefaultSizeThreshold); // static ThreadCacheRegistry& ThreadCacheRegistry::Instance() { @@ -82,7 +85,7 @@ } void ThreadCacheRegistry::RegisterThreadCache(ThreadCache* cache) { - PartitionAutoLock scoped_locker(GetLock()); + internal::ScopedGuard scoped_locker(GetLock()); cache->next_ = nullptr; cache->prev_ = nullptr; @@ -94,7 +97,7 @@ } void ThreadCacheRegistry::UnregisterThreadCache(ThreadCache* cache) { - PartitionAutoLock scoped_locker(GetLock()); + internal::ScopedGuard scoped_locker(GetLock()); if (cache->prev_) cache->prev_->next_ = cache->next_; if (cache->next_) @@ -108,7 +111,7 @@ ThreadCache::EnsureThreadSpecificDataInitialized(); memset(reinterpret_cast<void*>(stats), 0, sizeof(ThreadCacheStats)); - PartitionAutoLock scoped_locker(GetLock()); + internal::ScopedGuard scoped_locker(GetLock()); if (my_thread_only) { auto* tcache = ThreadCache::Get(); if (!ThreadCache::IsValid(tcache)) @@ -146,7 +149,7 @@ current_thread_tcache->Purge(); { - PartitionAutoLock scoped_locker(GetLock()); + internal::ScopedGuard scoped_locker(GetLock()); ThreadCache* tcache = list_head_; while (tcache) { PA_DCHECK(ThreadCache::IsValid(tcache)); @@ -162,7 +165,7 @@ } void ThreadCacheRegistry::ForcePurgeAllThreadAfterForkUnsafe() { - PartitionAutoLock scoped_locker(GetLock()); + internal::ScopedGuard scoped_locker(GetLock()); ThreadCache* tcache = list_head_; while (tcache) { #if DCHECK_IS_ON() @@ -201,7 +204,7 @@ // - Set the global limits, which will affect newly created threads. // - Enumerate all thread caches and set the limit to the global one. { - PartitionAutoLock scoped_locker(GetLock()); + internal::ScopedGuard scoped_locker(GetLock()); ThreadCache* tcache = list_head_; // If this is called before *any* thread cache has serviced *any* @@ -241,7 +244,7 @@ // which is fine. size_t cached_memory_approx = 0; { - PartitionAutoLock scoped_locker(GetLock()); + internal::ScopedGuard scoped_locker(GetLock()); ThreadCache* tcache = list_head_; // Can run when there is no thread cache, in which case there is nothing to // do, and the task should not be rescheduled. This would typically indicate @@ -293,11 +296,12 @@ void ThreadCache::EnsureThreadSpecificDataInitialized() { // Using the registry lock to protect from concurrent initialization without // adding a special-pupose lock. - PartitionAutoLock scoped_locker(ThreadCacheRegistry::Instance().GetLock()); + internal::ScopedGuard scoped_locker( + ThreadCacheRegistry::Instance().GetLock()); if (g_thread_cache_key_created) return; - bool ok = PartitionTlsCreate(&g_thread_cache_key, Delete); + bool ok = internal::PartitionTlsCreate(&internal::g_thread_cache_key, Delete); PA_CHECK(ok); g_thread_cache_key_created = true; } @@ -319,7 +323,7 @@ } else { #if BUILDFLAG(IS_WIN) // OnDllProcessDetach accesses g_thread_cache_root which is nullptr now. - PartitionTlsSetOnDllProcessDetach(nullptr); + internal::PartitionTlsSetOnDllProcessDetach(nullptr); #endif } } @@ -327,7 +331,7 @@ // static void ThreadCache::RemoveTombstoneForTesting() { PA_CHECK(IsTombstone(Get())); - PartitionTlsSet(g_thread_cache_key, nullptr); + internal::PartitionTlsSet(internal::g_thread_cache_key, nullptr); } // static @@ -352,7 +356,7 @@ } #if BUILDFLAG(IS_WIN) - PartitionTlsSetOnDllProcessDetach(OnDllProcessDetach); + internal::PartitionTlsSetOnDllProcessDetach(OnDllProcessDetach); #endif SetGlobalLimits(root, kDefaultMultiplier); @@ -413,8 +417,8 @@ PA_CHECK(root); // See comment in thread_cache.h, this is used to make sure // kThreadCacheNeedleArray is kept in the final binary. - PA_CHECK(partition_alloc::internal::tools::kThreadCacheNeedleArray[0] == - partition_alloc::internal::tools::kNeedle1); + PA_CHECK(internal::tools::kThreadCacheNeedleArray[0] == + internal::tools::kNeedle1); // Placement new and RawAlloc() are used, as otherwise when this partition is // the malloc() implementation, the memory allocated for the new thread cache @@ -429,13 +433,13 @@ auto* bucket = root->buckets + PartitionRoot<internal::ThreadSafe>::SizeToBucketIndex( raw_size, root->with_denser_bucket_distribution); - uintptr_t buffer = - root->RawAlloc(bucket, AllocFlags::kZeroFill, raw_size, - PartitionPageSize(), &usable_size, &already_zeroed); + uintptr_t buffer = root->RawAlloc(bucket, AllocFlags::kZeroFill, raw_size, + internal::PartitionPageSize(), &usable_size, + &already_zeroed); ThreadCache* tcache = new (reinterpret_cast<void*>(buffer)) ThreadCache(root); // This may allocate. - PartitionTlsSet(g_thread_cache_key, tcache); + internal::PartitionTlsSet(internal::g_thread_cache_key, tcache); #if defined(PA_THREAD_CACHE_FAST_TLS) // |thread_local| variables with destructors cause issues on some platforms. // Since we need a destructor (to empty the thread cache), we cannot use it @@ -446,7 +450,7 @@ // // To still get good performance, use |thread_local| to store a raw pointer, // and rely on the platform TLS to call the destructor. - g_thread_cache = tcache; + internal::g_thread_cache = tcache; #endif // defined(PA_THREAD_CACHE_FAST_TLS) return tcache; @@ -455,7 +459,7 @@ ThreadCache::ThreadCache(PartitionRoot<>* root) : should_purge_(false), root_(root), - thread_id_(PlatformThread::CurrentId()), + thread_id_(base::PlatformThread::CurrentId()), next_(nullptr), prev_(nullptr) { ThreadCacheRegistry::Instance().RegisterThreadCache(this); @@ -492,9 +496,9 @@ return; #if defined(PA_THREAD_CACHE_FAST_TLS) - g_thread_cache = nullptr; + internal::g_thread_cache = nullptr; #else - PartitionTlsSet(g_thread_cache_key, nullptr); + internal::PartitionTlsSet(internal::g_thread_cache_key, nullptr); #endif auto* root = tcache->root_; @@ -506,9 +510,10 @@ // they don't resurrect the thread cache. // // TODO(lizeb): Investigate whether this is needed on POSIX as well. - PartitionTlsSet(g_thread_cache_key, reinterpret_cast<void*>(kTombstone)); + internal::PartitionTlsSet(internal::g_thread_cache_key, + reinterpret_cast<void*>(kTombstone)); #if defined(PA_THREAD_CACHE_FAST_TLS) - g_thread_cache = reinterpret_cast<ThreadCache*>(kTombstone); + internal::g_thread_cache = reinterpret_cast<ThreadCache*>(kTombstone); #endif #endif // BUILDFLAG(IS_WIN) @@ -546,7 +551,7 @@ // clearing which would greatly increase calls to the central allocator. (3) // tries to keep memory usage low. So clearing half of the bucket, and filling // a quarter of it are sensible defaults. - INCREMENT_COUNTER(stats_.batch_fill_count); + PA_INCREMENT_COUNTER(stats_.batch_fill_count); Bucket& bucket = buckets_[bucket_index]; // Some buckets may have a limit lower than |kBatchFillRatio|, but we still @@ -566,7 +571,7 @@ size_t allocated_slots = 0; // Same as calling RawAlloc() |count| times, but acquires the lock only once. - ::partition_alloc::internal::ScopedGuard guard(root_->lock_); + internal::ScopedGuard guard(root_->lock_); for (int i = 0; i < count; i++) { // Thread cache fill should not trigger expensive operations, to not grab // the lock for a long time needlessly, but also to not inflate memory @@ -581,7 +586,7 @@ &root_->buckets[bucket_index], AllocFlags::kFastPathOrReturnNull | AllocFlags::kReturnNull, root_->buckets[bucket_index].slot_size /* raw_size */, - PartitionPageSize(), &usable_size, &is_already_zeroed); + internal::PartitionPageSize(), &usable_size, &is_already_zeroed); // Either the previous allocation would require a slow path allocation, or // the central allocator is out of memory. If the bucket was filled with @@ -651,11 +656,12 @@ } template <bool crash_on_corruption> -void ThreadCache::FreeAfter(PartitionFreelistEntry* head, size_t slot_size) { +void ThreadCache::FreeAfter(internal::PartitionFreelistEntry* head, + size_t slot_size) { // Acquire the lock once. Deallocation from the same bucket are likely to be // hitting the same cache lines in the central allocator, and lock // acquisitions can be expensive. - ::partition_alloc::internal::ScopedGuard guard(root_->lock_); + internal::ScopedGuard guard(root_->lock_); while (head) { uintptr_t slot_start = reinterpret_cast<uintptr_t>(head); head = head->GetNextForThreadCache<crash_on_corruption>(slot_size); @@ -708,7 +714,7 @@ stats->batch_fill_count += stats_.batch_fill_count; #if defined(PA_THREAD_CACHE_ALLOC_STATS) - for (size_t i = 0; i < kNumBuckets + 1; i++) + for (size_t i = 0; i < internal::kNumBuckets + 1; i++) stats->allocs_per_bucket_[i] += stats_.allocs_per_bucket_[i]; #endif // defined(PA_THREAD_CACHE_ALLOC_STATS) @@ -759,4 +765,4 @@ ClearBucketHelper<crash_on_corruption>(bucket, 0); } -} // namespace base::internal +} // namespace partition_alloc
diff --git a/base/allocator/partition_allocator/thread_cache.h b/base/allocator/partition_allocator/thread_cache.h index 978a83e..35b4977 100644 --- a/base/allocator/partition_allocator/thread_cache.h +++ b/base/allocator/partition_allocator/thread_cache.h
@@ -27,7 +27,13 @@ #include <algorithm> #endif -namespace partition_alloc::internal::tools { +namespace partition_alloc { + +class ThreadCache; + +namespace internal { + +namespace tools { // This is used from ThreadCacheInspector, which runs in a different process. It // scans the process memory looking for the two needles, to locate the thread @@ -57,13 +63,7 @@ class HeapDumper; class ThreadCacheInspector; -} // namespace partition_alloc::internal::tools - -namespace base { - -namespace internal { - -class ThreadCache; +} // namespace tools extern BASE_EXPORT PartitionTlsKey g_thread_cache_key; // On Android, we have to go through emutls, since this is always a shared @@ -76,6 +76,8 @@ extern BASE_EXPORT thread_local ThreadCache* g_thread_cache; #endif +} // namespace internal + struct ThreadCacheLimits { // When trying to conserve memory, set the thread cache limit to this. static constexpr size_t kDefaultSizeThreshold = 512; @@ -133,24 +135,25 @@ void SetThreadCacheMultiplier(float multiplier); void SetLargestActiveBucketIndex(uint8_t largest_active_bucket_index); - static PartitionLock& GetLock() { return Instance().lock_; } + static internal::Lock& GetLock() { return Instance().lock_; } // Purges all thread caches *now*. This is completely thread-unsafe, and // should only be called in a post-fork() handler. void ForcePurgeAllThreadAfterForkUnsafe(); void ResetForTesting(); - static constexpr TimeDelta kMinPurgeInterval = Seconds(1); - static constexpr TimeDelta kMaxPurgeInterval = Minutes(1); - static constexpr TimeDelta kDefaultPurgeInterval = 2 * kMinPurgeInterval; + static constexpr base::TimeDelta kMinPurgeInterval = base::Seconds(1); + static constexpr base::TimeDelta kMaxPurgeInterval = base::Minutes(1); + static constexpr base::TimeDelta kDefaultPurgeInterval = + 2 * kMinPurgeInterval; static constexpr size_t kMinCachedMemoryForPurging = 500 * 1024; private: - friend class partition_alloc::internal::tools::ThreadCacheInspector; - friend class partition_alloc::internal::tools::HeapDumper; + friend class internal::tools::ThreadCacheInspector; + friend class internal::tools::HeapDumper; // Not using base::Lock as the object's constructor must be constexpr. - PartitionLock lock_; + internal::Lock lock_; ThreadCache* list_head_ GUARDED_BY(GetLock()) = nullptr; bool periodic_purge_is_initialized_ = false; base::TimeDelta periodic_purge_next_interval_ = kDefaultPurgeInterval; @@ -160,24 +163,25 @@ // understand enough constexpr to handle the code below. uint8_t largest_active_bucket_index_ = 1; #else - uint8_t largest_active_bucket_index_ = - BucketIndexLookup::GetIndex(ThreadCacheLimits::kDefaultSizeThreshold); + uint8_t largest_active_bucket_index_ = internal::BucketIndexLookup::GetIndex( + ThreadCacheLimits::kDefaultSizeThreshold); #endif }; constexpr ThreadCacheRegistry::ThreadCacheRegistry() = default; #if defined(PA_THREAD_CACHE_ENABLE_STATISTICS) -#define INCREMENT_COUNTER(counter) ++counter -#define GET_COUNTER(counter) counter +#define PA_INCREMENT_COUNTER(counter) ++counter #else -#define INCREMENT_COUNTER(counter) \ - do { \ +#define PA_INCREMENT_COUNTER(counter) \ + do { \ } while (0) -#define GET_COUNTER(counter) 0 #endif // defined(PA_THREAD_CACHE_ENABLE_STATISTICS) #if DCHECK_IS_ON() + +namespace internal { + class ReentrancyGuard { public: explicit ReentrancyGuard(bool& flag) : flag_(flag) { @@ -191,10 +195,12 @@ bool& flag_; }; -#define PA_REENTRANCY_GUARD(x) \ - ReentrancyGuard guard { x } +} // namespace internal -#else +#define PA_REENTRANCY_GUARD(x) \ + internal::ReentrancyGuard guard { x } + +#else // DCHECK_IS_ON() #define PA_REENTRANCY_GUARD(x) \ do { \ @@ -232,9 +238,10 @@ static ThreadCache* Get() { #if defined(PA_THREAD_CACHE_FAST_TLS) - return g_thread_cache; + return internal::g_thread_cache; #else - return reinterpret_cast<ThreadCache*>(PartitionTlsGet(g_thread_cache_key)); + return reinterpret_cast<ThreadCache*>( + internal::PartitionTlsGet(internal::g_thread_cache_key)); #endif } @@ -298,7 +305,7 @@ return buckets_[index].count; } - PlatformThreadId thread_id() const { return thread_id_; } + base::PlatformThreadId thread_id() const { return thread_id_; } // Sets the maximum size of allocations that may be cached by the thread // cache. This applies to all threads. However, the maximum size is bounded by @@ -319,11 +326,11 @@ ThreadCacheLimits::kLargeSizeThreshold; private: - friend class partition_alloc::internal::tools::HeapDumper; - friend class partition_alloc::internal::tools::ThreadCacheInspector; + friend class internal::tools::HeapDumper; + friend class internal::tools::ThreadCacheInspector; struct Bucket { - PartitionFreelistEntry* freelist_head = nullptr; + internal::PartitionFreelistEntry* freelist_head = nullptr; // Want to keep sizeof(Bucket) small, using small types. uint8_t count = 0; std::atomic<uint8_t> limit{}; // Can be changed from another thread. @@ -350,7 +357,7 @@ void ResetForTesting(); // Releases the entire freelist starting at |head| to the root. template <bool crash_on_corruption> - void FreeAfter(PartitionFreelistEntry* head, size_t slot_size); + void FreeAfter(internal::PartitionFreelistEntry* head, size_t slot_size); static void SetGlobalLimits(PartitionRoot<>* root, float multiplier); #if BUILDFLAG(IS_NACL) @@ -363,7 +370,7 @@ 1; #endif static_assert( - kBucketCount < kNumBuckets, + kBucketCount < internal::kNumBuckets, "Cannot have more cached buckets than what the allocator supports"); // On some architectures, ThreadCache::Get() can be called and return @@ -397,7 +404,7 @@ // Cold data below. PartitionRoot<>* const root_; - const PlatformThreadId thread_id_; + const base::PlatformThreadId thread_id_; #if DCHECK_IS_ON() bool is_in_thread_cache_ = false; #endif @@ -409,7 +416,7 @@ friend class ThreadCacheRegistry; friend class PartitionAllocThreadCacheTest; - friend class partition_alloc::internal::tools::ThreadCacheInspector; + friend class internal::tools::ThreadCacheInspector; FRIEND_TEST_ALL_PREFIXES(PartitionAllocThreadCacheTest, Simple); FRIEND_TEST_ALL_PREFIXES(PartitionAllocThreadCacheTest, MultipleObjectsCachedPerBucket); @@ -435,10 +442,10 @@ ALWAYS_INLINE bool ThreadCache::MaybePutInCache(uintptr_t slot_start, size_t bucket_index) { PA_REENTRANCY_GUARD(is_in_thread_cache_); - INCREMENT_COUNTER(stats_.cache_fill_count); + PA_INCREMENT_COUNTER(stats_.cache_fill_count); if (UNLIKELY(bucket_index > largest_active_bucket_index_)) { - INCREMENT_COUNTER(stats_.cache_fill_misses); + PA_INCREMENT_COUNTER(stats_.cache_fill_misses); return false; } @@ -448,7 +455,7 @@ PutInBucket(bucket, slot_start); cached_memory_ += bucket.slot_size; - INCREMENT_COUNTER(stats_.cache_fill_hits); + PA_INCREMENT_COUNTER(stats_.cache_fill_hits); // Relaxed ordering: we don't care about having an up-to-date or consistent // value, just want it to not change while we are using it, hence using @@ -473,21 +480,21 @@ #endif PA_REENTRANCY_GUARD(is_in_thread_cache_); - INCREMENT_COUNTER(stats_.alloc_count); + PA_INCREMENT_COUNTER(stats_.alloc_count); // Only handle "small" allocations. if (UNLIKELY(bucket_index > largest_active_bucket_index_)) { - INCREMENT_COUNTER(stats_.alloc_miss_too_large); - INCREMENT_COUNTER(stats_.alloc_misses); + PA_INCREMENT_COUNTER(stats_.alloc_miss_too_large); + PA_INCREMENT_COUNTER(stats_.alloc_misses); return 0; } auto& bucket = buckets_[bucket_index]; if (LIKELY(bucket.freelist_head)) { - INCREMENT_COUNTER(stats_.alloc_hits); + PA_INCREMENT_COUNTER(stats_.alloc_hits); } else { PA_DCHECK(bucket.count == 0); - INCREMENT_COUNTER(stats_.alloc_miss_empty); - INCREMENT_COUNTER(stats_.alloc_misses); + PA_INCREMENT_COUNTER(stats_.alloc_miss_empty); + PA_INCREMENT_COUNTER(stats_.alloc_misses); FillBucket(bucket_index); @@ -531,12 +538,12 @@ // Here, only poison the current cacheline, which we are touching anyway. // TODO(lizeb): Make sure this does not hurt performance. - // Everything below requires this aligment. - static_assert(kAlignment == 16, ""); + // Everything below requires this alignment. + static_assert(internal::kAlignment == 16, ""); #if HAS_BUILTIN(__builtin_assume_aligned) uintptr_t address = reinterpret_cast<uintptr_t>(__builtin_assume_aligned( - reinterpret_cast<void*>(slot_start), kAlignment)); + reinterpret_cast<void*>(slot_start), internal::kAlignment)); #else uintptr_t address = slot_start; #endif @@ -545,7 +552,7 @@ // % 16. Its distance to the next cacheline is 64 - ((address & 63) / 16) * // 16. static_assert( - kPartitionCachelineSize == 64, + internal::kPartitionCachelineSize == 64, "The computation below assumes that cache lines are 64 bytes long."); int distance_to_next_cacheline_in_16_bytes = 4 - ((address >> 4) & 3); int slot_size_remaining_in_16_bytes = @@ -573,21 +580,21 @@ #endif // defined(PA_HAS_FREELIST_SHADOW_ENTRY) && defined(ARCH_CPU_X86_64) && // defined(PA_HAS_64_BITS_POINTERS) - auto* entry = PartitionFreelistEntry::EmplaceAndInitForThreadCache( + auto* entry = internal::PartitionFreelistEntry::EmplaceAndInitForThreadCache( slot_start, bucket.freelist_head); bucket.freelist_head = entry; bucket.count++; } -} // namespace internal -} // namespace base +} // namespace partition_alloc -namespace partition_alloc::internal { +namespace base::internal { // TODO(https://crbug.com/1288247): Remove these 'using' declarations once // the migration to the new namespaces gets done. -using ::base::internal::ThreadCache; +using ::partition_alloc::ThreadCache; +using ::partition_alloc::ThreadCacheRegistry; -} // namespace partition_alloc::internal +} // namespace base::internal #endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_THREAD_CACHE_H_
diff --git a/base/allocator/partition_allocator/thread_cache_unittest.cc b/base/allocator/partition_allocator/thread_cache_unittest.cc index cc4e1b1..30968219 100644 --- a/base/allocator/partition_allocator/thread_cache_unittest.cc +++ b/base/allocator/partition_allocator/thread_cache_unittest.cc
@@ -29,7 +29,7 @@ #if !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) && \ defined(PA_THREAD_CACHE_SUPPORTED) -namespace base::internal { +namespace partition_alloc { namespace { @@ -46,13 +46,13 @@ static_assert(kMediumSize <= ThreadCache::kDefaultSizeThreshold, ""); -class LambdaThreadDelegate : public PlatformThread::Delegate { +class LambdaThreadDelegate : public base::PlatformThread::Delegate { public: - explicit LambdaThreadDelegate(RepeatingClosure f) : f_(std::move(f)) {} + explicit LambdaThreadDelegate(base::RepeatingClosure f) : f_(std::move(f)) {} void ThreadMain() override { f_.Run(); } private: - RepeatingClosure f_; + base::RepeatingClosure f_; }; class DeltaCounter { @@ -105,8 +105,8 @@ ThreadSafePartitionRoot::DeleteForTesting(root_); // Cleanup the global state so next test can recreate ThreadCache. - if (internal::ThreadCache::IsTombstone(internal::ThreadCache::Get())) - internal::ThreadCache::RemoveTombstoneForTesting(); + if (ThreadCache::IsTombstone(ThreadCache::Get())) + ThreadCache::RemoveTombstoneForTesting(); } protected: @@ -119,7 +119,7 @@ #if defined(PA_HAS_64_BITS_POINTERS) // Another test can uninitialize the pools, so make sure they are // initialized. - PartitionAddressSpace::Init(); + internal::PartitionAddressSpace::Init(); #endif // defined(PA_HAS_64_BITS_POINTERS) ThreadCacheRegistry::Instance().SetThreadCacheMultiplier( ThreadCache::kDefaultMultiplier); @@ -158,7 +158,8 @@ } static size_t SizeToIndex(size_t size) { - return PartitionRoot<ThreadSafe>::SizeToBucketIndex(size, GetParam()); + return PartitionRoot<internal::ThreadSafe>::SizeToBucketIndex(size, + GetParam()); } size_t FillThreadCacheAndReturnIndex(size_t size, size_t count = 1) { @@ -215,8 +216,7 @@ EXPECT_EQ(kFillCountForSmallBucket, tcache->bucket_count_for_testing(index)); void* ptr2 = root_->Alloc(kSmallSize, ""); - EXPECT_EQ(::partition_alloc::internal::UnmaskPtr(ptr), - ::partition_alloc::internal::UnmaskPtr(ptr2)); + EXPECT_EQ(internal::UnmaskPtr(ptr), internal::UnmaskPtr(ptr2)); // Allocated from the thread cache. EXPECT_EQ(kFillCountForSmallBucket - 1, tcache->bucket_count_for_testing(index)); @@ -243,8 +243,7 @@ EXPECT_EQ(kFillCountForSmallBucket, tcache->bucket_count_for_testing(index)); void* ptr2 = root_->Alloc(kSmallSize + 1, ""); - EXPECT_EQ(::partition_alloc::internal::UnmaskPtr(ptr), - ::partition_alloc::internal::UnmaskPtr(ptr2)); + EXPECT_EQ(internal::UnmaskPtr(ptr), internal::UnmaskPtr(ptr2)); // Allocated from the thread cache. EXPECT_EQ(kFillCountForSmallBucket - 1, tcache->bucket_count_for_testing(index)); @@ -339,21 +338,21 @@ root_->get_total_size_of_allocated_bytes()); EXPECT_EQ(expected_allocated_size, root_->get_max_size_of_allocated_bytes()); - void* ptr = root_->Alloc(10 * kMaxBucketed, ""); + void* ptr = root_->Alloc(10 * internal::kMaxBucketed, ""); - EXPECT_EQ(expected_allocated_size + 10 * kMaxBucketed, + EXPECT_EQ(expected_allocated_size + 10 * internal::kMaxBucketed, root_->get_total_size_of_allocated_bytes()); - void* ptr2 = root_->Realloc(ptr, 9 * kMaxBucketed, ""); + void* ptr2 = root_->Realloc(ptr, 9 * internal::kMaxBucketed, ""); ASSERT_EQ(ptr, ptr2); - EXPECT_EQ(expected_allocated_size + 9 * kMaxBucketed, + EXPECT_EQ(expected_allocated_size + 9 * internal::kMaxBucketed, root_->get_total_size_of_allocated_bytes()); - ptr2 = root_->Realloc(ptr, 10 * kMaxBucketed, ""); + ptr2 = root_->Realloc(ptr, 10 * internal::kMaxBucketed, ""); ASSERT_EQ(ptr, ptr2); - EXPECT_EQ(expected_allocated_size + 10 * kMaxBucketed, + EXPECT_EQ(expected_allocated_size + 10 * internal::kMaxBucketed, root_->get_total_size_of_allocated_bytes()); root_->Free(ptr); @@ -364,7 +363,7 @@ auto* parent_thread_tcache = root_->thread_cache_for_testing(); ASSERT_TRUE(parent_thread_tcache); - LambdaThreadDelegate delegate{BindLambdaForTesting([&]() { + LambdaThreadDelegate delegate{base::BindLambdaForTesting([&]() { EXPECT_FALSE(root_->thread_cache_for_testing()); // No allocations yet. FillThreadCacheAndReturnIndex(kMediumSize); auto* tcache = root_->thread_cache_for_testing(); @@ -373,9 +372,9 @@ EXPECT_NE(parent_thread_tcache, tcache); })}; - PlatformThreadHandle thread_handle; - PlatformThread::Create(0, &delegate, &thread_handle); - PlatformThread::Join(thread_handle); + base::PlatformThreadHandle thread_handle; + base::PlatformThread::Create(0, &delegate, &thread_handle); + base::PlatformThread::Join(thread_handle); } TEST_P(PartitionAllocThreadCacheTest, ThreadCacheReclaimedWhenThreadExits) { @@ -390,22 +389,22 @@ void* other_thread_ptr; - LambdaThreadDelegate delegate{BindLambdaForTesting([&]() { + LambdaThreadDelegate delegate{base::BindLambdaForTesting([&]() { EXPECT_FALSE(root_->thread_cache_for_testing()); // No allocations yet. other_thread_ptr = root_->Alloc(kMediumSize, ""); root_->Free(other_thread_ptr); // |other_thread_ptr| is now in the thread cache. })}; - PlatformThreadHandle thread_handle; - PlatformThread::Create(0, &delegate, &thread_handle); - PlatformThread::Join(thread_handle); + base::PlatformThreadHandle thread_handle; + base::PlatformThread::Create(0, &delegate, &thread_handle); + base::PlatformThread::Join(thread_handle); void* this_thread_ptr = root_->Alloc(kMediumSize, ""); // |other_thread_ptr| was returned to the central allocator, and is returned // here, as it comes from the freelist. - EXPECT_EQ(::partition_alloc::internal::UnmaskPtr(this_thread_ptr), - ::partition_alloc::internal::UnmaskPtr(other_thread_ptr)); + EXPECT_EQ(internal::UnmaskPtr(this_thread_ptr), + internal::UnmaskPtr(other_thread_ptr)); root_->Free(other_thread_ptr); for (void* ptr : tmp) @@ -426,27 +425,27 @@ ASSERT_TRUE(parent_thread_tcache); { - PartitionAutoLock lock(ThreadCacheRegistry::GetLock()); + internal::ScopedGuard lock(ThreadCacheRegistry::GetLock()); EXPECT_EQ(parent_thread_tcache->prev_, nullptr); EXPECT_EQ(parent_thread_tcache->next_, nullptr); } - LambdaThreadDelegate delegate{BindLambdaForTesting([&]() { + LambdaThreadDelegate delegate{base::BindLambdaForTesting([&]() { EXPECT_FALSE(root_->thread_cache_for_testing()); // No allocations yet. FillThreadCacheAndReturnIndex(kSmallSize); auto* tcache = root_->thread_cache_for_testing(); EXPECT_TRUE(tcache); - PartitionAutoLock lock(ThreadCacheRegistry::GetLock()); + internal::ScopedGuard lock(ThreadCacheRegistry::GetLock()); EXPECT_EQ(tcache->prev_, nullptr); EXPECT_EQ(tcache->next_, parent_thread_tcache); })}; - PlatformThreadHandle thread_handle; - PlatformThread::Create(0, &delegate, &thread_handle); - PlatformThread::Join(thread_handle); + base::PlatformThreadHandle thread_handle; + base::PlatformThread::Create(0, &delegate, &thread_handle); + base::PlatformThread::Join(thread_handle); - PartitionAutoLock lock(ThreadCacheRegistry::GetLock()); + internal::ScopedGuard lock(ThreadCacheRegistry::GetLock()); EXPECT_EQ(parent_thread_tcache->prev_, nullptr); EXPECT_EQ(parent_thread_tcache->next_, nullptr); } @@ -504,7 +503,7 @@ FillThreadCacheAndReturnIndex(kMediumSize); uint64_t alloc_count = root_->thread_cache_for_testing()->stats_.alloc_count; - LambdaThreadDelegate delegate{BindLambdaForTesting([&]() { + LambdaThreadDelegate delegate{base::BindLambdaForTesting([&]() { EXPECT_FALSE(root_->thread_cache_for_testing()); // No allocations yet. size_t bucket_index = FillThreadCacheAndReturnIndex(kMediumSize); @@ -521,9 +520,9 @@ EXPECT_EQ(alloc_count + this_thread_alloc_count, stats.alloc_count); })}; - PlatformThreadHandle thread_handle; - PlatformThread::Create(0, &delegate, &thread_handle); - PlatformThread::Join(thread_handle); + base::PlatformThreadHandle thread_handle; + base::PlatformThread::Create(0, &delegate, &thread_handle); + base::PlatformThread::Join(thread_handle); } #endif // defined(PA_ENABLE_THREAD_CACHE_STATISTICS) @@ -544,7 +543,7 @@ ThreadCache* other_thread_tcache = nullptr; LambdaThreadDelegate delegate{ - BindLambdaForTesting([&]() NO_THREAD_SAFETY_ANALYSIS { + base::BindLambdaForTesting([&]() NO_THREAD_SAFETY_ANALYSIS { FillThreadCacheAndReturnIndex(kSmallSize); other_thread_tcache = root_->thread_cache_for_testing(); @@ -565,8 +564,8 @@ other_thread_tcache->bucket_count_for_testing(bucket_index)); })}; - PlatformThreadHandle thread_handle; - PlatformThread::Create(0, &delegate, &thread_handle); + base::PlatformThreadHandle thread_handle; + base::PlatformThread::Create(0, &delegate, &thread_handle); while (!other_thread_started.load(std::memory_order_acquire)) { } @@ -584,13 +583,14 @@ other_thread_tcache->bucket_count_for_testing(bucket_index)); purge_called.store(true, std::memory_order_release); - PlatformThread::Join(thread_handle); + base::PlatformThread::Join(thread_handle); } TEST_P(PartitionAllocThreadCacheTest, PeriodicPurge) { auto& registry = ThreadCacheRegistry::Instance(); auto NextInterval = [®istry]() { - return Microseconds(registry.GetPeriodicPurgeNextIntervalInMicroseconds()); + return base::Microseconds( + registry.GetPeriodicPurgeNextIntervalInMicroseconds()); }; EXPECT_EQ(NextInterval(), ThreadCacheRegistry::kDefaultPurgeInterval); @@ -639,7 +639,8 @@ DISABLED_PeriodicPurgeSumsOverAllThreads) { auto& registry = ThreadCacheRegistry::Instance(); auto NextInterval = [®istry]() { - return Microseconds(registry.GetPeriodicPurgeNextIntervalInMicroseconds()); + return base::Microseconds( + registry.GetPeriodicPurgeNextIntervalInMicroseconds()); }; EXPECT_EQ(NextInterval(), ThreadCacheRegistry::kDefaultPurgeInterval); @@ -666,7 +667,7 @@ std::atomic<int> allocations_done{0}; std::atomic<bool> can_finish{false}; - LambdaThreadDelegate delegate{BindLambdaForTesting([&]() { + LambdaThreadDelegate delegate{base::BindLambdaForTesting([&]() { FillThreadCacheWithMemory(5 * ThreadCacheRegistry::kMinCachedMemoryForPurging); allocations_done.fetch_add(1, std::memory_order_release); @@ -676,13 +677,13 @@ } })}; - PlatformThreadHandle thread_handle; - PlatformThread::Create(0, &delegate, &thread_handle); - PlatformThreadHandle thread_handle_2; - PlatformThread::Create(0, &delegate, &thread_handle_2); + base::PlatformThreadHandle thread_handle; + base::PlatformThread::Create(0, &delegate, &thread_handle); + base::PlatformThreadHandle thread_handle_2; + base::PlatformThread::Create(0, &delegate, &thread_handle_2); while (allocations_done.load(std::memory_order_acquire) != 2) { - PlatformThread::YieldCurrentThread(); + base::PlatformThread::YieldCurrentThread(); } // Many allocations on the other thread. @@ -690,8 +691,8 @@ EXPECT_EQ(NextInterval(), ThreadCacheRegistry::kDefaultPurgeInterval); can_finish.store(true, std::memory_order_release); - PlatformThread::Join(thread_handle); - PlatformThread::Join(thread_handle_2); + base::PlatformThread::Join(thread_handle); + base::PlatformThread::Join(thread_handle_2); } // TODO(https://crbug.com/1287799): Flaky on IOS. @@ -783,7 +784,7 @@ ThreadCacheRegistry::Instance().SetThreadCacheMultiplier( ThreadCache::kDefaultMultiplier + 1); - LambdaThreadDelegate delegate{BindLambdaForTesting([&]() { + LambdaThreadDelegate delegate{base::BindLambdaForTesting([&]() { FillThreadCacheAndReturnIndex(kSmallSize, kDefaultCountForSmallBucket + 10); auto* this_thread_tcache = root_->thread_cache_for_testing(); // More than the default since the multiplier has changed. @@ -802,8 +803,8 @@ this_thread_tcache->bucket_count_for_testing(bucket_index)); })}; - PlatformThreadHandle thread_handle; - PlatformThread::Create(0, &delegate, &thread_handle); + base::PlatformThreadHandle thread_handle; + base::PlatformThread::Create(0, &delegate, &thread_handle); while (!other_thread_started.load(std::memory_order_acquire)) { } @@ -811,7 +812,7 @@ ThreadCacheRegistry::Instance().SetThreadCacheMultiplier(1.); threshold_changed.store(true, std::memory_order_release); - PlatformThread::Join(thread_handle); + base::PlatformThread::Join(thread_handle); } TEST_P(PartitionAllocThreadCacheTest, DynamicSizeThreshold) { @@ -923,8 +924,9 @@ auto* tc_bucket = &root_->buckets[tc_bucket_index]; size_t expected_allocated_size = tc_bucket->slot_size; // For the ThreadCache itself. - size_t expected_committed_size = - kUseLazyCommit ? SystemPageSize() : tc_bucket->get_bytes_per_span(); + size_t expected_committed_size = kUseLazyCommit + ? internal::SystemPageSize() + : tc_bucket->get_bytes_per_span(); EXPECT_EQ(expected_committed_size, root_->total_size_of_committed_pages); EXPECT_EQ(expected_committed_size, root_->max_size_of_committed_pages); @@ -937,8 +939,9 @@ auto* medium_bucket = root_->buckets + SizeToIndex(kMediumSize); size_t medium_alloc_size = medium_bucket->slot_size; expected_allocated_size += medium_alloc_size; - expected_committed_size += - kUseLazyCommit ? SystemPageSize() : medium_bucket->get_bytes_per_span(); + expected_committed_size += kUseLazyCommit + ? internal::SystemPageSize() + : medium_bucket->get_bytes_per_span(); EXPECT_EQ(expected_committed_size, root_->total_size_of_committed_pages); EXPECT_EQ(expected_committed_size, root_->max_size_of_committed_pages); @@ -1043,7 +1046,7 @@ // The rest of the buckets all match up exactly with the existing // bucket distribution. - for (size_t i = 1 << 19; i < kMaxBucketed; i <<= 1) { + for (size_t i = 1 << 19; i < internal::kMaxBucketed; i <<= 1) { for (size_t offset = 0; offset < 4; offset++) { size_t n = i * (4 + offset) / 4; EXPECT_EQ(BucketIndexLookup::GetIndex(n), @@ -1075,8 +1078,8 @@ ThreadSafePartitionRoot::DeleteForTesting(root); // Cleanup the global state so next test can recreate ThreadCache. - if (internal::ThreadCache::IsTombstone(internal::ThreadCache::Get())) - internal::ThreadCache::RemoveTombstoneForTesting(); + if (ThreadCache::IsTombstone(ThreadCache::Get())) + ThreadCache::RemoveTombstoneForTesting(); } // This test makes sure it's safe to switch to the alternate bucket distribution @@ -1104,11 +1107,11 @@ ThreadSafePartitionRoot::DeleteForTesting(root); // Cleanup the global state so next test can recreate ThreadCache. - if (internal::ThreadCache::IsTombstone(internal::ThreadCache::Get())) - internal::ThreadCache::RemoveTombstoneForTesting(); + if (ThreadCache::IsTombstone(ThreadCache::Get())) + ThreadCache::RemoveTombstoneForTesting(); } -} // namespace base::internal +} // namespace partition_alloc #endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) && // defined(PA_THREAD_CACHE_SUPPORTED)
diff --git a/base/nix/xdg_util.cc b/base/nix/xdg_util.cc index 67db3ad..1980b9b 100644 --- a/base/nix/xdg_util.cc +++ b/base/nix/xdg_util.cc
@@ -90,6 +90,8 @@ return DESKTOP_ENVIRONMENT_PANTHEON; if (value == "XFCE") return DESKTOP_ENVIRONMENT_XFCE; + if (value == "UKUI") + return DESKTOP_ENVIRONMENT_UKUI; } } @@ -110,6 +112,8 @@ desktop_session == "xubuntu") { return DESKTOP_ENVIRONMENT_XFCE; } + if (desktop_session == "ukui") + return DESKTOP_ENVIRONMENT_UKUI; } // Fall back on some older environment variables. @@ -145,6 +149,8 @@ return "UNITY"; case DESKTOP_ENVIRONMENT_XFCE: return "XFCE"; + case DESKTOP_ENVIRONMENT_UKUI: + return "UKUI"; } return nullptr; }
diff --git a/base/nix/xdg_util.h b/base/nix/xdg_util.h index 60c924a8..daebc9d 100644 --- a/base/nix/xdg_util.h +++ b/base/nix/xdg_util.h
@@ -61,6 +61,7 @@ DESKTOP_ENVIRONMENT_KDE4, DESKTOP_ENVIRONMENT_KDE5, DESKTOP_ENVIRONMENT_PANTHEON, + DESKTOP_ENVIRONMENT_UKUI, DESKTOP_ENVIRONMENT_UNITY, DESKTOP_ENVIRONMENT_XFCE, };
diff --git a/base/nix/xdg_util_unittest.cc b/base/nix/xdg_util_unittest.cc index 6a1e9ee..babb366d 100644 --- a/base/nix/xdg_util_unittest.cc +++ b/base/nix/xdg_util_unittest.cc
@@ -38,6 +38,7 @@ const char* const kXdgDesktopGNOMEClassic = "GNOME:GNOME-Classic"; const char* const kXdgDesktopKDE = "KDE"; const char* const kXdgDesktopPantheon = "Pantheon"; +const char* const kXdgDesktopUKUI = "UKUI"; const char* const kXdgDesktopUnity = "Unity"; const char* const kXdgDesktopUnity7 = "Unity:Unity7"; const char* const kXdgDesktopUnity8 = "Unity:Unity8"; @@ -160,6 +161,15 @@ EXPECT_EQ(DESKTOP_ENVIRONMENT_PANTHEON, GetDesktopEnvironment(&getter)); } +TEST(XDGUtilTest, GetXdgDesktopUKUI) { + MockEnvironment getter; + EXPECT_CALL(getter, GetVar(_, _)).WillRepeatedly(Return(false)); + EXPECT_CALL(getter, GetVar(Eq(kXdgCurrentDesktopEnvVar), _)) + .WillOnce(DoAll(SetArgPointee<1>(kXdgDesktopUKUI), Return(true))); + + EXPECT_EQ(DESKTOP_ENVIRONMENT_UKUI, GetDesktopEnvironment(&getter)); +} + TEST(XDGUtilTest, GetXdgDesktopUnity) { MockEnvironment getter; EXPECT_CALL(getter, GetVar(_, _)).WillRepeatedly(Return(false));
diff --git a/build/android/unused_resources/UnusedResources.java b/build/android/unused_resources/UnusedResources.java index 6334223..dbdd42f 100644 --- a/build/android/unused_resources/UnusedResources.java +++ b/build/android/unused_resources/UnusedResources.java
@@ -382,7 +382,10 @@ ReferenceChecker callback = new ReferenceChecker() { @Override public boolean shouldProcess(String internalName) { - return !isResourceClass(internalName + DOT_CLASS); + // We do not need to ignore R subclasses since R8 now removes + // unused resource id fields in R subclasses thus their + // remaining presence means real usage. + return true; } @Override @@ -400,6 +403,12 @@ Resource resource = getResourceFromCode(internalName, fieldName); if (resource != null) { ResourceUsageModel.markReachable(resource); + if (mDebugPrinter != null) { + mDebugPrinter.println("Marking " + resource + + " reachable: referenced from dex" + + " in " + file + ":" + name + " (static field access " + + internalName + "." + fieldName + ")"); + } } }
diff --git a/build/fuchsia/device_target_test.py b/build/fuchsia/device_target_test.py index 6a40f4a..7eac42c 100755 --- a/build/fuchsia/device_target_test.py +++ b/build/fuchsia/device_target_test.py
@@ -12,6 +12,7 @@ from target import Target, FuchsiaTargetException +@mock.patch.object(FfxRunner, 'daemon_stop') class TestDiscoverDeviceTarget(unittest.TestCase): def setUp(self): self.args = Namespace(out_dir='out/fuchsia', @@ -25,7 +26,8 @@ logs_dir=None, system_image_dir=None) - def testNoNodeNameOneDeviceReturnNoneCheckNameAndAddress(self): + def testNoNodeNameOneDeviceReturnNoneCheckNameAndAddress( + self, mock_daemon_stop): with DeviceTarget.CreateFromArgs(self.args) as device_target_instance, \ mock.patch.object(FfxRunner, 'list_targets') as mock_list_targets, \ mock.patch.object( @@ -46,8 +48,10 @@ self.assertEqual(device_target_instance._node_name, 'device_name') self.assertEqual(device_target_instance._host, 'address') self.assertEqual(device_target_instance._port, 12345) + mock_daemon_stop.assert_called_once() - def testNoNodeNameTwoDevicesRaiseExceptionAmbiguousTarget(self): + def testNoNodeNameTwoDevicesRaiseExceptionAmbiguousTarget( + self, mock_daemon_stop): with DeviceTarget.CreateFromArgs(self.args) as device_target_instance, \ mock.patch.object(FfxRunner, 'list_targets') as mock_list_targets, \ self.assertRaisesRegex(Exception, \ @@ -70,8 +74,10 @@ device_target_instance.Start() self.assertIsNone(device_target_instance._node_name) self.assertIsNone(device_target_instance._host) + mock_daemon_stop.assert_called_once() - def testNoNodeNameDeviceDoesntHaveNameRaiseExceptionCouldNotFind(self): + def testNoNodeNameDeviceDoesntHaveNameRaiseExceptionCouldNotFind( + self, mock_daemon_stop): with DeviceTarget.CreateFromArgs(self.args) as device_target_instance, \ mock.patch.object(FfxRunner, 'list_targets') as mock_list_targets, \ self.assertRaisesRegex(Exception, 'Could not find device.'): @@ -86,8 +92,10 @@ device_target_instance.Start() self.assertIsNone(device_target_instance._node_name) self.assertIsNone(device_target_instance._host) + mock_daemon_stop.assert_called_once() - def testNodeNameDefinedDeviceFoundReturnNoneCheckNameAndHost(self): + def testNodeNameDefinedDeviceFoundReturnNoneCheckNameAndHost( + self, mock_daemon_stop): self.args.node_name = 'device_name' with DeviceTarget.CreateFromArgs(self.args) as device_target_instance, \ mock.patch.object( @@ -100,8 +108,10 @@ self.assertEqual(device_target_instance._node_name, 'device_name') self.assertEqual(device_target_instance._host, 'address') self.assertEqual(device_target_instance._port, 12345) + mock_daemon_stop.assert_called_once() - def testNodeNameDefinedDeviceNotFoundRaiseExceptionCouldNotFind(self): + def testNodeNameDefinedDeviceNotFoundRaiseExceptionCouldNotFind( + self, mock_daemon_stop): self.args.node_name = 'wrong_device_name' with DeviceTarget.CreateFromArgs(self.args) as device_target_instance, \ mock.patch.object( @@ -112,8 +122,9 @@ device_target_instance.Start() self.assertIsNone(device_target_instance._node_name) self.assertIsNone(device_target_instance._host) + mock_daemon_stop.assert_called_once() - def testNoDevicesFoundRaiseExceptionCouldNotFind(self): + def testNoDevicesFoundRaiseExceptionCouldNotFind(self, mock_daemon_stop): with DeviceTarget.CreateFromArgs(self.args) as device_target_instance, \ mock.patch.object(FfxRunner, 'list_targets') as mock_list_targets, \ self.assertRaisesRegex(Exception, 'Could not find device.'): @@ -121,8 +132,9 @@ device_target_instance.Start() self.assertIsNone(device_target_instance._node_name) self.assertIsNone(device_target_instance._host) + mock_daemon_stop.assert_called_once() - def testNoProvisionDeviceIfVersionsMatch(self): + def testNoProvisionDeviceIfVersionsMatch(self, mock_daemon_stop): self.args.os_check = 'update' self.args.system_image_dir = 'mockdir' with DeviceTarget.CreateFromArgs(self.args) as device_target_instance, \ @@ -137,8 +149,9 @@ mock_version.return_value = '1.0' device_target_instance.Start() self.assertEqual(mock_provision.call_count, 0) + mock_daemon_stop.assert_called_once() - def testRaiseExceptionIfCheckVersionsNoMatch(self): + def testRaiseExceptionIfCheckVersionsNoMatch(self, mock_daemon_stop): self.args.os_check = 'check' self.args.system_image_dir = 'mockdir' with DeviceTarget.CreateFromArgs(self.args) as device_target_instance, \ @@ -154,8 +167,9 @@ mock_hash.return_value = '2.0' mock_version.return_value = '1.0' device_target_instance.Start() + mock_daemon_stop.assert_called_once() - def testProvisionIfOneNonDetectableDevice(self): + def testProvisionIfOneNonDetectableDevice(self, mock_daemon_stop): self.args.os_check = 'update' self.args.node_name = 'mocknode' self.args.system_image_dir = 'mockdir' @@ -167,6 +181,7 @@ 1, 'ffx', 'Timeout attempting to reach target "mocknode"') device_target_instance.Start() self.assertEqual(mock_provision.call_count, 1) + mock_daemon_stop.assert_called_once() if __name__ == '__main__':
diff --git a/build/fuchsia/ffx_session.py b/build/fuchsia/ffx_session.py index 908ebed0..430644d 100755 --- a/build/fuchsia/ffx_session.py +++ b/build/fuchsia/ffx_session.py
@@ -289,6 +289,10 @@ raise Exception('Failed to determine node name for target at %s' % format_host_port(address, port)) + def daemon_stop(self): + """Stops the ffx daemon.""" + self.run_ffx(['daemon', 'stop'], check=False, suppress_repair=True) + class FfxTarget(): """A helper to run `ffx` commands for a specific target."""
diff --git a/build/fuchsia/fvdl_target_test.py b/build/fuchsia/fvdl_target_test.py index 937b24fd..6aecb453 100755 --- a/build/fuchsia/fvdl_target_test.py +++ b/build/fuchsia/fvdl_target_test.py
@@ -13,9 +13,11 @@ import unittest.mock as mock from argparse import Namespace +from ffx_session import FfxRunner from fvdl_target import FvdlTarget, _SSH_KEY_DIR +@mock.patch.object(FfxRunner, 'daemon_stop') class TestBuildCommandFvdlTarget(unittest.TestCase): def setUp(self): self.args = Namespace(out_dir='outdir', @@ -33,7 +35,7 @@ boot_data.ProvisionSSH = mock.MagicMock() FvdlTarget._Shutdown = mock.MagicMock() - def testBasicEmuCommand(self): + def testBasicEmuCommand(self, mock_daemon_stop): with FvdlTarget.CreateFromArgs(self.args) as target: build_command = target._BuildCommand() self.assertIn(target._FVDL_PATH, build_command) @@ -54,28 +56,35 @@ correct_ram_amount = True break self.assertTrue(correct_ram_amount) + mock_daemon_stop.assert_called_once() - def testBuildCommandCheckIfNotRequireKVMSetNoAcceleration(self): + def testBuildCommandCheckIfNotRequireKVMSetNoAcceleration( + self, mock_daemon_stop): self.args.require_kvm = False with FvdlTarget.CreateFromArgs(self.args) as target: self.assertIn('--noacceleration', target._BuildCommand()) + mock_daemon_stop.assert_called_once() - def testBuildCommandCheckIfNotEnableGraphicsSetHeadless(self): + def testBuildCommandCheckIfNotEnableGraphicsSetHeadless( + self, mock_daemon_stop): self.args.enable_graphics = True with FvdlTarget.CreateFromArgs(self.args) as target: self.assertNotIn('--headless', target._BuildCommand()) + mock_daemon_stop.assert_called_once() - def testBuildCommandCheckIfHardwareGpuSetHostGPU(self): + def testBuildCommandCheckIfHardwareGpuSetHostGPU(self, mock_daemon_stop): self.args.hardware_gpu = True with FvdlTarget.CreateFromArgs(self.args) as target: self.assertIn('--host-gpu', target._BuildCommand()) + mock_daemon_stop.assert_called_once() - def testBuildCommandCheckIfWithNetworkSetTunTap(self): + def testBuildCommandCheckIfWithNetworkSetTunTap(self, mock_daemon_stop): self.args.with_network = True with FvdlTarget.CreateFromArgs(self.args) as target: self.assertIn('-N', target._BuildCommand()) + mock_daemon_stop.assert_called_once() - def testBuildCommandCheckRamSizeNot8192SetRamSize(self): + def testBuildCommandCheckRamSizeNot8192SetRamSize(self, mock_daemon_stop): custom_ram_size = 4096 self.args.ram_size_mb = custom_ram_size with FvdlTarget.CreateFromArgs(self.args) as target: @@ -84,14 +93,16 @@ correct_ram_amount = False with open(target._device_proto_file.name, 'r') as f: self.assertTrue(' ram: {}\n'.format(custom_ram_size) in f.readlines()) + mock_daemon_stop.assert_called_once() - def testBuildCommandCheckEmulatorLogSetup(self): + def testBuildCommandCheckEmulatorLogSetup(self, mock_daemon_stop): with tempfile.TemporaryDirectory() as logs_dir: self.args.logs_dir = logs_dir with FvdlTarget.CreateFromArgs(self.args) as target: build_command = target._BuildCommand() self.assertIn('--emulator-log', build_command) self.assertIn('--envs', build_command) + mock_daemon_stop.assert_called_once() if __name__ == '__main__':
diff --git a/build/fuchsia/linux.sdk.sha1 b/build/fuchsia/linux.sdk.sha1 index 46a6147..1f416cf 100644 --- a/build/fuchsia/linux.sdk.sha1 +++ b/build/fuchsia/linux.sdk.sha1
@@ -1 +1 @@ -7.20220323.2.1 +7.20220324.0.1
diff --git a/build/fuchsia/linux_internal.sdk.sha1 b/build/fuchsia/linux_internal.sdk.sha1 index 46a6147..3f80868 100644 --- a/build/fuchsia/linux_internal.sdk.sha1 +++ b/build/fuchsia/linux_internal.sdk.sha1
@@ -1 +1 @@ -7.20220323.2.1 +7.20220324.1.1
diff --git a/build/fuchsia/mac.sdk.sha1 b/build/fuchsia/mac.sdk.sha1 index 46a6147..1f416cf 100644 --- a/build/fuchsia/mac.sdk.sha1 +++ b/build/fuchsia/mac.sdk.sha1
@@ -1 +1 @@ -7.20220323.2.1 +7.20220324.0.1
diff --git a/build/fuchsia/target.py b/build/fuchsia/target.py index 25a2031..4652cc13 100644 --- a/build/fuchsia/target.py +++ b/build/fuchsia/target.py
@@ -88,7 +88,17 @@ def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): - self.Stop() + try: + self.Stop() + finally: + # Stop the ffx daemon, since the target device is going / has gone away. + # This ensures that the daemon does not become "hung" if the target device + # stops responding to network I/O (e.g., due to emulator instance + # teardown). The daemon will be automatically restarted by the next `ffx` + # call. + self._ffx_runner.daemon_stop() + # Stop the log manager only after the last use of _ffx_runner. + self._log_manager.Stop() def Start(self): """Handles the instantiation and connection process for the Fuchsia @@ -110,7 +120,6 @@ self._symbolizer_proc.kill() if self._log_listener_proc: self._log_listener_proc.kill() - self._log_manager.Stop() def IsNewInstance(self): """Returns True if the connected target instance is newly provisioned."""
diff --git a/build/linux/strip_binary.py b/build/linux/strip_binary.py index 00b4089..c08b9931 100755 --- a/build/linux/strip_binary.py +++ b/build/linux/strip_binary.py
@@ -24,7 +24,7 @@ ] process = subprocess.Popen(cmd_line) - + process.wait() return process.returncode
diff --git a/cc/layers/layer.h b/cc/layers/layer.h index 57f75c9..b171e168 100644 --- a/cc/layers/layer.h +++ b/cc/layers/layer.h
@@ -21,7 +21,6 @@ #include "cc/base/region.h" #include "cc/benchmarks/micro_benchmark.h" #include "cc/cc_export.h" -#include "cc/input/input_handler.h" #include "cc/input/scroll_snap_data.h" #include "cc/layers/layer_collections.h" #include "cc/layers/touch_action_region.h"
diff --git a/cc/layers/scrollbar_layer_base.h b/cc/layers/scrollbar_layer_base.h index e99d421..d1f58d4 100644 --- a/cc/layers/scrollbar_layer_base.h +++ b/cc/layers/scrollbar_layer_base.h
@@ -6,6 +6,7 @@ #define CC_LAYERS_SCROLLBAR_LAYER_BASE_H_ #include "cc/cc_export.h" +#include "cc/input/scrollbar.h" #include "cc/layers/layer.h" namespace cc {
diff --git a/cc/tiles/gpu_image_decode_cache.cc b/cc/tiles/gpu_image_decode_cache.cc index 0e788293..a0271286 100644 --- a/cc/tiles/gpu_image_decode_cache.cc +++ b/cc/tiles/gpu_image_decode_cache.cc
@@ -2134,10 +2134,12 @@ // have happened at decode time. sk_sp<SkColorSpace> decoded_target_colorspace = ColorSpaceForImageDecode(draw_image, image_data->mode); - if (target_color_space && - SkColorSpace::Equals(target_color_space.get(), - decoded_target_colorspace.get())) { - target_color_space = nullptr; + if (target_color_space && decoded_target_colorspace) { + if (!gfx::ColorSpace(*decoded_target_colorspace).IsPQOrHLG() && + SkColorSpace::Equals(target_color_space.get(), + decoded_target_colorspace.get())) { + target_color_space = nullptr; + } } absl::optional<TargetColorParams> target_color_params; @@ -2146,12 +2148,6 @@ target_color_params->color_space = gfx::ColorSpace(*target_color_space); } - // Will be nullptr for non-HDR images or when we're using the default level. - const bool needs_adjusted_color_space = - NeedsColorSpaceAdjustedForUpload(draw_image); - if (needs_adjusted_color_space) - decoded_target_colorspace = ColorSpaceForImageUpload(draw_image); - if (image_data->mode == DecodedDataMode::kTransferCache) { DCHECK(use_transfer_cache_); if (image_data->decode.do_hardware_accelerated_decode()) { @@ -2166,8 +2162,7 @@ needs_tone_mapping ? target_color_params : absl::nullopt); } else { UploadImageIfNecessary_TransferCache_SoftwareDecode_RGBA( - draw_image, image_data, needs_adjusted_color_space, - decoded_target_colorspace, target_color_params); + draw_image, image_data, target_color_params); } } else { // Grab a reference to our decoded image. For the kCpu path, we will use @@ -2181,10 +2176,8 @@ draw_image, image_data, uploaded_image, image_needs_mips, decoded_target_colorspace, target_color_space); } else { - UploadImageIfNecessary_GpuCpu_RGBA( - draw_image, image_data, uploaded_image, image_needs_mips, - needs_adjusted_color_space, decoded_target_colorspace, - target_color_space); + UploadImageIfNecessary_GpuCpu_RGBA(draw_image, image_data, uploaded_image, + image_needs_mips, target_color_space); } } } @@ -2265,8 +2258,6 @@ UploadImageIfNecessary_TransferCache_SoftwareDecode_RGBA( const DrawImage& draw_image, ImageData* image_data, - bool needs_adjusted_color_space, - sk_sp<SkColorSpace> decoded_target_colorspace, absl::optional<TargetColorParams> target_color_params) { DCHECK_EQ(image_data->mode, DecodedDataMode::kTransferCache); DCHECK(use_transfer_cache_); @@ -2276,8 +2267,6 @@ SkPixmap pixmap; if (!image_data->decode.image()->peekPixels(&pixmap)) return; - if (needs_adjusted_color_space) - pixmap.setColorSpace(decoded_target_colorspace); ClientImageTransferCacheEntry image_entry(&pixmap, image_data->needs_mips, target_color_params); @@ -2385,18 +2374,10 @@ ImageData* image_data, sk_sp<SkImage> uploaded_image, GrMipMapped image_needs_mips, - bool needs_adjusted_color_space, - sk_sp<SkColorSpace> decoded_target_colorspace, sk_sp<SkColorSpace> color_space) { DCHECK(!use_transfer_cache_); DCHECK(!image_data->yuva_pixmap_info.has_value()); - // TODO(crbug.com/1120719): The RGBX path is broken for HDR images. - if (needs_adjusted_color_space) { - uploaded_image = - uploaded_image->reinterpretColorSpace(decoded_target_colorspace); - } - // RGBX decoding is below. // For kGpu, we upload and color convert (if necessary). if (image_data->mode == DecodedDataMode::kGpu) { @@ -3012,35 +2993,6 @@ return sk_ref_sp(image.paint_image().color_space()); } -bool GpuImageDecodeCache::NeedsColorSpaceAdjustedForUpload( - const DrawImage& image) const { - bool is_hlg = false; - if (image.paint_image().GetContentColorUsage(&is_hlg) != - gfx::ContentColorUsage::kHDR) { - return false; - } - - // Attempt basic "tonemapping" of HLG content when rendering to SDR. - if (is_hlg && !image.target_color_space().IsHDR()) - return true; - - return image.sdr_white_level() != gfx::ColorSpace::kDefaultSDRWhiteLevel; -} - -sk_sp<SkColorSpace> GpuImageDecodeCache::ColorSpaceForImageUpload( - const DrawImage& image) const { - DCHECK(NeedsColorSpaceAdjustedForUpload(image)); - if (!image.target_color_space().IsHDR()) { - // HLG is designed such that treating it as 2.2 gamma content works well. - constexpr skcms_TransferFunction kGamma22 = {2.2, 1, 0, 0, 0, 0, 0}; - return SkColorSpace::MakeRGB(kGamma22, SkNamedGamut::kRec2020); - } - - return gfx::ColorSpace(*image.paint_image().color_space()) - .GetWithSDRWhiteLevel(image.sdr_white_level()) - .ToSkColorSpace(); -} - void GpuImageDecodeCache::CheckContextLockAcquiredIfNecessary() { if (!context_->GetLock()) return; @@ -3162,9 +3114,7 @@ ? draw_image.target_color_space().ToSkColorSpace() : nullptr; sk_sp<SkColorSpace> upload_color_space = - NeedsColorSpaceAdjustedForUpload(draw_image) - ? ColorSpaceForImageUpload(draw_image) - : ColorSpaceForImageDecode(draw_image, image_data->mode); + ColorSpaceForImageDecode(draw_image, image_data->mode); sk_sp<SkImage> yuv_image_with_mips_owned = CreateImageFromYUVATexturesInternal( image_y_with_mips_owned.get(), image_u_with_mips_owned.get(), @@ -3205,15 +3155,6 @@ // delete, delaying deletion. sk_sp<SkImage> previous_image = image_data->upload.image(); -#if DCHECK_IS_ON() - // For already uploaded images, the correct color space should already have - // been set during the upload process. - if (NeedsColorSpaceAdjustedForUpload(draw_image)) { - DCHECK(SkColorSpace::Equals(previous_image->colorSpace(), - ColorSpaceForImageUpload(draw_image).get())); - } -#endif - // Generate a new image from the previous, adding mips. sk_sp<SkImage> image_with_mips = previous_image->makeTextureImage( context_->GrContext(), GrMipMapped::kYes);
diff --git a/cc/tiles/gpu_image_decode_cache.h b/cc/tiles/gpu_image_decode_cache.h index 30640e21e..c159315 100644 --- a/cc/tiles/gpu_image_decode_cache.h +++ b/cc/tiles/gpu_image_decode_cache.h
@@ -702,8 +702,6 @@ void UploadImageIfNecessary_TransferCache_SoftwareDecode_RGBA( const DrawImage& draw_image, ImageData* image_data, - bool needs_adjusted_color_space, - sk_sp<SkColorSpace> decoded_target_colorspace, absl::optional<TargetColorParams> target_color_params); void UploadImageIfNecessary_GpuCpu_YUVA( const DrawImage& draw_image, @@ -712,14 +710,11 @@ GrMipMapped image_needs_mips, sk_sp<SkColorSpace> decoded_target_colorspace, sk_sp<SkColorSpace> color_space); - void UploadImageIfNecessary_GpuCpu_RGBA( - const DrawImage& draw_image, - ImageData* image_data, - sk_sp<SkImage> uploaded_image, - GrMipMapped image_needs_mips, - bool needs_adjusted_color_space, - sk_sp<SkColorSpace> decoded_target_colorspace, - sk_sp<SkColorSpace> color_space); + void UploadImageIfNecessary_GpuCpu_RGBA(const DrawImage& draw_image, + ImageData* image_data, + sk_sp<SkImage> uploaded_image, + GrMipMapped image_needs_mips, + sk_sp<SkColorSpace> color_space); // Flush pending operations on context_->GrContext() for each element of // |yuv_images| and then clear the vector. @@ -735,11 +730,6 @@ sk_sp<SkColorSpace> ColorSpaceForImageDecode(const DrawImage& image, DecodedDataMode mode) const; - // HDR images need the SkColorSpace adjusted during upload to avoid white - // level issues on systems with variable SDR white levels (Windows). - bool NeedsColorSpaceAdjustedForUpload(const DrawImage& image) const; - sk_sp<SkColorSpace> ColorSpaceForImageUpload(const DrawImage& image) const; - // Helper function to add a memory dump to |pmd| for a single texture // identified by |gl_id| with size |bytes| and |locked_size| equal to either // |bytes| or 0 depending on whether the texture is currently locked.
diff --git a/cc/tiles/gpu_image_decode_cache_unittest.cc b/cc/tiles/gpu_image_decode_cache_unittest.cc index 3ab5d222..a2b72d79 100644 --- a/cc/tiles/gpu_image_decode_cache_unittest.cc +++ b/cc/tiles/gpu_image_decode_cache_unittest.cc
@@ -1208,12 +1208,12 @@ EXPECT_TRUE(decoded_draw_image.image()); EXPECT_TRUE(decoded_draw_image.image()->isTextureBacked()); EXPECT_TRUE(decoded_draw_image.is_budgeted()); - EXPECT_EQ(decoded_draw_image.image()->colorType(), kRGBA_F16_SkColorType); - auto cs = gfx::ColorSpace(*decoded_draw_image.image()->colorSpace()); - float sdr_white_level; - ASSERT_TRUE(cs.GetSDRWhiteLevel(&sdr_white_level)); - EXPECT_FLOAT_EQ(sdr_white_level, kCustomWhiteLevel); + // When testing in configurations that do not support rendering to F16, this + // will fall back to N32. + EXPECT_TRUE(decoded_draw_image.image()->colorType() == + kRGBA_F16_SkColorType || + decoded_draw_image.image()->colorType() == kN32_SkColorType); EXPECT_FALSE(cache->DiscardableIsLockedForTesting(draw_image)); @@ -3087,6 +3087,9 @@ gfx::ColorSpace decoded_cs; if (target_cs.IsHDR()) decoded_cs = gfx::ColorSpace::CreateHDR10(); + auto sk_decoded_cs = cache->SupportsColorSpaceConversion() + ? decoded_cs.ToSkColorSpace() + : nullptr; // An unknown SkColorType means we expect fallback to RGB. PaintImage image = @@ -3094,13 +3097,10 @@ decoded_cs.ToSkColorSpace()) : CreatePaintImageForFallbackToRGB(GetNormalImageSize()); - float sdr_white_level = gfx::ColorSpace::kDefaultSDRWhiteLevel; - if (target_cs.IsHDR()) - ASSERT_TRUE(target_cs.GetSDRWhiteLevel(&sdr_white_level)); - TargetColorParams target_color_params; target_color_params.color_space = target_cs; - target_color_params.sdr_max_luminance_nits = sdr_white_level; + target_color_params.sdr_max_luminance_nits = + gfx::ColorSpace::kDefaultSDRWhiteLevel; DrawImage draw_image( image, false, SkIRect::MakeWH(image.width(), image.height()), @@ -3131,7 +3131,7 @@ // If `draw_image` is tone mapped, then it will be converted to RGBA // during tone mapping. bool color_converted_to_rgba = use_transfer_cache_ && - target_cs.IsPQOrHLG() && + decoded_cs.IsPQOrHLG() && cache->SupportsColorSpaceConversion(); if (decodes_to_yuv && !color_converted_to_rgba) { @@ -3144,22 +3144,18 @@ SkYUVAPixmapInfo yuva_pixmap_info = GetYUVAPixmapInfo(GetNormalImageSize(), yuv_format_, yuv_data_type_); - // Decoded HDR images should have their SDR white level adjusted to match - // the display so we avoid scaling them by variable SDR brightness levels. - auto expected_cs = decoded_cs.IsHDR() - ? decoded_cs.GetWithSDRWhiteLevel(sdr_white_level) - : decoded_cs; - SkISize plane_sizes[SkYUVAInfo::kMaxPlanes]; yuva_pixmap_info.yuvaInfo().planeDimensions(plane_sizes); VerifyUploadedPlaneSizes(cache, draw_image, transfer_cache_entry_id, - plane_sizes, yuv_data_type, - expected_cs.ToSkColorSpace().get()); + plane_sizes, yuv_data_type, sk_decoded_cs.get()); - if (expected_cs.IsValid()) { - EXPECT_TRUE( - SkColorSpace::Equals(expected_cs.ToSkColorSpace().get(), - decoded_draw_image.image()->colorSpace())); + auto expected_image_cs = + cache->SupportsColorSpaceConversion() && sk_decoded_cs + ? target_color_params.color_space.ToSkColorSpace() + : nullptr; + if (expected_image_cs) { + EXPECT_TRUE(SkColorSpace::Equals( + expected_image_cs.get(), decoded_draw_image.image()->colorSpace())); } } else { if (use_transfer_cache_) { @@ -3186,7 +3182,7 @@ original_caps = context_provider_->ContextCapabilities(); } - const auto hdr_cs = gfx::ColorSpace::CreateHDR10(/*sdr_white_level=*/200.0f); + const auto hdr_cs = gfx::ColorSpace::CreateHDR10(); // Test that decoding to R16 works when supported. { @@ -3252,7 +3248,7 @@ SkYUVAPixmapInfo::DataType::kFloat16, DefaultColorSpace()); - // Verify HDR decoding has white level adjustment. + // Verify HDR decoding. yuv_format_ = YUVSubsampling::k420; decode_and_check_plane_sizes(f16_cache.get(), true, SkYUVAPixmapInfo::DataType::kFloat16, hdr_cs);
diff --git a/chrome/VERSION b/chrome/VERSION index 0ce79c9..8507b6c 100644 --- a/chrome/VERSION +++ b/chrome/VERSION
@@ -1,4 +1,4 @@ MAJOR=102 MINOR=0 -BUILD=4961 +BUILD=4962 PATCH=0
diff --git a/chrome/android/chrome_java_sources.gni b/chrome/android/chrome_java_sources.gni index 0904a80..ce8bfba4 100644 --- a/chrome/android/chrome_java_sources.gni +++ b/chrome/android/chrome_java_sources.gni
@@ -218,12 +218,15 @@ "java/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClient.java", "java/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClientWrappers.java", "java/src/org/chromium/chrome/browser/browserservices/TrustedWebActivitySettingsLauncher.java", + "java/src/org/chromium/chrome/browser/browserservices/digitalgoods/AcknowledgeConverter.java", + "java/src/org/chromium/chrome/browser/browserservices/digitalgoods/ConsumeConverter.java", "java/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsAdapter.java", "java/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsConverter.java", "java/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsFactoryFactory.java", "java/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsFactoryImpl.java", "java/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsImpl.java", "java/src/org/chromium/chrome/browser/browserservices/digitalgoods/GetDetailsConverter.java", + "java/src/org/chromium/chrome/browser/browserservices/digitalgoods/ListPurchaseHistoryConverter.java", "java/src/org/chromium/chrome/browser/browserservices/digitalgoods/ListPurchasesConverter.java", "java/src/org/chromium/chrome/browser/browserservices/digitalgoods/SiteIsolator.java", "java/src/org/chromium/chrome/browser/browserservices/permissiondelegation/InstalledWebappBridge.java",
diff --git a/chrome/android/chrome_junit_test_java_sources.gni b/chrome/android/chrome_junit_test_java_sources.gni index 46523179..f0d18ca 100644 --- a/chrome/android/chrome_junit_test_java_sources.gni +++ b/chrome/android/chrome_junit_test_java_sources.gni
@@ -38,6 +38,8 @@ "junit/src/org/chromium/chrome/browser/browserservices/SessionDataHolderTest.java", "junit/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClientTest.java", "junit/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsConverterTest.java", + "junit/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsUnitTest.java", + "junit/src/org/chromium/chrome/browser/browserservices/digitalgoods/MockTrustedWebActivityClient.java", "junit/src/org/chromium/chrome/browser/browserservices/permissiondelegation/InstalledWebappGeolocationBridgeTest.java", "junit/src/org/chromium/chrome/browser/browserservices/permissiondelegation/LocationPermissionUpdaterTest.java", "junit/src/org/chromium/chrome/browser/browserservices/permissiondelegation/NotificationChannelPreserverTest.java",
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/AcknowledgeConverter.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/AcknowledgeConverter.java new file mode 100644 index 0000000..af10a0719 --- /dev/null +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/AcknowledgeConverter.java
@@ -0,0 +1,83 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.chrome.browser.browserservices.digitalgoods; + +import static org.chromium.chrome.browser.browserservices.digitalgoods.DigitalGoodsConverter.convertResponseCode; + +import android.os.Bundle; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; +import androidx.browser.trusted.TrustedWebActivityCallback; + +import org.chromium.base.Log; +import org.chromium.payments.mojom.DigitalGoods.Consume_Response; + +/** + * The "Acknowledge" command was was removed in DGAPI v2.0. It is kept around because the "Consume" + * command can be implemented in terms of Acknowledge when talking to older clients. + */ +class AcknowledgeConverter { + private static final String TAG = "DigitalGoods"; + + static final String PARAM_ACKNOWLEDGE_PURCHASE_TOKEN = "acknowledge.purchaseToken"; + static final String PARAM_ACKNOWLEDGE_MAKE_AVAILABLE_AGAIN = "acknowledge.makeAvailableAgain"; + static final String RESPONSE_ACKNOWLEDGE = "acknowledge.response"; + static final String RESPONSE_ACKNOWLEDGE_RESPONSE_CODE = "acknowledge.responseCode"; + + private AcknowledgeConverter() {} + + static Bundle convertParams(String purchaseToken) { + // Consume is equivalent to the old acknowledge command when make_available_again = true. + boolean makeAvailableAgain = true; + + Bundle bundle = new Bundle(); + bundle.putString(PARAM_ACKNOWLEDGE_PURCHASE_TOKEN, purchaseToken); + bundle.putBoolean(PARAM_ACKNOWLEDGE_MAKE_AVAILABLE_AGAIN, makeAvailableAgain); + return bundle; + } + + static TrustedWebActivityCallback convertCallback(Consume_Response callback) { + return new TrustedWebActivityCallback() { + @Override + public void onExtraCallback(@NonNull String callbackName, @Nullable Bundle args) { + if (!RESPONSE_ACKNOWLEDGE.equals(callbackName)) { + Log.w(TAG, "Wrong callback name given: " + callbackName + "."); + ConsumeConverter.returnClientAppError(callback); + return; + } + + if (args == null) { + Log.w(TAG, "No args provided."); + ConsumeConverter.returnClientAppError(callback); + return; + } + + if (!(args.get(RESPONSE_ACKNOWLEDGE_RESPONSE_CODE) instanceof Integer)) { + Log.w(TAG, "Poorly formed args provided."); + ConsumeConverter.returnClientAppError(callback); + return; + } + + int code = args.getInt(RESPONSE_ACKNOWLEDGE_RESPONSE_CODE); + callback.call(convertResponseCode(code, args)); + } + }; + } + + /** + * Creates a {@link Bundle} that represents the result of an acknowledge call. This would be + * carried out by the client app and is only here to help testing. + */ + @VisibleForTesting + public static Bundle createResponseBundle(int responseCode) { + Bundle bundle = new Bundle(); + + bundle.putInt(RESPONSE_ACKNOWLEDGE_RESPONSE_CODE, responseCode); + + return bundle; + } +}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/ConsumeConverter.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/ConsumeConverter.java new file mode 100644 index 0000000..0aecd7e7 --- /dev/null +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/ConsumeConverter.java
@@ -0,0 +1,86 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.chrome.browser.browserservices.digitalgoods; + +import static org.chromium.chrome.browser.browserservices.digitalgoods.DigitalGoodsConverter.convertResponseCode; + +import android.os.Bundle; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; +import androidx.browser.trusted.TrustedWebActivityCallback; + +import org.chromium.base.Log; +import org.chromium.payments.mojom.BillingResponseCode; +import org.chromium.payments.mojom.DigitalGoods.Consume_Response; + +/** + * A converter that deals with the parameters and result for Consume calls. + */ +class ConsumeConverter { + private static final String TAG = "DigitalGoods"; + + static final String PARAM_CONSUME_PURCHASE_TOKEN = "consume.purchaseToken"; + static final String RESPONSE_CONSUME = "consume.response"; + static final String RESPONSE_CONSUME_RESPONSE_CODE = "consume.responseCode"; + + private ConsumeConverter() {} + + static Bundle convertParams(String purchaseToken) { + Bundle bundle = new Bundle(); + bundle.putString(PARAM_CONSUME_PURCHASE_TOKEN, purchaseToken); + return bundle; + } + + static TrustedWebActivityCallback convertCallback(Consume_Response callback) { + return new TrustedWebActivityCallback() { + @Override + public void onExtraCallback(@NonNull String callbackName, @Nullable Bundle args) { + if (!RESPONSE_CONSUME.equals(callbackName)) { + Log.w(TAG, "Wrong callback name given: " + callbackName + "."); + returnClientAppError(callback); + return; + } + + if (args == null) { + Log.w(TAG, "No args provided."); + returnClientAppError(callback); + return; + } + + if (!(args.get(RESPONSE_CONSUME_RESPONSE_CODE) instanceof Integer)) { + Log.w(TAG, "Poorly formed args provided."); + returnClientAppError(callback); + return; + } + + int code = args.getInt(RESPONSE_CONSUME_RESPONSE_CODE); + callback.call(convertResponseCode(code, args)); + } + }; + } + + public static void returnClientAppUnavailable(Consume_Response callback) { + callback.call(BillingResponseCode.CLIENT_APP_UNAVAILABLE); + } + + public static void returnClientAppError(Consume_Response callback) { + callback.call(BillingResponseCode.CLIENT_APP_ERROR); + } + + /** + * Creates a {@link Bundle} that represents the result of an consume call. This would be + * carried out by the client app and is only here to help testing. + */ + @VisibleForTesting + public static Bundle createResponseBundle(int responseCode) { + Bundle bundle = new Bundle(); + + bundle.putInt(RESPONSE_CONSUME_RESPONSE_CODE, responseCode); + + return bundle; + } +} \ No newline at end of file
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsAdapter.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsAdapter.java index 59252717..9dcef90b 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsAdapter.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsAdapter.java
@@ -13,7 +13,9 @@ import org.chromium.chrome.browser.browserservices.TrustedWebActivityClient; import org.chromium.chrome.browser.browserservices.TrustedWebActivityClientWrappers; import org.chromium.components.embedder_support.util.Origin; +import org.chromium.payments.mojom.DigitalGoods.Consume_Response; import org.chromium.payments.mojom.DigitalGoods.GetDetails_Response; +import org.chromium.payments.mojom.DigitalGoods.ListPurchaseHistory_Response; import org.chromium.payments.mojom.DigitalGoods.ListPurchases_Response; /** @@ -24,11 +26,15 @@ public class DigitalGoodsAdapter { private static final String TAG = "DigitalGoods"; - public static final String COMMAND_ACKNOWLEDGE = "acknowledge"; + public static final String COMMAND_CONSUME = "consume"; public static final String COMMAND_GET_DETAILS = "getDetails"; public static final String COMMAND_LIST_PURCHASES = "listPurchases"; + public static final String COMMAND_LIST_PURCHASE_HISTORY = "listPurchaseHistory"; public static final String KEY_SUCCESS = "success"; + // Legacy commands kept around for backwards compatibility. + public static final String COMMAND_ACKNOWLEDGE = "acknowledge"; + private final TrustedWebActivityClient mClient; public DigitalGoodsAdapter(TrustedWebActivityClient client) { @@ -53,6 +59,35 @@ execute(scope, COMMAND_LIST_PURCHASES, args, callback, onError, onUnavailable); } + public void listPurchaseHistory(Uri scope, ListPurchaseHistory_Response response) { + Bundle args = new Bundle(); + TrustedWebActivityCallback callback = + ListPurchaseHistoryConverter.convertCallback(response); + Runnable onError = () -> ListPurchaseHistoryConverter.returnClientAppError(response); + Runnable onUnavailable = + () -> ListPurchaseHistoryConverter.returnClientAppUnavailable(response); + + execute(scope, COMMAND_LIST_PURCHASE_HISTORY, args, callback, onError, onUnavailable); + } + + public void consume(Uri scope, String purchaseToken, Consume_Response response) { + Bundle args = ConsumeConverter.convertParams(purchaseToken); + TrustedWebActivityCallback callback = ConsumeConverter.convertCallback(response); + Runnable onUnavailable = () -> ConsumeConverter.returnClientAppUnavailable(response); + Runnable onError = () -> ConsumeConverter.returnClientAppError(response); + + // If Consume fails, try to call acknowledge(..., makeAvailableAgain = true) which will + // achieve the same effect on older clients. + Runnable tryAcknowledgeOnError = () -> { + Bundle ackArgs = AcknowledgeConverter.convertParams(purchaseToken); + TrustedWebActivityCallback ackCallback = AcknowledgeConverter.convertCallback(response); + + execute(scope, COMMAND_ACKNOWLEDGE, ackArgs, ackCallback, onError, onUnavailable); + }; + + execute(scope, COMMAND_CONSUME, args, callback, tryAcknowledgeOnError, onUnavailable); + } + private void execute(Uri scope, String command, Bundle args, TrustedWebActivityCallback callback, Runnable onClientAppError, Runnable onClientAppUnavailable) {
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsImpl.java index 04834ec..30dffc631 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsImpl.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsImpl.java
@@ -49,12 +49,14 @@ @Override public void listPurchaseHistory(ListPurchaseHistory_Response callback) { - // TODO(peconn) + GURL url = mDelegate.getUrl(); + if (url != null) mAdapter.listPurchaseHistory(Uri.parse(url.getSpec()), callback); } @Override public void consume(String purchaseToken, Consume_Response callback) { - // TODO(peconn) + GURL url = mDelegate.getUrl(); + if (url != null) mAdapter.consume(Uri.parse(url.getSpec()), purchaseToken, callback); } @Override
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/GetDetailsConverter.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/GetDetailsConverter.java index 9385d7ea..5efd2b2 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/GetDetailsConverter.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/GetDetailsConverter.java
@@ -20,7 +20,9 @@ import org.chromium.payments.mojom.BillingResponseCode; import org.chromium.payments.mojom.DigitalGoods.GetDetails_Response; import org.chromium.payments.mojom.ItemDetails; +import org.chromium.payments.mojom.ItemType; import org.chromium.payments.mojom.PaymentCurrencyAmount; +import org.chromium.url.mojom.Url; /** * A converter that deals with the parameters and result for GetDetails calls. @@ -40,11 +42,18 @@ static final String KEY_VALUE = "itemDetails.value"; static final String[] REQUIRED_FIELDS = {KEY_ID, KEY_TITLE, KEY_DESC, KEY_CURRENCY, KEY_VALUE}; + static final String KEY_TYPE = "itemDetails.type"; + static final String KEY_ICON_URL = "itemDetails.url"; + static final String KEY_SUBS_PERIOD = "itemDetails.subsPeriod"; static final String KEY_FREE_TRIAL_PERIOD = "itemDetails.freeTrialPeriod"; static final String KEY_INTRO_CURRENCY = "itemDetails.introPriceCurrency"; static final String KEY_INTRO_VALUE = "itemDetails.introPriceValue"; static final String KEY_INTRO_PERIOD = "itemDetails.introPricePeriod"; + static final String KEY_INTRO_CYCLES = "itemDetails.introPriceCycles"; + + static final String ITEM_TYPE_SUBS = "subs"; + static final String ITEM_TYPE_INAPP = "inapp"; private GetDetailsConverter() {} @@ -115,9 +124,20 @@ result.price = price; // Optional fields. + result.type = convertItemType(item.getString(KEY_TYPE)); + String iconUrl = item.getString(KEY_ICON_URL); + if (iconUrl != null) { + org.chromium.url.mojom.Url url = new Url(); + url.url = iconUrl; + result.iconUrls = new Url[] {url}; + } else { + result.iconUrls = new Url[0]; + } + result.subscriptionPeriod = item.getString(KEY_SUBS_PERIOD); result.freeTrialPeriod = item.getString(KEY_FREE_TRIAL_PERIOD); result.introductoryPricePeriod = item.getString(KEY_INTRO_PERIOD); + result.introductoryPriceCycles = item.getInt(KEY_INTRO_CYCLES, 0); String introPriceCurrency = item.getString(KEY_INTRO_CURRENCY); String introPriceValue = item.getString(KEY_INTRO_VALUE); @@ -132,6 +152,17 @@ return result; } + static int convertItemType(@Nullable String itemType) { + // TODO: introduce our own API here. + if (ITEM_TYPE_SUBS.equals(itemType)) { + return ItemType.SUBSCRIPTION; + } else if (ITEM_TYPE_INAPP.equals(itemType)) { + return ItemType.PRODUCT; + } + + return ItemType.UNKNOWN; + } + static void returnClientAppUnavailable(GetDetails_Response callback) { callback.call(BillingResponseCode.CLIENT_APP_UNAVAILABLE, new ItemDetails[0]); } @@ -146,16 +177,21 @@ */ @VisibleForTesting static Bundle createItemDetailsBundle(String id, String title, String desc, String currency, - String value, @Nullable String subsPeriod, @Nullable String freeTrialPeriod, - @Nullable String introPriceCurrency, @Nullable String introPriceValue, - @Nullable String intoPricePeriod) { + String value, String type, String iconUrl, @Nullable String subsPeriod, + @Nullable String freeTrialPeriod, @Nullable String introPriceCurrency, + @Nullable String introPriceValue, @Nullable String intoPricePeriod, + int introPriceCycles) { Bundle bundle = createItemDetailsBundle(id, title, desc, currency, value); + bundle.putString(KEY_TYPE, type); + bundle.putString(KEY_ICON_URL, iconUrl); + bundle.putString(KEY_SUBS_PERIOD, subsPeriod); bundle.putString(KEY_FREE_TRIAL_PERIOD, freeTrialPeriod); bundle.putString(KEY_INTRO_CURRENCY, introPriceCurrency); bundle.putString(KEY_INTRO_VALUE, introPriceValue); bundle.putString(KEY_INTRO_PERIOD, intoPricePeriod); + bundle.putInt(KEY_INTRO_CYCLES, introPriceCycles); return bundle; }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/ListPurchaseHistoryConverter.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/ListPurchaseHistoryConverter.java new file mode 100644 index 0000000..688cd2c0 --- /dev/null +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/ListPurchaseHistoryConverter.java
@@ -0,0 +1,90 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.chrome.browser.browserservices.digitalgoods; + +import static org.chromium.chrome.browser.browserservices.digitalgoods.DigitalGoodsConverter.checkField; +import static org.chromium.chrome.browser.browserservices.digitalgoods.DigitalGoodsConverter.convertParcelableArray; +import static org.chromium.chrome.browser.browserservices.digitalgoods.DigitalGoodsConverter.convertResponseCode; + +import android.os.Bundle; +import android.os.Parcelable; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; +import androidx.browser.trusted.TrustedWebActivityCallback; + +import org.chromium.base.Log; +import org.chromium.payments.mojom.BillingResponseCode; +import org.chromium.payments.mojom.DigitalGoods.ListPurchaseHistory_Response; +import org.chromium.payments.mojom.PurchaseReference; + +/** + * A converter that deals with the results of ListPurchaseHistory calls. + */ +class ListPurchaseHistoryConverter { + private static final String TAG = "DigitalGoods"; + + static final String RESPONSE_COMMAND = "listPurchaseHistory.response"; + static final String KEY_PURCHASES_LIST = "listPurchaseHistory.purchasesList"; + static final String KEY_RESPONSE_CODE = "listPurchaseHistory.responseCode"; + + private ListPurchaseHistoryConverter() {} + + /** + * Produces a {@link TrustedWebActivityCallback} that calls the given + * {@link ListPurchaseHistoryResponse}. + */ + static TrustedWebActivityCallback convertCallback(ListPurchaseHistory_Response callback) { + return new TrustedWebActivityCallback() { + @Override + public void onExtraCallback(@NonNull String callbackName, @Nullable Bundle args) { + if (!RESPONSE_COMMAND.equals(callbackName)) { + Log.w(TAG, "Wrong callback name given: " + callbackName + "."); + returnClientAppError(callback); + return; + } + + if (args == null) { + Log.w(TAG, "No args provided."); + returnClientAppError(callback); + return; + } + + if (!checkField(args, KEY_RESPONSE_CODE, Integer.class) + || !checkField(args, KEY_PURCHASES_LIST, Parcelable[].class)) { + returnClientAppError(callback); + return; + } + + int code = args.getInt(KEY_RESPONSE_CODE); + Parcelable[] array = args.getParcelableArray(KEY_PURCHASES_LIST); + + PurchaseReference[] reference = convertParcelableArray( + array, ListPurchasesConverter::convertPurchaseReference) + .toArray(new PurchaseReference[0]); + callback.call(convertResponseCode(code, args), reference); + } + }; + } + + static void returnClientAppUnavailable(ListPurchaseHistory_Response callback) { + callback.call(BillingResponseCode.CLIENT_APP_UNAVAILABLE, new PurchaseReference[0]); + } + + static void returnClientAppError(ListPurchaseHistory_Response callback) { + callback.call(BillingResponseCode.CLIENT_APP_ERROR, new PurchaseReference[0]); + } + + @VisibleForTesting + static Bundle createResponseBundle(int responseCode, Bundle... purchaseDetails) { + Bundle bundle = new Bundle(); + + bundle.putInt(KEY_RESPONSE_CODE, responseCode); + bundle.putParcelableArray(KEY_PURCHASES_LIST, purchaseDetails); + + return bundle; + } +} \ No newline at end of file
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/ListPurchasesConverter.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/ListPurchasesConverter.java index c2523c7c..4aa2ce0 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/ListPurchasesConverter.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/ListPurchasesConverter.java
@@ -34,11 +34,6 @@ static final String KEY_ITEM_ID = "purchaseDetails.itemId"; static final String KEY_PURCHASE_TOKEN = "purchaseDetails.purchaseToken"; - static final String KEY_ACKNOWLEDGED = "purchaseDetails.acknowledged"; - static final String KEY_PURCHASE_STATE = "purchaseDetails.purchaseState"; - static final String KEY_PURCHASE_TIME_MICROSECONDS_PAST_UNIX_EPOCH = - "purchaseDetails.purchaseTimeMicrosecondsPastUnixEpoch"; - static final String KEY_WILL_AUTO_RENEW = "purchaseDetails.willAutoRenew"; // These values are copied from the Play Billing library since Chrome cannot depend on it. // https://developer.android.com/reference/com/android/billingclient/api/Purchase.PurchaseState @@ -46,6 +41,8 @@ static final int PLAY_BILLING_PURCHASE_STATE_PURCHASED = 1; static final int PLAY_BILLING_PURCHASE_STATE_UNSPECIFIED = 0; + private ListPurchasesConverter() {} + /** * Produces a {@link TrustedWebActivityCallback} that calls the given * {@link ListPurchasesResponse}. @@ -76,15 +73,15 @@ Parcelable[] array = args.getParcelableArray(KEY_PURCHASES_LIST); PurchaseReference[] reference = convertParcelableArray( - array, ListPurchasesConverter::convertPurchaseDetails) + array, ListPurchasesConverter::convertPurchaseReference) .toArray(new PurchaseReference[0]); callback.call(convertResponseCode(code, args), reference); } }; } - /** Convert a PurchaseDetails bundle into a PurchaseReference object. */ - static PurchaseReference convertPurchaseDetails(Bundle purchase) { + /** Convert a Bundle into a PurchaseReference object. */ + static PurchaseReference convertPurchaseReference(Bundle purchase) { if (!checkField(purchase, KEY_ITEM_ID, String.class)) return null; if (!checkField(purchase, KEY_PURCHASE_TOKEN, String.class)) return null; @@ -116,18 +113,11 @@ } @VisibleForTesting - static Bundle createPurchaseDetailsBundle(String itemId, String purchaseToken, - boolean acknowledged, int purchaseState, long purchaseTimeMicrosecondsPastUnixEpoch, - boolean willAutoRenew) { + static Bundle createPurchaseReferenceBundle(String itemId, String purchaseToken) { Bundle bundle = new Bundle(); bundle.putString(KEY_ITEM_ID, itemId); bundle.putString(KEY_PURCHASE_TOKEN, purchaseToken); - bundle.putBoolean(KEY_ACKNOWLEDGED, acknowledged); - bundle.putInt(KEY_PURCHASE_STATE, purchaseState); - bundle.putLong(KEY_PURCHASE_TIME_MICROSECONDS_PAST_UNIX_EPOCH, - purchaseTimeMicrosecondsPastUnixEpoch); - bundle.putBoolean(KEY_WILL_AUTO_RENEW, willAutoRenew); return bundle; }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/AutofillVirtualCardEnrollmentInfoBar.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/AutofillVirtualCardEnrollmentInfoBar.java index c0a0c2c..b874e08 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/AutofillVirtualCardEnrollmentInfoBar.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/AutofillVirtualCardEnrollmentInfoBar.java
@@ -178,10 +178,18 @@ public void createContent(InfoBarLayout layout) { super.createContent(layout); + // Remove the default title view. UiUtils.removeViewFromParent(layout.getMessageTextView()); - layout.getMessageLayout().addIconTitle(mIconDrawableId, mTitleText); InfoBarControlLayout control = layout.addControlLayout(); + + // Add the illustration icon. + control.addLeadImage(R.drawable.virtual_card_enrollment_illustration); + + // Add Google Pay icon and title + control.addIconTitle(mIconDrawableId, mTitleText); + + // Add infobar description. if (!TextUtils.isEmpty(mDescriptionText) && !TextUtils.isEmpty(mLearnMoreLinkText)) { SpannableString text = new SpannableString(mDescriptionText); int offset = mDescriptionText.length() - mLearnMoreLinkText.length();
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/adaptive/AdaptiveButtonActionMenuRenderTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/adaptive/AdaptiveButtonActionMenuRenderTest.java index cf332ddf..9338d10 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/adaptive/AdaptiveButtonActionMenuRenderTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/adaptive/AdaptiveButtonActionMenuRenderTest.java
@@ -79,7 +79,9 @@ coordinator.buildMenuItems(), null); mView = coordinator.getContentViewForTesting(); - ((ViewGroup) mView.getParent()).removeView(mView); + if (mView.getParent() != null) { + ((ViewGroup) mView.getParent()).removeView(mView); + } int popupWidth = activity.getResources().getDimensionPixelSize(R.dimen.tab_switcher_menu_width);
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/top/TabSwitcherActionMenuRenderTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/top/TabSwitcherActionMenuRenderTest.java index c07ba630..b9dfe24ec 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/top/TabSwitcherActionMenuRenderTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/toolbar/top/TabSwitcherActionMenuRenderTest.java
@@ -88,7 +88,9 @@ coordinator.buildMenuItems(), null); mView = coordinator.getContentView(); - ((ViewGroup) mView.getParent()).removeView(mView); + if (mView.getParent() != null) { + ((ViewGroup) mView.getParent()).removeView(mView); + } int popupWidth = activity.getResources().getDimensionPixelSize(R.dimen.tab_switcher_menu_width);
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsConverterTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsConverterTest.java index e486cef..f6540f57 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsConverterTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsConverterTest.java
@@ -8,7 +8,11 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; +import static org.chromium.chrome.browser.browserservices.digitalgoods.ConsumeConverter.PARAM_CONSUME_PURCHASE_TOKEN; +import static org.chromium.chrome.browser.browserservices.digitalgoods.ConsumeConverter.RESPONSE_CONSUME; +import static org.chromium.chrome.browser.browserservices.digitalgoods.ConsumeConverter.RESPONSE_CONSUME_RESPONSE_CODE; import static org.chromium.chrome.browser.browserservices.digitalgoods.DigitalGoodsConverter.PLAY_BILLING_ITEM_ALREADY_OWNED; import static org.chromium.chrome.browser.browserservices.digitalgoods.DigitalGoodsConverter.PLAY_BILLING_ITEM_NOT_OWNED; import static org.chromium.chrome.browser.browserservices.digitalgoods.DigitalGoodsConverter.PLAY_BILLING_ITEM_UNAVAILABLE; @@ -26,11 +30,16 @@ import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.payments.mojom.BillingResponseCode; +import org.chromium.payments.mojom.DigitalGoods.Consume_Response; import org.chromium.payments.mojom.DigitalGoods.GetDetails_Response; +import org.chromium.payments.mojom.DigitalGoods.ListPurchaseHistory_Response; import org.chromium.payments.mojom.DigitalGoods.ListPurchases_Response; import org.chromium.payments.mojom.ItemDetails; +import org.chromium.payments.mojom.ItemType; import org.chromium.payments.mojom.PurchaseReference; +import java.util.concurrent.atomic.AtomicInteger; + /** * Tests for {@link DigitalGoodsConverterTest}. */ @@ -62,24 +71,26 @@ ItemDetails item = GetDetailsConverter.convertItemDetails(bundle); assertItemDetails(item, id, title, desc, currency, value); - assertSubsItemDetails(item, null, null, null, null, null); + assertOptionalItemDetails(item, null, null, null, null, null, null, null, 0); } @Test - public void convertItemDetails_subscriptions() { + public void convertItemDetails_optional() { + String iconUrl = "https://www.example.com/image.png"; String subsPeriod = "2 weeks"; String freeTrialPeriod = "1 week"; String introPriceCurrency = "GBP"; String introPriceValue = "3.0"; String introPricePeriod = "1 month"; + int introPriceCycles = 4; Bundle bundle = GetDetailsConverter.createItemDetailsBundle("id", "Title", "desc", "GBP", - "10.0", subsPeriod, freeTrialPeriod, introPriceCurrency, introPriceValue, - introPricePeriod); + "10.0", "subs", iconUrl, subsPeriod, freeTrialPeriod, introPriceCurrency, + introPriceValue, introPricePeriod, introPriceCycles); ItemDetails item = GetDetailsConverter.convertItemDetails(bundle); - assertSubsItemDetails(item, subsPeriod, freeTrialPeriod, introPriceCurrency, - introPriceValue, introPricePeriod); + assertOptionalItemDetails(item, "subs", iconUrl, subsPeriod, freeTrialPeriod, + introPriceCurrency, introPriceValue, introPricePeriod, introPriceCycles); } /** @@ -101,20 +112,22 @@ TrustedWebActivityCallback convertedCallback = GetDetailsConverter.convertCallback(callback); + String iconUrl = "https://www.example.com/image.png"; int responseCode = 0; Bundle args = GetDetailsConverter.createResponseBundle(responseCode, GetDetailsConverter.createItemDetailsBundle("1", "t1", "d1", "c1", "v1"), - GetDetailsConverter.createItemDetailsBundle( - "2", "t2", "d2", "c2", "v2", "sp2", "ftp2", "ipc2", "ipv2", "ipp2")); + GetDetailsConverter.createItemDetailsBundle("2", "t2", "d2", "c2", "v2", "inapp", + iconUrl, "sp2", "ftp2", "ipc2", "ipv2", "ipp2", 4)); convertedCallback.onExtraCallback(GetDetailsConverter.RESPONSE_COMMAND, args); assertEquals(DigitalGoodsConverter.convertResponseCode(responseCode, Bundle.EMPTY), state.responseCode); assertItemDetails(state.results[0], "1", "t1", "d1", "c1", "v1"); - assertSubsItemDetails(state.results[0], null, null, null, null, null); + assertOptionalItemDetails(state.results[0], null, null, null, null, null, null, null, 0); assertItemDetails(state.results[1], "2", "t2", "d2", "c2", "v2"); - assertSubsItemDetails(state.results[1], "sp2", "ftp2", "ipc2", "ipv2", "ipp2"); + assertOptionalItemDetails( + state.results[1], "inapp", iconUrl, "sp2", "ftp2", "ipc2", "ipv2", "ipp2", 4); } private static void assertItemDetails(ItemDetails item, String id, String title, String desc, @@ -126,9 +139,27 @@ assertEquals(value, item.price.value); } - private static void assertSubsItemDetails(ItemDetails item, @Nullable String subsPeriod, - @Nullable String freeTrialPeriod, @Nullable String introPriceCurrency, - @Nullable String introPriceValue, @Nullable String intoPricePeriod) { + private static void assertOptionalItemDetails(ItemDetails item, @Nullable String type, + @Nullable String iconUrl, @Nullable String subsPeriod, @Nullable String freeTrialPeriod, + @Nullable String introPriceCurrency, @Nullable String introPriceValue, + @Nullable String intoPricePeriod, int introPriceCycles) { + if (type == null) { + assertEquals(ItemType.UNKNOWN, item.type); + } else if ("subs".equals(type)) { + assertEquals(ItemType.SUBSCRIPTION, item.type); + } else if ("inapp".equals(type)) { + assertEquals(ItemType.PRODUCT, item.type); + } else { + fail("Invalid item type"); + } + + if (iconUrl == null) { + assertEquals(0, item.iconUrls.length); + } else { + assertEquals(1, item.iconUrls.length); + assertEquals(iconUrl, item.iconUrls[0].url); + } + assertEquals(subsPeriod, item.subscriptionPeriod); assertEquals(freeTrialPeriod, item.freeTrialPeriod); if (introPriceCurrency == null || introPriceValue == null) { @@ -138,21 +169,17 @@ assertEquals(introPriceValue, item.introductoryPrice.value); } assertEquals(intoPricePeriod, item.introductoryPricePeriod); + assertEquals(introPriceCycles, item.introductoryPriceCycles); } @Test - public void convertListPurchases() { + public void convertPurchaseReference() { String id = "id"; String token = "token"; - boolean acknowledged = true; - int state = 2; - long time = 1234L; - boolean autoRenew = true; - Bundle bundle = ListPurchasesConverter.createPurchaseDetailsBundle( - id, token, acknowledged, state, time, autoRenew); + Bundle bundle = ListPurchasesConverter.createPurchaseReferenceBundle(id, token); - PurchaseReference reference = ListPurchasesConverter.convertPurchaseDetails(bundle); + PurchaseReference reference = ListPurchasesConverter.convertPurchaseReference(bundle); assertPurchaseReference(reference, id, token); } @@ -164,21 +191,20 @@ @Test public void convertListPurchases_wrongTypes() { - Bundle validBundle = ListPurchasesConverter.createPurchaseDetailsBundle( - "id", "token", true, 1, 2L, true); + Bundle validBundle = ListPurchasesConverter.createPurchaseReferenceBundle("id", "token"); - assertNotNull(ListPurchasesConverter.convertPurchaseDetails(validBundle)); + assertNotNull(ListPurchasesConverter.convertPurchaseReference(validBundle)); { Bundle bundle = validBundle.deepCopy(); bundle.putInt(ListPurchasesConverter.KEY_ITEM_ID, 5); - assertNull(ListPurchasesConverter.convertPurchaseDetails(bundle)); + assertNull(ListPurchasesConverter.convertPurchaseReference(bundle)); } { Bundle bundle = validBundle.deepCopy(); bundle.putInt(ListPurchasesConverter.KEY_PURCHASE_TOKEN, 5); - assertNull(ListPurchasesConverter.convertPurchaseDetails(bundle)); + assertNull(ListPurchasesConverter.convertPurchaseReference(bundle)); } } @@ -195,8 +221,8 @@ int responseCode = 0; Bundle args = ListPurchasesConverter.createResponseBundle(responseCode, - ListPurchasesConverter.createPurchaseDetailsBundle("1", "t1", true, 1, 1L, true), - ListPurchasesConverter.createPurchaseDetailsBundle("2", "t2", false, 2, 2L, false)); + ListPurchasesConverter.createPurchaseReferenceBundle("1", "t1"), + ListPurchasesConverter.createPurchaseReferenceBundle("2", "t2")); convertedCallback.onExtraCallback(ListPurchasesConverter.RESPONSE_COMMAND, args); @@ -207,6 +233,60 @@ } @Test + public void convertListPurchaseHistoryCallback() { + TestState<PurchaseReference> state = new TestState<>(); + ListPurchaseHistory_Response callback = (responseCode, purchaseDetails) -> { + state.responseCode = responseCode; + state.results = purchaseDetails; + }; + + TrustedWebActivityCallback convertedCallback = + ListPurchaseHistoryConverter.convertCallback(callback); + + int responseCode = 0; + Bundle args = ListPurchaseHistoryConverter.createResponseBundle(responseCode, + ListPurchasesConverter.createPurchaseReferenceBundle("1", "t1"), + ListPurchasesConverter.createPurchaseReferenceBundle("2", "t2")); + + convertedCallback.onExtraCallback(ListPurchaseHistoryConverter.RESPONSE_COMMAND, args); + + assertEquals(DigitalGoodsConverter.convertResponseCode(responseCode, Bundle.EMPTY), + state.responseCode); + assertPurchaseReference(state.results[0], "1", "t1"); + assertPurchaseReference(state.results[1], "2", "t2"); + } + + @Test + public void convertConsumeParams() { + String token = "abcdef"; + + Bundle b = ConsumeConverter.convertParams(token); + + String outToken = b.getString(PARAM_CONSUME_PURCHASE_TOKEN); + + assertEquals(token, outToken); + } + + @Test + public void convertConsumeCallback() { + // Since there's only one value we want to get out of the callback, we can use Atomic* + // instead of creating a new class. + AtomicInteger state = new AtomicInteger(); + + Consume_Response callback = (responseCode) -> state.set(responseCode); + + TrustedWebActivityCallback convertedCallback = ConsumeConverter.convertCallback(callback); + + Bundle args = new Bundle(); + int responseCode = 0; + args.putInt(RESPONSE_CONSUME_RESPONSE_CODE, responseCode); + + convertedCallback.onExtraCallback(RESPONSE_CONSUME, args); + + assertEquals(responseCode, state.get()); + } + + @Test public void convertResponseCodes_v0() { Bundle args = Bundle.EMPTY;
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsUnitTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsUnitTest.java new file mode 100644 index 0000000..8ae5a54 --- /dev/null +++ b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsUnitTest.java
@@ -0,0 +1,118 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.chrome.browser.browserservices.digitalgoods; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.robolectric.annotation.Config; + +import org.chromium.base.test.BaseRobolectricTestRunner; +import org.chromium.base.test.util.CallbackHelper; +import org.chromium.payments.mojom.BillingResponseCode; +import org.chromium.url.GURL; + +import java.util.concurrent.TimeoutException; + +/** + * Tests the flow from DigitalGoodsImpl, through DigitalGoodsAdapter and the converts to the + * TrustedWebActivityClient and back again. It uses a mock TrustedWebActivityClient. + */ +@RunWith(BaseRobolectricTestRunner.class) +@Config(manifest = Config.NONE) +public class DigitalGoodsUnitTest { + private final DigitalGoodsImpl.Delegate mDelegate = () -> { + GURL url = Mockito.mock(GURL.class); + when(url.getSpec()).thenReturn("http://www.example.com/"); + return url; + }; + private final MockTrustedWebActivityClient mClient = new MockTrustedWebActivityClient(); + + private DigitalGoodsImpl mDigitalGoods; + + @Before + public void setUp() { + mDigitalGoods = + new DigitalGoodsImpl(new DigitalGoodsAdapter(mClient.getClient()), mDelegate); + } + + @Test + public void getDetails() throws TimeoutException { + CallbackHelper callbackHelper = new CallbackHelper(); + mDigitalGoods.getDetails(new String[] {"token 1", "token 2"}, (code, details) -> { + assertEquals(2, details.length); + + assertEquals("id1", details[0].itemId); + assertEquals("id2", details[1].itemId); + + callbackHelper.notifyCalled(); + }); + mClient.runCallback(); + + callbackHelper.waitForCallback(0); + } + + @Test + public void listPurchases() throws TimeoutException { + CallbackHelper callbackHelper = new CallbackHelper(); + mDigitalGoods.listPurchases((code, purchases) -> { + callbackHelper.notifyCalled(); + + assertEquals("id3", purchases[0].itemId); + assertEquals("id4", purchases[1].itemId); + }); + mClient.runCallback(); + + callbackHelper.waitForCallback(0); + } + + @Test + public void listPurchaseHistory() throws TimeoutException { + CallbackHelper callbackHelper = new CallbackHelper(); + mDigitalGoods.listPurchaseHistory((code, purchases) -> { + assertEquals("id4", purchases[0].itemId); + assertEquals("id3", purchases[1].itemId); + + callbackHelper.notifyCalled(); + }); + mClient.runCallback(); + + callbackHelper.waitForCallback(0); + } + + @Test + public void consume() throws TimeoutException { + CallbackHelper callbackHelper = new CallbackHelper(); + mDigitalGoods.consume("token", (code) -> { + assertEquals(BillingResponseCode.OK, (int) code); + + callbackHelper.notifyCalled(); + }); + + mClient.runCallback(); + + callbackHelper.waitForCallback(0); + } + + @Test + public void consume_oldClient() throws TimeoutException { + mClient.setVersion(1); + + CallbackHelper callbackHelper = new CallbackHelper(); + mDigitalGoods.consume("token", (code) -> { + assertEquals(BillingResponseCode.OK, (int) code); + + callbackHelper.notifyCalled(); + }); + + mClient.runCallback(); + + callbackHelper.waitForCallback(0); + } +}
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/digitalgoods/MockTrustedWebActivityClient.java b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/digitalgoods/MockTrustedWebActivityClient.java new file mode 100644 index 0000000..7ef16427 --- /dev/null +++ b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/digitalgoods/MockTrustedWebActivityClient.java
@@ -0,0 +1,144 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.chrome.browser.browserservices.digitalgoods; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doAnswer; + +import static org.chromium.chrome.browser.browserservices.digitalgoods.DigitalGoodsConverter.PLAY_BILLING_OK; + +import android.os.Bundle; +import android.os.RemoteException; + +import androidx.browser.trusted.TrustedWebActivityCallback; + +import org.mockito.Mockito; + +import org.chromium.chrome.browser.browserservices.TrustedWebActivityClient; +import org.chromium.chrome.browser.browserservices.TrustedWebActivityClientWrappers; +import org.chromium.components.embedder_support.util.Origin; + +/** + * Helper class for {@link DigitalGoodsUnitTest} - it pretends to be a TrustedWebActivityClient + * talking to the Digital Goods handler in the TWA shell, providing hardcoded responses. + */ +public class MockTrustedWebActivityClient { + private TrustedWebActivityClientWrappers.Connection mConnection; + private TrustedWebActivityClient mClient; + private Runnable mCallback; + private int mVersion = 2; + + private static final Bundle ITEM1 = GetDetailsConverter.createItemDetailsBundle( + "id1", "title 1", "description 1", "GBP", "20"); + private static final Bundle ITEM2 = GetDetailsConverter.createItemDetailsBundle("id2", + "title 2", "description 2", "GBP", "30", "subs", "https://www.example.com/image.png", + "2 weeks", "month", "GBP", "20", "week", 2); + + private static final Bundle PURCHASE1 = + ListPurchasesConverter.createPurchaseReferenceBundle("id3", "abc"); + private static final Bundle PURCHASE2 = + ListPurchasesConverter.createPurchaseReferenceBundle("id4", "def"); + + public MockTrustedWebActivityClient() { + mConnection = Mockito.mock(TrustedWebActivityClientWrappers.Connection.class); + mClient = Mockito.mock(TrustedWebActivityClient.class); + + doAnswer(invocation -> { + TrustedWebActivityClient.ExecutionCallback callback = invocation.getArgument(1); + + callback.onConnected(Mockito.mock(Origin.class), mConnection); + + return null; + }) + .when(mClient) + .connectAndExecute(any(), any()); + + try { + doAnswer(invocation -> { + String command = invocation.getArgument(0); + Bundle args = invocation.getArgument(1); + TrustedWebActivityCallback callback = invocation.getArgument(2); + + return handleWrapper(command, args, callback); + }) + .when(mConnection) + .sendExtraCommand(any(), any(), any()); + } catch (RemoteException e) { + // This ugliness is because we're mocking a method that could throw an exception. + throw new RuntimeException(e); + } + } + + /** Returns a mocked {@link TrustedWebActivityClient} to be used in tests. */ + public TrustedWebActivityClient getClient() { + return mClient; + } + + /** Runs the pending callback. */ + public void runCallback() { + mCallback.run(); + mCallback = null; + } + + /** Changes the clients behaviour to simulate older TWA shells. */ + public void setVersion(int version) { + mVersion = version; + } + + private boolean handle(String command, Bundle args, TrustedWebActivityCallback callback) { + // At this point, pretend we're in the TWA shell. + switch (command) { + case "getDetails": + mCallback = () -> { + callback.onExtraCallback("getDetails.response", + GetDetailsConverter.createResponseBundle( + PLAY_BILLING_OK, ITEM1, ITEM2)); + }; + return true; + case "listPurchases": + mCallback = () -> { + callback.onExtraCallback("listPurchases.response", + ListPurchasesConverter.createResponseBundle( + PLAY_BILLING_OK, PURCHASE1, PURCHASE2)); + }; + return true; + case "listPurchaseHistory": + // Version 1 clients did not have purchase history. + if (mVersion == 1) return false; + mCallback = () -> { + // Swap the order of PURCHASE1 and PURCHASE2 as an easy way to make sure the + // correct branch of this switch statement is executed. + callback.onExtraCallback("listPurchaseHistory.response", + ListPurchaseHistoryConverter.createResponseBundle( + PLAY_BILLING_OK, PURCHASE2, PURCHASE1)); + }; + return true; + case "consume": + // Version 1 clients did not have consume. + if (mVersion == 1) return false; + mCallback = () -> { + callback.onExtraCallback("consume.response", + ConsumeConverter.createResponseBundle(PLAY_BILLING_OK)); + }; + return true; + case "acknowledge": + // Only version 1 clients have acknowledge. + if (mVersion != 1) return false; + mCallback = () -> { + callback.onExtraCallback("acknowledge.response", + AcknowledgeConverter.createResponseBundle(PLAY_BILLING_OK)); + }; + return true; + } + + return false; + } + + private Bundle handleWrapper(String command, Bundle args, TrustedWebActivityCallback callback) { + Bundle bundle = new Bundle(); + bundle.putBoolean("success", handle(command, args, callback)); + return bundle; + } +}
diff --git a/chrome/app/chromeos_strings.grdp b/chrome/app/chromeos_strings.grdp index a132bde..ebcf0d4 100644 --- a/chrome/app/chromeos_strings.grdp +++ b/chrome/app/chromeos_strings.grdp
@@ -4273,6 +4273,21 @@ <message name="IDS_LACROS_DATA_MIGRATION_SCREEN_SKIP_SUGGESTION" desc="Message shown when skip button is visible."> This is taking longer than expected, you can skip or wait until it's done. </message> + <message name="IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_TITLE" desc="Shown if the lacros migration fails."> + Chrome browser could not be updated + </message> + <message name="IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_LOW_DISK_SPACE" desc="Shown if the lacros migration failed with low disk space error."> + There isn't enough space on this device to complete this update. Clean up <ph name="NECESSARY_SPACE">$1<ex>10 MB</ex></ph> on your device and try again from your Chrome browser. + </message> + <message name="IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_SUBTITLE" desc="Shown if the lacros migration failed other than low disk space error."> + You can try again later in Chrome. + </message> + <message name="IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_CANCEL_BUTTON" desc="Text button shown on the lacros data migration failure to cancel everything"> + Cancel + </message> + <message name="IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_GOTO_FILES_BUTTON" desc="Text button shown on the lacros data migration failure to open files.app in the following user session"> + Go to files + </message> <!-- Lacros data migration triggering UI. --> <message name="IDS_LACROS_DATA_MIGRATION_RELAUNCH" desc="Message shown as a menu to relaunch Chrome in order to trigger data migration.">
diff --git a/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_CANCEL_BUTTON.png.sha1 b/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_CANCEL_BUTTON.png.sha1 new file mode 100644 index 0000000..52efc021 --- /dev/null +++ b/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_CANCEL_BUTTON.png.sha1
@@ -0,0 +1 @@ +6c6cadecf63cfcde457d87a9e1d9bb1e77bfde93 \ No newline at end of file
diff --git a/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_GOTO_FILES_BUTTON.png.sha1 b/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_GOTO_FILES_BUTTON.png.sha1 new file mode 100644 index 0000000..52efc021 --- /dev/null +++ b/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_GOTO_FILES_BUTTON.png.sha1
@@ -0,0 +1 @@ +6c6cadecf63cfcde457d87a9e1d9bb1e77bfde93 \ No newline at end of file
diff --git a/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_LOW_DISK_SPACE.png.sha1 b/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_LOW_DISK_SPACE.png.sha1 new file mode 100644 index 0000000..52efc021 --- /dev/null +++ b/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_LOW_DISK_SPACE.png.sha1
@@ -0,0 +1 @@ +6c6cadecf63cfcde457d87a9e1d9bb1e77bfde93 \ No newline at end of file
diff --git a/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_SUBTITLE.png.sha1 b/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_SUBTITLE.png.sha1 new file mode 100644 index 0000000..6f2e4ea --- /dev/null +++ b/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_SUBTITLE.png.sha1
@@ -0,0 +1 @@ +ecff12674ec971dbedf9a43d9368296f77c94c9c \ No newline at end of file
diff --git a/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_TITLE.png.sha1 b/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_TITLE.png.sha1 new file mode 100644 index 0000000..52efc021 --- /dev/null +++ b/chrome/app/chromeos_strings_grdp/IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_TITLE.png.sha1
@@ -0,0 +1 @@ +6c6cadecf63cfcde457d87a9e1d9bb1e77bfde93 \ No newline at end of file
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 66053f8..f1fa69b 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd
@@ -6448,12 +6448,15 @@ <message name="IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_BODY_LINE_2" desc="Line 2 of Modular NTP Desktop v1 First Run Experience's body."> See all card options in <ph name="BEGIN_LINK"><a is="action-link" id="customizeChromeLink" on-click="onCustomizeModuleFre_"></ph>Customize Chrome<ph name="END_LINK"></a></ph> </message> - <message name="IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_IN_BUTTON" desc="Opt in button for Modular NTP Desktop v1 First Run Experience."> + <message name="IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_IN" desc="Opt in button for Modular NTP Desktop v1 First Run Experience."> Got it </message> - <message name="IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_OUT_BUTTON" desc="Opt out button for Modular NTP Desktop v1 First Run Experience."> + <message name="IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_OUT" desc="Opt out button for Modular NTP Desktop v1 First Run Experience."> Don't show </message> + <message name="IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_OUT_TOAST" desc="Opt out toast for Modular NTP Desktop v1 First Run Experience."> + You won't see cards on this page again + </message> <!-- Extensions NTP Middle Slot Promo --> <message name="IDS_EXTENSIONS_PROMO_PERFORMANCE">
diff --git a/chrome/app/generated_resources_grd/IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_IN_BUTTON.png.sha1 b/chrome/app/generated_resources_grd/IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_IN.png.sha1 similarity index 100% rename from chrome/app/generated_resources_grd/IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_IN_BUTTON.png.sha1 rename to chrome/app/generated_resources_grd/IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_IN.png.sha1
diff --git a/chrome/app/generated_resources_grd/IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_IN_BUTTON.png.sha1 b/chrome/app/generated_resources_grd/IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_OUT.png.sha1 similarity index 100% copy from chrome/app/generated_resources_grd/IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_IN_BUTTON.png.sha1 copy to chrome/app/generated_resources_grd/IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_OUT.png.sha1
diff --git a/chrome/app/generated_resources_grd/IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_OUT_BUTTON.png.sha1 b/chrome/app/generated_resources_grd/IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_OUT_BUTTON.png.sha1 deleted file mode 100644 index c55ff68..0000000 --- a/chrome/app/generated_resources_grd/IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_OUT_BUTTON.png.sha1 +++ /dev/null
@@ -1 +0,0 @@ -61af418dc5d6c17dd8a771b651111672b4aeb148 \ No newline at end of file
diff --git a/chrome/app/generated_resources_grd/IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_OUT_TOAST.png.sha1 b/chrome/app/generated_resources_grd/IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_OUT_TOAST.png.sha1 new file mode 100644 index 0000000..c8b9afd --- /dev/null +++ b/chrome/app/generated_resources_grd/IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_OUT_TOAST.png.sha1
@@ -0,0 +1 @@ +4b5b7eb12bd6a96947e07314edfd66439e02c670 \ No newline at end of file
diff --git a/chrome/app/vector_icons/BUILD.gn b/chrome/app/vector_icons/BUILD.gn index e573027..cc166ca 100644 --- a/chrome/app/vector_icons/BUILD.gn +++ b/chrome/app/vector_icons/BUILD.gn
@@ -261,6 +261,7 @@ "google_chrome/google_keep_note.icon", "google_chrome/google_lens_full_logo.icon", "google_chrome/google_lens_full_logo_dark.icon", + "google_chrome/google_password_manager.icon", "google_chrome/google_pay_logo.icon", "google_chrome/google_sites.icon", "google_chrome/google_super_g.icon",
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index 863c9e08..a07110b 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn
@@ -5297,6 +5297,9 @@ "//components/arc/common", "//ui/platform_window", ] + + # component builds are not compatible on device. + assert(!is_chromeos_device || !is_component_build) } if (is_chromeos_ash || is_chromeos_lacros) { @@ -7496,7 +7499,7 @@ deps += [ "//chrome/browser/resources/discards:discards_resources_gen", "//chrome/browser/resources/gaia_auth_host:modulize", - "//chrome/browser/resources/inline_login:web_components", + "//chrome/browser/resources/inline_login:components", "//chrome/browser/resources/management:web_components", "//chrome/browser/resources/signin:web_components", "//chrome/browser/ui/webui/discards:mojo_bindings_js", @@ -7517,6 +7520,7 @@ "//chrome/browser/resources/chromeos/account_manager:web_components", "//chrome/browser/resources/chromeos/account_manager/components:web_components", "//chrome/browser/resources/chromeos/add_supervision:web_components", + "//chrome/browser/resources/chromeos/arc_account_picker:web_components", "//chrome/browser/resources/chromeos/crostini_installer:crostini_installer", "//chrome/browser/resources/chromeos/crostini_installer:web_components", "//chrome/browser/resources/chromeos/crostini_upgrader:web_components",
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 937b23c..1ef493c 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc
@@ -2046,6 +2046,34 @@ {"Default browser", kFeatureNotificationGuide_default_browser, std::size(kFeatureNotificationGuide_default_browser), nullptr}, }; + +const FeatureEntry::FeatureParam + kNotificationPermissionRationale_show_dialog_next_start_text_variant[] = { + {"always_show_rationale_before_requesting_permission", "true"}, + {"notification_permission_dialog_text_variant_2", "true"}, + {"permission_request_interval_days", "0"}, +}; + +const FeatureEntry::FeatureParam + kNotificationPermissionRationale_show_dialog_next_start[] = { + {"always_show_rationale_before_requesting_permission", "true"}, + {"notification_permission_dialog_text_variant_2", "false"}, + {"permission_request_interval_days", "0"}, +}; + +const FeatureEntry::FeatureVariation + kNotificationPermissionRationaleVariations[] = { + {"- Show rationale dialog on next startup", + kNotificationPermissionRationale_show_dialog_next_start, + std::size(kNotificationPermissionRationale_show_dialog_next_start), + nullptr}, + {"- Show rationale dialog on next startup - alternative copy", + kNotificationPermissionRationale_show_dialog_next_start_text_variant, + std::size( + kNotificationPermissionRationale_show_dialog_next_start_text_variant), + nullptr}, +}; + const FeatureEntry::FeatureParam kWebFeed_accelerator[] = { {"intro_style", "accelerator"}}; @@ -4122,6 +4150,13 @@ feature_guide::features::kFeatureNotificationGuide, kFeatureNotificationGuideVariations, "FeatureNotificationGuide")}, + {"notification-permission-rationale-dialog", + flag_descriptions::kNotificationPermissionRationaleName, + flag_descriptions::kNotificationPermissionRationaleDescription, kOsAndroid, + FEATURE_WITH_PARAMS_VALUE_TYPE( + chrome::android::kNotificationPermissionVariant, + kNotificationPermissionRationaleVariations, + "NotificationPermissionVariant")}, {"feature-notification-guide-skip-check-for-low-engaged-users", flag_descriptions:: kFeatureNotificationGuideSkipCheckForLowEngagedUsersName, @@ -4439,6 +4474,10 @@ flag_descriptions::kVirtualKeyboardBorderedKeyName, flag_descriptions::kVirtualKeyboardBorderedKeyDescription, kOsCrOS, FEATURE_VALUE_TYPE(chromeos::features::kVirtualKeyboardBorderedKey)}, + {"enable-cros-virtual-keyboard-multitouch", + flag_descriptions::kVirtualKeyboardMultitouchName, + flag_descriptions::kVirtualKeyboardMultitouchDescription, kOsCrOS, + FEATURE_VALUE_TYPE(chromeos::features::kVirtualKeyboardMultitouch)}, {"enable-experimental-accessibility-dictation-extension", flag_descriptions::kExperimentalAccessibilityDictationExtensionName, flag_descriptions::kExperimentalAccessibilityDictationExtensionDescription, @@ -8279,6 +8318,13 @@ FEATURE_VALUE_TYPE(apps::features::kIntentChipAppIcon)}, #endif +#if BUILDFLAG(IS_CHROMEOS_ASH) + {"launcher-lacros-integration", + flag_descriptions::kLauncherLacrosIntegrationName, + flag_descriptions::kLauncherLacrosIntegrationDescription, kOsCrOS, + FEATURE_VALUE_TYPE(app_list_features::kLauncherLacrosIntegration)}, +#endif + // NOTE: Adding a new flag requires adding a corresponding entry to enum // "LoginCustomFlags" in tools/metrics/histograms/enums.xml. See "Flag // Histograms" in tools/metrics/histograms/README.md (run the
diff --git a/chrome/browser/apps/app_service/app_service_proxy_base.cc b/chrome/browser/apps/app_service/app_service_proxy_base.cc index 986bf7b..fdb31abf 100644 --- a/chrome/browser/apps/app_service/app_service_proxy_base.cc +++ b/chrome/browser/apps/app_service/app_service_proxy_base.cc
@@ -666,7 +666,17 @@ void AppServiceProxyBase::OnApps(std::vector<AppPtr> deltas, AppType app_type, bool should_notify_initialized) { - // TODO(crbug.com/1253250): add RemovePreferredApp related code. + if (app_service_.is_connected()) { + for (const auto& delta : deltas) { + if (delta->readiness != Readiness::kUnknown && + !apps_util::IsInstalled(delta->readiness)) { + // TODO(crbug.com/1253250): Remove dependency on mojom AppService. + app_service_->RemovePreferredApp( + ConvertAppTypeToMojomAppType(delta->app_type), delta->app_id); + } + } + } + app_registry_cache_.OnApps(std::move(deltas), app_type, should_notify_initialized); }
diff --git a/chrome/browser/apps/app_service/app_service_proxy_lacros.cc b/chrome/browser/apps/app_service/app_service_proxy_lacros.cc index 522c966..bdf884b 100644 --- a/chrome/browser/apps/app_service/app_service_proxy_lacros.cc +++ b/chrome/browser/apps/app_service/app_service_proxy_lacros.cc
@@ -37,99 +37,6 @@ namespace apps { -AppServiceProxyLacros::InnerIconLoader::InnerIconLoader( - AppServiceProxyLacros* host) - : host_(host), overriding_icon_loader_for_testing_(nullptr) {} - -absl::optional<IconKey> AppServiceProxyLacros::InnerIconLoader::GetIconKey( - const std::string& app_id) { - if (overriding_icon_loader_for_testing_) { - return overriding_icon_loader_for_testing_->GetIconKey(app_id); - } - - if (!host_->crosapi_receiver_.is_bound()) { - return absl::nullopt; - } - - absl::optional<IconKey> icon_key; - host_->app_registry_cache_.ForApp( - app_id, - [&icon_key](const AppUpdate& update) { icon_key = update.IconKey(); }); - return icon_key; -} - -std::unique_ptr<IconLoader::Releaser> -AppServiceProxyLacros::InnerIconLoader::LoadIconFromIconKey( - AppType app_type, - const std::string& app_id, - const IconKey& icon_key, - IconType icon_type, - int32_t size_hint_in_dip, - bool allow_placeholder_icon, - apps::LoadIconCallback callback) { - if (overriding_icon_loader_for_testing_) { - return overriding_icon_loader_for_testing_->LoadIconFromIconKey( - app_type, app_id, icon_key, icon_type, size_hint_in_dip, - allow_placeholder_icon, std::move(callback)); - } - - auto* service = chromeos::LacrosService::Get(); - - if (!service || !service->IsAvailable<crosapi::mojom::AppServiceProxy>()) { - std::move(callback).Run(std::make_unique<IconValue>()); - } else if (host_->crosapi_app_service_proxy_version_ < - int{crosapi::mojom::AppServiceProxy::MethodMinVersions:: - kLoadIconMinVersion}) { - LOG(WARNING) << "Ash AppServiceProxy version " - << host_->crosapi_app_service_proxy_version_ - << " does not support LoadIcon()."; - std::move(callback).Run(std::make_unique<IconValue>()); - } else { - service->GetRemote<crosapi::mojom::AppServiceProxy>()->LoadIcon( - app_id, icon_key.Clone(), icon_type, size_hint_in_dip, - std::move(callback)); - } - return nullptr; -} - -std::unique_ptr<IconLoader::Releaser> -AppServiceProxyLacros::InnerIconLoader::LoadIconFromIconKey( - apps::mojom::AppType app_type, - const std::string& app_id, - apps::mojom::IconKeyPtr icon_key, - apps::mojom::IconType icon_type, - int32_t size_hint_in_dip, - bool allow_placeholder_icon, - apps::mojom::Publisher::LoadIconCallback callback) { - if (overriding_icon_loader_for_testing_) { - return overriding_icon_loader_for_testing_->LoadIconFromIconKey( - app_type, app_id, std::move(icon_key), icon_type, size_hint_in_dip, - allow_placeholder_icon, std::move(callback)); - } - - auto* service = chromeos::LacrosService::Get(); - - if (!service || !service->IsAvailable<crosapi::mojom::AppServiceProxy>() || - !icon_key) { - std::move(callback).Run(apps::mojom::IconValue::New()); - } else if (host_->crosapi_app_service_proxy_version_ < - int{crosapi::mojom::AppServiceProxy::MethodMinVersions:: - kLoadIconMinVersion}) { - LOG(WARNING) << "Ash AppServiceProxy version " - << host_->crosapi_app_service_proxy_version_ - << " does not support LoadIcon()."; - std::move(callback).Run(apps::mojom::IconValue::New()); - } else { - service->GetRemote<crosapi::mojom::AppServiceProxy>()->LoadIcon( - app_id, - std::make_unique<IconKey>(icon_key->timeline, icon_key->resource_id, - icon_key->icon_effects), - ConvertMojomIconTypeToIconType(icon_type), size_hint_in_dip, - IconValueToMojomIconValueCallback(std::move(callback))); - } - return nullptr; -} - AppServiceProxyLacros::AppServiceProxyLacros(Profile* profile) : inner_icon_loader_(this), icon_coalescer_(&inner_icon_loader_), @@ -144,8 +51,7 @@ std::make_unique<apps::BrowserAppInstanceTracker>( profile_, app_registry_cache_); auto& registry = - chromeos::LacrosService::Get() - ->GetRemote<crosapi::mojom::BrowserAppInstanceRegistry>(); + service->GetRemote<crosapi::mojom::BrowserAppInstanceRegistry>(); DCHECK(registry); browser_app_instance_forwarder_ = std::make_unique<apps::BrowserAppInstanceForwarder>( @@ -156,46 +62,6 @@ AppServiceProxyLacros::~AppServiceProxyLacros() = default; -void AppServiceProxyLacros::Initialize() { - if (!IsValidProfile()) { - return; - } - - browser_app_launcher_ = std::make_unique<apps::BrowserAppLauncher>(profile_); - - if (profile_->IsMainProfile()) { - lacros_web_apps_controller_ = - std::make_unique<web_app::LacrosWebAppsController>(profile_); - lacros_web_apps_controller_->Init(); - } - - // Make the chrome://app-icon/ resource available. - content::URLDataSource::Add(profile_, - std::make_unique<apps::AppIconSource>(profile_)); - - auto* service = chromeos::LacrosService::Get(); - - if (!service || !service->IsAvailable<crosapi::mojom::AppServiceProxy>()) { - return; - } - - crosapi_app_service_proxy_version_ = - service->GetInterfaceVersion(crosapi::mojom::AppServiceProxy::Uuid_); - - if (crosapi_app_service_proxy_version_ < - int{crosapi::mojom::AppServiceProxy::MethodMinVersions:: - kRegisterAppServiceSubscriberMinVersion}) { - LOG(WARNING) << "Ash AppServiceProxy version " - << crosapi_app_service_proxy_version_ - << " does not support RegisterAppServiceSubscriber()."; - return; - } - - service->GetRemote<crosapi::mojom::AppServiceProxy>() - ->RegisterAppServiceSubscriber( - crosapi_receiver_.BindNewPipeAndPassRemote()); -} - void AppServiceProxyLacros::ReInitializeForTesting(Profile* profile) { // Some test code creates a profile and profile-linked services, like the App // Service, before the profile is fully initialized. Such tests can call this @@ -207,20 +73,6 @@ Initialize(); } -bool AppServiceProxyLacros::IsValidProfile() { - if (!profile_) { - return false; - } - - // We only initialize the App Service for regular or guest profiles. Non-guest - // off-the-record profiles do not get an instance. - if (profile_->IsOffTheRecord() && !profile_->IsGuestSession()) { - return false; - } - - return true; -} - apps::AppRegistryCache& AppServiceProxyLacros::AppRegistryCache() { return app_registry_cache_; } @@ -279,9 +131,7 @@ int32_t event_flags, apps::mojom::LaunchSource launch_source, apps::mojom::WindowInfoPtr window_info) { - auto* service = chromeos::LacrosService::Get(); - - if (!service || !service->IsAvailable<crosapi::mojom::AppServiceProxy>()) { + if (!remote_crosapi_app_service_proxy_) { return; } @@ -294,7 +144,7 @@ return; } - service->GetRemote<crosapi::mojom::AppServiceProxy>()->Launch( + remote_crosapi_app_service_proxy_->Launch( CreateCrosapiLaunchParamsWithEventFlags(this, app_id, event_flags, launch_source, display::kInvalidDisplayId)); @@ -305,9 +155,7 @@ int32_t event_flags, apps::mojom::LaunchSource launch_source, apps::mojom::FilePathsPtr file_paths) { - auto* service = chromeos::LacrosService::Get(); - - if (!service || !service->IsAvailable<crosapi::mojom::AppServiceProxy>()) { + if (!remote_crosapi_app_service_proxy_) { return; } @@ -322,8 +170,7 @@ auto params = CreateCrosapiLaunchParamsWithEventFlags( this, app_id, event_flags, launch_source, display::kInvalidDisplayId); params->intent = apps_util::CreateCrosapiIntentForViewFiles(file_paths); - service->GetRemote<crosapi::mojom::AppServiceProxy>()->Launch( - std::move(params)); + remote_crosapi_app_service_proxy_->Launch(std::move(params)); } void AppServiceProxyLacros::LaunchAppWithIntent( @@ -333,9 +180,8 @@ apps::mojom::LaunchSource launch_source, apps::mojom::WindowInfoPtr window_info) { CHECK(intent); - auto* service = chromeos::LacrosService::Get(); - if (!service || !service->IsAvailable<crosapi::mojom::AppServiceProxy>()) { + if (!remote_crosapi_app_service_proxy_) { return; } @@ -353,8 +199,7 @@ window_info ? window_info->display_id : display::kInvalidDisplayId); params->intent = apps_util::ConvertAppServiceToCrosapiIntent(intent, profile_); - service->GetRemote<crosapi::mojom::AppServiceProxy>()->Launch( - std::move(params)); + remote_crosapi_app_service_proxy_->Launch(std::move(params)); } void AppServiceProxyLacros::LaunchAppWithUrl( @@ -369,9 +214,7 @@ void AppServiceProxyLacros::LaunchAppWithParams(AppLaunchParams&& params, LaunchCallback callback) { - auto* service = chromeos::LacrosService::Get(); - - if (!service || !service->IsAvailable<crosapi::mojom::AppServiceProxy>()) { + if (!remote_crosapi_app_service_proxy_) { return; } @@ -384,7 +227,7 @@ return; } - service->GetRemote<crosapi::mojom::AppServiceProxy>()->Launch( + remote_crosapi_app_service_proxy_->Launch( ConvertLaunchParamsToCrosapi(params, profile_)); // TODO(crbug.com/1244506): Add params on crosapi and implement this. @@ -439,6 +282,10 @@ NOTIMPLEMENTED(); } +void AppServiceProxyLacros::FlushMojoCallsForTesting() { + crosapi_receiver_.FlushForTesting(); +} + apps::IconLoader* AppServiceProxyLacros::OverrideInnerIconLoaderForTesting( apps::IconLoader* icon_loader) { apps::IconLoader* old = @@ -533,13 +380,7 @@ void AppServiceProxyLacros::AddPreferredApp( const std::string& app_id, const apps::mojom::IntentPtr& intent) { - auto* service = chromeos::LacrosService::Get(); - - if (!service) { - return; - } - - if (!service->IsAvailable<crosapi::mojom::AppServiceProxy>()) { + if (!remote_crosapi_app_service_proxy_) { return; } @@ -550,7 +391,7 @@ return; } - service->GetRemote<crosapi::mojom::AppServiceProxy>()->AddPreferredApp( + remote_crosapi_app_service_proxy_->AddPreferredApp( app_id, apps_util::ConvertAppServiceToCrosapiIntent(intent, profile_)); } @@ -569,6 +410,173 @@ NOTIMPLEMENTED(); } +web_app::LacrosWebAppsController* +AppServiceProxyLacros::LacrosWebAppsControllerForTesting() { + return lacros_web_apps_controller_.get(); +} + +void AppServiceProxyLacros::SetCrosapiAppServiceProxyForTesting( + crosapi::mojom::AppServiceProxy* proxy) { + remote_crosapi_app_service_proxy_ = proxy; + // Set the proxy version to the newest version for testing. + crosapi_app_service_proxy_version_ = + crosapi::mojom::AppServiceProxy::Version_; +} + +AppServiceProxyLacros::InnerIconLoader::InnerIconLoader( + AppServiceProxyLacros* host) + : host_(host), overriding_icon_loader_for_testing_(nullptr) {} + +absl::optional<IconKey> AppServiceProxyLacros::InnerIconLoader::GetIconKey( + const std::string& app_id) { + if (overriding_icon_loader_for_testing_) { + return overriding_icon_loader_for_testing_->GetIconKey(app_id); + } + + if (!host_->crosapi_receiver_.is_bound()) { + return absl::nullopt; + } + + absl::optional<IconKey> icon_key; + host_->app_registry_cache_.ForApp( + app_id, + [&icon_key](const AppUpdate& update) { icon_key = update.IconKey(); }); + return icon_key; +} + +std::unique_ptr<IconLoader::Releaser> +AppServiceProxyLacros::InnerIconLoader::LoadIconFromIconKey( + AppType app_type, + const std::string& app_id, + const IconKey& icon_key, + IconType icon_type, + int32_t size_hint_in_dip, + bool allow_placeholder_icon, + apps::LoadIconCallback callback) { + if (overriding_icon_loader_for_testing_) { + return overriding_icon_loader_for_testing_->LoadIconFromIconKey( + app_type, app_id, icon_key, icon_type, size_hint_in_dip, + allow_placeholder_icon, std::move(callback)); + } + + if (!host_->remote_crosapi_app_service_proxy_) { + std::move(callback).Run(std::make_unique<IconValue>()); + } else if (host_->crosapi_app_service_proxy_version_ < + int{crosapi::mojom::AppServiceProxy::MethodMinVersions:: + kLoadIconMinVersion}) { + LOG(WARNING) << "Ash AppServiceProxy version " + << host_->crosapi_app_service_proxy_version_ + << " does not support LoadIcon()."; + std::move(callback).Run(std::make_unique<IconValue>()); + } else { + host_->remote_crosapi_app_service_proxy_->LoadIcon( + app_id, icon_key.Clone(), icon_type, size_hint_in_dip, + std::move(callback)); + } + return nullptr; +} + +std::unique_ptr<IconLoader::Releaser> +AppServiceProxyLacros::InnerIconLoader::LoadIconFromIconKey( + apps::mojom::AppType app_type, + const std::string& app_id, + apps::mojom::IconKeyPtr icon_key, + apps::mojom::IconType icon_type, + int32_t size_hint_in_dip, + bool allow_placeholder_icon, + apps::mojom::Publisher::LoadIconCallback callback) { + if (overriding_icon_loader_for_testing_) { + return overriding_icon_loader_for_testing_->LoadIconFromIconKey( + app_type, app_id, std::move(icon_key), icon_type, size_hint_in_dip, + allow_placeholder_icon, std::move(callback)); + } + + if (!host_->remote_crosapi_app_service_proxy_ || !icon_key) { + std::move(callback).Run(apps::mojom::IconValue::New()); + } else if (host_->crosapi_app_service_proxy_version_ < + int{crosapi::mojom::AppServiceProxy::MethodMinVersions:: + kLoadIconMinVersion}) { + LOG(WARNING) << "Ash AppServiceProxy version " + << host_->crosapi_app_service_proxy_version_ + << " does not support LoadIcon()."; + std::move(callback).Run(apps::mojom::IconValue::New()); + } else { + host_->remote_crosapi_app_service_proxy_->LoadIcon( + app_id, + std::make_unique<IconKey>(icon_key->timeline, icon_key->resource_id, + icon_key->icon_effects), + ConvertMojomIconTypeToIconType(icon_type), size_hint_in_dip, + IconValueToMojomIconValueCallback(std::move(callback))); + } + return nullptr; +} + +bool AppServiceProxyLacros::IsValidProfile() { + if (!profile_) { + return false; + } + + // We only initialize the App Service for regular or guest profiles. Non-guest + // off-the-record profiles do not get an instance. + if (profile_->IsOffTheRecord() && !profile_->IsGuestSession()) { + return false; + } + + return true; +} + +void AppServiceProxyLacros::Initialize() { + if (remote_crosapi_app_service_proxy_) { + return; + } + + if (!IsValidProfile()) { + return; + } + + browser_app_launcher_ = std::make_unique<apps::BrowserAppLauncher>(profile_); + + if (profile_->IsMainProfile()) { + lacros_web_apps_controller_ = + std::make_unique<web_app::LacrosWebAppsController>(profile_); + lacros_web_apps_controller_->Init(); + } + + // Make the chrome://app-icon/ resource available. + content::URLDataSource::Add(profile_, + std::make_unique<apps::AppIconSource>(profile_)); + + auto* service = chromeos::LacrosService::Get(); + + if (!service || !service->IsAvailable<crosapi::mojom::AppServiceProxy>()) { + return; + } + + crosapi_app_service_proxy_version_ = + service->GetInterfaceVersion(crosapi::mojom::AppServiceProxy::Uuid_); + + if (crosapi_app_service_proxy_version_ < + int{crosapi::mojom::AppServiceProxy::MethodMinVersions:: + kRegisterAppServiceSubscriberMinVersion}) { + LOG(WARNING) << "Ash AppServiceProxy version " + << crosapi_app_service_proxy_version_ + << " does not support RegisterAppServiceSubscriber()."; + return; + } + + service->GetRemote<crosapi::mojom::AppServiceProxy>() + ->RegisterAppServiceSubscriber( + crosapi_receiver_.BindNewPipeAndPassRemote()); + remote_crosapi_app_service_proxy_ = + service->GetRemote<crosapi::mojom::AppServiceProxy>().get(); +} + +void AppServiceProxyLacros::Shutdown() { + if (lacros_web_apps_controller_) { + lacros_web_apps_controller_->Shutdown(); + } +} + void AppServiceProxyLacros::OnApps(std::vector<AppPtr> deltas, AppType app_type, bool should_notify_initialized) { @@ -595,19 +603,4 @@ preferred_apps_.Init(preferred_apps); } -void AppServiceProxyLacros::FlushMojoCallsForTesting() { - crosapi_receiver_.FlushForTesting(); -} - -web_app::LacrosWebAppsController* -AppServiceProxyLacros::LacrosWebAppsControllerForTesting() { - return lacros_web_apps_controller_.get(); -} - -void AppServiceProxyLacros::Shutdown() { - if (lacros_web_apps_controller_) { - lacros_web_apps_controller_->Shutdown(); - } -} - } // namespace apps
diff --git a/chrome/browser/apps/app_service/app_service_proxy_lacros.h b/chrome/browser/apps/app_service/app_service_proxy_lacros.h index c8aaef0..7bf3be6 100644 --- a/chrome/browser/apps/app_service/app_service_proxy_lacros.h +++ b/chrome/browser/apps/app_service/app_service_proxy_lacros.h
@@ -246,6 +246,9 @@ web_app::LacrosWebAppsController* LacrosWebAppsControllerForTesting(); + void SetCrosapiAppServiceProxyForTesting( + crosapi::mojom::AppServiceProxy* proxy); + protected: // An adapter, presenting an IconLoader interface based on the underlying // Mojo service (or on a fake implementation for testing). @@ -367,6 +370,7 @@ std::unique_ptr<web_app::LacrosWebAppsController> lacros_web_apps_controller_; mojo::Receiver<crosapi::mojom::AppServiceSubscriber> crosapi_receiver_{this}; + crosapi::mojom::AppServiceProxy* remote_crosapi_app_service_proxy_ = nullptr; int crosapi_app_service_proxy_version_ = 0; base::WeakPtrFactory<AppServiceProxyLacros> weak_ptr_factory_{this};
diff --git a/chrome/browser/apps/app_service/app_service_proxy_lacros_unittest.cc b/chrome/browser/apps/app_service/app_service_proxy_lacros_unittest.cc new file mode 100644 index 0000000..ab2a965 --- /dev/null +++ b/chrome/browser/apps/app_service/app_service_proxy_lacros_unittest.cc
@@ -0,0 +1,55 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/apps/app_service/app_service_proxy_lacros.h" + +#include "base/test/task_environment.h" +#include "chrome/browser/apps/app_service/intent_util.h" +#include "chrome/browser/apps/app_service/launch_utils.h" +#include "chrome/browser/apps/app_service/mock_crosapi_app_service_proxy.h" +#include "components/services/app_service/public/cpp/intent_util.h" +#include "components/services/app_service/public/mojom/types.mojom.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "ui/events/event_constants.h" + +namespace { + +const char kAppId[] = "test_app"; +const char kUrl[] = "https://www.google.com"; +const int32_t event_flag = ui::EF_NONE; +const apps::mojom::LaunchSource launch_source = + apps::mojom::LaunchSource::kFromTest; + +// Expected container and disposition for ui::EF_NONE event flag; +const crosapi::mojom::LaunchContainer expected_container = + crosapi::mojom::LaunchContainer::kLaunchContainerNone; +const crosapi::mojom::WindowOpenDisposition expected_disposition = + crosapi::mojom::WindowOpenDisposition::kNewForegroundTab; + +} // namespace + +namespace apps { + +TEST(AppServiceProxyLacrosTest, Launch) { + base::test::SingleThreadTaskEnvironment task_environment; + + AppServiceProxy proxy(nullptr); + MockCrosapiAppServiceProxy mock_proxy; + proxy.SetCrosapiAppServiceProxyForTesting(&mock_proxy); + + proxy.LaunchAppWithUrl(kAppId, event_flag, GURL(kUrl), launch_source, + apps::MakeWindowInfo(display::kDefaultDisplayId)); + mock_proxy.Wait(); + ASSERT_EQ(mock_proxy.launched_apps().size(), 1U); + auto& launched_app = mock_proxy.launched_apps()[0]; + EXPECT_EQ(launched_app->app_id, kAppId); + EXPECT_EQ(launched_app->container, expected_container); + EXPECT_EQ(launched_app->disposition, expected_disposition); + EXPECT_EQ(launched_app->launch_source, launch_source); + auto intent = apps_util::ConvertAppServiceToCrosapiIntent( + apps_util::CreateIntentFromUrl(GURL(kUrl)), nullptr); + EXPECT_EQ(launched_app->intent, intent); +} + +} // namespace apps
diff --git a/chrome/browser/apps/app_service/app_service_proxy_unittest.cc b/chrome/browser/apps/app_service/app_service_proxy_unittest.cc index 958316d5..40c6baa 100644 --- a/chrome/browser/apps/app_service/app_service_proxy_unittest.cc +++ b/chrome/browser/apps/app_service/app_service_proxy_unittest.cc
@@ -15,7 +15,9 @@ #include "chrome/browser/web_applications/test/web_app_install_test_utils.h" #include "chrome/test/base/testing_profile.h" #include "components/services/app_service/public/cpp/app_types.h" +#include "components/services/app_service/public/cpp/features.h" #include "components/services/app_service/public/cpp/icon_types.h" +#include "components/services/app_service/public/cpp/intent_filter.h" #include "components/services/app_service/public/cpp/intent_filter_util.h" #include "components/services/app_service/public/cpp/intent_test_util.h" #include "components/services/app_service/public/cpp/intent_util.h" @@ -293,8 +295,18 @@ // Shortcut for adding apps to App Service without going through a real // Publisher. - void OnApps(std::vector<mojom::AppPtr> apps, mojom::AppType type) { - proxy_->OnApps(std::move(apps), type, /*should_notify_initialized=*/false); + void OnApps(std::vector<AppPtr> apps, AppType type) { + if (base::FeatureList::IsEnabled(kAppServiceOnAppUpdateWithoutMojom)) { + proxy_->OnApps(std::move(apps), type, + /*should_notify_initialized=*/false); + } else { + std::vector<mojom::AppPtr> mojom_apps; + for (const auto& app : apps) { + mojom_apps.push_back(ConvertAppToMojomApp(app)); + } + proxy_->OnApps(std::move(mojom_apps), ConvertAppTypeToMojomAppType(type), + /*should_notify_initialized=*/false); + } } private: @@ -308,15 +320,14 @@ // Install an app and set it as preferred for a URL. { - std::vector<mojom::AppPtr> apps; - mojom::AppPtr app = PublisherBase::MakeApp( - mojom::AppType::kWeb, kTestAppId, mojom::Readiness::kReady, "Test App", - mojom::InstallReason::kUser); + std::vector<AppPtr> apps; + AppPtr app = std::make_unique<App>(AppType::kWeb, kTestAppId); + app->readiness = Readiness::kReady; app->intent_filters.push_back( - apps_util::CreateIntentFilterForUrlScope(kTestUrl)); + apps_util::MakeIntentFilterForUrlScope(kTestUrl)); apps.push_back(std::move(app)); - OnApps(std::move(apps), mojom::AppType::kWeb); + OnApps(std::move(apps), AppType::kWeb); proxy()->AddPreferredApp(kTestAppId, kTestUrl); proxy()->FlushMojoCallsForTesting(); @@ -327,14 +338,12 @@ // Updating the app should not change its preferred app status. { - std::vector<mojom::AppPtr> apps; - mojom::AppPtr app = mojom::App::New(); - app->app_type = mojom::AppType::kWeb; - app->app_id = kTestAppId; + std::vector<AppPtr> apps; + AppPtr app = std::make_unique<App>(AppType::kWeb, kTestAppId); app->last_launch_time = base::Time(); apps.push_back(std::move(app)); - OnApps(std::move(apps), mojom::AppType::kWeb); + OnApps(std::move(apps), AppType::kWeb); proxy()->FlushMojoCallsForTesting(); absl::optional<std::string> preferred_app = @@ -344,14 +353,12 @@ // Uninstalling the app should remove it from the preferred app list. { - std::vector<mojom::AppPtr> apps; - mojom::AppPtr app = mojom::App::New(); - app->app_type = mojom::AppType::kWeb; - app->app_id = kTestAppId; - app->readiness = mojom::Readiness::kUninstalledByUser; + std::vector<AppPtr> apps; + AppPtr app = std::make_unique<App>(AppType::kWeb, kTestAppId); + app->readiness = Readiness::kUninstalledByUser; apps.push_back(std::move(app)); - OnApps(std::move(apps), mojom::AppType::kWeb); + OnApps(std::move(apps), AppType::kWeb); proxy()->FlushMojoCallsForTesting(); absl::optional<std::string> preferred_app = @@ -366,26 +373,24 @@ const GURL kTestUrl1 = GURL("https://www.foo.com/"); const GURL kTestUrl2 = GURL("https://www.bar.com/"); - auto url_filter_1 = apps_util::CreateIntentFilterForUrlScope(kTestUrl1); - auto url_filter_2 = apps_util::CreateIntentFilterForUrlScope(kTestUrl2); - auto send_filter = apps_util::CreateIntentFilterForSend("image/png"); + auto url_filter_1 = apps_util::MakeIntentFilterForUrlScope(kTestUrl1); + auto url_filter_2 = apps_util::MakeIntentFilterForUrlScope(kTestUrl2); + auto send_filter = apps_util::MakeIntentFilterForSend("image/png"); - std::vector<mojom::AppPtr> apps; - mojom::AppPtr app1 = PublisherBase::MakeApp( - mojom::AppType::kWeb, kTestAppId1, mojom::Readiness::kReady, "Test App", - mojom::InstallReason::kUser); - app1->intent_filters.push_back(url_filter_1.Clone()); - app1->intent_filters.push_back(url_filter_2.Clone()); - app1->intent_filters.push_back(send_filter.Clone()); + std::vector<AppPtr> apps; + AppPtr app1 = std::make_unique<App>(AppType::kWeb, kTestAppId1); + app1->readiness = Readiness::kReady; + app1->intent_filters.push_back(url_filter_1->Clone()); + app1->intent_filters.push_back(url_filter_2->Clone()); + app1->intent_filters.push_back(send_filter->Clone()); apps.push_back(std::move(app1)); - mojom::AppPtr app2 = PublisherBase::MakeApp( - mojom::AppType::kWeb, kTestAppId2, mojom::Readiness::kReady, "Test App", - mojom::InstallReason::kUser); - app2->intent_filters.push_back(url_filter_1.Clone()); + AppPtr app2 = std::make_unique<App>(AppType::kWeb, kTestAppId2); + app2->readiness = Readiness::kReady; + app2->intent_filters.push_back(url_filter_1->Clone()); apps.push_back(std::move(app2)); - OnApps(std::move(apps), mojom::AppType::kWeb); + OnApps(std::move(apps), AppType::kWeb); // Set app 1 as preferred. Both links should be set as preferred, but the // non-link filter is ignored. @@ -429,17 +434,16 @@ constexpr char kTestAppId[] = "aaa"; const GURL kTestUrl1 = GURL("https://www.foo.com/"); const GURL kTestUrl2 = GURL("https://www.bar.com/"); - auto url_filter_1 = apps_util::CreateIntentFilterForUrlScope(kTestUrl1); - auto url_filter_2 = apps_util::CreateIntentFilterForUrlScope(kTestUrl2); + auto url_filter_1 = apps_util::MakeIntentFilterForUrlScope(kTestUrl1); + auto url_filter_2 = apps_util::MakeIntentFilterForUrlScope(kTestUrl2); - std::vector<mojom::AppPtr> apps; - mojom::AppPtr app1 = PublisherBase::MakeApp( - mojom::AppType::kWeb, kTestAppId, mojom::Readiness::kReady, "Test App", - mojom::InstallReason::kUser); - app1->intent_filters.push_back(url_filter_1.Clone()); - app1->intent_filters.push_back(url_filter_2.Clone()); + std::vector<AppPtr> apps; + AppPtr app1 = std::make_unique<App>(AppType::kWeb, kTestAppId); + app1->readiness = Readiness::kReady; + app1->intent_filters.push_back(url_filter_1->Clone()); + app1->intent_filters.push_back(url_filter_2->Clone()); apps.push_back(std::move(app1)); - OnApps(std::move(apps), mojom::AppType::kWeb); + OnApps(std::move(apps), AppType::kWeb); proxy()->AddPreferredApp(kTestAppId, GURL("https://www.foo.com/something/")); proxy()->FlushMojoCallsForTesting(); @@ -457,25 +461,23 @@ const GURL kTestUrl2 = GURL("https://www.bar.com/"); const GURL kTestUrl3 = GURL("https://www.baz.com/"); - auto url_filter_1 = apps_util::CreateIntentFilterForUrlScope(kTestUrl1); - auto url_filter_2 = apps_util::CreateIntentFilterForUrlScope(kTestUrl2); - auto url_filter_3 = apps_util::CreateIntentFilterForUrlScope(kTestUrl3); + auto url_filter_1 = apps_util::MakeIntentFilterForUrlScope(kTestUrl1); + auto url_filter_2 = apps_util::MakeIntentFilterForUrlScope(kTestUrl2); + auto url_filter_3 = apps_util::MakeIntentFilterForUrlScope(kTestUrl3); - std::vector<mojom::AppPtr> apps; - mojom::AppPtr app1 = PublisherBase::MakeApp( - mojom::AppType::kWeb, kTestAppId1, mojom::Readiness::kReady, "Test App", - mojom::InstallReason::kUser); - app1->intent_filters.push_back(url_filter_1.Clone()); - app1->intent_filters.push_back(url_filter_2.Clone()); + std::vector<AppPtr> apps; + AppPtr app1 = std::make_unique<App>(AppType::kWeb, kTestAppId1); + app1->readiness = Readiness::kReady; + app1->intent_filters.push_back(url_filter_1->Clone()); + app1->intent_filters.push_back(url_filter_2->Clone()); apps.push_back(std::move(app1)); - mojom::AppPtr app2 = PublisherBase::MakeApp( - mojom::AppType::kWeb, kTestAppId2, mojom::Readiness::kReady, "Test App", - mojom::InstallReason::kUser); - app2->intent_filters.push_back(url_filter_3.Clone()); + AppPtr app2 = std::make_unique<App>(AppType::kWeb, kTestAppId2); + app2->readiness = Readiness::kReady; + app2->intent_filters.push_back(url_filter_3->Clone()); apps.push_back(std::move(app2)); - OnApps(std::move(apps), mojom::AppType::kWeb); + OnApps(std::move(apps), AppType::kWeb); proxy()->AddPreferredApp(kTestAppId1, kTestUrl1); proxy()->FlushMojoCallsForTesting();
diff --git a/chrome/browser/apps/app_service/browser_app_launcher.cc b/chrome/browser/apps/app_service/browser_app_launcher.cc index f2b7d13..a5241d9 100644 --- a/chrome/browser/apps/app_service/browser_app_launcher.cc +++ b/chrome/browser/apps/app_service/browser_app_launcher.cc
@@ -151,4 +151,34 @@ } #endif +void BrowserAppLauncher::LaunchAppWithCallback( + const std::string& app_id, + const base::CommandLine& command_line, + const base::FilePath& current_directory, + const absl::optional<GURL>& url_handler_launch_url, + const absl::optional<GURL>& protocol_handler_launch_url, + const std::vector<base::FilePath>& launch_files, + base::OnceCallback<void(Browser* browser, + apps::mojom::LaunchContainer container)> callback) { + // old-style app shortcuts + if (app_id.empty()) { + ::LaunchAppWithCallback(profile_, app_id, command_line, current_directory, + std::move(callback)); + return; + } + + const extensions::Extension* extension = + extensions::ExtensionRegistry::Get(profile_)->GetInstalledExtension( + app_id); + if (!extension) { + web_app_launch_manager_.LaunchApplication( + app_id, command_line, current_directory, url_handler_launch_url, + protocol_handler_launch_url, launch_files, std::move(callback)); + return; + } + + ::LaunchAppWithCallback(profile_, app_id, command_line, current_directory, + std::move(callback)); +} + } // namespace apps
diff --git a/chrome/browser/apps/app_service/browser_app_launcher.h b/chrome/browser/apps/app_service/browser_app_launcher.h index 1aaaf62c..00628bfb 100644 --- a/chrome/browser/apps/app_service/browser_app_launcher.h +++ b/chrome/browser/apps/app_service/browser_app_launcher.h
@@ -5,6 +5,9 @@ #ifndef CHROME_BROWSER_APPS_APP_SERVICE_BROWSER_APP_LAUNCHER_H_ #define CHROME_BROWSER_APPS_APP_SERVICE_BROWSER_APP_LAUNCHER_H_ +#include <memory> +#include <string> + #include "base/callback.h" #include "base/memory/raw_ptr.h" #include "chrome/browser/apps/app_service/app_launch_params.h" @@ -12,8 +15,15 @@ #include "components/services/app_service/public/mojom/types.mojom.h" #include "third_party/abseil-cpp/absl/types/optional.h" +class Browser; +class GURL; class Profile; +namespace base { +class CommandLine; +class FilePath; +} // namespace base + namespace content { class WebContents; } @@ -66,6 +76,29 @@ void LaunchPlayStoreWithExtensions(); #endif + // Attempts to open `app_id` in a new window or tab. Open an empty browser + // window if unsuccessful. The user's preferred launch container for the app + // (standalone window or browser tab) is used. `callback` will be called with + // the container type used to open the app, kLaunchContainerNone if an empty + // browser window was opened. `callback`'s `browser` will be nullptr if the + // navigation failed. + // `url_handler_launch_url` is the launch URL when a PWA should be launched + // as the URL handler. It's null if it's not a URL handler launch. + // `protocol_handler_launch_url` is the protocol URL when a PWA is launched + // as a protocol handler. It's null if it's not a protocol handler launch. + // `launch_files` is a list of files to be passed to the PWA when it is + // launched as a file handler, or empty if it's not a file handling launch. + void LaunchAppWithCallback( + const std::string& app_id, + const base::CommandLine& command_line, + const base::FilePath& current_directory, + const absl::optional<GURL>& url_handler_launch_url, + const absl::optional<GURL>& protocol_handler_launch_url, + const std::vector<base::FilePath>& launch_files, + base::OnceCallback<void(Browser* browser, + apps::mojom::LaunchContainer container)> + callback); + private: const raw_ptr<Profile> profile_; web_app::WebAppLaunchManager web_app_launch_manager_;
diff --git a/chrome/browser/apps/app_service/launch_utils.cc b/chrome/browser/apps/app_service/launch_utils.cc index e9da4975..c3b91ef 100644 --- a/chrome/browser/apps/app_service/launch_utils.cc +++ b/chrome/browser/apps/app_service/launch_utils.cc
@@ -371,12 +371,15 @@ std::string id = params.app_id; // In Lacros, all platform apps must be converted to use a muxed id. #if BUILDFLAG(IS_CHROMEOS_LACROS) - extensions::ExtensionRegistry* registry = - extensions::ExtensionRegistry::Get(profile); - const extensions::Extension* extension = - registry->GetExtensionById(id, extensions::ExtensionRegistry::ENABLED); - if (extension && extension->is_platform_app()) { - id = lacros_extensions_util::MuxId(profile, extension); + // During testing, the profile could be nullptr. + if (profile) { + extensions::ExtensionRegistry* registry = + extensions::ExtensionRegistry::Get(profile); + const extensions::Extension* extension = + registry->GetExtensionById(id, extensions::ExtensionRegistry::ENABLED); + if (extension && extension->is_platform_app()) { + id = lacros_extensions_util::MuxId(profile, extension); + } } #endif // BUILDFLAG(IS_CHROMEOS_LACROS)
diff --git a/chrome/browser/apps/app_service/mock_crosapi_app_service_proxy.cc b/chrome/browser/apps/app_service/mock_crosapi_app_service_proxy.cc new file mode 100644 index 0000000..f6e7707 --- /dev/null +++ b/chrome/browser/apps/app_service/mock_crosapi_app_service_proxy.cc
@@ -0,0 +1,46 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/apps/app_service/mock_crosapi_app_service_proxy.h" + +#include "base/notreached.h" + +namespace apps { + +MockCrosapiAppServiceProxy::MockCrosapiAppServiceProxy() { + run_loop_ = std::make_unique<base::RunLoop>(); +} + +MockCrosapiAppServiceProxy::~MockCrosapiAppServiceProxy() = default; + +void MockCrosapiAppServiceProxy::Wait() { + run_loop_->Run(); + run_loop_ = std::make_unique<base::RunLoop>(); +} + +void MockCrosapiAppServiceProxy::RegisterAppServiceSubscriber( + mojo::PendingRemote<crosapi::mojom::AppServiceSubscriber> subscriber) { + NOTIMPLEMENTED(); +} +void MockCrosapiAppServiceProxy::Launch( + crosapi::mojom::LaunchParamsPtr launch_params) { + launched_apps_.push_back(std::move(launch_params)); + run_loop_->Quit(); +} +void MockCrosapiAppServiceProxy::LoadIcon(const std::string& app_id, + IconKeyPtr icon_key, + IconType icon_type, + int32_t size_hint_in_dip, + apps::LoadIconCallback callback) { + // TODO(crbug/1309024): Implement this. + NOTIMPLEMENTED(); +} +void MockCrosapiAppServiceProxy::AddPreferredApp( + const std::string& app_id, + crosapi::mojom::IntentPtr intent) { + // TODO(crbug/1309024): Implement this. + NOTIMPLEMENTED(); +} + +} // namespace apps
diff --git a/chrome/browser/apps/app_service/mock_crosapi_app_service_proxy.h b/chrome/browser/apps/app_service/mock_crosapi_app_service_proxy.h new file mode 100644 index 0000000..ac25b59 --- /dev/null +++ b/chrome/browser/apps/app_service/mock_crosapi_app_service_proxy.h
@@ -0,0 +1,44 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_APPS_APP_SERVICE_MOCK_CROSAPI_APP_SERVICE_PROXY_H_ +#define CHROME_BROWSER_APPS_APP_SERVICE_MOCK_CROSAPI_APP_SERVICE_PROXY_H_ + +#include <memory> +#include <string> +#include <vector> + +#include "base/run_loop.h" +#include "chromeos/crosapi/mojom/app_service.mojom.h" +#include "components/services/app_service/public/cpp/icon_types.h" + +namespace apps { +class MockCrosapiAppServiceProxy : public crosapi::mojom::AppServiceProxy { + public: + MockCrosapiAppServiceProxy(); + ~MockCrosapiAppServiceProxy() override; + void Wait(); + const std::vector<crosapi::mojom::LaunchParamsPtr>& launched_apps() const { + return launched_apps_; + } + + private: + // crosapi::mojom::AppServiceProxy: + void RegisterAppServiceSubscriber( + mojo::PendingRemote<crosapi::mojom::AppServiceSubscriber> subscriber) + override; + void Launch(crosapi::mojom::LaunchParamsPtr launch_params) override; + void LoadIcon(const std::string& app_id, + IconKeyPtr icon_key, + IconType icon_type, + int32_t size_hint_in_dip, + apps::LoadIconCallback callback) override; + void AddPreferredApp(const std::string& app_id, + crosapi::mojom::IntentPtr intent) override; + std::vector<crosapi::mojom::LaunchParamsPtr> launched_apps_; + std::unique_ptr<base::RunLoop> run_loop_; +}; +} // namespace apps + +#endif // CHROME_BROWSER_APPS_APP_SERVICE_MOCK_CROSAPI_APP_SERVICE_PROXY_H_
diff --git a/chrome/browser/ash/chromebox_for_meetings/browser/cfm_browser_service.h b/chrome/browser/ash/chromebox_for_meetings/browser/cfm_browser_service.h index 87b8352..7819a7f 100644 --- a/chrome/browser/ash/chromebox_for_meetings/browser/cfm_browser_service.h +++ b/chrome/browser/ash/chromebox_for_meetings/browser/cfm_browser_service.h
@@ -5,10 +5,10 @@ #ifndef CHROME_BROWSER_ASH_CHROMEBOX_FOR_MEETINGS_BROWSER_CFM_BROWSER_SERVICE_H_ #define CHROME_BROWSER_ASH_CHROMEBOX_FOR_MEETINGS_BROWSER_CFM_BROWSER_SERVICE_H_ +#include "ash/services/chromebox_for_meetings/public/mojom/cfm_browser.mojom.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/ash/chromebox_for_meetings/service_adaptor.h" #include "chromeos/dbus/chromebox_for_meetings/cfm_observer.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/cfm_browser.mojom.h" #include "mojo/public/cpp/bindings/receiver_set.h" namespace ash::cfm {
diff --git a/chrome/browser/ash/chromebox_for_meetings/browser/cfm_browser_service_unittest.cc b/chrome/browser/ash/chromebox_for_meetings/browser/cfm_browser_service_unittest.cc index f877af8..2724ceb6 100644 --- a/chrome/browser/ash/chromebox_for_meetings/browser/cfm_browser_service_unittest.cc +++ b/chrome/browser/ash/chromebox_for_meetings/browser/cfm_browser_service_unittest.cc
@@ -8,6 +8,11 @@ #include <utility> #include <vector> +#include "ash/services/chromebox_for_meetings/public/cpp/fake_service_connection.h" +#include "ash/services/chromebox_for_meetings/public/cpp/fake_service_context.h" +#include "ash/services/chromebox_for_meetings/public/cpp/service_connection.h" +#include "ash/services/chromebox_for_meetings/public/mojom/cfm_browser.mojom.h" +#include "ash/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" #include "base/bind.h" #include "base/metrics/field_trial.h" #include "base/metrics/field_trial_params.h" @@ -18,11 +23,6 @@ #include "base/test/scoped_field_trial_list_resetter.h" #include "base/test/task_environment.h" #include "chromeos/dbus/chromebox_for_meetings/fake_cfm_hotline_client.h" -#include "chromeos/services/chromebox_for_meetings/public/cpp/fake_service_connection.h" -#include "chromeos/services/chromebox_for_meetings/public/cpp/fake_service_context.h" -#include "chromeos/services/chromebox_for_meetings/public/cpp/service_connection.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/cfm_browser.mojom.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" #include "components/variations/field_trial_config/field_trial_util.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/receiver.h"
diff --git a/chrome/browser/ash/chromebox_for_meetings/browser/cfm_memory_details.h b/chrome/browser/ash/chromebox_for_meetings/browser/cfm_memory_details.h index 554103b..2a3dbcf 100644 --- a/chrome/browser/ash/chromebox_for_meetings/browser/cfm_memory_details.h +++ b/chrome/browser/ash/chromebox_for_meetings/browser/cfm_memory_details.h
@@ -5,8 +5,8 @@ #ifndef CHROME_BROWSER_ASH_CHROMEBOX_FOR_MEETINGS_BROWSER_CFM_MEMORY_DETAILS_H_ #define CHROME_BROWSER_ASH_CHROMEBOX_FOR_MEETINGS_BROWSER_CFM_MEMORY_DETAILS_H_ +#include "ash/services/chromebox_for_meetings/public/mojom/cfm_browser.mojom.h" #include "chrome/browser/memory_details.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/cfm_browser.mojom.h" #include "content/public/browser/render_process_host.h" namespace ash::cfm {
diff --git a/chrome/browser/ash/chromebox_for_meetings/device_info/device_info_service.h b/chrome/browser/ash/chromebox_for_meetings/device_info/device_info_service.h index 39dfc627..40d1644 100644 --- a/chrome/browser/ash/chromebox_for_meetings/device_info/device_info_service.h +++ b/chrome/browser/ash/chromebox_for_meetings/device_info/device_info_service.h
@@ -5,12 +5,12 @@ #ifndef CHROME_BROWSER_ASH_CHROMEBOX_FOR_MEETINGS_DEVICE_INFO_DEVICE_INFO_SERVICE_H_ #define CHROME_BROWSER_ASH_CHROMEBOX_FOR_MEETINGS_DEVICE_INFO_DEVICE_INFO_SERVICE_H_ +#include "ash/services/chromebox_for_meetings/public/mojom/meet_devices_info.mojom.h" #include "base/memory/weak_ptr.h" #include "base/task/sequenced_task_runner.h" #include "chrome/browser/ash/chromebox_for_meetings/service_adaptor.h" #include "chrome/browser/ash/settings/device_settings_service.h" #include "chromeos/dbus/chromebox_for_meetings/cfm_observer.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/meet_devices_info.mojom.h" #include "mojo/public/cpp/bindings/receiver_set.h" #include "mojo/public/cpp/bindings/remote_set.h"
diff --git a/chrome/browser/ash/chromebox_for_meetings/device_info/device_info_service_unittest.cc b/chrome/browser/ash/chromebox_for_meetings/device_info/device_info_service_unittest.cc index e0aab15b..37aff40 100644 --- a/chrome/browser/ash/chromebox_for_meetings/device_info/device_info_service_unittest.cc +++ b/chrome/browser/ash/chromebox_for_meetings/device_info/device_info_service_unittest.cc
@@ -8,6 +8,11 @@ #include <utility> #include <vector> +#include "ash/services/chromebox_for_meetings/public/cpp/fake_service_connection.h" +#include "ash/services/chromebox_for_meetings/public/cpp/fake_service_context.h" +#include "ash/services/chromebox_for_meetings/public/cpp/service_connection.h" +#include "ash/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" +#include "ash/services/chromebox_for_meetings/public/mojom/meet_devices_info.mojom.h" #include "base/bind.h" #include "base/run_loop.h" #include "base/strings/string_number_conversions.h" @@ -20,11 +25,6 @@ #include "chrome/browser/ash/settings/device_settings_service.h" #include "chromeos/dbus/chromebox_for_meetings/fake_cfm_hotline_client.h" #include "chromeos/dbus/session_manager/fake_session_manager_client.h" -#include "chromeos/services/chromebox_for_meetings/public/cpp/fake_service_connection.h" -#include "chromeos/services/chromebox_for_meetings/public/cpp/fake_service_context.h" -#include "chromeos/services/chromebox_for_meetings/public/cpp/service_connection.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/meet_devices_info.mojom.h" #include "chromeos/system/fake_statistics_provider.h" #include "components/ownership/mock_owner_key_util.h" #include "content/public/test/test_utils.h"
diff --git a/chrome/browser/ash/chromebox_for_meetings/diagnostics/diagnostics_service.h b/chrome/browser/ash/chromebox_for_meetings/diagnostics/diagnostics_service.h index 995db3d..4a617df 100644 --- a/chrome/browser/ash/chromebox_for_meetings/diagnostics/diagnostics_service.h +++ b/chrome/browser/ash/chromebox_for_meetings/diagnostics/diagnostics_service.h
@@ -5,10 +5,10 @@ #ifndef CHROME_BROWSER_ASH_CHROMEBOX_FOR_MEETINGS_DIAGNOSTICS_DIAGNOSTICS_SERVICE_H_ #define CHROME_BROWSER_ASH_CHROMEBOX_FOR_MEETINGS_DIAGNOSTICS_DIAGNOSTICS_SERVICE_H_ +#include "ash/services/chromebox_for_meetings/public/mojom/meet_devices_diagnostics.mojom.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/ash/chromebox_for_meetings/service_adaptor.h" #include "chromeos/dbus/chromebox_for_meetings/cfm_observer.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/meet_devices_diagnostics.mojom.h" #include "mojo/public/cpp/bindings/receiver_set.h" namespace ash::cfm {
diff --git a/chrome/browser/ash/chromebox_for_meetings/diagnostics/diagnostics_service_unittest.cc b/chrome/browser/ash/chromebox_for_meetings/diagnostics/diagnostics_service_unittest.cc index 96a6a9c..0457efab 100644 --- a/chrome/browser/ash/chromebox_for_meetings/diagnostics/diagnostics_service_unittest.cc +++ b/chrome/browser/ash/chromebox_for_meetings/diagnostics/diagnostics_service_unittest.cc
@@ -7,6 +7,12 @@ #include <memory> #include <utility> #include <vector> + +#include "ash/services/chromebox_for_meetings/public/cpp/fake_service_connection.h" +#include "ash/services/chromebox_for_meetings/public/cpp/fake_service_context.h" +#include "ash/services/chromebox_for_meetings/public/cpp/service_connection.h" +#include "ash/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" +#include "ash/services/chromebox_for_meetings/public/mojom/meet_devices_diagnostics.mojom.h" #include "base/bind.h" #include "base/run_loop.h" #include "base/strings/string_number_conversions.h" @@ -16,11 +22,6 @@ #include "chromeos/dbus/chromebox_for_meetings/fake_cfm_hotline_client.h" #include "chromeos/dbus/cros_healthd/cros_healthd_client.h" #include "chromeos/dbus/cros_healthd/fake_cros_healthd_client.h" -#include "chromeos/services/chromebox_for_meetings/public/cpp/fake_service_connection.h" -#include "chromeos/services/chromebox_for_meetings/public/cpp/fake_service_context.h" -#include "chromeos/services/chromebox_for_meetings/public/cpp/service_connection.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/meet_devices_diagnostics.mojom.h" #include "chromeos/services/cros_healthd/public/cpp/service_connection.h" #include "content/public/test/test_utils.h" #include "mojo/public/cpp/bindings/pending_remote.h"
diff --git a/chrome/browser/ash/chromebox_for_meetings/external_display_brightness/external_display_brightness_service.h b/chrome/browser/ash/chromebox_for_meetings/external_display_brightness/external_display_brightness_service.h index 374195b..fa28c18f 100644 --- a/chrome/browser/ash/chromebox_for_meetings/external_display_brightness/external_display_brightness_service.h +++ b/chrome/browser/ash/chromebox_for_meetings/external_display_brightness/external_display_brightness_service.h
@@ -5,10 +5,10 @@ #ifndef CHROME_BROWSER_ASH_CHROMEBOX_FOR_MEETINGS_EXTERNAL_DISPLAY_BRIGHTNESS_EXTERNAL_DISPLAY_BRIGHTNESS_SERVICE_H_ #define CHROME_BROWSER_ASH_CHROMEBOX_FOR_MEETINGS_EXTERNAL_DISPLAY_BRIGHTNESS_EXTERNAL_DISPLAY_BRIGHTNESS_SERVICE_H_ +#include "ash/services/chromebox_for_meetings/public/mojom/external_display_brightness.mojom-shared.h" +#include "ash/services/chromebox_for_meetings/public/mojom/external_display_brightness.mojom.h" #include "chrome/browser/ash/chromebox_for_meetings/service_adaptor.h" #include "chromeos/dbus/chromebox_for_meetings/cfm_observer.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/external_display_brightness.mojom-shared.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/external_display_brightness.mojom.h" #include "mojo/public/cpp/bindings/receiver_set.h" #include "third_party/abseil-cpp/absl/types/optional.h"
diff --git a/chrome/browser/ash/chromebox_for_meetings/logger/cfm_logger_service.cc b/chrome/browser/ash/chromebox_for_meetings/logger/cfm_logger_service.cc index 18518fb..9c819aa 100644 --- a/chrome/browser/ash/chromebox_for_meetings/logger/cfm_logger_service.cc +++ b/chrome/browser/ash/chromebox_for_meetings/logger/cfm_logger_service.cc
@@ -4,11 +4,11 @@ #include "chrome/browser/ash/chromebox_for_meetings/logger/cfm_logger_service.h" +#include "ash/services/chromebox_for_meetings/public/mojom/meet_devices_logger.mojom-shared.h" #include "base/bind.h" #include "chrome/browser/ash/chromebox_for_meetings/logger/reporting_pipeline.h" #include "chromeos/components/chromebox_for_meetings/features/features.h" #include "chromeos/dbus/chromebox_for_meetings/cfm_hotline_client.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/meet_devices_logger.mojom-shared.h" #include "mojo/public/cpp/bindings/receiver_set.h" namespace ash::cfm {
diff --git a/chrome/browser/ash/chromebox_for_meetings/logger/cfm_logger_service.h b/chrome/browser/ash/chromebox_for_meetings/logger/cfm_logger_service.h index 4f68f3ca..8da2233 100644 --- a/chrome/browser/ash/chromebox_for_meetings/logger/cfm_logger_service.h +++ b/chrome/browser/ash/chromebox_for_meetings/logger/cfm_logger_service.h
@@ -5,11 +5,11 @@ #ifndef CHROME_BROWSER_ASH_CHROMEBOX_FOR_MEETINGS_LOGGER_CFM_LOGGER_SERVICE_H_ #define CHROME_BROWSER_ASH_CHROMEBOX_FOR_MEETINGS_LOGGER_CFM_LOGGER_SERVICE_H_ +#include "ash/services/chromebox_for_meetings/public/mojom/meet_devices_logger.mojom-shared.h" +#include "ash/services/chromebox_for_meetings/public/mojom/meet_devices_logger.mojom.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/ash/chromebox_for_meetings/service_adaptor.h" #include "chromeos/dbus/chromebox_for_meetings/cfm_observer.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/meet_devices_logger.mojom-shared.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/meet_devices_logger.mojom.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/receiver_set.h" #include "mojo/public/cpp/bindings/remote_set.h"
diff --git a/chrome/browser/ash/chromebox_for_meetings/logger/cfm_logger_service_unittest.cc b/chrome/browser/ash/chromebox_for_meetings/logger/cfm_logger_service_unittest.cc index 9da8d71f7..f0761d4 100644 --- a/chrome/browser/ash/chromebox_for_meetings/logger/cfm_logger_service_unittest.cc +++ b/chrome/browser/ash/chromebox_for_meetings/logger/cfm_logger_service_unittest.cc
@@ -8,6 +8,12 @@ #include <utility> #include <vector> +#include "ash/services/chromebox_for_meetings/public/cpp/fake_service_connection.h" +#include "ash/services/chromebox_for_meetings/public/cpp/fake_service_context.h" +#include "ash/services/chromebox_for_meetings/public/cpp/service_connection.h" +#include "ash/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" +#include "ash/services/chromebox_for_meetings/public/mojom/meet_devices_logger.mojom-shared.h" +#include "ash/services/chromebox_for_meetings/public/mojom/meet_devices_logger.mojom.h" #include "base/bind.h" #include "base/run_loop.h" #include "base/test/bind.h" @@ -16,12 +22,6 @@ #include "base/test/task_environment.h" #include "chromeos/components/chromebox_for_meetings/features/features.h" #include "chromeos/dbus/chromebox_for_meetings/fake_cfm_hotline_client.h" -#include "chromeos/services/chromebox_for_meetings/public/cpp/fake_service_connection.h" -#include "chromeos/services/chromebox_for_meetings/public/cpp/fake_service_context.h" -#include "chromeos/services/chromebox_for_meetings/public/cpp/service_connection.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/meet_devices_logger.mojom-shared.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/meet_devices_logger.mojom.h" #include "components/reporting/util/status.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/receiver.h"
diff --git a/chrome/browser/ash/chromebox_for_meetings/logger/reporting_pipeline.h b/chrome/browser/ash/chromebox_for_meetings/logger/reporting_pipeline.h index f8e5666b..b552252 100644 --- a/chrome/browser/ash/chromebox_for_meetings/logger/reporting_pipeline.h +++ b/chrome/browser/ash/chromebox_for_meetings/logger/reporting_pipeline.h
@@ -5,12 +5,12 @@ #ifndef CHROME_BROWSER_ASH_CHROMEBOX_FOR_MEETINGS_LOGGER_REPORTING_PIPELINE_H_ #define CHROME_BROWSER_ASH_CHROMEBOX_FOR_MEETINGS_LOGGER_REPORTING_PIPELINE_H_ +#include "ash/services/chromebox_for_meetings/public/mojom/meet_devices_logger.mojom-shared.h" #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" #include "base/task/sequenced_task_runner.h" #include "chrome/browser/ash/chromebox_for_meetings/logger/cfm_logger_service.h" #include "chrome/browser/ash/settings/device_settings_service.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/meet_devices_logger.mojom-shared.h" #include "components/reporting/client/report_queue.h" #include "components/reporting/client/report_queue_provider.h"
diff --git a/chrome/browser/ash/chromebox_for_meetings/network_settings/network_settings_service.h b/chrome/browser/ash/chromebox_for_meetings/network_settings/network_settings_service.h index c099fd0..bbfcfd10 100644 --- a/chrome/browser/ash/chromebox_for_meetings/network_settings/network_settings_service.h +++ b/chrome/browser/ash/chromebox_for_meetings/network_settings/network_settings_service.h
@@ -7,9 +7,9 @@ #include <string> +#include "ash/services/chromebox_for_meetings/public/mojom/cfm_network_settings.mojom.h" #include "chrome/browser/ash/chromebox_for_meetings/service_adaptor.h" #include "chromeos/dbus/chromebox_for_meetings/cfm_observer.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/cfm_network_settings.mojom.h" #include "mojo/public/cpp/bindings/receiver_set.h" namespace ash::cfm {
diff --git a/chrome/browser/ash/chromebox_for_meetings/service_adaptor.cc b/chrome/browser/ash/chromebox_for_meetings/service_adaptor.cc index 665441c..2f578a1 100644 --- a/chrome/browser/ash/chromebox_for_meetings/service_adaptor.cc +++ b/chrome/browser/ash/chromebox_for_meetings/service_adaptor.cc
@@ -4,7 +4,7 @@ #include "chrome/browser/ash/chromebox_for_meetings/service_adaptor.h" -#include "chromeos/services/chromebox_for_meetings/public/cpp/service_connection.h" +#include "ash/services/chromebox_for_meetings/public/cpp/service_connection.h" namespace ash::cfm {
diff --git a/chrome/browser/ash/chromebox_for_meetings/service_adaptor.h b/chrome/browser/ash/chromebox_for_meetings/service_adaptor.h index b7e7134..c13e59c0 100644 --- a/chrome/browser/ash/chromebox_for_meetings/service_adaptor.h +++ b/chrome/browser/ash/chromebox_for_meetings/service_adaptor.h
@@ -5,7 +5,7 @@ #ifndef CHROME_BROWSER_ASH_CHROMEBOX_FOR_MEETINGS_SERVICE_ADAPTOR_H_ #define CHROME_BROWSER_ASH_CHROMEBOX_FOR_MEETINGS_SERVICE_ADAPTOR_H_ -#include "chromeos/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" +#include "ash/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" #include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/remote.h"
diff --git a/chrome/browser/ash/chromebox_for_meetings/service_adaptor_unittest.cc b/chrome/browser/ash/chromebox_for_meetings/service_adaptor_unittest.cc index e413ea6..40303b9 100644 --- a/chrome/browser/ash/chromebox_for_meetings/service_adaptor_unittest.cc +++ b/chrome/browser/ash/chromebox_for_meetings/service_adaptor_unittest.cc
@@ -7,16 +7,16 @@ #include <utility> #include <vector> +#include "ash/services/chromebox_for_meetings/public/cpp/fake_service_connection.h" +#include "ash/services/chromebox_for_meetings/public/cpp/fake_service_context.h" +#include "ash/services/chromebox_for_meetings/public/cpp/service_connection.h" +#include "ash/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" #include "base/bind.h" #include "base/run_loop.h" #include "base/test/bind.h" #include "base/test/mock_callback.h" #include "base/test/task_environment.h" #include "chromeos/dbus/chromebox_for_meetings/cfm_hotline_client.h" -#include "chromeos/services/chromebox_for_meetings/public/cpp/fake_service_connection.h" -#include "chromeos/services/chromebox_for_meetings/public/cpp/fake_service_context.h" -#include "chromeos/services/chromebox_for_meetings/public/cpp/service_connection.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/remote.h"
diff --git a/chrome/browser/ash/file_manager/extract_io_task.cc b/chrome/browser/ash/file_manager/extract_io_task.cc index 068301a..eec3891 100644 --- a/chrome/browser/ash/file_manager/extract_io_task.cc +++ b/chrome/browser/ash/file_manager/extract_io_task.cc
@@ -10,6 +10,7 @@ #include "chrome/browser/ash/file_manager/fileapi_util.h" #include "chrome/browser/chromeos/fileapi/file_system_backend.h" #include "components/services/unzip/content/unzip_service.h" +#include "third_party/zlib/google/redact.h" namespace file_manager { namespace io_task { @@ -55,7 +56,10 @@ unzip::Unzip(unzip::LaunchUnzipper(), source_file, destination_directory, base::BindOnce(&ExtractIOTask::ZipExtractCallback, weak_ptr_factory_.GetWeakPtr())); - } // TODO(crbug.com/953256) Report directory creation error. + } else { + LOG(ERROR) << "Cannot create directory " + << zip::Redact(destination_directory); + } } void ExtractIOTask::ExtractArchive( @@ -85,22 +89,17 @@ VLOG(1) << "Executing EXTRACT_ARCHIVE IO task"; progress_.state = State::kInProgress; progress_callback_.Run(progress_); - for (size_t index = 0; index < progress_.sources.size(); ++index) { - const EntryStatus& source = progress_.sources[index]; - const base::FilePath source_file = source.url.path().BaseName(); - // TODO(crbug.com/953256) Perform this check only once. - if (chromeos::FileSystemBackend::CanHandleURL(parent_folder_)) { + if (!chromeos::FileSystemBackend::CanHandleURL(parent_folder_)) { + progress_.state = State::kError; + Complete(); + } else { + for (size_t index = 0; index < progress_.sources.size(); ++index) { + const EntryStatus& source = progress_.sources[index]; + const base::FilePath source_file = source.url.path().BaseName(); util::GenerateUnusedFilename( parent_folder_, source_file.RemoveExtension(), file_system_context_, base::BindOnce(&ExtractIOTask::ExtractArchive, weak_ptr_factory_.GetWeakPtr(), index)); - } else { - progress_.state = State::kError; - // We won't get a callback so reduce the count and maybe finalise. - DCHECK_GT(extractCount_, 0); - if (--extractCount_ == 0) { - Complete(); - } } } }
diff --git a/chrome/browser/ash/file_manager/file_manager_browsertest.cc b/chrome/browser/ash/file_manager/file_manager_browsertest.cc index 2c99a78..c84bd7a 100644 --- a/chrome/browser/ash/file_manager/file_manager_browsertest.cc +++ b/chrome/browser/ash/file_manager/file_manager_browsertest.cc
@@ -483,6 +483,8 @@ TestCase("zipCreateFileDrive").FilesSwa(), TestCase("zipCreateFileUsb"), TestCase("zipCreateFileUsb").FilesSwa(), + TestCase("zipExtractCheckContent").ExtractArchive().FilesSwa(), + TestCase("zipExtractCheckDuplicates").ExtractArchive().FilesSwa(), TestCase("zipExtractShowPanel").ExtractArchive().FilesSwa(), TestCase("zipExtractSelectionMenus").ExtractArchive().FilesSwa()));
diff --git a/chrome/browser/ash/input_method/input_method_settings.cc b/chrome/browser/ash/input_method/input_method_settings.cc index f0c5b996..41192b3 100644 --- a/chrome/browser/ash/input_method/input_method_settings.cc +++ b/chrome/browser/ash/input_method/input_method_settings.cc
@@ -6,6 +6,7 @@ #include "ash/constants/ash_features.h" #include "ash/constants/ash_pref_names.h" +#include "base/feature_list.h" #include "chrome/common/pref_names.h" namespace ash { @@ -101,6 +102,7 @@ settings->autocorrect = base::StartsWith(engine_id, "experimental_", base::CompareCase::SENSITIVE) || + base::FeatureList::IsEnabled(features::kAutocorrectParamsTuning) || input_method_specific_pref .FindIntKey("physicalKeyboardAutoCorrectionLevel") .value_or(0) > 0;
diff --git a/chrome/browser/ash/input_method/native_input_method_engine.cc b/chrome/browser/ash/input_method/native_input_method_engine.cc index f718115d..6342c0a 100644 --- a/chrome/browser/ash/input_method/native_input_method_engine.cc +++ b/chrome/browser/ash/input_method/native_input_method_engine.cc
@@ -123,7 +123,8 @@ bool IsPhysicalKeyboardAutocorrectEnabled(PrefService* prefs, const std::string& engine_id) { if (base::StartsWith(engine_id, "experimental_", - base::CompareCase::SENSITIVE)) { + base::CompareCase::SENSITIVE) || + base::FeatureList::IsEnabled(features::kAutocorrectParamsTuning)) { return true; }
diff --git a/chrome/browser/ash/login/password_change_browsertest.cc b/chrome/browser/ash/login/password_change_browsertest.cc index dc274ea8..971c8a0 100644 --- a/chrome/browser/ash/login/password_change_browsertest.cc +++ b/chrome/browser/ash/login/password_change_browsertest.cc
@@ -331,7 +331,7 @@ ReauthReason::INVALID_TOKEN_HANDLE, 1); } -IN_PROC_BROWSER_TEST_F(PasswordChangeTokenCheck, LoginScreenNoPasswordChange) { +IN_PROC_BROWSER_TEST_F(PasswordChangeTokenCheck, DISABLED_LoginScreenNoPasswordChange) { TokenHandleUtil::StoreTokenHandle(user_with_invalid_token_, kTokenHandle); // Focus triggers token check. LoginScreenTestApi::FocusUser(user_with_invalid_token_);
diff --git a/chrome/browser/ash/login/screens/lacros_data_migration_screen.cc b/chrome/browser/ash/login/screens/lacros_data_migration_screen.cc index 01e119e..3005d6c7 100644 --- a/chrome/browser/ash/login/screens/lacros_data_migration_screen.cc +++ b/chrome/browser/ash/login/screens/lacros_data_migration_screen.cc
@@ -23,6 +23,8 @@ namespace ash { namespace { constexpr char kUserActionSkip[] = "skip"; +constexpr char kUserActionCancel[] = "cancel"; +constexpr char kUserActionGotoFiles[] = "gotoFiles"; constexpr base::TimeDelta kShowSkipButtonDuration = base::Seconds(20); // If the battery percent is lower than this ratio, and the charger is not @@ -34,7 +36,8 @@ LacrosDataMigrationScreenView* view) : BaseScreen(LacrosDataMigrationScreenView::kScreenId, OobeScreenPriority::SCREEN_DEVICE_DEVELOPER_MODIFICATION), - view_(view) { + view_(view), + attempt_restart_(base::BindRepeating(&chrome::AttemptRestart)) { DCHECK(view_); if (view_) view_->Bind(this); @@ -69,7 +72,8 @@ << switches::kBrowserDataMigrationForUser << ". Aborting migration."; - chrome::AttemptRestart(); + attempt_restart_.Run(); + return; } DCHECK(!user_id_hash.empty()) << "user_id_hash should not be empty."; @@ -77,7 +81,7 @@ if (!base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { LOG(ERROR) << "Could not get the original user data dir path. Aborting " "migration."; - chrome::AttemptRestart(); + attempt_restart_.Run(); return; } @@ -93,13 +97,11 @@ migrator_ = std::make_unique<BrowserDataMigratorImpl>( profile_data_dir, user_id_hash, progress_callback, g_browser_process->local_state()); - - migrator_->Migrate(base::BindOnce([](BrowserDataMigrator::Result result) { - // TODO(crbug.com/1296174): support page transition on failure. - chrome::AttemptRestart(); - })); } + migrator_->Migrate(base::BindOnce(&LacrosDataMigrationScreen::OnMigrated, + weak_factory_.GetWeakPtr())); + // Show the screen. view_->Show(); @@ -136,11 +138,35 @@ // which triggers Chrome to restart. migrator_->Cancel(); } + } else if (action_id == kUserActionCancel) { + attempt_restart_.Run(); + } else if (action_id == kUserActionGotoFiles) { + // TODO(crbug.com/1296174): Record a bit here so that Files.app will be + // opened in the following user session. + attempt_restart_.Run(); } else { BaseScreen::OnUserAction(action_id); } } +void LacrosDataMigrationScreen::OnMigrated(BrowserDataMigrator::Result result) { + switch (result.kind) { + case BrowserDataMigrator::ResultKind::kSkipped: + case BrowserDataMigrator::ResultKind::kSucceeded: + case BrowserDataMigrator::ResultKind::kCancelled: + attempt_restart_.Run(); + return; + case BrowserDataMigrator::ResultKind::kFailed: + if (view_) { + // Goto Files button should be displayed on migration failure caused by + // out of disk space. + const bool show_goto_files = result.required_size.has_value(); + view_->SetFailureStatus(result.required_size, show_goto_files); + } + break; + } +} + void LacrosDataMigrationScreen::HideImpl() { GetWakeLock()->CancelWakeLock(); power_manager_subscription_.Reset(); @@ -191,4 +217,10 @@ migrator_ = std::move(migrator); } +void LacrosDataMigrationScreen::SetAttemptRestartForTesting( + const base::RepeatingClosure& attempt_restart) { + DCHECK(!attempt_restart.is_null()); + attempt_restart_ = attempt_restart; +} + } // namespace ash
diff --git a/chrome/browser/ash/login/screens/lacros_data_migration_screen.h b/chrome/browser/ash/login/screens/lacros_data_migration_screen.h index d6cab418..5cb2042a 100644 --- a/chrome/browser/ash/login/screens/lacros_data_migration_screen.h +++ b/chrome/browser/ash/login/screens/lacros_data_migration_screen.h
@@ -50,6 +50,11 @@ // PowerManagerClient::Observer: void PowerChanged(const power_manager::PowerSupplyProperties& proto) override; + // Sets |attempt_restart_| for testing. This helps testing as it can block + // to restart. + void SetAttemptRestartForTesting( + const base::RepeatingClosure& attempt_restart); + private: // BaseScreen: void ShowImpl() override; @@ -59,6 +64,9 @@ // Updates the low battery message. void UpdateLowBatteryStatus(); + // Called when migration is completed. + void OnMigrated(BrowserDataMigrator::Result result); + device::mojom::WakeLock* GetWakeLock(); mojo::Remote<device::mojom::WakeLock> wake_lock_; @@ -66,6 +74,7 @@ LacrosDataMigrationScreenView* view_; std::unique_ptr<BrowserDataMigrator> migrator_; bool skip_post_show_button_for_testing_ = false; + base::RepeatingClosure attempt_restart_; // PowerManagerClient::Observer is used only when screen is shown. base::ScopedObservation<PowerManagerClient, PowerManagerClient::Observer>
diff --git a/chrome/browser/ash/login/screens/lacros_data_migration_screen_browsertest.cc b/chrome/browser/ash/login/screens/lacros_data_migration_screen_browsertest.cc index 4515b08..ac0c963 100644 --- a/chrome/browser/ash/login/screens/lacros_data_migration_screen_browsertest.cc +++ b/chrome/browser/ash/login/screens/lacros_data_migration_screen_browsertest.cc
@@ -29,17 +29,33 @@ const test::UIPath kSkipButton = {kLacrosDataMigrationId, "skipButton"}; const test::UIPath kUpdating = {kLacrosDataMigrationId, "updating"}; const test::UIPath kLowBattery = {kLacrosDataMigrationId, "lowBattery"}; +const test::UIPath kProgressDialog = {kLacrosDataMigrationId, "progressDialog"}; +const test::UIPath kErrorDialog = {kLacrosDataMigrationId, "errorDialog"}; +const test::UIPath kLowDiskSpace = {kLacrosDataMigrationId, + "lowDiskSpaceError"}; +const test::UIPath kGenericError = {kLacrosDataMigrationId, "genericError"}; +const test::UIPath kCancelButton = {kLacrosDataMigrationId, "cancelButton"}; +const test::UIPath kGotoFilesButton = {kLacrosDataMigrationId, + "gotoFilesButton"}; class FakeMigrator : public BrowserDataMigrator { public: // BrowserDataMigrator overrides. - void Migrate(MigrateCallback callback) override {} + void Migrate(MigrateCallback callback) override { + callback_ = std::move(callback); + } void Cancel() override { cancel_called_ = true; } bool IsCancelCalled() { return cancel_called_; } + void MaybeRunCallback(const BrowserDataMigrator::Result& result) { + if (!callback_.is_null()) + std::move(callback_).Run(result); + } + private: bool cancel_called_ = false; + MigrateCallback callback_; }; class LacrosDataMigrationScreenTest : public OobeBaseTest { @@ -70,15 +86,22 @@ fake_migrator_ = new FakeMigrator(); lacros_data_migration_screen->SetMigratorForTesting( base::WrapUnique(fake_migrator_)); + lacros_data_migration_screen->SetAttemptRestartForTesting( + base::BindRepeating( + &LacrosDataMigrationScreenTest::OnAttemptRestartCalled, + base::Unretained(this))); lacros_data_migration_screen->SetSkipPostShowButtonForTesting(true); OobeBaseTest::SetUpOnMainThread(); } + bool is_attempt_restart_called() const { return is_attempt_restart_called_; } + protected: FakeMigrator* fake_migrator() { return fake_migrator_; } FakePowerManagerClient* power_manager_client() { return static_cast<FakePowerManagerClient*>(PowerManagerClient::Get()); } + void OnAttemptRestartCalled() { is_attempt_restart_called_ = true; } private: // This is owned by `LacrosDataMigrationScreen`. @@ -86,6 +109,7 @@ DeviceStateMixin device_state_{ &mixin_host_, DeviceStateMixin::State::OOBE_COMPLETED_CONSUMER_OWNED}; LoginManagerMixin login_mixin_{&mixin_host_}; + bool is_attempt_restart_called_ = false; }; IN_PROC_BROWSER_TEST_F(LacrosDataMigrationScreenTest, SkipButton) { @@ -175,5 +199,82 @@ test::OobeJS().CreateVisibilityWaiter(false, kLowBattery)->Wait(); } +IN_PROC_BROWSER_TEST_F(LacrosDataMigrationScreenTest, OutOfDiskError) { + OobeScreenWaiter waiter(LacrosDataMigrationScreenView::kScreenId); + WizardController::default_controller()->AdvanceToScreen( + LacrosDataMigrationScreenView::kScreenId); + waiter.Wait(); + + test::OobeJS().ExpectVisiblePath(kProgressDialog); + test::OobeJS().ExpectHiddenPath(kErrorDialog); + + fake_migrator()->MaybeRunCallback( + {BrowserDataMigrator::ResultKind::kFailed, 12345}); + + test::OobeJS().CreateVisibilityWaiter(false, kProgressDialog)->Wait(); + test::OobeJS().CreateVisibilityWaiter(true, kErrorDialog)->Wait(); + test::OobeJS().ExpectVisiblePath(kLowDiskSpace); + test::OobeJS().ExpectHiddenPath(kGenericError); + test::OobeJS().ExpectVisiblePath(kCancelButton); + test::OobeJS().ExpectVisiblePath(kGotoFilesButton); +} + +IN_PROC_BROWSER_TEST_F(LacrosDataMigrationScreenTest, GenericError) { + OobeScreenWaiter waiter(LacrosDataMigrationScreenView::kScreenId); + WizardController::default_controller()->AdvanceToScreen( + LacrosDataMigrationScreenView::kScreenId); + waiter.Wait(); + + test::OobeJS().ExpectVisiblePath(kProgressDialog); + test::OobeJS().ExpectHiddenPath(kErrorDialog); + + fake_migrator()->MaybeRunCallback({BrowserDataMigrator::ResultKind::kFailed}); + + test::OobeJS().CreateVisibilityWaiter(false, kProgressDialog)->Wait(); + test::OobeJS().CreateVisibilityWaiter(true, kErrorDialog)->Wait(); + test::OobeJS().ExpectHiddenPath(kLowDiskSpace); + test::OobeJS().ExpectVisiblePath(kGenericError); + test::OobeJS().ExpectVisiblePath(kCancelButton); + test::OobeJS().ExpectHiddenPath(kGotoFilesButton); +} + +IN_PROC_BROWSER_TEST_F(LacrosDataMigrationScreenTest, OnCancel) { + OobeScreenWaiter waiter(LacrosDataMigrationScreenView::kScreenId); + WizardController::default_controller()->AdvanceToScreen( + LacrosDataMigrationScreenView::kScreenId); + waiter.Wait(); + + fake_migrator()->MaybeRunCallback( + {BrowserDataMigrator::ResultKind::kFailed, 12345}); + test::OobeJS().CreateVisibilityWaiter(true, kErrorDialog)->Wait(); + + EXPECT_FALSE(is_attempt_restart_called()); + test::OobeJS().TapOnPath(kCancelButton); + test::TestPredicateWaiter( + base::BindRepeating( + &LacrosDataMigrationScreenTest::is_attempt_restart_called, + base::Unretained(this))) + .Wait(); +} + +IN_PROC_BROWSER_TEST_F(LacrosDataMigrationScreenTest, OnGotoFiles) { + OobeScreenWaiter waiter(LacrosDataMigrationScreenView::kScreenId); + WizardController::default_controller()->AdvanceToScreen( + LacrosDataMigrationScreenView::kScreenId); + waiter.Wait(); + + fake_migrator()->MaybeRunCallback( + {BrowserDataMigrator::ResultKind::kFailed, 12345}); + test::OobeJS().CreateVisibilityWaiter(true, kErrorDialog)->Wait(); + + EXPECT_FALSE(is_attempt_restart_called()); + test::OobeJS().TapOnPath(kGotoFilesButton); + test::TestPredicateWaiter( + base::BindRepeating( + &LacrosDataMigrationScreenTest::is_attempt_restart_called, + base::Unretained(this))) + .Wait(); +} + } // namespace } // namespace ash
diff --git a/chrome/browser/ash/system_extensions/api/window_management/cros_window_browsertest.cc b/chrome/browser/ash/system_extensions/api/window_management/cros_window_browsertest.cc index b8b854ca..cccef3c1 100644 --- a/chrome/browser/ash/system_extensions/api/window_management/cros_window_browsertest.cc +++ b/chrome/browser/ash/system_extensions/api/window_management/cros_window_browsertest.cc
@@ -124,3 +124,59 @@ RunTest(test_code); } + +IN_PROC_BROWSER_TEST_F(CrosWindowBrowserTest, RepeatSetFullscreen) { + const char test_code[] = R"( +async function test() { + let windows = await chromeos.windowManagement.windows(); + if (windows[0].isFullscreen) { + throw new Error("Window started in fullscreen."); + } + + windows[0].setFullscreen(false); + windows = await chromeos.windowManagement.windows(); + if (windows[0].isFullscreen) { + throw new Error("setFullscreen(false) set window fullscreen"); + } + + windows[0].setFullscreen(true); + windows = await chromeos.windowManagement.windows(); + if (!windows[0].isFullscreen) { + throw new Error("setFullscreen(true) failed"); + } + + windows[0].setFullscreen(true); + windows = await chromeos.windowManagement.windows(); + if (!windows[0].isFullscreen) { + throw new Error("setFullscreen(true) unset window fullscreen"); + } +} + )"; + + RunTest(test_code); +} + +IN_PROC_BROWSER_TEST_F(CrosWindowBrowserTest, FullscreenFromMinimised) { + const char test_code[] = R"( +async function test() { + let windows = await chromeos.windowManagement.windows(); + if (windows[0].isFullscreen) { + throw new Error("Window started in fullscreen."); + } + + windows[0].minimize(); + windows = await chromeos.windowManagement.windows(); + if (!windows[0].isMinimised || windows[0].isVisible) { + throw new Error("minimize() did not minimize window"); + } + + windows[0].setFullscreen(true); + windows = await chromeos.windowManagement.windows(); + if (!windows[0].isFullscreen || !windows[0].isVisible) { + throw new Error("setFullscreen(true) did not make window visible and fs"); + } +} + )"; + + RunTest(test_code); +}
diff --git a/chrome/browser/ash/tether/tether_service_unittest.cc b/chrome/browser/ash/tether/tether_service_unittest.cc index 6f15096..fa8685e 100644 --- a/chrome/browser/ash/tether/tether_service_unittest.cc +++ b/chrome/browser/ash/tether/tether_service_unittest.cc
@@ -194,8 +194,8 @@ // chromeos::device_sync::RemoteDeviceProviderImpl::Factory: std::unique_ptr<chromeos::device_sync::RemoteDeviceProvider> CreateInstance( - chromeos::device_sync::CryptAuthDeviceManager* device_manager, - chromeos::device_sync::CryptAuthV2DeviceManager* v2_device_manager, + device_sync::CryptAuthDeviceManager* device_manager, + device_sync::CryptAuthV2DeviceManager* v2_device_manager, const std::string& user_email, const std::string& user_private_key) override { return std::make_unique<chromeos::device_sync::FakeRemoteDeviceProvider>(); @@ -335,8 +335,8 @@ initial_feature_state_ = multidevice_setup::mojom::FeatureState::kEnabledByUser; - fake_enrollment_manager_ = std::make_unique< - chromeos::device_sync::FakeCryptAuthEnrollmentManager>(); + fake_enrollment_manager_ = + std::make_unique<device_sync::FakeCryptAuthEnrollmentManager>(); fake_enrollment_manager_->set_user_private_key(kTestUserPrivateKey); mock_adapter_ = @@ -543,7 +543,7 @@ fake_multidevice_setup_client_; std::unique_ptr<FakeMultiDeviceSetupClientImplFactory> fake_multidevice_setup_client_impl_factory_; - std::unique_ptr<chromeos::device_sync::FakeCryptAuthEnrollmentManager> + std::unique_ptr<device_sync::FakeCryptAuthEnrollmentManager> fake_enrollment_manager_; multidevice_setup::mojom::FeatureState initial_feature_state_;
diff --git a/chrome/browser/autofill/autofill_interactive_uitest.cc b/chrome/browser/autofill/autofill_interactive_uitest.cc index cc05719..57e0723 100644 --- a/chrome/browser/autofill/autofill_interactive_uitest.cc +++ b/chrome/browser/autofill/autofill_interactive_uitest.cc
@@ -1356,7 +1356,9 @@ ValuesAre(MergeValue(kDefaultAddress, {"state", "CA"}))); } -// Test that autofill works when the website prefills the form. +// Test that autofill works when the website prefills the form when +// |kAutofillPreventOverridingPrefilledValues| is not enabled, otherwise, the +// prefilled field values are not overridden. IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, PrefillFormAndFill) { const char kPrefillScript[] = R"( <script> @@ -1377,7 +1379,18 @@ ASSERT_TRUE( AutofillFlow(GetElementById("firstname"), this, {.after_focus = base::BindLambdaForTesting(Delete)})); - EXPECT_THAT(GetFormValues(), ValuesAre(kDefaultAddress)); + if (base::FeatureList::IsEnabled( + features::kAutofillPreventOverridingPrefilledValues)) { + EXPECT_EQ("Milton", GetFieldValueById("firstname")); + EXPECT_EQ("Bell", GetFieldValueById("lastname")); + EXPECT_EQ("3243 Notre-Dame Ouest", GetFieldValueById("address1")); + EXPECT_EQ("apt 843", GetFieldValueById("address2")); + EXPECT_EQ("Montreal", GetFieldValueById("city")); + EXPECT_EQ("H5D 4D3", GetFieldValueById("zip")); + EXPECT_EQ("15142223344", GetFieldValueById("phone")); + } else { + EXPECT_THAT(GetFormValues(), ValuesAre(kDefaultAddress)); + } } // Test that autofill doesn't refill a field modified by the user.
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index d009f251..6f2537b 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd
@@ -92,9 +92,9 @@ <if expr="chromeos"> <!-- In-session login flow --> <include name="IDR_INLINE_LOGIN_WELCOME_PAGE_APP_JS" file="${root_gen_dir}\chrome\browser\resources\inline_login\welcome_page_app.js" use_base_dir="false" type ="BINDATA" preprocess="true" /> - <include name="IDR_INLINE_LOGIN_ARC_ACCOUNT_PICKER_APP_JS" file="${root_gen_dir}\chrome\browser\resources\inline_login\arc_account_picker_app.js" use_base_dir="false" type ="BINDATA" preprocess="true" /> <include name="IDR_INLINE_LOGIN_SIGNIN_BLOCKED_BY_POLICY_PAGE_JS" file="${root_gen_dir}\chrome\browser\resources\inline_login\signin_blocked_by_policy_page.js" use_base_dir="false" type ="BINDATA" preprocess="true" /> - <include name="IDR_INLINE_LOGIN_ARC_ACCOUNT_PICKER_BROWSER_PROXY_JS" file="resources\inline_login\arc_account_picker_browser_proxy.js" type ="BINDATA" /> + <include name="IDR_ARC_ACCOUNT_PICKER_ARC_ACCOUNT_PICKER_APP_JS" file="${root_gen_dir}\chrome\browser\resources\chromeos\arc_account_picker\arc_account_picker_app.js" use_base_dir="false" type ="BINDATA" preprocess="true" /> + <include name="IDR_ARC_ACCOUNT_PICKER_ARC_ACCOUNT_PICKER_BROWSER_PROXY_JS" file="resources\chromeos\arc_account_picker\arc_account_picker_browser_proxy.js" type ="BINDATA" /> </if> <include name="IDR_IDENTITY_API_SCOPE_APPROVAL_MANIFEST" file="resources\identity_scope_approval_dialog\manifest.json" type="BINDATA" />
diff --git a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc index 18d0e06b..2f0b2d9 100644 --- a/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc +++ b/chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_unittest.cc
@@ -66,6 +66,7 @@ #include "chrome/browser/web_applications/test/web_app_install_test_utils.h" #include "chrome/browser/web_applications/test/web_app_test_utils.h" #include "chrome/browser/web_applications/web_app.h" +#include "chrome/browser/web_applications/web_app_sync_bridge.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_features.h" #include "chrome/common/chrome_paths.h" @@ -486,7 +487,7 @@ content::BrowserContext* context) { Profile* profile = Profile::FromBrowserContext(context); return std::make_unique<custom_handlers::ProtocolHandlerRegistry>( - profile, + profile->GetPrefs(), std::make_unique<custom_handlers::TestProtocolHandlerRegistryDelegate>()); }
diff --git a/chrome/browser/browsing_data/counters/site_settings_counter_unittest.cc b/chrome/browser/browsing_data/counters/site_settings_counter_unittest.cc index e8bfdc6..4dc9fa5 100644 --- a/chrome/browser/browsing_data/counters/site_settings_counter_unittest.cc +++ b/chrome/browser/browsing_data/counters/site_settings_counter_unittest.cc
@@ -47,7 +47,7 @@ #endif handler_registry_ = std::make_unique<custom_handlers::ProtocolHandlerRegistry>( - profile(), + profile()->GetPrefs(), std::make_unique< custom_handlers::TestProtocolHandlerRegistryDelegate>());
diff --git a/chrome/browser/chromeos/BUILD.gn b/chrome/browser/chromeos/BUILD.gn index b82a350..1184359b 100644 --- a/chrome/browser/chromeos/BUILD.gn +++ b/chrome/browser/chromeos/BUILD.gn
@@ -3723,10 +3723,10 @@ "../ash/chromebox_for_meetings/service_adaptor.h", ] deps += [ + "//ash/services/chromebox_for_meetings/public/cpp", + "//ash/services/chromebox_for_meetings/public/mojom", "//chromeos/components/chromebox_for_meetings/features", "//chromeos/dbus/chromebox_for_meetings", - "//chromeos/services/chromebox_for_meetings/public/cpp", - "//chromeos/services/chromebox_for_meetings/public/mojom", "//components/reporting/client:report_queue", "//components/reporting/client:report_queue_configuration", "//components/reporting/client:report_queue_provider", @@ -5038,8 +5038,7 @@ "../ash/chromebox_for_meetings/logger/cfm_logger_service_unittest.cc", "../ash/chromebox_for_meetings/service_adaptor_unittest.cc", ] - deps += - [ "//chromeos/services/chromebox_for_meetings/public/cpp:test_support" ] + deps += [ "//ash/services/chromebox_for_meetings/public/cpp:test_support" ] } data = [
diff --git a/chrome/browser/custom_handlers/chrome_protocol_handler_registry_unittest.cc b/chrome/browser/custom_handlers/chrome_protocol_handler_registry_unittest.cc index 13dff836..cf234bd2 100644 --- a/chrome/browser/custom_handlers/chrome_protocol_handler_registry_unittest.cc +++ b/chrome/browser/custom_handlers/chrome_protocol_handler_registry_unittest.cc
@@ -33,7 +33,7 @@ CHECK(profile_->GetPrefs()); auto delegate = std::make_unique< custom_handlers::TestProtocolHandlerRegistryDelegate>(); - registry_ = std::make_unique<ProtocolHandlerRegistry>(profile_.get(), + registry_ = std::make_unique<ProtocolHandlerRegistry>(profile_->GetPrefs(), std::move(delegate)); registry_->InitProtocolSettings(); }
diff --git a/chrome/browser/custom_handlers/protocol_handler_registry_factory.cc b/chrome/browser/custom_handlers/protocol_handler_registry_factory.cc index fc024927a..f66a82f 100644 --- a/chrome/browser/custom_handlers/protocol_handler_registry_factory.cc +++ b/chrome/browser/custom_handlers/protocol_handler_registry_factory.cc
@@ -13,6 +13,8 @@ #include "chrome/browser/profiles/incognito_helpers.h" #include "components/custom_handlers/protocol_handler_registry.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" +#include "components/user_prefs/user_prefs.h" +#include "content/public/browser/browser_context.h" // static ProtocolHandlerRegistryFactory* ProtocolHandlerRegistryFactory::GetInstance() { @@ -58,9 +60,11 @@ KeyedService* ProtocolHandlerRegistryFactory::BuildServiceInstanceFor( content::BrowserContext* context) const { + PrefService* prefs = user_prefs::UserPrefs::Get(context); + DCHECK(prefs); custom_handlers::ProtocolHandlerRegistry* registry = new custom_handlers::ProtocolHandlerRegistry( - context, std::make_unique<ChromeProtocolHandlerRegistryDelegate>()); + prefs, std::make_unique<ChromeProtocolHandlerRegistryDelegate>()); #if BUILDFLAG(IS_CHROMEOS_ASH) // If installing defaults, they must be installed prior calling
diff --git a/chrome/browser/extensions/BUILD.gn b/chrome/browser/extensions/BUILD.gn index 36c2d84..37537b8c 100644 --- a/chrome/browser/extensions/BUILD.gn +++ b/chrome/browser/extensions/BUILD.gn
@@ -1128,6 +1128,8 @@ "//ash/constants", "//ash/keyboard/ui:resources_grit_grit", "//ash/public/cpp", + "//ash/services/chromebox_for_meetings/public/cpp", + "//ash/services/chromebox_for_meetings/public/mojom", "//ash/services/ime/public/mojom", "//ash/webui/camera_app_ui", "//ash/webui/camera_app_ui:mojo_bindings", @@ -1151,8 +1153,6 @@ "//chromeos/network", "//chromeos/process_proxy", "//chromeos/services/assistant/public/cpp", - "//chromeos/services/chromebox_for_meetings/public/cpp", - "//chromeos/services/chromebox_for_meetings/public/mojom", "//chromeos/services/machine_learning/public/cpp", "//chromeos/services/machine_learning/public/mojom", "//chromeos/services/media_perception/public/mojom",
diff --git a/chrome/browser/extensions/api/debugger/debugger_api.cc b/chrome/browser/extensions/api/debugger/debugger_api.cc index 9f68b74b..ed8e242 100644 --- a/chrome/browser/extensions/api/debugger/debugger_api.cc +++ b/chrome/browser/extensions/api/debugger/debugger_api.cc
@@ -89,11 +89,23 @@ dst->target_id = std::make_unique<std::string>(*src.target_id); } +bool ExtensionMayAttachToTargetProfile(Profile* extension_profile, + bool allow_incognito_access, + DevToolsAgentHost& agent_host) { + Profile* profile = + Profile::FromBrowserContext(agent_host.GetBrowserContext()); + if (!profile) + return false; + if (!extension_profile->IsSameOrParent(profile)) + return false; + return profile == extension_profile || allow_incognito_access; +} + // Returns true if the given |Extension| is allowed to attach to the specified // |url|. bool ExtensionMayAttachToURL(const Extension& extension, + Profile* extension_profile, const GURL& url, - Profile* profile, std::string* error) { // Allow the extension to attach to about:blank and empty URLs. if (url.is_empty() || url == "about:") @@ -112,7 +124,8 @@ if (extension.permissions_data()->IsPolicyBlockedHost(url)) return false; - if (url.SchemeIsFile() && !util::AllowFileAccess(extension.id(), profile)) { + if (url.SchemeIsFile() && + !util::AllowFileAccess(extension.id(), extension_profile)) { *error = debugger_api_constants::kRestrictedError; return false; } @@ -121,15 +134,15 @@ } bool ExtensionMayAttachToURLOrInnerURL(const Extension& extension, - Profile* profile, + Profile* extension_profile, const GURL& url, std::string* error) { - if (!ExtensionMayAttachToURL(extension, url, profile, error)) + if (!ExtensionMayAttachToURL(extension, extension_profile, url, error)) return false; // For nested URLs, make sure ExtensionMayAttachToURL() allows both // the outer and the inner URLs. - if (url.inner_url() && - !ExtensionMayAttachToURL(extension, *url.inner_url(), profile, error)) { + if (url.inner_url() && !ExtensionMayAttachToURL(extension, extension_profile, + *url.inner_url(), error)) { return false; } return true; @@ -145,13 +158,13 @@ bool ExtensionMayAttachToRenderFrameHost( const Extension& extension, - Profile* profile, + Profile* extension_profile, content::RenderFrameHost* render_frame_host, std::string* error) { bool result = true; render_frame_host->ForEachRenderFrameHost(base::BindRepeating( - [](const Extension& extension, Profile* profile, std::string* error, - bool& result, content::RenderFrameHost* rfh) { + [](const Extension& extension, Profile* extension_profile, + std::string* error, bool& result, content::RenderFrameHost* rfh) { // If |rfh| is attached to an inner MimeHandlerViewGuest skip it. // This is done to fix crbug.com/1293856 because an extension cannot // inspect another extension. @@ -169,47 +182,56 @@ // We check both the last committed URL and the SiteURL because this // method may be called in the middle of a navigation where the SiteURL // has been updated but navigation hasn't committed yet. - if (!ExtensionMayAttachToURLOrInnerURL( - extension, profile, rfh->GetLastCommittedURL(), error) || + if (!ExtensionMayAttachToURLOrInnerURL(extension, extension_profile, + rfh->GetLastCommittedURL(), + error) || !ExtensionMayAttachToURLOrInnerURL( - extension, profile, rfh->GetSiteInstance()->GetSiteURL(), - error)) { + extension, extension_profile, + rfh->GetSiteInstance()->GetSiteURL(), error)) { result = false; return content::RenderFrameHost::FrameIterationAction::kStop; } return content::RenderFrameHost::FrameIterationAction::kContinue; }, - std::ref(extension), profile, error, std::ref(result))); + std::ref(extension), extension_profile, error, std::ref(result))); return result; } bool ExtensionMayAttachToWebContents(const Extension& extension, + Profile* extension_profile, WebContents& web_contents, - Profile* profile, std::string* error) { // This is *not* redundant to the checks below, as // web_contents.GetLastCommittedURL() may be different from // web_contents.GetMainFrame()->GetLastCommittedURL(), with the // former being a 'virtual' URL as obtained from NavigationEntry. - if (!ExtensionMayAttachToURL(extension, web_contents.GetLastCommittedURL(), - profile, error)) { + if (!ExtensionMayAttachToURL(extension, extension_profile, + web_contents.GetLastCommittedURL(), error)) { return false; } return ExtensionMayAttachToRenderFrameHost( - extension, profile, web_contents.GetMainFrame(), error); + extension, extension_profile, web_contents.GetMainFrame(), error); } bool ExtensionMayAttachToAgentHost(const Extension& extension, + bool allow_incognito_access, + Profile* extension_profile, DevToolsAgentHost& agent_host, - Profile* profile, std::string* error) { - if (WebContents* wc = agent_host.GetWebContents()) - return ExtensionMayAttachToWebContents(extension, *wc, profile, error); + if (!ExtensionMayAttachToTargetProfile(extension_profile, + allow_incognito_access, agent_host)) { + *error = debugger_api_constants::kRestrictedError; + return false; + } + if (WebContents* wc = agent_host.GetWebContents()) { + return ExtensionMayAttachToWebContents(extension, extension_profile, *wc, + error); + } - return ExtensionMayAttachToURL(extension, agent_host.GetURL(), profile, - error); + return ExtensionMayAttachToURL(extension, extension_profile, + agent_host.GetURL(), error); } } // namespace @@ -529,8 +551,8 @@ &web_contents); if (result && web_contents) { if (!ExtensionMayAttachToWebContents( - *extension(), *web_contents, - Profile::FromBrowserContext(browser_context()), error)) { + *extension(), Profile::FromBrowserContext(browser_context()), + *web_contents, error)) { return false; } @@ -554,8 +576,9 @@ DevToolsAgentHost::GetForId(*debuggee_.target_id); if (agent_host) { if (!ExtensionMayAttachToAgentHost( - *extension(), *agent_host, - Profile::FromBrowserContext(browser_context()), error)) { + *extension(), include_incognito_information(), + Profile::FromBrowserContext(browser_context()), *agent_host, + error)) { return false; } agent_host_ = std::move(agent_host); @@ -791,8 +814,14 @@ ExtensionFunction::ResponseAction DebuggerGetTargetsFunction::Run() { content::DevToolsAgentHost::List list = DevToolsAgentHost::GetOrCreateAll(); std::unique_ptr<base::ListValue> result(new base::ListValue()); - for (auto& i : list) - result->Append(SerializeTarget(i)); + Profile* profile = Profile::FromBrowserContext(browser_context()); + for (auto& host : list) { + if (!ExtensionMayAttachToTargetProfile( + profile, include_incognito_information(), *host)) { + continue; + } + result->Append(SerializeTarget(host)); + } return RespondNow( OneArgument(base::Value::FromUniquePtrValue(std::move(result))));
diff --git a/chrome/browser/extensions/api/debugger/debugger_apitest.cc b/chrome/browser/extensions/api/debugger/debugger_apitest.cc index 5e2002f..209c026 100644 --- a/chrome/browser/extensions/api/debugger/debugger_apitest.cc +++ b/chrome/browser/extensions/api/debugger/debugger_apitest.cc
@@ -15,15 +15,20 @@ #include "base/test/metrics/histogram_tester.h" #include "base/test/scoped_mock_time_message_loop_task_runner.h" #include "base/test/simple_test_tick_clock.h" +#include "base/test/values_test_util.h" +#include "chrome/browser/browser_process.h" #include "chrome/browser/extensions/api/debugger/debugger_api.h" #include "chrome/browser/extensions/api/debugger/extension_dev_tools_infobar_delegate.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/extensions/extension_function_test_utils.h" #include "chrome/browser/extensions/extension_management_test_util.h" +#include "chrome/browser/profiles/profile_destroyer.h" +#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" +#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/ui_test_utils.h" #include "components/infobars/content/content_infobar_manager.h" #include "components/infobars/core/infobar.h" @@ -43,8 +48,14 @@ #include "extensions/test/test_extension_dir.h" #include "net/dns/mock_host_resolver.h" +#if BUILDFLAG(IS_CHROMEOS_ASH) +#include "chrome/browser/ash/profiles/profile_helper.h" +#endif // BUILDFLAG(IS_CHROMEOS_ASH) + namespace extensions { +using testing::Eq; + class DebuggerApiTest : public ExtensionApiTest { protected: ~DebuggerApiTest() override = default; @@ -385,6 +396,153 @@ EXPECT_EQ(0u, manager->infobar_count()); } +class CrossProfileDebuggerApiTest : public DebuggerApiTest { + protected: + Profile* other_profile() { return other_profile_; } + Profile* otr_profile() { return otr_profile_; } + + std::unique_ptr<content::WebContents> CreateTabWithProfileAndNavigate( + Profile* profile, + const GURL& url) { + auto wc = content::WebContents::Create( + content::WebContents::CreateParams(profile)); + EXPECT_TRUE(content::NavigateToURL(wc.get(), url)); + return wc; + } + + private: + void SetUpOnMainThread() override { + ASSERT_TRUE(embedded_test_server()->Start()); +#if BUILDFLAG(IS_CHROMEOS_ASH) + ash::ProfileHelper::SetAlwaysReturnPrimaryUserForTesting(true); +#endif // BUILDFLAG(IS_CHROMEOS_ASH) + DebuggerApiTest::SetUpOnMainThread(); + profile_manager_ = g_browser_process->profile_manager(); + + base::RunLoop run_loop; + profile_manager_->CreateProfileAsync( + profile_manager_->GenerateNextProfileDirectoryPath(), + base::BindRepeating( + [](CrossProfileDebuggerApiTest* self, base::RunLoop* run_loop, + Profile* profile, Profile::CreateStatus status) { + if (status == Profile::CREATE_STATUS_INITIALIZED) { + self->other_profile_ = profile; + run_loop->Quit(); + } + }, + this, &run_loop)); + run_loop.Run(); + otr_profile_ = profile()->GetPrimaryOTRProfile(true); + } + + void TearDownOnMainThread() override { + ProfileDestroyer::DestroyProfileWhenAppropriate(otr_profile_); + DebuggerApiTest::TearDownOnMainThread(); + } + + ProfileManager* profile_manager_ = nullptr; + Profile* other_profile_ = nullptr; + Profile* otr_profile_ = nullptr; +}; + +IN_PROC_BROWSER_TEST_F(CrossProfileDebuggerApiTest, GetTargets) { + auto wc1 = CreateTabWithProfileAndNavigate( + other_profile(), + embedded_test_server()->GetURL("/simple.html?other_profile")); + auto wc2 = CreateTabWithProfileAndNavigate( + otr_profile(), + embedded_test_server()->GetURL("/simple.html?off_the_record")); + + { + auto get_targets_function = + base::MakeRefCounted<DebuggerGetTargetsFunction>(); + base::Value value = std::move( + *extension_function_test_utils::RunFunctionAndReturnSingleResult( + get_targets_function.get(), "[]", browser())); + + ASSERT_TRUE(value.is_list()); + const base::Value::List targets = std::move(value.GetList()); + ASSERT_THAT(targets, testing::SizeIs(1)); + EXPECT_THAT(targets[0], base::test::DictionaryHasValue( + "url", base::Value("about:blank"))); + } + + { + auto get_targets_function = + base::MakeRefCounted<DebuggerGetTargetsFunction>(); + base::Value value = std::move( + *extension_function_test_utils::RunFunctionAndReturnSingleResult( + get_targets_function.get(), "[]", browser(), + api_test_utils::RunFunctionFlags::INCLUDE_INCOGNITO)); + + ASSERT_TRUE(value.is_list()); + const base::Value::List targets = std::move(value.GetList()); + std::vector<std::string> urls; + std::transform( + targets.begin(), targets.end(), std::back_inserter(urls), + [](const base::Value& value) -> std::string { + GURL::Replacements remove_port; + remove_port.ClearPort(); + const std::string* url = value.GetDict().FindString("url"); + return url ? GURL(*url).ReplaceComponents(remove_port).spec() + : "<missing field>"; + }); + EXPECT_THAT(urls, testing::UnorderedElementsAre( + "about:blank", + "http://127.0.0.1/simple.html?off_the_record")); + } +} + +IN_PROC_BROWSER_TEST_F(CrossProfileDebuggerApiTest, Attach) { + auto wc1 = CreateTabWithProfileAndNavigate( + other_profile(), + embedded_test_server()->GetURL("/simple.html?other_profile")); + std::string target_in_other_profile = base::StringPrintf( + "[{\"targetId\": \"%s\"}, \"1.1\"]", + content::DevToolsAgentHost::GetOrCreateFor(wc1.get())->GetId().c_str()); + + { + auto debugger_attach_function = + base::MakeRefCounted<DebuggerAttachFunction>(); + debugger_attach_function->set_extension(extension()); + EXPECT_FALSE(extension_function_test_utils::RunFunction( + debugger_attach_function.get(), target_in_other_profile, browser(), + api_test_utils::NONE)); + } + { + auto debugger_attach_function = + base::MakeRefCounted<DebuggerAttachFunction>(); + debugger_attach_function->set_extension(extension()); + EXPECT_FALSE(extension_function_test_utils::RunFunction( + debugger_attach_function.get(), target_in_other_profile.c_str(), + browser(), api_test_utils::INCLUDE_INCOGNITO)); + } + + auto wc2 = CreateTabWithProfileAndNavigate( + otr_profile(), + embedded_test_server()->GetURL("/simple.html?off_the_record")); + std::string target_in_otr_profile = base::StringPrintf( + "[{\"targetId\": \"%s\"}, \"1.1\"]", + content::DevToolsAgentHost::GetOrCreateFor(wc2.get())->GetId().c_str()); + + { + auto debugger_attach_function = + base::MakeRefCounted<DebuggerAttachFunction>(); + debugger_attach_function->set_extension(extension()); + EXPECT_FALSE(extension_function_test_utils::RunFunction( + debugger_attach_function.get(), target_in_otr_profile.c_str(), + browser(), api_test_utils::NONE)); + } + { + auto debugger_attach_function = + base::MakeRefCounted<DebuggerAttachFunction>(); + debugger_attach_function->set_extension(extension()); + EXPECT_TRUE(extension_function_test_utils::RunFunction( + debugger_attach_function.get(), target_in_otr_profile.c_str(), + browser(), api_test_utils::INCLUDE_INCOGNITO)); + } +} + IN_PROC_BROWSER_TEST_F(DebuggerApiTest, InfoBarIsNotRemovedIfAttachAgainBeforeFiveSeconds) { int tab_id = sessions::SessionTabHelper::IdForTab(
diff --git a/chrome/browser/extensions/api/feedback_private/feedback_browsertest.cc b/chrome/browser/extensions/api/feedback_private/feedback_browsertest.cc index 14232b0..b620328 100644 --- a/chrome/browser/extensions/api/feedback_private/feedback_browsertest.cc +++ b/chrome/browser/extensions/api/feedback_private/feedback_browsertest.cc
@@ -5,17 +5,18 @@ #include "base/bind.h" #include "base/memory/raw_ptr.h" #include "base/run_loop.h" -#include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "chrome/browser/apps/platform_apps/app_browsertest_util.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/devtools/devtools_window_testing.h" +#include "chrome/browser/extensions/component_loader.h" +#include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/feedback/feedback_dialog_utils.h" #include "chrome/browser/feedback/feedback_uploader_chrome.h" #include "chrome/browser/feedback/feedback_uploader_factory_chrome.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/webui/feedback/feedback_dialog.h" +#include "chrome/common/extensions/extension_constants.h" #include "chrome/common/webui_url_constants.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" @@ -25,67 +26,79 @@ #include "content/public/test/test_utils.h" #include "extensions/browser/api/feedback_private/feedback_private_api.h" #include "extensions/browser/app_window/app_window.h" +#include "extensions/browser/app_window/app_window_registry.h" +#include "extensions/browser/event_router.h" +#include "extensions/browser/extension_system.h" #include "extensions/common/api/feedback_private.h" using extensions::api::feedback_private::FeedbackFlow; +namespace { + +void StopMessageLoopCallback() { + base::RunLoop::QuitCurrentWhenIdleDeprecated(); +} + +} // namespace + namespace extensions { -class FeedbackTest : public InProcessBrowserTest { +class FeedbackTest : public ExtensionBrowserTest { public: + void SetUp() override { + extensions::ComponentLoader::EnableBackgroundExtensionsForTesting(); + ExtensionBrowserTest::SetUp(); + } + void SetUpCommandLine(base::CommandLine* command_line) override { command_line->AppendSwitch(::switches::kEnableUserMediaScreenCapturing); } protected: + bool IsFeedbackAppAvailable() { + return extensions::EventRouter::Get(browser()->profile()) + ->ExtensionHasEventListener( + extension_misc::kFeedbackExtensionId, + extensions::api::feedback_private::OnFeedbackRequested::kEventName); + } + void StartFeedbackUI(FeedbackFlow flow, const std::string& extra_diagnostics, bool from_assistant = false, bool include_bluetooth_logs = false, bool show_questionnaire = false) { - extensions::FeedbackPrivateAPI* api = - extensions::FeedbackPrivateAPI::GetFactoryInstance()->Get( - browser()->profile()); - auto info = api->CreateFeedbackInfo( - "Test description", "Test placeholder", "Test tag", extra_diagnostics, - GURL("http://www.test.com"), flow, from_assistant, - include_bluetooth_logs, show_questionnaire, - /*from_chrome_labs_or_kaleidoscope=*/false); - - FeedbackDialog::CreateOrShow(browser()->profile(), *info); + base::OnceClosure callback = base::BindOnce(&StopMessageLoopCallback); + extensions::FeedbackPrivateGetStringsFunction::set_test_callback(&callback); + InvokeFeedbackUI(flow, extra_diagnostics, from_assistant, + include_bluetooth_logs, show_questionnaire); + content::RunMessageLoop(); + extensions::FeedbackPrivateGetStringsFunction::set_test_callback(nullptr); } void VerifyFeedbackAppLaunch() { - feedback_dialog_ = FeedbackDialog::GetInstanceForTest(); - ASSERT_NE(nullptr, feedback_dialog_); - - base::RunLoop run_loop; - EnsureFeedbackAppUIShown(feedback_dialog_, run_loop.QuitClosure()); - run_loop.Run(); - - ASSERT_NE(nullptr, feedback_dialog_); - ASSERT_NE(nullptr, feedback_dialog_->GetWidget()); - EXPECT_TRUE(feedback_dialog_->GetWidget()->IsVisible()); + AppWindow* window = + PlatformAppBrowserTest::GetFirstAppWindowForBrowser(browser()); + ASSERT_TRUE(window); + const Extension* feedback_app = window->GetExtension(); + ASSERT_TRUE(feedback_app); + EXPECT_EQ(feedback_app->id(), + std::string(extension_misc::kFeedbackExtensionId)); } private: - void EnsureFeedbackAppUIShown(FeedbackDialog* feedback_dialog, - base::OnceClosure callback) { - auto* widget = feedback_dialog->GetWidget(); - ASSERT_NE(nullptr, widget); - if (widget->IsActive()) { - std::move(callback).Run(); - } else { - base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( - FROM_HERE, - base::BindOnce(&FeedbackTest::EnsureFeedbackAppUIShown, - base::Unretained(this), feedback_dialog, - std::move(callback)), - base::Seconds(1)); - } + void InvokeFeedbackUI(FeedbackFlow flow, + const std::string& extra_diagnostics, + bool from_assistant, + bool include_bluetooth_logs, + bool show_questionnaire) { + extensions::FeedbackPrivateAPI* api = + extensions::FeedbackPrivateAPI::GetFactoryInstance()->Get( + browser()->profile()); + api->RequestFeedbackForFlow( + "Test description", "Test placeholder", "Test tag", extra_diagnostics, + GURL("http://www.test.com"), flow, from_assistant, + include_bluetooth_logs, show_questionnaire); } - - FeedbackDialog* feedback_dialog_; }; class TestFeedbackUploaderDelegate @@ -100,53 +113,58 @@ raw_ptr<base::RunLoop> quit_on_dispatch_; }; -// TODO(http://b/225380600): Fix the tests on mac. -#if !BUILDFLAG(IS_MAC) +// TODO(crbug.com/1241504): disable tests. +IN_PROC_BROWSER_TEST_F(FeedbackTest, DISABLED_ShowFeedback) { + WaitForExtensionViewsToLoad(); -IN_PROC_BROWSER_TEST_F(FeedbackTest, ShowFeedback) { + ASSERT_TRUE(IsFeedbackAppAvailable()); StartFeedbackUI(FeedbackFlow::FEEDBACK_FLOW_REGULAR, std::string()); VerifyFeedbackAppLaunch(); } -IN_PROC_BROWSER_TEST_F(FeedbackTest, ShowLoginFeedback) { - content::WebContentsAddedObserver observer; +// TODO(crbug.com/1241504): disable tests. +IN_PROC_BROWSER_TEST_F(FeedbackTest, DISABLED_ShowLoginFeedback) { + WaitForExtensionViewsToLoad(); + ASSERT_TRUE(IsFeedbackAppAvailable()); StartFeedbackUI(FeedbackFlow::FEEDBACK_FLOW_LOGIN, std::string()); VerifyFeedbackAppLaunch(); - content::WebContents* content = observer.GetWebContents(); - ASSERT_TRUE(content::WaitForLoadStop(content)); - ASSERT_EQ(u"Feedback", content->GetTitle()); - ASSERT_EQ("chrome://feedback/", content->GetURL().spec()); + AppWindow* const window = + PlatformAppBrowserTest::GetFirstAppWindowForBrowser(browser()); + ASSERT_TRUE(window); + content::WebContents* const content = window->web_contents(); bool bool_result = false; ASSERT_TRUE(content::ExecuteScriptAndExtractBool( content, - "window.domAutomationController.send(" - "document.querySelector('#page-url').hidden && " - "document.querySelector('#attach-file-container').hidden && " - "document.querySelector('#attach-file-note').hidden);", + "domAutomationController.send(" + "$('page-url').hidden && $('attach-file-container').hidden && " + "$('attach-file-note').hidden);", &bool_result)); EXPECT_TRUE(bool_result); } // Tests that there's an option in the email drop down box with a value ''. -IN_PROC_BROWSER_TEST_F(FeedbackTest, AnonymousUser) { - content::WebContentsAddedObserver observer; +// TODO(crbug.com/1241504): disable tests. +IN_PROC_BROWSER_TEST_F(FeedbackTest, DISABLED_AnonymousUser) { + WaitForExtensionViewsToLoad(); + ASSERT_TRUE(IsFeedbackAppAvailable()); StartFeedbackUI(FeedbackFlow::FEEDBACK_FLOW_REGULAR, std::string()); VerifyFeedbackAppLaunch(); - content::WebContents* content = observer.GetWebContents(); - ASSERT_TRUE(content::WaitForLoadStop(content)); + AppWindow* const window = + PlatformAppBrowserTest::GetFirstAppWindowForBrowser(browser()); + ASSERT_TRUE(window); + content::WebContents* const content = window->web_contents(); bool bool_result = false; ASSERT_TRUE(content::ExecuteScriptAndExtractBool( content, "domAutomationController.send(" " ((function() {" - " var options = " - "document.querySelector('#user-email-drop-down').options;" + " var options = $('user-email-drop-down').options;" " for (var option in options) {" " if (options[option].value == '')" " return true;" @@ -160,14 +178,18 @@ // Ensures that when extra diagnostics are provided with feedback, they are // injected properly in the system information. -IN_PROC_BROWSER_TEST_F(FeedbackTest, ExtraDiagnostics) { - content::WebContentsAddedObserver observer; +// TODO(crbug.com/1241504): disable tests. +IN_PROC_BROWSER_TEST_F(FeedbackTest, DISABLED_ExtraDiagnostics) { + WaitForExtensionViewsToLoad(); + ASSERT_TRUE(IsFeedbackAppAvailable()); StartFeedbackUI(FeedbackFlow::FEEDBACK_FLOW_REGULAR, "Some diagnostics"); VerifyFeedbackAppLaunch(); - content::WebContents* content = observer.GetWebContents(); - ASSERT_TRUE(content::WaitForLoadStop(content)); + AppWindow* const window = + PlatformAppBrowserTest::GetFirstAppWindowForBrowser(browser()); + ASSERT_TRUE(window); + content::WebContents* const content = window->web_contents(); bool bool_result = false; ASSERT_TRUE(content::ExecuteScriptAndExtractBool( @@ -190,25 +212,27 @@ // Ensures that when triggered from Assistant with Google account, Assistant // checkbox are not hidden. -IN_PROC_BROWSER_TEST_F(FeedbackTest, ShowFeedbackFromAssistant) { - content::WebContentsAddedObserver observer; +// Disabled due to flake: https://crbug.com/1240591 +IN_PROC_BROWSER_TEST_F(FeedbackTest, DISABLED_ShowFeedbackFromAssistant) { + WaitForExtensionViewsToLoad(); + ASSERT_TRUE(IsFeedbackAppAvailable()); StartFeedbackUI(FeedbackFlow::FEEDBACK_FLOW_GOOGLEINTERNAL, std::string(), /*from_assistant*/ true); VerifyFeedbackAppLaunch(); - content::WebContents* content = observer.GetWebContents(); - ASSERT_TRUE(content::WaitForLoadStop(content)); + AppWindow* const window = + PlatformAppBrowserTest::GetFirstAppWindowForBrowser(browser()); + ASSERT_TRUE(window); + content::WebContents* const content = window->web_contents(); bool bool_result = false; ASSERT_TRUE(content::ExecuteScriptAndExtractBool( content, "domAutomationController.send(" " ((function() {" - " var elem = " - " document.getElementById('assistant-checkbox-container');" - " if (elem != null && elem.hidden == true) " - " {" + " if ($('assistant-checkbox-container') != null &&" + " $('assistant-checkbox-container').hidden == true) {" " return false;" " }" " return true;" @@ -222,14 +246,17 @@ // string is entered into the description, that we provide the option for // uploading Bluetooth logs as well. IN_PROC_BROWSER_TEST_F(FeedbackTest, ProvideBluetoothLogs) { - content::WebContentsAddedObserver observer; + WaitForExtensionViewsToLoad(); + ASSERT_TRUE(IsFeedbackAppAvailable()); StartFeedbackUI(FeedbackFlow::FEEDBACK_FLOW_GOOGLEINTERNAL, std::string(), /*from_assistant*/ false, /*include_bluetooth_logs*/ true); VerifyFeedbackAppLaunch(); - content::WebContents* content = observer.GetWebContents(); - ASSERT_TRUE(content::WaitForLoadStop(content)); + AppWindow* const window = + PlatformAppBrowserTest::GetFirstAppWindowForBrowser(browser()); + ASSERT_TRUE(window); + content::WebContents* const content = window->web_contents(); // It shouldn't be visible until we put the Bluetooth text into the // description. @@ -238,14 +265,12 @@ content, "domAutomationController.send(" " ((function() {" - " var bluetooth = " - " document.getElementById('bluetooth-checkbox-container');" - " if (bluetooth != null && bluetooth.hidden == true) " - " { " - " return true; " - " } " - " return false; " - "})()));", + " if ($('bluetooth-checkbox-container') != null &&" + " $('bluetooth-checkbox-container').hidden == true) {" + " return true;" + " }" + " return false;" + " })()));", &bool_result)); EXPECT_TRUE(bool_result); bool_result = false; @@ -256,13 +281,12 @@ " var elem = document.getElementById('description-text');" " elem.value = 'bluetooth';" " elem.dispatchEvent(new Event('input', {}));" - " var bluetooth = " - " document.getElementById('bluetooth-checkbox-container');" - " if (bluetooth != null && bluetooth.hidden == false) {" - " return true; " + " if ($('bluetooth-checkbox-container') != null &&" + " $('bluetooth-checkbox-container').hidden == false) {" + " return true;" " }" " return false;" - "})()));", + " })()));", &bool_result)); EXPECT_TRUE(bool_result); } @@ -271,24 +295,27 @@ // string is entered into the description, that we append Bluetooth-related // questions to the issue description. IN_PROC_BROWSER_TEST_F(FeedbackTest, AppendQuestionnaire) { - content::WebContentsAddedObserver observer; + WaitForExtensionViewsToLoad(); + + ASSERT_TRUE(IsFeedbackAppAvailable()); StartFeedbackUI(FeedbackFlow::FEEDBACK_FLOW_GOOGLEINTERNAL, std::string(), /*from_assistant*/ false, /*include_bluetooth_logs*/ true, /*show_questionnaire*/ true); VerifyFeedbackAppLaunch(); - content::WebContents* content = observer.GetWebContents(); - ASSERT_TRUE(content::WaitForLoadStop(content)); + AppWindow* const window = + PlatformAppBrowserTest::GetFirstAppWindowForBrowser(browser()); + ASSERT_TRUE(window); + content::WebContents* const content = window->web_contents(); - // Questionnaire shouldn't be visible until we put the Bluetooth text into - // the description. + // Questionnaire shouldn't be visible until we put the Bluetooth text into the + // description. bool bool_result = false; ASSERT_TRUE(content::ExecuteScriptAndExtractBool( content, "domAutomationController.send(" " ((function() {" - " var elem = document.getElementById('description-text');" - " return !elem.value.includes('please answer');" + " return !$('description-text').value.includes('please answer');" " })()));", &bool_result)); EXPECT_TRUE(bool_result); @@ -326,14 +353,18 @@ // Questionnaires should not be displayed if it's not a Googler session. IN_PROC_BROWSER_TEST_F(FeedbackTest, AppendQuestionnaireNotGoogler) { - content::WebContentsAddedObserver observer; + WaitForExtensionViewsToLoad(); + + ASSERT_TRUE(IsFeedbackAppAvailable()); StartFeedbackUI(FeedbackFlow::FEEDBACK_FLOW_REGULAR, std::string(), /*from_assistant*/ false, /*include_bluetooth_logs*/ false, /*show_questionnaire*/ false); VerifyFeedbackAppLaunch(); - content::WebContents* content = observer.GetWebContents(); - ASSERT_TRUE(content::WaitForLoadStop(content)); + AppWindow* const window = + PlatformAppBrowserTest::GetFirstAppWindowForBrowser(browser()); + ASSERT_TRUE(window); + content::WebContents* const content = window->web_contents(); // Questionnaire shouldn't be visible in the beginning. bool bool_result = false; @@ -341,8 +372,7 @@ content, "domAutomationController.send(" " ((function() {" - " var elem = document.getElementById('description-text');" - " return !elem.value.includes('[Bluetooth]');" + " return !$('description-text').value.includes('[Bluetooth]');" " })()));", &bool_result)); EXPECT_TRUE(bool_result); @@ -363,7 +393,8 @@ } #endif // BUILDFLAG(IS_CHROMEOS_ASH) -IN_PROC_BROWSER_TEST_F(FeedbackTest, GetTargetTabUrl) { +// Disabled due to flake: https://crbug.com/1069870 +IN_PROC_BROWSER_TEST_F(FeedbackTest, DISABLED_GetTargetTabUrl) { const std::pair<std::string, std::string> test_cases[] = { {"https://www.google.com/", "https://www.google.com/"}, {"chrome://version/", chrome::kChromeUIVersionURL}, @@ -404,13 +435,16 @@ // Disabled due to flake: https://crbug.com/1180373 IN_PROC_BROWSER_TEST_F(FeedbackTest, DISABLED_SubmissionTest) { - content::WebContentsAddedObserver observer; + WaitForExtensionViewsToLoad(); + ASSERT_TRUE(IsFeedbackAppAvailable()); StartFeedbackUI(FeedbackFlow::FEEDBACK_FLOW_GOOGLEINTERNAL, std::string()); VerifyFeedbackAppLaunch(); - content::WebContents* content = observer.GetWebContents(); - ASSERT_TRUE(content::WaitForLoadStop(content)); + AppWindow* const window = + PlatformAppBrowserTest::GetFirstAppWindowForBrowser(browser()); + ASSERT_TRUE(window); + content::WebContents* const content = window->web_contents(); // Set a delegate for the uploader which will be invoked when the report // normally would have been uploaded. We have it setup to then quit the @@ -427,9 +461,8 @@ content, "domAutomationController.send(" " ((function() {" - " var button = document.getElementById('send-report-button');" - " if (button != null) {" - " button.click();" + " if ($('send-report-button') != null) {" + " document.getElementById('send-report-button').click();" " return true;" " }" " return false;" @@ -444,6 +477,5 @@ ->GetForBrowserContext(browser()->profile()) ->set_feedback_uploader_delegate(nullptr); } -#endif } // namespace extensions
diff --git a/chrome/browser/extensions/api/virtual_keyboard_private/chrome_virtual_keyboard_delegate.cc b/chrome/browser/extensions/api/virtual_keyboard_private/chrome_virtual_keyboard_delegate.cc index 055eaed..9d70865 100644 --- a/chrome/browser/extensions/api/virtual_keyboard_private/chrome_virtual_keyboard_delegate.cc +++ b/chrome/browser/extensions/api/virtual_keyboard_private/chrome_virtual_keyboard_delegate.cc
@@ -576,6 +576,9 @@ "borderedkey", base::FeatureList::IsEnabled( chromeos::features::kVirtualKeyboardBorderedKey))); features.Append(GenerateFeatureFlag( + "multitouch", base::FeatureList::IsEnabled( + chromeos::features::kVirtualKeyboardMultitouch))); + features.Append(GenerateFeatureFlag( "systemchinesephysicaltyping", base::FeatureList::IsEnabled( chromeos::features::kSystemChinesePhysicalTyping)));
diff --git a/chrome/browser/extensions/chrome_extensions_browser_interface_binders.cc b/chrome/browser/extensions/chrome_extensions_browser_interface_binders.cc index 851e920..96fdb03 100644 --- a/chrome/browser/extensions/chrome_extensions_browser_interface_binders.cc +++ b/chrome/browser/extensions/chrome_extensions_browser_interface_binders.cc
@@ -17,6 +17,8 @@ #if BUILDFLAG(IS_CHROMEOS_ASH) #include "ash/components/enhanced_network_tts/mojom/enhanced_network_tts.mojom.h" +#include "ash/services/chromebox_for_meetings/public/cpp/appid_util.h" +#include "ash/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" #include "ash/webui/camera_app_ui/camera_app_ui.h" #include "chrome/browser/ash/enhanced_network_tts/enhanced_network_tts_impl.h" #include "chrome/browser/ash/remote_apps/remote_apps_impl.h" @@ -29,8 +31,6 @@ #include "chromeos/components/remote_apps/mojom/remote_apps.mojom.h" #include "chromeos/language/language_packs/language_packs_impl.h" #include "chromeos/language/public/mojom/language_packs.mojom.h" -#include "chromeos/services/chromebox_for_meetings/public/cpp/appid_util.h" -#include "chromeos/services/chromebox_for_meetings/public/mojom/cfm_service_manager.mojom.h" #include "chromeos/services/media_perception/public/mojom/media_perception.mojom.h" #include "chromeos/services/tts/public/mojom/tts_service.mojom.h" #include "extensions/browser/api/extensions_api_client.h" @@ -47,8 +47,8 @@ #endif #if BUILDFLAG(PLATFORM_CFM) +#include "ash/services/chromebox_for_meetings/public/cpp/service_connection.h" #include "chromeos/components/chromebox_for_meetings/features/features.h" -#include "chromeos/services/chromebox_for_meetings/public/cpp/service_connection.h" #endif #endif // BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json index 3219b239..debef40 100644 --- a/chrome/browser/flag-metadata.json +++ b/chrome/browser/flag-metadata.json
@@ -1163,11 +1163,6 @@ "expiry_milestone": 101 }, { - "name": "detected-source-language-option", - "owners": [ "cuianthony", "chrome-language@google.com" ], - "expiry_milestone": 97 - }, - { "name": "device-force-scheduled-reboot", "owners": [ "sanjaperisic"], "expiry_milestone": 102 @@ -1810,6 +1805,11 @@ "expiry_milestone": 100 }, { + "name": "enable-cros-virtual-keyboard-multitouch", + "owners": [ "michellegc", "essential-inputs-team@google.com" ], + "expiry_milestone": 110 + }, + { "name": "enable-cros-virtual-keyboard-new-header", "owners": ["jopalmer", "essential-inputs-team@google.com"], "expiry_milestone" : 110 @@ -3859,6 +3859,11 @@ "expiry_milestone": 105 }, { + "name": "launcher-lacros-integration", + "owners": ["wrong", "thanhdng", "tby"], + "expiry_milestone": 105 + }, + { "name": "launcher-nudge", "owners": [ "wcwang", "//ash/app_list/OWNERS" ], "expiry_milestone": 104 @@ -4181,7 +4186,7 @@ { "name": "new-overflow-menu", "owners": [ "rkgibson@google.com", "bling-flags@google.com" ], - "expiry_milestone": 99 + "expiry_milestone": 105 }, { "name": "new-shortcut-mapping", @@ -4199,6 +4204,11 @@ "expiry_milestone": 100 }, { + "name": "notification-permission-rationale-dialog", + "owners": ["shaktisahu", "salg"], + "expiry_milestone": 110 + }, + { "name": "notification-scheduler", "owners": [ "//chrome/browser/notifications/scheduler/OWNERS" ], "expiry_milestone": 102 @@ -4410,7 +4420,7 @@ { "name": "omnibox-local-history-zero-suggest", "owners": ["rkgibson@google.com", "stkhapugin", "chrome-omnibox-team@google.com"], - "expiry_milestone": 100 + "expiry_milestone": 105 }, { "name": "omnibox-max-url-matches", @@ -4435,7 +4445,7 @@ { "name": "omnibox-new-textfield-implementation", "owners": ["stkhapugin", "rkgibson@google.com", "chrome-omnibox-team@google.com"], - "expiry_milestone": 95 + "expiry_milestone": 105 }, { "name": "omnibox-on-device-head-suggestions-incognito", @@ -6100,12 +6110,12 @@ { "name": "webpage-alternative-text-zoom", "owners": [ "rkgibson@google.com", "bling-flags@google.com" ], - "expiry_milestone": 91 + "expiry_milestone": 105 }, { "name": "webpage-default-zoom-from-dynamic-type", "owners": [ "rkgibson@google.com", "bling-flags@google.com" ], - "expiry_milestone": 91 + "expiry_milestone": 105 }, { "name": "webui-feedback",
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc index 29872bc6..2d1678d0 100644 --- a/chrome/browser/flag_descriptions.cc +++ b/chrome/browser/flag_descriptions.cc
@@ -3327,6 +3327,12 @@ "Show a new menu item 'New Window' on tablet-sized screen when Chrome " "can open a new window and create a new instance in it."; +const char kNotificationPermissionRationaleName[] = + "Notification Permission Rationale UI"; +const char kNotificationPermissionRationaleDescription[] = + "Configure the dialog shown before requesting notification permission. " + "Only works with builds targeting Android T."; + const char kOfflinePagesLivePageSharingName[] = "Enables live page sharing of offline pages"; const char kOfflinePagesLivePageSharingDescription[] = @@ -5036,6 +5042,11 @@ "migration is rolled out to the user, the migration will not run and the " "user can continue to use lacros without profile migration."; +const char kLauncherLacrosIntegrationName[] = "Launcher lacros integration"; +const char kLauncherLacrosIntegrationDescription[] = + "Forces launcher Omnibox search queries to be sent to the lacros browser. " + "If disabled, queries are sent to the ash browser."; + const char kLimitShelfItemsToActiveDeskName[] = "Limit Shelf items to active desk"; const char kLimitShelfItemsToActiveDeskDescription[] = @@ -5382,6 +5393,10 @@ "Always disable virtual keyboard regardless of device mode. Workaround for " "virtual keyboard showing with some external keyboards."; +const char kVirtualKeyboardMultitouchName[] = "Virtual Keyboard Multitouch"; +const char kVirtualKeyboardMultitouchDescription[] = + "Enables multitouch on the virtual keyboard."; + const char kWakeOnWifiAllowedName[] = "Allow enabling wake on WiFi features"; const char kWakeOnWifiAllowedDescription[] = "Allows wake on WiFi features in shill to be enabled.";
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h index b9b663a..560ac38 100644 --- a/chrome/browser/flag_descriptions.h +++ b/chrome/browser/flag_descriptions.h
@@ -1904,6 +1904,9 @@ extern const char kNewWindowAppMenuName[]; extern const char kNewWindowAppMenuDescription[]; +extern const char kNotificationPermissionRationaleName[]; +extern const char kNotificationPermissionRationaleDescription[]; + extern const char kOfflinePagesLivePageSharingName[]; extern const char kOfflinePagesLivePageSharingDescription[]; @@ -2893,6 +2896,9 @@ extern const char kLacrosSupportName[]; extern const char kLacrosSupportDescription[]; +extern const char kLauncherLacrosIntegrationName[]; +extern const char kLauncherLacrosIntegrationDescription[]; + extern const char kLimitShelfItemsToActiveDeskName[]; extern const char kLimitShelfItemsToActiveDeskDescription[]; @@ -3099,6 +3105,9 @@ extern const char kVirtualKeyboardDisabledName[]; extern const char kVirtualKeyboardDisabledDescription[]; +extern const char kVirtualKeyboardMultitouchName[]; +extern const char kVirtualKeyboardMultitouchDescription[]; + extern const char kWakeOnWifiAllowedName[]; extern const char kWakeOnWifiAllowedDescription[];
diff --git a/chrome/browser/policy/test/isolated_apps_developer_mode_allowed_browsertest.cc b/chrome/browser/policy/test/isolated_apps_developer_mode_allowed_browsertest.cc index 9704c68..034b2ec 100644 --- a/chrome/browser/policy/test/isolated_apps_developer_mode_allowed_browsertest.cc +++ b/chrome/browser/policy/test/isolated_apps_developer_mode_allowed_browsertest.cc
@@ -12,7 +12,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" -#include "chrome/browser/web_applications/test/isolated_app_test_utils.h" +#include "chrome/browser/ui/web_applications/test/isolated_app_test_utils.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/ui_test_utils.h" #include "components/policy/core/browser/browser_policy_connector.h"
diff --git a/chrome/browser/predictors/preconnect_manager.cc b/chrome/browser/predictors/preconnect_manager.cc index 39ace4b..6f43114 100644 --- a/chrome/browser/predictors/preconnect_manager.cc +++ b/chrome/browser/predictors/preconnect_manager.cc
@@ -189,10 +189,12 @@ #if defined(UNIT_TEST) if (!network_context) { - // Cannot invoke the callback right away because it would cause the - // use-after-free after returning from this function. - content::GetUIThreadTaskRunner({content::BrowserTaskType::kPreconnect}) - ->PostTask(FROM_HERE, base::BindOnce(std::move(callback), false)); + // Cannot invoke the callback right away because it would cause a + // use-after-free after returning from this method: + // The return value of this method is assigned to a member variable of a + // PreresolveJob that is destroyed when the callback executes. + content::GetUIThreadTaskRunner()->PostTask( + FROM_HERE, base::BindOnce(std::move(callback), false)); return nullptr; } #endif
diff --git a/chrome/browser/printing/print_backend_service_manager.cc b/chrome/browser/printing/print_backend_service_manager.cc index d462d06..ef24d1b 100644 --- a/chrome/browser/printing/print_backend_service_manager.cc +++ b/chrome/browser/printing/print_backend_service_manager.cc
@@ -95,16 +95,17 @@ } uint32_t PrintBackendServiceManager::RegisterQueryClient() { - return RegisterClient(ClientType::kQuery, kEmptyPrinterName); + return *RegisterClient(ClientType::kQuery, kEmptyPrinterName); } -uint32_t PrintBackendServiceManager::RegisterQueryWithUiClient() { +absl::optional<uint32_t> +PrintBackendServiceManager::RegisterQueryWithUiClient() { return RegisterClient(ClientType::kQueryWithUi, kEmptyPrinterName); } uint32_t PrintBackendServiceManager::RegisterPrintDocumentClient( const std::string& printer_name) { DCHECK_NE(printer_name, kEmptyPrinterName); - return RegisterClient(ClientType::kPrintDocument, printer_name); + return *RegisterClient(ClientType::kPrintDocument, printer_name); } void PrintBackendServiceManager::UnregisterClient(uint32_t id) { @@ -407,7 +408,7 @@ #endif } -uint32_t PrintBackendServiceManager::RegisterClient( +absl::optional<uint32_t> PrintBackendServiceManager::RegisterClient( ClientType client_type, const std::string& printer_name) { uint32_t client_id = ++last_client_id_; @@ -421,7 +422,8 @@ break; case ClientType::kQueryWithUi: #if !BUILDFLAG(IS_LINUX) - DCHECK_EQ(query_with_ui_clients_.size(), 0u); + if (!query_with_ui_clients_.empty()) + return absl::nullopt; #endif query_with_ui_clients_.insert(client_id); break;
diff --git a/chrome/browser/printing/print_backend_service_manager.h b/chrome/browser/printing/print_backend_service_manager.h index ad92c9f..9b511ea 100644 --- a/chrome/browser/printing/print_backend_service_manager.h +++ b/chrome/browser/printing/print_backend_service_manager.h
@@ -19,6 +19,7 @@ #include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote_set.h" #include "printing/buildflags/buildflags.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #if !BUILDFLAG(ENABLE_OOP_PRINTING) #error "Out-of-process printing must be enabled." @@ -56,8 +57,10 @@ uint32_t RegisterQueryClient(); // Register as a client of PrintBackendServiceManager for print queries which - // require a system print dialog UI. - uint32_t RegisterQueryWithUiClient(); + // require a system print dialog UI. If a platform cannot support concurrent + // queries of this type then this will return `absl::nullopt` if another + // client is already registered. + absl::optional<uint32_t> RegisterQueryWithUiClient(); // Register as a client of PrintBackendServiceManager for printing a document // to a specific printer. @@ -232,8 +235,8 @@ std::string GetRemoteIdForPrinterName(const std::string& printer_name) const; // Common helper for registering clients. - uint32_t RegisterClient(ClientType client_type, - const std::string& printer_name); + absl::optional<uint32_t> RegisterClient(ClientType client_type, + const std::string& printer_name); // Get the total number of clients registered. size_t GetClientsRegisteredCount() const;
diff --git a/chrome/browser/printing/printer_manager_dialog_linux.cc b/chrome/browser/printing/printer_manager_dialog_linux.cc index 8515ec8..ba446689 100644 --- a/chrome/browser/printing/printer_manager_dialog_linux.cc +++ b/chrome/browser/printing/printer_manager_dialog_linux.cc
@@ -77,6 +77,7 @@ break; case base::nix::DESKTOP_ENVIRONMENT_CINNAMON: case base::nix::DESKTOP_ENVIRONMENT_GNOME: + case base::nix::DESKTOP_ENVIRONMENT_UKUI: case base::nix::DESKTOP_ENVIRONMENT_OTHER: opened = OpenPrinterConfigDialog(kSystemConfigPrinterCommand) || OpenPrinterConfigDialog(kGnomeControlCenterPrintersCommand);
diff --git a/chrome/browser/renderer_context_menu/render_view_context_menu_unittest.cc b/chrome/browser/renderer_context_menu/render_view_context_menu_unittest.cc index d5a0428f..fc003e4 100644 --- a/chrome/browser/renderer_context_menu/render_view_context_menu_unittest.cc +++ b/chrome/browser/renderer_context_menu/render_view_context_menu_unittest.cc
@@ -383,7 +383,7 @@ RenderViewContextMenuTest::SetUp(); // TestingProfile does not provide a protocol registry. registry_ = std::make_unique<custom_handlers::ProtocolHandlerRegistry>( - profile(), nullptr); + profile()->GetPrefs(), nullptr); } void TearDown() override { @@ -447,7 +447,7 @@ void SetUp() override { ChromeRenderViewHostTestHarness::SetUp(); registry_ = std::make_unique<custom_handlers::ProtocolHandlerRegistry>( - profile(), nullptr); + profile()->GetPrefs(), nullptr); TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( profile(),
diff --git a/chrome/browser/resources/chromeos/BUILD.gn b/chrome/browser/resources/chromeos/BUILD.gn index 3c920b5..f60b00db7 100644 --- a/chrome/browser/resources/chromeos/BUILD.gn +++ b/chrome/browser/resources/chromeos/BUILD.gn
@@ -66,6 +66,7 @@ "account_manager:closure_compile", "account_manager/components:closure_compile", "add_supervision:closure_compile", + "arc_account_picker:closure_compile", "bluetooth_pairing_dialog:closure_compile", "crostini_installer:closure_compile", "crostini_upgrader:closure_compile",
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/BUILD.gn b/chrome/browser/resources/chromeos/accessibility/chromevox/BUILD.gn index 3661acd4..05de254a 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/BUILD.gn +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/BUILD.gn
@@ -29,7 +29,6 @@ "../common/key_code.js", "../common/string_util.js", "../common/tree_walker.js", - "background/auto_scroll_handler.js", "background/automation_object_constructor_installer.js", "background/braille_captions_background.js", "background/braille_command_data.js", @@ -37,7 +36,6 @@ "background/command_handler_interface.js", "background/custom_automation_event.js", "background/event_source.js", - "background/gesture_command_data.js", "background/keymaps/key_map.js", "background/output/locale_output_helper.js", "background/logging/event_stream_logger.js", @@ -91,6 +89,7 @@ # ES6 modules. chromevox_es6_modules = [ "../common/instance_checker.js", + "background/auto_scroll_handler.js", "background/background.js", "background/base_automation_handler.js", "background/braille_background.js", @@ -109,6 +108,7 @@ "background/es6_loader.js", "background/find_handler.js", "background/focus_automation_handler.js", + "background/gesture_command_data.js", "background/gesture_command_handler.js", "background/gesture_interface.js", "background/injected_script_loader.js",
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/background/auto_scroll_handler.js b/chrome/browser/resources/chromeos/accessibility/chromevox/background/auto_scroll_handler.js index 629d543..e50f672 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/background/auto_scroll_handler.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/background/auto_scroll_handler.js
@@ -11,22 +11,13 @@ // option modification. /* eslint prefer-const: ["error", {"ignoreReadBeforeAssign": true}] */ -goog.provide('AutoScrollHandler'); - -goog.require('AutomationPredicate'); -goog.require('AutomationUtil'); -goog.require('CommandHandlerInterface'); -goog.require('constants'); - -goog.scope(function() { -const Dir = constants.Dir; const AutomationNode = chrome.automation.AutomationNode; const EventType = chrome.automation.EventType; /** * Handler of auto scrolling. Most logics are for supporting ARC++. */ -AutoScrollHandler = class { +export class AutoScrollHandler { constructor() { /** @private {boolean} */ this.isScrolling_ = false; @@ -41,12 +32,20 @@ this.relatedFocusEventHappened_ = false; } + /** @return {!AutoScrollHandler} */ + static getInstance() { + if (!AutoScrollHandler.instance_) { + AutoScrollHandler.instance_ = new AutoScrollHandler(); + } + return AutoScrollHandler.instance_; + } + /** * This should be called before any command triggers ChromeVox navigation. * * @param {!cursors.Range} target The range that is going to be navigated * before scrolling. - * @param {Dir} dir The direction to navigate. + * @param {constants.Dir} dir The direction to navigate. * @param {?AutomationPredicate.Unary} pred The predicate to match. * @param {?cursors.Unit} unit The unit to navigate by. * @param {?Object} speechProps The optional speech properties given to @@ -93,8 +92,9 @@ let current = target.start.node; let parent = current.parent; while (parent && parent.root === current.root) { - if (!(dir === Dir.BACKWARD && parent.firstChild === current) && - !(dir === Dir.FORWARD && parent.lastChild === current)) { + if (!(dir === constants.Dir.BACKWARD && + parent.firstChild === current) && + !(dir === constants.Dir.FORWARD && parent.lastChild === current)) { // Currently on non-edge node. Don't try scrolling. scrollable = null; break; @@ -118,7 +118,7 @@ (async () => { const scrollResult = await new Promise(resolve => { - if (dir === Dir.FORWARD) { + if (dir === constants.Dir.FORWARD) { scrollable.scrollForward(resolve); } else { scrollable.scrollBackward(resolve); @@ -192,7 +192,7 @@ } } else if (pred) { let node; - if (dir === Dir.FORWARD) { + if (dir === constants.Dir.FORWARD) { node = AutomationUtil.findNextNode( this.scrollingNode_, dir, pred, {root: rootPred, skipInitialSubtree: false}); @@ -256,7 +256,7 @@ this.relatedFocusEventHappened_ = true; return false; } -}; +} /** * An array of Automation event types that AutoScrollHandler observes when @@ -297,5 +297,5 @@ */ AutoScrollHandler.DELAY_HANDLE_SCROLLED_MS = 150; -goog.addSingletonGetter(AutoScrollHandler); -}); // goog.scope +/** @private {?AutoScrollHandler} */ +AutoScrollHandler.instance_ = null;
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/background/auto_scroll_handler_test.js b/chrome/browser/resources/chromeos/accessibility/chromevox/background/auto_scroll_handler_test.js index c90ffc6..a91f483 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/background/auto_scroll_handler_test.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/background/auto_scroll_handler_test.js
@@ -17,6 +17,13 @@ this.forceContextualLastOutput(); } + /** @override */ + async setUpDeferred() { + await super.setUpDeferred(); + await importModule( + 'AutoScrollHandler', '/chromevox/background/auto_scroll_handler.js'); + } + runWithFakeArcSimpleScrollable(callback) { // This simulates a scrolling behavior of Android scrollable, where when a // scroll action is performed, a new item is added to the list.
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/background/command_handler.js b/chrome/browser/resources/chromeos/accessibility/chromevox/background/command_handler.js index 22856d239..be5c97161c 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/background/command_handler.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/background/command_handler.js
@@ -7,10 +7,12 @@ */ import {TypingEcho} from '../common/editable_text_base.js'; +import {AutoScrollHandler} from './auto_scroll_handler.js'; import {BrailleBackground} from './braille_background.js'; import {ChromeVoxBackground} from './classic_background.js'; import {Color} from './color.js'; import {DesktopAutomationInterface} from './desktop_automation_interface.js'; +import {GestureGranularity} from './gesture_command_data.js'; import {GestureInterface} from './gesture_interface.js'; import {SmartStickyMode} from './smart_sticky_mode.js';
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/background/desktop_automation_handler.js b/chrome/browser/resources/chromeos/accessibility/chromevox/background/desktop_automation_handler.js index 92edae6..d422e695 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/background/desktop_automation_handler.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/background/desktop_automation_handler.js
@@ -5,6 +5,7 @@ /** * @fileoverview Handles automation from a desktop automation node. */ +import {AutoScrollHandler} from './auto_scroll_handler.js'; import {DesktopAutomationInterface} from './desktop_automation_interface.js'; import {TextEditHandler} from './editing/editing.js';
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/background/gesture_command_data.js b/chrome/browser/resources/chromeos/accessibility/chromevox/background/gesture_command_data.js index 43e4596..15900d18 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/background/gesture_command_data.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/background/gesture_command_data.js
@@ -2,10 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -goog.provide('GestureCommandData'); -goog.provide('GestureGranularity'); - -goog.require('KeyCode'); +export const GestureCommandData = {}; /** * Map from gesture names (ax::mojom::Gesture defined in @@ -92,7 +89,7 @@ * Possible granularities to navigate. * @enum {number} */ -GestureGranularity = { +export const GestureGranularity = { CHARACTER: 0, WORD: 1, LINE: 2,
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/background/gesture_command_handler.js b/chrome/browser/resources/chromeos/accessibility/chromevox/background/gesture_command_handler.js index 0bef325e..967ec0a 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/background/gesture_command_handler.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/background/gesture_command_handler.js
@@ -5,6 +5,7 @@ /** * @fileoverview Handles gesture-based commands. */ +import {GestureCommandData, GestureGranularity} from './gesture_command_data.js'; import {GestureInterface} from './gesture_interface.js'; import {PointerHandler} from './pointer_handler.js';
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/background/gesture_interface.js b/chrome/browser/resources/chromeos/accessibility/chromevox/background/gesture_interface.js index 2dd239f55..10eefd6 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/background/gesture_interface.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/background/gesture_interface.js
@@ -6,6 +6,7 @@ * @fileoverview Interface to prevent circular dependencies between * CommandHandler and GestureCommandHandler. */ +import {GestureGranularity} from './gesture_command_data.js'; export const GestureInterface = {};
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/background/loader.js b/chrome/browser/resources/chromeos/accessibility/chromevox/background/loader.js index f89bbd5..3702e5a 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/background/loader.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/background/loader.js
@@ -10,7 +10,6 @@ goog.require('AutomationPredicate'); goog.require('AutomationTreeWalker'); goog.require('AutomationUtil'); -goog.require('AutoScrollHandler'); goog.require('AutomationObjectConstructorInstaller'); goog.require('BrailleCaptionsBackground'); goog.require('BrailleCommandData'); @@ -33,8 +32,6 @@ goog.require('EventSourceState'); goog.require('EventStreamLogger'); goog.require('ExtensionBridge'); -goog.require('GestureCommandData'); -goog.require('GestureGranularity'); goog.require('JaPhoneticMap'); goog.require('KeyCode'); goog.require('LibLouis.FormType');
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/learn_mode/kbexplorer_loader.js b/chrome/browser/resources/chromeos/accessibility/chromevox/learn_mode/kbexplorer_loader.js index 2f27504..d674d2b7b 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/learn_mode/kbexplorer_loader.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/learn_mode/kbexplorer_loader.js
@@ -8,7 +8,6 @@ goog.require('BrailleCommandData'); goog.require('BrailleKeyEvent'); -goog.require('GestureCommandData'); goog.require('Spannable'); goog.require('AbstractTts'); goog.require('BrailleKeyCommand');
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/learn_mode/learn_mode.js b/chrome/browser/resources/chromeos/accessibility/chromevox/learn_mode/learn_mode.js index 2d54abc..0f79c3e 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/learn_mode/learn_mode.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/learn_mode/learn_mode.js
@@ -6,6 +6,7 @@ * @fileoverview Script for ChromeOS keyboard explorer. * */ +import {GestureCommandData} from '../background/gesture_command_data.js'; /** * Class to manage the keyboard explorer.
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/panel/panel.js b/chrome/browser/resources/chromeos/accessibility/chromevox/panel/panel.js index 62f6487..ad8a0d72 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/panel/panel.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/panel/panel.js
@@ -5,6 +5,7 @@ /** * @fileoverview The ChromeVox panel and menus. */ +import {GestureCommandData} from '../background/gesture_command_data.js'; import {ISearchUI} from './i_search.js'; import {PanelInterface} from './panel_interface.js';
diff --git a/chrome/browser/resources/chromeos/accessibility/chromevox/panel/panel_loader.js b/chrome/browser/resources/chromeos/accessibility/chromevox/panel/panel_loader.js index 0c71b33b..d31eb853 100644 --- a/chrome/browser/resources/chromeos/accessibility/chromevox/panel/panel_loader.js +++ b/chrome/browser/resources/chromeos/accessibility/chromevox/panel/panel_loader.js
@@ -14,7 +14,6 @@ goog.require('CommandStore'); goog.require('EventGenerator'); goog.require('EventSourceType'); -goog.require('GestureCommandData'); goog.require('KeyCode'); goog.require('KeyMap'); goog.require('KeyUtil');
diff --git a/chrome/browser/resources/chromeos/arc_account_picker/BUILD.gn b/chrome/browser/resources/chromeos/arc_account_picker/BUILD.gn new file mode 100644 index 0000000..064f5740 --- /dev/null +++ b/chrome/browser/resources/chromeos/arc_account_picker/BUILD.gn
@@ -0,0 +1,30 @@ +# Copyright 2020 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//third_party/closure_compiler/compile_js.gni") +import("//tools/polymer/html_to_js.gni") + +js_type_check("closure_compile") { + is_polymer3 = true + deps = [ + ":arc_account_picker_app", + ":arc_account_picker_browser_proxy", + ] +} + +js_library("arc_account_picker_app") { + deps = [ + ":arc_account_picker_browser_proxy", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + ] +} + +js_library("arc_account_picker_browser_proxy") { + deps = [ "//ui/webui/resources/js:cr.m" ] + externs_list = [ "$externs_path/chrome_send.js" ] +} + +html_to_js("web_components") { + js_files = [ "arc_account_picker_app.js" ] +}
diff --git a/chrome/browser/resources/inline_login/arc_account_picker_app.html b/chrome/browser/resources/chromeos/arc_account_picker/arc_account_picker_app.html similarity index 100% rename from chrome/browser/resources/inline_login/arc_account_picker_app.html rename to chrome/browser/resources/chromeos/arc_account_picker/arc_account_picker_app.html
diff --git a/chrome/browser/resources/inline_login/arc_account_picker_app.js b/chrome/browser/resources/chromeos/arc_account_picker/arc_account_picker_app.js similarity index 100% rename from chrome/browser/resources/inline_login/arc_account_picker_app.js rename to chrome/browser/resources/chromeos/arc_account_picker/arc_account_picker_app.js
diff --git a/chrome/browser/resources/inline_login/arc_account_picker_browser_proxy.js b/chrome/browser/resources/chromeos/arc_account_picker/arc_account_picker_browser_proxy.js similarity index 100% rename from chrome/browser/resources/inline_login/arc_account_picker_browser_proxy.js rename to chrome/browser/resources/chromeos/arc_account_picker/arc_account_picker_browser_proxy.js
diff --git a/chrome/browser/resources/chromeos/login/components/web_view_loader.html b/chrome/browser/resources/chromeos/login/components/web_view_loader.html index 987f6d7..7a499156 100644 --- a/chrome/browser/resources/chromeos/login/components/web_view_loader.html +++ b/chrome/browser/resources/chromeos/login/components/web_view_loader.html
@@ -6,4 +6,4 @@ Adding this file as an import will force the Polymer3 version of the file to add the directive: - `import {WebViewLoader} from '.../web_view_loader.m.js';` ---> \ No newline at end of file +-->
diff --git a/chrome/browser/resources/chromeos/login/components/web_view_loader.js b/chrome/browser/resources/chromeos/login/components/web_view_loader.js index 572b7475..860e705 100644 --- a/chrome/browser/resources/chromeos/login/components/web_view_loader.js +++ b/chrome/browser/resources/chromeos/login/components/web_view_loader.js
@@ -8,7 +8,7 @@ * @fileoverview web view loader. */ -const CLEAR_ANCHORS_CONTENT_SCRIPT = { +/* #export */ const CLEAR_ANCHORS_CONTENT_SCRIPT = { code: 'A=Array.from(document.getElementsByTagName("a"));' + 'for(var i = 0; i < A.length; ++i) {' + ' const el = A[i];' +
diff --git a/chrome/browser/resources/chromeos/login/oobe_auto_imports.gni b/chrome/browser/resources/chromeos/login/oobe_auto_imports.gni index 5a07580..423cdc72 100644 --- a/chrome/browser/resources/chromeos/login/oobe_auto_imports.gni +++ b/chrome/browser/resources/chromeos/login/oobe_auto_imports.gni
@@ -46,7 +46,7 @@ "chrome/browser/resources/chromeos/login/components/oobe_types.html|OobeTypes", "chrome/browser/resources/chromeos/login/components/oobe_a11y_option.html|OobeA11yOption", "chrome/browser/resources/chromeos/login/components/web_view_helper.html|WebViewHelper", - "chrome/browser/resources/chromeos/login/components/web_view_loader.html|WebViewLoader", + "chrome/browser/resources/chromeos/login/components/web_view_loader.html|WebViewLoader,CLEAR_ANCHORS_CONTENT_SCRIPT", "chrome/browser/resources/chromeos/login/screens/common/offline_ad_login.html|ActiveDirectoryErrorState,ADLoginStep,JoinConfigType", "chrome/browser/resources/chromeos/login/screens/login/checking_downloading_update.html|CheckingDownloadingUpdate", "chrome/browser/resources/chromeos/login/screens/oobe/welcome_dialog.html|OobeWelcomeDialog",
diff --git a/chrome/browser/resources/chromeos/login/screens/common/BUILD.gn b/chrome/browser/resources/chromeos/login/screens/common/BUILD.gn index 831e4a8..3941174 100644 --- a/chrome/browser/resources/chromeos/login/screens/common/BUILD.gn +++ b/chrome/browser/resources/chromeos/login/screens/common/BUILD.gn
@@ -103,9 +103,7 @@ js_type_check("closure_compile_module_multidevice_setup") { is_polymer3 = true closure_flags = default_closure_args - deps = [ - ":multidevice_setup.m", - ] + deps = [ ":multidevice_setup.m" ] } ############################### @@ -151,6 +149,7 @@ "../../:display_manager.m", "../../components:oobe_select.m", "../../components:web_view_helper.m", + "../../components:web_view_loader.m", "../../components/behaviors:oobe_dialog_host_behavior.m", "../../components/behaviors:oobe_i18n_behavior.m", "../../components/buttons:oobe_back_button.m",
diff --git a/chrome/browser/resources/chromeos/login/screens/common/arc_terms_of_service.html b/chrome/browser/resources/chromeos/login/screens/common/arc_terms_of_service.html index 612600ed8..48b6032 100644 --- a/chrome/browser/resources/chromeos/login/screens/common/arc_terms_of_service.html +++ b/chrome/browser/resources/chromeos/login/screens/common/arc_terms_of_service.html
@@ -17,6 +17,7 @@ <link rel="import" href="../../components/oobe_select.html"> <link rel="import" href="../../components/oobe_types.html"> <link rel="import" href="../../components/web_view_helper.html"> +<link rel="import" href="../../components/web_view_loader.html"> <link rel="import" href="../../components/behaviors/login_screen_behavior.html"> <link rel="import" href="../../components/behaviors/multi_step_behavior.html"> <link rel="import" href="../../components/behaviors/oobe_i18n_behavior.html">
diff --git a/chrome/browser/resources/chromeos/login/screens/common/arc_terms_of_service.js b/chrome/browser/resources/chromeos/login/screens/common/arc_terms_of_service.js index 6ba716b1..8904757 100644 --- a/chrome/browser/resources/chromeos/login/screens/common/arc_terms_of_service.js +++ b/chrome/browser/resources/chromeos/login/screens/common/arc_terms_of_service.js
@@ -370,7 +370,11 @@ this.$.arcTosOverlayWebview, TERMS_URL, WebViewHelper.ContentType.PDF); } else { - this.$.arcTosOverlayWebview.src = targetUrl; + let overlayWebview = this.$.arcTosOverlayWebview; + if (this.isDemoModeSetup_()) { + this.setClearAnchorScriptForWebview_(overlayWebview); + } + overlayWebview.src = targetUrl; } this.lastFocusedElement_ = this.shadowRoot.activeElement; @@ -482,6 +486,9 @@ } }); } else { + if (this.isDemoModeSetup_()) { + this.setClearAnchorScriptForWebview_(termsView); + } this.reloadPlayStoreToS(); } } @@ -816,6 +823,20 @@ return isChild ? this.i18n('arcTermsOfServiceScreenHeadingForChild') : this.i18n('arcTermsOfServiceScreenHeading'); } + + /** + * Set up a script for webview to clear anchor of the page after loading. + */ + setClearAnchorScriptForWebview_(webview) { + webview.addContentScripts([{ + name: 'clearAnchors', + matches: ['<all_urls>'], + js: CLEAR_ANCHORS_CONTENT_SCRIPT, + }]); + webview.addEventListener('contentload', () => { + webview.executeScript(CLEAR_ANCHORS_CONTENT_SCRIPT); + }); + } } customElements.define(ArcTermsOfService.is, ArcTermsOfService);
diff --git a/chrome/browser/resources/chromeos/login/screens/login/lacros_data_migration.html b/chrome/browser/resources/chromeos/login/screens/login/lacros_data_migration.html index e4af7399..abad232e 100644 --- a/chrome/browser/resources/chromeos/login/screens/login/lacros_data_migration.html +++ b/chrome/browser/resources/chromeos/login/screens/login/lacros_data_migration.html
@@ -9,6 +9,7 @@ <link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/color.html"> <link rel="import" href="../../components/behaviors/login_screen_behavior.html"> +<link rel="import" href="../../components/behaviors/multi_step_behavior.html"> <link rel="import" href="../../components/behaviors/oobe_dialog_host_behavior.html"> <link rel="import" href="../../components/behaviors/oobe_i18n_behavior.html"> <link rel="import" href="../../components/common_styles/oobe_dialog_host_styles.html"> @@ -34,7 +35,8 @@ width: 380px; } </style> - <oobe-adaptive-dialog id="dialog" role="dialog"> + <oobe-adaptive-dialog id="progressDialog" for-step="progress" id="dialog" + role="dialog"> <iron-icon slot="icon" icon="oobe-32:googleg"></iron-icon> <h1 slot="title">[[i18nDynamic(locale, 'lacrosDataMigrationTitle')]]</h1> <paper-progress slot="progress" min="0" max="100" @@ -75,6 +77,44 @@ </oobe-text-button> </div> </oobe-adaptive-dialog> + + <oobe-adaptive-dialog id="errorDialog" for-step="error" role="dialog" + footer-shrinkable> + <iron-icon slot="icon" icon="oobe-32:warning"></iron-icon> + <h1 slot="title"> + [[i18nDynamic(locale, 'lacrosDataMigrationErrorTitle')]] + </h1> + <div slot="subtitle" id="lowDiskSpaceError" + hidden="[[!requiredSizeStr_]]"> + <p> + [[i18nDynamic(locale, 'lacrosDataMigrationErrorLowDiskSpace', + requiredSizeStr_)]] + </p> + </div> + <div slot="subtitle" id="genericError" hidden="[[requiredSizeStr_]]"> + <p> + [[i18nDynamic(locale, 'lacrosDataMigrationErrorSubtitle')]] + </p> + </div> + <div slot="content" class="flex layout vertical center center-justified"> + <img src="/images/error.svg" + class="oobe-illustration" aria-hidden="true"> + </div> + + <!-- Cancel button --> + <div slot="bottom-buttons" class="layout horizontal end-justified"> + <oobe-text-button id="cancelButton" + on-click="onCancelButtonClicked_" + text-key="lacrosDataMigrationErrorCancelButton"> + </oobe-text-button> + <oobe-text-button id="gotoFilesButton" + on-click="onGotoFilesButtonClicked_" + text-key="lacrosDataMigrationErrorGotoFilesButton" + hidden="[[!showGotoFiles_]]" + inverse> + </oobe-text-button> + </div> + </oobe-adaptive-dialog> </template> <script src="lacros_data_migration.js"></script> </dom-module>
diff --git a/chrome/browser/resources/chromeos/login/screens/login/lacros_data_migration.js b/chrome/browser/resources/chromeos/login/screens/login/lacros_data_migration.js index 4062469..cb73b2d 100644 --- a/chrome/browser/resources/chromeos/login/screens/login/lacros_data_migration.js +++ b/chrome/browser/resources/chromeos/login/screens/login/lacros_data_migration.js
@@ -12,9 +12,13 @@ * @constructor * @extends {PolymerElement} * @implements {LoginScreenBehaviorInterface} + * @implements {MultiStepBehaviorInterface} */ const LacrosDataMigrationScreenElementBase = Polymer.mixinBehaviors( - [OobeDialogHostBehavior, OobeI18nBehavior, LoginScreenBehavior], + [ + OobeDialogHostBehavior, OobeI18nBehavior, LoginScreenBehavior, + MultiStepBehavior + ], Polymer.Element); class LacrosDataMigrationScreen extends LacrosDataMigrationScreenElementBase { @@ -29,6 +33,8 @@ this.progressValue_ = 0; this.canSkip_ = false; this.lowBatteryStatus_ = false; + this.requiredSizeStr_ = ''; + this.showGotoFiles_ = false; } static get properties() { @@ -36,12 +42,41 @@ progressValue_: {type: Number}, canSkip_: {type: Boolean}, - lowBatteryStatus_: {type: Boolean} + lowBatteryStatus_: {type: Boolean}, + requiredSizeStr_: {type: String}, + showGotoFiles_: {type: Boolean} + }; + } + + defaultUIStep() { + return 'progress'; + } + + get UI_STEPS() { + return { + PROGRESS: 'progress', + ERROR: 'error', }; } get EXTERNAL_API() { - return ['setProgressValue', 'showSkipButton', 'setLowBatteryStatus']; + return [ + 'setProgressValue', 'showSkipButton', 'setLowBatteryStatus', + 'setFailureStatus' + ]; + } + + /** + * Called when the migration failed. + * @param {string} requiredSizeStr The extra space that users need to free up + * to run the migration formatted into a string. Maybe empty, if the + * failure is not caused by low disk space. + * @param {boolean} showGotoFiles If true, displays the "goto files" button. + */ + setFailureStatus(requiredSizeStr, showGotoFiles) { + this.requiredSizeStr_ = requiredSizeStr; + this.showGotoFiles_ = showGotoFiles; + this.setUIStep('error'); } /** @@ -79,6 +114,14 @@ assert(this.canSkip_); this.userActed('skip'); } + + onCancelButtonClicked_() { + this.userActed('cancel'); + } + + onGotoFilesButtonClicked_() { + this.userActed('gotoFiles'); + } } customElements.define(LacrosDataMigrationScreen.is, LacrosDataMigrationScreen);
diff --git a/chrome/browser/resources/history/history_clusters/cluster.html b/chrome/browser/resources/history/history_clusters/cluster.html index e95da9d..da6dca9 100644 --- a/chrome/browser/resources/history/history_clusters/cluster.html +++ b/chrome/browser/resources/history/history_clusters/cluster.html
@@ -11,7 +11,7 @@ box-shadow: inset 0 0 0 2px var(--cr-focus-outline-color); } - :host([has-hidden-related-visits_]) #container { + :host([has-hidden-visits_]) #container { /* For containers with a "Show More" button, add some additional spacing for the pill button by adding a margin on the container. */ margin-bottom: var(--cluster-padding-vertical); @@ -102,7 +102,8 @@ </style> <div id="container" on-visit-clicked="onVisitClicked_" on-open-all-visits="onOpenAllVisits_" - on-remove-visits="onRemoveVisits_"> + on-remove-all-visits="onRemoveAllVisits_" + on-remove-visit="onRemoveVisit_"> <div id="label-row" hidden="[[!cluster.label]]"> <div id="label">[[cluster.label]]</div> <div class="timestamp-and-menu"> @@ -111,16 +112,15 @@ </menu-container> </div> </div> - <url-visit visit="[[cluster.visit]]" is-top-visit$="[[!cluster.label]]"> - </url-visit> - <template is="dom-repeat" items="[[visibleRelatedVisits_]]"> - <url-visit visit="[[item]]" indented$="[[!cluster.label]]"> + <template is="dom-repeat" items="[[visibleVisits_]]"> + <url-visit visit="[[item]]" indented$="[[!cluster.label]]" + is-top-visit$="[[isTopVisit_(index, cluster.label)]]"> </url-visit> </template> <!-- Disable animation on iron-collapse, as the parent iron-list can't easily handle it. --> <iron-collapse opened="[[expanded_]]" no-animation> - <template is="dom-repeat" items="[[hiddenRelatedVisits_]]"> + <template is="dom-repeat" items="[[hiddenVisits_]]"> <url-visit visit="[[item]]" indented$="[[!cluster.label]]"> </url-visit> </template> @@ -136,7 +136,7 @@ </template> </div> </div> - <div id="visibility-toggle" hidden="[[!hasHiddenRelatedVisits_]]"> + <div id="visibility-toggle" hidden="[[!hasHiddenVisits_]]"> <div id="toggle-button" class="pill pill-icon-end" tabindex="0" on-click="onToggleButtonClick_" on-keydown="onToggleButtonKeyDown_"> <span>[[getToggleButtonLabel_(expanded_)]]</span>
diff --git a/chrome/browser/resources/history/history_clusters/cluster.ts b/chrome/browser/resources/history/history_clusters/cluster.ts index 469c3b8c..8354a95d 100644 --- a/chrome/browser/resources/history/history_clusters/cluster.ts +++ b/chrome/browser/resources/history/history_clusters/cluster.ts
@@ -54,7 +54,7 @@ cluster: Object, /** - * Whether the default-hidden related visits are visible. + * Whether the default-hidden visits are visible. */ expanded_: { type: Boolean, @@ -63,28 +63,28 @@ }, /** - * Whether there are default-hidden related visits. + * Whether there are default-hidden visits. */ - hasHiddenRelatedVisits_: { + hasHiddenVisits_: { type: Boolean, - computed: `computeHasHiddenRelatedVisits_(hiddenRelatedVisits_)`, + computed: `computeHasHiddenVisits_(hiddenVisits_)`, reflectToAttribute: true, }, /** - * The default-hidden related visits. + * The default-hidden visits. */ - hiddenRelatedVisits_: { + hiddenVisits_: { type: Object, - computed: `computeHiddenRelatedVisits_(cluster.visit.relatedVisits.*)`, + computed: `computeHiddenVisits_(cluster.visits.*)`, }, /** - * The always-visible related visits. + * The always-visible visits. */ - visibleRelatedVisits_: { + visibleVisits_: { type: Object, - computed: `computeVisibleRelatedVisits_(cluster.visit.relatedVisits.*)`, + computed: `computeVisibleVisits_(cluster.visits.*)`, }, }; } @@ -98,8 +98,8 @@ private callbackRouter_: PageCallbackRouter; private onVisitsRemovedListenerId_: number|null = null; private expanded_: boolean; - private hiddenRelatedVisits_: Array<URLVisit>; - private visibleRelatedVisits_: Array<URLVisit>; + private hiddenVisits_: Array<URLVisit>; + private visibleVisits_: Array<URLVisit>; //============================================================================ // Overridden methods @@ -149,11 +149,11 @@ } private onOpenAllVisits_() { - const visitsToOpen = [this.cluster.visit, ...this.visibleRelatedVisits_]; - // Only try to open the hidden related visits if the user actually has + const visitsToOpen = this.visibleVisits_; + // Only try to open the hidden visits if the user actually has // expanded the cluster by clicking "Show More". if (this.expanded_) { - visitsToOpen.push(...this.hiddenRelatedVisits_); + visitsToOpen.push(...this.hiddenVisits_); } BrowserProxyImpl.getInstance().handler.openVisitUrlsInTabGroup( @@ -163,19 +163,28 @@ ClusterAction.OPENED_IN_TAB_GROUP, this.index); } - private onRemoveVisits_(event: CustomEvent<Array<URLVisit>>) { + private onRemoveAllVisits_() { + // Pass event up with new detail of all this cluster's visits. + this.dispatchEvent(new CustomEvent('remove-visits', { + bubbles: true, + composed: true, + detail: this.cluster.visits, + })); + } + + private onRemoveVisit_(event: CustomEvent<URLVisit>) { // The actual removal is handled at in clusters.ts. This is just a good // place to record the metric. - const visitsToBeRemoved = event.detail; + const visit = event.detail; + MetricsProxyImpl.getInstance().recordVisitAction( + VisitAction.DELETED, this.getVisitIndex_(visit), + MetricsProxyImpl.getVisitType(visit)); - // To match the historic semantics, we only record this metric when a single - // visit is requested to be removed by the user. - if (visitsToBeRemoved.length === 1) { - const visit = visitsToBeRemoved[0]; - MetricsProxyImpl.getInstance().recordVisitAction( - VisitAction.DELETED, this.getVisitIndex_(visit), - MetricsProxyImpl.getVisitType(visit)); - } + this.dispatchEvent(new CustomEvent('remove-visits', { + bubbles: true, + composed: true, + detail: [visit], + })); } private onToggleButtonKeyDown_(e: KeyboardEvent) { @@ -225,9 +234,7 @@ }) !== -1; }; - // Flatten the cluster's constitutent visits and filter out the removed - // ones, if any. - const allVisits = [this.cluster.visit, ...this.cluster.visit.relatedVisits]; + const allVisits = this.cluster.visits; const remainingVisits = allVisits.filter(v => !visitHasBeenRemoved(v)); if (allVisits.length === remainingVisits.length) { return; @@ -245,10 +252,7 @@ MetricsProxyImpl.getInstance().recordClusterAction( ClusterAction.DELETED, this.index); } else { - // Reconstitute the cluster by setting the top visit with the - // `remainingVisits` as its related visits. - this.set('cluster.visit', remainingVisits.shift()!); - this.set('cluster.visit.relatedVisits', remainingVisits); + this.set('cluster.visits', remainingVisits); } this.dispatchEvent(new CustomEvent('iron-resize', { @@ -257,25 +261,32 @@ })); } - private computeHasHiddenRelatedVisits_(): boolean { - return this.hiddenRelatedVisits_.length > 0; + private computeHasHiddenVisits_(): boolean { + return this.hiddenVisits_.length > 0; } - private computeHiddenRelatedVisits_(): Array<URLVisit> { - return this.cluster.visit.relatedVisits.filter((visit: URLVisit) => { - return visit.belowTheFold; + private computeHiddenVisits_(): Array<URLVisit> { + return this.cluster.visits.filter((visit: URLVisit) => { + return visit.hidden; }); } - private computeVisibleRelatedVisits_(): Array<URLVisit> { - return this.cluster.visit.relatedVisits.filter((visit: URLVisit) => { - return !visit.belowTheFold; + private computeVisibleVisits_(): Array<URLVisit> { + return this.cluster.visits.filter((visit: URLVisit) => { + return !visit.hidden; }); } /** + * Returns true if this should be considered a top visit. + */ + private isTopVisit_(index: number, label: string): boolean { + return index === 0 && !label; + } + + /** * Returns the label of the toggle button based on whether the default-hidden - * related visits are visible. + * visits are visible. */ private getToggleButtonLabel_(_expanded: boolean): string { return loadTimeData.getString( @@ -287,16 +298,7 @@ * if the visit is not found in the cluster at all. */ private getVisitIndex_(visit: URLVisit): number { - if (visit === this.cluster.visit) { - return 0; - } - - const relatedVisitIndex = this.cluster.visit.relatedVisits.indexOf(visit); - if (relatedVisitIndex === -1) { - return -1; - } - // Add one, because the "top visit" is the 0th visit. - return relatedVisitIndex + 1; + return this.cluster.visits.indexOf(visit); } }
diff --git a/chrome/browser/resources/history/history_clusters/menu_container.ts b/chrome/browser/resources/history/history_clusters/menu_container.ts index 6b2c2c4..0d0be64 100644 --- a/chrome/browser/resources/history/history_clusters/menu_container.ts +++ b/chrome/browser/resources/history/history_clusters/menu_container.ts
@@ -79,10 +79,9 @@ private onRemoveAllButtonClick_(event: MouseEvent) { event.preventDefault(); // Prevent default browser action (navigation). - this.dispatchEvent(new CustomEvent('remove-visits', { + this.dispatchEvent(new CustomEvent('remove-all-visits', { bubbles: true, composed: true, - detail: [this.visit, ...this.visit.relatedVisits], })); this.$.actionMenu.get().close(); @@ -91,10 +90,10 @@ private onRemoveSelfButtonClick_(event: MouseEvent) { event.preventDefault(); // Prevent default browser action (navigation). - this.dispatchEvent(new CustomEvent('remove-visits', { + this.dispatchEvent(new CustomEvent('remove-visit', { bubbles: true, composed: true, - detail: [this.visit], + detail: this.visit, })); this.$.actionMenu.get().close();
diff --git a/chrome/browser/resources/history/history_clusters/url_visit.html b/chrome/browser/resources/history/history_clusters/url_visit.html index 7ca534f..92d271152 100644 --- a/chrome/browser/resources/history/history_clusters/url_visit.html +++ b/chrome/browser/resources/history/history_clusters/url_visit.html
@@ -20,7 +20,7 @@ user-select: none; } - :host([indented]) #header { + :host([indented]:not([is-top-visit])) #header { padding-inline-start: calc(var(--cluster-padding-horizontal) + var(--top-visit-favicon-size) + var(--favicon-margin));
diff --git a/chrome/browser/resources/inline_login/BUILD.gn b/chrome/browser/resources/inline_login/BUILD.gn index fb16ddda..4d901cda 100644 --- a/chrome/browser/resources/inline_login/BUILD.gn +++ b/chrome/browser/resources/inline_login/BUILD.gn
@@ -2,43 +2,80 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//chrome/browser/buildflags.gni") +import("//chrome/common/features.gni") import("//third_party/closure_compiler/compile_js.gni") +import("//tools/grit/preprocess_if_expr.gni") import("//tools/polymer/html_to_js.gni") -js_type_check("closure_compile") { - is_polymer3 = true - closure_flags = - default_closure_args + [ - "js_module_root=../../chrome/browser/resources/gaia_auth_host/", - "js_module_root=./gen/chrome/browser/resources/gaia_auth_host/", - ] +preprocess_folder = "preprocessed" + +group("components") { deps = [ - ":arc_account_picker_app", - ":arc_account_picker_browser_proxy", - ":inline_login_app", - ":inline_login_browser_proxy", - ":inline_login_util", - ":signin_blocked_by_policy_page", - ":welcome_page_app", + ":preprocess", + ":preprocess_generated", + ":web_components", ] } -js_library("inline_login_app") { +preprocess_if_expr("preprocess") { + in_folder = "./" + out_folder = "$target_gen_dir/$preprocess_folder" + in_files = [ "inline_login_browser_proxy.js" ] +} + +preprocess_if_expr("preprocess_generated") { + deps = [ ":web_components" ] + in_folder = "$target_gen_dir" + out_folder = "$target_gen_dir/$preprocess_folder" + in_files = [ "inline_login_app.js" ] +} + +js_type_check("closure_compile") { + is_polymer3 = true + closure_flags = default_closure_args + [ + "js_module_root=../../chrome/browser/resources/inline_login/", + "js_module_root=./gen/chrome/browser/resources/inline_login/", + "js_module_root=./gen/chrome/browser/resources/inline_login/preprocessed/", + "js_module_root=../../chrome/browser/resources/", + "js_module_root=./gen/chrome/browser/resources/", + ] deps = [ - ":arc_account_picker_app", + ":inline_login_app", ":inline_login_browser_proxy", - ":inline_login_util", - ":signin_blocked_by_policy_page", - ":welcome_page_app", + ] + if (is_chromeos_ash) { + deps += [ + ":inline_login_util", + ":signin_blocked_by_policy_page", + ":welcome_page_app", + ] + } +} + +js_library("inline_login_app") { + sources = [ "$target_gen_dir/$preprocess_folder/inline_login_app.js" ] + deps = [ + ":inline_login_browser_proxy", "//chrome/browser/resources/gaia_auth_host:authenticator.m", "//third_party/polymer/v3_0/components-chromium/paper-spinner:paper-spinner-lite", "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", "//ui/webui/resources/cr_elements/cr_view_manager:cr_view_manager", "//ui/webui/resources/js:assert.m", + "//ui/webui/resources/js:i18n_behavior.m", "//ui/webui/resources/js:load_time_data.m", "//ui/webui/resources/js:web_ui_listener_behavior.m", ] + if (is_chromeos_ash) { + deps += [ + ":inline_login_util", + ":signin_blocked_by_policy_page", + ":welcome_page_app", + "//chrome/browser/resources/chromeos/arc_account_picker:arc_account_picker_app", + ] + } externs_list = [ "$externs_path/webview_tag.js" ] + extra_deps = [ ":preprocess_generated" ] } js_library("welcome_page_app") { @@ -50,13 +87,6 @@ ] } -js_library("arc_account_picker_app") { - deps = [ - ":arc_account_picker_browser_proxy", - "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", - ] -} - js_library("signin_blocked_by_policy_page") { deps = [ "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", @@ -65,16 +95,14 @@ } js_library("inline_login_browser_proxy") { + sources = + [ "$target_gen_dir/$preprocess_folder/inline_login_browser_proxy.js" ] deps = [ "//chrome/browser/resources/gaia_auth_host:authenticator.m", "//ui/webui/resources/js:cr.m", ] externs_list = [ "$externs_path/chrome_send.js" ] -} - -js_library("arc_account_picker_browser_proxy") { - deps = [ "//ui/webui/resources/js:cr.m" ] - externs_list = [ "$externs_path/chrome_send.js" ] + extra_deps = [ ":preprocess" ] } js_library("inline_login_util") { @@ -86,6 +114,5 @@ "inline_login_app.js", "signin_blocked_by_policy_page.js", "welcome_page_app.js", - "arc_account_picker_app.js", ] }
diff --git a/chrome/browser/resources/inline_login/inline_login_app.js b/chrome/browser/resources/inline_login/inline_login_app.js index 13362e8..54fc1c0 100644 --- a/chrome/browser/resources/inline_login/inline_login_app.js +++ b/chrome/browser/resources/inline_login/inline_login_app.js
@@ -25,7 +25,7 @@ import {getAccountAdditionOptionsFromJSON} from './inline_login_util.js'; // </if> -import {AuthCompletedCredentials, Authenticator, AuthParams} from '../gaia_auth_host/authenticator.m.js'; +import {AuthCompletedCredentials, Authenticator, AuthParams} from './gaia_auth_host/authenticator.m.js'; import {InlineLoginBrowserProxy, InlineLoginBrowserProxyImpl} from './inline_login_browser_proxy.js'; /** @@ -174,10 +174,11 @@ this.addWebUIListener( 'send-lst-fetch-results', arg => this.sendLSTFetchResults_(arg)); this.addWebUIListener('close-dialog', () => this.closeDialog_()); - + // <if expr="chromeos_ash"> this.addWebUIListener( 'show-signin-blocked-by-policy-page', data => this.signinBlockedByPolicyShowView_(data)); + // </if> }, /** @private */ @@ -313,6 +314,7 @@ this.browserProxy_.dialogClose(); }, + // <if expr="chromeos_ash"> /** * Navigates to the welcome screen. * @private @@ -381,6 +383,7 @@ return this.enableGaiaActionButtons_ && this.currentView_ === View.addAccount; }, + // </if> /** * Navigates to the default view. @@ -416,10 +419,10 @@ getDefaultView_() { // TODO(https://crbug.com/1155041): simplify this when the file will be // split into CrOS and non-CrOS parts. - if (!isChromeOS) { - // On non-ChromeOS always show 'Add account'. - return View.addAccount; - } + // <if expr="not chromeos_ash"> + // On non-ChromeOS always show 'Add account'. + return View.addAccount; + // </if> // <if expr="chromeos_ash"> if (this.isReauthentication_) { @@ -452,10 +455,12 @@ * @private */ isWelcomePageEnabled_() { - if (!isChromeOS) { - return false; - } + // <if expr="not chromeos_ash"> + return false; + // </if> + // <if expr="chromeos_ash"> return !this.shouldSkipWelcomePage_ && !this.isReauthentication_; + // </if> }, // <if expr="chromeos">
diff --git a/chrome/browser/resources/inline_login/inline_login_browser_proxy.js b/chrome/browser/resources/inline_login/inline_login_browser_proxy.js index 41045f1..5b9cb95b 100644 --- a/chrome/browser/resources/inline_login/inline_login_browser_proxy.js +++ b/chrome/browser/resources/inline_login/inline_login_browser_proxy.js
@@ -5,7 +5,7 @@ import {assert} from 'chrome://resources/js/assert.m.js'; import {addSingletonGetter, sendWithPromise} from 'chrome://resources/js/cr.m.js'; -import {AuthCompletedCredentials} from '../gaia_auth_host/authenticator.m.js'; +import {AuthCompletedCredentials} from './gaia_auth_host/authenticator.m.js'; /** @interface */ export class InlineLoginBrowserProxy {
diff --git a/chrome/browser/resources/new_tab_page/app.html b/chrome/browser/resources/new_tab_page/app.html index 832f7ca..6283a08 100644 --- a/chrome/browser/resources/new_tab_page/app.html +++ b/chrome/browser/resources/new_tab_page/app.html
@@ -289,7 +289,7 @@ hidden="[[!promoAndModulesLoaded_]]"> </ntp-middle-slot-promo> </template> - <template is="dom-if" if="[[modulesEnabled_]]" > + <template is="dom-if" if="[[modulesEnabled_]]"> <ntp-modules id="modules" on-modules-loaded="onModulesLoaded_" on-customize-module="onCustomizeModule_"
diff --git a/chrome/browser/resources/new_tab_page/modules/modules.html b/chrome/browser/resources/new_tab_page/modules/modules.html index b5cd634..cb20987f4 100644 --- a/chrome/browser/resources/new_tab_page/modules/modules.html +++ b/chrome/browser/resources/new_tab_page/modules/modules.html
@@ -6,6 +6,7 @@ } :host([show-modules-fre_]) #freAndModulesContainer { + background-color: var(--ntp-background-override-color); border: 1px solid var(--ntp-border-color); border-radius: 4px; padding: 20px; @@ -38,7 +39,7 @@ font-size: 10px; height: 12px; padding: 2px 6px; - vertical-align: top; + vertical-align: 5px; } .first-run-experience-body { @@ -85,6 +86,10 @@ flex-grow: 1; } + #removeModuleFreToastMessage { + flex-grow: 1; + } + :host([drag-enabled_]) ntp-module-wrapper { cursor: grab; } @@ -109,10 +114,10 @@ $i18nRaw{modulesFirstRunExperienceBodyLine2} </div> <cr-button class="action-button" on-click="onModulesFreOptIn_"> - $i18n{modulesFirstRunOptInButton} + $i18n{modulesFirstRunExperienceOptIn} </cr-button> - <cr-button class="cancel-button"> - $i18n{modulesFirstRunOptOutButton} + <cr-button class="cancel-button" on-click="onModulesFreOptOut_"> + $i18n{modulesFirstRunExperienceOptOut} </cr-button> </div> </template> @@ -126,3 +131,13 @@ $i18n{undo} </cr-button> </cr-toast> +<cr-toast id="removeModuleFreToast" duration="10000"> + <div id="removeModuleFreToastMessage"> + $i18n{modulesFirstRunExperienceOptOutToast} + </div> + <cr-button id="undoRemoveModuleFreButton" + aria-label="$i18n{undoDescription}" + on-click="onUndoRemoveModuleFreButtonClick_"> + $i18n{undo} + </cr-button> +</cr-toast>
diff --git a/chrome/browser/resources/new_tab_page/modules/modules.ts b/chrome/browser/resources/new_tab_page/modules/modules.ts index bf27185..fb1c65a73 100644 --- a/chrome/browser/resources/new_tab_page/modules/modules.ts +++ b/chrome/browser/resources/new_tab_page/modules/modules.ts
@@ -37,6 +37,9 @@ removeModuleToast: CrToastElement, removeModuleToastMessage: HTMLElement, undoRemoveModuleButton: HTMLElement, + removeModuleFreToast: CrToastElement, + removeModuleFreToastMessage: HTMLElement, + undoRemoveModuleFreButton: HTMLElement, }; } @@ -82,6 +85,8 @@ observer: 'onModulesLoadedAndVisibilityDeterminedChange_', }, + modulesShownToUser_: Boolean, + modulesFreVisible_: { type: Boolean, value: false, @@ -94,7 +99,8 @@ showModulesFre_: { reflectToAttribute: true, type: Boolean, - computed: `computeShowModulesFre_(modulesFreVisible_, modulesLoaded_)`, + computed: + `computeShowModulesFre_(modulesLoaded_, modulesFreVisible_, modulesShownToUser_)`, }, /** @private {boolean} */ @@ -123,6 +129,7 @@ private modulesLoaded_: boolean; private modulesVisibilityDetermined_: boolean; private modulesLoadedAndVisibilityDetermined_: boolean; + private modulesShownToUser_: boolean; private modulesFreVisible_: boolean; private showModulesFre_: boolean; private dragEnabled_: boolean; @@ -168,14 +175,19 @@ private computeShowModulesFre_(): boolean { return ( loadTimeData.getBoolean('modulesFirstRunExperienceEnabled') && - this.modulesLoaded_ && this.modulesFreVisible_); + this.modulesLoaded_ && this.modulesFreVisible_ && + this.modulesShownToUser_); } private appendModuleContainers_(moduleContainers: HTMLElement[]) { this.$.modules.innerHTML = ''; let shortModuleSiblingsContainer: HTMLElement|null = null; + this.modulesShownToUser_ = false; moduleContainers.forEach((moduleContainer: HTMLElement, index: number) => { let moduleContainerParent = this.$.modules; + if (!moduleContainer.hidden) { + this.modulesShownToUser_ = !moduleContainer.hidden; + } if (loadTimeData.getBoolean('modulesRedesignedLayoutEnabled')) { // Wrap pairs of sibling short modules in a container. All other // modules will be placed in a container of their own. @@ -264,6 +276,7 @@ // </if> if (ctrlKeyPressed && e.key === 'z') { this.onUndoRemoveModuleButtonClick_(); + this.onUndoRemoveModuleFreButtonClick_(); } } @@ -385,10 +398,36 @@ new Event('customize-module', {bubbles: true, composed: true})); } - private onModulesFreOptIn_() { + private hideFre_() { NewTabPageProxy.getInstance().handler.setModulesFreVisible(false); } + private onModulesFreOptIn_() { + this.hideFre_(); + } + + private onModulesFreOptOut_() { + this.hideFre_(); + NewTabPageProxy.getInstance().handler.setModulesVisible(false); + + // Hide remove module toast in case user removed a module before opting out + // of fre. + this.$.removeModuleToast.hide(); + + // Any module the user removed before opting out of the FRE should not be + // restored if FRE opt out is undone. + this.removedModuleData_ = null; + + // Notify the user + this.$.removeModuleFreToast.show(); + } + + private onUndoRemoveModuleFreButtonClick_() { + NewTabPageProxy.getInstance().handler.setModulesFreVisible(true); + NewTabPageProxy.getInstance().handler.setModulesVisible(true); + this.$.removeModuleFreToast.hide(); + } + /** * Module is dragged by updating the module position based on the * position of the pointer.
diff --git a/chrome/browser/safe_browsing/threat_details_unittest.cc b/chrome/browser/safe_browsing/threat_details_unittest.cc index ac6295e..dd1a997 100644 --- a/chrome/browser/safe_browsing/threat_details_unittest.cc +++ b/chrome/browser/safe_browsing/threat_details_unittest.cc
@@ -695,7 +695,7 @@ parent_node->children.push_back(GURL(kDOMChildURL)); params.push_back(std::move(parent_node)); report->OnReceivedThreatDOMDetails(mojo::Remote<mojom::ThreatReporter>(), - main_rfh()->GetGlobalId(), + main_rfh()->GetWeakDocumentPtr(), std::move(params)); std::string serialized = WaitForThreatDetailsDone( @@ -919,10 +919,10 @@ // Send both sets of nodes from different render frames. report->OnReceivedThreatDOMDetails(mojo::Remote<mojom::ThreatReporter>(), - main_rfh()->GetGlobalId(), + main_rfh()->GetWeakDocumentPtr(), std::move(outer_params_copy)); report->OnReceivedThreatDOMDetails(mojo::Remote<mojom::ThreatReporter>(), - child_rfh->GetGlobalId(), + child_rfh->GetWeakDocumentPtr(), std::move(inner_params_copy)); std::string serialized = WaitForThreatDetailsDone( @@ -969,10 +969,10 @@ // Send both sets of nodes from different render frames. report->OnReceivedThreatDOMDetails(mojo::Remote<mojom::ThreatReporter>(), - child_rfh->GetGlobalId(), + child_rfh->GetWeakDocumentPtr(), std::move(inner_params)); report->OnReceivedThreatDOMDetails(mojo::Remote<mojom::ThreatReporter>(), - main_rfh()->GetGlobalId(), + main_rfh()->GetWeakDocumentPtr(), std::move(outer_params)); std::string serialized = WaitForThreatDetailsDone( @@ -1099,10 +1099,10 @@ // Send both sets of nodes from different render frames. report->OnReceivedThreatDOMDetails(mojo::Remote<mojom::ThreatReporter>(), - main_rfh()->GetGlobalId(), + main_rfh()->GetWeakDocumentPtr(), std::move(outer_params)); report->OnReceivedThreatDOMDetails(mojo::Remote<mojom::ThreatReporter>(), - child_rfh->GetGlobalId(), + child_rfh->GetWeakDocumentPtr(), std::move(inner_params)); std::string serialized = WaitForThreatDetailsDone( report.get(), false /* did_proceed*/, 0 /* num_visit */); @@ -1370,10 +1370,10 @@ // Send both sets of nodes from different render frames. trimmed_report->OnReceivedThreatDOMDetails( - mojo::Remote<mojom::ThreatReporter>(), child_rfh->GetGlobalId(), + mojo::Remote<mojom::ThreatReporter>(), child_rfh->GetWeakDocumentPtr(), std::move(inner_params)); trimmed_report->OnReceivedThreatDOMDetails( - mojo::Remote<mojom::ThreatReporter>(), main_rfh()->GetGlobalId(), + mojo::Remote<mojom::ThreatReporter>(), main_rfh()->GetWeakDocumentPtr(), std::move(outer_params)); std::string serialized = WaitForThreatDetailsDone( @@ -1446,10 +1446,10 @@ // Send both sets of nodes from different render frames. trimmed_report->OnReceivedThreatDOMDetails( - mojo::Remote<mojom::ThreatReporter>(), child_rfh->GetGlobalId(), + mojo::Remote<mojom::ThreatReporter>(), child_rfh->GetWeakDocumentPtr(), std::move(inner_params)); trimmed_report->OnReceivedThreatDOMDetails( - mojo::Remote<mojom::ThreatReporter>(), main_rfh()->GetGlobalId(), + mojo::Remote<mojom::ThreatReporter>(), main_rfh()->GetWeakDocumentPtr(), std::move(outer_params)); std::string serialized = WaitForThreatDetailsDone( @@ -1717,7 +1717,7 @@ // The cache collection starts after the IPC from the DOM is fired. std::vector<mojom::ThreatDOMDetailsNodePtr> params; report->OnReceivedThreatDOMDetails(mojo::Remote<mojom::ThreatReporter>(), - main_rfh()->GetGlobalId(), + main_rfh()->GetWeakDocumentPtr(), std::move(params)); // Let the cache callbacks complete. @@ -1801,7 +1801,7 @@ // The cache collection starts after the IPC from the DOM is fired. std::vector<mojom::ThreatDOMDetailsNodePtr> params; report->OnReceivedThreatDOMDetails(mojo::Remote<mojom::ThreatReporter>(), - main_rfh()->GetGlobalId(), + main_rfh()->GetWeakDocumentPtr(), std::move(params)); // Let the cache callbacks complete. @@ -1888,7 +1888,7 @@ // The cache collection starts after the IPC from the DOM is fired. std::vector<mojom::ThreatDOMDetailsNodePtr> params; report->OnReceivedThreatDOMDetails(mojo::Remote<mojom::ThreatReporter>(), - main_rfh()->GetGlobalId(), + main_rfh()->GetWeakDocumentPtr(), std::move(params)); // Let the cache callbacks complete. @@ -1950,7 +1950,7 @@ // The redirects collection starts after the IPC from the DOM is fired. std::vector<mojom::ThreatDOMDetailsNodePtr> params; report->OnReceivedThreatDOMDetails(mojo::Remote<mojom::ThreatReporter>(), - main_rfh()->GetGlobalId(), + main_rfh()->GetWeakDocumentPtr(), std::move(params)); // Let the redirects callbacks complete. @@ -2012,7 +2012,7 @@ // The cache collection starts after the IPC from the DOM is fired. std::vector<mojom::ThreatDOMDetailsNodePtr> params; report->OnReceivedThreatDOMDetails(mojo::Remote<mojom::ThreatReporter>(), - main_rfh()->GetGlobalId(), + main_rfh()->GetWeakDocumentPtr(), std::move(params)); // Let the cache callbacks complete.
diff --git a/chrome/browser/share/core/resources/PRESUBMIT.py b/chrome/browser/share/core/resources/PRESUBMIT.py index 47646c6..2f45ae2 100644 --- a/chrome/browser/share/core/resources/PRESUBMIT.py +++ b/chrome/browser/share/core/resources/PRESUBMIT.py
@@ -3,6 +3,8 @@ # found in the LICENSE file. """Presubmit checks for Share share_targets.""" +USE_PYTHON3 = True + def CheckVersionUpdatedInShareTargetList(input_api, output_api): def IsShareTargetList(x):
diff --git a/chrome/browser/sync/test/integration/two_client_web_apps_integration_test_mac_win_linux.cc b/chrome/browser/sync/test/integration/two_client_web_apps_integration_test_mac_win_linux.cc index 5887d9203..c2b9672 100644 --- a/chrome/browser/sync/test/integration/two_client_web_apps_integration_test_mac_win_linux.cc +++ b/chrome/browser/sync/test/integration/two_client_web_apps_integration_test_mac_win_linux.cc
@@ -915,7 +915,9 @@ } // TODO(crbug.com/1301414): Mac shims failing to launch on Mac debug and ASAN. -#if BUILDFLAG(IS_MAC) && (!defined(NDEBUG) || defined(ADDRESS_SANITIZER)) +// #if BUILDFLAG(IS_MAC) && (!defined(NDEBUG) || defined(ADDRESS_SANITIZER)) +// TODO(https://crbug.com/1309739): Failing on regular Mac now too. +#if BUILDFLAG(IS_MAC) #define MAYBE_WebAppIntegration_47SiteA_24_12SiteA_40Client2_45SiteA_46SiteA_12SiteA_69SiteA_24 \ DISABLED_WebAppIntegration_47SiteA_24_12SiteA_40Client2_45SiteA_46SiteA_12SiteA_69SiteA_24 #else @@ -965,7 +967,9 @@ } // TODO(crbug.com/1301414): Mac shims failing to launch on Mac debug and ASAN. -#if BUILDFLAG(IS_MAC) && (!defined(NDEBUG) || defined(ADDRESS_SANITIZER)) +// #if BUILDFLAG(IS_MAC) && (!defined(NDEBUG) || defined(ADDRESS_SANITIZER)) +// TODO(https://crbug.com/1309739): Failing on regular Mac now too. +#if BUILDFLAG(IS_MAC) #define MAYBE_WebAppIntegration_30SiteA_24_12SiteA_40Client2_45SiteA_1SiteA_22 \ DISABLED_WebAppIntegration_30SiteA_24_12SiteA_40Client2_45SiteA_1SiteA_22 #else @@ -988,7 +992,9 @@ } // TODO(crbug.com/1301414): Mac shims failing to launch on Mac debug and ASAN. -#if BUILDFLAG(IS_MAC) && (!defined(NDEBUG) || defined(ADDRESS_SANITIZER)) +// #if BUILDFLAG(IS_MAC) && (!defined(NDEBUG) || defined(ADDRESS_SANITIZER)) +// TODO(https://crbug.com/1309739): Failing on regular Mac now too. +#if BUILDFLAG(IS_MAC) #define MAYBE_WebAppIntegration_31SiteA_24_12SiteA_40Client2_45SiteA_46SiteA_12SiteA_1SiteA_24 \ DISABLED_WebAppIntegration_31SiteA_24_12SiteA_40Client2_45SiteA_46SiteA_12SiteA_1SiteA_24 #else @@ -1013,7 +1019,9 @@ } // TODO(crbug.com/1301414): Mac shims failing to launch on Mac debug and ASAN. -#if BUILDFLAG(IS_MAC) && (!defined(NDEBUG) || defined(ADDRESS_SANITIZER)) +// #if BUILDFLAG(IS_MAC) && (!defined(NDEBUG) || defined(ADDRESS_SANITIZER)) +// TODO(https://crbug.com/1309739): Failing on regular Mac now too. +#if BUILDFLAG(IS_MAC) #define MAYBE_WebAppIntegration_31SiteA_24_12SiteA_40Client2_45SiteA_1SiteA_22 \ DISABLED_WebAppIntegration_31SiteA_24_12SiteA_40Client2_45SiteA_1SiteA_22 #else @@ -1036,7 +1044,9 @@ } // TODO(crbug.com/1301414): Mac shims failing to launch on Mac debug and ASAN. -#if BUILDFLAG(IS_MAC) && (!defined(NDEBUG) || defined(ADDRESS_SANITIZER)) +// #if BUILDFLAG(IS_MAC) && (!defined(NDEBUG) || defined(ADDRESS_SANITIZER)) +// TODO(https://crbug.com/1309739): Failing on regular Mac now too. +#if BUILDFLAG(IS_MAC) #define MAYBE_WebAppIntegration_47SiteA_24_12SiteA_40Client2_45SiteA_46SiteA_12SiteA_1SiteA_24 \ DISABLED_WebAppIntegration_47SiteA_24_12SiteA_40Client2_45SiteA_46SiteA_12SiteA_1SiteA_24 #else @@ -1061,7 +1071,9 @@ } // TODO(crbug.com/1301414): Mac shims failing to launch on Mac debug and ASAN. -#if BUILDFLAG(IS_MAC) && (!defined(NDEBUG) || defined(ADDRESS_SANITIZER)) +// #if BUILDFLAG(IS_MAC) && (!defined(NDEBUG) || defined(ADDRESS_SANITIZER)) +// TODO(https://crbug.com/1309739): Failing on regular Mac now too. +#if BUILDFLAG(IS_MAC) #define MAYBE_WebAppIntegration_47SiteA_24_12SiteA_40Client2_45SiteA_1SiteA_22 \ DISABLED_WebAppIntegration_47SiteA_24_12SiteA_40Client2_45SiteA_1SiteA_22 #else @@ -1084,7 +1096,9 @@ } // TODO(crbug.com/1301414): Mac shims failing to launch on Mac debug and ASAN. -#if BUILDFLAG(IS_MAC) && (!defined(NDEBUG) || defined(ADDRESS_SANITIZER)) +// #if BUILDFLAG(IS_MAC) && (!defined(NDEBUG) || defined(ADDRESS_SANITIZER)) +// TODO(https://crbug.com/1309739): Failing on regular Mac now too. +#if BUILDFLAG(IS_MAC) #define MAYBE_WebAppIntegration_29SiteA_11SiteA_40Client2_45SiteA_46SiteA_11SiteA_1SiteA_22 \ DISABLED_WebAppIntegration_29SiteA_11SiteA_40Client2_45SiteA_46SiteA_11SiteA_1SiteA_22 #else @@ -1108,7 +1122,9 @@ } // TODO(crbug.com/1301414): Mac shims failing to launch on Mac debug and ASAN. -#if BUILDFLAG(IS_MAC) && (!defined(NDEBUG) || defined(ADDRESS_SANITIZER)) +// #if BUILDFLAG(IS_MAC) && (!defined(NDEBUG) || defined(ADDRESS_SANITIZER)) +// TODO(https://crbug.com/1309739): Failing on regular Mac now too. +#if BUILDFLAG(IS_MAC) #define MAYBE_WebAppIntegration_29SiteA_11SiteA_40Client2_45SiteA_1SiteA_22 \ DISABLED_WebAppIntegration_29SiteA_11SiteA_40Client2_45SiteA_1SiteA_22 #else
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index 951421b..85a8ad3d55 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn
@@ -2024,6 +2024,12 @@ "app_list/search/files/zero_state_drive_provider.h", "app_list/search/files/zero_state_file_provider.cc", "app_list/search/files/zero_state_file_provider.h", + "app_list/search/games/game_provider.cc", + "app_list/search/games/game_provider.h", + "app_list/search/games/game_result.cc", + "app_list/search/games/game_result.h", + "app_list/search/games/stub_api.cc", + "app_list/search/games/stub_api.h", "app_list/search/help_app_provider.cc", "app_list/search/help_app_provider.h", "app_list/search/keyboard_shortcut_data.cc",
diff --git a/chrome/browser/ui/app_list/search/app_search_provider_unittest.cc b/chrome/browser/ui/app_list/search/app_search_provider_unittest.cc index 7174745..cf88a17 100644 --- a/chrome/browser/ui/app_list/search/app_search_provider_unittest.cc +++ b/chrome/browser/ui/app_list/search/app_search_provider_unittest.cc
@@ -663,11 +663,13 @@ // UI (i.e. calling ViewClosing). CallViewClosing(); - // Verify the search results are cleared async. EXPECT_FALSE(results().empty()); // Allow async callbacks to run. base::RunLoop().RunUntilIdle(); - EXPECT_TRUE(results().empty()); + if (!app_list_features::IsCategoricalSearchEnabled()) { + // Verify the search results are cleared async. + EXPECT_TRUE(results().empty()); + } EXPECT_EQ(2, stub_icon_loader.NumLoadIconFromIconKeyCalls());
diff --git a/chrome/browser/ui/app_list/search/files/file_result.h b/chrome/browser/ui/app_list/search/files/file_result.h index 456aa79d..31bf77f 100644 --- a/chrome/browser/ui/app_list/search/files/file_result.h +++ b/chrome/browser/ui/app_list/search/files/file_result.h
@@ -70,8 +70,7 @@ } private: - // Callback for the result of MaybeRequestThumbnail's call to the - // ThumbnailLoader. + // Callback for the result of RequestThumbnail's call to the ThumbnailLoader. void OnThumbnailLoaded(const SkBitmap* bitmap, base::File::Error error); // Callback for the result of SetDetailsToJustificationString to
diff --git a/chrome/browser/ui/app_list/search/files/zero_state_drive_provider.cc b/chrome/browser/ui/app_list/search/files/zero_state_drive_provider.cc index 43a030e..2ac1163 100644 --- a/chrome/browser/ui/app_list/search/files/zero_state_drive_provider.cc +++ b/chrome/browser/ui/app_list/search/files/zero_state_drive_provider.cc
@@ -251,12 +251,7 @@ } void ZeroStateDriveProvider::Start(const std::u16string& query) { - // Results should be cleared on search only in the classic launcher. In the - // productivity launcher, this is handled automatically by the search - // controller. - if (!ash::features::IsProductivityLauncherEnabled()) { - ClearResultsSilently(); - } + ClearResultsSilently(); } void ZeroStateDriveProvider::StartZeroState() {
diff --git a/chrome/browser/ui/app_list/search/files/zero_state_file_provider.cc b/chrome/browser/ui/app_list/search/files/zero_state_file_provider.cc index 01fd00a4..904e7e8 100644 --- a/chrome/browser/ui/app_list/search/files/zero_state_file_provider.cc +++ b/chrome/browser/ui/app_list/search/files/zero_state_file_provider.cc
@@ -141,12 +141,7 @@ } void ZeroStateFileProvider::Start(const std::u16string& query) { - // Results should be cleared on search only in the classic launcher. In the - // productivity launcher, this is handled automatically by the search - // controller. - if (!ash::features::IsProductivityLauncherEnabled()) { - ClearResultsSilently(); - } + ClearResultsSilently(); } void ZeroStateFileProvider::StartZeroState() {
diff --git a/chrome/browser/ui/app_list/search/games/game_provider.cc b/chrome/browser/ui/app_list/search/games/game_provider.cc new file mode 100644 index 0000000..c0999500 --- /dev/null +++ b/chrome/browser/ui/app_list/search/games/game_provider.cc
@@ -0,0 +1,124 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/app_list/search/games/game_provider.h" + +#include <utility> + +#include "base/strings/strcat.h" +#include "base/task/task_traits.h" +#include "base/task/thread_pool.h" +#include "base/time/time.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/app_list/app_list_controller_delegate.h" +#include "chrome/browser/ui/app_list/search/games/game_result.h" +#include "chrome/grit/generated_resources.h" +#include "chromeos/components/string_matching/tokenized_string.h" +#include "chromeos/components/string_matching/tokenized_string_match.h" +#include "ui/base/l10n/l10n_util.h" + +namespace app_list { +namespace { + +using chromeos::string_matching::TokenizedString; +using chromeos::string_matching::TokenizedStringMatch; + +constexpr double kRelevanceThreshold = 0.7; +constexpr size_t kMaxResults = 3u; + +double CalculateTitleRelevance(const TokenizedString& tokenized_query, + const std::u16string& game_title) { + const TokenizedString tokenized_title(game_title, + TokenizedString::Mode::kCamelCase); + + if (tokenized_query.text().empty() || tokenized_title.text().empty()) { + static constexpr double kDefaultRelevance = 0.0; + return kDefaultRelevance; + } + + TokenizedStringMatch match; + match.Calculate(tokenized_query, tokenized_title); + return match.relevance(); +} + +std::vector<std::pair<GameData, double>> SearchGames(std::u16string query, + GameIndex* index) { + TokenizedString tokenized_query(query, TokenizedString::Mode::kCamelCase); + + std::vector<std::pair<GameData, double>> matches; + for (const auto& game_data : *index) { + double relevance = + CalculateTitleRelevance(tokenized_query, game_data.title); + if (relevance > kRelevanceThreshold) { + matches.push_back(std::make_pair(game_data, relevance)); + } + } + return matches; +} + +} // namespace + +GameProvider::GameProvider(Profile* profile, + AppListControllerDelegate* list_controller) + : profile_(profile), list_controller_(list_controller) { + DCHECK(profile_); + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + + game_index_manager_ = std::make_unique<GameIndexManager>(); + game_index_ = game_index_manager_->GetIndex(); + + index_observer_.Observe(game_index_manager_.get()); +} + +GameProvider::~GameProvider() = default; + +ash::AppListSearchResultType GameProvider::ResultType() const { + return ash::AppListSearchResultType::kGames; +} + +void GameProvider::OnIndexUpdated(const absl::optional<GameIndex>& index) { + if (index) + game_index_ = index; +} + +void GameProvider::Start(const std::u16string& query) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + + if (!game_index_) + return; + + // Clear results and discard any existing searches. + ClearResultsSilently(); + weak_factory_.InvalidateWeakPtrs(); + + base::ThreadPool::PostTaskAndReplyWithResult( + FROM_HERE, {base::TaskPriority::USER_BLOCKING}, + base::BindOnce(&SearchGames, query, &game_index_.value()), + base::BindOnce(&GameProvider::OnSearchComplete, + weak_factory_.GetWeakPtr(), query)); +} + +void GameProvider::SetGameIndexForTest(const GameIndex& game_index) { + game_index_ = game_index; +} + +void GameProvider::OnSearchComplete( + std::u16string query, + std::vector<std::pair<GameData, double>> matches) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + + // Sort matches by descending relevance score. + std::sort(matches.begin(), matches.end(), + [](const auto& a, const auto& b) { return a.second > b.second; }); + + SearchProvider::Results results; + for (size_t i = 0; i < std::min(matches.size(), kMaxResults); ++i) { + results.emplace_back(std::make_unique<GameResult>( + profile_, list_controller_, game_index_manager_.get(), matches[i].first, + matches[i].second, query)); + } + SwapResults(&results); +} + +} // namespace app_list
diff --git a/chrome/browser/ui/app_list/search/games/game_provider.h b/chrome/browser/ui/app_list/search/games/game_provider.h new file mode 100644 index 0000000..d31120a --- /dev/null +++ b/chrome/browser/ui/app_list/search/games/game_provider.h
@@ -0,0 +1,63 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_GAMES_GAME_PROVIDER_H_ +#define CHROME_BROWSER_UI_APP_LIST_SEARCH_GAMES_GAME_PROVIDER_H_ + +#include <utility> +#include <vector> + +#include "base/files/file_path.h" +#include "base/memory/weak_ptr.h" +#include "base/scoped_observation.h" +#include "base/sequence_checker.h" +#include "base/time/time.h" +#include "chrome/browser/ui/app_list/search/games/stub_api.h" +#include "chrome/browser/ui/app_list/search/search_provider.h" +#include "chrome/browser/ui/ash/thumbnail_loader.h" +#include "third_party/abseil-cpp/absl/types/optional.h" + +class AppListControllerDelegate; +class Profile; + +namespace app_list { + +// Provider for cloud gaming search. +class GameProvider : public SearchProvider, public GameIndexManager::Observer { + public: + GameProvider(Profile* profile, AppListControllerDelegate* list_controller); + ~GameProvider() override; + + GameProvider(const GameProvider&) = delete; + GameProvider& operator=(const GameProvider&) = delete; + + // GameIndexManager::Observer: + void OnIndexUpdated(const absl::optional<GameIndex>& index) override; + + // SearchProvider: + ash::AppListSearchResultType ResultType() const override; + void Start(const std::u16string& query) override; + + void SetGameIndexForTest(const GameIndex& game_index); + + private: + void OnSearchComplete(std::u16string query, + std::vector<std::pair<GameData, double>> matches); + + Profile* const profile_; + AppListControllerDelegate* list_controller_; + + std::unique_ptr<GameIndexManager> game_index_manager_; + absl::optional<GameIndex> game_index_; + + base::ScopedObservation<GameIndexManager, GameIndexManager::Observer> + index_observer_{this}; + + SEQUENCE_CHECKER(sequence_checker_); + base::WeakPtrFactory<GameProvider> weak_factory_{this}; +}; + +} // namespace app_list + +#endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_GAMES_GAME_PROVIDER_H_
diff --git a/chrome/browser/ui/app_list/search/games/game_provider_unittest.cc b/chrome/browser/ui/app_list/search/games/game_provider_unittest.cc new file mode 100644 index 0000000..7ad50cb --- /dev/null +++ b/chrome/browser/ui/app_list/search/games/game_provider_unittest.cc
@@ -0,0 +1,90 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/app_list/search/games/game_provider.h" + +#include "ash/public/cpp/app_list/app_list_features.h" +#include "base/strings/utf_string_conversions.h" +#include "base/test/task_environment.h" +#include "chrome/browser/ui/app_list/search/games/stub_api.h" +#include "chrome/browser/ui/app_list/search/test/test_search_controller.h" +#include "chrome/browser/ui/app_list/test/test_app_list_controller_delegate.h" +#include "chrome/test/base/testing_profile.h" +#include "content/public/test/browser_task_environment.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "url/gurl.h" + +namespace app_list { +namespace { + +using ::testing::ElementsAre; +using ::testing::UnorderedElementsAre; + +MATCHER_P(Title, title, "") { + return base::UTF16ToUTF8(arg->title()) == title; +} + +GameData MakeGameData(const std::u16string& title) { + GameData data; + data.title = title; + data.source = GameSource::kExampleSource; + data.launch_url = GURL("https://example.com"); + return data; +} + +} // namespace + +class GameProviderTest : public testing::Test { + protected: + void SetUp() override { + profile_ = std::make_unique<TestingProfile>(); + provider_ = + std::make_unique<GameProvider>(profile_.get(), &list_controller_); + + search_controller_ = std::make_unique<TestSearchController>(); + provider_->set_controller(search_controller_.get()); + } + + const SearchProvider::Results& LastResults() { + if (app_list_features::IsCategoricalSearchEnabled()) { + return search_controller_->last_results(); + } else { + return provider_->results(); + } + } + + void SetUpTestingIndex() { + GameIndex index; + index.push_back(MakeGameData(u"First Title")); + index.push_back(MakeGameData(u"Second Title")); + index.push_back(MakeGameData(u"Third Title")); + provider_->SetGameIndexForTest(std::move(index)); + } + + void Wait() { task_environment_.RunUntilIdle(); } + + content::BrowserTaskEnvironment task_environment_; + ::test::TestAppListControllerDelegate list_controller_; + std::unique_ptr<TestSearchController> search_controller_; + std::unique_ptr<Profile> profile_; + + std::unique_ptr<GameProvider> provider_; +}; + +TEST_F(GameProviderTest, SearchResultsMatchQuery) { + SetUpTestingIndex(); + + provider_->Start(u"first"); + Wait(); + EXPECT_THAT(LastResults(), ElementsAre(Title("First Title"))); + + provider_->Start(u"title"); + Wait(); + EXPECT_THAT(LastResults(), + UnorderedElementsAre(Title("First Title"), Title("Second Title"), + Title("Third Title"))); +} + +} // namespace app_list
diff --git a/chrome/browser/ui/app_list/search/games/game_result.cc b/chrome/browser/ui/app_list/search/games/game_result.cc new file mode 100644 index 0000000..9f2a254 --- /dev/null +++ b/chrome/browser/ui/app_list/search/games/game_result.cc
@@ -0,0 +1,121 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/app_list/search/games/game_result.h" + +#include <string> + +#include "ash/public/cpp/app_list/app_list_config.h" +#include "ash/public/cpp/app_list/app_list_types.h" +#include "ash/strings/grit/ash_strings.h" +#include "base/bind.h" +#include "base/metrics/histogram_functions.h" +#include "base/strings/strcat.h" +#include "base/strings/string_util.h" +#include "base/strings/utf_string_conversions.h" +#include "chrome/browser/ui/app_list/app_list_controller_delegate.h" +#include "chrome/browser/ui/app_list/search/common/icon_constants.h" +#include "chrome/browser/ui/app_list/search/common/search_result_util.h" +#include "chrome/browser/ui/app_list/search/search_tags_util.h" +#include "chrome/browser/ui/ash/thumbnail_loader.h" +#include "chromeos/components/string_matching/tokenized_string.h" +#include "third_party/skia/include/core/SkBitmap.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/base/page_transition_types.h" +#include "ui/gfx/geometry/size.h" +#include "ui/gfx/image/image_skia.h" + +namespace app_list { +namespace { + +constexpr char16_t kPlatformDelimiter[] = u", "; +constexpr char16_t kDetailsDelimiter[] = u" - "; +constexpr char16_t kA11yDelimiter[] = u", "; + +} // namespace + +GameResult::GameResult(Profile* profile, + AppListControllerDelegate* list_controller, + GameIndexManager* index_manager, + const GameData& game_data, + double relevance, + const std::u16string& query) + : profile_(profile), + list_controller_(list_controller), + launch_url_(game_data.launch_url) { + DCHECK(profile); + DCHECK(list_controller); + DCHECK(index_manager); + DCHECK(launch_url_.is_valid()); + + set_id(launch_url_.spec()); + set_relevance(relevance); + + SetMetricsType(ash::GAME_SEARCH); + SetResultType(ResultType::kGames); + SetDisplayType(DisplayType::kList); + SetCategory(Category::kGames); + + UpdateText(game_data, query); + + // TODO(crbug.com/1305880): Set a default icon. + + index_manager->GetIcon(game_data.icon_url, + base::BindOnce(&GameResult::OnIconLoaded, + weak_ptr_factory_.GetWeakPtr())); +} + +GameResult::~GameResult() = default; + +void GameResult::Open(int event_flags) { + list_controller_->OpenURL(profile_, launch_url_, ui::PAGE_TRANSITION_TYPED, + ui::DispositionFromEventFlags(event_flags)); +} + +void GameResult::UpdateText(const GameData& game_data, + const std::u16string& query) { + SetTitle(game_data.title); + SetTitleTags(CalculateTags(query, title())); + + std::vector<ash::SearchResultTextItem> details; + std::vector<std::u16string> accessible_name; + + accessible_name.push_back(title()); + accessible_name.push_back(kA11yDelimiter); + + std::u16string source = GameSourceDisplayString(game_data.source); + details.push_back(CreateStringTextItem(source).SetElidable(false)); + accessible_name.push_back(source); + + if (game_data.platforms) { + std::u16string platforms = + base::JoinString(game_data.platforms.value(), kPlatformDelimiter); + + details.push_back(CreateStringTextItem(kDetailsDelimiter)); + details.push_back( + CreateStringTextItem(IDS_APP_LIST_SEARCH_GAME_PLATFORMS_PREFIX)); + details.push_back(CreateStringTextItem(u" ")); + details.push_back(CreateStringTextItem(platforms)); + + accessible_name.push_back(kA11yDelimiter); + accessible_name.push_back( + l10n_util::GetStringUTF16(IDS_APP_LIST_SEARCH_GAME_PLATFORMS_PREFIX)); + accessible_name.push_back(u" "); + accessible_name.push_back(platforms); + } + + SetDetailsTextVector(details); + SetAccessibleName(base::StrCat(accessible_name)); +} + +void GameResult::OnIconLoaded(const SkBitmap* bitmap) { + if (!bitmap || bitmap->isNull()) + return; + + IconInfo icon_info(gfx::ImageSkia::CreateFrom1xBitmap(*bitmap), + GetAppIconDimension(), IconShape::kRoundedRectangle); + SetIcon(icon_info); +} + +} // namespace app_list
diff --git a/chrome/browser/ui/app_list/search/games/game_result.h b/chrome/browser/ui/app_list/search/games/game_result.h new file mode 100644 index 0000000..122be5bf --- /dev/null +++ b/chrome/browser/ui/app_list/search/games/game_result.h
@@ -0,0 +1,51 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_GAMES_GAME_RESULT_H_ +#define CHROME_BROWSER_UI_APP_LIST_SEARCH_GAMES_GAME_RESULT_H_ + +#include "base/memory/weak_ptr.h" +#include "chrome/browser/ui/app_list/search/chrome_search_result.h" +#include "chrome/browser/ui/app_list/search/games/stub_api.h" +#include "url/gurl.h" + +class AppListControllerDelegate; +class Profile; +class SkBitmap; + +namespace app_list { + +// Search result for cloud gaming search. +class GameResult : public ChromeSearchResult { + public: + GameResult(Profile* profile, + AppListControllerDelegate* list_controller, + GameIndexManager* index_manager, + const GameData& game_data, + double relevance, + const std::u16string& query); + ~GameResult() override; + + GameResult(const GameResult&) = delete; + GameResult& operator=(const GameResult&) = delete; + + // ChromeSearchResult overrides: + void Open(int event_flags) override; + + private: + void OnIconLoaded(const SkBitmap* bitmap); + + void UpdateText(const GameData& game_data, const std::u16string& query); + + Profile* profile_; + AppListControllerDelegate* list_controller_; + + const GURL launch_url_; + + base::WeakPtrFactory<GameResult> weak_ptr_factory_{this}; +}; + +} // namespace app_list + +#endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_GAMES_GAME_RESULT_H_
diff --git a/chrome/browser/ui/app_list/search/games/game_result_unittest.cc b/chrome/browser/ui/app_list/search/games/game_result_unittest.cc new file mode 100644 index 0000000..8f41ad6 --- /dev/null +++ b/chrome/browser/ui/app_list/search/games/game_result_unittest.cc
@@ -0,0 +1,60 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/app_list/search/games/game_result.h" + +#include "ash/strings/grit/ash_strings.h" +#include "base/strings/strcat.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/app_list/search/common/search_result_util.h" +#include "chrome/browser/ui/app_list/search/games/stub_api.h" +#include "chrome/browser/ui/app_list/test/test_app_list_controller_delegate.h" +#include "chrome/test/base/testing_profile.h" +#include "content/public/test/browser_task_environment.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "ui/base/l10n/l10n_util.h" +#include "url/gurl.h" + +namespace app_list { + +class GameResultTest : public testing::Test { + public: + GameResultTest() { profile_ = std::make_unique<TestingProfile>(); } + + ~GameResultTest() override = default; + + content::BrowserTaskEnvironment task_environment_; + test::TestAppListControllerDelegate list_controller_; + std::unique_ptr<Profile> profile_; +}; + +TEST_F(GameResultTest, Basic) { + GameIndexManager index_manager; + + GameData game_data; + game_data.title = u"Title"; + game_data.source = GameSource::kExampleSource; + game_data.launch_url = GURL("https://test-url.com/"); + game_data.platforms = {u"A", u"B", u"C"}; + + GameResult result(profile_.get(), &list_controller_, &index_manager, + game_data, 0.6, u"SomeGame"); + + EXPECT_EQ(result.title(), u"Title"); + + EXPECT_EQ(StringFromTextVector(result.details_text_vector()), + base::StrCat({u"Example source - ", + l10n_util::GetStringUTF16( + IDS_APP_LIST_SEARCH_GAME_PLATFORMS_PREFIX), + u" A, B, C"})); + + EXPECT_EQ(result.accessible_name(), + base::StrCat({u"Title, Example source, ", + l10n_util::GetStringUTF16( + IDS_APP_LIST_SEARCH_GAME_PLATFORMS_PREFIX), + u" A, B, C"})); +} + +} // namespace app_list
diff --git a/chrome/browser/ui/app_list/search/games/stub_api.cc b/chrome/browser/ui/app_list/search/games/stub_api.cc new file mode 100644 index 0000000..1b0a9c6 --- /dev/null +++ b/chrome/browser/ui/app_list/search/games/stub_api.cc
@@ -0,0 +1,40 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/app_list/search/games/stub_api.h" + +// TODO(crbug.com/1305880) +// This whole file is a temporary fake API for the game index manager, that can +// be deleted and replaced once the real API is implemented. + +namespace app_list { + +GameData::GameData() = default; + +GameData::~GameData() = default; + +GameData::GameData(const GameData&) = default; + +GameData& GameData::operator=(const GameData&) = default; + +absl::optional<GameIndex> GameIndexManager::GetIndex() { + return absl::nullopt; +} + +void GameIndexManager::AddObserver(GameIndexManager::Observer* observer) {} + +void GameIndexManager::RemoveObserver(GameIndexManager::Observer* observer) {} + +void GameIndexManager::GetIcon( + const GURL& icon_url, + base::OnceCallback<void(const SkBitmap*)> callback) {} + +std::u16string GameSourceDisplayString(GameSource source) { + switch (source) { + case GameSource::kExampleSource: + return u"Example source"; + } +} + +} // namespace app_list
diff --git a/chrome/browser/ui/app_list/search/games/stub_api.h b/chrome/browser/ui/app_list/search/games/stub_api.h new file mode 100644 index 0000000..9e28307 --- /dev/null +++ b/chrome/browser/ui/app_list/search/games/stub_api.h
@@ -0,0 +1,72 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_GAMES_STUB_API_H_ +#define CHROME_BROWSER_UI_APP_LIST_SEARCH_GAMES_STUB_API_H_ + +#include <string> + +#include "base/callback.h" +#include "base/observer_list_types.h" +#include "third_party/abseil-cpp/absl/types/optional.h" +#include "third_party/skia/include/core/SkBitmap.h" +#include "url/gurl.h" + +// TODO(crbug.com/1305880) +// This whole file is a temporary fake API for the game index manager, that can +// be deleted and replaced once the real API is implemented. + +namespace app_list { + +// Each possible source a game can be provided by. +enum class GameSource { + kExampleSource, +}; + +// Metadata for a single game in the index of games. +struct GameData { + // Game title + std::u16string title; + + GameSource source = GameSource::kExampleSource; + + // What platforms the game is available on. + absl::optional<std::vector<std::u16string>> platforms; + + // The URL that should be opened when the search result is clicked. + GURL launch_url; + + // A token uniquely identifying an icon. + GURL icon_url; + + GameData(); + ~GameData(); + + GameData(const GameData&); + GameData& operator=(const GameData&); +}; + +// A collection of game data, forming an index. +using GameIndex = std::vector<GameData>; + +class GameIndexManager { + public: + class Observer : public base::CheckedObserver { + public: + virtual void OnIndexUpdated(const absl::optional<GameIndex>& index) = 0; + }; + + absl::optional<GameIndex> GetIndex(); + void GetIcon(const GURL& icon_url, + base::OnceCallback<void(const SkBitmap*)> callback); + + void AddObserver(Observer* observer); + void RemoveObserver(Observer* observer); +}; + +std::u16string GameSourceDisplayString(GameSource source); + +} // namespace app_list + +#endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_GAMES_STUB_API_H_
diff --git a/chrome/browser/ui/app_list/search/ranking/filtering_ranker.cc b/chrome/browser/ui/app_list/search/ranking/filtering_ranker.cc index b7b36e4..d0f0763 100644 --- a/chrome/browser/ui/app_list/search/ranking/filtering_ranker.cc +++ b/chrome/browser/ui/app_list/search/ranking/filtering_ranker.cc
@@ -18,6 +18,35 @@ namespace app_list { namespace { +// Given `higher_priority` and `lower_priority` result types, deduplicate +// results between the two result types in `results` based on their id, +// preserving the ones in `higher_priority`. +// +// Note this only deduplicates results whose ids are present in both result +// types; if two results of one result type have the same id, they will not be +// deduplicated. +void DeduplicateResults(ResultsMap& results, + ResultType higher_priority, + ResultType lower_priority) { + const auto first_it = results.find(higher_priority); + const auto second_it = results.find(lower_priority); + if (first_it == results.end() || second_it == results.end()) + return; + const auto& first_results = first_it->second; + const auto& second_results = second_it->second; + + base::flat_set<std::string> first_ids; + for (const auto& result : first_results) { + if (result->result_type() == higher_priority) + first_ids.insert(result->id()); + } + + for (auto& result : second_results) { + if (first_ids.contains(result->id())) + result->scoring().filter = true; + } +} + void DeduplicateDriveFilesAndTabs(ResultsMap& results) { const auto omnibox_it = results.find(ProviderType::kOmnibox); const auto drive_it = results.find(ProviderType::kDriveSearch); @@ -91,6 +120,9 @@ return; FilterOmniboxResults(results); DeduplicateDriveFilesAndTabs(results); + // TODO(crbug.com/1305880): Verify that game URLs match the omnibox stripped + // URL once game URLs are finalized. + DeduplicateResults(results, ResultType::kGames, ResultType::kOmnibox); } } // namespace app_list
diff --git a/chrome/browser/ui/app_list/search/search_controller_factory.cc b/chrome/browser/ui/app_list/search/search_controller_factory.cc index 794c104b..16d87ff 100644 --- a/chrome/browser/ui/app_list/search/search_controller_factory.cc +++ b/chrome/browser/ui/app_list/search/search_controller_factory.cc
@@ -25,6 +25,7 @@ #include "chrome/browser/ui/app_list/search/files/file_search_provider.h" #include "chrome/browser/ui/app_list/search/files/zero_state_drive_provider.h" #include "chrome/browser/ui/app_list/search/files/zero_state_file_provider.h" +#include "chrome/browser/ui/app_list/search/games/game_provider.h" #include "chrome/browser/ui/app_list/search/help_app_provider.h" #include "chrome/browser/ui/app_list/search/keyboard_shortcut_provider.h" #include "chrome/browser/ui/app_list/search/mixer.h" @@ -171,6 +172,15 @@ controller->AddProvider(help_app_group_id, std::make_unique<HelpAppProvider>(profile)); + // TODO(crbug.com/1305880): Move this to its own flag. + if (ash::features::IsProductivityLauncherEnabled() && + base::GetFieldTrialParamByFeatureAsBool( + ash::features::kProductivityLauncher, "enable_games", false)) { + size_t games_group_id = controller->AddGroup(kGenericMaxResults); + controller->AddProvider(games_group_id, std::make_unique<GameProvider>( + profile, list_controller)); + } + return controller; }
diff --git a/chrome/browser/ui/app_list/search/search_provider.cc b/chrome/browser/ui/app_list/search/search_provider.cc index 87689af1..7a681a31 100644 --- a/chrome/browser/ui/app_list/search/search_provider.cc +++ b/chrome/browser/ui/app_list/search/search_provider.cc
@@ -39,23 +39,14 @@ } void SearchProvider::ClearResults() { - if (app_list_features::IsCategoricalSearchEnabled()) { - Results results; - SwapResults(&results); - FireResultChanged(); - } else { + if (!app_list_features::IsCategoricalSearchEnabled()) { results_.clear(); FireResultChanged(); } } void SearchProvider::ClearResultsSilently() { - if (app_list_features::IsCategoricalSearchEnabled()) { - // Don't call `SwapResults()` to avoid calling `FireResultsChanged()`. - Results results; - if (search_controller_) - search_controller_->SetResults(this, std::move(results)); - } else { + if (!app_list_features::IsCategoricalSearchEnabled()) { results_.clear(); } }
diff --git a/chrome/browser/ui/app_list/search/search_provider.h b/chrome/browser/ui/app_list/search/search_provider.h index 65ccdaca..052c5ef 100644 --- a/chrome/browser/ui/app_list/search/search_provider.h +++ b/chrome/browser/ui/app_list/search/search_provider.h
@@ -72,10 +72,14 @@ // desired to be done only once when all results are added. void SwapResults(Results* new_results); - // Clear results and call the |result_changed_callback_|. + // Clear results and call the |result_changed_callback_|. This is a no-op if + // categorical search is enabled, since clearing results is handled by the + // search controller. void ClearResults(); - // Clear the results without calling the |result_changed_callback_|. + // Clear the results without calling the |result_changed_callback_|. this is a + // no-op if categorical search is enabled, since clearing results is handled + // by the search controller. void ClearResultsSilently(); private:
diff --git a/chrome/browser/ui/ash/holding_space/BUILD.gn b/chrome/browser/ui/ash/holding_space/BUILD.gn index 54cc20b..3f9f8fe 100644 --- a/chrome/browser/ui/ash/holding_space/BUILD.gn +++ b/chrome/browser/ui/ash/holding_space/BUILD.gn
@@ -62,7 +62,7 @@ "//chrome/browser/chromeos", "//chrome/browser/extensions", "//chrome/browser/ui", - "//chrome/browser/web_applications:web_applications_test_support", + "//chrome/browser/web_applications:browser_tests_base", "//chrome/test:test_support_ui", "//chromeos/dbus/session_manager", "//components/session_manager/core",
diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc index 761a679..9d74e7c7 100644 --- a/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc
@@ -1045,7 +1045,7 @@ TEST_F(ContentSettingBubbleModelTest, RPHAllow) { custom_handlers::ProtocolHandlerRegistry registry( - profile(), + profile()->GetPrefs(), std::make_unique<custom_handlers::TestProtocolHandlerRegistryDelegate>()); registry.InitProtocolSettings(); @@ -1113,7 +1113,7 @@ TEST_F(ContentSettingBubbleModelTest, RPHDefaultDone) { custom_handlers::ProtocolHandlerRegistry registry( - profile(), + profile()->GetPrefs(), std::make_unique<custom_handlers::TestProtocolHandlerRegistryDelegate>()); registry.InitProtocolSettings();
diff --git a/chrome/browser/ui/startup/startup_browser_creator.cc b/chrome/browser/ui/startup/startup_browser_creator.cc index bfe5a55..431e25c97 100644 --- a/chrome/browser/ui/startup/startup_browser_creator.cc +++ b/chrome/browser/ui/startup/startup_browser_creator.cc
@@ -60,7 +60,6 @@ #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list_observer.h" #include "chrome/browser/ui/browser_window.h" -#include "chrome/browser/ui/extensions/application_launch.h" #include "chrome/browser/ui/startup/launch_mode_recorder.h" #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" #include "chrome/browser/ui/startup/startup_tab_provider.h" @@ -86,7 +85,6 @@ #include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/navigation_controller.h" #include "content/public/common/content_switches.h" -#include "extensions/browser/extension_registry.h" #include "extensions/common/switches.h" #include "printing/buildflags/buildflags.h" #include "third_party/abseil-cpp/absl/types/optional.h" @@ -423,7 +421,7 @@ } #endif // !BUILDFLAG(IS_CHROMEOS_ASH) -#if !BUILDFLAG(IS_CHROMEOS_ASH) +#if !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_ANDROID) StartupProfileInfo GetProfilePickerStartupProfileInfo() { auto path_info = GetProfilePickerStartupProfilePathInfo(); DCHECK_EQ(path_info.mode, StartupProfileMode::kProfilePicker); @@ -444,7 +442,7 @@ return {nullptr, StartupProfileMode::kError}; } -#endif // !BUILDFLAG(IS_CHROMEOS_ASH) +#endif // !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_ANDROID) void ShowProfilePicker(chrome::startup::IsProcessStartup process_startup) { #if !BUILDFLAG(IS_CHROMEOS_ASH) @@ -516,27 +514,6 @@ return false; } -bool MaybeLaunchExtensionApp(const base::CommandLine& command_line, - const base::FilePath& cur_dir, - chrome::startup::IsFirstRun is_first_run, - Profile* profile) { - if (!command_line.HasSwitch(switches::kAppId)) - return false; - - std::string app_id = command_line.GetSwitchValueASCII(switches::kAppId); - const extensions::Extension* extension = - extensions::ExtensionRegistry::Get(profile)->GetInstalledExtension( - app_id); - if (!extension) - return false; - - LaunchAppWithCallback(profile, app_id, command_line, cur_dir, - base::BindOnce(&web_app::startup::FinalizeWebAppLaunch, - LaunchMode::kAsWebAppInWindowByAppId, - command_line, is_first_run)); - return true; -} - // These values are persisted to logs. Entries should not be renumbered and // numeric values should never be reused. Updates need to be reflected in // enum IncognitoForcedStart in tools/metrics/histograms/enums.xml. @@ -1188,22 +1165,10 @@ return true; } - // Try a platform app launch. - if (MaybeLaunchExtensionApp(command_line, cur_dir, is_first_run, - privacy_safe_profile)) { - return true; - } - - // On Mac, PWA launch is handled in web_app_shim_manager_delegate_mac.cc. - // On Chrome OS, app launches are routed through the AppService and - // WebAppPublisherHelper. This path is mostly used for Window and Linux, - // but also session restore for Lacros. -#if !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_CHROMEOS_ASH) - // Try a web app launch. + // Try a web app launch (--app-id is present). if (web_app::startup::MaybeHandleWebAppLaunch( command_line, cur_dir, privacy_safe_profile, is_first_run)) return true; -#endif LaunchBrowserForLastProfiles(command_line, cur_dir, process_startup, is_first_run, profile_info, @@ -1446,7 +1411,7 @@ StartupProfileMode::kBrowserWindow}; } -#if !BUILDFLAG(IS_CHROMEOS_ASH) +#if !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_ANDROID) StartupProfileInfo GetStartupProfile(const base::FilePath& cur_dir, const base::CommandLine& command_line) { ProfileManager* profile_manager = g_browser_process->profile_manager(); @@ -1520,4 +1485,4 @@ return {nullptr, StartupProfileMode::kError}; } -#endif // !BUILDFLAG(IS_CHROMEOS_ASH) +#endif // !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_ANDROID)
diff --git a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc index 3c9d017..8680150 100644 --- a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc +++ b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
@@ -820,9 +820,6 @@ base::CommandLine command_line(base::CommandLine::NO_PROGRAM); command_line.AppendSwitchASCII(switches::kAppId, extension_app->id()); - - ui_test_utils::BrowserChangeObserver browser_waiter( - nullptr, ui_test_utils::BrowserChangeObserver::ChangeType::kAdded); ASSERT_TRUE(StartupBrowserCreator().ProcessCmdLineImpl( command_line, base::FilePath(), chrome::startup::IsProcessStartup::kNo, {browser()->profile(), StartupProfileMode::kBrowserWindow}, {})); @@ -831,7 +828,7 @@ // Pref was set to open in a window, so the app should have opened in a // window. The launch should have created a new browser. Find the new // browser. - Browser* new_browser = browser_waiter.Wait(); + Browser* new_browser = ui_test_utils::WaitForBrowserToOpen(); ASSERT_TRUE(new_browser); // Expect an app window.
diff --git a/chrome/browser/ui/startup/web_app_startup_utils.cc b/chrome/browser/ui/startup/web_app_startup_utils.cc index d1b5275..56be9f61 100644 --- a/chrome/browser/ui/startup/web_app_startup_utils.cc +++ b/chrome/browser/ui/startup/web_app_startup_utils.cc
@@ -106,7 +106,6 @@ profile_(profile), is_first_run_(is_first_run), app_id_(app_id), - web_app_launch_manager_(profile), profile_keep_alive_( profile, ProfileKeepAliveOrigin::kWebAppPermissionDialogWindow), @@ -149,12 +148,13 @@ absl::optional<GURL> protocol; if (!protocol_url_.is_empty()) protocol = protocol_url_; - - web_app_launch_manager_.LaunchApplication( - app_id_, command_line_, cur_dir_, - /*url_handler_launch_url=*/absl::nullopt, protocol, launch_files_, - base::BindOnce(&StartupWebAppCreator::OnAppLaunched, - base::WrapRefCounted(this))); + apps::AppServiceProxyFactory::GetForProfile(profile_) + ->BrowserAppLauncher() + ->LaunchAppWithCallback( + app_id_, command_line_, cur_dir_, + /*url_handler_launch_url=*/absl::nullopt, protocol, launch_files_, + base::BindOnce(&StartupWebAppCreator::OnAppLaunched, + base::WrapRefCounted(this))); } // Determines if the launch is a protocol handler launch. If so, takes @@ -312,8 +312,6 @@ // The app id for this launch, corresponding to --app-id on the command line. const AppId app_id_; - WebAppLaunchManager web_app_launch_manager_; - // This object keeps the profile and browser process alive while determining // whether to launch a window. ScopedProfileKeepAlive profile_keep_alive_;
diff --git a/chrome/browser/ui/tabs/tab_renderer_data.cc b/chrome/browser/ui/tabs/tab_renderer_data.cc index eba9135..76393a3 100644 --- a/chrome/browser/ui/tabs/tab_renderer_data.cc +++ b/chrome/browser/ui/tabs/tab_renderer_data.cc
@@ -22,9 +22,19 @@ bool ShouldThemifyFaviconForEntryUrl(const GURL& url) { // Themify favicon for the default NTP and incognito NTP. - return url.SchemeIs(content::kChromeUIScheme) && - (url.host_piece() == chrome::kChromeUINewTabPageHost || - url.host_piece() == chrome::kChromeUINewTabHost); + if (url.SchemeIs(content::kChromeUIScheme)) { + return url.host_piece() == chrome::kChromeUINewTabPageHost || + url.host_piece() == chrome::kChromeUINewTabHost; + } + +#if BUILDFLAG(IS_CHROMEOS_ASH) + // Themify menu favicon for CrOS Terminal home page. + if (url.SchemeIs(content::kChromeUIUntrustedScheme)) { + return url.host_piece() == chrome::kChromeUIUntrustedTerminalHost; + } +#endif // BUILDFLAG(IS_CHROMEOS_ASH) + + return false; } bool ShouldThemifyFaviconForVisibleUrl(const GURL& visible_url) {
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc index 6accef8..499bf96 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc
@@ -335,16 +335,6 @@ profile_, event, drop_data_, drop_parent, index_to_drop_at); } -ui::mojom::DragOperation BookmarkMenuDelegate::OnPerformDrop( - MenuItemView* menu, - views::MenuDelegate::DropPosition position, - const ui::DropTargetEvent& event) { - auto drop_cb = GetDropCallback(menu, position, event); - ui::mojom::DragOperation output_drag_op = ui::mojom::DragOperation::kNone; - std::move(drop_cb).Run(event, output_drag_op); - return output_drag_op; -} - views::View::DropCallback BookmarkMenuDelegate::GetDropCallback( views::MenuItemView* menu, views::MenuDelegate::DropPosition position,
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h index 0dbe0c4e..12badfc 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h +++ b/chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h
@@ -119,10 +119,6 @@ views::MenuItemView* item, const ui::DropTargetEvent& event, views::MenuDelegate::DropPosition* position); - ui::mojom::DragOperation OnPerformDrop( - views::MenuItemView* menu, - views::MenuDelegate::DropPosition position, - const ui::DropTargetEvent& event); views::View::DropCallback GetDropCallback( views::MenuItemView* menu, views::MenuDelegate::DropPosition position,
diff --git a/chrome/browser/ui/views/bubble/webui_bubble_dialog_view.cc b/chrome/browser/ui/views/bubble/webui_bubble_dialog_view.cc index cc40d68..15813c1 100644 --- a/chrome/browser/ui/views/bubble/webui_bubble_dialog_view.cc +++ b/chrome/browser/ui/views/bubble/webui_bubble_dialog_view.cc
@@ -8,7 +8,6 @@ #include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/visibility.h" #include "ui/base/metadata/metadata_impl_macros.h" -#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rounded_corners_f.h" #include "ui/views/bubble/bubble_border.h" #include "ui/views/controls/webview/webview.h" @@ -126,11 +125,5 @@ event, GetFocusManager()); } -gfx::Rect WebUIBubbleDialogView::GetAnchorRect() const { - if (anchor_rect()) - return anchor_rect().value(); - return BubbleDialogDelegateView::GetAnchorRect(); -} - BEGIN_METADATA(WebUIBubbleDialogView, views::BubbleDialogDelegateView) END_METADATA
diff --git a/chrome/browser/ui/views/bubble/webui_bubble_dialog_view.h b/chrome/browser/ui/views/bubble/webui_bubble_dialog_view.h index 5148fc7..fa9b557 100644 --- a/chrome/browser/ui/views/bubble/webui_bubble_dialog_view.h +++ b/chrome/browser/ui/views/bubble/webui_bubble_dialog_view.h
@@ -19,9 +19,6 @@ } // namespace views // A Views bubble host for a BubbleContentsWrapper. -// NOTE: The anchor rect takes precedence over the anchor view in this class. -// This is the opposite of the behaviour specified in the -// BubbleDialogDelegateView base class. class WebUIBubbleDialogView : public views::WidgetObserver, public views::BubbleDialogDelegateView, public BubbleContentsWrapper::Host { @@ -59,15 +56,6 @@ } void ResetWebUIContentsForTesting(); - // TODO(ffred): This is necessary because the default behaviour of the bubble - // dialog is that anchor view positioning takes precedent over anchor rect. - // This will not work because the anchor rect is used to explicitly specify - // the positioning of the bubble and the anchor view cannot be null. - // - // That being said, the base class should reconsider its behaviour so that - // this type of override is not necessary. - gfx::Rect GetAnchorRect() const override; - virtual void Redraw() {} private:
diff --git a/chrome/browser/ui/views/bubble/webui_bubble_dialog_view_unittest.cc b/chrome/browser/ui/views/bubble/webui_bubble_dialog_view_unittest.cc index 112dcfc..6ad14bdb 100644 --- a/chrome/browser/ui/views/bubble/webui_bubble_dialog_view_unittest.cc +++ b/chrome/browser/ui/views/bubble/webui_bubble_dialog_view_unittest.cc
@@ -12,7 +12,6 @@ #include "chrome/test/base/testing_profile.h" #include "chrome/test/views/chrome_views_test_base.h" #include "testing/gtest/include/gtest/gtest.h" -#include "ui/gfx/geometry/rect.h" #include "ui/views/controls/webview/webview.h" #include "ui/views/widget/unique_widget_ptr.h" @@ -122,13 +121,5 @@ EXPECT_EQ(nullptr, web_view()->web_contents()); } -TEST_F(WebUIBubbleDialogViewTest, GetAnchorRect) { - gfx::Rect anchor(666, 666, 0, 0); - - EXPECT_NE(bubble_dialog_view()->GetAnchorRect(), anchor); - bubble_dialog_view()->SetAnchorRect(anchor); - EXPECT_EQ(bubble_dialog_view()->GetAnchorRect(), anchor); -} - } // namespace test } // namespace views
diff --git a/chrome/browser/ui/views/bubble/webui_bubble_manager.cc b/chrome/browser/ui/views/bubble/webui_bubble_manager.cc index 494165b5..4dfb6da 100644 --- a/chrome/browser/ui/views/bubble/webui_bubble_manager.cc +++ b/chrome/browser/ui/views/bubble/webui_bubble_manager.cc
@@ -6,7 +6,6 @@ #include "base/timer/timer.h" #include "chrome/browser/ui/browser_list.h" -#include "ui/gfx/geometry/rect.h" #include "ui/views/widget/widget.h" namespace { @@ -24,13 +23,13 @@ WebUIBubbleManager::~WebUIBubbleManager() = default; -bool WebUIBubbleManager::ShowBubble(const absl::optional<gfx::Rect>& anchor) { +bool WebUIBubbleManager::ShowBubble() { if (bubble_view_) return false; cache_timer_->Stop(); - bubble_view_ = CreateWebUIBubbleDialog(anchor); + bubble_view_ = CreateWebUIBubbleDialog(); bubble_widget_observation_.Observe(bubble_view_->GetWidget()); // Some bubbles can be triggered when there is no active browser (e.g. emoji
diff --git a/chrome/browser/ui/views/bubble/webui_bubble_manager.h b/chrome/browser/ui/views/bubble/webui_bubble_manager.h index 552ee7e..9651502 100644 --- a/chrome/browser/ui/views/bubble/webui_bubble_manager.h +++ b/chrome/browser/ui/views/bubble/webui_bubble_manager.h
@@ -32,14 +32,13 @@ const WebUIBubbleManager& operator=(const WebUIBubbleManager&) = delete; ~WebUIBubbleManager() override; - bool ShowBubble(const absl::optional<gfx::Rect>& anchor = absl::nullopt); + bool ShowBubble(); void CloseBubble(); views::Widget* GetBubbleWidget() const; bool bubble_using_cached_web_contents() const { return bubble_using_cached_web_contents_; } - virtual base::WeakPtr<WebUIBubbleDialogView> CreateWebUIBubbleDialog( - const absl::optional<gfx::Rect>& anchor) = 0; + virtual base::WeakPtr<WebUIBubbleDialogView> CreateWebUIBubbleDialog() = 0; // views::WidgetObserver: void OnWidgetDestroying(views::Widget* widget) override; @@ -111,8 +110,7 @@ } ~WebUIBubbleManagerT() override = default; - base::WeakPtr<WebUIBubbleDialogView> CreateWebUIBubbleDialog( - const absl::optional<gfx::Rect>& anchor) override { + base::WeakPtr<WebUIBubbleDialogView> CreateWebUIBubbleDialog() override { BubbleContentsWrapper* contents_wrapper = nullptr; // Only use per profile peristence if the flag is set and if a @@ -153,8 +151,6 @@ auto bubble_view = std::make_unique<WebUIBubbleDialogView>(anchor_view_, contents_wrapper); - if (anchor) - bubble_view->SetAnchorRect(anchor.value()); auto weak_ptr = bubble_view->GetWeakPtr(); views::BubbleDialogDelegateView::CreateBubble(std::move(bubble_view)); return weak_ptr;
diff --git a/chrome/browser/ui/views/bubble/webui_bubble_manager_unittest.cc b/chrome/browser/ui/views/bubble/webui_bubble_manager_unittest.cc index 4668e9c..f16df73 100644 --- a/chrome/browser/ui/views/bubble/webui_bubble_manager_unittest.cc +++ b/chrome/browser/ui/views/bubble/webui_bubble_manager_unittest.cc
@@ -142,24 +142,6 @@ profile_manager()->DeleteTestingProfile(kProfileName); } -TEST_F(WebUIBubbleManagerTest, CreateWebUIBubbleDialogWithAnchorProvided) { - const char* kProfileName = "Person 1"; - auto* test_profile = profile_manager()->CreateTestingProfile(kProfileName); - - std::unique_ptr<views::Widget> anchor_widget = - CreateTestWidget(views::Widget::InitParams::TYPE_WINDOW); - auto bubble_manager = - std::make_unique<WebUIBubbleManagerT<TestWebUIController>>( - anchor_widget->GetContentsView(), test_profile, GURL(kTestURL), 1); - bubble_manager->DisableCloseBubbleHelperForTesting(); - - gfx::Rect anchor(666, 666, 0, 0); - bubble_manager->ShowBubble(anchor); - auto bubble_view = bubble_manager->bubble_view_for_testing(); - - EXPECT_EQ(bubble_view->GetAnchorRect(), anchor); -} - #if !BUILDFLAG(IS_CHROMEOS_ASH) // No multi-profile on ChromeOS. TEST_F(WebUIBubbleManagerTest,
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 0c95f72..e19f59b9 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -216,7 +216,6 @@ #include "ui/gfx/canvas.h" #include "ui/gfx/color_utils.h" #include "ui/gfx/geometry/rect_conversions.h" -#include "ui/gfx/geometry/size.h" #include "ui/gfx/scoped_canvas.h" #include "ui/gfx/scrollbar_size.h" #include "ui/views/accessibility/view_accessibility.h"
diff --git a/chrome/browser/ui/views/location_bar/cookie_controls_bubble_view_browsertest.cc b/chrome/browser/ui/views/location_bar/cookie_controls_bubble_view_browsertest.cc index 8b3e506..d8a7215 100644 --- a/chrome/browser/ui/views/location_bar/cookie_controls_bubble_view_browsertest.cc +++ b/chrome/browser/ui/views/location_bar/cookie_controls_bubble_view_browsertest.cc
@@ -4,6 +4,7 @@ #include "base/memory/raw_ptr.h" #include "base/memory/scoped_refptr.h" +#include "build/build_config.h" #include "chrome/browser/content_settings/cookie_settings_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" @@ -105,7 +106,13 @@ // Test opening cookie controls bubble and clicking on "not working" link. // Check that accepting the bubble unblocks 3p cookies for this origin. -IN_PROC_BROWSER_TEST_F(CookieControlsBubbleViewTest, NotWorkingClicked) { +// TODO(https://crbug.com/1309497): Flaky on win and mac. +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) +#define MAYBE_NotWorkingClicked DISABLED_NotWorkingClicked +#else +#define MAYBE_NotWorkingClicked NotWorkingClicked +#endif +IN_PROC_BROWSER_TEST_F(CookieControlsBubbleViewTest, MAYBE_NotWorkingClicked) { // Block 3p cookies. SetThirdPartyCookieBlocking(true); GURL origin = embedded_test_server()->GetURL("a.com", "/");
diff --git a/chrome/browser/ui/views/passwords/password_save_update_view.cc b/chrome/browser/ui/views/passwords/password_save_update_view.cc index 8ee76e4a..3c11fbe 100644 --- a/chrome/browser/ui/views/passwords/password_save_update_view.cc +++ b/chrome/browser/ui/views/passwords/password_save_update_view.cc
@@ -69,6 +69,8 @@ namespace { +constexpr int kIconHeight = 20; + int ComboboxIconSize() { // Use the line height of the body small text. This allows the icons to adapt // if the user changes the font size. @@ -441,7 +443,9 @@ is_update_bubble_ ? &Controller::OnNopeUpdateClicked : &Controller::OnNeverForThisSiteClicked)); } - SetShowIcon(false); + + SetShowIcon(base::FeatureList::IsEnabled( + password_manager::features::kUnifiedPasswordManagerDesktop)); SetFootnoteView(CreateFooterView()); UpdateBubbleUIElements(); @@ -515,7 +519,16 @@ } ui::ImageModel PasswordSaveUpdateView::GetWindowIcon() { - return ui::ImageModel(); + if (!base::FeatureList::IsEnabled( + password_manager::features::kUnifiedPasswordManagerDesktop)) { + return ui::ImageModel(); + } +#if BUILDFLAG(GOOGLE_CHROME_BRANDING) + return ui::ImageModel::FromVectorIcon(kGooglePasswordManagerIcon, + ui::kColorIcon, kIconHeight); +#else + return ui::ImageModel::FromVectorIcon(kKeyIcon, ui::kColorIcon, kIconHeight); +#endif } void PasswordSaveUpdateView::AddedToWidget() {
diff --git a/chrome/browser/ui/views/status_icons/status_icon_linux_dbus.cc b/chrome/browser/ui/views/status_icons/status_icon_linux_dbus.cc index 912f84ae4..f35b8cd 100644 --- a/chrome/browser/ui/views/status_icons/status_icon_linux_dbus.cc +++ b/chrome/browser/ui/views/status_icons/status_icon_linux_dbus.cc
@@ -155,6 +155,7 @@ case base::nix::DESKTOP_ENVIRONMENT_KDE3: case base::nix::DESKTOP_ENVIRONMENT_KDE4: case base::nix::DESKTOP_ENVIRONMENT_KDE5: + case base::nix::DESKTOP_ENVIRONMENT_UKUI: case base::nix::DESKTOP_ENVIRONMENT_UNITY: case base::nix::DESKTOP_ENVIRONMENT_XFCE: return false;
diff --git a/chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views_unittest.cc b/chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views_unittest.cc index ebc738a1..32d2305 100644 --- a/chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views_unittest.cc +++ b/chrome/browser/ui/views/tab_contents/chrome_web_contents_view_delegate_views_unittest.cc
@@ -13,7 +13,14 @@ // Test that makes sure ShowContextMenu does not crash if web_contents() does // not have a focused frame. -TEST_F(ChromeWebContentsViewDelegateViewsTest, ContextMenuNoFocusedFrame) { +// TODO(crbug.com/1309808): Failing on Mac11. +#if BUILDFLAG(IS_MAC) +#define MAYBE_ContextMenuNoFocusedFrame DISABLED_ContextMenuNoFocusedFrame +#else +#define MAYBE_ContextMenuNoFocusedFrame ContextMenuNoFocusedFrame +#endif +TEST_F(ChromeWebContentsViewDelegateViewsTest, + MAYBE_ContextMenuNoFocusedFrame) { std::unique_ptr<content::WebContentsViewDelegate> delegate_view( CreateWebContentsViewDelegate(web_contents())); EXPECT_FALSE(web_contents()->GetFocusedFrame());
diff --git a/chrome/browser/ui/views/tab_search_bubble_host.cc b/chrome/browser/ui/views/tab_search_bubble_host.cc index 34b7fee..4c574a5a 100644 --- a/chrome/browser/ui/views/tab_search_bubble_host.cc +++ b/chrome/browser/ui/views/tab_search_bubble_host.cc
@@ -5,11 +5,9 @@ #include "chrome/browser/ui/views/tab_search_bubble_host.h" #include "base/bind.h" -#include "base/i18n/rtl.h" #include "base/metrics/histogram_functions.h" #include "chrome/app/vector_icons/vector_icons.h" #include "chrome/browser/feature_engagement/tracker_factory.h" -#include "chrome/browser/ui/layout_constants.h" #include "chrome/browser/ui/views/tabs/tab_strip_controller.h" #include "chrome/browser/ui/views/user_education/browser_feature_promo_controller.h" #include "chrome/common/webui_url_constants.h" @@ -19,7 +17,6 @@ #include "components/feature_engagement/public/tracker.h" #include "ui/base/metadata/metadata_impl_macros.h" #include "ui/compositor/compositor.h" -#include "ui/display/screen.h" #include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/presentation_feedback.h" #include "ui/views/widget/widget.h" @@ -109,26 +106,8 @@ if (controller) controller->CloseBubble(feature_engagement::kIPHTabSearchFeature); - absl::optional<gfx::Rect> anchor; - if (button_->GetWidget()->IsFullscreen()) { - // An anchor is necessary because the tabstrip used for bubble positioning - // is not available in fullscreen mode. The padding gives the bubble a - // more similar relative positioning to its non-fullscreen positioning. - // The mirrored position is needed to get the correct position in RTL - // mode. - auto display = display::Screen::GetScreen()->GetDisplayNearestView( - button_->GetWidget()->GetNativeView()); - gfx::Rect bounds = display.bounds(); - int offset = GetLayoutConstant(TABSTRIP_REGION_VIEW_CONTROL_PADDING); - - int x = base::i18n::IsRTL() ? bounds.x() + offset - : bounds.x() + bounds.width() - offset; - - anchor.emplace(gfx::Rect(x, bounds.y() + offset, 0, 0)); - } - bubble_created_time_ = base::TimeTicks::Now(); - webui_bubble_manager_.ShowBubble(anchor); + webui_bubble_manager_.ShowBubble(); auto* tracker = feature_engagement::TrackerFactory::GetForBrowserContext(profile_);
diff --git a/chrome/browser/ui/views/tab_search_bubble_host_browsertest.cc b/chrome/browser/ui/views/tab_search_bubble_host_browsertest.cc index 12759528..a0f97b10 100644 --- a/chrome/browser/ui/views/tab_search_bubble_host_browsertest.cc +++ b/chrome/browser/ui/views/tab_search_bubble_host_browsertest.cc
@@ -2,21 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/ui/test/test_browser_dialog.h" #include "chrome/browser/ui/views/tab_search_bubble_host.h" #include "base/run_loop.h" #include "build/build_config.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" #include "chrome/browser/ui/views/bubble/webui_bubble_manager.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/test/base/in_process_browser_test.h" #include "content/public/test/browser_test.h" #include "ui/base/accelerators/accelerator.h" -#include "ui/gfx/geometry/point.h" -#include "ui/gfx/geometry/rect.h" -#include "ui/gfx/geometry/size.h" class TabSearchBubbleHostBrowserTest : public InProcessBrowserTest { public: @@ -61,27 +56,6 @@ RunUntilBubbleWidgetDestroyed(); } -IN_PROC_BROWSER_TEST_F(TabSearchBubbleHostBrowserTest, - BubbleShowCorrectlyInFullscreen) { - browser() - ->exclusive_access_manager() - ->fullscreen_controller() - ->ToggleBrowserFullscreenMode(); - - gfx::Rect rect(gfx::Point(20, 4), gfx::Size()); - bubble_manager()->ShowBubble(rect); - - bubble_manager()->bubble_view_for_testing()->ShowUI(); - EXPECT_TRUE(bubble_manager()->GetBubbleWidget()->IsVisible()); - - gfx::Rect bound = - bubble_manager()->bubble_view_for_testing()->GetAnchorRect(); - EXPECT_EQ(bound, rect); - - tab_search_bubble_host()->CloseTabSearchBubble(); - RunUntilBubbleWidgetDestroyed(); -} - // On macOS, most accelerators are handled by CommandDispatcher. #if !BUILDFLAG(IS_MAC) IN_PROC_BROWSER_TEST_F(TabSearchBubbleHostBrowserTest, @@ -101,26 +75,3 @@ RunUntilBubbleWidgetDestroyed(); } #endif - -class FullscreenTabSearchBubbleDialogTest : public DialogBrowserTest { - public: - FullscreenTabSearchBubbleDialogTest() = default; - - FullscreenTabSearchBubbleDialogTest( - const FullscreenTabSearchBubbleDialogTest&) = delete; - FullscreenTabSearchBubbleDialogTest& operator=( - const FullscreenTabSearchBubbleDialogTest&) = delete; - - void ShowUi(const std::string& name) override { - browser() - ->exclusive_access_manager() - ->fullscreen_controller() - ->ToggleBrowserFullscreenMode(); - BrowserView* view = BrowserView::GetBrowserViewForBrowser(browser()); - view->CreateTabSearchBubble(); - } -}; - -IN_PROC_BROWSER_TEST_F(FullscreenTabSearchBubbleDialogTest, InvokeUi_default) { - ShowAndVerifyUi(); -}
diff --git a/chrome/browser/ui/views/web_apps/file_handler_launch_dialog_browsertest.cc b/chrome/browser/ui/views/web_apps/file_handler_launch_dialog_browsertest.cc index a00300d..c70fe58 100644 --- a/chrome/browser/ui/views/web_apps/file_handler_launch_dialog_browsertest.cc +++ b/chrome/browser/ui/views/web_apps/file_handler_launch_dialog_browsertest.cc
@@ -48,8 +48,7 @@ } // namespace // Tests for the `FileHandlerLaunchDialogView` as well as -// `startup::web_app::MaybeHandleWebAppLaunch()`. As Chrome OS uses the app -// service to launch PWAs, this test suite is not run there. +// `startup::web_app::MaybeHandleWebAppLaunch()`. class FileHandlerLaunchDialogTest : public InProcessBrowserTest { public: void SetUpOnMainThread() override {
diff --git a/chrome/browser/ui/views/web_apps/web_app_integration_browsertest.cc b/chrome/browser/ui/views/web_apps/web_app_integration_browsertest.cc index 0090aff..fd3f71d 100644 --- a/chrome/browser/ui/views/web_apps/web_app_integration_browsertest.cc +++ b/chrome/browser/ui/views/web_apps/web_app_integration_browsertest.cc
@@ -11,6 +11,15 @@ // Manual tests: +IN_PROC_BROWSER_TEST_F(WebAppIntegrationBrowserTest, + LaunchFromPlatformShortcut) { + helper_.InstallCreateShortcutWindowed("SiteA"); + helper_.CheckWindowCreated(); + helper_.ClosePwa(); + helper_.LaunchFromPlatformShortcut("SiteA"); + helper_.CheckWindowCreated(); +} + IN_PROC_BROWSER_TEST_F(WebAppIntegrationBrowserTest, UninstallFromList) { helper_.InstallCreateShortcutWindowed("SiteA"); helper_.UninstallFromList("SiteA");
diff --git a/chrome/browser/ui/views/web_apps/web_app_integration_browsertest_mac_win_linux.cc b/chrome/browser/ui/views/web_apps/web_app_integration_browsertest_mac_win_linux.cc index 7b0b481d..de4f7c3 100644 --- a/chrome/browser/ui/views/web_apps/web_app_integration_browsertest_mac_win_linux.cc +++ b/chrome/browser/ui/views/web_apps/web_app_integration_browsertest_mac_win_linux.cc
@@ -13,15 +13,6 @@ // Manual tests: -IN_PROC_BROWSER_TEST_F(WebAppIntegrationBrowserTest, - LaunchFromPlatformShortcut) { - helper_.InstallCreateShortcutWindowed("SiteA"); - helper_.CheckWindowCreated(); - helper_.ClosePwa(); - helper_.LaunchFromPlatformShortcut("SiteA"); - helper_.CheckWindowCreated(); -} - IN_PROC_BROWSER_TEST_F(WebAppIntegrationBrowserTestMacWinLinux, CheckPlatformShortcutAndIcon) { helper_.CheckPlatformShortcutNotExists("SiteA");
diff --git a/chrome/browser/ui/views/web_apps/web_app_integration_test_driver.cc b/chrome/browser/ui/views/web_apps/web_app_integration_test_driver.cc index 60b7611..07d4861 100644 --- a/chrome/browser/ui/views/web_apps/web_app_integration_test_driver.cc +++ b/chrome/browser/ui/views/web_apps/web_app_integration_test_driver.cc
@@ -832,7 +832,6 @@ void WebAppIntegrationTestDriver::LaunchFromPlatformShortcut( const std::string& site_mode) { -#if !BUILDFLAG(IS_CHROMEOS) BeforeStateChangeAction(__FUNCTION__); absl::optional<AppState> app_state = GetAppBySiteMode( before_state_change_action_state_.get(), profile(), site_mode); @@ -859,9 +858,6 @@ app_banner_manager->WaitForInstallableCheck(); } AfterStateChangeAction(); -#else - NOTREACHED() << "Not implemented on Chrome OS."; -#endif } void WebAppIntegrationTestDriver::OpenAppSettingsFromAppMenu(
diff --git a/chrome/browser/web_applications/test/isolated_app_test_utils.cc b/chrome/browser/ui/web_applications/test/isolated_app_test_utils.cc similarity index 97% rename from chrome/browser/web_applications/test/isolated_app_test_utils.cc rename to chrome/browser/ui/web_applications/test/isolated_app_test_utils.cc index 5665de7e..268a7b9 100644 --- a/chrome/browser/web_applications/test/isolated_app_test_utils.cc +++ b/chrome/browser/ui/web_applications/test/isolated_app_test_utils.cc
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/web_applications/test/isolated_app_test_utils.h" +#include "chrome/browser/ui/web_applications/test/isolated_app_test_utils.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h"
diff --git a/chrome/browser/web_applications/test/isolated_app_test_utils.h b/chrome/browser/ui/web_applications/test/isolated_app_test_utils.h similarity index 84% rename from chrome/browser/web_applications/test/isolated_app_test_utils.h rename to chrome/browser/ui/web_applications/test/isolated_app_test_utils.h index 4569df2..2fb7db8 100644 --- a/chrome/browser/web_applications/test/isolated_app_test_utils.h +++ b/chrome/browser/ui/web_applications/test/isolated_app_test_utils.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_WEB_APPLICATIONS_TEST_ISOLATED_APP_TEST_UTILS_H_ -#define CHROME_BROWSER_WEB_APPLICATIONS_TEST_ISOLATED_APP_TEST_UTILS_H_ +#ifndef CHROME_BROWSER_UI_WEB_APPLICATIONS_TEST_ISOLATED_APP_TEST_UTILS_H_ +#define CHROME_BROWSER_UI_WEB_APPLICATIONS_TEST_ISOLATED_APP_TEST_UTILS_H_ #include <string> @@ -40,4 +40,4 @@ } // namespace web_app -#endif // CHROME_BROWSER_WEB_APPLICATIONS_TEST_ISOLATED_APP_TEST_UTILS_H_ +#endif // CHROME_BROWSER_UI_WEB_APPLICATIONS_TEST_ISOLATED_APP_TEST_UTILS_H_
diff --git a/chrome/browser/ui/web_applications/web_app_engagement_browsertest.cc b/chrome/browser/ui/web_applications/web_app_engagement_browsertest.cc index 150c7c8..d315b10 100644 --- a/chrome/browser/ui/web_applications/web_app_engagement_browsertest.cc +++ b/chrome/browser/ui/web_applications/web_app_engagement_browsertest.cc
@@ -475,9 +475,6 @@ TestEngagementEventsAfterLaunch(histograms, browser()); } -// On Chrome OS, PWAs are launched via the app service rather than via command -// line flags. -#if !BUILDFLAG(IS_CHROMEOS) IN_PROC_BROWSER_TEST_F(WebAppEngagementBrowserTest, CommandLineWindowByUrl) { base::HistogramTester tester; ASSERT_TRUE(embedded_test_server()->Start()); @@ -629,6 +626,5 @@ EXPECT_EQ(expected_browsers, chrome::GetBrowserCount(browser()->profile())); EXPECT_EQ(expected_tabs, browser()->tab_strip_model()->count()); } -#endif } // namespace web_app
diff --git a/chrome/browser/ui/webui/chromeos/login/lacros_data_migration_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/lacros_data_migration_screen_handler.cc index 77dc4b1..921bbaca 100644 --- a/chrome/browser/ui/webui/chromeos/login/lacros_data_migration_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/lacros_data_migration_screen_handler.cc
@@ -8,6 +8,7 @@ #include "chrome/grit/chromium_strings.h" #include "chrome/grit/generated_resources.h" #include "components/login/localized_values_builder.h" +#include "ui/base/text/bytes_formatting.h" namespace chromeos { @@ -36,6 +37,16 @@ IDS_LACROS_DATA_MIGRATION_SCREEN_SKIP_SUGGESTION); builder->Add("batteryWarningTitle", IDS_UPDATE_BATTERY_WARNING_TITLE); builder->Add("batteryWarningText", IDS_UPDATE_BATTERY_WARNING_TEXT); + builder->Add("lacrosDataMigrationErrorTitle", + IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_TITLE); + builder->Add("lacrosDataMigrationErrorLowDiskSpace", + IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_LOW_DISK_SPACE); + builder->Add("lacrosDataMigrationErrorSubtitle", + IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_SUBTITLE); + builder->Add("lacrosDataMigrationErrorCancelButton", + IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_CANCEL_BUTTON); + builder->Add("lacrosDataMigrationErrorGotoFilesButton", + IDS_LACROS_DATA_MIGRATION_SCREEN_ERROR_GOTO_FILES_BUTTON); } void LacrosDataMigrationScreenHandler::Bind(LacrosDataMigrationScreen* screen) { @@ -68,6 +79,16 @@ CallJS("login.LacrosDataMigrationScreen.setLowBatteryStatus", low_battery); } +void LacrosDataMigrationScreenHandler::SetFailureStatus( + const absl::optional<uint64_t>& required_size, + bool show_goto_files) { + CallJS("login.LacrosDataMigrationScreen.setFailureStatus", + required_size.has_value() + ? ui::FormatBytes(static_cast<int64_t>(required_size.value())) + : std::u16string(), + show_goto_files); +} + void LacrosDataMigrationScreenHandler::Initialize() { if (show_on_init_) { Show();
diff --git a/chrome/browser/ui/webui/chromeos/login/lacros_data_migration_screen_handler.h b/chrome/browser/ui/webui/chromeos/login/lacros_data_migration_screen_handler.h index a0e2506..994d309 100644 --- a/chrome/browser/ui/webui/chromeos/login/lacros_data_migration_screen_handler.h +++ b/chrome/browser/ui/webui/chromeos/login/lacros_data_migration_screen_handler.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_LACROS_DATA_MIGRATION_SCREEN_HANDLER_H_ #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace ash { class LacrosDataMigrationScreen; @@ -38,6 +39,13 @@ // Notifies the UI about low battery. virtual void SetLowBatteryStatus(bool low_battery) = 0; + + // Displays the error page. If |required_size| is non nullopt, the error + // message is to navigate users to make some space on their disk to run + // migration. + // |show_goto_files| can control + virtual void SetFailureStatus(const absl::optional<uint64_t>& required_size, + bool show_goto_files) = 0; }; class LacrosDataMigrationScreenHandler : public BaseScreenHandler, @@ -64,6 +72,8 @@ void SetProgressValue(int progress) override; void ShowSkipButton() override; void SetLowBatteryStatus(bool low_battery) override; + void SetFailureStatus(const absl::optional<uint64_t>& required_size, + bool show_goto_files) override; private: // BaseScreenHandler:
diff --git a/chrome/browser/ui/webui/history_clusters/history_clusters.mojom b/chrome/browser/ui/webui/history_clusters/history_clusters.mojom index 1e93841..995ed05 100644 --- a/chrome/browser/ui/webui/history_clusters/history_clusters.mojom +++ b/chrome/browser/ui/webui/history_clusters/history_clusters.mojom
@@ -60,12 +60,8 @@ // Annotations for this visit. array<Annotation> annotations; - // Related visits to this visit; starting with the highest scoring one, if - // applicable. Only prominently featured visits have related visits. - array<URLVisit> related_visits; - // Whether a related visit is initially hidden. - bool below_the_fold; + bool hidden; // A key-value dictionary of additional debug info to show. This is not // visible in production, and used for development only. @@ -79,12 +75,12 @@ // Cluster identifier. See //components/history/core/browser/history_types.h int64 id; - // The prominently featured constituent visit, typically the highest scoring - // one, containing its own related visits. - URLVisit visit; + // A flat list of all the visits in the cluster. The first one is the + // "top visit" if the UI needs to specially display a "top visit". + array<URLVisit> visits; // An optional label for the whole cluster. If this is not defined or empty, - // `visit` should be displayed prominently instead. + // the first visit should be displayed prominently instead. string? label; // Search queries related to this cluster's visits.
diff --git a/chrome/browser/ui/webui/history_clusters/history_clusters_handler.cc b/chrome/browser/ui/webui/history_clusters/history_clusters_handler.cc index 7d3f0959..01ebb5d 100644 --- a/chrome/browser/ui/webui/history_clusters/history_clusters_handler.cc +++ b/chrome/browser/ui/webui/history_clusters/history_clusters_handler.cc
@@ -144,27 +144,19 @@ for (const auto& visit : cluster.visits) { mojom::URLVisitPtr visit_mojom = VisitToMojom(profile, visit); - if (!cluster_mojom->visit) { - // The first visit is always the top visit. - cluster_mojom->visit = std::move(visit_mojom); - } else { - const auto& top_visit = cluster.visits.front(); - DCHECK(visit.score <= top_visit.score); - // After the experiment-controlled max related visits are attached to - // the top visit, any subsequent visits scored below the - // experiment-controlled threshold are considered below the fold. - // 0-scored (duplicate) visits are always considered below the fold. - const auto& top_visit_mojom = cluster_mojom->visit; - visit_mojom->below_the_fold = - (top_visit_mojom->related_visits.size() >= - static_cast<size_t>( - GetConfig().num_visits_to_always_show_above_the_fold) && - visit.score < - GetConfig().min_score_to_always_show_above_the_fold) || - visit.score == 0.0; - top_visit_mojom->related_visits.push_back(std::move(visit_mojom)); + + // Even a 0.0 visit shouldn't be hidden if this is the first visit we + // encounter. The assumption is that the visits are always ranked by score + // in a descending order. + if ((visit.score == 0.0 && !cluster_mojom->visits.empty()) || + (visit.score < GetConfig().min_score_to_always_show_above_the_fold && + cluster_mojom->visits.size() >= + GetConfig().num_visits_to_always_show_above_the_fold)) { + visit_mojom->hidden = true; } + cluster_mojom->visits.push_back(std::move(visit_mojom)); + // Coalesce the unique related searches of this visit into the cluster // until the cap is reached. for (const auto& search_query :
diff --git a/chrome/browser/ui/webui/history_clusters/history_clusters_handler_unittest.cc b/chrome/browser/ui/webui/history_clusters/history_clusters_handler_unittest.cc index 71ea9ca..a1fef0c 100644 --- a/chrome/browser/ui/webui/history_clusters/history_clusters_handler_unittest.cc +++ b/chrome/browser/ui/webui/history_clusters/history_clusters_handler_unittest.cc
@@ -51,7 +51,7 @@ TestingProfile profile_; }; -TEST_F(HistoryClustersHandlerTest, QueryClustersResultToMojom_BelowTheFold) { +TEST_F(HistoryClustersHandlerTest, QueryClustersResultToMojom_Hidden) { std::vector<history::Cluster> clusters; // High scoring visits should always be above the fold. @@ -96,35 +96,31 @@ { EXPECT_EQ(mojom_result->clusters[0]->id, 4); - EXPECT_EQ(mojom_result->clusters[0]->visit->below_the_fold, false); - const auto& related_visits = - mojom_result->clusters[0]->visit->related_visits; - ASSERT_EQ(related_visits.size(), 4u); - EXPECT_EQ(related_visits[0]->below_the_fold, false); - EXPECT_EQ(related_visits[1]->below_the_fold, false); - EXPECT_EQ(related_visits[2]->below_the_fold, false); - EXPECT_EQ(related_visits[3]->below_the_fold, false); + const auto& visits = mojom_result->clusters[0]->visits; + ASSERT_EQ(visits.size(), 5u); + EXPECT_EQ(visits[0]->hidden, false); + EXPECT_EQ(visits[1]->hidden, false); + EXPECT_EQ(visits[2]->hidden, false); + EXPECT_EQ(visits[3]->hidden, false); + EXPECT_EQ(visits[4]->hidden, false); } { EXPECT_EQ(mojom_result->clusters[1]->id, 6); - EXPECT_EQ(mojom_result->clusters[0]->visit->below_the_fold, false); - const auto& related_visits = - mojom_result->clusters[1]->visit->related_visits; - ASSERT_EQ(related_visits.size(), 4u); - EXPECT_EQ(related_visits[0]->below_the_fold, false); - EXPECT_EQ(related_visits[1]->below_the_fold, false); - EXPECT_EQ(related_visits[2]->below_the_fold, false); - EXPECT_EQ(related_visits[3]->below_the_fold, true); + const auto& visits = mojom_result->clusters[1]->visits; + ASSERT_EQ(visits.size(), 5u); + EXPECT_EQ(visits[0]->hidden, false); + EXPECT_EQ(visits[1]->hidden, false); + EXPECT_EQ(visits[2]->hidden, false); + EXPECT_EQ(visits[3]->hidden, false); + EXPECT_EQ(visits[4]->hidden, true); } { EXPECT_EQ(mojom_result->clusters[2]->id, 8); - ASSERT_EQ(mojom_result->clusters[2]->visit->related_visits.size(), 1u); - EXPECT_EQ(mojom_result->clusters[2]->visit->below_the_fold, false); - const auto& related_visits = - mojom_result->clusters[02]->visit->related_visits; - EXPECT_EQ(related_visits[0]->below_the_fold, true); + ASSERT_EQ(mojom_result->clusters[2]->visits.size(), 2u); + EXPECT_EQ(mojom_result->clusters[2]->visits[0]->hidden, false); + EXPECT_EQ(mojom_result->clusters[2]->visits[1]->hidden, true); } }
diff --git a/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc b/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc index 51942c8..8c603a56 100644 --- a/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc +++ b/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc
@@ -400,6 +400,8 @@ registry->RegisterListPref(prefs::kNtpModulesOrder, true); registry->RegisterBooleanPref(prefs::kNtpModulesVisible, true); registry->RegisterBooleanPref(prefs::kNtpModulesFreVisible, true); + registry->RegisterIntegerPref(prefs::kNtpModulesFreShownCount, 0); + registry->RegisterTimePref(prefs::kNtpModulesFreFirstShownTime, base::Time()); } void NewTabPageHandler::SetMostVisitedSettings(bool custom_links_enabled, @@ -654,8 +656,35 @@ } void NewTabPageHandler::UpdateModulesFreVisibility() { - page_->SetModulesFreVisibility( - profile_->GetPrefs()->GetBoolean(prefs::kNtpModulesFreVisible)); + const auto ntp_modules_fre_first_shown_time = + profile_->GetPrefs()->GetTime(prefs::kNtpModulesFreFirstShownTime); + const auto ntp_modules_fre_shown_count = + profile_->GetPrefs()->GetInteger(prefs::kNtpModulesFreShownCount); + const auto ntp_modules_fre_visible = + profile_->GetPrefs()->GetBoolean(prefs::kNtpModulesFreVisible); + + // Hide Modular NTP Desktop v1 First Run Experience after 8 impressions or 1 + // day, whichever comes first. + if (ntp_modules_fre_shown_count >= 8 || + (!ntp_modules_fre_first_shown_time.is_null() && + (base::Time::Now() - ntp_modules_fre_first_shown_time) > + base::Days(1))) { + profile_->GetPrefs()->SetBoolean(prefs::kNtpModulesFreVisible, false); + page_->SetModulesFreVisibility(false); + } else { + page_->SetModulesFreVisibility(ntp_modules_fre_visible); + } + + // Count the number of times the user has seen the FRE. + if (ntp_modules_fre_visible == true) { + // Record time user first sees Modular NTP Desktop v1 First Run Experience + if (ntp_modules_fre_shown_count == 0) { + profile_->GetPrefs()->SetTime(prefs::kNtpModulesFreFirstShownTime, + base::Time::Now()); + } + profile_->GetPrefs()->SetInteger(prefs::kNtpModulesFreShownCount, + ntp_modules_fre_shown_count + 1); + } } void NewTabPageHandler::SetModulesFreVisible(bool visible) {
diff --git a/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler_unittest.cc b/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler_unittest.cc index f34d1e3..02d9a99 100644 --- a/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler_unittest.cc +++ b/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler_unittest.cc
@@ -674,7 +674,7 @@ EXPECT_THAT(module_ids, ElementsAre("foo", "bar", "baz")); } -TEST_F(NewTabPageHandlerTest, UpdateModulesFreVisibility) { +TEST_F(NewTabPageHandlerTest, UpdateNtpModulesFreVisibility) { bool expected_visibility = true; profile_->GetPrefs()->SetBoolean(prefs::kNtpModulesFreVisible, expected_visibility); @@ -695,3 +695,43 @@ mock_page_.FlushForTesting(); } + +TEST_F(NewTabPageHandlerTest, NtpModulesFreShownCount) { + handler_->SetModulesFreVisible(true); + profile_->GetPrefs()->SetInteger(prefs::kNtpModulesFreShownCount, 7); + + handler_->UpdateModulesFreVisibility(); + + EXPECT_EQ(profile_->GetPrefs()->GetBoolean(prefs::kNtpModulesFreVisible), + true); + + profile_->GetPrefs()->SetInteger(prefs::kNtpModulesFreShownCount, 9); + + handler_->UpdateModulesFreVisibility(); + + EXPECT_EQ(profile_->GetPrefs()->GetBoolean(prefs::kNtpModulesFreVisible), + false); + + mock_page_.FlushForTesting(); +} + +TEST_F(NewTabPageHandlerTest, NtpModulesFreFirstShownTime) { + handler_->SetModulesFreVisible(true); + profile_->GetPrefs()->SetTime(prefs::kNtpModulesFreFirstShownTime, + base::Time::Now()); + + handler_->UpdateModulesFreVisibility(); + + EXPECT_EQ(profile_->GetPrefs()->GetBoolean(prefs::kNtpModulesFreVisible), + true); + + profile_->GetPrefs()->SetTime(prefs::kNtpModulesFreFirstShownTime, + base::Time::Now() - base::Days(2)); + + handler_->UpdateModulesFreVisibility(); + + EXPECT_EQ(profile_->GetPrefs()->GetBoolean(prefs::kNtpModulesFreVisible), + false); + + mock_page_.FlushForTesting(); +}
diff --git a/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc b/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc index 8caf81d..568c5e9d 100644 --- a/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc +++ b/chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.cc
@@ -384,10 +384,12 @@ IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_BODY_LINE_1}, {"modulesFirstRunExperienceBodyLine2", IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_BODY_LINE_2}, - {"modulesFirstRunOptInButton", - IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_IN_BUTTON}, - {"modulesFirstRunOptOutButton", - IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_OUT_BUTTON}, + {"modulesFirstRunExperienceOptIn", + IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_IN}, + {"modulesFirstRunExperienceOptOut", + IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_OUT}, + {"modulesFirstRunExperienceOptOutToast", + IDS_NTP_MODULES_FIRST_RUN_EXPERIENCE_OPT_OUT_TOAST}, }; source->AddLocalizedStrings(kStrings);
diff --git a/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.cc b/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.cc index a2c0902..2dbce49 100644 --- a/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.cc +++ b/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.cc
@@ -87,14 +87,12 @@ OfflineInternalsUIMessageHandler::~OfflineInternalsUIMessageHandler() {} void OfflineInternalsUIMessageHandler::HandleDeleteSelectedPages( - const base::ListValue* args) { - base::Value::ConstListView args_list = args->GetListDeprecated(); - CHECK_EQ(2u, args_list.size()); - std::string callback_id = args_list[0].GetString(); + const base::Value::List& args) { + CHECK_EQ(2u, args.size()); + std::string callback_id = args[0].GetString(); std::vector<int64_t> offline_ids; - base::Value::ConstListView offline_ids_from_arg = - args_list[1].GetListDeprecated(); + base::Value::ConstListView offline_ids_from_arg = args[1].GetListDeprecated(); for (size_t i = 0; i < offline_ids_from_arg.size(); i++) { std::string value = offline_ids_from_arg[i].GetString(); int64_t int_value; @@ -112,14 +110,12 @@ } void OfflineInternalsUIMessageHandler::HandleDeleteSelectedRequests( - const base::ListValue* args) { - base::Value::ConstListView args_list = args->GetListDeprecated(); - CHECK_EQ(2u, args_list.size()); - std::string callback_id = args_list[0].GetString(); + const base::Value::List& args) { + CHECK_EQ(2u, args.size()); + std::string callback_id = args[0].GetString(); std::vector<int64_t> offline_ids; - base::Value::ConstListView offline_ids_from_arg = - args_list[1].GetListDeprecated(); + base::Value::ConstListView offline_ids_from_arg = args[1].GetListDeprecated(); for (size_t i = 0; i < offline_ids_from_arg.size(); i++) { std::string value = offline_ids_from_arg[i].GetString(); int64_t int_value; @@ -207,9 +203,9 @@ } void OfflineInternalsUIMessageHandler::HandleGetRequestQueue( - const base::ListValue* args) { + const base::Value::List& args) { AllowJavascript(); - const std::string& callback_id = args->GetListDeprecated()[0].GetString(); + const std::string& callback_id = args[0].GetString(); if (request_coordinator_) { request_coordinator_->GetAllRequests(base::BindOnce( @@ -222,9 +218,9 @@ } void OfflineInternalsUIMessageHandler::HandleGetStoredPages( - const base::ListValue* args) { + const base::Value::List& args) { AllowJavascript(); - const std::string& callback_id = args->GetListDeprecated()[0].GetString(); + const std::string& callback_id = args[0].GetString(); if (offline_page_model_) { offline_page_model_->GetAllPages(base::BindOnce( @@ -237,19 +233,18 @@ } void OfflineInternalsUIMessageHandler::HandleSetRecordPageModel( - const base::ListValue* args) { + const base::Value::List& args) { AllowJavascript(); - const auto& list = args->GetListDeprecated(); - CHECK(!list.empty()); - const bool should_record = list[0].GetBool(); + CHECK(!args.empty()); + const bool should_record = args[0].GetBool(); if (offline_page_model_) offline_page_model_->GetLogger()->SetIsLogging(should_record); } void OfflineInternalsUIMessageHandler::HandleGetNetworkStatus( - const base::ListValue* args) { + const base::Value::List& args) { AllowJavascript(); - const base::Value& callback_id = args->GetListDeprecated()[0]; + const base::Value& callback_id = args[0]; ResolveJavascriptCallback( callback_id, @@ -258,9 +253,9 @@ } void OfflineInternalsUIMessageHandler::HandleScheduleNwake( - const base::ListValue* args) { + const base::Value::List& args) { AllowJavascript(); - const base::Value& callback_id = args->GetListDeprecated()[0]; + const base::Value& callback_id = args[0]; if (prefetch_service_) { prefetch_service_->ForceRefreshSuggestions(); @@ -274,9 +269,9 @@ } void OfflineInternalsUIMessageHandler::HandleCancelNwake( - const base::ListValue* args) { + const base::Value::List& args) { AllowJavascript(); - const base::Value& callback_id = args->GetListDeprecated()[0]; + const base::Value& callback_id = args[0]; if (prefetch_service_) { prefetch_service_->GetPrefetchBackgroundTaskHandler() @@ -289,9 +284,9 @@ } void OfflineInternalsUIMessageHandler::HandleGeneratePageBundle( - const base::ListValue* args) { + const base::Value::List& args) { AllowJavascript(); - const std::string& callback_id = args->GetListDeprecated()[0].GetString(); + const std::string& callback_id = args[0].GetString(); if (!prefetch_service_) { RejectJavascriptCallback(base::Value(callback_id), @@ -299,7 +294,7 @@ return; } - const std::string& data = args->GetListDeprecated()[1].GetString(); + const std::string& data = args[1].GetString(); std::vector<std::string> page_urls = base::SplitStringUsingSubstr( data, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); std::vector<offline_pages::PrefetchURL> prefetch_urls; @@ -340,9 +335,9 @@ } void OfflineInternalsUIMessageHandler::HandleGetOperation( - const base::ListValue* args) { + const base::Value::List& args) { AllowJavascript(); - const std::string& callback_id = args->GetListDeprecated()[0].GetString(); + const std::string& callback_id = args[0].GetString(); if (!prefetch_service_) { RejectJavascriptCallback(base::Value(callback_id), @@ -350,7 +345,7 @@ return; } - std::string name = args->GetListDeprecated()[1].GetString(); + std::string name = args[1].GetString(); base::TrimWhitespaceASCII(name, base::TRIM_ALL, &name); prefetch_service_->GetPrefetchDispatcher() @@ -360,9 +355,9 @@ } void OfflineInternalsUIMessageHandler::HandleDownloadArchive( - const base::ListValue* args) { + const base::Value::List& args) { AllowJavascript(); - std::string name = args->GetListDeprecated()[0].GetString(); + std::string name = args[0].GetString(); base::TrimWhitespaceASCII(name, base::TRIM_ALL, &name); if (prefetch_service_) { @@ -372,38 +367,36 @@ } void OfflineInternalsUIMessageHandler::HandleSetRecordRequestQueue( - const base::ListValue* args) { + const base::Value::List& args) { AllowJavascript(); - const auto& list = args->GetListDeprecated(); - CHECK(!list.empty()); - const bool should_record = list[0].GetBool(); + CHECK(!args.empty()); + const bool should_record = args[0].GetBool(); if (request_coordinator_) request_coordinator_->GetLogger()->SetIsLogging(should_record); } void OfflineInternalsUIMessageHandler::HandleSetRecordPrefetchService( - const base::ListValue* args) { + const base::Value::List& args) { AllowJavascript(); - const auto& list = args->GetListDeprecated(); - CHECK(!list.empty()); - const bool should_record = list[0].GetBool(); + CHECK(!args.empty()); + const bool should_record = args[0].GetBool(); if (prefetch_service_) prefetch_service_->GetLogger()->SetIsLogging(should_record); } void OfflineInternalsUIMessageHandler::HandleSetLimitlessPrefetchingEnabled( - const base::ListValue* args) { + const base::Value::List& args) { AllowJavascript(); PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); - DCHECK(!args->GetListDeprecated().empty()); - bool enabled = args->GetListDeprecated()[0].GetBool(); + DCHECK(!args.empty()); + bool enabled = args[0].GetBool(); offline_pages::prefetch_prefs::SetLimitlessPrefetchingEnabled(prefs, enabled); } void OfflineInternalsUIMessageHandler::HandleGetLimitlessPrefetchingEnabled( - const base::ListValue* args) { + const base::Value::List& args) { AllowJavascript(); - const base::Value& callback_id = args->GetListDeprecated()[0]; + const base::Value& callback_id = args[0]; PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); bool enabled = @@ -413,56 +406,54 @@ } void OfflineInternalsUIMessageHandler::HandleSetPrefetchTestingHeader( - const base::ListValue* args) { + const base::Value::List& args) { AllowJavascript(); PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); - if (args->GetListDeprecated().size() != 1) { + if (args.size() != 1) { DLOG(ERROR) << "Expected 1 argument to setPrefetchTesting header but got " - << args->GetListDeprecated().size(); + << args.size(); return; } - if (!args->GetListDeprecated()[0].is_string()) { + if (!args[0].is_string()) { DLOG(ERROR) << "Expected argument to be string but got " - << base::Value::GetTypeName( - args->GetListDeprecated()[0].type()); + << base::Value::GetTypeName(args[0].type()); return; } - offline_pages::prefetch_prefs::SetPrefetchTestingHeader( - prefs, args->GetListDeprecated()[0].GetString()); + offline_pages::prefetch_prefs::SetPrefetchTestingHeader(prefs, + args[0].GetString()); if (prefetch_service_) prefetch_service_->SetEnabledByServer(prefs, true); } void OfflineInternalsUIMessageHandler::HandleGetPrefetchTestingHeader( - const base::ListValue* args) { + const base::Value::List& args) { AllowJavascript(); - if (args->GetListDeprecated().size() != 1) { + if (args.size() != 1) { DLOG(ERROR) << "Expected 1 argument to getPrefetchTestingHeader but got " - << args->GetListDeprecated().size(); + << args.size(); return; } - if (!args->GetListDeprecated()[0].is_string()) { + if (!args[0].is_string()) { DLOG(ERROR) << "Expected callback_id to be a string but got " - << base::Value::GetTypeName( - args->GetListDeprecated()[0].type()); + << base::Value::GetTypeName(args[0].type()); return; } PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); ResolveJavascriptCallback( - args->GetListDeprecated()[0], + args[0], base::Value(offline_pages::prefetch_prefs::GetPrefetchTestingHeader(prefs) )); } void OfflineInternalsUIMessageHandler::HandleGetLoggingState( - const base::ListValue* args) { + const base::Value::List& args) { AllowJavascript(); - const base::Value& callback_id = args->GetListDeprecated()[0]; + const base::Value& callback_id = args[0]; base::DictionaryValue result; result.SetBoolKey("modelIsLogging", @@ -482,9 +473,9 @@ } void OfflineInternalsUIMessageHandler::HandleGetEventLogs( - const base::ListValue* args) { + const base::Value::List& args) { AllowJavascript(); - const base::Value& callback_id = args->GetListDeprecated()[0]; + const base::Value& callback_id = args[0]; std::vector<std::string> logs; if (offline_page_model_) @@ -504,11 +495,11 @@ } void OfflineInternalsUIMessageHandler::HandleAddToRequestQueue( - const base::ListValue* args) { - const std::string& callback_id = args->GetListDeprecated()[0].GetString(); + const base::Value::List& args) { + const std::string& callback_id = args[0].GetString(); if (request_coordinator_) { - const std::string& url = args->GetListDeprecated()[1].GetString(); + const std::string& url = args[1].GetString(); // To be visible in Downloads UI, these items need a well-formed GUID // and AsyncNamespace in their ClientId. @@ -538,99 +529,99 @@ } void OfflineInternalsUIMessageHandler::RegisterMessages() { - web_ui()->RegisterDeprecatedMessageCallback( + web_ui()->RegisterMessageCallback( "deleteSelectedPages", base::BindRepeating( &OfflineInternalsUIMessageHandler::HandleDeleteSelectedPages, base::Unretained(this))); - web_ui()->RegisterDeprecatedMessageCallback( + web_ui()->RegisterMessageCallback( "deleteSelectedRequests", base::BindRepeating( &OfflineInternalsUIMessageHandler::HandleDeleteSelectedRequests, base::Unretained(this))); - web_ui()->RegisterDeprecatedMessageCallback( + web_ui()->RegisterMessageCallback( "getRequestQueue", base::BindRepeating( &OfflineInternalsUIMessageHandler::HandleGetRequestQueue, base::Unretained(this))); - web_ui()->RegisterDeprecatedMessageCallback( + web_ui()->RegisterMessageCallback( "getStoredPages", base::BindRepeating( &OfflineInternalsUIMessageHandler::HandleGetStoredPages, base::Unretained(this))); - web_ui()->RegisterDeprecatedMessageCallback( + web_ui()->RegisterMessageCallback( "getEventLogs", base::BindRepeating(&OfflineInternalsUIMessageHandler::HandleGetEventLogs, base::Unretained(this))); - web_ui()->RegisterDeprecatedMessageCallback( + web_ui()->RegisterMessageCallback( "setRecordRequestQueue", base::BindRepeating( &OfflineInternalsUIMessageHandler::HandleSetRecordRequestQueue, base::Unretained(this))); - web_ui()->RegisterDeprecatedMessageCallback( + web_ui()->RegisterMessageCallback( "setRecordPageModel", base::BindRepeating( &OfflineInternalsUIMessageHandler::HandleSetRecordPageModel, base::Unretained(this))); - web_ui()->RegisterDeprecatedMessageCallback( + web_ui()->RegisterMessageCallback( "setRecordPrefetchService", base::BindRepeating( &OfflineInternalsUIMessageHandler::HandleSetRecordPrefetchService, base::Unretained(this))); - web_ui()->RegisterDeprecatedMessageCallback( + web_ui()->RegisterMessageCallback( "setLimitlessPrefetchingEnabled", base::BindRepeating(&OfflineInternalsUIMessageHandler:: HandleSetLimitlessPrefetchingEnabled, base::Unretained(this))); - web_ui()->RegisterDeprecatedMessageCallback( + web_ui()->RegisterMessageCallback( "getLimitlessPrefetchingEnabled", base::BindRepeating(&OfflineInternalsUIMessageHandler:: HandleGetLimitlessPrefetchingEnabled, base::Unretained(this))); - web_ui()->RegisterDeprecatedMessageCallback( + web_ui()->RegisterMessageCallback( "setPrefetchTestingHeader", base::BindRepeating( &OfflineInternalsUIMessageHandler::HandleSetPrefetchTestingHeader, base::Unretained(this))); - web_ui()->RegisterDeprecatedMessageCallback( + web_ui()->RegisterMessageCallback( "getPrefetchTestingHeader", base::BindRepeating( &OfflineInternalsUIMessageHandler::HandleGetPrefetchTestingHeader, base::Unretained(this))); - web_ui()->RegisterDeprecatedMessageCallback( + web_ui()->RegisterMessageCallback( "getLoggingState", base::BindRepeating( &OfflineInternalsUIMessageHandler::HandleGetLoggingState, base::Unretained(this))); - web_ui()->RegisterDeprecatedMessageCallback( + web_ui()->RegisterMessageCallback( "addToRequestQueue", base::BindRepeating( &OfflineInternalsUIMessageHandler::HandleAddToRequestQueue, base::Unretained(this))); - web_ui()->RegisterDeprecatedMessageCallback( + web_ui()->RegisterMessageCallback( "getNetworkStatus", base::BindRepeating( &OfflineInternalsUIMessageHandler::HandleGetNetworkStatus, base::Unretained(this))); - web_ui()->RegisterDeprecatedMessageCallback( + web_ui()->RegisterMessageCallback( "scheduleNwake", base::BindRepeating( &OfflineInternalsUIMessageHandler::HandleScheduleNwake, base::Unretained(this))); - web_ui()->RegisterDeprecatedMessageCallback( + web_ui()->RegisterMessageCallback( "cancelNwake", base::BindRepeating(&OfflineInternalsUIMessageHandler::HandleCancelNwake, base::Unretained(this))); - web_ui()->RegisterDeprecatedMessageCallback( + web_ui()->RegisterMessageCallback( "generatePageBundle", base::BindRepeating( &OfflineInternalsUIMessageHandler::HandleGeneratePageBundle, base::Unretained(this))); - web_ui()->RegisterDeprecatedMessageCallback( + web_ui()->RegisterMessageCallback( "getOperation", base::BindRepeating(&OfflineInternalsUIMessageHandler::HandleGetOperation, base::Unretained(this))); - web_ui()->RegisterDeprecatedMessageCallback( + web_ui()->RegisterMessageCallback( "downloadArchive", base::BindRepeating( &OfflineInternalsUIMessageHandler::HandleDownloadArchive,
diff --git a/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.h b/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.h index 22f9820..abd58681 100644 --- a/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.h +++ b/chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.h
@@ -44,66 +44,66 @@ private: // Delete selected list of page ids from the store. - void HandleDeleteSelectedPages(const base::ListValue* args); + void HandleDeleteSelectedPages(const base::Value::List& args); // Delete selected list of requests from the request queue. - void HandleDeleteSelectedRequests(const base::ListValue* args); + void HandleDeleteSelectedRequests(const base::Value::List& args); // Load Request Queue info. - void HandleGetRequestQueue(const base::ListValue* args); + void HandleGetRequestQueue(const base::Value::List& args); // Load Stored pages info. - void HandleGetStoredPages(const base::ListValue* args); + void HandleGetStoredPages(const base::Value::List& args); // Set whether to record offline page model events. - void HandleSetRecordPageModel(const base::ListValue* args); + void HandleSetRecordPageModel(const base::Value::List& args); // Set whether to record request queue events. - void HandleSetRecordRequestQueue(const base::ListValue* args); + void HandleSetRecordRequestQueue(const base::Value::List& args); // Set whether to record prefetch service events. - void HandleSetRecordPrefetchService(const base::ListValue* args); + void HandleSetRecordPrefetchService(const base::Value::List& args); // Set whether to enable limitless prefetching. - void HandleSetLimitlessPrefetchingEnabled(const base::ListValue* args); + void HandleSetLimitlessPrefetchingEnabled(const base::Value::List& args); // Get whether limitless prefetching is enabled. - void HandleGetLimitlessPrefetchingEnabled(const base::ListValue* args); + void HandleGetLimitlessPrefetchingEnabled(const base::Value::List& args); // Set whether to enable sending the testing header when making // GeneratePageBundle requests. - void HandleSetPrefetchTestingHeader(const base::ListValue* args); + void HandleSetPrefetchTestingHeader(const base::Value::List& args); // Get whether we are sending the testing header for GeneratePageBundle // requests. - void HandleGetPrefetchTestingHeader(const base::ListValue* args); + void HandleGetPrefetchTestingHeader(const base::Value::List& args); // Load all offline services' event logs. - void HandleGetEventLogs(const base::ListValue* args); + void HandleGetEventLogs(const base::Value::List& args); // Load whether logs are being recorded. - void HandleGetLoggingState(const base::ListValue* args); + void HandleGetLoggingState(const base::Value::List& args); // Adds a url to the background loader queue. - void HandleAddToRequestQueue(const base::ListValue* args); + void HandleAddToRequestQueue(const base::Value::List& args); // Load whether device is currently offline. - void HandleGetNetworkStatus(const base::ListValue* args); + void HandleGetNetworkStatus(const base::Value::List& args); // Schedules an NWake signal. - void HandleScheduleNwake(const base::ListValue* args); + void HandleScheduleNwake(const base::Value::List& args); // Cancels an NWake signal. - void HandleCancelNwake(const base::ListValue* args); + void HandleCancelNwake(const base::Value::List& args); // Sends and processes the request to generate page bundle. - void HandleGeneratePageBundle(const base::ListValue* args); + void HandleGeneratePageBundle(const base::Value::List& args); // Sends and processes a request to get the info about an operation. - void HandleGetOperation(const base::ListValue* args); + void HandleGetOperation(const base::Value::List& args); // Downloads an archive. - void HandleDownloadArchive(const base::ListValue* args); + void HandleDownloadArchive(const base::Value::List& args); // Callback for async GetAllPages calls. void HandleStoredPagesCallback(
diff --git a/chrome/browser/ui/webui/settings/settings_utils_linux.cc b/chrome/browser/ui/webui/settings/settings_utils_linux.cc index 236c2a7..7c82b9d 100644 --- a/chrome/browser/ui/webui/settings/settings_utils_linux.cc +++ b/chrome/browser/ui/webui/settings/settings_utils_linux.cc
@@ -105,6 +105,7 @@ break; case base::nix::DESKTOP_ENVIRONMENT_GNOME: case base::nix::DESKTOP_ENVIRONMENT_PANTHEON: + case base::nix::DESKTOP_ENVIRONMENT_UKUI: case base::nix::DESKTOP_ENVIRONMENT_UNITY: { launched = StartProxyConfigUtil(kGNOME2ProxyConfigCommand); if (!launched) {
diff --git a/chrome/browser/ui/webui/signin/inline_login_ui.cc b/chrome/browser/ui/webui/signin/inline_login_ui.cc index e1f61031..c129605 100644 --- a/chrome/browser/ui/webui/signin/inline_login_ui.cc +++ b/chrome/browser/ui/webui/signin/inline_login_ui.cc
@@ -121,9 +121,10 @@ {"webview_saml_injected.js", IDR_GAIA_AUTH_WEBVIEW_SAML_INJECTED_JS}, #if BUILDFLAG(IS_CHROMEOS_ASH) {"inline_login_util.js", IDR_INLINE_LOGIN_UTIL_JS}, - {"arc_account_picker_app.js", IDR_INLINE_LOGIN_ARC_ACCOUNT_PICKER_APP_JS}, + {"arc_account_picker_app.js", + IDR_ARC_ACCOUNT_PICKER_ARC_ACCOUNT_PICKER_APP_JS}, {"arc_account_picker_browser_proxy.js", - IDR_INLINE_LOGIN_ARC_ACCOUNT_PICKER_BROWSER_PROXY_JS}, + IDR_ARC_ACCOUNT_PICKER_ARC_ACCOUNT_PICKER_BROWSER_PROXY_JS}, {"welcome_page_app.js", IDR_INLINE_LOGIN_WELCOME_PAGE_APP_JS}, {"signin_blocked_by_policy_page.js", IDR_INLINE_LOGIN_SIGNIN_BLOCKED_BY_POLICY_PAGE_JS},
diff --git a/chrome/browser/usb/usb_browsertest.cc b/chrome/browser/usb/usb_browsertest.cc index a1eccc3..3cb34118 100644 --- a/chrome/browser/usb/usb_browsertest.cc +++ b/chrome/browser/usb/usb_browsertest.cc
@@ -17,12 +17,12 @@ #include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/chooser_bubble_testapi.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" +#include "chrome/browser/ui/web_applications/test/isolated_app_test_utils.h" #include "chrome/browser/usb/usb_chooser_context_factory.h" #include "chrome/browser/usb/usb_chooser_controller.h" #include "chrome/browser/usb/web_usb_chooser.h" #include "chrome/browser/usb/web_usb_histograms.h" #include "chrome/browser/usb/web_usb_service_impl.h" -#include "chrome/browser/web_applications/test/isolated_app_test_utils.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "components/content_settings/core/browser/host_content_settings_map.h"
diff --git a/chrome/browser/web_applications/BUILD.gn b/chrome/browser/web_applications/BUILD.gn index aa94adee..dfb54420 100644 --- a/chrome/browser/web_applications/BUILD.gn +++ b/chrome/browser/web_applications/BUILD.gn
@@ -362,55 +362,16 @@ ] } -# The set of dependencies that //chrome/test:test_support{_ui} have on -# web_applications test support. Split out from the below target as the below -# target itself depends on //chrome/test:test_support{_ui}. -source_set("web_applications_test_support_minimal") { - testonly = true - - sources = [ - "system_web_apps/test/test_system_web_app_manager.cc", - "system_web_apps/test/test_system_web_app_manager.h", - "test/fake_web_app_provider.cc", - "test/fake_web_app_provider.h", - "test/service_worker_registration_waiter.cc", - "test/service_worker_registration_waiter.h", - "test/web_app_install_test_utils.cc", - "test/web_app_install_test_utils.h", - "test/web_app_test_observers.cc", - "test/web_app_test_observers.h", - "test/with_crosapi_param.cc", - "test/with_crosapi_param.h", - ] - deps = [ - "//base", - "//base/test:test_support", - "//build:chromeos_buildflags", - "//chrome/browser/profiles:profile", - "//chrome/browser/web_applications", - "//chrome/common:buildflags", - "//chrome/common:chrome_features", - "//chrome/common:non_code_constants", - "//components/keyed_service/content", - "//components/services/app_service/public/cpp:app_url_handling", - "//components/webapps/browser", - "//content/public/browser", - "//url", - ] - if (is_chromeos_ash) { - deps += [ "//ash/constants" ] - } -} - -# This test_support library doesn't use extensions. +# This test_support library doesn't use extensions. It must not depend on +# //chrome/test:test_support{_ui} as it is depended upon by those targets. source_set("web_applications_test_support") { testonly = true sources = [ - "system_web_apps/test/system_web_app_browsertest_base.cc", - "system_web_apps/test/system_web_app_browsertest_base.h", "system_web_apps/test/test_system_web_app_installation.cc", "system_web_apps/test/test_system_web_app_installation.h", + "system_web_apps/test/test_system_web_app_manager.cc", + "system_web_apps/test/test_system_web_app_manager.h", "system_web_apps/test/test_system_web_app_url_data_source.cc", "system_web_apps/test/test_system_web_app_url_data_source.h", "system_web_apps/test/test_system_web_app_web_ui_controller_factory.cc", @@ -433,16 +394,18 @@ "test/fake_web_app_origin_association_manager.h", "test/fake_web_app_protocol_handler_manager.cc", "test/fake_web_app_protocol_handler_manager.h", + "test/fake_web_app_provider.cc", + "test/fake_web_app_provider.h", "test/fake_web_app_registry_controller.cc", "test/fake_web_app_registry_controller.h", "test/fake_web_app_ui_manager.cc", "test/fake_web_app_ui_manager.h", - "test/isolated_app_test_utils.cc", - "test/isolated_app_test_utils.h", "test/mock_file_utils_wrapper.cc", "test/mock_file_utils_wrapper.h", "test/mock_os_integration_manager.cc", "test/mock_os_integration_manager.h", + "test/service_worker_registration_waiter.cc", + "test/service_worker_registration_waiter.h", "test/test_file_utils.cc", "test/test_file_utils.h", "test/test_web_app_url_loader.cc", @@ -451,17 +414,20 @@ "test/web_app_icon_test_utils.h", "test/web_app_icon_waiter.cc", "test/web_app_icon_waiter.h", + "test/web_app_install_test_utils.cc", + "test/web_app_install_test_utils.h", "test/web_app_registration_waiter.cc", "test/web_app_registration_waiter.h", "test/web_app_sync_test_utils.cc", "test/web_app_sync_test_utils.h", - "test/web_app_test.h", + "test/web_app_test_observers.cc", + "test/web_app_test_observers.h", "test/web_app_test_utils.cc", "test/web_app_test_utils.h", + "test/with_crosapi_param.cc", + "test/with_crosapi_param.h", ] - public_deps = [ ":web_applications_test_support_minimal" ] - deps = [ ":web_app_test_group", ":web_applications", @@ -470,19 +436,22 @@ "//chrome/app/theme:chrome_unscaled_resources_grit", "//chrome/browser", "//chrome/browser/profiles:profile", - "//chrome/browser/ui:ui", - "//chrome/test:test_support", - "//chrome/test:test_support_ui", + "//chrome/browser/ui", "//components/crx_file:crx_file", - "//components/keyed_service/content:content", + "//components/keyed_service/content", "//components/services/app_service/public/cpp:app_url_handling", "//components/services/app_service/public/cpp:types", "//components/sync:test_support_model", + "//components/sync_preferences:test_support", "//components/webapps/browser", "//content/test:test_support", "//testing/gtest", - "//ui/webui:webui", + "//ui/webui", ] + + if (is_chromeos_ash) { + deps += [ "//ash/constants" ] + } } source_set("web_applications_unit_tests") { @@ -506,6 +475,7 @@ "preinstalled_web_app_manager_unittest.cc", "preinstalled_web_app_utils_unittest.cc", "preinstalled_web_apps/preinstalled_web_app_definition_utils_unittest.cc", + "test/web_app_test.h", "web_app_command_manager_unittest.cc", "web_app_constants_unittest.cc", "web_app_data_retriever_unittest.cc", @@ -621,6 +591,33 @@ } } +# Browsertest base classes that depend on //chrome/test:test_support_ui. Must +# be separate from :web_applications_test_support because that is depended upon +# by //chrome/test:test_support_ui. +source_set("browser_tests_base") { + testonly = true + + sources = [ + "system_web_apps/test/system_web_app_browsertest_base.cc", + "system_web_apps/test/system_web_app_browsertest_base.h", + ] + + defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ] + + deps = [ + ":web_applications", + "//chrome/browser", + "//chrome/browser/profiles:profile", + "//chrome/browser/ui", + "//chrome/browser/web_applications:web_applications_test_support", + "//chrome/test:test_support_ui", + "//components/services/app_service/public/cpp:types", + "//content/test:test_support", + "//testing/gtest", + "//url", + ] +} + source_set("web_applications_browser_tests") { testonly = true @@ -656,6 +653,7 @@ defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ] deps = [ + ":browser_tests_base", ":web_applications", ":web_applications_test_support", "adjustments:adjustments_browser_tests", @@ -675,6 +673,7 @@ "//components/services/app_service/public/cpp:icon_types", "//components/services/app_service/public/cpp:intents", "//components/services/app_service/public/cpp:run_on_os_login", + "//components/services/app_service/public/cpp:types", "//components/webapps/browser", "//components/webapps/services/web_app_origin_association/test:test_support", "//extensions/browser:test_support",
diff --git a/chrome/browser/web_applications/adjustments/BUILD.gn b/chrome/browser/web_applications/adjustments/BUILD.gn index eb718680..34abf51d 100644 --- a/chrome/browser/web_applications/adjustments/BUILD.gn +++ b/chrome/browser/web_applications/adjustments/BUILD.gn
@@ -45,7 +45,7 @@ deps = [ ":adjustments", "//chrome/browser/web_applications", - "//chrome/browser/web_applications:web_applications_test_support_minimal", + "//chrome/browser/web_applications:web_applications_test_support", "//chrome/test:test_support", ] }
diff --git a/chrome/browser/web_applications/app_service/web_app_publisher_helper.cc b/chrome/browser/web_applications/app_service/web_app_publisher_helper.cc index 37911fa..2e4a333 100644 --- a/chrome/browser/web_applications/app_service/web_app_publisher_helper.cc +++ b/chrome/browser/web_applications/app_service/web_app_publisher_helper.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/web_applications/app_service/web_app_publisher_helper.h" #include <atomic> +#include <memory> #include <ostream> #include <set> #include <utility> @@ -21,6 +22,7 @@ #include "base/metrics/histogram_base.h" #include "base/metrics/histogram_macros.h" #include "base/notreached.h" +#include "base/strings/utf_string_conversions.h" #include "base/time/time.h" #include "build/build_config.h" #include "build/chromeos_buildflags.h" @@ -564,6 +566,15 @@ const auto login_mode = registrar().GetAppRunOnOsLoginMode(web_app->app_id()); app->run_on_os_login = apps::RunOnOsLogin( ConvertOsLoginMode(login_mode.value), !login_mode.user_controllable); + + for (const auto& shortcut : web_app->shortcuts_menu_item_infos()) { + const std::string name = base::UTF16ToUTF8(shortcut.name); + std::string shortcut_id = GenerateShortcutId(); + StoreShortcutId(shortcut_id, shortcut); + app->shortcuts.push_back( + std::make_unique<apps::Shortcut>(shortcut_id, name)); + } + return app; }
diff --git a/chrome/browser/web_applications/extensions/externally_managed_app_install_task_unittest.cc b/chrome/browser/web_applications/extensions/externally_managed_app_install_task_unittest.cc index a707204..2c85d6c 100644 --- a/chrome/browser/web_applications/extensions/externally_managed_app_install_task_unittest.cc +++ b/chrome/browser/web_applications/extensions/externally_managed_app_install_task_unittest.cc
@@ -39,6 +39,7 @@ #include "chrome/browser/web_applications/web_app_install_manager.h" #include "chrome/browser/web_applications/web_app_provider.h" #include "chrome/browser/web_applications/web_app_registrar.h" +#include "chrome/browser/web_applications/web_app_sync_bridge.h" #include "chrome/common/chrome_features.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h"
diff --git a/chrome/browser/web_applications/extensions/web_app_provider_unittest.cc b/chrome/browser/web_applications/extensions/web_app_provider_unittest.cc index 1d1a641e..39dfb50 100644 --- a/chrome/browser/web_applications/extensions/web_app_provider_unittest.cc +++ b/chrome/browser/web_applications/extensions/web_app_provider_unittest.cc
@@ -6,14 +6,14 @@ #include "base/memory/raw_ptr.h" #include "build/chromeos_buildflags.h" -#include "chrome/browser/web_applications/test/web_app_test.h" #include "chrome/browser/web_applications/web_app_registrar.h" #include "chrome/browser/web_applications/web_app_utils.h" +#include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" namespace web_app { -class WebAppProviderUnitTest : public WebAppTest { +class WebAppProviderUnitTest : public ChromeRenderViewHostTestHarness { public: WebAppProviderUnitTest() = default; WebAppProviderUnitTest(const WebAppProviderUnitTest&) = delete; @@ -21,7 +21,7 @@ ~WebAppProviderUnitTest() override = default; void SetUp() override { - WebAppTest::SetUp(); + ChromeRenderViewHostTestHarness::SetUp(); #if BUILDFLAG(IS_CHROMEOS_LACROS) SkipMainProfileCheckForTesting();
diff --git a/chrome/browser/web_applications/isolated_app_browsertest.cc b/chrome/browser/web_applications/isolated_app_browsertest.cc index 46520c54..2dd99ce 100644 --- a/chrome/browser/web_applications/isolated_app_browsertest.cc +++ b/chrome/browser/web_applications/isolated_app_browsertest.cc
@@ -19,10 +19,10 @@ #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/toolbar/app_menu_model.h" #include "chrome/browser/ui/web_applications/app_browser_controller.h" +#include "chrome/browser/ui/web_applications/test/isolated_app_test_utils.h" #include "chrome/browser/ui/web_applications/test/web_app_browsertest_util.h" #include "chrome/browser/ui/web_applications/web_app_controller_browsertest.h" #include "chrome/browser/ui/web_applications/web_app_menu_model.h" -#include "chrome/browser/web_applications/test/isolated_app_test_utils.h" #include "chrome/browser/web_applications/test/service_worker_registration_waiter.h" #include "chrome/browser/web_applications/test/web_app_test_utils.h" #include "chrome/browser/web_applications/web_app_helpers.h"
diff --git a/chrome/browser/web_applications/manifest_update_manager_browsertest.cc b/chrome/browser/web_applications/manifest_update_manager_browsertest.cc index 76fa8f3..7bb244f8 100644 --- a/chrome/browser/web_applications/manifest_update_manager_browsertest.cc +++ b/chrome/browser/web_applications/manifest_update_manager_browsertest.cc
@@ -36,7 +36,6 @@ #include "chrome/browser/web_applications/test/web_app_icon_test_utils.h" #include "chrome/browser/web_applications/test/web_app_install_test_utils.h" #include "chrome/browser/web_applications/test/web_app_sync_test_utils.h" -#include "chrome/browser/web_applications/test/web_app_test.h" #include "chrome/browser/web_applications/test/web_app_test_observers.h" #include "chrome/browser/web_applications/test/web_app_test_utils.h" #include "chrome/browser/web_applications/web_app.h" @@ -48,6 +47,7 @@ #include "chrome/browser/web_applications/web_app_provider.h" #include "chrome/browser/web_applications/web_app_registrar.h" #include "chrome/browser/web_applications/web_app_registry_update.h" +#include "chrome/browser/web_applications/web_app_sync_bridge.h" #include "chrome/browser/web_applications/web_app_utils.h" #include "chrome/common/chrome_features.h" #include "chrome/test/base/in_process_browser_test.h"
diff --git a/chrome/browser/web_applications/test/fake_web_app_provider.cc b/chrome/browser/web_applications/test/fake_web_app_provider.cc index 5dd1a96..680270c4 100644 --- a/chrome/browser/web_applications/test/fake_web_app_provider.cc +++ b/chrome/browser/web_applications/test/fake_web_app_provider.cc
@@ -4,23 +4,41 @@ #include "chrome/browser/web_applications/test/fake_web_app_provider.h" +#include <memory> +#include <ostream> #include <utility> #include "base/bind.h" +#include "base/check.h" +#include "base/command_line.h" +#include "base/memory/scoped_refptr.h" +#include "base/one_shot_event.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/web_applications/externally_managed_app_manager.h" #include "chrome/browser/web_applications/os_integration/os_integration_manager.h" #include "chrome/browser/web_applications/policy/web_app_policy_manager.h" #include "chrome/browser/web_applications/system_web_apps/system_web_app_manager.h" #include "chrome/browser/web_applications/system_web_apps/test/test_system_web_app_manager.h" +#include "chrome/browser/web_applications/test/fake_externally_managed_app_manager.h" +#include "chrome/browser/web_applications/test/fake_os_integration_manager.h" +#include "chrome/browser/web_applications/test/fake_web_app_database_factory.h" +#include "chrome/browser/web_applications/test/fake_web_app_ui_manager.h" +#include "chrome/browser/web_applications/test/test_file_utils.h" #include "chrome/browser/web_applications/web_app_database_factory.h" #include "chrome/browser/web_applications/web_app_icon_manager.h" #include "chrome/browser/web_applications/web_app_install_finalizer.h" #include "chrome/browser/web_applications/web_app_install_manager.h" #include "chrome/browser/web_applications/web_app_provider_factory.h" #include "chrome/browser/web_applications/web_app_registrar.h" +#include "chrome/browser/web_applications/web_app_sync_bridge.h" +#include "chrome/browser/web_applications/web_app_translation_manager.h" #include "chrome/browser/web_applications/web_app_ui_manager.h" #include "chrome/browser/web_applications/web_app_utils.h" +#include "chrome/common/chrome_switches.h" +#include "components/keyed_service/content/browser_context_dependency_manager.h" +#include "components/keyed_service/core/keyed_service.h" +#include "components/sync/test/model/mock_model_type_change_processor.h" +#include "testing/gmock/include/gmock/gmock.h" namespace web_app { @@ -33,7 +51,7 @@ // Do not call default production StartImpl if in TestingProfile. provider->SetRunSubsystemStartupTasks(false); - // TODO(crbug.com/973324): Replace core subsystems with fakes by default. + // TODO(crbug.com/973324): `SetDefaultFakeSubsystems` by default. provider->ConnectSubsystems(); return provider; @@ -69,12 +87,36 @@ registrar_ = std::move(registrar); } +void FakeWebAppProvider::SetDatabaseFactory( + std::unique_ptr<AbstractWebAppDatabaseFactory> database_factory) { + CheckNotStarted(); + database_factory_ = std::move(database_factory_); +} + void FakeWebAppProvider::SetSyncBridge( std::unique_ptr<WebAppSyncBridge> sync_bridge) { CheckNotStarted(); sync_bridge_ = std::move(sync_bridge); } +void FakeWebAppProvider::SetIconManager( + std::unique_ptr<WebAppIconManager> icon_manager) { + CheckNotStarted(); + icon_manager_ = std::move(icon_manager); +} + +void FakeWebAppProvider::SetTranslationManager( + std::unique_ptr<WebAppTranslationManager> translation_manager) { + CheckNotStarted(); + translation_manager_ = std::move(translation_manager); +} + +void FakeWebAppProvider::SetOsIntegrationManager( + std::unique_ptr<OsIntegrationManager> os_integration_manager) { + CheckNotStarted(); + os_integration_manager_ = std::move(os_integration_manager); +} + void FakeWebAppProvider::SetInstallManager( std::unique_ptr<WebAppInstallManager> install_manager) { CheckNotStarted(); @@ -112,27 +154,6 @@ web_app_policy_manager_ = std::move(web_app_policy_manager); } -void FakeWebAppProvider::SetOsIntegrationManager( - std::unique_ptr<OsIntegrationManager> os_integration_manager) { - CheckNotStarted(); - os_integration_manager_ = std::move(os_integration_manager); -} - -void FakeWebAppProvider::SkipAwaitingExtensionSystem() { - CheckNotStarted(); - skip_awaiting_extension_system_ = true; -} - -void FakeWebAppProvider::StartWithSubsystems() { - CheckNotStarted(); - SetRunSubsystemStartupTasks(true); - // Use a TestSystemWebAppManager to skip system web apps being - // auto-installed on |Start|. - SetSystemWebAppManager( - std::make_unique<web_app::TestSystemWebAppManager>(profile_.get())); - Start(); -} - WebAppRegistrarMutable& FakeWebAppProvider::GetRegistrarMutable() const { DCHECK(registrar_); return *static_cast<WebAppRegistrarMutable*>(registrar_.get()); @@ -148,6 +169,67 @@ return *database_factory_; } +void FakeWebAppProvider::SkipAwaitingExtensionSystem() { + CheckNotStarted(); + skip_awaiting_extension_system_ = true; +} + +void FakeWebAppProvider::StartWithSubsystems() { + CheckNotStarted(); + SetRunSubsystemStartupTasks(true); + // Use a TestSystemWebAppManager to skip system web apps being + // auto-installed on |Start|. + // TODO(crbug.com/973324): This is set in `SetDefaultFakeSubsystems`. Remove + // it from here. + SetSystemWebAppManager( + std::make_unique<web_app::TestSystemWebAppManager>(profile_)); + Start(); +} + +void FakeWebAppProvider::SetDefaultFakeSubsystems() { + // Disable preinstalled apps by default as they add noise and time to tests + // that don't need them. + base::CommandLine::ForCurrentProcess()->AppendSwitch( + switches::kDisablePreinstalledApps); + + // Default to not wait for a test extension system, that is usually never + // started in web app tests. + SkipAwaitingExtensionSystem(); + + SetRegistrar(std::make_unique<WebAppRegistrarMutable>(profile_)); + SetDatabaseFactory(std::make_unique<FakeWebAppDatabaseFactory>()); + + SetOsIntegrationManager(std::make_unique<FakeOsIntegrationManager>( + profile_, /*app_shortcut_manager=*/nullptr, + /*file_handler_manager=*/nullptr, + /*protocol_handler_manager=*/nullptr, + /*url_handler_manager=*/nullptr)); + + SetSyncBridge(std::make_unique<WebAppSyncBridge>( + &GetRegistrarMutable(), processor().CreateForwardingProcessor())); + + SetIconManager(std::make_unique<WebAppIconManager>( + profile_, base::MakeRefCounted<TestFileUtils>())); + + SetTranslationManager(std::make_unique<WebAppTranslationManager>( + profile_, base::MakeRefCounted<TestFileUtils>())); + + SetWebAppUiManager(std::make_unique<FakeWebAppUiManager>()); + + SetExternallyManagedAppManager( + std::make_unique<FakeExternallyManagedAppManager>(profile_)); + + SetWebAppPolicyManager(std::make_unique<WebAppPolicyManager>(profile_)); + + // Use a TestSystemWebAppManager to skip system web apps being + // auto-installed on |Start|. + SetSystemWebAppManager( + std::make_unique<web_app::TestSystemWebAppManager>(profile_)); + + ON_CALL(processor(), IsTrackingMetadata()) + .WillByDefault(testing::Return(true)); +} + void FakeWebAppProvider::CheckNotStarted() const { CHECK(!started_) << "Attempted to set a WebAppProvider subsystem after " "Start() was called.";
diff --git a/chrome/browser/web_applications/test/fake_web_app_provider.h b/chrome/browser/web_applications/test/fake_web_app_provider.h index 32f91bee..470848a 100644 --- a/chrome/browser/web_applications/test/fake_web_app_provider.h +++ b/chrome/browser/web_applications/test/fake_web_app_provider.h
@@ -8,11 +8,13 @@ #include <memory> #include "base/callback.h" +#include "base/callback_forward.h" +#include "base/callback_list.h" #include "chrome/browser/web_applications/web_app_provider.h" -#include "chrome/browser/web_applications/web_app_registrar.h" -#include "chrome/browser/web_applications/web_app_sync_bridge.h" -#include "components/keyed_service/content/browser_context_dependency_manager.h" +#include "components/sync/test/model/mock_model_type_change_processor.h" +#include "testing/gmock/include/gmock/gmock.h" +class KeyedService; class Profile; namespace content { @@ -30,6 +32,10 @@ class WebAppInstallManager; class WebAppPolicyManager; class WebAppIconManager; +class WebAppTranslationManager; +class WebAppRegistrarMutable; +class WebAppSyncBridge; +class WebAppUiManager; class FakeWebAppProvider : public WebAppProvider { public: @@ -58,7 +64,12 @@ // NB: If you replace the Registrar, you also have to replace the SyncBridge // accordingly. void SetRegistrar(std::unique_ptr<WebAppRegistrar> registrar); + void SetDatabaseFactory( + std::unique_ptr<AbstractWebAppDatabaseFactory> database_factory); void SetSyncBridge(std::unique_ptr<WebAppSyncBridge> sync_bridge); + void SetIconManager(std::unique_ptr<WebAppIconManager> icon_manager); + void SetTranslationManager( + std::unique_ptr<WebAppTranslationManager> translation_manager); void SetOsIntegrationManager( std::unique_ptr<OsIntegrationManager> os_integration_manager); void SetInstallManager(std::unique_ptr<WebAppInstallManager> install_manager); @@ -72,10 +83,6 @@ std::unique_ptr<SystemWebAppManager> system_web_app_manager); void SetWebAppPolicyManager( std::unique_ptr<WebAppPolicyManager> web_app_policy_manager); - void SkipAwaitingExtensionSystem(); - // Starts this WebAppProvider and its subsystems. It does not wait for systems - // to be ready. - void StartWithSubsystems(); // These getters can be called at any time: no // WebAppProvider::CheckIsConnected() check performed. See @@ -86,6 +93,16 @@ WebAppIconManager& GetIconManager() const; AbstractWebAppDatabaseFactory& GetDatabaseFactory() const; + void SkipAwaitingExtensionSystem(); + // Starts this WebAppProvider and its subsystems. It does not wait for systems + // to be ready. + void StartWithSubsystems(); + + // Create and set default fake subsystems. + void SetDefaultFakeSubsystems(); + + syncer::MockModelTypeChangeProcessor& processor() { return mock_processor_; } + private: void CheckNotStarted() const; @@ -96,6 +113,7 @@ // WebAppProvider::StartImpl() and fire startup tasks like a real // WebAppProvider. bool run_subsystem_startup_tasks_ = true; + testing::NiceMock<syncer::MockModelTypeChangeProcessor> mock_processor_; }; // Used in BrowserTests to ensure that the WebAppProvider that is create on
diff --git a/chrome/browser/web_applications/test/fake_web_app_registry_controller.h b/chrome/browser/web_applications/test/fake_web_app_registry_controller.h index b6aed80a..05cb1049 100644 --- a/chrome/browser/web_applications/test/fake_web_app_registry_controller.h +++ b/chrome/browser/web_applications/test/fake_web_app_registry_controller.h
@@ -29,6 +29,7 @@ class WebApp; class WebAppPolicyManager; +// Deprecated: Prefer to use `FakeWebAppProvider::SetDefaultFakeSubsystems()`. class FakeWebAppRegistryController : public SyncInstallDelegate { public: FakeWebAppRegistryController();
diff --git a/chrome/browser/web_applications/web_app_install_finalizer_unittest.cc b/chrome/browser/web_applications/web_app_install_finalizer_unittest.cc index 81a3a56..c3f1fd7 100644 --- a/chrome/browser/web_applications/web_app_install_finalizer_unittest.cc +++ b/chrome/browser/web_applications/web_app_install_finalizer_unittest.cc
@@ -4,29 +4,39 @@ #include "chrome/browser/web_applications/web_app_install_finalizer.h" +#include <initializer_list> #include <memory> +#include <utility> -#include "base/command_line.h" -#include "base/memory/scoped_refptr.h" +#include "base/feature_list.h" #include "base/run_loop.h" -#include "base/strings/utf_string_conversions.h" +#include "base/scoped_observation.h" +#include "base/strings/string_piece_forward.h" #include "base/test/bind.h" -#include "chrome/browser/web_applications/file_utils_wrapper.h" -#include "chrome/browser/web_applications/policy/web_app_policy_manager.h" -#include "chrome/browser/web_applications/test/fake_web_app_registry_controller.h" -#include "chrome/browser/web_applications/test/fake_web_app_ui_manager.h" +#include "base/test/scoped_feature_list.h" +#include "base/traits_bag.h" +#include "build/build_config.h" +#include "build/buildflag.h" +#include "chrome/browser/web_applications/test/fake_os_integration_manager.h" +#include "chrome/browser/web_applications/test/fake_web_app_provider.h" +#include "chrome/browser/web_applications/test/web_app_install_test_utils.h" #include "chrome/browser/web_applications/test/web_app_test.h" #include "chrome/browser/web_applications/web_app_helpers.h" -#include "chrome/browser/web_applications/web_app_icon_manager.h" #include "chrome/browser/web_applications/web_app_install_info.h" #include "chrome/browser/web_applications/web_app_install_manager.h" #include "chrome/browser/web_applications/web_app_install_manager_observer.h" -#include "chrome/browser/web_applications/web_app_prefs_utils.h" -#include "chrome/browser/web_applications/web_app_sync_bridge.h" +#include "chrome/browser/web_applications/web_app_install_utils.h" +#include "chrome/browser/web_applications/web_app_provider.h" +#include "chrome/browser/web_applications/web_app_registrar.h" +#include "chrome/test/base/testing_profile.h" +#include "components/services/app_service/public/cpp/file_handler.h" #include "components/webapps/browser/install_result_code.h" +#include "mojo/public/cpp/bindings/struct_ptr.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/common/features.h" +#include "third_party/blink/public/mojom/manifest/manifest.mojom-forward.h" +#include "third_party/blink/public/mojom/manifest/manifest.mojom.h" #include "url/gurl.h" namespace web_app { @@ -78,37 +88,20 @@ void SetUp() override { WebAppTest::SetUp(); - fake_registry_controller_ = - std::make_unique<FakeWebAppRegistryController>(); - install_manager_ = std::make_unique<WebAppInstallManager>(profile()); + FakeWebAppProvider* provider = FakeWebAppProvider::Get(profile()); + provider->SetDefaultFakeSubsystems(); + auto install_manager = std::make_unique<WebAppInstallManager>(profile()); install_manager_observer_ = - std::make_unique<TestInstallManagerObserver>(install_manager_.get()); - fake_registry_controller_->SetUp(profile()); - icon_manager_ = std::make_unique<WebAppIconManager>( - profile(), base::MakeRefCounted<FileUtilsWrapper>()); - policy_manager_ = std::make_unique<WebAppPolicyManager>(profile()); - ui_manager_ = std::make_unique<FakeWebAppUiManager>(); - finalizer_ = std::make_unique<WebAppInstallFinalizer>(profile()); + std::make_unique<TestInstallManagerObserver>(install_manager.get()); + provider->SetInstallManager(std::move(install_manager)); + provider->SetInstallFinalizer( + std::make_unique<WebAppInstallFinalizer>(profile())); - icon_manager_->SetSubsystems(®istrar(), &install_manager()); - finalizer_->SetSubsystems( - &install_manager(), ®istrar(), ui_manager_.get(), - &fake_registry_controller_->sync_bridge(), - &fake_registry_controller_->os_integration_manager(), - icon_manager_.get(), policy_manager_.get(), - &fake_registry_controller_->translation_manager()); - fake_registry_controller_->Init(); - finalizer_->Start(); + test::AwaitStartWebAppProviderAndSubsystems(profile()); } void TearDown() override { install_manager_observer_.reset(); - finalizer_.reset(); - ui_manager_.reset(); - policy_manager_.reset(); - icon_manager_.reset(); - fake_registry_controller_.reset(); - install_manager_.reset(); WebAppTest::TearDown(); } @@ -141,25 +134,21 @@ file_handlers->push_back(std::move(file_handler)); } - WebAppInstallFinalizer& finalizer() { return *finalizer_; } - WebAppRegistrar& registrar() { - return fake_registry_controller_->registrar(); + WebAppProvider& provider() { return *WebAppProvider::GetForTest(profile()); } + WebAppInstallFinalizer& finalizer() { return provider().install_finalizer(); } + WebAppRegistrar& registrar() { return provider().registrar(); } + WebAppInstallManager& install_manager() { + return provider().install_manager(); } - WebAppInstallManager& install_manager() const { return *install_manager_; } protected: FakeOsIntegrationManager& os_integration_manager() { - return fake_registry_controller_->os_integration_manager(); + return static_cast<FakeOsIntegrationManager&>( + provider().os_integration_manager()); } - std::unique_ptr<WebAppInstallFinalizer> finalizer_; std::unique_ptr<TestInstallManagerObserver> install_manager_observer_; private: - std::unique_ptr<WebAppInstallManager> install_manager_; - std::unique_ptr<FakeWebAppRegistryController> fake_registry_controller_; - std::unique_ptr<WebAppIconManager> icon_manager_; - std::unique_ptr<WebAppPolicyManager> policy_manager_; - std::unique_ptr<WebAppUiManager> ui_manager_; base::test::ScopedFeatureList scoped_feature_list_; }; @@ -259,7 +248,7 @@ FinalizeInstallResult result = AwaitFinalizeInstall(*info, options); base::RunLoop runloop; - finalizer_->FinalizeUpdate( + finalizer().FinalizeUpdate( *info, base::BindLambdaForTesting( [&](const web_app::AppId& app_id, webapps::InstallResultCode code, @@ -394,7 +383,7 @@ CreateFileHandlersFromManifest(file_handlers, info->start_url); base::RunLoop runloop; - finalizer_->FinalizeUpdate( + finalizer().FinalizeUpdate( *info, base::BindLambdaForTesting([&](const web_app::AppId& app_id, webapps::InstallResultCode code,
diff --git a/chrome/browser/web_applications/web_app_provider.h b/chrome/browser/web_applications/web_app_provider.h index 8920253..c21362c 100644 --- a/chrome/browser/web_applications/web_app_provider.h +++ b/chrome/browser/web_applications/web_app_provider.h
@@ -28,7 +28,7 @@ namespace web_app { -class WebAppDatabaseFactory; +class AbstractWebAppDatabaseFactory; class WebAppSyncBridge; class WebAppIconManager; class PreinstalledWebAppManager; @@ -172,7 +172,7 @@ void DoMigrateProfilePrefs(Profile* profile); - std::unique_ptr<WebAppDatabaseFactory> database_factory_; + std::unique_ptr<AbstractWebAppDatabaseFactory> database_factory_; std::unique_ptr<WebAppRegistrar> registrar_; std::unique_ptr<WebAppSyncBridge> sync_bridge_; std::unique_ptr<PreinstalledWebAppManager> preinstalled_web_app_manager_;
diff --git a/chrome/browser/web_applications/web_app_translation_manager_unittest.cc b/chrome/browser/web_applications/web_app_translation_manager_unittest.cc index 5c20480..f014b9fb 100644 --- a/chrome/browser/web_applications/web_app_translation_manager_unittest.cc +++ b/chrome/browser/web_applications/web_app_translation_manager_unittest.cc
@@ -4,16 +4,25 @@ #include "chrome/browser/web_applications/web_app_translation_manager.h" +#include <initializer_list> +#include <memory> +#include <utility> + #include "base/run_loop.h" #include "base/test/bind.h" +#include "base/test/scoped_feature_list.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/web_applications/test/fake_web_app_provider.h" -#include "chrome/browser/web_applications/test/fake_web_app_registry_controller.h" -#include "chrome/browser/web_applications/test/test_file_utils.h" #include "chrome/browser/web_applications/test/web_app_install_test_utils.h" #include "chrome/browser/web_applications/test/web_app_test.h" -#include "chrome/browser/web_applications/test/web_app_test_utils.h" +#include "chrome/browser/web_applications/web_app_install_info.h" +#include "chrome/browser/web_applications/web_app_provider.h" +#include "chrome/browser/web_applications/web_app_registrar.h" +#include "chrome/test/base/testing_profile.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/common/features.h" +#include "url/gurl.h" namespace web_app { @@ -21,14 +30,9 @@ void SetUp() override { WebAppTest::SetUp(); - fake_registry_controller_ = - std::make_unique<FakeWebAppRegistryController>(); - fake_registry_controller_->SetUp(profile()); - - file_utils_ = base::MakeRefCounted<TestFileUtils>(); - - controller().Init(); - InitWebAppProvider(); + FakeWebAppProvider* provider = FakeWebAppProvider::Get(profile()); + provider->SetDefaultFakeSubsystems(); + test::AwaitStartWebAppProviderAndSubsystems(profile()); } protected: @@ -67,52 +71,27 @@ return result; } - void InitWebAppProvider() { - provider_ = web_app::FakeWebAppProvider::Get(profile()); - provider_->SetOsIntegrationManager( - std::make_unique<FakeOsIntegrationManager>(profile(), nullptr, nullptr, - nullptr, nullptr)); - // FakeWebAppProvider should not wait for a test extension system, that is - // never started, to be ready. - provider_->SkipAwaitingExtensionSystem(); - web_app::test::AwaitStartWebAppProviderAndSubsystems(profile()); - } - - FakeWebAppRegistryController& controller() { - return *fake_registry_controller_; - } - - WebAppInstallManager& install_manager() { return *install_manager_; } - - FakeWebAppProvider& provider() { return *provider_; } - WebAppRegistrar& registrar() { return controller().registrar(); } + WebAppProvider& provider() { return *WebAppProvider::GetForTest(profile()); } + WebAppRegistrar& registrar() { return provider().registrar(); } WebAppTranslationManager& translation_manager() { - return controller().translation_manager(); - } - TestFileUtils& file_utils() { - DCHECK(file_utils_); - return *file_utils_; + return provider().translation_manager(); } private: - std::unique_ptr<FakeWebAppRegistryController> fake_registry_controller_; - std::unique_ptr<WebAppInstallManager> install_manager_; - scoped_refptr<TestFileUtils> file_utils_; - web_app::FakeWebAppProvider* provider_; base::test::ScopedFeatureList features_{ blink::features::kWebAppEnableTranslations}; }; TEST_F(WebAppTranslationManagerTest, WriteReadAndDelete) { - auto web_app1 = test::CreateWebApp(GURL("https://example.com/path")); - const AppId app_id1 = web_app1->app_id(); - web_app1->SetName("App1 name"); - controller().RegisterApp(std::move(web_app1)); + auto app_info1 = std::make_unique<WebAppInstallInfo>(); + app_info1->start_url = GURL("https://example.com/path"); + app_info1->title = u"App1 name"; + const AppId app_id1 = test::InstallWebApp(profile(), std::move(app_info1)); - auto web_app2 = test::CreateWebApp(GURL("https://example.com/path2")); - const AppId app_id2 = web_app2->app_id(); - web_app2->SetName("App2 name"); - controller().RegisterApp(std::move(web_app2)); + auto app_info2 = std::make_unique<WebAppInstallInfo>(); + app_info2->start_url = GURL("https://example.com/path2"); + app_info2->title = u"App2 name"; + const AppId app_id2 = test::InstallWebApp(profile(), std::move(app_info2)); g_browser_process->SetApplicationLocale("en"); @@ -190,9 +169,10 @@ } TEST_F(WebAppTranslationManagerTest, UpdateTranslations) { - auto web_app1 = test::CreateWebApp(GURL("https://example.com/path")); - const AppId app_id1 = web_app1->app_id(); - controller().RegisterApp(std::move(web_app1)); + auto app_info1 = std::make_unique<WebAppInstallInfo>(); + app_info1->start_url = GURL("https://example.com/path"); + app_info1->title = u"App1 name"; + const AppId app_id1 = test::InstallWebApp(profile(), std::move(app_info1)); g_browser_process->SetApplicationLocale("en");
diff --git a/chrome/build/linux.pgo.txt b/chrome/build/linux.pgo.txt index 57337ab..b7345b1 100644 --- a/chrome/build/linux.pgo.txt +++ b/chrome/build/linux.pgo.txt
@@ -1 +1 @@ -chrome-linux-main-1648058190-adf01fc78c756eddecbc3a7e86520f0ba46c8b60.profdata +chrome-linux-main-1648123130-de2ce5f37901865e245fbd32b9b3173c7722846d.profdata
diff --git a/chrome/build/mac-arm.pgo.txt b/chrome/build/mac-arm.pgo.txt index 5c291f8..a02ace1 100644 --- a/chrome/build/mac-arm.pgo.txt +++ b/chrome/build/mac-arm.pgo.txt
@@ -1 +1 @@ -chrome-mac-arm-main-1648058190-86efac576a6fd190f95c57b8d4d763e90b19e990.profdata +chrome-mac-arm-main-1648101516-bc2317f720d4f6bccd657046c16031de9f227eed.profdata
diff --git a/chrome/build/mac.pgo.txt b/chrome/build/mac.pgo.txt index 93767302..b683247 100644 --- a/chrome/build/mac.pgo.txt +++ b/chrome/build/mac.pgo.txt
@@ -1 +1 @@ -chrome-mac-main-1648058190-9f024efd93e000e5805b35b0e28b3f06e423369d.profdata +chrome-mac-main-1648101516-0caaa45b27e76da5d8fd06281678e2b95a831bba.profdata
diff --git a/chrome/build/win32.pgo.txt b/chrome/build/win32.pgo.txt index c45de60..3d1df00 100644 --- a/chrome/build/win32.pgo.txt +++ b/chrome/build/win32.pgo.txt
@@ -1 +1 @@ -chrome-win32-main-1648058190-36e77ae44ee326b6b95f3f2e6cb58c2f2c0ba079.profdata +chrome-win32-main-1648112170-84b09836b43546716f6b238c314494da909382eb.profdata
diff --git a/chrome/build/win64.pgo.txt b/chrome/build/win64.pgo.txt index 5a5b4cad..22327899 100644 --- a/chrome/build/win64.pgo.txt +++ b/chrome/build/win64.pgo.txt
@@ -1 +1 @@ -chrome-win64-main-1648058190-1cca018ea40a54ab31045ba4dfaad8db1c91f989.profdata +chrome-win64-main-1648112170-eda8c2c71af0eaa92359138ce4462d4be0ccddd1.profdata
diff --git a/chrome/common/extensions/api/_features.md b/chrome/common/extensions/api/_features.md index 9f81ca0..c1b2398b 100644 --- a/chrome/common/extensions/api/_features.md +++ b/chrome/common/extensions/api/_features.md
@@ -314,8 +314,8 @@ The `platforms` property specifies the properties the feature should be available on. -The accepted values are lists of strings from `chromeos`, `mac`, `lacros`, -`linux`, and `win`. +The accepted values are lists of strings from `chromeos`, `fuchsia`, `lacros`, +`linux`, `mac`, and `win`. ### session\_types
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 40399896..fbf12a86 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc
@@ -1930,8 +1930,13 @@ const char kNtpModulesOrder[] = "NewTabPage.ModulesOrder"; // Whether NTP modules are visible. const char kNtpModulesVisible[] = "NewTabPage.ModulesVisible"; +// Time Modular NTP Desktop v1 First Run Experience was first shown to user. +const char kNtpModulesFreFirstShownTime[] = + "NewTabPage.ModulesFreFirstShownTime"; // Whether Modular NTP Desktop v1 First Run Experience is visible. const char kNtpModulesFreVisible[] = "NewTabPage.ModulesFreVisible"; +// Number of times Modular NTP Desktop v1 First Run Experience has been visible. +const char kNtpModulesFreShownCount[] = "NewTabPage.ModulesFreShownCount"; // List of promos that the user has dismissed while on the NTP. const char kNtpPromoBlocklist[] = "ntp.promo_blocklist"; // Whether the promo is visible.
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 35b32149..65b2f78 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h
@@ -645,7 +645,9 @@ extern const char kNtpDisabledModules[]; extern const char kNtpModulesOrder[]; extern const char kNtpModulesVisible[]; +extern const char kNtpModulesFreFirstShownTime[]; extern const char kNtpModulesFreVisible[]; +extern const char kNtpModulesFreShownCount[]; extern const char kNtpPromoBlocklist[]; extern const char kNtpPromoVisible[]; extern const char kNtpSearchSuggestionsBlocklist[];
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index 3a3318c..3d7606b 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn
@@ -635,6 +635,8 @@ "../browser/extensions/test_extension_prefs.h", "../browser/policy/extension_force_install_mixin.cc", "../browser/policy/extension_force_install_mixin.h", + "../browser/ui/web_applications/test/isolated_app_test_utils.cc", + "../browser/ui/web_applications/test/isolated_app_test_utils.h", "../browser/ui/web_applications/test/ssl_test_utils.cc", "../browser/ui/web_applications/test/ssl_test_utils.h", "../browser/ui/web_applications/test/test_server_redirect_handle.cc", @@ -656,7 +658,7 @@ deps += [ "//build:chromeos_buildflags", - "//chrome/browser/web_applications:web_applications_test_support_minimal", + "//chrome/browser/web_applications:web_applications_test_support", "//components/webapps/browser", "//third_party/zlib/google:zip", ] @@ -1178,6 +1180,7 @@ "//chrome/browser/ui/tabs:tab_enums", "//chrome/browser/ui/webui/history_clusters:mojo_bindings", "//chrome/browser/web_applications:browser_tests", + "//chrome/browser/web_applications:browser_tests_base", "//chrome/browser/web_applications:web_applications_test_support", "//chrome/browser/web_applications/extensions", "//chrome/browser/web_share_target:browser_tests", @@ -2121,6 +2124,7 @@ "../browser/ui/views/toolbar/app_menu_browsertest.cc", "../browser/ui/views/toolbar/avatar_toolbar_button_browsertest.cc", "../browser/ui/views/toolbar/chrome_labs_browsertest.cc", + "../browser/ui/views/web_apps/file_handler_launch_dialog_browsertest.cc", "../browser/ui/views/web_apps/frame_toolbar/web_app_frame_toolbar_browsertest.cc", "../browser/ui/views/web_apps/frame_toolbar/web_app_minimal_ui_test.cc", "../browser/ui/views/web_apps/web_app_protocol_handler_intent_picker_dialog_browsertest.cc", @@ -2666,9 +2670,8 @@ "//third_party/liblouis/wasm/liblouis_wrapper_browsertest.cc", ] deps += [ "//chrome/browser/chromeos" ] - data_deps += [ - "//third_party/liblouis:liblouis_test_data", - ] + data_deps += [ "//third_party/liblouis:liblouis_test_data" ] + # TODO(https://crbug.com/1299021): Implement building these NaCl # targets as ARM32 when Chrome is built for ARM64 (for Linux/Chrome # OS). @@ -2689,6 +2692,7 @@ # browser process as needed by this test. See http://crbug.com/157312. sources -= [ "../browser/nacl_host/test/gdb_debug_stub_browsertest.cc" ] } + # TODO(https://crbug.com/1299021): Implement building this NaCl target # as ARM32 when Chrome is built for ARM64 (for Linux/Chrome OS). if ((is_linux || is_chromeos) && target_cpu != "arm64") { @@ -2948,7 +2952,6 @@ sources += [ "../browser/enterprise/connectors/device_trust/device_trust_browsertest.cc", "../browser/extensions/api/system_indicator/system_indicator_apitest.cc", - "../browser/ui/views/web_apps/file_handler_launch_dialog_browsertest.cc", ] deps += [ @@ -6633,7 +6636,6 @@ "//chrome/browser/ui/color:mixers", "//chrome/browser/ui/webui/discards:mojo_bindings", "//chrome/browser/web_applications:web_applications_test_support", - "//chrome/browser/web_applications:web_applications_test_support_minimal", "//components/chrome_cleaner/test:test_name_helper", "//components/commerce/core:commerce_heuristics_data", "//components/enterprise", @@ -6814,6 +6816,14 @@ } } + if (is_chromeos_lacros) { + sources += [ + "../browser/apps/app_service/app_service_proxy_lacros_unittest.cc", + "../browser/apps/app_service/mock_crosapi_app_service_proxy.cc", + "../browser/apps/app_service/mock_crosapi_app_service_proxy.h", + ] + } + if (enable_system_notifications) { # TODO(crbug.com/1052397): Rename is_chromeos_lacros to is_chromeos_lacros. if ((is_linux || is_chromeos_lacros) && !is_chromeos_lacros) { @@ -7011,6 +7021,8 @@ "../browser/ui/app_list/search/files/justifications_unittest.cc", "../browser/ui/app_list/search/files/zero_state_drive_provider_unittest.cc", "../browser/ui/app_list/search/files/zero_state_file_provider_unittest.cc", + "../browser/ui/app_list/search/games/game_provider_unittest.cc", + "../browser/ui/app_list/search/games/game_result_unittest.cc", "../browser/ui/app_list/search/help_app_provider_unittest.cc", "../browser/ui/app_list/search/keyboard_shortcut_provider_unittest.cc", "../browser/ui/app_list/search/keyboard_shortcut_result_unittest.cc", @@ -8506,7 +8518,7 @@ "//chrome/browser/profiles:profile", "//chrome/browser/ui", "//chrome/browser/web_applications", - "//chrome/browser/web_applications:web_applications_test_support_minimal", + "//chrome/browser/web_applications:web_applications_test_support", "//chrome/common", "//chrome/common:chrome_features", "//chrome/common:constants", @@ -8869,6 +8881,7 @@ "//chrome/browser/devtools:test_support", "//chrome/browser/resource_coordinator:tab_metrics_event_proto", "//chrome/browser/resource_coordinator/tab_ranker", + "//chrome/browser/web_applications:browser_tests_base", "//chrome/browser/web_applications:interactive_ui_tests", "//chrome/browser/web_applications:web_applications_test_support", "//chrome/common:version_header",
diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc index 66b6690..1bcedb49 100644 --- a/chrome/test/base/in_process_browser_test.cc +++ b/chrome/test/base/in_process_browser_test.cc
@@ -141,13 +141,13 @@ #if BUILDFLAG(IS_CHROMEOS_ASH) class FakeDeviceSyncImplFactory - : public chromeos::device_sync::DeviceSyncImpl::Factory { + : public ash::device_sync::DeviceSyncImpl::Factory { public: FakeDeviceSyncImplFactory() = default; ~FakeDeviceSyncImplFactory() override = default; - // chromeos::device_sync::DeviceSyncImpl::Factory: - std::unique_ptr<chromeos::device_sync::DeviceSyncBase> CreateInstance( + // ash::device_sync::DeviceSyncImpl::Factory: + std::unique_ptr<ash::device_sync::DeviceSyncBase> CreateInstance( signin::IdentityManager* identity_manager, gcm::GCMDriver* gcm_driver, PrefService* profile_prefs, @@ -431,7 +431,7 @@ #if BUILDFLAG(IS_CHROMEOS_ASH) // Device sync (for multidevice "Better Together") is ash specific. - chromeos::device_sync::DeviceSyncImpl::Factory::SetCustomFactory( + ash::device_sync::DeviceSyncImpl::Factory::SetCustomFactory( GetFakeDeviceSyncImplFactory()); // Using a screenshot for clamshell to tablet mode transitions makes the flow @@ -493,7 +493,7 @@ #endif #if BUILDFLAG(IS_CHROMEOS_ASH) - chromeos::device_sync::DeviceSyncImpl::Factory::SetCustomFactory(nullptr); + ash::device_sync::DeviceSyncImpl::Factory::SetCustomFactory(nullptr); launch_browser_for_testing_ = nullptr; #endif }
diff --git a/chrome/test/data/webui/BUILD.gn b/chrome/test/data/webui/BUILD.gn index 0fed60b2..add02e0 100644 --- a/chrome/test/data/webui/BUILD.gn +++ b/chrome/test/data/webui/BUILD.gn
@@ -157,6 +157,7 @@ "../../../browser/ui/webui/chromeos/certificate_manager_dialog_browsertest.js", "../chromeos/oobe_webui_browsertest.js", "chromeos/account_manager/account_manager_browsertest.js", + "chromeos/arc_account_picker/arc_account_picker_browsertest.js", "chromeos/edu_coexistence/edu_coexistence_browsertest.js", "chromeos/emoji_picker/emoji_picker_browsertest.js", "chromeos/gaia_action_buttons/gaia_action_buttons_browsertest.js",
diff --git a/chrome/test/data/webui/chromeos/BUILD.gn b/chrome/test/data/webui/chromeos/BUILD.gn index 1411eafa..9c2b1a357 100644 --- a/chrome/test/data/webui/chromeos/BUILD.gn +++ b/chrome/test/data/webui/chromeos/BUILD.gn
@@ -44,6 +44,7 @@ public_deps += [ ":closure_compile_local", "account_manager:closure_compile", + "arc_account_picker:closure_compile", "ash_common:closure_compile", "diagnostics:closure_compile", "emoji_picker:closure_compile",
diff --git a/chrome/test/data/webui/chromeos/arc_account_picker/BUILD.gn b/chrome/test/data/webui/chromeos/arc_account_picker/BUILD.gn new file mode 100644 index 0000000..8186d6e4 --- /dev/null +++ b/chrome/test/data/webui/chromeos/arc_account_picker/BUILD.gn
@@ -0,0 +1,36 @@ +# Copyright 2022 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//third_party/closure_compiler/compile_js.gni") + +js_type_check("closure_compile") { + is_polymer3 = true + closure_flags = default_closure_args + [ + "browser_resolver_prefix_replacements=\"chrome://chrome-signin/=../../chrome/browser/resources/chromeos/arc_account_picker/\"", + "js_module_root=../../chrome/test/data/webui/", + "js_module_root=./gen/chrome/test/data/webui/", + ] + deps = [ + ":arc_account_picker_test", + ":test_util", + ] +} + +js_library("arc_account_picker_test") { + deps = [ + "../..:chai_assert", + "//chrome/browser/resources/chromeos/arc_account_picker:arc_account_picker_app", + "//chrome/browser/resources/chromeos/arc_account_picker:arc_account_picker_browser_proxy", + "//ui/webui/resources/js:assert.m", + "//ui/webui/resources/js/cr:event_target.m", + ] + externs_list = [ "$externs_path/mocha-2.5.js" ] +} + +js_library("test_util") { + deps = [ + "../..:test_browser_proxy", + "//chrome/browser/resources/chromeos/arc_account_picker:arc_account_picker_browser_proxy", + ] +}
diff --git a/chrome/test/data/webui/chromeos/arc_account_picker/arc_account_picker_browsertest.js b/chrome/test/data/webui/chromeos/arc_account_picker/arc_account_picker_browsertest.js new file mode 100644 index 0000000..4e152c1 --- /dev/null +++ b/chrome/test/data/webui/chromeos/arc_account_picker/arc_account_picker_browsertest.js
@@ -0,0 +1,49 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/** + * @fileoverview Tests for ARC account picker screen. + */ + +// Polymer BrowserTest fixture. +GEN_INCLUDE(['//chrome/test/data/webui/polymer_browser_test_base.js']); + +GEN('#include "content/public/test/browser_test.h"'); + +// eslint-disable-next-line no-var +var ArcAccountPickerTest = class extends PolymerTest { + /** @override */ + get browsePreload() { + return 'chrome://chrome-signin/test_loader.html?module=chromeos/arc_account_picker/arc_account_picker_test.js'; + } + + get suiteName() { + return arc_account_picker_test.suiteName; + } + + /** @param {string} testName The name of the test to run. */ + runMochaTest(testName) { + runMochaTest(this.suiteName, testName); + } +}; + +TEST_F('ArcAccountPickerTest', 'EmptyAccountList', function() { + this.runMochaTest(arc_account_picker_test.TestNames.EmptyAccountList); +}); + +TEST_F('ArcAccountPickerTest', 'AccountList', function() { + this.runMochaTest(arc_account_picker_test.TestNames.AccountList); +}); + +TEST_F('ArcAccountPickerTest', 'AddAccount', function() { + this.runMochaTest(arc_account_picker_test.TestNames.AddAccount); +}); + +TEST_F('ArcAccountPickerTest', 'MakeAvailableInArc', function() { + this.runMochaTest(arc_account_picker_test.TestNames.MakeAvailableInArc); +}); + +TEST_F('ArcAccountPickerTest', 'LinkClick', function() { + this.runMochaTest(arc_account_picker_test.TestNames.LinkClick); +});
diff --git a/chrome/test/data/webui/inline_login/arc_account_picker_test.js b/chrome/test/data/webui/chromeos/arc_account_picker/arc_account_picker_test.js similarity index 98% rename from chrome/test/data/webui/inline_login/arc_account_picker_test.js rename to chrome/test/data/webui/chromeos/arc_account_picker/arc_account_picker_test.js index 05d9d36..c78ae5a 100644 --- a/chrome/test/data/webui/inline_login/arc_account_picker_test.js +++ b/chrome/test/data/webui/chromeos/arc_account_picker/arc_account_picker_test.js
@@ -9,7 +9,7 @@ import {assertDeepEquals, assertEquals, assertFalse, assertTrue} from '../../chai_assert.js'; -import {getFakeAccountsNotAvailableInArcList, TestArcAccountPickerBrowserProxy} from './inline_login_test_util.js'; +import {getFakeAccountsNotAvailableInArcList, TestArcAccountPickerBrowserProxy} from './test_util.js'; window.arc_account_picker_test = {}; const arc_account_picker_test = window.arc_account_picker_test;
diff --git a/chrome/test/data/webui/chromeos/arc_account_picker/test_util.js b/chrome/test/data/webui/chromeos/arc_account_picker/test_util.js new file mode 100644 index 0000000..41a5c0b2 --- /dev/null +++ b/chrome/test/data/webui/chromeos/arc_account_picker/test_util.js
@@ -0,0 +1,59 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import {Account, ArcAccountPickerBrowserProxy, ArcAccountPickerBrowserProxyImpl} from 'chrome://chrome-signin/arc_account_picker_browser_proxy.js'; +import {TestBrowserProxy} from '../../test_browser_proxy.js'; + +/** + * @param {!TestArcAccountPickerBrowserProxy} testBrowserProxy + */ +export function setTestArcAccountPickerBrowserProxy(testBrowserProxy) { + ArcAccountPickerBrowserProxyImpl.setInstance( + /** @type {!ArcAccountPickerBrowserProxy} */ (testBrowserProxy)); +} + +/** @return {!Array<Account>} */ +export function getFakeAccountsNotAvailableInArcList() { + return [ + { + id: '1', + email: 'test@gmail.com', + fullName: 'Test User', + image: 'data:image/png;base64,abc123' + }, + {id: '2', email: 'test2@gmail.com', fullName: 'Test2 User', image: ''}, + {id: '3', email: 'test3@gmail.com', fullName: 'Test3 User', image: ''}, + ]; +} + +/** @implements {ArcAccountPickerBrowserProxy} */ +export class TestArcAccountPickerBrowserProxy extends TestBrowserProxy { + constructor() { + super([ + 'getAccountsNotAvailableInArc', + 'makeAvailableInArc', + ]); + + /** @private */ + this.accountsNotAvailableInArc_ = []; + } + + /** + * @param {!Array<Account>} accountsNotAvailableInArc + */ + setAccountsNotAvailableInArc(accountsNotAvailableInArc) { + this.accountsNotAvailableInArc_ = accountsNotAvailableInArc; + } + + /** @override */ + getAccountsNotAvailableInArc() { + this.methodCalled('getAccountsNotAvailableInArc'); + return Promise.resolve(this.accountsNotAvailableInArc_); + } + + /** @override */ + makeAvailableInArc(account) { + this.methodCalled('makeAvailableInArc', account); + } +}
diff --git a/chrome/test/data/webui/inline_login/BUILD.gn b/chrome/test/data/webui/inline_login/BUILD.gn index abdc1d41..c48673c 100644 --- a/chrome/test/data/webui/inline_login/BUILD.gn +++ b/chrome/test/data/webui/inline_login/BUILD.gn
@@ -17,11 +17,13 @@ "browser_resolver_prefix_replacements=\"chrome://chrome-signin/=../../chrome/browser/resources/inline_login/\"", "js_module_root=../../chrome/test/data/webui/", "js_module_root=./gen/chrome/test/data/webui/", - "js_module_root=../../chrome/browser/resources/gaia_auth_host/", - "js_module_root=./gen/chrome/browser/resources/gaia_auth_host/", + "js_module_root=../../chrome/browser/resources/", + "js_module_root=./gen/chrome/browser/resources/", + "js_module_root=../../chrome/browser/resources/inline_login/", + "js_module_root=./gen/chrome/browser/resources/inline_login/", + "js_module_root=./gen/chrome/browser/resources/inline_login/preprocessed/", ] deps = [ - ":arc_account_picker_test", ":inline_login_test", ":inline_login_test_util", ] @@ -39,58 +41,52 @@ externs_list = [ "$externs_path/mocha-2.5.js" ] } -js_library("inline_login_welcome_page_test") { - deps = [ - ":inline_login_test_util", - "..:chai_assert", - "..:test_util", - "//chrome/browser/resources/inline_login:inline_login_app", - "//ui/webui/resources/js:assert.m", - "//ui/webui/resources/js:load_time_data.m", - ] - externs_list = [ "$externs_path/mocha-2.5.js" ] -} +if (is_chromeos) { + js_library("inline_login_welcome_page_test") { + deps = [ + ":inline_login_test_util", + "..:chai_assert", + "..:test_util", + "//chrome/browser/resources/inline_login:inline_login_app", + "//ui/webui/resources/js:assert.m", + "//ui/webui/resources/js:load_time_data.m", + ] + externs_list = [ "$externs_path/mocha-2.5.js" ] + } -js_library("inline_login_signin_blocked_by_policy_page_test") { - deps = [ - ":inline_login_test_util", - "..:chai_assert", - "..:test_util", - "//chrome/browser/resources/inline_login:inline_login_app", - "//ui/webui/resources/js:assert.m", - "//ui/webui/resources/js:load_time_data.m", - ] - externs_list = [ "$externs_path/mocha-2.5.js" ] -} + js_library("inline_login_signin_blocked_by_policy_page_test") { + deps = [ + ":inline_login_test_util", + "..:chai_assert", + "..:test_util", + "//chrome/browser/resources/inline_login:inline_login_app", + "//ui/webui/resources/js:assert.m", + "//ui/webui/resources/js:load_time_data.m", + ] + externs_list = [ "$externs_path/mocha-2.5.js" ] + } -js_library("arc_account_picker_page_test") { - deps = [ - ":inline_login_test_util", - "..:chai_assert", - "..:test_util", - "//chrome/browser/resources/inline_login:inline_login_app", - "//ui/webui/resources/js:assert.m", - "//ui/webui/resources/js:load_time_data.m", - ] - externs_list = [ "$externs_path/mocha-2.5.js" ] -} - -js_library("arc_account_picker_test") { - deps = [ - "..:chai_assert", - "//chrome/browser/resources/inline_login:arc_account_picker_app", - "//chrome/browser/resources/inline_login:arc_account_picker_browser_proxy", - "//ui/webui/resources/js:assert.m", - "//ui/webui/resources/js/cr:event_target.m", - ] - externs_list = [ "$externs_path/mocha-2.5.js" ] + js_library("arc_account_picker_page_test") { + deps = [ + ":inline_login_test_util", + "..:chai_assert", + "..:test_util", + "../chromeos/arc_account_picker:test_util", + "//chrome/browser/resources/inline_login:inline_login_app", + "//ui/webui/resources/js:assert.m", + "//ui/webui/resources/js:load_time_data.m", + ] + externs_list = [ "$externs_path/mocha-2.5.js" ] + } } js_library("inline_login_test_util") { + sources = [ "$target_gen_dir/inline_login_test_util.js" ] deps = [ "..:test_browser_proxy", "//chrome/browser/resources/gaia_auth_host:authenticator.m", "//chrome/browser/resources/inline_login:inline_login_browser_proxy", "//ui/webui/resources/js/cr:event_target.m", ] + extra_deps = [ ":preprocess" ] }
diff --git a/chrome/test/data/webui/inline_login/arc_account_picker_page_test.js b/chrome/test/data/webui/inline_login/arc_account_picker_page_test.js index 293552e..e15524a 100644 --- a/chrome/test/data/webui/inline_login/arc_account_picker_page_test.js +++ b/chrome/test/data/webui/inline_login/arc_account_picker_page_test.js
@@ -6,13 +6,15 @@ import {ArcAccountPickerBrowserProxyImpl} from 'chrome://chrome-signin/arc_account_picker_browser_proxy.js'; import {InlineLoginBrowserProxyImpl} from 'chrome://chrome-signin/inline_login_browser_proxy.js'; +import {AccountAdditionOptions} from 'chrome://chrome-signin/inline_login_util.js'; import {assert} from 'chrome://resources/js/assert.m.js'; import {webUIListenerCallback} from 'chrome://resources/js/cr.m.js'; import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {assertDeepEquals, assertEquals} from '../chai_assert.js'; +import {getFakeAccountsNotAvailableInArcList, setTestArcAccountPickerBrowserProxy, TestArcAccountPickerBrowserProxy} from '../chromeos/arc_account_picker/test_util.js'; -import {fakeAuthExtensionData, fakeAuthExtensionDataWithEmail, getFakeAccountsNotAvailableInArcList, TestArcAccountPickerBrowserProxy, TestAuthenticator, TestInlineLoginBrowserProxy} from './inline_login_test_util.js'; +import {fakeAuthExtensionData, fakeAuthExtensionDataWithEmail, TestAuthenticator, TestInlineLoginBrowserProxy} from './inline_login_test_util.js'; window.arc_account_picker_page_test = {}; const arc_account_picker_page_test = window.arc_account_picker_page_test; @@ -59,7 +61,7 @@ testArcBrowserProxy = new TestArcAccountPickerBrowserProxy(); testArcBrowserProxy.setAccountsNotAvailableInArc(accountsNotAvailableInArc); - ArcAccountPickerBrowserProxyImpl.setInstance(testArcBrowserProxy); + setTestArcAccountPickerBrowserProxy(testArcBrowserProxy); inlineLoginComponent = /** @type {InlineLoginAppElement} */ ( document.createElement('inline-login-app'));
diff --git a/chrome/test/data/webui/inline_login/inline_login_browsertest.js b/chrome/test/data/webui/inline_login/inline_login_browsertest.js index cd3acf6d..a975047 100644 --- a/chrome/test/data/webui/inline_login/inline_login_browsertest.js +++ b/chrome/test/data/webui/inline_login/inline_login_browsertest.js
@@ -269,51 +269,4 @@ this.runMochaTest(inline_login_signin_blocked_by_policy_page_test .TestNames.FireWebUIListenerCallback); }); - -// eslint-disable-next-line no-var -var ArcAccountPickerTest = class extends PolymerTest { - /** @override */ - get browsePreload() { - return 'chrome://chrome-signin/test_loader.html?module=inline_login/arc_account_picker_test.js'; - } - - get suiteName() { - return arc_account_picker_test.suiteName; - } - - /** @param {string} testName The name of the test to run. */ - runMochaTest(testName) { - runMochaTest(this.suiteName, testName); - } - - /** @override */ - get featureList() { - return { - enabled: [ - 'chromeos::features::kArcAccountRestrictions', - 'chromeos::features::kLacrosSupport' - ] - }; - } -}; - -TEST_F('ArcAccountPickerTest', 'EmptyAccountList', function() { - this.runMochaTest(arc_account_picker_test.TestNames.EmptyAccountList); -}); - -TEST_F('ArcAccountPickerTest', 'AccountList', function() { - this.runMochaTest(arc_account_picker_test.TestNames.AccountList); -}); - -TEST_F('ArcAccountPickerTest', 'AddAccount', function() { - this.runMochaTest(arc_account_picker_test.TestNames.AddAccount); -}); - -TEST_F('ArcAccountPickerTest', 'MakeAvailableInArc', function() { - this.runMochaTest(arc_account_picker_test.TestNames.MakeAvailableInArc); -}); - -TEST_F('ArcAccountPickerTest', 'LinkClick', function() { - this.runMochaTest(arc_account_picker_test.TestNames.LinkClick); -}); GEN('#endif');
diff --git a/chrome/test/data/webui/inline_login/inline_login_test_util.js b/chrome/test/data/webui/inline_login/inline_login_test_util.js index 0378b67..9c7717e 100644 --- a/chrome/test/data/webui/inline_login/inline_login_test_util.js +++ b/chrome/test/data/webui/inline_login/inline_login_test_util.js
@@ -5,7 +5,6 @@ import {InlineLoginBrowserProxy} from 'chrome://chrome-signin/inline_login_browser_proxy.js'; import {NativeEventTarget as EventTarget} from 'chrome://resources/js/cr/event_target.m.js'; // <if expr="chromeos"> -import {Account, ArcAccountPickerBrowserProxy, ArcAccountPickerBrowserProxyImpl} from 'chrome://chrome-signin/arc_account_picker_browser_proxy.js'; import {AccountAdditionOptions} from 'chrome://chrome-signin/inline_login_util.js'; // </if> import {TestBrowserProxy} from '../test_browser_proxy.js'; @@ -183,51 +182,3 @@ } // </if> } - -// <if expr="chromeos"> - -/** @return {!Array<Account>} */ -export function getFakeAccountsNotAvailableInArcList() { - return [ - { - id: '1', - email: 'test@gmail.com', - fullName: 'Test User', - image: 'data:image/png;base64,abc123' - }, - {id: '2', email: 'test2@gmail.com', fullName: 'Test2 User', image: ''}, - {id: '3', email: 'test3@gmail.com', fullName: 'Test3 User', image: ''}, - ]; -} - -/** @implements {ArcAccountPickerBrowserProxy} */ -export class TestArcAccountPickerBrowserProxy extends TestBrowserProxy { - constructor() { - super([ - 'getAccountsNotAvailableInArc', - 'makeAvailableInArc', - ]); - - /** @private */ - this.accountsNotAvailableInArc_ = []; - } - - /** - * @param {!Array<Account>} accountsNotAvailableInArc - */ - setAccountsNotAvailableInArc(accountsNotAvailableInArc) { - this.accountsNotAvailableInArc_ = accountsNotAvailableInArc; - } - - /** @override */ - getAccountsNotAvailableInArc() { - this.methodCalled('getAccountsNotAvailableInArc'); - return Promise.resolve(this.accountsNotAvailableInArc_); - } - - /** @override */ - makeAvailableInArc(account) { - this.methodCalled('makeAvailableInArc', account); - } -} -// </if>
diff --git a/chrome/test/data/webui/new_tab_page/modules/modules_test.ts b/chrome/test/data/webui/new_tab_page/modules/modules_test.ts index a871073..d465b2e 100644 --- a/chrome/test/data/webui/new_tab_page/modules/modules_test.ts +++ b/chrome/test/data/webui/new_tab_page/modules/modules_test.ts
@@ -167,6 +167,7 @@ }, ]); callbackRouterRemote.setModulesFreVisibility(true); + callbackRouterRemote.setDisabledModules(false, []); await callbackRouterRemote.$.flushForTesting(); const customizeModule = capture(modulesElement, 'customize-module'); render(modulesElement); @@ -177,6 +178,39 @@ // Assert. assertTrue(customizeModule.received); }); + + test(`fre can be opted out of and restored`, async () => { + // Arrange. + const fooDescriptor = new ModuleDescriptor('foo', 'Foo', initNullModule); + moduleRegistry.setResultFor('getDescriptors', [fooDescriptor]); + const modulesElement = await createModulesElement([ + { + descriptor: fooDescriptor, + element: createElement(), + }, + ]); + callbackRouterRemote.setModulesFreVisibility(true); + callbackRouterRemote.setDisabledModules(false, []); + await callbackRouterRemote.$.flushForTesting(); + + // Act + $$<HTMLElement>(modulesElement, '.cancel-button')!.click(); + + // Assert. + assertDeepEquals(false, handler.getArgs('setModulesFreVisible')[0]); + assertDeepEquals(false, handler.getArgs('setModulesVisible')[0]); + assertTrue(modulesElement.$.removeModuleFreToast.open); + assertFalse(modulesElement.$.removeModuleToast.open); + + + // Act. + modulesElement.$.undoRemoveModuleFreButton.click(); + + // Assert. + assertFalse(modulesElement.$.removeModuleFreToast.open); + assertDeepEquals(true, handler.getArgs('setModulesFreVisible')[1]); + assertDeepEquals(true, handler.getArgs('setModulesVisible')[1]); + }); }); suite('modules redesigned layout', () => { @@ -367,7 +401,7 @@ // Act. modulesElement.$.undoRemoveModuleButton.click(); - // // Assert. + // Assert. assertDeepEquals(['foo', false], handler.getArgs('setModuleDisabled')[1]); // Act.
diff --git a/chromeos/dbus/u2f/fake_u2f_client.cc b/chromeos/dbus/u2f/fake_u2f_client.cc index 8a76975..1d748a0 100644 --- a/chromeos/dbus/u2f/fake_u2f_client.cc +++ b/chromeos/dbus/u2f/fake_u2f_client.cc
@@ -80,4 +80,10 @@ NOTREACHED(); } +void FakeU2FClient::GetAlgorithms( + const u2f::GetAlgorithmsRequest& request, + DBusMethodCallback<u2f::GetAlgorithmsResponse> callback) { + NOTREACHED(); +} + } // namespace chromeos
diff --git a/chromeos/dbus/u2f/fake_u2f_client.h b/chromeos/dbus/u2f/fake_u2f_client.h index fe36b72..949e6e72 100644 --- a/chromeos/dbus/u2f/fake_u2f_client.h +++ b/chromeos/dbus/u2f/fake_u2f_client.h
@@ -46,6 +46,9 @@ void CancelWebAuthnFlow( const u2f::CancelWebAuthnFlowRequest& request, DBusMethodCallback<u2f::CancelWebAuthnFlowResponse> callback) override; + void GetAlgorithms( + const u2f::GetAlgorithmsRequest& request, + DBusMethodCallback<u2f::GetAlgorithmsResponse> callback) override; }; } // namespace chromeos
diff --git a/chromeos/dbus/u2f/u2f_client.cc b/chromeos/dbus/u2f/u2f_client.cc index e153988..7538d97 100644 --- a/chromeos/dbus/u2f/u2f_client.cc +++ b/chromeos/dbus/u2f/u2f_client.cc
@@ -116,6 +116,9 @@ void CancelWebAuthnFlow( const u2f::CancelWebAuthnFlowRequest& request, DBusMethodCallback<u2f::CancelWebAuthnFlowResponse> callback) override; + void GetAlgorithms( + const u2f::GetAlgorithmsRequest& request, + DBusMethodCallback<u2f::GetAlgorithmsResponse> callback) override; private: dbus::ObjectProxy* proxy_ = nullptr; @@ -303,6 +306,18 @@ weak_factory_.GetWeakPtr(), std::move(callback))); } +void U2FClientImpl::GetAlgorithms( + const u2f::GetAlgorithmsRequest& request, + DBusMethodCallback<u2f::GetAlgorithmsResponse> callback) { + dbus::MethodCall method_call(u2f::kU2FInterface, u2f::kU2FGetAlgorithms); + dbus::MessageWriter writer(&method_call); + writer.AppendProtoAsArrayOfBytes(request); + proxy_->CallMethod( + &method_call, kU2FShortTimeout, + base::BindOnce(&U2FClientImpl::HandleResponse<u2f::GetAlgorithmsResponse>, + weak_factory_.GetWeakPtr(), std::move(callback))); +} + } // namespace U2FClient::U2FClient() {
diff --git a/chromeos/dbus/u2f/u2f_client.h b/chromeos/dbus/u2f/u2f_client.h index eceddeb..f999e8b2 100644 --- a/chromeos/dbus/u2f/u2f_client.h +++ b/chromeos/dbus/u2f/u2f_client.h
@@ -102,6 +102,10 @@ const u2f::CancelWebAuthnFlowRequest& request, DBusMethodCallback<u2f::CancelWebAuthnFlowResponse> callback) = 0; + virtual void GetAlgorithms( + const u2f::GetAlgorithmsRequest& request, + DBusMethodCallback<u2f::GetAlgorithmsResponse> callback) = 0; + protected: U2FClient(); virtual ~U2FClient();
diff --git a/chromeos/services/BUILD.gn b/chromeos/services/BUILD.gn index a3a93d1..ca872f20 100644 --- a/chromeos/services/BUILD.gn +++ b/chromeos/services/BUILD.gn
@@ -21,7 +21,6 @@ deps = [ "//chromeos/services/assistant:tests", "//chromeos/services/bluetooth_config:unit_tests", - "//chromeos/services/chromebox_for_meetings/public/cpp:unit_tests", "//chromeos/services/cros_healthd/private/cpp:unit_tests", "//chromeos/services/cros_healthd/public/cpp:unit_tests", "//chromeos/services/federated/public/cpp:unit_tests",
diff --git a/chromeos/tast_control.gni b/chromeos/tast_control.gni index c90f4c3..e9231a3 100644 --- a/chromeos/tast_control.gni +++ b/chromeos/tast_control.gni
@@ -162,6 +162,16 @@ # https://crbug.com/1309146 "u2fd.WebauthnUsingPassword.tpm1", + + # b/224969741 + # "arc.Boot.vm", # Flaky, but also important. + "arc.ChromeCrash.vm_logged_in", + "arc.Drivefs.vm", + "arc.IMEBlockingVK.vm", + "arc.RemovableMedia.vm", + "arc.SettingsBridge.vm", + "arc.StartStop.vm", + "arc.TextToSpeech.vm", ] # To disable a specific test in lacros_all_tast_tests, add it the following
diff --git a/codelabs/cpp101/codelab.md b/codelabs/cpp101/codelab.md index e239196d..dbc69a1 100644 --- a/codelabs/cpp101/codelab.md +++ b/codelabs/cpp101/codelab.md
@@ -227,13 +227,30 @@ Normally you wouldn't have to worry about setting up a threading environment and keeping it running, since that is automatically done by Chromium's thread classes. However, since the main thread doesn't automatically start off with -`TaskEnvironment`, there's a bit of extra setup involved. This setup code is -available in the exercise solution files. +`TaskEnvironment`, there's a bit of extra setup involved. The following setup +code should be enough to create the necessary TaskEnvironment. +Include `testonly=true` flag in the BUILD.gn file, along with +`"//base/test:test_support"` set as a dependency. ### Important header files ```cpp +#include "base/test/task_environment.h" +#include "base/test/test_timeouts.h" +#include "base/at_exit.h" #include "base/threading/sequenced_task_runner_handle.h" #include "base/time/time.h" +#include "base/command_line.h" +``` +### Setup code: +```cpp +int main(int argc, char* argv[]) { + base::AtExitManager exit_manager; + base::CommandLine::Init(argc, argv); + TestTimeouts::Initialize(); + base::test::TaskEnvironment task_environment{ + base::test::TaskEnvironment::TimeSource::SYSTEM_TIME}; + + // The rest of your code will go here. ``` ### Exercise 3a: Sleep @@ -241,6 +258,8 @@ Implement the Unix command-line utility `sleep` using only a `base::SequencedTaskRunnerHandle` (i.e., without using the `sleep` function or `base::PlatformThread::Sleep`). +Hint: You will need to use `base::RunLoop` to prevent the main function from +exiting prematurely. ### Exercise 3b: Integer factorization
diff --git a/components/autofill/core/browser/form_structure.cc b/components/autofill/core/browser/form_structure.cc index 7fa8bdb..944402ce 100644 --- a/components/autofill/core/browser/form_structure.cc +++ b/components/autofill/core/browser/form_structure.cc
@@ -692,24 +692,19 @@ // Then if there are enough active fields, and if we are dealing with either a // proper <form> or a <form>-less checkout, run the heuristics and server // prediction routines. + FieldCandidatesMap field_type_map; if (ShouldRunHeuristics()) { - const FieldCandidatesMap field_type_map = FormField::ParseFormFields( - fields_, current_page_language_, is_form_tag_, log_manager); - for (const auto& field : fields_) { - const auto iter = field_type_map.find(field->global_id()); - if (iter != field_type_map.end()) { - field->set_heuristic_type(iter->second.BestHeuristicType()); - } - } - } else if (ShouldRunPromoCodeHeuristics()) { - const FieldCandidatesMap field_type_map = - FormField::ParseFormFieldsForPromoCodes(fields_, current_page_language_, + field_type_map = FormField::ParseFormFields(fields_, current_page_language_, is_form_tag_, log_manager); + } else if (ShouldRunPromoCodeHeuristics()) { + field_type_map = FormField::ParseFormFieldsForPromoCodes( + fields_, current_page_language_, is_form_tag_, log_manager); + } + if (!field_type_map.empty()) { for (const auto& field : fields_) { - const auto iter = field_type_map.find(field->global_id()); - if (iter != field_type_map.end()) { + auto iter = field_type_map.find(field->global_id()); + if (iter != field_type_map.end()) field->set_heuristic_type(iter->second.BestHeuristicType()); - } } }
diff --git a/components/autofill/core/browser/payments/autofill_virtual_card_enrollment_infobar_delegate_mobile.cc b/components/autofill/core/browser/payments/autofill_virtual_card_enrollment_infobar_delegate_mobile.cc index fcf9d1e..d7353a9 100644 --- a/components/autofill/core/browser/payments/autofill_virtual_card_enrollment_infobar_delegate_mobile.cc +++ b/components/autofill/core/browser/payments/autofill_virtual_card_enrollment_infobar_delegate_mobile.cc
@@ -90,10 +90,7 @@ } int AutofillVirtualCardEnrollmentInfoBarDelegateMobile::GetIconId() const { - // TODO(crbug.com/1298224): Change the icon to - // IDR_AUTOFILL_GOOGLE_PAY_WITH_DIVIDER after adding the top icon as the - // divider currently causes the title to wrap to second line. - return IDR_AUTOFILL_GOOGLE_PAY; + return IDR_AUTOFILL_GOOGLE_PAY_WITH_DIVIDER; } std::u16string
diff --git a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/listmenu/ListMenuButton.java b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/listmenu/ListMenuButton.java index 29735d1..a5f5247 100644 --- a/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/listmenu/ListMenuButton.java +++ b/components/browser_ui/widget/android/java/src/org/chromium/components/browser_ui/widget/listmenu/ListMenuButton.java
@@ -47,6 +47,7 @@ private ObserverList<PopupMenuShownListener> mPopupListeners = new ObserverList<>(); private boolean mTryToFitLargestItem; private boolean mPositionedAtEnd; + private boolean mIsAttachedToWindow; /** * Creates a new {@link ListMenuButton}. @@ -128,6 +129,7 @@ * Shows a popupWindow built by ListMenuButton */ public void showMenu() { + if (!mIsAttachedToWindow) return; initPopupWindow(); mPopupMenu.show(); notifyPopupListeners(true); @@ -218,8 +220,15 @@ } @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + mIsAttachedToWindow = true; + } + + @Override protected void onDetachedFromWindow() { dismiss(); + mIsAttachedToWindow = false; super.onDetachedFromWindow(); }
diff --git a/components/client_hints/browser/client_hints.cc b/components/client_hints/browser/client_hints.cc index e39050d..4937623 100644 --- a/components/client_hints/browser/client_hints.cc +++ b/components/client_hints/browser/client_hints.cc
@@ -174,16 +174,16 @@ } const base::TimeTicks start_time = base::TimeTicks::Now(); - base::Value::ListStorage client_hints_list; + base::Value::List client_hints_list; client_hints_list.reserve(client_hints.size()); for (const auto& entry : client_hints) { - client_hints_list.push_back(base::Value(static_cast<int>(entry))); + client_hints_list.Append(static_cast<int>(entry)); } - auto client_hints_dictionary = std::make_unique<base::DictionaryValue>(); - client_hints_dictionary->SetKey(kClientHintsSettingKey, - base::Value(std::move(client_hints_list))); + base::Value::Dict client_hints_dictionary; + client_hints_dictionary.Set(kClientHintsSettingKey, + std::move(client_hints_list)); const auto session_model = base::FeatureList::IsEnabled(blink::features::kDurableClientHintsCache) @@ -194,7 +194,7 @@ // when cookies are disabled for |primary_origin|. settings_map_->SetWebsiteSettingDefaultScope( primary_url, GURL(), ContentSettingsType::CLIENT_HINTS, - base::Value::FromUniquePtrValue(std::move(client_hints_dictionary)), + base::Value(std::move(client_hints_dictionary)), {base::Time(), session_model}); // Record the time spent getting the client hints.
diff --git a/components/client_hints/common/client_hints.cc b/components/client_hints/common/client_hints.cc index 27596d2..2af20840 100644 --- a/components/client_hints/common/client_hints.cc +++ b/components/client_hints/common/client_hints.cc
@@ -36,11 +36,15 @@ DCHECK(rule.setting_value.is_dict()); const base::Value* list_value = - rule.setting_value.FindKey(kClientHintsSettingKey); + rule.setting_value.GetDict().Find(kClientHintsSettingKey); if (list_value == nullptr) continue; + + // We should guarantee client hints list value always be Type::List since we + // save the client hints as base::Value::List in the Prefs. For details, + // check components/client_hints/browser/client_hints.cc DCHECK(list_value->is_list()); - for (const auto& client_hint : list_value->GetListDeprecated()) { + for (const auto& client_hint : list_value->GetList()) { DCHECK(client_hint.is_int()); network::mojom::WebClientHintsType client_hint_mojo = static_cast<network::mojom::WebClientHintsType>(client_hint.GetInt());
diff --git a/components/cronet/cronet_context.cc b/components/cronet/cronet_context.cc index 9f30bc41..1fa1e93 100644 --- a/components/cronet/cronet_context.cc +++ b/components/cronet/cronet_context.cc
@@ -176,6 +176,16 @@ base::Time::Max(), quic::ParsedQuicVersionVector()); } +// net::NetworkChangeNotifier doesn't provide an API to query if a specific +// network has become disconnected. For these network though, it will return +// CONNECTION_UNKNOWN as their connection type. This should be a good enough +// approximation for the time being. +bool IsNetworkNoLongerConnected( + net::NetworkChangeNotifier::NetworkHandle network) { + return net::NetworkChangeNotifier::GetNetworkConnectionType(network) == + net::NetworkChangeNotifier::CONNECTION_UNKNOWN; +} + } // namespace namespace cronet { @@ -556,6 +566,26 @@ return contexts_[network].get(); } +void CronetContext::NetworkTasks::MaybeDestroyURLRequestContext( + net::NetworkChangeNotifier::NetworkHandle network) { + DCHECK_CALLED_ON_VALID_THREAD(network_thread_checker_); + + // Default network context is never deleted. + if (network == net::NetworkChangeNotifier::kInvalidNetworkHandle) + return; + if (!contexts_.contains(network)) + return; + + auto& context = contexts_[network]; + // For a URLRequestContext to be destroyed, two conditions must be satisfied: + // 1. The network associated to that context must be no longer connected + // 2. There must be no URLRequests associated to that context + if (context->url_requests()->size() == 0 && + IsNetworkNoLongerConnected(network)) { + contexts_.erase(network); + } +} + // Request context getter for CronetContext. class CronetContext::ContextGetter : public net::URLRequestContextGetter { public: @@ -659,6 +689,12 @@ base::Unretained(network_tasks_))); } +void CronetContext::MaybeDestroyURLRequestContext( + net::NetworkChangeNotifier::NetworkHandle network) { + DCHECK(IsOnNetworkThread()); + network_tasks_->MaybeDestroyURLRequestContext(network); +} + int CronetContext::default_load_flags() const { return default_load_flags_; } @@ -722,9 +758,16 @@ net::NetworkChangeNotifier::NetworkHandle network) { DCHECK_CALLED_ON_VALID_THREAD(network_thread_checker_); - // TODO(stefanoduo): Properly cancel pending requests before destroying the - // context. - contexts_.erase(network); + if (!contexts_.contains(network)) + return; + + auto& context = contexts_[network]; + // After `network` disconnects, we can delete the URLRequestContext + // associated with it only if it has no pending URLRequests. + // If there are, their destruction procedure will take care of destroying + // this context (see MaybeDestroyURLRequestContext for more info). + if (context->url_requests()->size() == 0) + contexts_.erase(network); } void CronetContext::NetworkTasks::OnNetworkConnected(
diff --git a/components/cronet/cronet_context.h b/components/cronet/cronet_context.h index 5706e31b..7754c31 100644 --- a/components/cronet/cronet_context.h +++ b/components/cronet/cronet_context.h
@@ -150,6 +150,13 @@ // flush any remaining writes to disk. void StopNetLog(); + // Destroys the URLRequestContext associated to `network` if `network` has + // disconnected and it has no pending URLRequests. This must be called on + // the network thread while destroying a CronetURLRequest as that might + // mark a URLRequestContext as eligible for destruction. + void MaybeDestroyURLRequestContext( + net::NetworkChangeNotifier::NetworkHandle network); + // Default net::LOAD flags used to create requests. int default_load_flags() const; @@ -262,6 +269,9 @@ // Stops NetLog logging. void StopNetLog(); + void MaybeDestroyURLRequestContext( + net::NetworkChangeNotifier::NetworkHandle network); + // Callback for StopObserving() that unblocks the client thread and // signals that it is safe to access the NetLog files. void StopNetLogCompleted();
diff --git a/components/cronet/cronet_url_request.cc b/components/cronet/cronet_url_request.cc index 60002772..08cee12 100644 --- a/components/cronet/cronet_url_request.cc +++ b/components/cronet/cronet_url_request.cc
@@ -361,7 +361,14 @@ if (send_on_canceled) callback_->OnCanceled(); callback_->OnDestroyed(); - // Deleting owner request also deletes |this|. + // Check if the URLRequestContext associated to `network_` has become eligible + // for destruction. To simplify MaybeDestroyURLRequestContext's logic: destroy + // the underlying URLRequest in advance, so that it has already deregistered + // from its URLRequestContext by the time MaybeDestroyURLRequestContext is + // called. + url_request_.reset(); + request->context_->MaybeDestroyURLRequestContext(network_); + // Deleting owner request also deletes `this`. delete request; }
diff --git a/components/cronet/network_tasks_unittest.cc b/components/cronet/network_tasks_unittest.cc index 661e8e2..17800fcf 100644 --- a/components/cronet/network_tasks_unittest.cc +++ b/components/cronet/network_tasks_unittest.cc
@@ -14,6 +14,7 @@ #include "net/base/request_priority.h" #include "net/cert/cert_verifier.h" #include "net/proxy_resolution/proxy_config_service_fixed.h" +#include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "net/url_request/url_request.h" #include "net/url_request/url_request_context.h" #include "testing/gtest/include/gtest/gtest.h" @@ -134,6 +135,27 @@ })); } + void CreateURLRequest(net::NetworkChangeNotifier::NetworkHandle network) { + PostToNetworkThreadSync(base::BindLambdaForTesting([&]() { + auto* context = network_tasks_->GetURLRequestContext(network); + url_request_ = context->CreateRequest(GURL("http://www.foo.com"), + net::DEFAULT_PRIORITY, nullptr, + TRAFFIC_ANNOTATION_FOR_TESTS); + EXPECT_TRUE(url_request_); + })); + } + + void ReleaseURLRequest() { + PostToNetworkThreadSync( + base::BindLambdaForTesting([&]() { url_request_.reset(); })); + } + + void MaybeDestroyURLRequestContext( + net::NetworkChangeNotifier::NetworkHandle network) { + PostToNetworkThreadSync(base::BindLambdaForTesting( + [&]() { network_tasks_->MaybeDestroyURLRequestContext(network); })); + } + void PostToNetworkThreadSync(base::OnceCallback<void()> callback) { std::latch callback_executed{1}; auto wait_for_callback = base::BindLambdaForTesting( @@ -149,6 +171,7 @@ scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; raw_ptr<CronetContext::NetworkTasks> network_tasks_; + std::unique_ptr<net::URLRequest> url_request_; }; TEST_F(NetworkTasksTest, NetworkBoundContextLifetime) { @@ -170,6 +193,34 @@ CheckURLRequestContextExistence(kNetwork, false); } +TEST_F(NetworkTasksTest, NetworkBoundContextWithPendingRequest) { +#if BUILDFLAG(IS_ANDROID) + if (base::android::BuildInfo::GetInstance()->sdk_int() < + base::android::SDK_VERSION_MARSHMALLOW) { + GTEST_SKIP() << "Network binding on Android requires an API level >= 23"; + } +#endif // BUILDFLAG(IS_ANDROID) + constexpr net::NetworkChangeNotifier::NetworkHandle kNetwork = 1; + + CheckURLRequestContextExistence(kNetwork, false); + SpawnNetworkBoundURLRequestContext(kNetwork); + CheckURLRequestContextExistence(kNetwork, true); + + // If after a network disconnection there are still pending requests, the + // context should not be destroyed to avoid UAFs (URLRequests can reference + // their associated URLRequestContext). + CreateURLRequest(kNetwork); + scoped_ncn_.mock_network_change_notifier()->NotifyNetworkDisconnected( + kNetwork); + CheckURLRequestContextExistence(kNetwork, true); + + // Once the URLRequest is destroyed, MaybeDestroyURLRequestContext should be + // able to destroy the context. + ReleaseURLRequest(); + MaybeDestroyURLRequestContext(kNetwork); + CheckURLRequestContextExistence(kNetwork, false); +} + } // namespace } // namespace cronet
diff --git a/components/custom_handlers/protocol_handler_registry.cc b/components/custom_handlers/protocol_handler_registry.cc index caddaaa..3944080 100644 --- a/components/custom_handlers/protocol_handler_registry.cc +++ b/components/custom_handlers/protocol_handler_registry.cc
@@ -63,9 +63,9 @@ // ProtocolHandlerRegistry ----------------------------------------------------- ProtocolHandlerRegistry::ProtocolHandlerRegistry( - content::BrowserContext* context, + PrefService* prefs, std::unique_ptr<Delegate> delegate) - : context_(context), + : prefs_(prefs), delegate_(std::move(delegate)), enabled_(true), is_loading_(false), @@ -181,9 +181,13 @@ is_loaded_ = true; is_loading_ = true; - PrefService* prefs = user_prefs::UserPrefs::Get(context_); - if (prefs->HasPrefPath(prefs::kCustomHandlersEnabled)) { - if (prefs->GetBoolean(prefs::kCustomHandlersEnabled)) { + if (!prefs_) { + is_loading_ = false; + return; + } + + if (prefs_->HasPrefPath(prefs::kCustomHandlersEnabled)) { + if (prefs_->GetBoolean(prefs::kCustomHandlersEnabled)) { Enable(); } else { Disable(); @@ -500,13 +504,16 @@ if (is_loading_) { return; } + + if (!prefs_) + return; + base::Value registered_protocol_handlers(EncodeRegisteredHandlers()); base::Value ignored_protocol_handlers(EncodeIgnoredHandlers()); - PrefService* prefs = user_prefs::UserPrefs::Get(context_); - prefs->Set(prefs::kRegisteredProtocolHandlers, registered_protocol_handlers); - prefs->Set(prefs::kIgnoredProtocolHandlers, ignored_protocol_handlers); - prefs->SetBoolean(prefs::kCustomHandlersEnabled, enabled_); + prefs_->Set(prefs::kRegisteredProtocolHandlers, registered_protocol_handlers); + prefs_->Set(prefs::kIgnoredProtocolHandlers, ignored_protocol_handlers); + prefs_->SetBoolean(prefs::kCustomHandlersEnabled, enabled_); } const ProtocolHandlerRegistry::ProtocolHandlerList* @@ -607,12 +614,11 @@ ProtocolHandlerRegistry::GetHandlersFromPref(const char* pref_name) const { DCHECK_CURRENTLY_ON(BrowserThread::UI); std::vector<const base::Value::Dict*> result; - PrefService* prefs = user_prefs::UserPrefs::Get(context_); - if (!prefs->HasPrefPath(pref_name)) { + if (!prefs_ || !prefs_->HasPrefPath(pref_name)) { return result; } - const base::Value* handlers = prefs->GetList(pref_name); + const base::Value* handlers = prefs_->GetList(pref_name); if (handlers) { for (const auto& list_item : handlers->GetList()) { if (const base::Value::Dict* encoded_handler = list_item.GetIfDict()) {
diff --git a/components/custom_handlers/protocol_handler_registry.h b/components/custom_handlers/protocol_handler_registry.h index 1d99bdb..887c0c31 100644 --- a/components/custom_handlers/protocol_handler_registry.h +++ b/components/custom_handlers/protocol_handler_registry.h
@@ -17,13 +17,15 @@ #include "base/time/time.h" #include "base/values.h" #include "components/keyed_service/core/keyed_service.h" -#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" namespace user_prefs { class PrefRegistrySyncable; } +class PrefService; +class GURL; + using DefaultClientCallback = base::OnceCallback<void(bool)>; namespace custom_handlers { @@ -74,7 +76,7 @@ }; // Creates a new instance. - ProtocolHandlerRegistry(content::BrowserContext* context, + ProtocolHandlerRegistry(PrefService* prefs, std::unique_ptr<Delegate> delegate); ProtocolHandlerRegistry(const ProtocolHandlerRegistry&) = delete; @@ -341,8 +343,9 @@ // Protocol handlers that are the defaults for a given protocol. ProtocolHandlerMap default_handlers_; - // The browser context that owns this ProtocolHandlerRegistry. - raw_ptr<content::BrowserContext> context_; + // The PrefService to store the registered handlers in the user profile (it + // may be null for testing) + raw_ptr<PrefService> prefs_ = nullptr; // The Delegate that registers / deregisters external handlers on our behalf. std::unique_ptr<Delegate> delegate_;
diff --git a/components/custom_handlers/protocol_handler_registry_unittest.cc b/components/custom_handlers/protocol_handler_registry_unittest.cc index fb5d669..1b35bdd 100644 --- a/components/custom_handlers/protocol_handler_registry_unittest.cc +++ b/components/custom_handlers/protocol_handler_registry_unittest.cc
@@ -192,8 +192,8 @@ DCHECK(browser_context_); auto delegate = std::make_unique<TestProtocolHandlerRegistryDelegate>(); delegate_ = delegate.get(); - registry_ = std::make_unique<ProtocolHandlerRegistry>( - browser_context_.get(), std::move(delegate)); + registry_ = std::make_unique<ProtocolHandlerRegistry>(GetPrefs(), + std::move(delegate)); if (initialize) registry_->InitProtocolSettings(); }
diff --git a/components/history_clusters/core/config.cc b/components/history_clusters/core/config.cc index d2a7e69..34699a1 100644 --- a/components/history_clusters/core/config.cc +++ b/components/history_clusters/core/config.cc
@@ -87,6 +87,20 @@ features::kOnDeviceClustering, "navigation_time_cutoff_minutes", cluster_navigation_time_cutoff.InMinutes())); + entity_relevance_threshold = GetFieldTrialParamByFeatureAsInt( + features::kOnDeviceClustering, "entity_relevance_threshold", + entity_relevance_threshold); + // Ensure that the value is [0 and 100]. + DCHECK_GE(entity_relevance_threshold, 0); + DCHECK_LE(entity_relevance_threshold, 100); + + category_relevance_threshold = GetFieldTrialParamByFeatureAsInt( + features::kOnDeviceClustering, "category_relevance_threshold", + category_relevance_threshold); + // Ensure that the value is [0 and 100]. + DCHECK_GE(category_relevance_threshold, 0); + DCHECK_LE(category_relevance_threshold, 100); + content_clustering_enabled = GetFieldTrialParamByFeatureAsBool( features::kOnDeviceClustering, "content_clustering_enabled", content_clustering_enabled);
diff --git a/components/history_clusters/core/config.h b/components/history_clusters/core/config.h index 4c46a981..ecdc99a 100644 --- a/components/history_clusters/core/config.h +++ b/components/history_clusters/core/config.h
@@ -51,8 +51,10 @@ double min_score_to_always_show_above_the_fold = 0.5; // If enabled, this is the number of non-zero scored visits to always show - // above the fold regardless of score. - int num_visits_to_always_show_above_the_fold = 3; + // above the fold regardless of score. Note, this value includes the + // "top visit". In the unlabeled "top visit" UI configuration, that means the + // one "top visit" and three subordinate looking visits will be always shown. + size_t num_visits_to_always_show_above_the_fold = 4; // If enabled, when there is a Journeys search query, the backend re-scores // visits within a cluster to account for whether or not that visit matches. @@ -95,6 +97,14 @@ // a visit can be considered for the same cluster. base::TimeDelta cluster_navigation_time_cutoff = base::Minutes(60); + // The minimum threshold for whether an entity is considered relevant to the + // visit. + int entity_relevance_threshold = 60; + + // The minimum threshold for whether a category is considered relevant to the + // visit. + int category_relevance_threshold = 36; // 60 * 0.6 = 36. + // Returns whether content clustering is enabled and // should be performed by the clustering backend. bool content_clustering_enabled = true;
diff --git a/components/history_clusters/core/on_device_clustering_backend.cc b/components/history_clusters/core/on_device_clustering_backend.cc index 9067555..88a5d3a8 100644 --- a/components/history_clusters/core/on_device_clustering_backend.cc +++ b/components/history_clusters/core/on_device_clustering_backend.cc
@@ -134,6 +134,10 @@ for (const auto& visit : visits) { for (const auto& entity : visit.content_annotations.model_annotations.entities) { + // Only put the entity IDs in if they exceed a certain threshold. + if (entity.weight < GetConfig().entity_relevance_threshold) { + continue; + } entity_ids.insert(entity.id); } } @@ -297,7 +301,7 @@ .entities.clear(); cluster_visit.annotated_visit.content_annotations.model_annotations .categories.clear(); - base::flat_set<std::string> inserted_categories; + base::flat_map<std::string, int> inserted_categories; for (const auto& entity : visit.content_annotations.model_annotations.entities) { auto entity_metadata_it = entity_metadata_map.find(entity.id); @@ -313,15 +317,25 @@ for (const auto& category : entity_metadata_it->second.human_readable_categories) { - if (inserted_categories.find(category.first) == - inserted_categories.end()) { - cluster_visit.annotated_visit.content_annotations.model_annotations - .categories.push_back( - {category.first, static_cast<int>(100 * category.second)}); - inserted_categories.insert(category.first); + auto category_it = inserted_categories.find(category.first); + int category_score = + static_cast<int>(category.second * entity.weight); + // Just take the max category score (which is weighted by entity) as + // the canonical score for the category. + if (category_it == inserted_categories.end() || + category_it->second < category_score) { + inserted_categories[category.first] = category_score; } } } + + // Only add the category to the visit if it exceeds the threshold. + for (const auto& category : inserted_categories) { + if (category.second > GetConfig().category_relevance_threshold) { + cluster_visit.annotated_visit.content_annotations.model_annotations + .categories.push_back({category.first, category.second}); + } + } } cluster_visits.push_back(cluster_visit);
diff --git a/components/history_clusters/core/on_device_clustering_backend_unittest.cc b/components/history_clusters/core/on_device_clustering_backend_unittest.cc index 7044aded..951f6542 100644 --- a/components/history_clusters/core/on_device_clustering_backend_unittest.cc +++ b/components/history_clusters/core/on_device_clustering_backend_unittest.cc
@@ -64,11 +64,14 @@ optimization_guide::EntityMetadataRetrievedCallback callback) { optimization_guide::EntityMetadata metadata; metadata.human_readable_name = "rewritten-" + entity_id; - // Add it in twice to verify that a category only gets added once. + // Add it in twice to verify that a category only gets added once + // and it takes the max. + metadata.human_readable_categories.insert( + {"category-" + entity_id, 0.6}); metadata.human_readable_categories.insert( {"category-" + entity_id, 0.5}); metadata.human_readable_categories.insert( - {"category-" + entity_id, 0.5}); + {"toolow-" + entity_id, 0.01}); std::move(callback).Run(entity_id == "nometadata" ? absl::nullopt : absl::make_optional(metadata)); @@ -97,6 +100,7 @@ config_.should_exclude_keywords_from_noisy_visits = false; config_.split_clusters_at_search_visits = false; config_.should_label_clusters = false; + config_.entity_relevance_threshold = 60; SetConfigForTesting(config_); } @@ -171,13 +175,13 @@ history::AnnotatedVisit visit = testing::CreateDefaultAnnotatedVisit(1, GURL("https://google.com/")); visit.content_annotations.model_annotations.categories = { - {"google-category", 1}, {"com", 1}}; + {"google-category", 100}, {"com", 100}}; visits.push_back(visit); history::AnnotatedVisit visit2 = testing::CreateDefaultAnnotatedVisit(2, GURL("https://google.com/next")); - visit2.content_annotations.model_annotations.entities = {{"google-entity", 1}, - {"com", 1}}; + visit2.content_annotations.model_annotations.entities = { + {"google-entity", 100}, {"com", 100}}; visit2.referring_visit_of_redirect_chain_start = 1; visits.push_back(visit2); @@ -419,14 +423,14 @@ // visits by visit ID. history::AnnotatedVisit visit = testing::CreateDefaultAnnotatedVisit(1, GURL("https://github.com/")); - visit.content_annotations.model_annotations.entities = {{"github", 1}}; - visit.content_annotations.model_annotations.categories = {{"category", 1}}; + visit.content_annotations.model_annotations.entities = {{"github", 100}}; + visit.content_annotations.model_annotations.categories = {{"category", 100}}; visits.push_back(visit); history::AnnotatedVisit visit2 = testing::CreateDefaultAnnotatedVisit(2, GURL("https://google.com/")); - visit2.content_annotations.model_annotations.entities = {{"github", 1}}; - visit2.content_annotations.model_annotations.categories = {{"category", 1}}; + visit2.content_annotations.model_annotations.entities = {{"github", 100}}; + visit2.content_annotations.model_annotations.categories = {{"category", 100}}; visit2.referring_visit_of_redirect_chain_start = 1; // Set the visit duration to be 2x the default so it has the same duration // after |visit| and |visit4| are deduped. @@ -435,9 +439,9 @@ history::AnnotatedVisit visit4 = testing::CreateDefaultAnnotatedVisit(4, GURL("https://github.com/")); - visit4.content_annotations.model_annotations.entities = {{"github", 1}}; - visit4.content_annotations.model_annotations.categories = {{"category", 1}, - {"category2", 1}}; + visit4.content_annotations.model_annotations.entities = {{"github", 100}}; + visit4.content_annotations.model_annotations.categories = { + {"category", 100}, {"category2", 100}}; visits.push_back(visit4); // After the context clustering, visit5 will not be in the same cluster as @@ -445,9 +449,9 @@ // and categories so they will be clustered in the content pass. history::AnnotatedVisit visit5 = testing::CreateDefaultAnnotatedVisit( 10, GURL("https://nonexistentreferrer.com/")); - visit5.content_annotations.model_annotations.entities = {{"github", 1}}; - visit5.content_annotations.model_annotations.categories = {{"category", 1}, - {"category2", 1}}; + visit5.content_annotations.model_annotations.entities = {{"github", 100}}; + visit5.content_annotations.model_annotations.categories = { + {"category", 100}, {"category2", 100}}; visit5.referring_visit_of_redirect_chain_start = 6; visits.push_back(visit5); @@ -472,8 +476,8 @@ // visits by visit ID. history::AnnotatedVisit visit = testing::CreateDefaultAnnotatedVisit(1, GURL("https://github.com/")); - visit.content_annotations.model_annotations.entities = {{"github", 1}}; - visit.content_annotations.model_annotations.categories = {{"category", 1}}; + visit.content_annotations.model_annotations.entities = {{"github", 100}}; + visit.content_annotations.model_annotations.categories = {{"category", 100}}; visits.push_back(visit); history::AnnotatedVisit visit2 = @@ -489,15 +493,15 @@ // title. history::AnnotatedVisit visit4 = testing::CreateDefaultAnnotatedVisit(4, GURL("https://github.com/")); - visit4.content_annotations.model_annotations.entities = {{"github", 1}}; - visit4.content_annotations.model_annotations.categories = {{"category", 1}}; + visit4.content_annotations.model_annotations.entities = {{"github", 100}}; + visit4.content_annotations.model_annotations.categories = {{"category", 100}}; visits.push_back(visit4); // This visit has a different title and shouldn't be grouped with the others. history::AnnotatedVisit visit5 = testing::CreateDefaultAnnotatedVisit( 10, GURL("https://nonexistentreferrer.com/")); visit5.referring_visit_of_redirect_chain_start = 6; - visit5.content_annotations.model_annotations.entities = {{"irrelevant", 1}}; + visit5.content_annotations.model_annotations.entities = {{"irrelevant", 100}}; visits.push_back(visit5); std::vector<history::Cluster> result_clusters = @@ -556,8 +560,9 @@ history::AnnotatedVisit visit2 = testing::CreateDefaultAnnotatedVisit( 2, GURL("http://default-engine.com/?q=foo")); visit2.content_annotations.model_annotations.entities = { - history::VisitContentModelAnnotations::Category("foo", 50), - history::VisitContentModelAnnotations::Category("nometadata", 30), + history::VisitContentModelAnnotations::Category("foo", 70), + history::VisitContentModelAnnotations::Category("nometadata", 100), + history::VisitContentModelAnnotations::Category("toolow", 1), }; visit2.content_annotations.model_annotations.visibility_score = 0.5; visits.push_back(visit2); @@ -565,7 +570,7 @@ history::AnnotatedVisit visit3 = testing::CreateDefaultAnnotatedVisit( 3, GURL("http://non-default-engine.com/?q=nometadata#whatever")); visit3.content_annotations.model_annotations.entities = { - history::VisitContentModelAnnotations::Category("nometadata", 30), + history::VisitContentModelAnnotations::Category("nometadata", 100), }; visit3.content_annotations.search_terms = u"nometadata"; visit3.content_annotations.search_normalized_url = @@ -600,6 +605,7 @@ .categories; ASSERT_EQ(categories.size(), 1u); EXPECT_EQ(categories.at(0).id, "category-foo"); + EXPECT_EQ(categories.at(0).weight, /*70*0.6=*/42); EXPECT_THAT(better_visit.annotated_visit.content_annotations.model_annotations .visibility_score, FloatEq(0.5));
diff --git a/components/infobars/android/java/src/org/chromium/components/infobars/InfoBarControlLayout.java b/components/infobars/android/java/src/org/chromium/components/infobars/InfoBarControlLayout.java index c0b931d..d48ed9ba 100644 --- a/components/infobars/android/java/src/org/chromium/components/infobars/InfoBarControlLayout.java +++ b/components/infobars/android/java/src/org/chromium/components/infobars/InfoBarControlLayout.java
@@ -11,6 +11,7 @@ import android.text.method.LinkMovementMethod; import android.util.AttributeSet; import android.util.TypedValue; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -27,6 +28,7 @@ import org.chromium.base.StrictModeContext; import org.chromium.components.browser_ui.widget.DualControlLayout; import org.chromium.components.browser_ui.widget.RadioButtonLayout; +import org.chromium.ui.widget.ChromeImageView; import java.util.List; @@ -293,6 +295,28 @@ } /** + * Adds a center justified image. + * + * ----------------------------------------------------- + * | IMAGE | + * ----------------------------------------------------- + * + * @param imageResourceId Resource ID of the image. + */ + public View addLeadImage(int imageResourceId) { + ChromeImageView imageView = new ChromeImageView(getContext()); + LinearLayout.LayoutParams lp = + new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); + lp.gravity = Gravity.CENTER; + imageView.setLayoutParams(lp); + + addView(imageView, new ControlLayoutParams()); + imageView.setImageResource(imageResourceId); + + return imageView; + } + + /** * Adds an icon with a descriptive message to the Title. * * -----------------------------------------------------
diff --git a/components/invalidation/impl/invalidator_registrar_with_memory.cc b/components/invalidation/impl/invalidator_registrar_with_memory.cc index 2c12ed3..eee48637 100644 --- a/components/invalidation/impl/invalidator_registrar_with_memory.cc +++ b/components/invalidation/impl/invalidator_registrar_with_memory.cc
@@ -196,13 +196,17 @@ DictionaryPrefUpdate update(prefs_, kTopicsToHandler); base::Value* pref_data = update->FindDictKey(sender_id_); - // TODO(crbug.com/1020117): This does currently *not* remove subscribed - // topics which are not registered, but it almost certainly should. It - // requires GetOwnerName() to return unique value for each handler, which is - // currently not the case for CloudPolicyInvalidator (see crbug.com/1049591). + + // This does *not* remove subscribed topics which are not registered. This + // behaviour is used by some handlers to keep topic subscriptions after + // browser startup even if they are not included in the first call of this + // method. It's useful to prevent unsubscribing from and subscribing to the + // topics on each browser startup. + // + // TODO(crbug.com/1051893): make the unsubscription behaviour consistent + // regardless of browser restart in between. auto to_unregister = base::STLSetDifference<std::set<TopicData>>(old_topics, topics); - ; for (const auto& topic : to_unregister) { pref_data->RemoveKey(topic.name); handler_name_to_subscribed_topics_map_[handler->GetOwnerName()].erase(
diff --git a/components/invalidation/impl/invalidator_registrar_with_memory.h b/components/invalidation/impl/invalidator_registrar_with_memory.h index 4fda4c0..5896cac 100644 --- a/components/invalidation/impl/invalidator_registrar_with_memory.h +++ b/components/invalidation/impl/invalidator_registrar_with_memory.h
@@ -58,12 +58,14 @@ // topics associated with |handler| from the server. void UnregisterHandler(InvalidationHandler* handler); - // Updates the set of topics associated with |handler|. |handler| must - // not be nullptr, and must already be registered. A topic must be registered - // for at most one handler. If any of the |topics| is already registered - // to a different handler, returns false. - // Note that this also updates the *subscribed* topics - assuming that whoever - // called this will also send (un)subscription requests to the server. + // Updates the set of topics associated with |handler|. |handler| must not be + // nullptr, and must already be registered. A topic must be registered for at + // most one handler. If any of the |topics| is already registered to a + // different handler, returns false. Note that this also updates the + // *subscribed* topics - assuming that whoever called this will also send + // (un)subscription requests to the server. However, this method does *not* + // unsubscribe from the topics which were not registered since browser + // startup. [[nodiscard]] bool UpdateRegisteredTopics(InvalidationHandler* handler, const std::set<TopicData>& topics);
diff --git a/components/invalidation/impl/invalidator_registrar_with_memory_unittest.cc b/components/invalidation/impl/invalidator_registrar_with_memory_unittest.cc index 24b020f3..8299432 100644 --- a/components/invalidation/impl/invalidator_registrar_with_memory_unittest.cc +++ b/components/invalidation/impl/invalidator_registrar_with_memory_unittest.cc
@@ -15,12 +15,19 @@ #include "components/invalidation/public/invalidator_state.h" #include "components/invalidation/public/topic_invalidation_map.h" #include "components/prefs/testing_pref_service.h" +#include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +using testing::IsEmpty; +using testing::Pair; +using testing::UnorderedElementsAre; + namespace invalidation { namespace { +constexpr char kTopicsToHandler[] = "invalidation.per_sender_topics_to_handler"; + // Initialize the invalidator, register a handler, register some topics for that // handler, and then unregister the handler, dispatching invalidations in // between. The handler should only see invalidations when it's registered and @@ -247,9 +254,6 @@ } TEST(InvalidatorRegistrarWithMemoryTest, RestoresInterestingTopics) { - constexpr char kTopicsToHandler[] = - "invalidation.per_sender_topics_to_handler"; - const base::Feature restore_interesting_topics_feature{ "InvalidatorRestoreInterestingTopics", base::FEATURE_ENABLED_BY_DEFAULT}; base::test::ScopedFeatureList feature_list; @@ -290,9 +294,6 @@ TEST(InvalidatorRegistrarWithMemoryTest, ClearsTopicsWithObsoleteOwnerNamesWhenPrefIsEmpty) { - constexpr char kTopicsToHandler[] = - "invalidation.per_sender_topics_to_handler"; - TestingPrefServiceSimple pref_service; InvalidatorRegistrarWithMemory::RegisterProfilePrefs(pref_service.registry()); ASSERT_EQ(base::Value(base::Value::Type::DICTIONARY), @@ -362,6 +363,72 @@ EXPECT_EQ(*expected_stored_topics.value, *pref_service.Get(kTopicsToHandler)); } +// This test verifies that topics are not unsubscribed after browser restart +// even if it's not registered using UpdateRegisteredTopics() method. This is +// useful for Sync invalidations to prevent unsubscribing from some data types +// which require more time to initialize and which are added later in following +// UpdateRegisteredTopics() calls. +// +// TODO(crbug.com/1051893): make the unsubscription behaviour consistent +// regardless of browser restart in between. +TEST(InvalidatorRegistrarWithMemoryTest, ShouldKeepSubscriptionsAfterRestart) { + const TopicData kTopic1(/*name=*/"topic_1", /*is_public=*/true); + const TopicData kTopic2(/*name=*/"topic_2", /*is_public=*/true); + + TestingPrefServiceSimple pref_service; + InvalidatorRegistrarWithMemory::RegisterProfilePrefs(pref_service.registry()); + + // Set up some previously-registered topics in the pref. + constexpr char kStoredTopicsJson[] = + R"({"sender_id": { + "topic_1": {"handler": "handler", "is_public": true}, + "topic_2": {"handler": "handler", "is_public": true} + }})"; + + auto stored_topics = + base::JSONReader::ReadAndReturnValueWithError(kStoredTopicsJson); + ASSERT_TRUE(stored_topics.value) << stored_topics.error_message; + pref_service.Set(kTopicsToHandler, std::move(*stored_topics.value)); + + auto invalidator = std::make_unique<InvalidatorRegistrarWithMemory>( + &pref_service, "sender_id", /*migrate_old_prefs=*/false); + FakeInvalidationHandler handler("handler"); + invalidator->RegisterHandler(&handler); + + // Verify that all topics are successfully subscribed but not registered by + // the |handler|. + ASSERT_THAT(invalidator->GetRegisteredTopics(&handler), IsEmpty()); + ASSERT_THAT(invalidator->GetAllSubscribedTopics(), + UnorderedElementsAre( + Pair(kTopic1.name, TopicMetadata{kTopic1.is_public}), + Pair(kTopic2.name, TopicMetadata{kTopic2.is_public}))); + + // Register fo only one topic, but the previous subscriptions to other topics + // should be kept. + ASSERT_TRUE(invalidator->UpdateRegisteredTopics(&handler, {kTopic1})); + EXPECT_THAT(invalidator->GetRegisteredTopics(&handler), + UnorderedElementsAre( + Pair(kTopic1.name, TopicMetadata{kTopic1.is_public}))); + EXPECT_THAT(invalidator->GetAllSubscribedTopics(), + UnorderedElementsAre( + Pair(kTopic1.name, TopicMetadata{kTopic1.is_public}), + Pair(kTopic2.name, TopicMetadata{kTopic2.is_public}))); + + // To unsubscribe from the topics which were added before browser restart, the + // handler needs to explicitly register this topic, then unregister again. + ASSERT_TRUE( + invalidator->UpdateRegisteredTopics(&handler, {kTopic1, kTopic2})); + ASSERT_TRUE(invalidator->UpdateRegisteredTopics(&handler, {kTopic1})); + EXPECT_THAT(invalidator->GetRegisteredTopics(&handler), + UnorderedElementsAre( + Pair(kTopic1.name, TopicMetadata{kTopic1.is_public}))); + EXPECT_THAT(invalidator->GetAllSubscribedTopics(), + UnorderedElementsAre( + Pair(kTopic1.name, TopicMetadata{kTopic1.is_public}))); + + invalidator->UnregisterHandler(&handler); +} + } // namespace } // namespace invalidation
diff --git a/components/os_crypt/key_storage_util_linux.cc b/components/os_crypt/key_storage_util_linux.cc index 16e9f9d5d..b11eac5 100644 --- a/components/os_crypt/key_storage_util_linux.cc +++ b/components/os_crypt/key_storage_util_linux.cc
@@ -61,6 +61,7 @@ case base::nix::DESKTOP_ENVIRONMENT_CINNAMON: case base::nix::DESKTOP_ENVIRONMENT_GNOME: case base::nix::DESKTOP_ENVIRONMENT_PANTHEON: + case base::nix::DESKTOP_ENVIRONMENT_UKUI: case base::nix::DESKTOP_ENVIRONMENT_UNITY: case base::nix::DESKTOP_ENVIRONMENT_XFCE: return SelectedLinuxBackend::GNOME_ANY;
diff --git a/components/permissions/contexts/sensor_permission_context.cc b/components/permissions/contexts/sensor_permission_context.cc index 960ec4c3..50cf295 100644 --- a/components/permissions/contexts/sensor_permission_context.cc +++ b/components/permissions/contexts/sensor_permission_context.cc
@@ -22,10 +22,9 @@ SensorPermissionContext::~SensorPermissionContext() {} -void SensorPermissionContext::UpdateTabContext( - const permissions::PermissionRequestID& id, - const GURL& requesting_frame, - bool allowed) { +void SensorPermissionContext::UpdateTabContext(const PermissionRequestID& id, + const GURL& requesting_frame, + bool allowed) { auto* content_settings = content_settings::PageSpecificContentSettings::GetForFrame( id.render_process_id(), id.render_frame_id());
diff --git a/components/policy/resources/policy_templates.json b/components/policy/resources/policy_templates.json index 0ca85666..20afada 100644 --- a/components/policy/resources/policy_templates.json +++ b/components/policy/resources/policy_templates.json
@@ -10008,6 +10008,8 @@ 'tags': [], 'desc': '''Setting the policy allows merging of selected policies when they come from different sources, with the same scopes and level. + Use the wildcard character '*' to allow merging of all list policies. + If a policy is in the list and there's conflict between sources with: * The same scopes and level: The values merge into a new policy list. @@ -10077,6 +10079,8 @@ 'tags': [], 'desc': '''Setting the policy allows merging of selected policies when they come from different sources, with the same scopes and level. This merging is in the first level keys of the dictionary from each source. The key coming from the highest priority source takes precedence. + Use the wildcard character '*' to allow merging of all supported dictionary policies. + If a policy is in the list and there's conflict between sources with: * The same scopes and level: The values merge into a new policy dictionary.
diff --git a/components/safe_browsing/content/browser/threat_details.cc b/components/safe_browsing/content/browser/threat_details.cc index 90f855d..2c53361 100644 --- a/components/safe_browsing/content/browser/threat_details.cc +++ b/components/safe_browsing/content/browser/threat_details.cc
@@ -37,7 +37,6 @@ #include "content/public/browser/back_forward_cache.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/global_routing_id.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/render_frame_host.h" @@ -48,7 +47,6 @@ using content::BrowserThread; using content::NavigationEntry; -using content::RenderFrameHost; using content::WebContents; // Keep in sync with KMaxNodes in components/safe_browsing/content/renderer/ @@ -390,8 +388,8 @@ ReferrerChainProvider* referrer_chain_provider, bool trim_to_ad_tags, ThreatDetailsDoneCallback done_callback) - : content::WebContentsObserver(web_contents), - url_loader_factory_(url_loader_factory), + : url_loader_factory_(url_loader_factory), + web_contents_(web_contents), ui_manager_(ui_manager), browser_context_(web_contents->GetBrowserContext()), resource_(resource), @@ -645,7 +643,7 @@ // OnReceivedThreatDOMDetails will be called when the renderer replies. // TODO(mattm): In theory, if the user proceeds through the warning DOM // detail collection could be started once the page loads. - web_contents()->GetMainFrame()->ForEachRenderFrameHost(base::BindRepeating( + web_contents_->GetMainFrame()->ForEachRenderFrameHost(base::BindRepeating( &ThreatDetails::RequestThreatDOMDetails, GetWeakPtr())); } } @@ -668,34 +666,26 @@ threat_reporter.BindNewPipeAndPassReceiver()); safe_browsing::mojom::ThreatReporter* raw_threat_report = threat_reporter.get(); - pending_render_frame_hosts_.push_back(frame); raw_threat_report->GetThreatDOMDetails( base::BindOnce(&ThreatDetails::OnReceivedThreatDOMDetails, GetWeakPtr(), - std::move(threat_reporter), frame->GetGlobalId())); + std::move(threat_reporter), frame->GetWeakDocumentPtr())); } // When the renderer is done, this is called. void ThreatDetails::OnReceivedThreatDOMDetails( mojo::Remote<mojom::ThreatReporter> threat_reporter, - content::GlobalRenderFrameHostId sender_id, + content::WeakDocumentPtr sender, std::vector<mojom::ThreatDOMDetailsNodePtr> params) { // If the RenderFrameHost was closed between sending the IPC and this callback // running, |sender| will be invalid. - auto* sender = content::RenderFrameHost::FromID(sender_id); - if (!sender) { + auto* sender_rfh = sender.AsRenderFrameHostIfValid(); + if (!sender_rfh) { return; } - const auto sender_it = std::find(pending_render_frame_hosts_.begin(), - pending_render_frame_hosts_.end(), sender); - if (sender_it == pending_render_frame_hosts_.end()) { - return; - } - - pending_render_frame_hosts_.erase(sender_it); // Lookup the FrameTreeNode ID of any child frames in the list of DOM nodes. - const int sender_process_id = sender->GetProcess()->GetID(); - const int sender_frame_tree_node_id = sender->GetFrameTreeNodeId(); + const int sender_process_id = sender_rfh->GetProcess()->GetID(); + const int sender_frame_tree_node_id = sender_rfh->GetFrameTreeNodeId(); KeyToFrameTreeIdMap child_frame_tree_map; for (const mojom::ThreatDOMDetailsNodePtr& node : params) { if (node->child_frame_routing_id == 0) @@ -900,7 +890,7 @@ // We would have cancelled a prerender if it was blocked, so we can use the // primary main frame here. referrer_chain_provider_->IdentifyReferrerChainByRenderFrameHost( - web_contents()->GetMainFrame(), kThreatDetailsUserGestureLimit, + web_contents_->GetMainFrame(), kThreatDetailsUserGestureLimit, report_->mutable_referrer_chain()); } @@ -908,16 +898,7 @@ is_all_done_ = true; content::GetUIThreadTaskRunner({})->PostTask( FROM_HERE, base::BindOnce(std::move(done_callback_), - base::Unretained(web_contents()))); -} - -void ThreatDetails::RenderFrameDeleted(RenderFrameHost* render_frame_host) { - base::Erase(pending_render_frame_hosts_, render_frame_host); -} - -void ThreatDetails::RenderFrameHostChanged(RenderFrameHost* old_host, - RenderFrameHost* new_host) { - base::Erase(pending_render_frame_hosts_, old_host); + base::Unretained(web_contents_))); } base::WeakPtr<ThreatDetails> ThreatDetails::GetWeakPtr() {
diff --git a/components/safe_browsing/content/browser/threat_details.h b/components/safe_browsing/content/browser/threat_details.h index 29932811d..cbfde100 100644 --- a/components/safe_browsing/content/browser/threat_details.h +++ b/components/safe_browsing/content/browser/threat_details.h
@@ -24,10 +24,14 @@ #include "components/safe_browsing/core/common/proto/csd.pb.h" #include "components/security_interstitials/core/unsafe_resource.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/global_routing_id.h" -#include "content/public/browser/web_contents_observer.h" +#include "content/public/browser/weak_document_ptr.h" #include "mojo/public/cpp/bindings/remote.h" +namespace content { +class BrowserContext; +class WebContents; +} // namespace content + namespace history { class HistoryService; } // namespace history @@ -71,14 +75,14 @@ using ThreatDetailsDoneCallback = base::OnceCallback<void(content::WebContents*)>; -class ThreatDetails : public content::WebContentsObserver { +class ThreatDetails { public: typedef security_interstitials::UnsafeResource UnsafeResource; ThreatDetails(const ThreatDetails&) = delete; ThreatDetails& operator=(const ThreatDetails&) = delete; - ~ThreatDetails() override; + virtual ~ThreatDetails(); // Constructs a new ThreatDetails instance, using the factory. static std::unique_ptr<ThreatDetails> NewThreatDetails( @@ -112,11 +116,6 @@ // Overridden during tests virtual void OnRedirectionCollectionReady(); - // WebContentsObserver implementation: - void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; - void RenderFrameHostChanged(content::RenderFrameHost* old_host, - content::RenderFrameHost* new_host) override; - base::WeakPtr<ThreatDetails> GetWeakPtr(); protected: @@ -178,7 +177,7 @@ void OnReceivedThreatDOMDetails( mojo::Remote<mojom::ThreatReporter> threat_reporter, - content::GlobalRenderFrameHostId sender_id, + content::WeakDocumentPtr sender, std::vector<mojom::ThreatDOMDetailsNodePtr> params); void AddRedirectUrlList(const std::vector<GURL>& urls); @@ -206,6 +205,10 @@ // Called when the report is complete. Runs |done_callback_|. void AllDone(); + // `this` is owned by TriggerManager which prevents this from outliving + // the WebContents. + raw_ptr<content::WebContents> web_contents_ = nullptr; + scoped_refptr<BaseUIManager> ui_manager_; raw_ptr<content::BrowserContext> browser_context_; @@ -278,10 +281,6 @@ // Whether the |done_callback_| has been invoked. bool is_all_done_; - // The set of RenderFrameHosts that have pending requests and haven't been - // deleted. - std::vector<content::RenderFrameHost*> pending_render_frame_hosts_; - // Used for references to |this| bound in callbacks. base::WeakPtrFactory<ThreatDetails> weak_factory_{this};
diff --git a/components/services/app_service/public/cpp/shortcut.cc b/components/services/app_service/public/cpp/shortcut.cc index 88c1550..bb2f14f6 100644 --- a/components/services/app_service/public/cpp/shortcut.cc +++ b/components/services/app_service/public/cpp/shortcut.cc
@@ -33,8 +33,8 @@ std::string Shortcut::ToString() const { std::stringstream out; out << "shortcut_id: " << shortcut_id << std::endl; - out << "name: " << name << std::endl; - out << "position: " << position << std::endl; + out << "- name: " << name << std::endl; + out << "- position: " << position << std::endl; return out.str(); }
diff --git a/components/services/app_service/public/cpp/shortcut.h b/components/services/app_service/public/cpp/shortcut.h index 4467bab..04d1b1e 100644 --- a/components/services/app_service/public/cpp/shortcut.h +++ b/components/services/app_service/public/cpp/shortcut.h
@@ -34,8 +34,8 @@ // Example output: // // shortcut_id: 2 - // shortcut_name: Launch - // position: 0 + // - shortcut_name: Launch + // - position: 0 std::string ToString() const; // Represents a particular shortcut in an app. Needs to be unique within an
diff --git a/components/signin/public/identity_manager/account_capabilities.cc b/components/signin/public/identity_manager/account_capabilities.cc index 3ee661a..9a224dff 100644 --- a/components/signin/public/identity_manager/account_capabilities.cc +++ b/components/signin/public/identity_manager/account_capabilities.cc
@@ -32,11 +32,11 @@ // static const std::vector<std::string>& AccountCapabilities::GetSupportedAccountCapabilityNames() { - static base::NoDestructor<std::vector<std::string>> kCapabilityNames({ + static base::NoDestructor<std::vector<std::string>> kCapabilityNames{{ #define ACCOUNT_CAPABILITY(cpp_label, java_label, value) cpp_label, #include "components/signin/internal/identity_manager/account_capabilities_list.h" #undef ACCOUNT_CAPABILITY - }); + }}; return *kCapabilityNames; }
diff --git a/content/browser/back_forward_cache_browsertest.cc b/content/browser/back_forward_cache_browsertest.cc index cf3b0e7..c9d3d21 100644 --- a/content/browser/back_forward_cache_browsertest.cc +++ b/content/browser/back_forward_cache_browsertest.cc
@@ -141,6 +141,11 @@ } } +void BackForwardCacheBrowserTest::NotifyNotRestoredReasons( + std::unique_ptr<BackForwardCacheCanStoreTreeResult> tree_result) { + tree_result_ = std::move(tree_result); +} + // Disables checking metrics that are recorded recardless of the domains. By // default, this class' Expect* function checks the metrics both for the // specific domain and for all domains at the same time. In the case when the @@ -2507,7 +2512,8 @@ } // Verifies that the reasons match those given and no others. -testing::Matcher<BackForwardCacheCanStoreDocumentResult> MatchesDocumentResult( +testing::Matcher<BackForwardCacheCanStoreDocumentResult> +BackForwardCacheBrowserTest::MatchesDocumentResult( testing::Matcher<NotStoredReasons> not_stored, BlockListedFeatures block_listed) { return testing::AllOf( @@ -2530,7 +2536,7 @@ } // Check the contents of the BackForwardCacheCanStoreTreeResult of a page. -IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, TreeResult1) { +IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, TreeResultFeatureUsage) { ASSERT_TRUE(embedded_test_server()->Start()); GURL url_a(embedded_test_server()->GetURL( "a.com", "/cross_site_iframe_factory.html?a(a, b, c)")); @@ -2604,6 +2610,115 @@ BlockListedFeatures(BlockListedFeatures()))); } +// Check the contents of the BackForwardCacheCanStoreTreeResult of a page when +// it is evicted. +IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, + TreeResultEvictionMainFrame) { + ASSERT_TRUE(embedded_test_server()->Start()); + GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); + GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html")); + + // 1) Navigate to a. + ASSERT_TRUE(NavigateToURL(shell(), url_a)); + RenderFrameHostImplWrapper rfh_a(current_frame_host()); + rfh_a->GetBackForwardCacheMetrics()->SetObserverForTesting(this); + + // 2) Navigate to B and evict A by JavaScript execution. + ASSERT_TRUE(NavigateToURL(shell(), url_b)); + EvictByJavaScript(rfh_a.get()); + ASSERT_TRUE(rfh_a.WaitUntilRenderFrameDeleted()); + + // 3) Go back to A. + ASSERT_TRUE(HistoryGoBack(web_contents())); + ExpectNotRestored({NotRestoredReason::kJavaScriptExecution}, {}, {}, {}, {}, + FROM_HERE); + EXPECT_THAT(GetTreeResult()->GetDocumentResult(), + MatchesDocumentResult( + NotStoredReasons(NotRestoredReason::kJavaScriptExecution), + BlockListedFeatures())); +} + +// Check the contents of the BackForwardCacheCanStoreTreeResult of a page when +// its subframe is evicted. +IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, + TreeResultEvictionSubFrame) { + ASSERT_TRUE(embedded_test_server()->Start()); + GURL url_a(embedded_test_server()->GetURL( + "a.com", "/cross_site_iframe_factory.html?a(b)")); + GURL url_c(embedded_test_server()->GetURL("c.com", "/title1.html")); + + // 1) Navigate to A. + ASSERT_TRUE(NavigateToURL(shell(), url_a)); + RenderFrameHostImplWrapper rfh_a(current_frame_host()); + RenderFrameHostImplWrapper rfh_b( + current_frame_host()->child_at(0)->current_frame_host()); + rfh_a->GetBackForwardCacheMetrics()->SetObserverForTesting(this); + + // 2) Navigate to C and evict A's subframe B by JavaScript execution. + ASSERT_TRUE(NavigateToURL(shell(), url_c)); + EvictByJavaScript(rfh_b.get()); + ASSERT_TRUE(rfh_a.WaitUntilRenderFrameDeleted()); + + // 3) Go back to A. + ASSERT_TRUE(HistoryGoBack(web_contents())); + ExpectNotRestored({NotRestoredReason::kJavaScriptExecution}, {}, {}, {}, {}, + FROM_HERE); + // Main frame result in the tree is empty. + EXPECT_THAT(GetTreeResult()->GetDocumentResult(), + MatchesDocumentResult(NotStoredReasons(), BlockListedFeatures())); + // Subframe result in the tree contains the reason. + EXPECT_THAT(GetTreeResult()->GetChildren().at(0)->GetDocumentResult(), + MatchesDocumentResult( + NotStoredReasons(NotRestoredReason::kJavaScriptExecution), + BlockListedFeatures())); +} + +// Check the contents of the BackForwardCacheCanStoreTreeResult of a page when +// its subframe's subframe is evicted. +IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, + TreeResultEvictionSubFramesSubframe) { + ASSERT_TRUE(embedded_test_server()->Start()); + GURL url_a(embedded_test_server()->GetURL( + "a.com", "/cross_site_iframe_factory.html?a(b(c))")); + GURL url_d(embedded_test_server()->GetURL("d.com", "/title1.html")); + + // 1) Navigate to A. + ASSERT_TRUE(NavigateToURL(shell(), url_a)); + RenderFrameHostImplWrapper rfh_a(current_frame_host()); + RenderFrameHostImplWrapper rfh_c(current_frame_host() + ->child_at(0) + ->current_frame_host() + ->child_at(0) + ->current_frame_host()); + rfh_a->GetBackForwardCacheMetrics()->SetObserverForTesting(this); + + // 2) Navigate to D and evict C by JavaScript execution. + ASSERT_TRUE(NavigateToURL(shell(), url_d)); + EvictByJavaScript(rfh_c.get()); + ASSERT_TRUE(rfh_a.WaitUntilRenderFrameDeleted()); + + // 3) Go back to A. + ASSERT_TRUE(HistoryGoBack(web_contents())); + ExpectNotRestored({NotRestoredReason::kJavaScriptExecution}, {}, {}, {}, {}, + FROM_HERE); + // Main frame result in the tree is empty. + EXPECT_THAT(GetTreeResult()->GetDocumentResult(), + MatchesDocumentResult(NotStoredReasons(), BlockListedFeatures())); + // The first level subframe result in the tree is empty. + EXPECT_THAT(GetTreeResult()->GetChildren().at(0)->GetDocumentResult(), + MatchesDocumentResult(NotStoredReasons(), BlockListedFeatures())); + // The second level subframe result in the tree contains the reason. + EXPECT_THAT(GetTreeResult() + ->GetChildren() + .at(0) + ->GetChildren() + .at(0) + ->GetDocumentResult(), + MatchesDocumentResult( + NotStoredReasons(NotRestoredReason::kJavaScriptExecution), + BlockListedFeatures())); +} + class BackForwardCacheOptInBrowserTest : public BackForwardCacheBrowserTest { protected: void SetUpCommandLine(base::CommandLine* command_line) override {
diff --git a/content/browser/back_forward_cache_browsertest.h b/content/browser/back_forward_cache_browsertest.h index 17e3c7ae..ea7ec12 100644 --- a/content/browser/back_forward_cache_browsertest.h +++ b/content/browser/back_forward_cache_browsertest.h
@@ -24,6 +24,10 @@ namespace content { +using NotStoredReasons = + BackForwardCacheCanStoreDocumentResult::NotStoredReasons; +using NotRestoredReason = BackForwardCacheMetrics::NotRestoredReason; + // Match RenderFrameHostImpl* that are in the BackForwardCache. MATCHER(InBackForwardCache, "") { return arg->IsInBackForwardCache(); @@ -58,12 +62,18 @@ } // namespace // Test about the BackForwardCache. -class BackForwardCacheBrowserTest : public ContentBrowserTest, - public WebContentsObserver { +class BackForwardCacheBrowserTest + : public ContentBrowserTest, + public WebContentsObserver, + public BackForwardCacheMetrics::TestObserver { public: BackForwardCacheBrowserTest(); ~BackForwardCacheBrowserTest() override; + // TestObserver: + void NotifyNotRestoredReasons( + std::unique_ptr<BackForwardCacheCanStoreTreeResult> tree_result) override; + protected: using UkmMetrics = ukm::TestUkmRecorder::HumanReadableUkmMetrics; @@ -172,6 +182,16 @@ // assert that the URL after navigation is |url|. void NavigateAndBlock(GURL url, int history_offset); + static testing::Matcher<BackForwardCacheCanStoreDocumentResult> + MatchesDocumentResult(testing::Matcher<NotStoredReasons> not_stored, + BlockListedFeatures block_listed); + + // Access the tree result of NotRestoredReason for the last main frame + // navigation. + BackForwardCacheCanStoreTreeResult* GetTreeResult() { + return tree_result_.get(); + } + base::HistogramTester histogram_tester_; bool same_site_back_forward_cache_enabled_ = true; @@ -242,6 +262,10 @@ std::vector<UkmMetrics> expected_ukm_not_restored_reasons_; std::unique_ptr<ukm::TestAutoSetUkmRecorder> ukm_recorder_; + // Store the tree result of NotRestoredReasons for the last main frame + // navigation. + std::unique_ptr<BackForwardCacheCanStoreTreeResult> tree_result_; + // Indicates whether metrics for all sites regardless of the domains are // checked or not. bool check_all_sites_ = true;
diff --git a/content/browser/back_forward_cache_internal_browsertest.cc b/content/browser/back_forward_cache_internal_browsertest.cc index cd7ac6e..864ec06 100644 --- a/content/browser/back_forward_cache_internal_browsertest.cc +++ b/content/browser/back_forward_cache_internal_browsertest.cc
@@ -757,35 +757,39 @@ // 1) Navigate to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); - RenderFrameHostImpl* rfh_a = current_frame_host(); + RenderFrameHostImplWrapper rfh_a(current_frame_host()); + rfh_a->GetBackForwardCacheMetrics()->SetObserverForTesting(this); - ExecuteScriptAsync(rfh_a, R"( + ExecuteScriptAsync(rfh_a.get(), R"( let i = 0; while (true) { i++; } )"); - RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); - RenderProcessHost* process = rfh_a->GetProcess(); + RenderProcessHost* process = rfh_a.get()->GetProcess(); RenderProcessHostWatcher destruction_observer( process, RenderProcessHostWatcher::WATCH_FOR_HOST_DESTRUCTION); // 2) Navigate to B. EXPECT_TRUE(NavigateToURL(shell(), url_b)); - RenderFrameHostImpl* rfh_b = current_frame_host(); - RenderFrameDeletedObserver delete_observer_rfh_b(rfh_b); + RenderFrameHostImplWrapper rfh_b(current_frame_host()); // rfh_a should be destroyed (not kept in the cache). destruction_observer.Wait(); - delete_observer_rfh_a.WaitUntilDeleted(); + EXPECT_TRUE(rfh_a.WaitUntilRenderFrameDeleted()); // rfh_b should still be the current frame. - EXPECT_EQ(current_frame_host(), rfh_b); - EXPECT_FALSE(delete_observer_rfh_b.deleted()); + EXPECT_EQ(current_frame_host(), rfh_b.get()); // 3) Go back to A. ASSERT_TRUE(HistoryGoBack(web_contents())); ExpectNotRestored({NotRestoredReason::kTimeoutPuttingInCache}, {}, {}, {}, {}, FROM_HERE); + + // Make sure that the tree reasons match the flattened reasons. + EXPECT_THAT(GetTreeResult()->GetDocumentResult(), + MatchesDocumentResult( + NotStoredReasons(NotRestoredReason::kTimeoutPuttingInCache), + BlockListedFeatures())); } // Test the race condition where a document is evicted from the BackForwardCache @@ -1166,12 +1170,13 @@ // 1) Navigate to A. EXPECT_TRUE(NavigateToURL(shell(), url_a)); - RenderFrameHostImpl* rfh_a = current_frame_host(); - RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a); + RenderFrameHostImplWrapper rfh_a(current_frame_host()); + RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a.get()); + rfh_a->GetBackForwardCacheMetrics()->SetObserverForTesting(this); // 2) Navigate to B. EXPECT_TRUE(NavigateToURL(shell(), url_b)); - RenderFrameHostImpl* rfh_b = current_frame_host(); + RenderFrameHostImplWrapper rfh_b(current_frame_host()); // 3) Fast forward to just before eviction is due. task_runner->FastForwardBy(time_to_live_in_back_forward_cache - delta); @@ -1185,11 +1190,16 @@ // 6) Confirm A is evicted. delete_observer_rfh_a.WaitUntilDeleted(); - EXPECT_EQ(current_frame_host(), rfh_b); + EXPECT_EQ(current_frame_host(), rfh_b.get()); // 7) Go back to A. ASSERT_TRUE(HistoryGoBack(web_contents())); ExpectNotRestored({NotRestoredReason::kTimeout}, {}, {}, {}, {}, FROM_HERE); + // Make sure that the tree reasons match the flattened reasons. + EXPECT_THAT( + GetTreeResult()->GetDocumentResult(), + MatchesDocumentResult(NotStoredReasons(NotRestoredReason::kTimeout), + BlockListedFeatures())); } IN_PROC_BROWSER_TEST_F(
diff --git a/content/browser/compute_pressure/OWNERS b/content/browser/compute_pressure/OWNERS index 8de7804..af6d84b 100644 --- a/content/browser/compute_pressure/OWNERS +++ b/content/browser/compute_pressure/OWNERS
@@ -1,5 +1,6 @@ # Primary pwnall@chromium.org +raphael.kubo.da.costa@intel.com # Secondary jsbell@chromium.org
diff --git a/content/browser/file_system_access/file_system_access_directory_handle_impl.cc b/content/browser/file_system_access/file_system_access_directory_handle_impl.cc index 56863d5..eb91c33 100644 --- a/content/browser/file_system_access/file_system_access_directory_handle_impl.cc +++ b/content/browser/file_system_access/file_system_access_directory_handle_impl.cc
@@ -528,6 +528,10 @@ *result = file_system_context()->CreateCrackedFileSystemURL( parent.storage_key(), parent.mount_type(), parent.virtual_path().Append(base::FilePath::FromUTF8Unsafe(basename))); + // Child URLs inherit their parent's storage bucket. + if (parent.bucket()) { + result->SetBucket(parent.bucket().value()); + } return file_system_access_error::Ok(); }
diff --git a/content/browser/file_system_access/file_system_access_directory_handle_impl_unittest.cc b/content/browser/file_system_access/file_system_access_directory_handle_impl_unittest.cc index aeeb3d8..0462cc6 100644 --- a/content/browser/file_system_access/file_system_access_directory_handle_impl_unittest.cc +++ b/content/browser/file_system_access/file_system_access_directory_handle_impl_unittest.cc
@@ -16,6 +16,7 @@ #include "base/test/bind.h" #include "base/test/task_environment.h" #include "build/build_config.h" +#include "components/services/storage/public/cpp/buckets/bucket_locator.h" #include "content/browser/file_system_access/file_system_access_write_lock_manager.h" #include "content/browser/file_system_access/fixed_file_system_access_permission_grant.h" #include "content/public/test/browser_task_environment.h" @@ -25,6 +26,7 @@ #include "storage/common/file_system/file_system_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/common/storage_key/storage_key.h" #include "url/gurl.h" @@ -73,10 +75,17 @@ void TearDown() override { task_environment_.RunUntilIdle(); } - std::unique_ptr<FileSystemAccessDirectoryHandleImpl> - GetHandleWithPermissions(const base::FilePath& path, bool read, bool write) { + std::unique_ptr<FileSystemAccessDirectoryHandleImpl> GetHandleWithPermissions( + const base::FilePath& path, + bool read, + bool write, + const absl::optional<storage::BucketLocator> url_bucket_override = + absl::nullopt) { auto url = manager_->CreateFileSystemURLFromPath( FileSystemAccessEntryFactory::PathType::kLocal, path); + if (url_bucket_override.has_value()) { + url.SetBucket(url_bucket_override.value()); + } auto handle = std::make_unique<FileSystemAccessDirectoryHandleImpl>( manager_.get(), FileSystemAccessManagerImpl::BindingContext( @@ -408,4 +417,31 @@ } } +TEST_F(FileSystemAccessDirectoryHandleImplTest, GetChildURL_CustomBucket) { + base::FilePath dir = dir_.GetPath().AppendASCII("dirname"); + ASSERT_TRUE(base::CreateDirectory(dir)); + base::FilePath file; + base::CreateTemporaryFileInDir(dir, &file); + auto base_name = storage::FilePathToString(file.BaseName()); + storage::FileSystemURL file_url; + + auto default_handle = + GetHandleWithPermissions(dir, /*read=*/true, /*write=*/true); + EXPECT_EQ(default_handle->GetChildURL(base_name, &file_url)->file_error, + base::File::Error::FILE_OK); + EXPECT_FALSE(file_url.bucket()); + + const auto custom_bucket = storage::BucketLocator( + storage::BucketId(1), + blink::StorageKey::CreateFromStringForTesting("http://example/"), + blink::mojom::StorageType::kTemporary, /*is_default=*/false); + auto custom_handle = + GetHandleWithPermissions(dir, /*read=*/true, /*write=*/true, + /*url_bucket_override=*/custom_bucket); + EXPECT_EQ(custom_handle->GetChildURL(base_name, &file_url)->file_error, + base::File::Error::FILE_OK); + EXPECT_TRUE(file_url.bucket()); + EXPECT_EQ(file_url.bucket().value(), custom_bucket); +} + } // namespace content
diff --git a/content/browser/file_system_access/file_system_access_handle_base.cc b/content/browser/file_system_access/file_system_access_handle_base.cc index 79679fc0..683019e 100644 --- a/content/browser/file_system_access/file_system_access_handle_base.cc +++ b/content/browser/file_system_access/file_system_access_handle_base.cc
@@ -438,11 +438,18 @@ std::move(wrapped_callback), url, recurse); } +// Calculates the parent URL fom current context, propagating any +// storage bucket overrides from the child. storage::FileSystemURL FileSystemAccessHandleBase::GetParentURL() { const storage::FileSystemURL child = url(); - return file_system_context()->CreateCrackedFileSystemURL( - child.storage_key(), child.mount_type(), - storage::VirtualPath::DirName(child.virtual_path())); + storage::FileSystemURL parent = + file_system_context()->CreateCrackedFileSystemURL( + child.storage_key(), child.mount_type(), + storage::VirtualPath::DirName(child.virtual_path())); + if (child.bucket()) { + parent.SetBucket(child.bucket().value()); + } + return parent; } } // namespace content
diff --git a/content/browser/file_system_access/file_system_access_handle_base.h b/content/browser/file_system_access/file_system_access_handle_base.h index d6b7913..88cf3a59 100644 --- a/content/browser/file_system_access/file_system_access_handle_base.h +++ b/content/browser/file_system_access/file_system_access_handle_base.h
@@ -57,6 +57,7 @@ PermissionStatus GetReadPermissionStatus(); PermissionStatus GetWritePermissionStatus(); + storage::FileSystemURL GetParentURLForTesting() { return GetParentURL(); } // Implementation for the GetPermissionStatus method in the // blink::mojom::FileSystemAccessFileHandle and DirectoryHandle interfaces. @@ -116,7 +117,6 @@ private: storage::FileSystemURL GetParentURL(); - void DidRequestPermission( bool writable, base::OnceCallback<void(blink::mojom::FileSystemAccessErrorPtr,
diff --git a/content/browser/file_system_access/file_system_access_handle_base_unittest.cc b/content/browser/file_system_access/file_system_access_handle_base_unittest.cc index a92827f..14f8e24 100644 --- a/content/browser/file_system_access/file_system_access_handle_base_unittest.cc +++ b/content/browser/file_system_access/file_system_access_handle_base_unittest.cc
@@ -8,6 +8,7 @@ #include "base/test/bind.h" #include "base/test/gmock_callback_support.h" #include "base/test/task_environment.h" +#include "components/services/storage/public/cpp/buckets/bucket_locator.h" #include "content/browser/file_system_access/mock_file_system_access_permission_grant.h" #include "content/public/test/browser_task_environment.h" #include "storage/browser/blob/blob_storage_context.h" @@ -210,4 +211,33 @@ loop.Run(); } +TEST_F(FileSystemAccessHandleBaseTest, GetParentURL_CustomBucketLocator) { + auto default_bucket_url = FileSystemURL::CreateForTest( + kTestStorageKey, storage::kFileSystemTypeTest, + base::FilePath::FromUTF8Unsafe("/test")); + TestFileSystemAccessHandle default_handle( + manager_.get(), + FileSystemAccessManagerImpl::BindingContext(kTestStorageKey, kTestURL, + /*worker_process_id=*/1), + default_bucket_url, handle_state_); + EXPECT_FALSE(default_handle.GetParentURLForTesting().bucket()); + + auto custom_bucket_url = FileSystemURL::CreateForTest( + kTestStorageKey, storage::kFileSystemTypeTest, + base::FilePath::FromUTF8Unsafe("/test")); + const auto custom_bucket = storage::BucketLocator( + storage::BucketId(1), + blink::StorageKey::CreateFromStringForTesting("http://example/"), + blink::mojom::StorageType::kTemporary, /*is_default=*/false); + custom_bucket_url.SetBucket(custom_bucket); + TestFileSystemAccessHandle custom_handle( + manager_.get(), + FileSystemAccessManagerImpl::BindingContext(kTestStorageKey, kTestURL, + /*worker_process_id=*/1), + custom_bucket_url, handle_state_); + EXPECT_TRUE(custom_handle.GetParentURLForTesting().bucket()); + EXPECT_EQ(custom_handle.GetParentURLForTesting().bucket().value(), + custom_bucket_url.bucket().value()); +} + } // namespace content
diff --git a/content/browser/renderer_host/back_forward_cache_impl.cc b/content/browser/renderer_host/back_forward_cache_impl.cc index bd03240..cb8745b4 100644 --- a/content/browser/renderer_host/back_forward_cache_impl.cc +++ b/content/browser/renderer_host/back_forward_cache_impl.cc
@@ -983,17 +983,41 @@ } } +std::unique_ptr<BackForwardCacheCanStoreTreeResult> +BackForwardCacheImpl::CreateEvictionBackForwardCacheCanStoreTreeResult( + RenderFrameHostImpl& rfh, + BackForwardCacheCanStoreDocumentResult& eviction_reason) { + BackForwardCacheImpl::NotRestoredReasonBuilder builder( + rfh.GetMainFrame(), + /* include_non_sticky = */ false, + /* create_tree = */ true, + BackForwardCacheImpl::NotRestoredReasonBuilder::EvictionInfo( + rfh, &eviction_reason)); + return builder.GetTreeResult(); +} + BackForwardCacheImpl::NotRestoredReasonBuilder::NotRestoredReasonBuilder( RenderFrameHostImpl* root_rfh, bool include_non_sticky, bool create_tree) + : NotRestoredReasonBuilder(root_rfh, + include_non_sticky, + create_tree, + /* eviction_info = */ absl::nullopt) {} + +BackForwardCacheImpl::NotRestoredReasonBuilder::NotRestoredReasonBuilder( + RenderFrameHostImpl* root_rfh, + bool include_non_sticky, + bool create_tree, + absl::optional<EvictionInfo> eviction_info) : root_rfh_(root_rfh), bfcache_(root_rfh_->frame_tree_node() ->navigator() .controller() .GetBackForwardCache()), include_non_sticky_(include_non_sticky), - create_tree_(create_tree) { + create_tree_(create_tree), + eviction_info_(eviction_info) { // |root_rfh_| should be either primary main frame or back/forward cached // page's main frame. DCHECK(root_rfh_->IsInPrimaryMainFrame() || @@ -1008,9 +1032,23 @@ std::unique_ptr<BackForwardCacheCanStoreTreeResult> BackForwardCacheImpl:: NotRestoredReasonBuilder::PopulateReasonsAndReturnSubtreeIfNeededFor( RenderFrameHostImpl* rfh) { + // TODO(https://crbug.com/1280150): Add cache-control:no-store reasons to the + // tree. + BackForwardCacheCanStoreDocumentResult result_for_rfh; - // Populate |result_for_rfh| by checking the bfcache eligibility of |rfh|. - bfcache_.PopulateReasonsForDocument(result_for_rfh, rfh, include_non_sticky_); + if (eviction_info_.has_value()) { + // When |eviction_info_| is set, that means that we are populating the + // reasons for eviction. In that case, we do not need to check each frame's + // eligibility, but only mark |rfh_to_be_evicted| with |reasons|, as it is + // the cause of eviction. + if (rfh == eviction_info_->rfh_to_be_evicted) { + result_for_rfh.AddReasonsFrom(*(eviction_info_->reasons)); + } + } else { + // Populate |result_for_rfh| by checking the bfcache eligibility of |rfh|. + bfcache_.PopulateReasonsForDocument(result_for_rfh, rfh, + include_non_sticky_); + } flattened_result_.AddReasonsFrom(result_for_rfh); // Finds the reasons recursively and create the reason subtree for the @@ -1281,8 +1319,7 @@ if (!can_store) { (*matching_entry) ->render_frame_host() - ->EvictFromBackForwardCacheWithReasons( - can_store.flattened_reasons, std::move(can_store.tree_reasons)); + ->EvictFromBackForwardCacheWithFlattenedAndTreeReasons(can_store); } }
diff --git a/content/browser/renderer_host/back_forward_cache_impl.h b/content/browser/renderer_host/back_forward_cache_impl.h index b0c6155..5a07db7 100644 --- a/content/browser/renderer_host/back_forward_cache_impl.h +++ b/content/browser/renderer_host/back_forward_cache_impl.h
@@ -16,6 +16,7 @@ #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" #include "content/browser/renderer_host/back_forward_cache_can_store_document_result.h" +#include "content/browser/renderer_host/back_forward_cache_metrics.h" #include "content/browser/renderer_host/page_impl.h" #include "content/browser/renderer_host/render_process_host_internal_observer.h" #include "content/browser/renderer_host/stored_page.h" @@ -100,6 +101,9 @@ class CONTENT_EXPORT BackForwardCacheImpl : public BackForwardCache, public RenderProcessHostInternalObserver { + friend class BackForwardCacheCanStoreTreeResult; + friend class BackForwardCacheMetrics; + public: enum MessageHandlingPolicyWhenCached { kMessagePolicyNone, @@ -338,6 +342,18 @@ SiteInstanceId site_instance_id); bool IsProxyInBackForwardCacheForDebugging(RenderFrameProxyHost* proxy); + // Construct a tree of NotRestoredReasons for |rfh| without checking the + // eligibility of all the documents in the frame tree. This should be only + // used for evicting the back/forward cache entry where we know why the entry + // is not eligible and which document is causing it. + // This preserves the frame tree structure after eviction, because the actual + // page and frame tree is not kept around after eviction. + // |rfh| will be marked as having |eviction_reason| as not restored reasons. + static std::unique_ptr<BackForwardCacheCanStoreTreeResult> + CreateEvictionBackForwardCacheCanStoreTreeResult( + RenderFrameHostImpl& rfh, + BackForwardCacheCanStoreDocumentResult& eviction_reason); + private: // Destroys all evicted frames in the BackForwardCache. void DestroyEvictedFrames(); @@ -461,15 +477,33 @@ // NotRestoredReasons. class NotRestoredReasonBuilder { public: - // |rfh_root| represents the root document of the page. |include_non_sticky| + // Construct a tree of NotRestoredReasons by checking the eligibility of + // each frame in the frame tree rooted at |root_rfh|. + // |root_rfh| represents the root document of the page. |include_non_sticky| // controls whether or not we should record non-sticky reasons in the tree, // and |create_tree| controls whether or not we should build // |BackForwardCacheCanStoreTreeResult|. If |create_tree| is false, we only // record them in a flattened list. - NotRestoredReasonBuilder(RenderFrameHostImpl* rfh_root, + NotRestoredReasonBuilder(RenderFrameHostImpl* root_rfh, bool include_non_sticky, bool create_tree); + // Struct for containing the RenderFrameHostImpl that is going to be + // evicted if applicable. |reasons| represent why |rfh_to_be_evicted| will + // be evicted. + struct EvictionInfo { + EvictionInfo(RenderFrameHostImpl& rfh, + BackForwardCacheCanStoreDocumentResult* reasons) + : rfh_to_be_evicted(&rfh), reasons(reasons) {} + RenderFrameHostImpl* const rfh_to_be_evicted; + const BackForwardCacheCanStoreDocumentResult* reasons; + }; + + NotRestoredReasonBuilder(RenderFrameHostImpl* root_rfh, + bool include_non_sticky, + bool create_tree, + absl::optional<EvictionInfo> eviction_info); + ~NotRestoredReasonBuilder(); // Access the populated result. @@ -505,6 +539,11 @@ // If true, construct a tree of NotRestoredReasons representing the frame // tree structure. If false, only populate |flattened_result_|. const bool create_tree_; + // Contains the information of the RenderFrameHost that causes eviction, if + // applicable. If set, the result returned by the builder will only contain + // the NotRestoredReason for the RenderFrameHost that causes eviction + // (instead of the reasons for the whole tree). + absl::optional<EvictionInfo> eviction_info_; }; base::WeakPtrFactory<BackForwardCacheImpl> weak_factory_;
diff --git a/content/browser/renderer_host/back_forward_cache_metrics.cc b/content/browser/renderer_host/back_forward_cache_metrics.cc index 30a7f78e..8ff625d 100644 --- a/content/browser/renderer_host/back_forward_cache_metrics.cc +++ b/content/browser/renderer_host/back_forward_cache_metrics.cc
@@ -168,10 +168,15 @@ devtools_instrumentation::BackForwardCacheNotUsed( navigation, page_store_result_.get(), page_store_tree_result_.get()); } + if (test_observer_) { + // This is for reporting |page_store_tree_result_| for testing. + test_observer_->NotifyNotRestoredReasons( + std::move(page_store_tree_result_)); + } } - page_store_result_ = std::make_unique<BackForwardCacheCanStoreDocumentResult>(); + page_store_tree_result_ = nullptr; previous_navigation_is_served_from_bfcache_ = navigation->IsServedFromBackForwardCache(); previous_navigation_is_history_ = IsHistoryNavigation(navigation); @@ -357,6 +362,8 @@ // unittests. return; } + // TODO(yuzus): Update |page_store_tree_result_| to match with + // |page_store_result_|. } void BackForwardCacheMetrics::RecordMetricsForHistoryNavigationCommit(
diff --git a/content/browser/renderer_host/back_forward_cache_metrics.h b/content/browser/renderer_host/back_forward_cache_metrics.h index dcd0c1f..221b13c6f 100644 --- a/content/browser/renderer_host/back_forward_cache_metrics.h +++ b/content/browser/renderer_host/back_forward_cache_metrics.h
@@ -236,6 +236,18 @@ // Should be called only from the UI thread. CONTENT_EXPORT static void OverrideTimeForTesting(base::TickClock* clock); + class TestObserver { + public: + virtual ~TestObserver() = default; + // Report the tree result of NotRestoredReason to the observer. + virtual void NotifyNotRestoredReasons( + std::unique_ptr<BackForwardCacheCanStoreTreeResult> tree_result) = 0; + }; + + void SetObserverForTesting(TestObserver* observer) { + test_observer_ = observer; + } + private: friend class base::RefCounted<BackForwardCacheMetrics>; @@ -307,6 +319,8 @@ absl::optional<base::TimeTicks> renderer_killed_timestamp_; + TestObserver* test_observer_ = nullptr; + // The reason why the last attempted navigation in the frame used or didn't // use a new BrowsingInstance. absl::optional<ShouldSwapBrowsingInstance> browsing_instance_swap_result_;
diff --git a/content/browser/renderer_host/back_forward_cache_metrics_browsertest.cc b/content/browser/renderer_host/back_forward_cache_metrics_browsertest.cc index fe12ec9..39997c42 100644 --- a/content/browser/renderer_host/back_forward_cache_metrics_browsertest.cc +++ b/content/browser/renderer_host/back_forward_cache_metrics_browsertest.cc
@@ -24,6 +24,7 @@ #include "content/public/test/browser_test_utils.h" #include "content/public/test/content_browser_test.h" #include "content/public/test/content_browser_test_utils.h" +#include "content/public/test/fenced_frame_test_util.h" #include "content/public/test/prerender_test_util.h" #include "content/public/test/test_navigation_observer.h" #include "content/shell/browser/shell.h" @@ -985,6 +986,58 @@ testing::ElementsAre(FeatureUsage{id5, 0, 0, 0})); } +class BackForwardCacheMetricsFencedFrameBrowserTest + : public BackForwardCacheMetricsBrowserTest { + public: + BackForwardCacheMetricsFencedFrameBrowserTest() = default; + ~BackForwardCacheMetricsFencedFrameBrowserTest() override = default; + + test::FencedFrameTestHelper& fenced_frame_test_helper() { + return fenced_frame_test_helper_; + } + + private: + test::FencedFrameTestHelper fenced_frame_test_helper_; +}; + +// Tests that fenced frame navigation doesn't have BackForwardCacheMetrics. +IN_PROC_BROWSER_TEST_P(BackForwardCacheMetricsFencedFrameBrowserTest, + FenceFrameNavigation) { + ukm::TestAutoSetUkmRecorder recorder; + + const GURL url1(embedded_test_server()->GetURL("/title1.html")); + const GURL fenced_frame_url1( + embedded_test_server()->GetURL("/fenced_frames/title1.html")); + const GURL url2(embedded_test_server()->GetURL("/title2.html")); + + EXPECT_TRUE(NavigateToURL(shell(), url1)); + + auto* fenced_frame = fenced_frame_test_helper().CreateFencedFrame( + web_contents()->GetMainFrame(), fenced_frame_url1); + NavigationEntryImpl* fenced_frame_entry = FrameTreeNode::From(fenced_frame) + ->frame_tree() + ->controller() + .GetLastCommittedEntry(); + EXPECT_EQ(fenced_frame_entry->back_forward_cache_metrics(), nullptr); + + EXPECT_TRUE(NavigateToURL(shell(), url2)); + // Navigate back to `url1`. + ASSERT_TRUE(HistoryGoBack(shell()->web_contents())); + + // The navigations observed should be: + // 1) url1 + // 2) fenced_frame_url1 + // 3) url2 + // 4) url1 (back navigation) + + ASSERT_EQ(navigation_ids_.size(), static_cast<size_t>(4)); + ukm::SourceId id4 = ToSourceId(navigation_ids_[3]); + + // We should only record metrics for the last navigation. + EXPECT_THAT(GetFeatureUsageMetrics(&recorder), + testing::ElementsAre(FeatureUsage{id4, 0, 0, 0})); +} + INSTANTIATE_TEST_SUITE_P(All, BackForwardCacheMetricsBrowserTest, testing::ValuesIn({BackForwardCacheStatus::kDisabled, @@ -996,4 +1049,10 @@ BackForwardCacheStatus::kEnabled}), BackForwardCacheMetricsBrowserTest::DescribeParams); +INSTANTIATE_TEST_SUITE_P(All, + BackForwardCacheMetricsFencedFrameBrowserTest, + testing::ValuesIn({BackForwardCacheStatus::kDisabled, + BackForwardCacheStatus::kEnabled}), + BackForwardCacheMetricsBrowserTest::DescribeParams); + } // namespace content
diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc index 20b9d7c..dc75ab59 100644 --- a/content/browser/renderer_host/render_frame_host_impl.cc +++ b/content/browser/renderer_host/render_frame_host_impl.cc
@@ -6024,9 +6024,9 @@ case LifecycleStateImpl::kReadyToBeDeleted: return true; case LifecycleStateImpl::kInBackForwardCache: { - BackForwardCacheCanStoreDocumentResult can_store; - can_store.NoDueToDisallowActivation(reason); - EvictFromBackForwardCacheWithReasons(can_store); + BackForwardCacheCanStoreDocumentResult can_store_flat; + can_store_flat.NoDueToDisallowActivation(reason); + EvictFromBackForwardCacheWithFlattenedReasons(can_store_flat); } return true; case LifecycleStateImpl::kPrerendering: @@ -6063,9 +6063,9 @@ } // If the lifecycle state is |LifecycleStateImpl::kInBackForwardCache|, we // cannot handle accessibility events any more. We should evict the entry. - BackForwardCacheCanStoreDocumentResult can_store; - can_store.NoDueToAXEvents(events); - EvictFromBackForwardCacheWithReasons(can_store); + BackForwardCacheCanStoreDocumentResult can_store_flat; + can_store_flat.NoDueToAXEvents(events); + EvictFromBackForwardCacheWithFlattenedReasons(can_store_flat); return true; } @@ -6081,22 +6081,36 @@ // details. DCHECK_NE(reason, BackForwardCacheMetrics::NotRestoredReason::kIgnoreEventAndEvict); - BackForwardCacheCanStoreDocumentResultWithTree can_store = - frame_tree()->controller().GetBackForwardCache().CanStorePageNow( - GetMainFrame()); - can_store.flattened_reasons.No(reason); - EvictFromBackForwardCacheWithReasons(can_store.flattened_reasons, - std::move(can_store.tree_reasons)); + + BackForwardCacheCanStoreDocumentResult flattened_reasons; + flattened_reasons.No(reason); + EvictFromBackForwardCacheWithFlattenedReasons(flattened_reasons); } -void RenderFrameHostImpl::EvictFromBackForwardCacheWithReasons( - const BackForwardCacheCanStoreDocumentResult& can_store_flattened, - std::unique_ptr<BackForwardCacheCanStoreTreeResult> can_store_tree) { +void RenderFrameHostImpl::EvictFromBackForwardCacheWithFlattenedReasons( + BackForwardCacheCanStoreDocumentResult can_store_flat) { + // Create a NotRestoredReasons tree that has |can_store_flat| as a reason + // for |this| render frame host. + std::unique_ptr<BackForwardCacheCanStoreTreeResult> can_store_tree = + BackForwardCacheImpl::CreateEvictionBackForwardCacheCanStoreTreeResult( + *this, can_store_flat); + BackForwardCacheCanStoreDocumentResultWithTree can_store( + can_store_flat, std::move(can_store_tree)); + EvictFromBackForwardCacheWithFlattenedAndTreeReasons(can_store); +} + +void RenderFrameHostImpl::EvictFromBackForwardCacheWithFlattenedAndTreeReasons( + BackForwardCacheCanStoreDocumentResultWithTree& can_store) { + BackForwardCacheCanStoreDocumentResult& can_store_flattened = + can_store.flattened_reasons; + std::unique_ptr<BackForwardCacheCanStoreTreeResult> can_store_tree = + std::move(can_store.tree_reasons); TRACE_EVENT2("navigation", "RenderFrameHostImpl::EvictFromBackForwardCache", "can_store", can_store_flattened.ToString(), "rfh", static_cast<void*>(this)); TRACE_EVENT("navigation", - "RenderFrameHostImpl::EvictFromBackForwardCacheWithReasons", + "RenderFrameHostImpl::" + "EvictFromBackForwardCacheWithFlattenedAndTreeReasons", ChromeTrackEvent::kBackForwardCacheCanStoreDocumentResult, can_store_flattened); DCHECK(IsBackForwardCacheEnabled()); @@ -12569,8 +12583,7 @@ if (can_store) return; - EvictFromBackForwardCacheWithReasons(can_store.flattened_reasons, - std::move(can_store.tree_reasons)); + EvictFromBackForwardCacheWithFlattenedAndTreeReasons(can_store); } void RenderFrameHostImpl::LogCannotCommitOriginCrashKeys(
diff --git a/content/browser/renderer_host/render_frame_host_impl.h b/content/browser/renderer_host/render_frame_host_impl.h index df5d7a0..06b5de3 100644 --- a/content/browser/renderer_host/render_frame_host_impl.h +++ b/content/browser/renderer_host/render_frame_host_impl.h
@@ -478,12 +478,21 @@ bool IsInactiveAndDisallowActivationForAXEvents( const std::vector<ui::AXEvent>& events); + // Evict the RenderFrameHostImpl with |reason| that causes the eviction. This + // constructs a flattened list of NotRestoredReasons and calls + // |EvictFromBackForwardCacheWithFlattenedReasons|. void EvictFromBackForwardCacheWithReason( BackForwardCacheMetrics::NotRestoredReason reason); - void EvictFromBackForwardCacheWithReasons( - const BackForwardCacheCanStoreDocumentResult& can_store_flat, - std::unique_ptr<BackForwardCacheCanStoreTreeResult> can_store_tree = - nullptr); + // Evict the RenderFrameHostImpl with |can_store_flat| as the eviction reason. + // This constructs a tree of NotRestoredReasons based on |can_store_flat| and + // calls |EvictFromBackForwardCacheWithFlattenedAndTreeReasons|. + void EvictFromBackForwardCacheWithFlattenedReasons( + BackForwardCacheCanStoreDocumentResult can_store_flat); + // Evict the RenderFrameHostImpl with |can_store| that causes the eviction. + // This reports the flattened list and the tree of NotRestoredReasons to + // metrics, and posts a task to evict the frame. + void EvictFromBackForwardCacheWithFlattenedAndTreeReasons( + BackForwardCacheCanStoreDocumentResultWithTree& can_store); // Only for testing sticky WebBackForwardCacheDisablingFeature. void UseDummyStickyBackForwardCacheDisablingFeatureForTesting();
diff --git a/content/browser/service_worker/service_worker_internals_ui_browsertest.cc b/content/browser/service_worker/service_worker_internals_ui_browsertest.cc index 1c45803..719856ae 100644 --- a/content/browser/service_worker/service_worker_internals_ui_browsertest.cc +++ b/content/browser/service_worker/service_worker_internals_ui_browsertest.cc
@@ -400,8 +400,16 @@ TearDownWindow(); } +// TODO(crbug.com/1307548): Flaky on Linux/Lacros +#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) +#define MAYBE_RegisteredSWReflectedOnInternalUI \ + DISABLED_RegisteredSWReflectedOnInternalUI +#else +#define MAYBE_RegisteredSWReflectedOnInternalUI \ + RegisteredSWReflectedOnInternalUI +#endif IN_PROC_BROWSER_TEST_F(ServiceWorkerInternalsUIBrowserTest, - RegisteredSWReflectedOnInternalUI) { + MAYBE_RegisteredSWReflectedOnInternalUI) { Shell* SWInternalUIWindow = CreateNewWindow(); NavigateToServiceWorkerInternalUI();
diff --git a/content/common/partition_alloc_support.cc b/content/common/partition_alloc_support.cc index 0105638..65376e8 100644 --- a/content/common/partition_alloc_support.cc +++ b/content/common/partition_alloc_support.cc
@@ -376,8 +376,8 @@ #if BUILDFLAG(IS_ANDROID) // Lower thread cache limits to avoid stranding too much memory in the caches. if (base::SysInfo::IsLowEndDevice()) { - base::internal::ThreadCacheRegistry::Instance().SetThreadCacheMultiplier( - base::internal::ThreadCache::kDefaultMultiplier / 2.); + ::partition_alloc::ThreadCacheRegistry::Instance().SetThreadCacheMultiplier( + ::partition_alloc::ThreadCache::kDefaultMultiplier / 2.); } #endif // BUILDFLAG(IS_ANDROID) @@ -387,17 +387,17 @@ base::FeatureList::IsEnabled( base::features::kPartitionAllocLargeThreadCacheSize)) { largest_cached_size_ = - base::internal::ThreadCacheLimits::kLargeSizeThreshold; + ::partition_alloc::ThreadCacheLimits::kLargeSizeThreshold; #if BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_32_BITS) // Devices almost always report less physical memory than what they actually // have, so anything above 3GiB will catch 4GiB and above. if (base::SysInfo::AmountOfPhysicalMemory() <= int64_t{3500} * 1024 * 1024) largest_cached_size_ = - base::internal::ThreadCacheLimits::kDefaultSizeThreshold; + ::partition_alloc::ThreadCacheLimits::kDefaultSizeThreshold; #endif // BUILDFLAG(IS_ANDROID) && !defined(ARCH_CPU_64_BITS) - base::internal::ThreadCache::SetLargestCachedSize(largest_cached_size_); + ::partition_alloc::ThreadCache::SetLargestCachedSize(largest_cached_size_); } #endif // defined(PA_THREAD_CACHE_SUPPORTED) && @@ -428,7 +428,7 @@ return; } - base::internal::ThreadCache::SetLargestCachedSize(largest_cached_size_); + ::partition_alloc::ThreadCache::SetLargestCachedSize(largest_cached_size_); #endif // defined(PA_THREAD_CACHE_SUPPORTED) && // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) } @@ -444,8 +444,8 @@ // Performance matters less for background renderers, don't pay the memory // cost. - base::internal::ThreadCache::SetLargestCachedSize( - base::internal::ThreadCacheLimits::kDefaultSizeThreshold); + ::partition_alloc::ThreadCache::SetLargestCachedSize( + ::partition_alloc::ThreadCacheLimits::kDefaultSizeThreshold); // In renderers, memory reclaim uses the "idle time" task runner to run // periodic reclaim. This does not always run when the renderer is idle, and
diff --git a/content/common/partition_alloc_support.h b/content/common/partition_alloc_support.h index 7869842..21ceeca9 100644 --- a/content/common/partition_alloc_support.h +++ b/content/common/partition_alloc_support.h
@@ -68,7 +68,7 @@ #if defined(PA_THREAD_CACHE_SUPPORTED) && \ BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) size_t largest_cached_size_ = - base::internal::ThreadCacheLimits::kDefaultSizeThreshold; + ::partition_alloc::ThreadCacheLimits::kDefaultSizeThreshold; #endif };
diff --git a/content/test/data/gpu/pixel_webgpu_util.js b/content/test/data/gpu/pixel_webgpu_util.js index d3885f4b..53c24d3 100644 --- a/content/test/data/gpu/pixel_webgpu_util.js +++ b/content/test/data/gpu/pixel_webgpu_util.js
@@ -20,12 +20,12 @@ vec2<f32>(1.0, 1.0)); struct VertexOutput { - [[builtin(position)]] Position : vec4<f32>; - [[location(0)]] fragUV : vec2<f32>; + @builtin(position) Position : vec4<f32>; + @location(0) fragUV : vec2<f32>; }; -[[stage(vertex)]] -fn main([[builtin(vertex_index)]] VertexIndex : u32) -> VertexOutput { +@stage(vertex) +fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOutput { var output: VertexOutput; output.Position = quadPos[VertexIndex]; output.fragUV = quadUV[VertexIndex]; @@ -34,28 +34,28 @@ `, fragmentBlit: ` -[[binding(0), group(0)]] var mySampler: sampler; -[[binding(1), group(0)]] var myTexture: texture_2d<f32>; +@group(0) @binding(0) var mySampler: sampler; +@group(0) @binding(1) var myTexture: texture_2d<f32>; -[[stage(fragment)]] -fn main([[location(0)]] fragUV : vec2<f32>) -> [[location(0)]] vec4<f32> { +@stage(fragment) +fn main(@location(0) fragUV : vec2<f32>) -> @location(0) vec4<f32> { return textureSample(myTexture, mySampler, fragUV); } `, fragmentClear: ` -[[stage(fragment)]] -fn main([[location(0)]] fragUV : vec2<f32>) -> [[location(0)]] vec4<f32> { +@stage(fragment) +fn main(@location(0) fragUV : vec2<f32>) -> @location(0) vec4<f32> { return vec4<f32>(1.0, 1.0, 1.0, 1.0); } `, fragmentImport: ` -[[binding(0), group(0)]] var mySampler: sampler; -[[binding(1), group(0)]] var myTexture: texture_external; +@group(0) @binding(0) var mySampler: sampler; +@group(0) @binding(1) var myTexture: texture_external; -[[stage(fragment)]] -fn main([[location(0)]] fragUV : vec2<f32>) -> [[location(0)]] vec4<f32> { +@stage(fragment) +fn main(@location(0) fragUV : vec2<f32>) -> @location(0) vec4<f32> { return textureSampleLevel(myTexture, mySampler, fragUV); } `,
diff --git a/content/test/data/gpu/vc/webgpu_video.js b/content/test/data/gpu/vc/webgpu_video.js index 1199d3cb..d3703d1 100644 --- a/content/test/data/gpu/vc/webgpu_video.js +++ b/content/test/data/gpu/vc/webgpu_video.js
@@ -32,13 +32,13 @@ const wgslShaders = { vertex: ` struct VertexOutput { - [[builtin(position)]] Position : vec4<f32>; - [[location(0)]] fragUV : vec2<f32>; + @builtin(position) Position : vec4<f32>; + @location(0) fragUV : vec2<f32>; }; -[[stage(vertex)]] fn main( - [[location(0)]] position : vec2<f32>, - [[location(1)]] uv : vec2<f32> +@stage(vertex) fn main( + @location(0) position : vec2<f32>, + @location(1) uv : vec2<f32> ) -> VertexOutput { var output : VertexOutput; output.Position = vec4<f32>(position, 0.0, 1.0); @@ -48,49 +48,49 @@ `, fragment_external_texture: ` -[[binding(0), group(0)]] var mySampler: sampler; -[[binding(1), group(0)]] var myTexture: texture_external; +@group(0) @binding(0) var mySampler: sampler; +@group(0) @binding(1) var myTexture: texture_external; -[[stage(fragment)]] -fn main([[location(0)]] fragUV : vec2<f32>) -> [[location(0)]] vec4<f32> { +@stage(fragment) +fn main(@location(0) fragUV : vec2<f32>) -> @location(0) vec4<f32> { return textureSampleLevel(myTexture, mySampler, fragUV); } `, fragment: ` -[[binding(0), group(0)]] var mySampler: sampler; -[[binding(1), group(0)]] var myTexture: texture_2d<f32>; +@group(0) @binding(0) var mySampler: sampler; +@group(0) @binding(1) var myTexture: texture_2d<f32>; -[[stage(fragment)]] -fn main([[location(0)]] fragUV : vec2<f32>) -> [[location(0)]] vec4<f32> { +@stage(fragment) +fn main(@location(0) fragUV : vec2<f32>) -> @location(0) vec4<f32> { return textureSample(myTexture, mySampler, fragUV); } `, vertex_icons: ` -[[stage(vertex)]] -fn main([[location(0)]] position : vec2<f32>) - -> [[builtin(position)]] vec4<f32> { +@stage(vertex) +fn main(@location(0) position : vec2<f32>) + -> @builtin(position) vec4<f32> { return vec4<f32>(position, 0.0, 1.0); } `, fragment_output_blue: ` -[[stage(fragment)]] -fn main() -> [[location(0)]] vec4<f32> { +@stage(fragment) +fn main() -> @location(0) vec4<f32> { return vec4<f32>(0.11328125, 0.4296875, 0.84375, 1.0); } `, fragment_output_light_blue: ` -[[stage(fragment)]] -fn main() -> [[location(0)]] vec4<f32> { +@stage(fragment) +fn main() -> @location(0) vec4<f32> { return vec4<f32>(0.3515625, 0.50390625, 0.75390625, 1.0); } `, fragment_output_white: ` -[[stage(fragment)]] -fn main() -> [[location(0)]] vec4<f32> { +@stage(fragment) +fn main() -> @location(0) vec4<f32> { return vec4<f32>(1.0, 1.0, 1.0, 1.0); } `,
diff --git a/content/test/data/gpu/webgpu-import-video.html b/content/test/data/gpu/webgpu-import-video.html index f253921f..b6ac22b 100644 --- a/content/test/data/gpu/webgpu-import-video.html +++ b/content/test/data/gpu/webgpu-import-video.html
@@ -58,12 +58,12 @@ module: device.createShaderModule({ code: ` struct VertexOutput { - [[builtin(position)]] Position : vec4<f32>; - [[location(0)]] fragUV : vec2<f32>; + @builtin(position) Position : vec4<f32>; + @location(0) fragUV : vec2<f32>; }; -[[stage(vertex)]] -fn main([[builtin(vertex_index)]] idx : u32) -> VertexOutput { +@stage(vertex) +fn main(@builtin(vertex_index) idx : u32) -> VertexOutput { var pos = array<vec3<f32>, 6>( vec3<f32>( 1.0, 1.0, 0.0), vec3<f32>( 1.0, -1.0, 0.0), @@ -93,12 +93,12 @@ fragment: { module: device.createShaderModule({ code: ` -[[binding(0), group(0)]] var mySampler: sampler; -[[binding(1), group(0)]] var myTexture: texture_external; -[[binding(2), group(0)]] var myTexture2: texture_external; +@binding(0) @group(0) var mySampler: sampler; +@binding(1) @group(0) var myTexture: texture_external; +@binding(2) @group(0) var myTexture2: texture_external; -[[stage(fragment)]] -fn main([[location(0)]] fragUV : vec2<f32>) -> [[location(0)]] vec4<f32> { +@stage(fragment) +fn main(@location(0) fragUV : vec2<f32>) -> @location(0) vec4<f32> { var result : vec4<f32>; if (fragUV.y <= 1.0) { result = textureSampleLevel(myTexture, mySampler, fragUV);
diff --git a/device/fido/cros/authenticator.cc b/device/fido/cros/authenticator.cc index abefdac6..19ca55d 100644 --- a/device/fido/cros/authenticator.cc +++ b/device/fido/cros/authenticator.cc
@@ -9,6 +9,7 @@ #include "device/fido/cros/authenticator.h" #include "base/bind.h" +#include "base/containers/span.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "chromeos/dbus/u2f/u2f_client.h" @@ -68,9 +69,39 @@ void ChromeOSAuthenticator::InitializeAuthenticator( base::OnceClosure callback) { + u2f::GetAlgorithmsRequest request; + chromeos::U2FClient::Get()->GetAlgorithms( + request, base::BindOnce(&ChromeOSAuthenticator::OnGetAlgorithmsResponse, + weak_factory_.GetWeakPtr(), std::move(callback))); +} + +void ChromeOSAuthenticator::OnGetAlgorithmsResponse( + base::OnceClosure callback, + absl::optional<u2f::GetAlgorithmsResponse> response) { + if (response && response->status() == + u2f::GetAlgorithmsResponse_GetAlgorithmsStatus_SUCCESS) { + supported_algorithms_ = std::vector<int32_t>(); + for (int i = 0; i < response->algorithm_size(); i++) { + supported_algorithms_->push_back(response->algorithm(i)); + } + } else { + // Keep `supported_algorithms_` as nullopt if fetching supported algorithms + // from u2fd failed, since the caller of `GetAlgorithms` method might want + // to provide defaults. + supported_algorithms_ = absl::nullopt; + } + std::move(callback).Run(); } +absl::optional<base::span<const int32_t>> +ChromeOSAuthenticator::GetAlgorithms() { + if (supported_algorithms_) { + return base::span<const int32_t>(*supported_algorithms_); + } + return absl::nullopt; +} + void ChromeOSAuthenticator::MakeCredential( CtapMakeCredentialRequest request, MakeCredentialOptions request_options,
diff --git a/device/fido/cros/authenticator.h b/device/fido/cros/authenticator.h index 2798583b..1f553bd 100644 --- a/device/fido/cros/authenticator.h +++ b/device/fido/cros/authenticator.h
@@ -8,6 +8,7 @@ #include <string> #include "base/component_export.h" +#include "base/containers/span.h" #include "base/memory/weak_ptr.h" #include "chromeos/dbus/u2f/u2f_interface.pb.h" #include "dbus/bus.h" @@ -60,7 +61,14 @@ base::OnceCallback<void(bool is_enabled)> callback); // FidoAuthenticator + + // Calls the u2fd API `GetAlgorithms` and cache the result. void InitializeAuthenticator(base::OnceClosure callback) override; + + // Since this method is synchronous, it will simply return the GetAlgorithms + // result obtained during `InitializeAuthenticator`. + absl::optional<base::span<const int32_t>> GetAlgorithms() override; + void MakeCredential(CtapMakeCredentialRequest request, MakeCredentialOptions request_options, MakeCredentialCallback callback) override; @@ -84,6 +92,11 @@ base::WeakPtr<FidoAuthenticator> GetWeakPtr() override; private: + // Cache the supported algorithms in response, and run the completion callback + // of `InitializeAuthenticator`. + void OnGetAlgorithmsResponse( + base::OnceClosure callback, + absl::optional<u2f::GetAlgorithmsResponse> response); void OnMakeCredentialResponse( CtapMakeCredentialRequest request, MakeCredentialCallback callback, @@ -104,6 +117,7 @@ // Callback to set request_id in the window property. base::RepeatingCallback<uint32_t()> generate_request_id_callback_; const Config config_; + absl::optional<std::vector<int32_t>> supported_algorithms_; base::WeakPtrFactory<ChromeOSAuthenticator> weak_factory_; };
diff --git a/device/gamepad/gamepad_monitor.cc b/device/gamepad/gamepad_monitor.cc index 28082924..cdaa5fc 100644 --- a/device/gamepad/gamepad_monitor.cc +++ b/device/gamepad/gamepad_monitor.cc
@@ -53,6 +53,8 @@ GamepadService* service = GamepadService::GetInstance(); if (!service->ConsumerBecameActive(this)) { mojo::ReportBadMessage("GamepadMonitor::GamepadStartPolling failed"); + // On error, invoke `callback` with a default-initialized memory region + // instead of the real memory region. std::move(callback).Run(base::ReadOnlySharedMemoryRegion()); return; } @@ -66,6 +68,7 @@ if (!GamepadService::GetInstance()->ConsumerBecameInactive(this)) { mojo::ReportBadMessage("GamepadMonitor::GamepadStopPolling failed"); } + // Invoke `callback` regardless of whether an error was encountered. std::move(callback).Run(); }
diff --git a/docs/memory/oom.md b/docs/memory/oom.md new file mode 100644 index 0000000..6fe65a3 --- /dev/null +++ b/docs/memory/oom.md
@@ -0,0 +1,151 @@ +# Investigating Out of Memory crashes + +A large fraction of process crashes in Chromium are due to Out Of Memory (OOM) +conditions. This page is meant to help Chromium developers understand stack +traces, and investigate. Note that some of the documentation here will only be +applicable to Google Chrome, as it is specific to the way Google's crash +reporting infrastructure aggregates and reports crashes. + +Some of the following also assumes that the `malloc()` implementation is +PartitionAlloc, which is as of 2022 the case on most platforms. + +[TOC] + +## Identifying OOM crashes + +When a process crashes due to an Out Of Memory condition, this is usually +signaled by the presence of `base::internal::OnNoMemoryInternal()` on the stack. + +**Google Chrome only:** crash report infrastructure tags these as "[Out of +Memory]" based on this, and other function names. The full list is determined in +the (internal) crash server's code. + +Since Chromium configures its memory allocators to prefer crashing rather than +returning `nullptr`, an OOM crash can be triggered from anywhere in the code, +and most commonly from within the allocator, or higher-level functions such as +`operator new` in C++. + +## Distinguishing between underlying causes +### Different causes + +A process can reach an OOM condition for several reasons: + +* **The OS is truly out of memory**, regardless of how much memory the *current* + process is using +* **Some limit inside the OS is reached**. For instance, on Windows, there + exists a global "commit limit", which is the amount of memory that the system + can commit. Note that it is possible to commit more memory than what is + actually in use. This may also happen on Linux systems configured with no or + limited "overcommit", though the majority of systems don't have a limit. +* **Virtual address space exhaustion**. This is most likely to happen for relatively + large allocations, on 32 bit systems, where total addressable space is + typically 2GiB (most Windows systems), 3GiB (e.g. some Windows configurations, + Linux) or 4GiB (e.g. WoW64). However, it may also happen on 64 bit systems, + either due to: + * Limited virtual addressable space in the CPU/OS. For instance most Android + ARM64 systems have only 40 bits of address space as of 2022. + * "Cage" exhaustion. This is most likely to happen with PartitionAlloc on 64 + bit systems, where all allocations are grouped into a single contiguous + virtual address space "cage". +* **Sandbox per-process memory limit**. For some process types (e.g. Renderers) + and on most platforms, the sandbox enforces a maximum per-process memory + limit. Given that this limit is typically set at the OS level, it may not be + distinguishable from e.g. commit limit exhaustion. +* **Excessive allocation size**. Some allocators (notably PartitionAlloc) + purposely limit the maximum allocation size. + +### Identifying the cause + +In the case of PartitionAlloc, it is possible to distinguish some of these cases: + +* **Virtual address space exhaustion**. This is identified by the presence of + `PartitionOutOfMemoryMappingFailure()` on the stack. It means that the + allocator was unable to find enough address space, either for its internal + memory allocation unit size, or the requested size. Since memory is *not* + committed as this step, this signals an address space issue. +* **Commit**. This is identified by the presence of + `PartitionOutOfMemoryCommitFailure()` on the stack. This signals that either + the OS or the sandbox limit has been reached. +* **Excessive allocation size**. Shown by `PartitionExcessiveAllocationSize()` + on the stack. + + +## What to do? + +### Commit Limit Reached + +The process is "truly" out of memory, or the system is. Some amount of these +crashes is expected, and the crashing location is not necessarily the +culprit. Indeed, as a rough approximation, the failing allocation is more likely +to be from a component naturally allocating a lot of memory, e.g. V8 or +rendering. + +However, if there is a spike, and many stack traces come from an unusual +location (e.g. newly added code), this may signal a memory leak in the component +on the stack, or excessive temporary allocations. + +Also, if `PartitionAllocDirectMap()` is on the stack, the memory allocation was +large. It may come from a large buffer, and potentially made worse by buffer +resizing. For instance, `std::vector` often double their size when out of +capacity. In which case, `reserve()`-ing the right size ahead of time may help. + +### Excessive allocation size + +Is the calling code expected to allocate more than 2GiB? Or it is an underflow +somewhere in the calling code? + +### Virtual address space + +On 32 bit systems, this is most likely to occur when overall memory usage is +high, or when the allocation size request is large. Is the calling code +allocating a very large buffer? + +## Debugging + +### General + +On Windows, the allocation size is added into the exception record. In Google +Chrome's crash dashboard, this is shown in "Parameter[0]" of the exception +info. On other operating systems, the allocation size if put on the stack before +crashing, and thus visible in minidumps. + +### PartitionAlloc and Google specific + +1. Starting from a specific report, click on the bug icon to start a cloud lldb + instance +2. Locate the `PartitionRoot<true>::OutOfMemory()` frame on the stack, move to it with `f 5` +3. Locate the stack addresses by printing registers `re re` +4. Show the stack content with `x <stack_pointer> <frame pointer>` + +Below is an example for a crash on x86_64: + +``` +( lizeb ) bt +* thread #1, stop reason = EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x10c45912f) + * frame #0: 0x000000010c45912f Google Chrome Framework`base::internal::OnNoMemoryInternal(unsigned long) at memory.cc:62 + frame #1: 0x000000010c459149 Google Chrome Framework`base::TerminateBecauseOutOfMemory(unsigned long) at memory.cc:69 + frame #2: 0x000000010c4f39c6 Google Chrome Framework`OnNoMemory(unsigned long) at oom.cc:17 + frame #3: 0x000000010d7e5794 Google Chrome Framework`WTF::PartitionsOutOfMemoryUsing2G(unsigned long) at partitions.cc:281 + frame #4: 0x000000010d7e4d2c Google Chrome Framework`WTF::Partitions::HandleOutOfMemory(unsigned long) at partitions.cc:415 + frame #5: 0x000000010c4f7474 Google Chrome Framework`base::PartitionRoot<true>::OutOfMemory(unsigned long) at partition_root.cc:521 +[...] +( lizeb ) f 5 +frame #5: 0x000000010c4f7474 Google Chrome Framework`base::PartitionRoot<true>::OutOfMemory(unsigned long) at partition_root.cc:521 +( lizeb ) re re +General Purpose Registers: + rbp = 0x00007ffee7012c50 + rsp = 0x00007ffee7012bf0 + rip = 0x000000010c4f7474 Google Chrome Framework`base::PartitionRoot<true>::OutOfMemory(unsigned long) + 196 at partition_root.cc:522 +21 registers were unavailable. +( lizeb ) x 0x00007ffee7012bf0 0x00007ffee7012c50 +0x7ffee7012bf0: 76 61 5f 73 69 7a 65 00 00 00 00 07 00 00 00 00 va_size......... +0x7ffee7012c00: 61 6c 6c 6f 63 00 20 20 00 2d 2d 01 00 00 00 00 alloc. .--..... +0x7ffee7012c10: 63 6f 6d 6d 69 74 00 20 00 a0 9d 01 00 00 00 00 commit. ........ +0x7ffee7012c20: 73 69 7a 65 00 20 20 20 00 00 20 00 00 00 00 00 size. .. ..... +0x7ffee7012c30: aa aa aa aa aa aa aa aa 00 18 b0 12 01 00 00 00 ................ +0x7ffee7012c40: 00 00 20 00 00 00 00 00 48 22 b0 12 01 00 00 00 .. .....H"...... +``` + +The results here can help the PartitionAlloc team to identify issues, as +important metrics from PartitionAlloc are saved above. For instance virtual +address space usage is (in little endian) 0x70000000.
diff --git a/extensions/browser/api/socket/OWNERS b/extensions/browser/api/socket/OWNERS index 9c3e19a..b29206a 100644 --- a/extensions/browser/api/socket/OWNERS +++ b/extensions/browser/api/socket/OWNERS
@@ -1,3 +1,5 @@ # Username must start with r reillyg@chromium.org rockot@google.com + +file://chromeos/TERMINAL_OWNERS
diff --git a/extensions/common/api/sockets/OWNERS b/extensions/common/api/sockets/OWNERS new file mode 100644 index 0000000..bf0229d --- /dev/null +++ b/extensions/common/api/sockets/OWNERS
@@ -0,0 +1 @@ +file://extensions/browser/api/socket/OWNERS
diff --git a/extensions/renderer/api/automation/automation_internal_custom_bindings.cc b/extensions/renderer/api/automation/automation_internal_custom_bindings.cc index 412a76e..18e2e553 100644 --- a/extensions/renderer/api/automation/automation_internal_custom_bindings.cc +++ b/extensions/renderer/api/automation/automation_internal_custom_bindings.cc
@@ -1746,6 +1746,14 @@ if (message_filter_) message_filter_->Detach(); + auto& child_tree_id_reverse_map = + AutomationAXTreeWrapper::GetChildTreeIDReverseMap(); + base::EraseIf( + child_tree_id_reverse_map, + [this](const std::pair<ui::AXTreeID, AutomationAXTreeWrapper*>& pair) { + return pair.second->owner() == this; + }); + tree_id_to_tree_wrapper_map_.clear(); }
diff --git a/extensions/renderer/resources/test_custom_bindings.js b/extensions/renderer/resources/test_custom_bindings.js index 7326836..027d42e 100644 --- a/extensions/renderer/resources/test_custom_bindings.js +++ b/extensions/renderer/resources/test_custom_bindings.js
@@ -296,13 +296,31 @@ // Note: Importing scripts is different depending on if this script is // executing in a Service Worker context. const inServiceWorker = 'ServiceWorkerGlobalScope' in self; + + function createError(exception) { + let errorStr = 'Unable to load script: "' + scriptUrl + '"'; + if (inServiceWorker) { + return new Error(errorStr, { cause:exception }); + } else { + return new Error(errorStr); + } + } + if (inServiceWorker) { - importScripts(scriptUrl); + try { + importScripts(scriptUrl); + } catch (e) { + return Promise.reject(createError(e)); + } return Promise.resolve(); } let script = document.createElement('script'); - let onScriptLoad = new Promise((resolve) => { + let onScriptLoad = new Promise((resolve, reject) => { script.onload = resolve; + function onError() { + reject(createError()); + } + script.onerror = onError; }); script.src = scriptUrl; document.body.appendChild(script);
diff --git a/extensions/test/data/sockets_tcp/OWNERS b/extensions/test/data/sockets_tcp/OWNERS new file mode 100644 index 0000000..bf0229d --- /dev/null +++ b/extensions/test/data/sockets_tcp/OWNERS
@@ -0,0 +1 @@ +file://extensions/browser/api/socket/OWNERS
diff --git a/extensions/test/data/sockets_tcp_server/OWNERS b/extensions/test/data/sockets_tcp_server/OWNERS new file mode 100644 index 0000000..bf0229d --- /dev/null +++ b/extensions/test/data/sockets_tcp_server/OWNERS
@@ -0,0 +1 @@ +file://extensions/browser/api/socket/OWNERS
diff --git a/extensions/test/data/sockets_udp/OWNERS b/extensions/test/data/sockets_udp/OWNERS new file mode 100644 index 0000000..bf0229d --- /dev/null +++ b/extensions/test/data/sockets_udp/OWNERS
@@ -0,0 +1 @@ +file://extensions/browser/api/socket/OWNERS
diff --git a/infra/config/generated/builders/ci/ios-m1-simulator/properties.json b/infra/config/generated/builders/ci/ios-m1-simulator/properties.json index c18caf9e..409d530 100644 --- a/infra/config/generated/builders/ci/ios-m1-simulator/properties.json +++ b/infra/config/generated/builders/ci/ios-m1-simulator/properties.json
@@ -1,4 +1,49 @@ { + "$build/chromium_tests_builder_config": { + "builder_config": { + "builder_db": { + "entries": [ + { + "builder_id": { + "bucket": "ci", + "builder": "ios-m1-simulator", + "project": "chromium" + }, + "builder_spec": { + "builder_group": "chromium.fyi", + "execution_mode": "COMPILE_AND_TEST", + "legacy_chromium_config": { + "apply_configs": [ + "mb", + "mac_toolchain" + ], + "build_config": "Debug", + "config": "chromium", + "target_bits": 64, + "target_platform": "ios" + }, + "legacy_gclient_config": { + "config": "ios" + } + } + } + ] + }, + "builder_ids": [ + { + "bucket": "ci", + "builder": "ios-m1-simulator", + "project": "chromium" + } + ], + "mirroring_builder_group_and_names": [ + { + "builder": "ios-m1-simulator", + "group": "tryserver.chromium.mac" + } + ] + } + }, "$build/goma": { "rpc_extra_params": "?prod", "server_host": "goma.chromium.org",
diff --git a/infra/config/generated/builders/try/ios-m1-simulator/properties.json b/infra/config/generated/builders/try/ios-m1-simulator/properties.json index b9041d6..eacb3c6 100644 --- a/infra/config/generated/builders/try/ios-m1-simulator/properties.json +++ b/infra/config/generated/builders/try/ios-m1-simulator/properties.json
@@ -1,4 +1,43 @@ { + "$build/chromium_tests_builder_config": { + "builder_config": { + "builder_db": { + "entries": [ + { + "builder_id": { + "bucket": "ci", + "builder": "ios-m1-simulator", + "project": "chromium" + }, + "builder_spec": { + "builder_group": "chromium.fyi", + "execution_mode": "COMPILE_AND_TEST", + "legacy_chromium_config": { + "apply_configs": [ + "mb", + "mac_toolchain" + ], + "build_config": "Debug", + "config": "chromium", + "target_bits": 64, + "target_platform": "ios" + }, + "legacy_gclient_config": { + "config": "ios" + } + } + } + ] + }, + "builder_ids": [ + { + "bucket": "ci", + "builder": "ios-m1-simulator", + "project": "chromium" + } + ] + } + }, "$build/goma": { "rpc_extra_params": "?prod", "server_host": "goma.chromium.org",
diff --git a/infra/config/generated/cq-builders.md b/infra/config/generated/cq-builders.md index c0a6718..f498732 100644 --- a/infra/config/generated/cq-builders.md +++ b/infra/config/generated/cq-builders.md
@@ -315,7 +315,7 @@ Path regular expressions: * [`//chromeos/components/chromebox_for_meetings/.+`](https://cs.chromium.org/chromium/src/chromeos/components/chromebox_for_meetings/) * [`//chromeos/dbus/chromebox_for_meetings/.+`](https://cs.chromium.org/chromium/src/chromeos/dbus/chromebox_for_meetings/) - * [`//chromeos/services/chromebox_for_meetings/.+`](https://cs.chromium.org/chromium/src/chromeos/services/chromebox_for_meetings/) + * [`//ash/services/chromebox_for_meetings/.+`](https://cs.chromium.org/chromium/src/ash/services/chromebox_for_meetings/) * [`//chrome/browser/ash/chromebox_for_meetings/.+`](https://cs.chromium.org/chromium/src/chrome/browser/ash/chromebox_for_meetings/) * [`//chrome/browser/resources/chromeos/chromebox_for_meetings/.+`](https://cs.chromium.org/chromium/src/chrome/browser/resources/chromeos/chromebox_for_meetings/) * [`//chrome/browser/ui/webui/chromeos/chromebox_for_meetings/.+`](https://cs.chromium.org/chromium/src/chrome/browser/ui/webui/chromeos/chromebox_for_meetings/)
diff --git a/infra/config/generated/cq-usage/full.cfg b/infra/config/generated/cq-usage/full.cfg index 8915da1..0b870233 100644 --- a/infra/config/generated/cq-usage/full.cfg +++ b/infra/config/generated/cq-usage/full.cfg
@@ -358,7 +358,7 @@ name: "chromium/try/linux-cfm-rel" location_regexp: ".+/[+]/chromeos/components/chromebox_for_meetings/.+" location_regexp: ".+/[+]/chromeos/dbus/chromebox_for_meetings/.+" - location_regexp: ".+/[+]/chromeos/services/chromebox_for_meetings/.+" + location_regexp: ".+/[+]/ash/services/chromebox_for_meetings/.+" location_regexp: ".+/[+]/chrome/browser/ash/chromebox_for_meetings/.+" location_regexp: ".+/[+]/chrome/browser/resources/chromeos/chromebox_for_meetings/.+" location_regexp: ".+/[+]/chrome/browser/ui/webui/chromeos/chromebox_for_meetings/.+"
diff --git a/infra/config/generated/luci/commit-queue.cfg b/infra/config/generated/luci/commit-queue.cfg index 6b8bfd31..efda8bf 100644 --- a/infra/config/generated/luci/commit-queue.cfg +++ b/infra/config/generated/luci/commit-queue.cfg
@@ -1246,7 +1246,7 @@ name: "chromium/try/linux-cfm-rel" location_regexp: ".+/[+]/chromeos/components/chromebox_for_meetings/.+" location_regexp: ".+/[+]/chromeos/dbus/chromebox_for_meetings/.+" - location_regexp: ".+/[+]/chromeos/services/chromebox_for_meetings/.+" + location_regexp: ".+/[+]/ash/services/chromebox_for_meetings/.+" location_regexp: ".+/[+]/chrome/browser/ash/chromebox_for_meetings/.+" location_regexp: ".+/[+]/chrome/browser/resources/chromeos/chromebox_for_meetings/.+" location_regexp: ".+/[+]/chrome/browser/ui/webui/chromeos/chromebox_for_meetings/.+"
diff --git a/infra/config/generated/luci/cr-buildbucket.cfg b/infra/config/generated/luci/cr-buildbucket.cfg index cc8c0dbbe..f8c67ef 100644 --- a/infra/config/generated/luci/cr-buildbucket.cfg +++ b/infra/config/generated/luci/cr-buildbucket.cfg
@@ -662,11 +662,10 @@ } properties: '{' - ' "$build/goma": {' - ' "enable_ats": true,' - ' "rpc_extra_params": "?prod",' - ' "server_host": "goma.chromium.org",' - ' "use_luci_auth": true' + ' "$build/reclient": {' + ' "instance": "rbe-chromium-trusted",' + ' "jobs": 250,' + ' "metrics_project": "chromium-reclient-metrics"' ' },' ' "$recipe_engine/resultdb/test_presentation": {' ' "column_keys": [],'
diff --git a/infra/config/subprojects/chromium/ci/chromium.fuzz.star b/infra/config/subprojects/chromium/ci/chromium.fuzz.star index a39abae..88e6390 100644 --- a/infra/config/subprojects/chromium/ci/chromium.fuzz.star +++ b/infra/config/subprojects/chromium/ci/chromium.fuzz.star
@@ -131,6 +131,9 @@ triggering_policy = scheduler.greedy_batching( max_concurrent_invocations = 4, ), + goma_backend = None, + reclient_jobs = rbe_jobs.DEFAULT, + reclient_instance = rbe_instance.DEFAULT, ) ci.builder(
diff --git a/infra/config/subprojects/chromium/ci/chromium.fyi.star b/infra/config/subprojects/chromium/ci/chromium.fyi.star index 0011e12..f58b5fa2 100644 --- a/infra/config/subprojects/chromium/ci/chromium.fyi.star +++ b/infra/config/subprojects/chromium/ci/chromium.fyi.star
@@ -1350,6 +1350,18 @@ fyi_ios_builder( name = "ios-m1-simulator", + builder_spec = builder_config.builder_spec( + gclient_config = builder_config.gclient_config( + config = "ios", + ), + chromium_config = builder_config.chromium_config( + config = "chromium", + apply_configs = ["mb", "mac_toolchain"], + build_config = builder_config.build_config.DEBUG, + target_bits = 64, + target_platform = builder_config.target_platform.IOS, + ), + ), console_view_entry = consoles.console_view_entry( category = "iOS|iOSM1", short_name = "iosM1",
diff --git a/infra/config/subprojects/chromium/try/tryserver.chromium.chromiumos.star b/infra/config/subprojects/chromium/try/tryserver.chromium.chromiumos.star index e167646..bca7fa1 100644 --- a/infra/config/subprojects/chromium/try/tryserver.chromium.chromiumos.star +++ b/infra/config/subprojects/chromium/try/tryserver.chromium.chromiumos.star
@@ -216,7 +216,7 @@ location_regexp = [ ".+/[+]/chromeos/components/chromebox_for_meetings/.+", ".+/[+]/chromeos/dbus/chromebox_for_meetings/.+", - ".+/[+]/chromeos/services/chromebox_for_meetings/.+", + ".+/[+]/ash/services/chromebox_for_meetings/.+", ".+/[+]/chrome/browser/ash/chromebox_for_meetings/.+", ".+/[+]/chrome/browser/resources/chromeos/chromebox_for_meetings/.+", ".+/[+]/chrome/browser/ui/webui/chromeos/chromebox_for_meetings/.+",
diff --git a/infra/config/subprojects/chromium/try/tryserver.chromium.mac.star b/infra/config/subprojects/chromium/try/tryserver.chromium.mac.star index ca7fff7..662de682 100644 --- a/infra/config/subprojects/chromium/try/tryserver.chromium.mac.star +++ b/infra/config/subprojects/chromium/try/tryserver.chromium.mac.star
@@ -252,6 +252,7 @@ ios_builder( name = "ios-m1-simulator", + mirrors = ["ci/ios-m1-simulator"], os = os.MAC_11, cpu = cpu.ARM64, )
diff --git a/ios/chrome/app/resources/ios_chrome_repack.gni b/ios/chrome/app/resources/ios_chrome_repack.gni index 94bab42..8403c0d 100644 --- a/ios/chrome/app/resources/ios_chrome_repack.gni +++ b/ios/chrome/app/resources/ios_chrome_repack.gni
@@ -31,6 +31,8 @@ "${root_gen_dir}/components/strings/components_${branding_path_component}_strings_", "${root_gen_dir}/components/strings/components_locale_settings_", "${root_gen_dir}/components/strings/components_strings_", + "${root_gen_dir}/components/omnibox/resources/omnibox_pedal_synonyms_", + "${root_gen_dir}/components/omnibox/resources/omnibox_resources_", "${root_gen_dir}/ios/chrome/ios_${branding_path_component}_strings_", "${root_gen_dir}/ios/chrome/ios_strings_", "${root_gen_dir}/third_party/libaddressinput/address_input_strings_", @@ -49,6 +51,8 @@ } deps = [ + "//components/omnibox/resources:omnibox_pedal_synonyms_grit", + "//components/omnibox/resources:omnibox_resources_grit", "//components/strings:components_${branding_path_component}_strings", "//components/strings:components_locale_settings", "//components/strings:components_strings",
diff --git a/ios/chrome/browser/autocomplete/BUILD.gn b/ios/chrome/browser/autocomplete/BUILD.gn index c8bf9afb..694f19d 100644 --- a/ios/chrome/browser/autocomplete/BUILD.gn +++ b/ios/chrome/browser/autocomplete/BUILD.gn
@@ -12,6 +12,8 @@ "autocomplete_scheme_classifier_impl.mm", "in_memory_url_index_factory.cc", "in_memory_url_index_factory.h", + "omnibox_pedal_implementation.h", + "omnibox_pedal_implementation.mm", "remote_suggestions_service_factory.h", "remote_suggestions_service_factory.mm", "shortcuts_backend_factory.h", @@ -30,10 +32,14 @@ "//components/keyed_service/ios", "//components/language/core/browser", "//components/omnibox/browser", + "//components/omnibox/resources:omnibox_pedal_synonyms", + "//components/omnibox/resources:omnibox_resources_grit", "//components/prefs", "//components/signin/public/identity_manager", + "//components/strings:components_strings_grit", "//components/sync", "//components/unified_consent", + "//ios/chrome/app/strings", "//ios/chrome/browser", "//ios/chrome/browser/bookmarks", "//ios/chrome/browser/browser_state",
diff --git a/ios/chrome/browser/autocomplete/DEPS b/ios/chrome/browser/autocomplete/DEPS new file mode 100644 index 0000000..b6818dc --- /dev/null +++ b/ios/chrome/browser/autocomplete/DEPS
@@ -0,0 +1,3 @@ +include_rules = [ + "+components/omnibox/resources", + ]
diff --git a/ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.h b/ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.h index 288d54e..683239a9 100644 --- a/ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.h +++ b/ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.h
@@ -5,6 +5,7 @@ #ifndef IOS_CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_PROVIDER_CLIENT_IMPL_H_ #define IOS_CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_PROVIDER_CLIENT_IMPL_H_ +#include "components/omnibox/browser/actions/omnibox_pedal.h" #include "components/omnibox/browser/autocomplete_provider_client.h" #include "ios/chrome/browser/autocomplete/autocomplete_scheme_classifier_impl.h" #include "ios/chrome/browser/autocomplete/tab_matcher_impl.h" @@ -97,6 +98,7 @@ std::unique_ptr<OmniboxTriggeredFeatureService> omnibox_triggered_feature_service_; TabMatcherImpl tab_matcher_; + std::unique_ptr<OmniboxPedalProvider> pedal_provider_; }; #endif // IOS_CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_PROVIDER_CLIENT_IMPL_H_
diff --git a/ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.mm b/ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.mm index 01591f5..61c9fb2 100644 --- a/ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.mm +++ b/ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.mm
@@ -9,6 +9,7 @@ #include "components/history/core/browser/history_service.h" #include "components/keyed_service/core/service_access_type.h" #include "components/language/core/browser/pref_names.h" +#include "components/omnibox/browser/actions/omnibox_pedal_provider.h" #include "components/omnibox/browser/autocomplete_classifier.h" #include "components/prefs/pref_service.h" #include "components/signin/public/identity_manager/identity_manager.h" @@ -17,6 +18,7 @@ #include "ios/chrome/browser/application_context.h" #include "ios/chrome/browser/autocomplete/autocomplete_classifier_factory.h" #include "ios/chrome/browser/autocomplete/in_memory_url_index_factory.h" +#import "ios/chrome/browser/autocomplete/omnibox_pedal_implementation.h" #include "ios/chrome/browser/autocomplete/remote_suggestions_service_factory.h" #include "ios/chrome/browser/autocomplete/shortcuts_backend_factory.h" #include "ios/chrome/browser/autocomplete/tab_matcher_impl.h" @@ -49,7 +51,10 @@ SyncServiceFactory::GetForBrowserState(browser_state_))), omnibox_triggered_feature_service_( std::make_unique<OmniboxTriggeredFeatureService>()), - tab_matcher_(browser_state_) {} + tab_matcher_(browser_state_) { + pedal_provider_ = std::make_unique<OmniboxPedalProvider>( + *this, GetPedalImplementations(IsOffTheRecord(), false)); +} AutocompleteProviderClientImpl::~AutocompleteProviderClientImpl() {} @@ -123,7 +128,7 @@ } OmniboxPedalProvider* AutocompleteProviderClientImpl::GetPedalProvider() const { - return nullptr; + return pedal_provider_.get(); } scoped_refptr<ShortcutsBackend>
diff --git a/ios/chrome/browser/autocomplete/omnibox_pedal_implementation.h b/ios/chrome/browser/autocomplete/omnibox_pedal_implementation.h new file mode 100644 index 0000000..ff6c88f --- /dev/null +++ b/ios/chrome/browser/autocomplete/omnibox_pedal_implementation.h
@@ -0,0 +1,18 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef IOS_CHROME_BROWSER_AUTOCOMPLETE_OMNIBOX_PEDAL_IMPLEMENTATION_H_ +#define IOS_CHROME_BROWSER_AUTOCOMPLETE_OMNIBOX_PEDAL_IMPLEMENTATION_H_ + +#include <unordered_map> + +#include "base/memory/scoped_refptr.h" +#include "components/omnibox/browser/actions/omnibox_pedal.h" +#include "components/omnibox/browser/actions/omnibox_pedal_concepts.h" + +// Returns the full set of encapsulated OmniboxPedal implementations. +std::unordered_map<OmniboxPedalId, scoped_refptr<OmniboxPedal>> +GetPedalImplementations(bool incognito, bool testing); + +#endif // IOS_CHROME_BROWSER_AUTOCOMPLETE_OMNIBOX_PEDAL_IMPLEMENTATION_H_
diff --git a/ios/chrome/browser/autocomplete/omnibox_pedal_implementation.mm b/ios/chrome/browser/autocomplete/omnibox_pedal_implementation.mm new file mode 100644 index 0000000..918cf1c --- /dev/null +++ b/ios/chrome/browser/autocomplete/omnibox_pedal_implementation.mm
@@ -0,0 +1,30 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "ios/chrome/browser/autocomplete/omnibox_pedal_implementation.h" + +#include "components/omnibox/browser/actions/omnibox_pedal.h" +#include "components/omnibox/browser/autocomplete_input.h" +#include "components/omnibox/browser/autocomplete_provider_client.h" +#include "components/omnibox/browser/buildflags.h" +#include "components/omnibox/browser/omnibox_client.h" +#include "components/omnibox/browser/omnibox_field_trial.h" +#include "components/omnibox/common/omnibox_features.h" +#include "components/omnibox/resources/grit/omnibox_pedal_synonyms.h" +#include "components/prefs/pref_service.h" +#include "components/strings/grit/components_strings.h" + +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + +std::unordered_map<OmniboxPedalId, scoped_refptr<OmniboxPedal>> +GetPedalImplementations(bool incognito, bool testing) { + std::unordered_map<OmniboxPedalId, scoped_refptr<OmniboxPedal>> pedals; + __unused const auto add = [&](OmniboxPedal* pedal) { + pedals.insert(std::make_pair(pedal->id(), base::WrapRefCounted(pedal))); + }; + + return pedals; +}
diff --git a/ios/chrome/browser/ui/authentication/signin/signin_coordinator.mm b/ios/chrome/browser/ui/authentication/signin/signin_coordinator.mm index 58afd68..5ee282e 100644 --- a/ios/chrome/browser/ui/authentication/signin/signin_coordinator.mm +++ b/ios/chrome/browser/ui/authentication/signin/signin_coordinator.mm
@@ -75,8 +75,7 @@ (Browser*)browser { DCHECK(!base::FeatureList::IsEnabled(kEnableFREUIModuleIOS)); UserSigninLogger* logger = [[FirstRunSigninLogger alloc] - initWithAccessPoint:AccessPoint::ACCESS_POINT_START_PAGE - promoAction:PromoAction::PROMO_ACTION_NO_SIGNIN_PROMO + initWithPromoAction:PromoAction::PROMO_ACTION_NO_SIGNIN_PROMO accountManagerService:ChromeAccountManagerServiceFactory:: GetForBrowserState(browser->GetBrowserState())]; return [[UserSigninCoordinator alloc]
diff --git a/ios/chrome/browser/ui/authentication/signin/user_signin/logging/BUILD.gn b/ios/chrome/browser/ui/authentication/signin/user_signin/logging/BUILD.gn index d7dae2d..3630a62 100644 --- a/ios/chrome/browser/ui/authentication/signin/user_signin/logging/BUILD.gn +++ b/ios/chrome/browser/ui/authentication/signin/user_signin/logging/BUILD.gn
@@ -9,6 +9,8 @@ sources = [ "first_run_signin_logger.h", "first_run_signin_logger.mm", + "force_signin_logger.h", + "force_signin_logger.mm", "upgrade_signin_logger.h", "upgrade_signin_logger.mm", "user_signin_logger.h",
diff --git a/ios/chrome/browser/ui/authentication/signin/user_signin/logging/first_run_signin_logger.h b/ios/chrome/browser/ui/authentication/signin/user_signin/logging/first_run_signin_logger.h index ee517e5..34446e7f 100644 --- a/ios/chrome/browser/ui/authentication/signin/user_signin/logging/first_run_signin_logger.h +++ b/ios/chrome/browser/ui/authentication/signin/user_signin/logging/first_run_signin_logger.h
@@ -9,6 +9,19 @@ // Logs metrics for Chrome first-run operations. @interface FirstRunSigninLogger : UserSigninLogger + +- (instancetype)initWithAccessPoint:(signin_metrics::AccessPoint)accessPoint + promoAction:(signin_metrics::PromoAction)promoAction + accountManagerService: + (ChromeAccountManagerService*)accountManagerService + NS_UNAVAILABLE; + +// The designated initializer. +- (instancetype)initWithPromoAction:(signin_metrics::PromoAction)promoAction + accountManagerService: + (ChromeAccountManagerService*)accountManagerService + NS_DESIGNATED_INITIALIZER; + @end #endif // IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_USER_SIGNIN_LOGGING_FIRST_RUN_SIGNIN_LOGGER_H_
diff --git a/ios/chrome/browser/ui/authentication/signin/user_signin/logging/first_run_signin_logger.mm b/ios/chrome/browser/ui/authentication/signin/user_signin/logging/first_run_signin_logger.mm index e980a1c..eec7748 100644 --- a/ios/chrome/browser/ui/authentication/signin/user_signin/logging/first_run_signin_logger.mm +++ b/ios/chrome/browser/ui/authentication/signin/user_signin/logging/first_run_signin_logger.mm
@@ -8,11 +8,6 @@ #error "This file requires ARC support." #endif -using signin_metrics::AccessPoint; -using signin_metrics::LogSigninAccessPointStarted; -using signin_metrics::PromoAction; -using signin_metrics::RecordSigninUserActionForAccessPoint; - @interface FirstRunSigninLogger () // Presenter for showing sync-related UI. @@ -24,16 +19,22 @@ #pragma mark - Public +- (instancetype)initWithPromoAction:(signin_metrics::PromoAction)promoAction + accountManagerService: + (ChromeAccountManagerService*)accountManagerService { + return [super + initWithAccessPoint:signin_metrics::AccessPoint::ACCESS_POINT_START_PAGE + promoAction:promoAction + accountManagerService:accountManagerService]; +} + - (void)logSigninStarted { if (!self.hasRecordedSigninStarted) { self.hasRecordedSigninStarted = YES; - LogSigninAccessPointStarted(self.accessPoint, self.promoAction); - if (self.accessPoint != AccessPoint::ACCESS_POINT_FORCED_SIGNIN) { - // Don't record a sign-in user action when the access point forces the - // user to sign-in. Signing in in that case isn't really an action but - // rather something required by the policy. - RecordSigninUserActionForAccessPoint(self.accessPoint, self.promoAction); - } + signin_metrics::LogSigninAccessPointStarted(self.accessPoint, + self.promoAction); + signin_metrics::RecordSigninUserActionForAccessPoint(self.accessPoint, + self.promoAction); } }
diff --git a/ios/chrome/browser/ui/authentication/signin/user_signin/logging/force_signin_logger.h b/ios/chrome/browser/ui/authentication/signin/user_signin/logging/force_signin_logger.h new file mode 100644 index 0000000..bbee35a --- /dev/null +++ b/ios/chrome/browser/ui/authentication/signin/user_signin/logging/force_signin_logger.h
@@ -0,0 +1,27 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_USER_SIGNIN_LOGGING_FORCE_SIGNIN_LOGGER_H_ +#define IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_USER_SIGNIN_LOGGING_FORCE_SIGNIN_LOGGER_H_ + +#import "ios/chrome/browser/ui/authentication/signin/user_signin/logging/user_signin_logger.h" + +// Logs metrics for Chrome first-run operations. +@interface ForceSigninLogger : UserSigninLogger + +- (instancetype)initWithAccessPoint:(signin_metrics::AccessPoint)accessPoint + promoAction:(signin_metrics::PromoAction)promoAction + accountManagerService: + (ChromeAccountManagerService*)accountManagerService + NS_UNAVAILABLE; + +// The designated initializer. +- (instancetype)initWithPromoAction:(signin_metrics::PromoAction)promoAction + accountManagerService: + (ChromeAccountManagerService*)accountManagerService + NS_DESIGNATED_INITIALIZER; + +@end + +#endif // IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_USER_SIGNIN_LOGGING_FORCE_SIGNIN_LOGGER_H_
diff --git a/ios/chrome/browser/ui/authentication/signin/user_signin/logging/force_signin_logger.mm b/ios/chrome/browser/ui/authentication/signin/user_signin/logging/force_signin_logger.mm new file mode 100644 index 0000000..9c24556 --- /dev/null +++ b/ios/chrome/browser/ui/authentication/signin/user_signin/logging/force_signin_logger.mm
@@ -0,0 +1,39 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "ios/chrome/browser/ui/authentication/signin/user_signin/logging/force_signin_logger.h" + +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + +@interface ForceSigninLogger () + +// Presenter for showing sync-related UI. +@property(nonatomic, assign) BOOL hasRecordedSigninStarted; + +@end + +@implementation ForceSigninLogger + +#pragma mark - Public + +- (instancetype)initWithPromoAction:(signin_metrics::PromoAction)promoAction + accountManagerService: + (ChromeAccountManagerService*)accountManagerService { + return [super initWithAccessPoint:signin_metrics::AccessPoint:: + ACCESS_POINT_FORCED_SIGNIN + promoAction:promoAction + accountManagerService:accountManagerService]; +} + +- (void)logSigninStarted { + if (!self.hasRecordedSigninStarted) { + self.hasRecordedSigninStarted = YES; + signin_metrics::LogSigninAccessPointStarted(self.accessPoint, + self.promoAction); + } +} + +@end
diff --git a/ios/chrome/browser/ui/authentication/signin_sync/signin_sync_mediator.mm b/ios/chrome/browser/ui/authentication/signin_sync/signin_sync_mediator.mm index 4d4daaa..2f502ce 100644 --- a/ios/chrome/browser/ui/authentication/signin_sync/signin_sync_mediator.mm +++ b/ios/chrome/browser/ui/authentication/signin_sync/signin_sync_mediator.mm
@@ -85,9 +85,7 @@ self, _accountManagerService); _logger = [[FirstRunSigninLogger alloc] - initWithAccessPoint:signin_metrics::AccessPoint:: - ACCESS_POINT_START_PAGE - promoAction:signin_metrics::PromoAction:: + initWithPromoAction:signin_metrics::PromoAction:: PROMO_ACTION_NO_SIGNIN_PROMO accountManagerService:accountManagerService];
diff --git a/ios/chrome/browser/ui/commands/BUILD.gn b/ios/chrome/browser/ui/commands/BUILD.gn index 7c6251e..e427b6a 100644 --- a/ios/chrome/browser/ui/commands/BUILD.gn +++ b/ios/chrome/browser/ui/commands/BUILD.gn
@@ -47,6 +47,7 @@ "text_zoom_commands.h", "thumb_strip_commands.h", "toolbar_commands.h", + "tos_commands.h", "whats_new_commands.h", ]
diff --git a/ios/chrome/browser/ui/first_run/welcome/tos_commands.h b/ios/chrome/browser/ui/commands/tos_commands.h similarity index 73% rename from ios/chrome/browser/ui/first_run/welcome/tos_commands.h rename to ios/chrome/browser/ui/commands/tos_commands.h index 4d500acc..c295ee6 100644 --- a/ios/chrome/browser/ui/first_run/welcome/tos_commands.h +++ b/ios/chrome/browser/ui/commands/tos_commands.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef IOS_CHROME_BROWSER_UI_FIRST_RUN_WELCOME_TOS_COMMANDS_H_ -#define IOS_CHROME_BROWSER_UI_FIRST_RUN_WELCOME_TOS_COMMANDS_H_ +#ifndef IOS_CHROME_BROWSER_UI_COMMANDS_TOS_COMMANDS_H_ +#define IOS_CHROME_BROWSER_UI_COMMANDS_TOS_COMMANDS_H_ // Commands related to the Terms of Service (ToS) UI use in welcome screen from // the first run experience. It displays the ToS in modal view with a top @@ -19,4 +19,4 @@ @end -#endif // IOS_CHROME_BROWSER_UI_FIRST_RUN_WELCOME_TOS_COMMANDS_H_ +#endif // IOS_CHROME_BROWSER_UI_COMMANDS_TOS_COMMANDS_H_
diff --git a/ios/chrome/browser/ui/first_run/legacy_signin/legacy_signin_screen_mediator.mm b/ios/chrome/browser/ui/first_run/legacy_signin/legacy_signin_screen_mediator.mm index fd5455b..1a2d292d6 100644 --- a/ios/chrome/browser/ui/first_run/legacy_signin/legacy_signin_screen_mediator.mm +++ b/ios/chrome/browser/ui/first_run/legacy_signin/legacy_signin_screen_mediator.mm
@@ -9,7 +9,7 @@ #import "ios/chrome/browser/ui/authentication/authentication_flow.h" #import "ios/chrome/browser/ui/authentication/enterprise/enterprise_utils.h" #import "ios/chrome/browser/ui/authentication/signin/user_signin/logging/first_run_signin_logger.h" -#import "ios/chrome/browser/ui/authentication/signin/user_signin/logging/user_signin_logger.h" +#import "ios/chrome/browser/ui/authentication/signin/user_signin/logging/force_signin_logger.h" #import "ios/chrome/browser/ui/first_run/legacy_signin/legacy_signin_screen_consumer.h" #import "ios/public/provider/chrome/browser/signin/chrome_identity.h" @@ -54,17 +54,17 @@ // access point will still be used. The forced sign-in screen may also be // presented outside of the FRE when the user has to be prompted to sign-in // because of the policy. - signin_metrics::AccessPoint accessPoint = - IsForceSignInEnabled() - ? signin_metrics::AccessPoint::ACCESS_POINT_FORCED_SIGNIN - : signin_metrics::AccessPoint::ACCESS_POINT_START_PAGE; - - _logger = [[FirstRunSigninLogger alloc] - initWithAccessPoint:accessPoint - promoAction:signin_metrics::PromoAction:: - PROMO_ACTION_NO_SIGNIN_PROMO - accountManagerService:accountManagerService]; - + if (IsForceSignInEnabled()) { + _logger = [[ForceSigninLogger alloc] + initWithPromoAction:signin_metrics::PromoAction:: + PROMO_ACTION_NO_SIGNIN_PROMO + accountManagerService:accountManagerService]; + } else { + _logger = [[FirstRunSigninLogger alloc] + initWithPromoAction:signin_metrics::PromoAction:: + PROMO_ACTION_NO_SIGNIN_PROMO + accountManagerService:accountManagerService]; + } [_logger logSigninStarted]; } return self;
diff --git a/ios/chrome/browser/ui/first_run/welcome/BUILD.gn b/ios/chrome/browser/ui/first_run/welcome/BUILD.gn index 5cabff7..62caf51a 100644 --- a/ios/chrome/browser/ui/first_run/welcome/BUILD.gn +++ b/ios/chrome/browser/ui/first_run/welcome/BUILD.gn
@@ -18,6 +18,7 @@ "//ios/chrome/browser/browser_state", "//ios/chrome/browser/main:public", "//ios/chrome/browser/ui/commands", + "//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/coordinators:chrome_coordinators", "//ios/chrome/browser/ui/first_run:screen_delegate", "//ios/chrome/browser/ui/first_run/uma", @@ -33,7 +34,6 @@ sources = [ "checkbox_button.h", "checkbox_button.mm", - "tos_commands.h", "tos_view_controller.h", "tos_view_controller.mm", "welcome_screen_mediator.h", @@ -48,6 +48,7 @@ "//components/prefs", "//ios/chrome/app/strings", "//ios/chrome/browser", + "//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/first_run:constants", "//ios/chrome/browser/ui/first_run/resources:welcome_metrics_checkmark", "//ios/chrome/browser/ui/first_run/resources:welcome_screen_banner",
diff --git a/ios/chrome/browser/ui/first_run/welcome/tos_coordinator.mm b/ios/chrome/browser/ui/first_run/welcome/tos_coordinator.mm index a63098bd..10ac3c6 100644 --- a/ios/chrome/browser/ui/first_run/welcome/tos_coordinator.mm +++ b/ios/chrome/browser/ui/first_run/welcome/tos_coordinator.mm
@@ -11,7 +11,7 @@ #include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/main/browser.h" #import "ios/chrome/browser/ui/commands/command_dispatcher.h" -#import "ios/chrome/browser/ui/first_run/welcome/tos_commands.h" +#import "ios/chrome/browser/ui/commands/tos_commands.h" #import "ios/chrome/browser/ui/first_run/welcome/tos_view_controller.h" #include "ios/chrome/browser/ui/util/terms_util.h" #import "ios/web/common/web_view_creation_util.h"
diff --git a/ios/chrome/browser/ui/first_run/welcome/tos_view_controller.mm b/ios/chrome/browser/ui/first_run/welcome/tos_view_controller.mm index 9538a40..5e12f22 100644 --- a/ios/chrome/browser/ui/first_run/welcome/tos_view_controller.mm +++ b/ios/chrome/browser/ui/first_run/welcome/tos_view_controller.mm
@@ -7,7 +7,7 @@ #import <WebKit/WebKit.h> #include "base/check.h" -#import "ios/chrome/browser/ui/first_run/welcome/tos_commands.h" +#import "ios/chrome/browser/ui/commands/tos_commands.h" #import "ios/chrome/common/ui/colors/semantic_color_names.h" #include "ios/chrome/grit/ios_strings.h" #include "ui/base/l10n/l10n_util.h"
diff --git a/ios/chrome/browser/ui/first_run/welcome/welcome_screen_coordinator.mm b/ios/chrome/browser/ui/first_run/welcome/welcome_screen_coordinator.mm index 803180e..f84434e 100644 --- a/ios/chrome/browser/ui/first_run/welcome/welcome_screen_coordinator.mm +++ b/ios/chrome/browser/ui/first_run/welcome/welcome_screen_coordinator.mm
@@ -8,7 +8,7 @@ #include "base/metrics/user_metrics_action.h" #include "ios/chrome/browser/main/browser.h" #import "ios/chrome/browser/ui/commands/command_dispatcher.h" -#include "ios/chrome/browser/ui/first_run/welcome/tos_commands.h" +#include "ios/chrome/browser/ui/commands/tos_commands.h" #include "ios/chrome/browser/ui/first_run/welcome/tos_coordinator.h" #include "ios/chrome/browser/ui/first_run/welcome/welcome_screen_mediator.h" #include "ios/chrome/browser/ui/first_run/welcome/welcome_screen_view_controller.h"
diff --git a/ios/chrome/browser/ui/first_run/welcome/welcome_screen_view_controller.mm b/ios/chrome/browser/ui/first_run/welcome/welcome_screen_view_controller.mm index 4941851..549e58147 100644 --- a/ios/chrome/browser/ui/first_run/welcome/welcome_screen_view_controller.mm +++ b/ios/chrome/browser/ui/first_run/welcome/welcome_screen_view_controller.mm
@@ -5,9 +5,9 @@ #import "ios/chrome/browser/ui/first_run/welcome/welcome_screen_view_controller.h" #import "components/policy/core/common/policy_loader_ios_constants.h" +#import "ios/chrome/browser/ui/commands/tos_commands.h" #import "ios/chrome/browser/ui/first_run/first_run_constants.h" #import "ios/chrome/browser/ui/first_run/welcome/checkbox_button.h" -#import "ios/chrome/browser/ui/first_run/welcome/tos_commands.h" #import "ios/chrome/common/string_util.h" #import "ios/chrome/common/ui/colors/semantic_color_names.h" #import "ios/chrome/common/ui/util/pointer_interaction_util.h"
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_egtest.mm b/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_egtest.mm index 298e2bd..2f1d30c 100644 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_egtest.mm +++ b/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_egtest.mm
@@ -193,7 +193,7 @@ grey_sufficientlyVisible(), nil); } -// Returns a matcher for the "Search recent tabs" suggested action. +// Returns a matcher for the "Search open tabs" suggested action. id<GREYMatcher> SearchOpenTabsSuggestedAction() { return grey_allOf(chrome_test_util::StaticTextWithAccessibilityLabelId( IDS_IOS_TABS_SEARCH_SUGGESTED_ACTION_SEARCH_OPEN_TABS), @@ -208,7 +208,7 @@ } // Returns a matcher for the "Search history (|matches_count| Found)" suggested -// action. +// action on the regular tab grid. id<GREYMatcher> SearchHistorySuggestedActionWithMatches(size_t matches_count) { NSString* count_str = [NSString stringWithFormat:@"%" PRIuS, matches_count]; NSString* history_label = l10n_util::GetNSStringF( @@ -218,6 +218,16 @@ grey_sufficientlyVisible(), nil); } +// Returns a matcher for the "Search history (|matches_count| Found)" suggested +// action on the recent tabs page. +id<GREYMatcher> RecentTabsSearchHistorySuggestedActionWithMatches( + size_t matches_count) { + return grey_allOf( + RecentTabsTable(), + grey_descendant(SearchHistorySuggestedActionWithMatches(matches_count)), + nil); +} + // Returns a matcher for the search suggested actions section. id<GREYMatcher> SearchSuggestedActionsSection() { return grey_allOf(grey_accessibilityID(kSuggestedActionsGridCellIdentifier), @@ -269,7 +279,10 @@ @selector(testOpenTabsHeaderVisibleInSearchModeWhenSearchBarIsNotEmpty), @selector(testSuggestedActionsVisibleInSearchModeWhenSearchBarIsNotEmpty), @selector(testSearchSuggestedActionsDisplaysCorrectHistoryMatchesCount), + @selector + (testRecentTabsSearchSuggestedActionsDisplaysCorrectHistoryMatchesCount), @selector(testSearchSuggestedActionsSectionContentInRegularGrid), + @selector(testSearchSuggestedActionsSectionContentInRecentTabs), @selector(testSuggestedActionsNotAvailableInIncognitoPageSearchMode), @selector(testSearchSuggestedActionsPageSwitch), @selector(testHistorySuggestedActionInRegularTabsSearch), @@ -1724,6 +1737,41 @@ assertWithMatcher:grey_notNil()]; } +// Tests that the search suggested actions section has the right rows in the +// recent tabs page. +- (void)testSearchSuggestedActionsSectionContentInRecentTabs { + [self loadTestURLsInNewTabs]; + [ChromeEarlGrey showTabSwitcher]; + [[EarlGrey selectElementWithMatcher:TabGridOtherDevicesPanelButton()] + performAction:grey_tap()]; + + // Enter search mode and enter a search query. + [[EarlGrey selectElementWithMatcher:TabGridSearchTabsButton()] + performAction:grey_tap()]; + // TODO(crbug.com/1306246): Scrolling doesn't work properly in very small + // devices. Once that is fixed a more broad query can be used for searching + // (eg. "page"). + NSString* query = [NSString stringWithFormat:@"%s\n", kTitle2]; + [[EarlGrey selectElementWithMatcher:TabGridSearchBar()] + performAction:grey_typeText(query)]; + + // Verify that the suggested actions section exist and has "Search on web", + // "Search open tabs", "Search history" rows. + [[self scrollDownViewMatcher:RecentTabsTable() + toSelectMatcher:chrome_test_util::HeaderWithAccessibilityLabelId( + IDS_IOS_TABS_SEARCH_SUGGESTED_ACTIONS)] + assertWithMatcher:grey_sufficientlyVisible()]; + [[self scrollDownViewMatcher:RecentTabsTable() + toSelectMatcher:SearchOnWebSuggestedAction()] + assertWithMatcher:grey_notNil()]; + [[self scrollDownViewMatcher:RecentTabsTable() + toSelectMatcher:SearchOpenTabsSuggestedAction()] + assertWithMatcher:grey_notNil()]; + [[self scrollDownViewMatcher:RecentTabsTable() + toSelectMatcher:SearchHistorySuggestedAction()] + assertWithMatcher:grey_notNil()]; +} + // Tests that history row in the search suggested actions section displays the // correct number of matches. - (void)testSearchSuggestedActionsDisplaysCorrectHistoryMatchesCount { @@ -1761,6 +1809,49 @@ performAction:grey_tap()]; } +// Tests that history row in the search suggested actions section displays the +// correct number of matches in recent tabs. +- (void)testRecentTabsSearchSuggestedActionsDisplaysCorrectHistoryMatchesCount { + [ChromeEarlGrey clearBrowsingHistory]; + [self loadTestURLs]; + [ChromeEarlGrey showTabSwitcher]; + [[EarlGrey selectElementWithMatcher:TabGridOtherDevicesPanelButton()] + performAction:grey_tap()]; + + // Enter search mode. + [[EarlGrey selectElementWithMatcher:TabGridSearchTabsButton()] + performAction:grey_tap()]; + + // Verify that the suggested actions section does not exist. + [[EarlGrey + selectElementWithMatcher:chrome_test_util::HeaderWithAccessibilityLabelId( + IDS_IOS_TABS_SEARCH_SUGGESTED_ACTIONS)] + assertWithMatcher:grey_notVisible()]; + + // Searching the word "page" matches 2 items from history. + [[EarlGrey selectElementWithMatcher:TabGridSearchBar()] + performAction:grey_typeText(@"page\n")]; + [[self + scrollDownViewMatcher:RecentTabsTable() + toSelectMatcher:RecentTabsSearchHistorySuggestedActionWithMatches( + 2)] + assertWithMatcher:grey_sufficientlyVisible()]; + + // Adding to the existing query " two" will search for "page two" and should + // only match 1 item from the history. + [[EarlGrey selectElementWithMatcher:TabGridSearchBar()] + performAction:grey_typeText(@" two\n")]; + [[self + scrollDownViewMatcher:RecentTabsTable() + toSelectMatcher:RecentTabsSearchHistorySuggestedActionWithMatches( + 1)] + assertWithMatcher:grey_sufficientlyVisible()]; + + // Cancel search mode. + [[EarlGrey selectElementWithMatcher:TabGridSearchCancelButton()] + performAction:grey_tap()]; +} + // Tests that selecting an open tab search result in the regular mode will // correctly open the expected tab. - (void)testSearchRegularOpenTabsSelectResult {
diff --git a/ios/web/js_messaging/java_script_feature_manager.mm b/ios/web/js_messaging/java_script_feature_manager.mm index 8191285..3effbbb 100644 --- a/ios/web/js_messaging/java_script_feature_manager.mm +++ b/ios/web/js_messaging/java_script_feature_manager.mm
@@ -64,13 +64,9 @@ std::make_unique<JavaScriptContentWorld>(browser_state_); AddSharedCommonFeatures(page_content_world_.get()); -#if defined(__IPHONE_14_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0 - if (@available(iOS 14, *)) { - isolated_world_ = std::make_unique<JavaScriptContentWorld>( - browser_state_, WKContentWorld.defaultClientWorld); - AddSharedCommonFeatures(isolated_world_.get()); - } -#endif // defined(__IPHONE14_0) + isolated_world_ = std::make_unique<JavaScriptContentWorld>( + browser_state_, WKContentWorld.defaultClientWorld); + AddSharedCommonFeatures(isolated_world_.get()); for (JavaScriptFeature* feature : features) { if (isolated_world_ &&
diff --git a/net/proxy_resolution/proxy_config_service_linux.cc b/net/proxy_resolution/proxy_config_service_linux.cc index ecde7a5..4406f2b0 100644 --- a/net/proxy_resolution/proxy_config_service_linux.cc +++ b/net/proxy_resolution/proxy_config_service_linux.cc
@@ -1208,6 +1208,7 @@ case base::nix::DESKTOP_ENVIRONMENT_CINNAMON: case base::nix::DESKTOP_ENVIRONMENT_GNOME: case base::nix::DESKTOP_ENVIRONMENT_PANTHEON: + case base::nix::DESKTOP_ENVIRONMENT_UKUI: case base::nix::DESKTOP_ENVIRONMENT_UNITY: #if defined(USE_GIO) {
diff --git a/skia/ext/benchmarking_canvas.cc b/skia/ext/benchmarking_canvas.cc index cc8f4a4..4aecb9a9 100644 --- a/skia/ext/benchmarking_canvas.cc +++ b/skia/ext/benchmarking_canvas.cc
@@ -111,7 +111,7 @@ std::unique_ptr<base::Value> AsValue(const SkMatrix& matrix) { std::unique_ptr<base::ListValue> val(new base::ListValue()); for (int i = 0; i < 9; ++i) - val->Append(AsValue(matrix[i])); + val->Append(base::Value::FromUniquePtrValue(AsValue(matrix[i]))); return std::move(val); } @@ -154,8 +154,10 @@ SkScalar color_matrix[20]; if (filter.asAColorMatrix(color_matrix)) { std::unique_ptr<base::ListValue> color_matrix_val(new base::ListValue()); - for (unsigned i = 0; i < 20; ++i) - color_matrix_val->Append(AsValue(color_matrix[i])); + for (unsigned i = 0; i < 20; ++i) { + color_matrix_val->Append( + base::Value::FromUniquePtrValue(AsValue(color_matrix[i]))); + } val->SetKey("color_matrix", base::Value::FromUniquePtrValue(std::move(color_matrix_val))); @@ -322,7 +324,7 @@ std::unique_ptr<base::ListValue> val(new base::ListValue()); for (size_t i = 0; i < count; ++i) - val->Append(AsValue(array[i])); + val->Append(base::Value::FromUniquePtrValue(AsValue(array[i]))); return std::move(val); } @@ -358,14 +360,15 @@ base::TimeDelta ticks = base::TimeTicks::Now() - start_ticks_; op_record_->SetDouble("cmd_time", ticks.InMillisecondsF()); - canvas_->op_records_.Append(std::move(op_record_)); + canvas_->op_records_.Append( + base::Value::FromUniquePtrValue(std::move(op_record_))); } void addParam(const char name[], std::unique_ptr<base::Value> value) { std::unique_ptr<base::DictionaryValue> param(new base::DictionaryValue()); param->SetKey(name, base::Value::FromUniquePtrValue(std::move(value))); - op_params_->Append(std::move(param)); + op_params_->Append(base::Value::FromUniquePtrValue(std::move(param))); } const SkPaint* paint() const { return &filtered_paint_; }
diff --git a/storage/browser/quota/quota_database.cc b/storage/browser/quota/quota_database.cc index 4ce5c9b..3909485 100644 --- a/storage/browser/quota/quota_database.cc +++ b/storage/browser/quota/quota_database.cc
@@ -975,27 +975,6 @@ return EnsureOpened(EnsureOpenedMode::kCreateIfNotFound) == QuotaError::kNone; } -QuotaError QuotaDatabase::DumpQuotaTable(const QuotaTableCallback& callback) { - DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - QuotaError open_error = EnsureOpened(EnsureOpenedMode::kCreateIfNotFound); - if (open_error != QuotaError::kNone) - return open_error; - - static constexpr char kSql[] = "SELECT * FROM quota"; - sql::Statement statement(db_->GetCachedStatement(SQL_FROM_HERE, kSql)); - - while (statement.Step()) { - QuotaTableEntry entry = { - .host = statement.ColumnString(0), - .type = static_cast<StorageType>(statement.ColumnInt(1)), - .quota = statement.ColumnInt64(2)}; - - if (!callback.Run(entry)) - return QuotaError::kNone; - } - return statement.Succeeded() ? QuotaError::kNone : QuotaError::kDatabaseError; -} - QuotaError QuotaDatabase::DumpBucketTable(const BucketTableCallback& callback) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); QuotaError open_error = EnsureOpened(EnsureOpenedMode::kCreateIfNotFound); @@ -1083,18 +1062,6 @@ base::Time::Max(), 0); } -bool operator==(const QuotaDatabase::QuotaTableEntry& lhs, - const QuotaDatabase::QuotaTableEntry& rhs) { - return std::tie(lhs.host, lhs.type, lhs.quota) == - std::tie(rhs.host, rhs.type, rhs.quota); -} - -bool operator<(const QuotaDatabase::QuotaTableEntry& lhs, - const QuotaDatabase::QuotaTableEntry& rhs) { - return std::tie(lhs.host, lhs.type, lhs.quota) < - std::tie(rhs.host, rhs.type, rhs.quota); -} - bool operator<(const QuotaDatabase::BucketTableEntry& lhs, const QuotaDatabase::BucketTableEntry& rhs) { return std::tie(lhs.storage_key, lhs.type, lhs.use_count, lhs.last_accessed) <
diff --git a/storage/browser/quota/quota_database_unittest.cc b/storage/browser/quota/quota_database_unittest.cc index 09f6eee..d7965f6 100644 --- a/storage/browser/quota/quota_database_unittest.cc +++ b/storage/browser/quota/quota_database_unittest.cc
@@ -57,7 +57,6 @@ // mode. True will create the database in memory. class QuotaDatabaseTest : public testing::TestWithParam<bool> { protected: - using QuotaTableEntry = QuotaDatabase::QuotaTableEntry; using BucketTableEntry = QuotaDatabase::BucketTableEntry; using EnsureOpenedMode = QuotaDatabase::EnsureOpenedMode; @@ -833,25 +832,6 @@ EXPECT_EQ(1, info->use_count); } -TEST_P(QuotaDatabaseTest, DumpQuotaTable) { - QuotaTableEntry kTableEntries[] = { - {.host = "http://go/", .type = kTemp, .quota = 1}, - {.host = "http://oo/", .type = kTemp, .quota = 2}, - {.host = "http://gle/", .type = kPerm, .quota = 3}}; - - QuotaDatabase db(use_in_memory_db() ? base::FilePath() : DbPath()); - EXPECT_TRUE(EnsureOpened(&db, EnsureOpenedMode::kCreateIfNotFound)); - AssignQuotaTable(&db, kTableEntries); - - using Verifier = EntryVerifier<QuotaTableEntry>; - Verifier verifier(kTableEntries, std::end(kTableEntries)); - EXPECT_EQ( - DumpQuotaTable(&db, base::BindRepeating(&Verifier::Run, - base::Unretained(&verifier))), - QuotaError::kNone); - EXPECT_TRUE(verifier.table.empty()); -} - TEST_P(QuotaDatabaseTest, DumpBucketTable) { base::Time now = base::Time::Now(); using Entry = QuotaDatabase::BucketTableEntry;
diff --git a/storage/browser/quota/quota_manager_impl.cc b/storage/browser/quota/quota_manager_impl.cc index 746f2fa..3021904 100644 --- a/storage/browser/quota/quota_manager_impl.cc +++ b/storage/browser/quota/quota_manager_impl.cc
@@ -1109,43 +1109,7 @@ // Gather storage key info table for quota-internals page. // // This class is granted ownership of itself when it is passed to -// DidDumpQuotaTable() via base::Owned(). When the closure for said function -// goes out of scope, the object is deleted. -// This class is not thread-safe because there can be a race when entries_ is -// modified. -class QuotaManagerImpl::DumpQuotaTableHelper { - public: - QuotaError DumpQuotaTableOnDBThread(QuotaDatabase* database) { - DCHECK(database); - return database->DumpQuotaTable(base::BindRepeating( - &DumpQuotaTableHelper::AppendEntry, base::Unretained(this))); - } - - void DidDumpQuotaTable(const base::WeakPtr<QuotaManagerImpl>& manager, - DumpQuotaTableCallback callback, - QuotaError error) { - if (!manager) { - // The operation was aborted. - std::move(callback).Run(QuotaTableEntries()); - return; - } - manager->DidDatabaseWork(error != QuotaError::kDatabaseError); - std::move(callback).Run(entries_); - } - - private: - bool AppendEntry(const QuotaTableEntry& entry) { - entries_.push_back(entry); - return true; - } - - QuotaTableEntries entries_; -}; - -// Gather storage key info table for quota-internals page. -// -// This class is granted ownership of itself when it is passed to -// DidDumpQuotaTable() via base::Owned(). When the closure for said function +// DidDumpBucketTable() via base::Owned(). When the closure for said function // goes out of scope, the object is deleted. // This class is not thread-safe because there can be races when entries_ is // modified. @@ -2015,24 +1979,6 @@ modification_time, std::move(callback))); } -void QuotaManagerImpl::DumpQuotaTable(DumpQuotaTableCallback callback) { - DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - DCHECK(callback); - - if (db_disabled_) { - std::move(callback).Run(QuotaTableEntries()); - return; - } - - DumpQuotaTableHelper* helper = new DumpQuotaTableHelper; - PostTaskAndReplyWithResultForDBThread( - base::BindOnce(&DumpQuotaTableHelper::DumpQuotaTableOnDBThread, - base::Unretained(helper)), - base::BindOnce(&DumpQuotaTableHelper::DidDumpQuotaTable, - base::Owned(helper), weak_factory_.GetWeakPtr(), - std::move(callback))); -} - void QuotaManagerImpl::DumpBucketTable(DumpBucketTableCallback callback) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK(callback);
diff --git a/storage/browser/quota/quota_manager_impl.h b/storage/browser/quota/quota_manager_impl.h index f62d0a0..6cd5198 100644 --- a/storage/browser/quota/quota_manager_impl.h +++ b/storage/browser/quota/quota_manager_impl.h
@@ -475,7 +475,6 @@ class StorageKeyGathererTask; class BucketDataDeleter; class HostDataDeleter; - class DumpQuotaTableHelper; class DumpBucketTableHelper; class StorageCleanupHelper; @@ -492,17 +491,13 @@ std::set<int> active_override_session_ids; }; - using QuotaTableEntry = QuotaDatabase::QuotaTableEntry; using BucketTableEntry = QuotaDatabase::BucketTableEntry; - using QuotaTableEntries = std::vector<QuotaTableEntry>; using BucketTableEntries = std::vector<BucketTableEntry>; using StorageKeysByType = base::flat_map<blink::mojom::StorageType, std::set<blink::StorageKey>>; using QuotaSettingsCallback = base::OnceCallback<void(const QuotaSettings&)>; - using DumpQuotaTableCallback = - base::OnceCallback<void(const QuotaTableEntries&)>; using DumpBucketTableCallback = base::OnceCallback<void(const BucketTableEntries&)>; @@ -544,7 +539,6 @@ UsageTracker* GetUsageTracker(blink::mojom::StorageType type) const; - void DumpQuotaTable(DumpQuotaTableCallback callback); void DumpBucketTable(DumpBucketTableCallback callback); void DidRetrieveBucketsTable(RetrieveBucketsTableCallback callback, const BucketTableEntries& entries);
diff --git a/storage/browser/quota/quota_manager_unittest.cc b/storage/browser/quota/quota_manager_unittest.cc index 242461ac..266399e 100644 --- a/storage/browser/quota/quota_manager_unittest.cc +++ b/storage/browser/quota/quota_manager_unittest.cc
@@ -135,8 +135,6 @@ class QuotaManagerImplTest : public testing::Test { protected: - using QuotaTableEntry = QuotaManagerImpl::QuotaTableEntry; - using QuotaTableEntries = QuotaManagerImpl::QuotaTableEntries; using BucketTableEntries = QuotaManagerImpl::BucketTableEntries; public: @@ -436,13 +434,6 @@ return future.Get<0>(); } - QuotaTableEntries DumpQuotaTable() { - base::test::TestFuture<QuotaTableEntries> future; - quota_manager_impl_->DumpQuotaTable( - future.GetCallback<const QuotaTableEntries&>()); - return future.Get(); - } - BucketTableEntries DumpBucketTable() { base::test::TestFuture<BucketTableEntries> future; quota_manager_impl_->DumpBucketTable( @@ -2754,22 +2745,6 @@ EXPECT_TRUE(buckets.empty()); } -TEST_F(QuotaManagerImplTest, DumpQuotaTable) { - SetPersistentHostQuota("example1.com", 1); - SetPersistentHostQuota("example2.com", 20); - SetPersistentHostQuota("example3.com", 300); - task_environment_.RunUntilIdle(); - - const QuotaTableEntries& entries = DumpQuotaTable(); - EXPECT_THAT( - entries, - testing::UnorderedElementsAre( - QuotaTableEntry{.host = "example1.com", .type = kPerm, .quota = 1}, - QuotaTableEntry{.host = "example2.com", .type = kPerm, .quota = 20}, - QuotaTableEntry{ - .host = "example3.com", .type = kPerm, .quota = 300})); -} - TEST_F(QuotaManagerImplTest, DumpBucketTable) { const StorageKey kStorageKey = ToStorageKey("http://example.com/"); CreateBucketForTesting(kStorageKey, kDefaultBucketName, kTemp);
diff --git a/testing/buildbot/chrome.json b/testing/buildbot/chrome.json index 1d645ab..93b4d494 100644 --- a/testing/buildbot/chrome.json +++ b/testing/buildbot/chrome.json
@@ -1804,7 +1804,7 @@ { "args": [], "cros_board": "atlas", - "cros_img": "atlas-release/R101-14583.0.0", + "cros_img": "atlas-release/R101-14588.11.0", "name": "lacros_all_tast_tests_ATLAS_RELEASE_DEV", "resultdb": { "enable": true, @@ -1864,7 +1864,7 @@ { "args": [], "cros_board": "eve", - "cros_img": "eve-release/R101-14583.0.0", + "cros_img": "eve-release/R101-14588.11.0", "name": "lacros_all_tast_tests_EVE_RELEASE_DEV", "resultdb": { "enable": true,
diff --git a/testing/buildbot/chromium.android.fyi.json b/testing/buildbot/chromium.android.fyi.json index 3999c4f..de5bb39ae 100644 --- a/testing/buildbot/chromium.android.fyi.json +++ b/testing/buildbot/chromium.android.fyi.json
@@ -9581,7 +9581,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M100", - "revision": "version:100.0.4896.55" + "revision": "version:100.0.4896.56" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -9665,7 +9665,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M101", - "revision": "version:101.0.4951.7" + "revision": "version:101.0.4951.9" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -10085,7 +10085,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M100", - "revision": "version:100.0.4896.55" + "revision": "version:100.0.4896.56" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -10169,7 +10169,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M101", - "revision": "version:101.0.4951.7" + "revision": "version:101.0.4951.9" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}",
diff --git a/testing/buildbot/chromium.android.json b/testing/buildbot/chromium.android.json index 111ec0c..fc5d864 100644 --- a/testing/buildbot/chromium.android.json +++ b/testing/buildbot/chromium.android.json
@@ -44881,7 +44881,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M100", - "revision": "version:100.0.4896.55" + "revision": "version:100.0.4896.56" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -44965,7 +44965,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M101", - "revision": "version:101.0.4951.7" + "revision": "version:101.0.4951.9" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -45385,7 +45385,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M100", - "revision": "version:100.0.4896.55" + "revision": "version:100.0.4896.56" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -45469,7 +45469,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M101", - "revision": "version:101.0.4951.7" + "revision": "version:101.0.4951.9" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -45893,7 +45893,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M100", - "revision": "version:100.0.4896.55" + "revision": "version:100.0.4896.56" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -45977,7 +45977,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M101", - "revision": "version:101.0.4951.7" + "revision": "version:101.0.4951.9" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -46397,7 +46397,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M100", - "revision": "version:100.0.4896.55" + "revision": "version:100.0.4896.56" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -46481,7 +46481,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M101", - "revision": "version:101.0.4951.7" + "revision": "version:101.0.4951.9" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -46972,7 +46972,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M100", - "revision": "version:100.0.4896.55" + "revision": "version:100.0.4896.56" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -47056,7 +47056,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M101", - "revision": "version:101.0.4951.7" + "revision": "version:101.0.4951.9" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -47476,7 +47476,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M100", - "revision": "version:100.0.4896.55" + "revision": "version:100.0.4896.56" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -47560,7 +47560,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M101", - "revision": "version:101.0.4951.7" + "revision": "version:101.0.4951.9" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -48051,7 +48051,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M100", - "revision": "version:100.0.4896.55" + "revision": "version:100.0.4896.56" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -48135,7 +48135,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M101", - "revision": "version:101.0.4951.7" + "revision": "version:101.0.4951.9" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -48555,7 +48555,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M100", - "revision": "version:100.0.4896.55" + "revision": "version:100.0.4896.56" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}", @@ -48639,7 +48639,7 @@ { "cipd_package": "chromium/testing/weblayer-x86", "location": "weblayer_instrumentation_test_M101", - "revision": "version:101.0.4951.7" + "revision": "version:101.0.4951.9" }, { "cipd_package": "infra/tools/luci/logdog/butler/${platform}",
diff --git a/testing/buildbot/chromium.fyi.json b/testing/buildbot/chromium.fyi.json index 65914ab..ed3d1c1 100644 --- a/testing/buildbot/chromium.fyi.json +++ b/testing/buildbot/chromium.fyi.json
@@ -26,10 +26,6 @@ "all" ] }, - "GPU FYI Win x64 Builder (dbg) (reclient shadow)": {}, - "GPU FYI Win x64 Builder (reclient shadow)": {}, - "GPU FYI Win x64 DX12 Vulkan Builder (dbg) (reclient shadow)": {}, - "GPU FYI Win x64 DX12 Vulkan Builder (reclient shadow)": {}, "Linux Builder (j-500) (reclient)": { "additional_compile_targets": [ "all"
diff --git a/testing/buildbot/chromium.gpu.fyi.json b/testing/buildbot/chromium.gpu.fyi.json index 57ad640..5c0cda0 100644 --- a/testing/buildbot/chromium.gpu.fyi.json +++ b/testing/buildbot/chromium.gpu.fyi.json
@@ -6197,8 +6197,62 @@ "GPU FYI Win Builder": {}, "GPU FYI Win x64 Builder": {}, "GPU FYI Win x64 Builder (dbg)": {}, + "GPU FYI Win x64 Builder (dbg) (reclient shadow)": { + "additional_compile_targets": [ + "angle_unittests", + "gl_tests", + "gl_unittests", + "gles2_conform_test", + "gpu_unittests", + "swiftshader_unittests", + "telemetry_gpu_integration_test", + "vulkan_tests", + "xr_browser_tests" + ] + }, + "GPU FYI Win x64 Builder (reclient shadow)": { + "additional_compile_targets": [ + "angle_unittests", + "browser_tests", + "command_buffer_perftests", + "gl_tests", + "gl_unittests", + "gles2_conform_test", + "gpu_unittests", + "rendering_representative_perf_tests", + "swiftshader_unittests", + "telemetry_gpu_integration_test", + "vulkan_tests", + "xr_browser_tests" + ] + }, "GPU FYI Win x64 DX12 Vulkan Builder": {}, "GPU FYI Win x64 DX12 Vulkan Builder (dbg)": {}, + "GPU FYI Win x64 DX12 Vulkan Builder (dbg) (reclient shadow)": { + "additional_compile_targets": [ + "telemetry_gpu_integration_test" + ] + }, + "GPU FYI Win x64 DX12 Vulkan Builder (reclient shadow)": { + "additional_compile_targets": [ + "telemetry_gpu_integration_test" + ] + }, + "GPU FYI XR Win x64 Builder (reclient shadow)": { + "additional_compile_targets": [ + "vr_perf_tests" + ] + }, + "GPU Win x64 Builder (dbg) (reclient shadow)": { + "additional_compile_targets": [ + "angle_unittests", + "browser_tests", + "gl_tests", + "gl_unittests", + "telemetry_gpu_integration_test", + "xr_browser_tests" + ] + }, "Lacros FYI x64 Release (AMD)": { "isolated_scripts": [ {
diff --git a/testing/buildbot/variants.pyl b/testing/buildbot/variants.pyl index 3f9d44d1..0d9a264 100644 --- a/testing/buildbot/variants.pyl +++ b/testing/buildbot/variants.pyl
@@ -459,7 +459,7 @@ { 'cipd_package': 'chromium/testing/weblayer-x86', 'location': 'weblayer_instrumentation_test_M101', - 'revision': 'version:101.0.4951.7', + 'revision': 'version:101.0.4951.9', } ], }, @@ -483,7 +483,7 @@ { 'cipd_package': 'chromium/testing/weblayer-x86', 'location': 'weblayer_instrumentation_test_M100', - 'revision': 'version:100.0.4896.55', + 'revision': 'version:100.0.4896.56', } ], }, @@ -603,7 +603,7 @@ { 'cipd_package': 'chromium/testing/weblayer-x86', 'location': 'weblayer_instrumentation_test_M101', - 'revision': 'version:101.0.4951.7', + 'revision': 'version:101.0.4951.9', } ], }, @@ -627,7 +627,7 @@ { 'cipd_package': 'chromium/testing/weblayer-x86', 'location': 'weblayer_instrumentation_test_M100', - 'revision': 'version:100.0.4896.55', + 'revision': 'version:100.0.4896.56', } ], }, @@ -747,7 +747,7 @@ { 'cipd_package': 'chromium/testing/weblayer-x86', 'location': 'weblayer_instrumentation_test_M101', - 'revision': 'version:101.0.4951.7', + 'revision': 'version:101.0.4951.9', } ], }, @@ -771,7 +771,7 @@ { 'cipd_package': 'chromium/testing/weblayer-x86', 'location': 'weblayer_instrumentation_test_M100', - 'revision': 'version:100.0.4896.55', + 'revision': 'version:100.0.4896.56', } ], }, @@ -884,8 +884,8 @@ 'CROS_ATLAS_RELEASE_DEV': { 'skylab': { 'cros_board': 'atlas', - 'cros_chrome_version': '101.0.4943.0', - 'cros_img': 'atlas-release/R101-14583.0.0', + 'cros_chrome_version': '101.0.4951.6', + 'cros_img': 'atlas-release/R101-14588.11.0', }, 'enabled': True, 'identifier': 'ATLAS_RELEASE_DEV', @@ -920,8 +920,8 @@ 'CROS_EVE_RELEASE_DEV': { 'skylab': { 'cros_board': 'eve', - 'cros_chrome_version': '101.0.4943.0', - 'cros_img': 'eve-release/R101-14583.0.0', + 'cros_chrome_version': '101.0.4951.6', + 'cros_img': 'eve-release/R101-14588.11.0', }, 'enabled': True, 'identifier': 'EVE_RELEASE_DEV',
diff --git a/testing/buildbot/waterfalls.pyl b/testing/buildbot/waterfalls.pyl index d706f83..9a2475a 100644 --- a/testing/buildbot/waterfalls.pyl +++ b/testing/buildbot/waterfalls.pyl
@@ -2664,10 +2664,6 @@ 'all' ], }, - 'GPU FYI Win x64 Builder (dbg) (reclient shadow)' : {}, - 'GPU FYI Win x64 Builder (reclient shadow)' : {}, - 'GPU FYI Win x64 DX12 Vulkan Builder (dbg) (reclient shadow)': {}, - 'GPU FYI Win x64 DX12 Vulkan Builder (reclient shadow)': {}, 'Linux Builder (j-500) (reclient)': { # Copied from # https://source.chromium.org/chromium/chromium/src/+/main:testing/buildbot/waterfalls.pyl;l=4844-4854;drc=75f767e92e86611728189739fb26f4e2cdf212d9 @@ -4373,8 +4369,62 @@ 'GPU FYI Win Builder' : {}, 'GPU FYI Win x64 Builder' : {}, 'GPU FYI Win x64 Builder (dbg)' : {}, + 'GPU FYI Win x64 Builder (dbg) (reclient shadow)' : { + 'additional_compile_targets': [ + 'angle_unittests', + 'gl_tests', + 'gl_unittests', + 'gles2_conform_test', + 'gpu_unittests', + 'swiftshader_unittests', + 'telemetry_gpu_integration_test', + 'vulkan_tests', + 'xr_browser_tests' + ], + }, + 'GPU FYI Win x64 Builder (reclient shadow)' : { + 'additional_compile_targets': [ + 'angle_unittests', + 'browser_tests', + 'command_buffer_perftests', + 'gl_tests', + 'gl_unittests', + 'gles2_conform_test', + 'gpu_unittests', + 'rendering_representative_perf_tests', + 'swiftshader_unittests', + 'telemetry_gpu_integration_test', + 'vulkan_tests', + 'xr_browser_tests' + ], + }, 'GPU FYI Win x64 DX12 Vulkan Builder': {}, 'GPU FYI Win x64 DX12 Vulkan Builder (dbg)': {}, + 'GPU FYI Win x64 DX12 Vulkan Builder (dbg) (reclient shadow)': { + 'additional_compile_targets': [ + 'telemetry_gpu_integration_test' + ], + }, + 'GPU FYI Win x64 DX12 Vulkan Builder (reclient shadow)': { + 'additional_compile_targets': [ + 'telemetry_gpu_integration_test' + ], + }, + 'GPU FYI XR Win x64 Builder (reclient shadow)': { + 'additional_compile_targets': [ + 'vr_perf_tests' + ], + }, + 'GPU Win x64 Builder (dbg) (reclient shadow)': { + 'additional_compile_targets': [ + 'angle_unittests', + 'browser_tests', + 'gl_tests', + 'gl_unittests', + 'telemetry_gpu_integration_test', + 'xr_browser_tests' + ], + }, 'Lacros FYI x64 Release (AMD)': { 'os_type': 'lacros', 'browser_config': 'release',
diff --git a/testing/scripts/run_android_wpt.pydeps b/testing/scripts/run_android_wpt.pydeps index 44950e16..62a21e3 100644 --- a/testing/scripts/run_android_wpt.pydeps +++ b/testing/scripts/run_android_wpt.pydeps
@@ -67,6 +67,7 @@ //third_party/blink/tools/blinkpy/web_tests/layout_package/bot_test_expectations.py //third_party/blink/tools/blinkpy/web_tests/layout_package/json_results_generator.py //third_party/blink/tools/blinkpy/web_tests/models/__init__.py +//third_party/blink/tools/blinkpy/web_tests/models/failure_reason.py //third_party/blink/tools/blinkpy/web_tests/models/test_configuration.py //third_party/blink/tools/blinkpy/web_tests/models/test_expectations.py //third_party/blink/tools/blinkpy/web_tests/models/test_failures.py
diff --git a/testing/scripts/run_finch_smoke_tests_android.py b/testing/scripts/run_finch_smoke_tests_android.py index 1e66be7..7404317 100755 --- a/testing/scripts/run_finch_smoke_tests_android.py +++ b/testing/scripts/run_finch_smoke_tests_android.py
@@ -584,11 +584,10 @@ test_results_dict = OrderedDict({'version': 3, 'interrupted': False, 'num_failures_by_type': {}, 'tests': {}}) - ret = test_case.run_tests('without_finch_seed', test_results_dict) - test_case.install_seed() - ret |= test_case.run_tests('with_finch_seed', test_results_dict) - if test_case.product_name() == 'webview': + ret = test_case.run_tests('without_finch_seed', test_results_dict) + test_case.install_seed() + ret |= test_case.run_tests('with_finch_seed', test_results_dict) # WebView needs several restarts to fetch and load a new finch seed # TODO(b/187185389): Figure out why the first restart is needed ret |= test_case.run_tests('extra_restart', test_results_dict, @@ -600,6 +599,13 @@ # variations_seed_new to variations_seed ret |= test_case.run_tests('load_new_seed_restart', test_results_dict, test_case.finch_seed_download_args()) + else: + test_case.install_seed() + ret = test_case.run_tests('with_finch_seed', test_results_dict) + # Clears out the finch seed. Need to run finch_seed tests first. + # See crbug/1305430 + device.ClearApplicationState(test_case.browser_package_name) + ret |= test_case.run_tests('without_finch_seed', test_results_dict) test_results_dict['seconds_since_epoch'] = int(time.time()) test_results_dict['path_delimiter'] = '/'
diff --git a/testing/scripts/wpt_common_unittest.py b/testing/scripts/wpt_common_unittest.py index 24ea573..2e920e2 100755 --- a/testing/scripts/wpt_common_unittest.py +++ b/testing/scripts/wpt_common_unittest.py
@@ -127,7 +127,7 @@ (os.path.join('layout-test-results', 'external', 'wpt', 'fail', 'test_variant1-actual.txt'))]} - self.assertEquals(self.wpt_adapter.sink.sink_requests, + self.assertEqual(self.wpt_adapter.sink.sink_requests, [{'test': os.path.join('external','wpt', 'fail', 'test.html?variant1'), 'test_path': test_abs_path, @@ -160,7 +160,7 @@ (os.path.join('layout-test-results', 'external', 'wpt', 'fail', 'test_variant1-actual.txt'))]} - self.assertEquals(self.wpt_adapter.sink.sink_requests, + self.assertEqual(self.wpt_adapter.sink.sink_requests, [{'test': os.path.join('external', 'wpt', 'fail', 'test.html?variant1'), 'test_path': test_abs_path, @@ -193,7 +193,7 @@ os.path.join('layout-test-results', 'external', 'wpt', 'fail', 'test-actual.txt')]} - self.assertEquals(self.wpt_adapter.sink.sink_requests, + self.assertEqual(self.wpt_adapter.sink.sink_requests, [{'test': os.path.join('external', 'wpt', 'fail', 'test.html'), 'test_path': test_abs_path, @@ -248,14 +248,16 @@ full_results_jsonp = written_files[os.path.join( self.wpt_adapter.layout_test_results_subdir, 'full_results_jsonp.js')] - match = re.match(r'ADD_FULL_RESULTS\((.*)\);$', full_results_jsonp) + match = re.match(r'ADD_FULL_RESULTS\((.*)\);$', + full_results_jsonp.decode('utf-8')) self.assertIsNotNone(match) self.assertEqual(match.group(1), written_files[OUTPUT_JSON_FILENAME].decode(encoding='utf-8')) failing_results_jsonp = written_files[os.path.join( self.wpt_adapter.layout_test_results_subdir, 'failing_results.json')] - match = re.match(r'ADD_RESULTS\((.*)\);$', failing_results_jsonp) + match = re.match(r'ADD_RESULTS\((.*)\);$', + failing_results_jsonp.decode('utf-8')) self.assertIsNotNone(match) failing_results = json.loads(match.group(1)) # Verify filtering of failing_results.json
diff --git a/testing/variations/fieldtrial_testing_config.json b/testing/variations/fieldtrial_testing_config.json index 4911604f..de3265b 100644 --- a/testing/variations/fieldtrial_testing_config.json +++ b/testing/variations/fieldtrial_testing_config.json
@@ -1089,6 +1089,28 @@ ] } ], + "AutofillPreventOverridingPrefilledFieldValue": [ + { + "platforms": [ + "android_webview", + "android", + "chromeos", + "chromeos_lacros", + "ios", + "linux", + "mac", + "windows" + ], + "experiments": [ + { + "name": "Enabled2022-03-01", + "enable_features": [ + "AutofillPreventOverridingPrefilledValues" + ] + } + ] + } + ], "AutofillRetrieveOverallPredictionsFromCache": [ { "platforms": [
diff --git a/third_party/blink/common/associated_interfaces/associated_interface_provider.cc b/third_party/blink/common/associated_interfaces/associated_interface_provider.cc index 826f183b..2628ddf3 100644 --- a/third_party/blink/common/associated_interfaces/associated_interface_provider.cc +++ b/third_party/blink/common/associated_interfaces/associated_interface_provider.cc
@@ -7,6 +7,7 @@ #include <map> #include "base/no_destructor.h" +#include "base/threading/thread_task_runner_handle.h" #include "mojo/public/cpp/bindings/associated_receiver.h" namespace blink {
diff --git a/third_party/blink/common/browser_interface_broker_proxy.cc b/third_party/blink/common/browser_interface_broker_proxy.cc index ee2306b..44b2243 100644 --- a/third_party/blink/common/browser_interface_broker_proxy.cc +++ b/third_party/blink/common/browser_interface_broker_proxy.cc
@@ -7,6 +7,7 @@ #include <tuple> #include "base/threading/sequence_local_storage_slot.h" +#include "base/threading/thread_task_runner_handle.h" namespace blink {
diff --git a/third_party/blink/perf_tests/webgpu/binding-draw.html b/third_party/blink/perf_tests/webgpu/binding-draw.html index 5d379ec..0b3c75e 100644 --- a/third_party/blink/perf_tests/webgpu/binding-draw.html +++ b/third_party/blink/perf_tests/webgpu/binding-draw.html
@@ -37,8 +37,8 @@ vec2<f32>(-0.5, -0.5), vec2<f32>(0.5, -0.5)); - [[stage(vertex)]] - fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> { + @stage(vertex) + fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> { return vec4<f32>(pos[VertexIndex], 0.0, 1.0); }` }), @@ -47,8 +47,8 @@ fragment: { module: device.createShaderModule({ code: ` - [[stage(fragment)]] - fn main() -> [[location(0)]] vec4<f32> { + @stage(fragment) + fn main() -> @location(0) vec4<f32> { return vec4<f32>(0.0, 1.0, 0.0, 1.0); }` }),
diff --git a/third_party/blink/public/platform/platform.h b/third_party/blink/public/platform/platform.h index ced2c8e4..8cc6400 100644 --- a/third_party/blink/public/platform/platform.h +++ b/third_party/blink/public/platform/platform.h
@@ -59,7 +59,6 @@ #include "third_party/blink/public/platform/web_code_cache_loader.h" #include "third_party/blink/public/platform/web_common.h" #include "third_party/blink/public/platform/web_data.h" -#include "third_party/blink/public/platform/web_dedicated_worker_host_factory_client.h" #include "third_party/blink/public/platform/web_string.h" #include "third_party/blink/public/platform/web_v8_value_converter.h" #include "third_party/blink/public/platform/websocket_handshake_throttle_provider.h" @@ -134,6 +133,7 @@ class WebAudioLatencyHint; class WebCrypto; class WebDedicatedWorker; +class WebDedicatedWorkerHostFactoryClient; class WebGraphicsContext3DProvider; class WebLocalFrame; class WebMediaCapabilitiesClient;
diff --git a/third_party/blink/renderer/bindings/core/v8/js_event_handler_for_content_attribute.cc b/third_party/blink/renderer/bindings/core/v8/js_event_handler_for_content_attribute.cc index 060690bb..18108a2 100644 --- a/third_party/blink/renderer/bindings/core/v8/js_event_handler_for_content_attribute.cc +++ b/third_party/blink/renderer/bindings/core/v8/js_event_handler_for_content_attribute.cc
@@ -245,7 +245,7 @@ return source_location; // Fallback to uncompiled source info. return std::make_unique<SourceLocation>( - source_url_, position_.line_.ZeroBasedInt(), + source_url_, String(), position_.line_.ZeroBasedInt(), position_.column_.ZeroBasedInt(), nullptr); }
diff --git a/third_party/blink/renderer/bindings/core/v8/source_location.cc b/third_party/blink/renderer/bindings/core/v8/source_location.cc index ab2665b..4bfbe619 100644 --- a/third_party/blink/renderer/bindings/core/v8/source_location.cc +++ b/third_party/blink/renderer/bindings/core/v8/source_location.cc
@@ -45,8 +45,8 @@ return SourceLocation::CreateFromNonEmptyV8StackTrace( std::move(stack_trace)); } - return std::make_unique<SourceLocation>(url, line_number, column_number, - std::move(stack_trace)); + return std::make_unique<SourceLocation>( + url, String(), line_number, column_number, std::move(stack_trace)); } // static @@ -68,13 +68,14 @@ line_number = document->GetScriptableDocumentParser()->LineNumber().OneBasedInt(); } - return std::make_unique<SourceLocation>( - document->Url().GetString(), line_number, 0, std::move(stack_trace)); + return std::make_unique<SourceLocation>(document->Url().GetString(), + String(), line_number, 0, + std::move(stack_trace)); } return std::make_unique<SourceLocation>( - execution_context ? execution_context->Url().GetString() : String(), 0, 0, - std::move(stack_trace)); + execution_context ? execution_context->Url().GetString() : String(), + String(), 0, 0, std::move(stack_trace)); } // static @@ -110,8 +111,9 @@ message->GetScriptOrigin().ResourceName()); if (url.IsEmpty()) url = execution_context->Url(); - return std::make_unique<SourceLocation>(url, line_number, column_number, - std::move(stack_trace), script_id); + return std::make_unique<SourceLocation>(url, String(), line_number, + column_number, std::move(stack_trace), + script_id); } // static @@ -119,11 +121,13 @@ std::unique_ptr<v8_inspector::V8StackTrace> stack_trace) { // Retrieve the data before passing the ownership to SourceLocation. String url = ToCoreString(stack_trace->topSourceURL()); + String function = ToCoreString(stack_trace->topFunctionName()); unsigned line_number = stack_trace->topLineNumber(); unsigned column_number = stack_trace->topColumnNumber(); int script_id = stack_trace->topScriptId(); - return base::WrapUnique(new SourceLocation( - url, line_number, column_number, std::move(stack_trace), script_id)); + return base::WrapUnique( + new SourceLocation(url, function, line_number, column_number, + std::move(stack_trace), script_id)); } // static @@ -133,9 +137,10 @@ return std::make_unique<SourceLocation>( ToCoreStringWithUndefinedOrNullCheck( function->GetScriptOrigin().ResourceName()), + ToCoreStringWithUndefinedOrNullCheck(function->GetName()), function->GetScriptLineNumber() + 1, function->GetScriptColumnNumber() + 1, nullptr, function->ScriptId()); - return std::make_unique<SourceLocation>(String(), 0, 0, nullptr, 0); + return std::make_unique<SourceLocation>(String(), String(), 0, 0, nullptr, 0); } // static @@ -146,16 +151,18 @@ return SourceLocation::CreateFromNonEmptyV8StackTrace( std::move(stack_trace)); } - return std::make_unique<SourceLocation>(String(), 0, 0, nullptr, 0); + return std::make_unique<SourceLocation>(String(), String(), 0, 0, nullptr, 0); } SourceLocation::SourceLocation( const String& url, + const String& function, unsigned line_number, unsigned column_number, std::unique_ptr<v8_inspector::V8StackTrace> stack_trace, int script_id) : url_(url), + function_(function), line_number_(line_number), column_number_(column_number), stack_trace_(std::move(stack_trace)), @@ -194,8 +201,9 @@ std::unique_ptr<SourceLocation> SourceLocation::Clone() const { return base::WrapUnique(new SourceLocation( - url_.IsolatedCopy(), line_number_, column_number_, - stack_trace_ ? stack_trace_->clone() : nullptr, script_id_)); + url_.IsolatedCopy(), function_.IsolatedCopy(), line_number_, + column_number_, stack_trace_ ? stack_trace_->clone() : nullptr, + script_id_)); } std::unique_ptr<v8_inspector::protocol::Runtime::API::StackTrace>
diff --git a/third_party/blink/renderer/bindings/core/v8/source_location.h b/third_party/blink/renderer/bindings/core/v8/source_location.h index 27b0464..46d87ab 100644 --- a/third_party/blink/renderer/bindings/core/v8/source_location.h +++ b/third_party/blink/renderer/bindings/core/v8/source_location.h
@@ -42,6 +42,7 @@ static std::unique_ptr<SourceLocation> CaptureWithFullStackTrace(); SourceLocation(const String& url, + const String& function, unsigned line_number, unsigned column_number, std::unique_ptr<v8_inspector::V8StackTrace>, @@ -52,6 +53,7 @@ return url_.IsNull() && !script_id_ && !line_number_; } const String& Url() const { return url_; } + const String& Function() const { return function_; } unsigned LineNumber() const { return line_number_; } unsigned ColumnNumber() const { return column_number_; } int ScriptId() const { return script_id_; } @@ -88,6 +90,7 @@ std::unique_ptr<v8_inspector::V8StackTrace>); String url_; + String function_; unsigned line_number_; unsigned column_number_; std::unique_ptr<v8_inspector::V8StackTrace> stack_trace_;
diff --git a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc index 5040ec8..66dddc12 100644 --- a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc +++ b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc
@@ -280,8 +280,8 @@ if (message->IsSharedCrossOrigin()) sanitize_script_errors = SanitizeScriptErrors::kDoNotSanitize; } else { - location = std::make_unique<SourceLocation>(context->Url().GetString(), 0, - 0, nullptr); + location = std::make_unique<SourceLocation>(context->Url().GetString(), + String(), 0, 0, nullptr); } String message_for_console =
diff --git a/third_party/blink/renderer/core/css/css_container_rule.cc b/third_party/blink/renderer/core/css/css_container_rule.cc index ea28faf..79071ee8 100644 --- a/third_party/blink/renderer/core/css/css_container_rule.cc +++ b/third_party/blink/renderer/core/css/css_container_rule.cc
@@ -4,6 +4,7 @@ #include "third_party/blink/renderer/core/css/css_container_rule.h" +#include "third_party/blink/renderer/core/css/css_markup.h" #include "third_party/blink/renderer/core/css/css_style_sheet.h" #include "third_party/blink/renderer/core/css/style_rule.h" #include "third_party/blink/renderer/platform/wtf/text/string_builder.h" @@ -22,7 +23,7 @@ String name = ContainerQuery().Selector().Name(); if (!name.IsEmpty()) { - result.Append(name); + SerializeIdentifier(name, result); result.Append(' '); } result.Append(ContainerQuery().ToString());
diff --git a/third_party/blink/renderer/core/dom/scripted_idle_task_controller.cc b/third_party/blink/renderer/core/dom/scripted_idle_task_controller.cc index a75d397..7b8bac50 100644 --- a/third_party/blink/renderer/core/dom/scripted_idle_task_controller.cc +++ b/third_party/blink/renderer/core/dom/scripted_idle_task_controller.cc
@@ -6,6 +6,7 @@ #include "base/location.h" #include "base/metrics/histogram_macros.h" +#include "third_party/blink/public/mojom/frame/lifecycle.mojom-shared.h" #include "third_party/blink/public/platform/platform.h" #include "third_party/blink/renderer/bindings/core/v8/v8_idle_request_options.h" #include "third_party/blink/renderer/core/execution_context/execution_context.h"
diff --git a/third_party/blink/renderer/core/events/error_event.cc b/third_party/blink/renderer/core/events/error_event.cc index 5a0fa0a..1cfb07f 100644 --- a/third_party/blink/renderer/core/events/error_event.cc +++ b/third_party/blink/renderer/core/events/error_event.cc
@@ -44,14 +44,15 @@ DCHECK(script_state); return MakeGarbageCollected<ErrorEvent>( "Script error.", - std::make_unique<SourceLocation>(String(), 0, 0, nullptr), + std::make_unique<SourceLocation>(String(), String(), 0, 0, nullptr), ScriptValue::CreateNull(script_state->GetIsolate()), &script_state->World()); } ErrorEvent::ErrorEvent() : sanitized_message_(), - location_(std::make_unique<SourceLocation>(String(), 0, 0, nullptr)), + location_( + std::make_unique<SourceLocation>(String(), String(), 0, 0, nullptr)), world_(&DOMWrapperWorld::Current(v8::Isolate::GetCurrent())) {} ErrorEvent::ErrorEvent(ScriptState* script_state, @@ -62,7 +63,7 @@ world_(&script_state->World()) { sanitized_message_ = initializer->message(); location_ = std::make_unique<SourceLocation>(initializer->filename(), - initializer->lineno(), + String(), initializer->lineno(), initializer->colno(), nullptr); // TODO(crbug.com/1070964): Remove this existence check. There is a bug that // the current code generator does not initialize a ScriptValue with the
diff --git a/third_party/blink/renderer/core/frame/csp/content_security_policy.cc b/third_party/blink/renderer/core/frame/csp/content_security_policy.cc index 20fd826..5cff3fa2 100644 --- a/third_party/blink/renderer/core/frame/csp/content_security_policy.cc +++ b/third_party/blink/renderer/core/frame/csp/content_security_policy.cc
@@ -33,6 +33,7 @@ #include "services/network/public/cpp/web_sandbox_flags.h" #include "services/network/public/mojom/web_sandbox_flags.mojom-blink.h" #include "third_party/abseil-cpp/absl/types/optional.h" +#include "third_party/blink/public/common/security_context/insecure_request_policy.h" #include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink.h" #include "third_party/blink/public/mojom/security_context/insecure_request_policy.mojom-blink.h" #include "third_party/blink/public/platform/platform.h"
diff --git a/third_party/blink/renderer/core/frame/local_dom_window.cc b/third_party/blink/renderer/core/frame/local_dom_window.cc index c18012a..b48d3dbf 100644 --- a/third_party/blink/renderer/core/frame/local_dom_window.cc +++ b/third_party/blink/renderer/core/frame/local_dom_window.cc
@@ -622,8 +622,8 @@ console_message = MakeGarbageCollected<ConsoleMessage>( console_message->Source(), console_message->Level(), console_message->Message(), - std::make_unique<SourceLocation>(Url().GetString(), line_number, 0, - nullptr)); + std::make_unique<SourceLocation>(Url().GetString(), String(), + line_number, 0, nullptr)); console_message->SetNodes(GetFrame(), std::move(nodes)); if (category) console_message->SetCategory(*category);
diff --git a/third_party/blink/renderer/core/frame/local_frame.cc b/third_party/blink/renderer/core/frame/local_frame.cc index 1efaff0..85849e4 100644 --- a/third_party/blink/renderer/core/frame/local_frame.cc +++ b/third_party/blink/renderer/core/frame/local_frame.cc
@@ -3066,7 +3066,7 @@ // Finally dispatch the message to the DOM Window. DomWindow()->DispatchMessageEventWithOriginCheck( target_security_origin.get(), message_event, - std::make_unique<SourceLocation>(String(), 0, 0, nullptr), + std::make_unique<SourceLocation>(String(), String(), 0, 0, nullptr), message.locked_agent_cluster_id ? message.locked_agent_cluster_id.value() : base::UnguessableToken()); }
diff --git a/third_party/blink/renderer/core/frame/local_frame_mojo_handler.cc b/third_party/blink/renderer/core/frame/local_frame_mojo_handler.cc index e598aa2..92314545 100644 --- a/third_party/blink/renderer/core/frame/local_frame_mojo_handler.cc +++ b/third_party/blink/renderer/core/frame/local_frame_mojo_handler.cc
@@ -777,8 +777,9 @@ void LocalFrameMojoHandler::ReportContentSecurityPolicyViolation( network::mojom::blink::CSPViolationPtr violation) { auto source_location = std::make_unique<SourceLocation>( - violation->source_location->url, violation->source_location->line, - violation->source_location->column, nullptr); + violation->source_location->url, String(), + violation->source_location->line, violation->source_location->column, + nullptr); frame_->Console().AddMessage(MakeGarbageCollected<ConsoleMessage>( mojom::blink::ConsoleMessageSource::kSecurity, @@ -1077,7 +1078,7 @@ network::mojom::blink::SourceLocationPtr source_location) { std::unique_ptr<SourceLocation> source; if (source_location) { - source = std::make_unique<SourceLocation>(source_location->url, + source = std::make_unique<SourceLocation>(source_location->url, String(), source_location->line, source_location->column, nullptr); }
diff --git a/third_party/blink/renderer/core/inspector/console_message.cc b/third_party/blink/renderer/core/inspector/console_message.cc index 33fac88..5d589dda 100644 --- a/third_party/blink/renderer/core/inspector/console_message.cc +++ b/third_party/blink/renderer/core/inspector/console_message.cc
@@ -52,6 +52,7 @@ message.level, message.text, std::make_unique<SourceLocation>(message.url, + String(), message.line_number, message.column_number, nullptr)) {
diff --git a/third_party/blink/renderer/core/inspector/inspector_audits_issue.cc b/third_party/blink/renderer/core/inspector/inspector_audits_issue.cc index a1af04ed..6f5ed622 100644 --- a/third_party/blink/renderer/core/inspector/inspector_audits_issue.cc +++ b/third_party/blink/renderer/core/inspector/inspector_audits_issue.cc
@@ -225,10 +225,12 @@ // Try to get only the script name quickly. std::unique_ptr<SourceLocation> location; String script_url = GetCurrentScriptUrl(); - if (!script_url.IsEmpty()) - location = std::make_unique<SourceLocation>(script_url, 1, 0, nullptr); - else + if (!script_url.IsEmpty()) { + location = + std::make_unique<SourceLocation>(script_url, String(), 1, 0, nullptr); + } else { location = SourceLocation::Capture(execution_context); + } if (location) { navigator_user_agent_details->setLocation(
diff --git a/third_party/blink/renderer/core/inspector/main_thread_debugger.cc b/third_party/blink/renderer/core/inspector/main_thread_debugger.cc index cb82318..2e477ee 100644 --- a/third_party/blink/renderer/core/inspector/main_thread_debugger.cc +++ b/third_party/blink/renderer/core/inspector/main_thread_debugger.cc
@@ -338,7 +338,7 @@ // TODO(dgozman): we can save a copy of message and url here by making // FrameConsole work with StringView. std::unique_ptr<SourceLocation> location = std::make_unique<SourceLocation>( - ToCoreString(url), line_number, column_number, + ToCoreString(url), String(), line_number, column_number, stack_trace ? stack_trace->clone() : nullptr, 0); frame->Console().ReportMessageToClient( mojom::ConsoleMessageSource::kConsoleApi,
diff --git a/third_party/blink/renderer/core/inspector/worker_thread_debugger.cc b/third_party/blink/renderer/core/inspector/worker_thread_debugger.cc index a493c370..dea39fe 100644 --- a/third_party/blink/renderer/core/inspector/worker_thread_debugger.cc +++ b/third_party/blink/renderer/core/inspector/worker_thread_debugger.cc
@@ -236,7 +236,7 @@ return; WorkerThread* worker_thread = worker_threads_.at(context_group_id); std::unique_ptr<SourceLocation> location = std::make_unique<SourceLocation>( - ToCoreString(url), line_number, column_number, + ToCoreString(url), String(), line_number, column_number, stack_trace ? stack_trace->clone() : nullptr, 0); worker_thread->GetWorkerReportingProxy().ReportConsoleMessage( mojom::ConsoleMessageSource::kConsoleApi,
diff --git a/third_party/blink/renderer/core/layout/layout_object.cc b/third_party/blink/renderer/core/layout/layout_object.cc index 90d4552f..9fb216e 100644 --- a/third_party/blink/renderer/core/layout/layout_object.cc +++ b/third_party/blink/renderer/core/layout/layout_object.cc
@@ -3722,8 +3722,24 @@ return multicol_container; } - if (IsFloating() && !IsInLayoutNGInlineFormattingContext()) - return ContainingBlock(skip_info); + if (IsFloating() && !IsInLayoutNGInlineFormattingContext()) { + // TODO(crbug.com/1229581): Remove this when removing support for legacy + // layout. + // + // In the legacy engine, floats inside non-atomic inlines belong to their + // nearest containing block, not the parent non-atomic inline (if any). Skip + // past all non-atomic inlines. Note that the reason for not simply using + // ContainingBlock() here is that we want to stop at any kind of LayoutBox, + // such as LayoutVideo. Otherwise we won't mark the container chain + // correctly when marking for re-layout. + LayoutObject* walker = Parent(); + while (walker && walker->IsLayoutInline()) { + if (skip_info) + skip_info->Update(*walker); + walker = walker->Parent(); + } + return walker; + } return Parent(); }
diff --git a/third_party/blink/renderer/core/page/page.cc b/third_party/blink/renderer/core/page/page.cc index d2370bf..6971a3d 100644 --- a/third_party/blink/renderer/core/page/page.cc +++ b/third_party/blink/renderer/core/page/page.cc
@@ -1046,7 +1046,7 @@ auto* message = MakeGarbageCollected<ConsoleMessage>( mojom::ConsoleMessageSource::kOther, mojom::ConsoleMessageLevel::kWarning, text, - std::make_unique<SourceLocation>(String(), 0, 0, nullptr)); + std::make_unique<SourceLocation>(String(), String(), 0, 0, nullptr)); local_frame->GetDocument()->AddConsoleMessage(message); } }
diff --git a/third_party/blink/renderer/core/paint/paint_layer.cc b/third_party/blink/renderer/core/paint/paint_layer.cc index 448a5e6..aed92ea 100644 --- a/third_party/blink/renderer/core/paint/paint_layer.cc +++ b/third_party/blink/renderer/core/paint/paint_layer.cc
@@ -906,9 +906,10 @@ MarkAncestorChainForFlagsUpdate(); - // TODO(wangxianzhu): Change this to the same pattern as cull rect update - // when removing pre-CAP code. - child->SetNeedsRepaint(); + if (child->SelfNeedsRepaint()) + MarkCompositingContainerChainForNeedsRepaint(); + else + child->SetNeedsRepaint(); if (child->NeedsCullRectUpdate()) MarkCompositingContainerChainForNeedsCullRectUpdate(); @@ -2665,16 +2666,12 @@ } void PaintLayer::SetNeedsRepaint() { - SetSelfNeedsRepaint(); - // Do this unconditionally to ensure container chain is marked when - // compositing status of the layer changes. - MarkCompositingContainerChainForNeedsRepaint(); -} - -void PaintLayer::SetSelfNeedsRepaint() { + if (self_needs_repaint_) + return; self_needs_repaint_ = true; // Invalidate as a display item client. static_cast<DisplayItemClient*>(this)->Invalidate(); + MarkCompositingContainerChainForNeedsRepaint(); } void PaintLayer::SetDescendantNeedsRepaint() {
diff --git a/third_party/blink/renderer/core/paint/paint_layer.h b/third_party/blink/renderer/core/paint/paint_layer.h index 29d97e8f..84410ff 100644 --- a/third_party/blink/renderer/core/paint/paint_layer.h +++ b/third_party/blink/renderer/core/paint/paint_layer.h
@@ -792,7 +792,6 @@ void UpdatePaginationRecursive(bool needs_pagination_update = false); void ClearPaginationRecursive(); - void SetSelfNeedsRepaint(); void MarkCompositingContainerChainForNeedsRepaint(); PaintLayerRareData& EnsureRareData() {
diff --git a/third_party/blink/renderer/core/paint/pre_paint_tree_walk.cc b/third_party/blink/renderer/core/paint/pre_paint_tree_walk.cc index 587491ca..0c451086 100644 --- a/third_party/blink/renderer/core/paint/pre_paint_tree_walk.cc +++ b/third_party/blink/renderer/core/paint/pre_paint_tree_walk.cc
@@ -556,6 +556,8 @@ const NGPhysicalBoxFragment& parent) { bool has_missable_children = false; for (const NGLink& child : parent.Children()) { + if (UNLIKELY(child->IsLayoutObjectDestroyedOrMoved())) + continue; if ((child->IsOutOfFlowPositioned() && (context.current_fragmentainer.fragment || child->IsFixedPositioned())) || @@ -619,6 +621,8 @@ return; for (const NGLink& child : fragment.Children()) { + if (UNLIKELY(child->IsLayoutObjectDestroyedOrMoved())) + continue; if (!child->IsOutOfFlowPositioned() && !child->IsFloating()) continue; if (!pending_missables_.Contains(child.fragment))
diff --git a/third_party/blink/renderer/core/workers/worker_thread.cc b/third_party/blink/renderer/core/workers/worker_thread.cc index 2406a8b..68c38d2 100644 --- a/third_party/blink/renderer/core/workers/worker_thread.cc +++ b/third_party/blink/renderer/core/workers/worker_thread.cc
@@ -34,6 +34,7 @@ #include "base/synchronization/waitable_event.h" #include "base/threading/thread_restrictions.h" #include "third_party/blink/public/common/loader/worker_main_script_load_parameters.h" +#include "third_party/blink/public/mojom/frame/lifecycle.mojom-shared.h" #include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/task_type.h" #include "third_party/blink/renderer/bindings/core/v8/worker_or_worklet_script_controller.h"
diff --git a/third_party/blink/renderer/core/xml/xslt_processor_libxslt.cc b/third_party/blink/renderer/core/xml/xslt_processor_libxslt.cc index f7ebf06f..7b312828 100644 --- a/third_party/blink/renderer/core/xml/xslt_processor_libxslt.cc +++ b/third_party/blink/renderer/core/xml/xslt_processor_libxslt.cc
@@ -81,7 +81,8 @@ console->AddMessage(MakeGarbageCollected<ConsoleMessage>( mojom::ConsoleMessageSource::kXml, level, error->message, - std::make_unique<SourceLocation>(error->file, error->line, 0, nullptr))); + std::make_unique<SourceLocation>(error->file, String(), error->line, 0, + nullptr))); } // FIXME: There seems to be no way to control the ctxt pointer for loading here,
diff --git a/third_party/blink/renderer/modules/broadcastchannel/broadcast_channel.cc b/third_party/blink/renderer/modules/broadcastchannel/broadcast_channel.cc index 46494cf..ac53b00 100644 --- a/third_party/blink/renderer/modules/broadcastchannel/broadcast_channel.cc +++ b/third_party/blink/renderer/modules/broadcastchannel/broadcast_channel.cc
@@ -51,14 +51,6 @@ if (window && window->IsCrossSiteSubframe()) UseCounter::Count(window, WebFeature::kThirdPartyBroadcastChannel); - if (execution_context->GetSecurityOrigin()->IsOpaque()) { - // TODO(mek): Decide what to do here depending on - // https://github.com/whatwg/html/issues/1319 - exception_state.ThrowDOMException( - DOMExceptionCode::kNotSupportedError, - "Can't create BroadcastChannel in an opaque origin"); - return nullptr; - } return MakeGarbageCollected<BroadcastChannel>(execution_context, name); }
diff --git a/third_party/blink/renderer/modules/manifest/manifest_manager.cc b/third_party/blink/renderer/modules/manifest/manifest_manager.cc index e199be9..6dae077c 100644 --- a/third_party/blink/renderer/modules/manifest/manifest_manager.cc +++ b/third_party/blink/renderer/modules/manifest/manifest_manager.cc
@@ -195,8 +195,9 @@ parser.TakeErrors(&manifest_debug_info_->errors); for (const auto& error : manifest_debug_info_->errors) { - auto location = std::make_unique<SourceLocation>( - ManifestURL().GetString(), error->line, error->column, nullptr, 0); + auto location = std::make_unique<SourceLocation>(ManifestURL().GetString(), + String(), error->line, + error->column, nullptr, 0); GetSupplementable()->AddConsoleMessage(MakeGarbageCollected<ConsoleMessage>( mojom::blink::ConsoleMessageSource::kOther,
diff --git a/third_party/blink/renderer/modules/mediastream/video_track_adapter.cc b/third_party/blink/renderer/modules/mediastream/video_track_adapter.cc index 5f557400..6a871123 100644 --- a/third_party/blink/renderer/modules/mediastream/video_track_adapter.cc +++ b/third_party/blink/renderer/modules/mediastream/video_track_adapter.cc
@@ -16,6 +16,7 @@ #include "base/location.h" #include "base/metrics/histogram_macros.h" #include "base/strings/string_number_conversions.h" +#include "base/threading/thread_task_runner_handle.h" #include "base/trace_event/trace_event.h" #include "build/build_config.h" #include "media/base/bind_to_current_loop.h"
diff --git a/third_party/blink/renderer/modules/permissions/permission_status.cc b/third_party/blink/renderer/modules/permissions/permission_status.cc index 9196d62..d74aca8b 100644 --- a/third_party/blink/renderer/modules/permissions/permission_status.cc +++ b/third_party/blink/renderer/modules/permissions/permission_status.cc
@@ -5,6 +5,7 @@ #include "third_party/blink/renderer/modules/permissions/permission_status.h" #include "mojo/public/cpp/bindings/remote.h" +#include "third_party/blink/public/mojom/frame/lifecycle.mojom-shared.h" #include "third_party/blink/public/platform/platform.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" #include "third_party/blink/renderer/core/dom/document.h"
diff --git a/third_party/blink/renderer/modules/shared_storage/shared_storage.cc b/third_party/blink/renderer/modules/shared_storage/shared_storage.cc index 7b0381b00..af8fe37 100644 --- a/third_party/blink/renderer/modules/shared_storage/shared_storage.cc +++ b/third_party/blink/renderer/modules/shared_storage/shared_storage.cc
@@ -9,6 +9,7 @@ #include <utility> #include "base/threading/sequence_local_storage_slot.h" +#include "base/threading/thread_task_runner_handle.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" #include "third_party/blink/public/common/browser_interface_broker_proxy.h" #include "third_party/blink/public/common/features.h"
diff --git a/third_party/blink/renderer/modules/webaudio/base_audio_context.cc b/third_party/blink/renderer/modules/webaudio/base_audio_context.cc index 6ea4344..bda2daf 100644 --- a/third_party/blink/renderer/modules/webaudio/base_audio_context.cc +++ b/third_party/blink/renderer/modules/webaudio/base_audio_context.cc
@@ -28,6 +28,7 @@ #include "base/metrics/histogram_functions.h" #include "build/build_config.h" #include "third_party/blink/public/mojom/devtools/console_message.mojom-blink.h" +#include "third_party/blink/public/mojom/frame/lifecycle.mojom-shared.h" #include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/task_type.h" #include "third_party/blink/renderer/bindings/core/v8/dictionary.h"
diff --git a/third_party/blink/renderer/modules/websockets/web_pepper_socket_impl.cc b/third_party/blink/renderer/modules/websockets/web_pepper_socket_impl.cc index 8657442..c9b0f3b6 100644 --- a/third_party/blink/renderer/modules/websockets/web_pepper_socket_impl.cc +++ b/third_party/blink/renderer/modules/websockets/web_pepper_socket_impl.cc
@@ -128,8 +128,9 @@ } void WebPepperSocketImpl::Fail(const WebString& reason) { - private_->Fail(reason, mojom::ConsoleMessageLevel::kError, - std::make_unique<SourceLocation>(String(), 0, 0, nullptr)); + private_->Fail( + reason, mojom::ConsoleMessageLevel::kError, + std::make_unique<SourceLocation>(String(), String(), 0, 0, nullptr)); } void WebPepperSocketImpl::Disconnect() {
diff --git a/third_party/blink/renderer/modules/websockets/websocket_channel_impl_test.cc b/third_party/blink/renderer/modules/websockets/websocket_channel_impl_test.cc index 3f3eecd..bf9d400 100644 --- a/third_party/blink/renderer/modules/websockets/websocket_channel_impl_test.cc +++ b/third_party/blink/renderer/modules/websockets/websocket_channel_impl_test.cc
@@ -1301,9 +1301,9 @@ auto websocket = Connect(4 * 1024, &writable, &readable, &client); ASSERT_TRUE(websocket); - Channel()->Fail("fail message from WebSocket", - mojom::ConsoleMessageLevel::kError, - std::make_unique<SourceLocation>(String(), 0, 0, nullptr)); + Channel()->Fail( + "fail message from WebSocket", mojom::ConsoleMessageLevel::kError, + std::make_unique<SourceLocation>(String(), String(), 0, 0, nullptr)); } class WebSocketChannelImplHandshakeThrottleTest @@ -1395,9 +1395,9 @@ } Channel()->Connect(url(), ""); - Channel()->Fail("close during handshake", - mojom::ConsoleMessageLevel::kWarning, - std::make_unique<SourceLocation>(String(), 0, 0, nullptr)); + Channel()->Fail( + "close during handshake", mojom::ConsoleMessageLevel::kWarning, + std::make_unique<SourceLocation>(String(), String(), 0, 0, nullptr)); checkpoint.Call(1); } @@ -1421,9 +1421,9 @@ auto websocket = Connect(4 * 1024, &writable, &readable, &client); ASSERT_TRUE(websocket); - Channel()->Fail("close during handshake", - mojom::ConsoleMessageLevel::kWarning, - std::make_unique<SourceLocation>(String(), 0, 0, nullptr)); + Channel()->Fail( + "close during handshake", mojom::ConsoleMessageLevel::kWarning, + std::make_unique<SourceLocation>(String(), String(), 0, 0, nullptr)); checkpoint.Call(1); }
diff --git a/third_party/blink/renderer/modules/websockets/websocket_common.cc b/third_party/blink/renderer/modules/websockets/websocket_common.cc index 2ea9b38..e1ab9a5 100644 --- a/third_party/blink/renderer/modules/websockets/websocket_common.cc +++ b/third_party/blink/renderer/modules/websockets/websocket_common.cc
@@ -168,9 +168,10 @@ return; if (state_ == kConnecting) { state_ = kClosing; - channel->Fail("WebSocket is closed before the connection is established.", - mojom::ConsoleMessageLevel::kWarning, - std::make_unique<SourceLocation>(String(), 0, 0, nullptr)); + channel->Fail( + "WebSocket is closed before the connection is established.", + mojom::ConsoleMessageLevel::kWarning, + std::make_unique<SourceLocation>(String(), String(), 0, 0, nullptr)); return; } state_ = kClosing;
diff --git a/third_party/blink/renderer/platform/bindings/v8_per_isolate_data.cc b/third_party/blink/renderer/platform/bindings/v8_per_isolate_data.cc index fe8509a..ed6c0a4 100644 --- a/third_party/blink/renderer/platform/bindings/v8_per_isolate_data.cc +++ b/third_party/blink/renderer/platform/bindings/v8_per_isolate_data.cc
@@ -422,8 +422,8 @@ } void ReportV8OOMError(const char* location, bool is_js_heap) { - DVLOG(1) << "V8 " << (is_js_heap ? "javascript" : "process") << " OOM: (" - << location << ")."; + LOG(ERROR) << "V8 " << (is_js_heap ? "javascript" : "process") << " OOM: (" + << location << ")."; OOM_CRASH(0); }
diff --git a/third_party/blink/renderer/platform/exported/resource_load_info_notifier_wrapper.cc b/third_party/blink/renderer/platform/exported/resource_load_info_notifier_wrapper.cc index 7ab5af8..02e8a76d 100644 --- a/third_party/blink/renderer/platform/exported/resource_load_info_notifier_wrapper.cc +++ b/third_party/blink/renderer/platform/exported/resource_load_info_notifier_wrapper.cc
@@ -6,6 +6,7 @@ #include "base/bind.h" #include "base/metrics/histogram_macros.h" +#include "base/threading/thread_task_runner_handle.h" #include "build/build_config.h" #include "net/base/ip_endpoint.h" #include "net/url_request/redirect_info.h"
diff --git a/third_party/blink/renderer/platform/geometry/float_rounded_rect.cc b/third_party/blink/renderer/platform/geometry/float_rounded_rect.cc index 6afcf05a..0e5374c 100644 --- a/third_party/blink/renderer/platform/geometry/float_rounded_rect.cc +++ b/third_party/blink/renderer/platform/geometry/float_rounded_rect.cc
@@ -147,8 +147,10 @@ } void FloatRoundedRect::Radii::OutsetForShapeMargin(float outset) { - // We're not sure the following is fully correct for non-circular corners, - // but it's definitely close. + // TODO(crbug.com/1309478): This isn't correct for non-circular + // corners (that is, corners that have x and y radii that are not + // equal). But it's not clear to me if the correct result for that + // case is even an ellipse. gfx::SizeF outset_size(outset, outset); top_left_ += outset_size; top_right_ += outset_size;
diff --git a/third_party/blink/renderer/platform/graphics/paint_worklet_paint_dispatcher_test.cc b/third_party/blink/renderer/platform/graphics/paint_worklet_paint_dispatcher_test.cc index 2dfb0ac..568b84a 100644 --- a/third_party/blink/renderer/platform/graphics/paint_worklet_paint_dispatcher_test.cc +++ b/third_party/blink/renderer/platform/graphics/paint_worklet_paint_dispatcher_test.cc
@@ -12,6 +12,7 @@ #include "third_party/blink/public/platform/platform.h" #include "third_party/blink/renderer/platform/scheduler/public/thread.h" #include "third_party/blink/renderer/platform/scheduler/public/thread_type.h" +#include "third_party/blink/renderer/platform/wtf/vector.h" using ::testing::_; using ::testing::NiceMock;
diff --git a/third_party/blink/renderer/platform/graphics/video_frame_submitter.cc b/third_party/blink/renderer/platform/graphics/video_frame_submitter.cc index cf13b55..e7001a1 100644 --- a/third_party/blink/renderer/platform/graphics/video_frame_submitter.cc +++ b/third_party/blink/renderer/platform/graphics/video_frame_submitter.cc
@@ -13,6 +13,7 @@ #include "base/metrics/histogram_macros.h" #include "base/threading/platform_thread.h" #include "base/threading/sequenced_task_runner_handle.h" +#include "base/threading/thread_task_runner_handle.h" #include "base/trace_event/trace_event.h" #include "build/build_config.h" #include "cc/metrics/video_playback_roughness_reporter.h"
diff --git a/third_party/blink/renderer/platform/loader/fetch/url_loader/web_resource_request_sender.cc b/third_party/blink/renderer/platform/loader/fetch/url_loader/web_resource_request_sender.cc index 48456dc..5c8719c 100644 --- a/third_party/blink/renderer/platform/loader/fetch/url_loader/web_resource_request_sender.cc +++ b/third_party/blink/renderer/platform/loader/fetch/url_loader/web_resource_request_sender.cc
@@ -18,6 +18,7 @@ #include "base/synchronization/waitable_event.h" #include "base/task/post_task.h" #include "base/task/thread_pool.h" +#include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" #include "base/trace_event/trace_event.h" #include "build/build_config.h"
diff --git a/third_party/blink/renderer/platform/loader/fetch/url_loader/web_url_loader.cc b/third_party/blink/renderer/platform/loader/fetch/url_loader/web_url_loader.cc index 7ea7729..1a0288a 100644 --- a/third_party/blink/renderer/platform/loader/fetch/url_loader/web_url_loader.cc +++ b/third_party/blink/renderer/platform/loader/fetch/url_loader/web_url_loader.cc
@@ -84,6 +84,7 @@ #include "third_party/blink/public/web/web_local_frame.h" #include "third_party/blink/public/web/web_security_policy.h" #include "third_party/blink/renderer/platform/loader/fetch/url_loader/sync_load_response.h" +#include "third_party/blink/renderer/platform/weborigin/kurl.h" #include "third_party/boringssl/src/include/openssl/ssl.h" #include "url/origin.h"
diff --git a/third_party/blink/renderer/platform/loader/internet_disconnected_web_url_loader.cc b/third_party/blink/renderer/platform/loader/internet_disconnected_web_url_loader.cc index cd7ca3c..449b9060 100644 --- a/third_party/blink/renderer/platform/loader/internet_disconnected_web_url_loader.cc +++ b/third_party/blink/renderer/platform/loader/internet_disconnected_web_url_loader.cc
@@ -15,6 +15,7 @@ #include "third_party/blink/public/platform/web_url_loader_client.h" #include "third_party/blink/public/platform/web_url_request.h" #include "third_party/blink/public/platform/web_url_request_extra_data.h" +#include "third_party/blink/renderer/platform/weborigin/kurl.h" namespace blink {
diff --git a/third_party/blink/renderer/platform/p2p/socket_dispatcher.cc b/third_party/blink/renderer/platform/p2p/socket_dispatcher.cc index 4c934b0..7770f1a1 100644 --- a/third_party/blink/renderer/platform/p2p/socket_dispatcher.cc +++ b/third_party/blink/renderer/platform/p2p/socket_dispatcher.cc
@@ -5,6 +5,7 @@ #include "third_party/blink/renderer/platform/p2p/socket_dispatcher.h" #include "base/memory/scoped_refptr.h" +#include "base/threading/thread_task_runner_handle.h" #include "base/types/pass_key.h" #include "services/network/public/cpp/p2p_param_traits.h" #include "third_party/blink/public/common/browser_interface_broker_proxy.h"
diff --git a/third_party/blink/renderer/platform/scheduler/common/dummy_schedulers.cc b/third_party/blink/renderer/platform/scheduler/common/dummy_schedulers.cc index d00b535..d15be87 100644 --- a/third_party/blink/renderer/platform/scheduler/common/dummy_schedulers.cc +++ b/third_party/blink/renderer/platform/scheduler/common/dummy_schedulers.cc
@@ -4,6 +4,7 @@ #include "third_party/blink/renderer/platform/scheduler/public/dummy_schedulers.h" +#include "base/threading/thread_task_runner_handle.h" #include "third_party/blink/public/common/browser_interface_broker_proxy.h" #include "third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.h" #include "third_party/blink/renderer/platform/scheduler/public/agent_group_scheduler.h"
diff --git a/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.h b/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.h index 5745180..42adfad 100644 --- a/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.h +++ b/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.h
@@ -20,6 +20,7 @@ #include "base/task/sequence_manager/task_queue.h" #include "base/task/sequence_manager/task_time_observer.h" #include "base/task/single_thread_task_runner.h" +#include "base/threading/thread_task_runner_handle.h" #include "base/trace_event/trace_log.h" #include "build/build_config.h" #include "components/power_scheduler/power_mode_voter.h"
diff --git a/third_party/blink/renderer/platform/scheduler/worker/worker_thread.cc b/third_party/blink/renderer/platform/scheduler/worker/worker_thread.cc index a75d5403..8f20e044 100644 --- a/third_party/blink/renderer/platform/scheduler/worker/worker_thread.cc +++ b/third_party/blink/renderer/platform/scheduler/worker/worker_thread.cc
@@ -17,6 +17,7 @@ #include "base/task/sequence_manager/task_queue.h" #include "base/task/single_thread_task_runner.h" #include "base/threading/thread_restrictions.h" +#include "base/threading/thread_task_runner_handle.h" #include "base/time/default_tick_clock.h" #include "third_party/blink/public/platform/task_type.h" #include "third_party/blink/renderer/platform/heap/blink_gc_memory_dump_provider.h"
diff --git a/third_party/blink/renderer/platform/timer_test.cc b/third_party/blink/renderer/platform/timer_test.cc index 94ccfd2..78a2ca2 100644 --- a/third_party/blink/renderer/platform/timer_test.cc +++ b/third_party/blink/renderer/platform/timer_test.cc
@@ -11,6 +11,7 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/blink/public/platform/platform.h" +#include "third_party/blink/renderer/platform/heap/garbage_collected.h" #include "third_party/blink/renderer/platform/heap/thread_state.h" #include "third_party/blink/renderer/platform/heap/thread_state_scopes.h" #include "third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.h"
diff --git a/third_party/blink/renderer/platform/widget/input/widget_input_handler_impl.cc b/third_party/blink/renderer/platform/widget/input/widget_input_handler_impl.cc index 4d90ede..0b79e01 100644 --- a/third_party/blink/renderer/platform/widget/input/widget_input_handler_impl.cc +++ b/third_party/blink/renderer/platform/widget/input/widget_input_handler_impl.cc
@@ -8,6 +8,7 @@ #include "base/bind.h" #include "base/check.h" +#include "base/threading/thread_task_runner_handle.h" #include "build/build_config.h" #include "mojo/public/cpp/bindings/self_owned_associated_receiver.h" #include "third_party/blink/public/common/input/web_coalesced_input_event.h"
diff --git a/third_party/blink/renderer/platform/widget/widget_base.cc b/third_party/blink/renderer/platform/widget/widget_base.cc index 3e6efc9e..89a8e8d 100644 --- a/third_party/blink/renderer/platform/widget/widget_base.cc +++ b/third_party/blink/renderer/platform/widget/widget_base.cc
@@ -8,6 +8,7 @@ #include "base/logging.h" #include "base/metrics/histogram_macros.h" #include "base/ranges/algorithm.h" +#include "base/threading/thread_task_runner_handle.h" #include "build/build_config.h" #include "cc/mojo_embedder/async_layer_tree_frame_sink.h" #include "cc/trees/layer_tree_host.h"
diff --git a/third_party/blink/tools/blinkpy/web_tests/controllers/test_result_sink.py b/third_party/blink/tools/blinkpy/web_tests/controllers/test_result_sink.py index c9d71df..9677e97 100644 --- a/third_party/blink/tools/blinkpy/web_tests/controllers/test_result_sink.py +++ b/third_party/blink/tools/blinkpy/web_tests/controllers/test_result_sink.py
@@ -247,6 +247,13 @@ if summaries: r['summaryHtml'] = '\n'.join(summaries) + if result.failure_reason: + primary_error_message = _truncate_to_utf8_bytes( + result.failure_reason.primary_error_message, 1024) + r['failureReason'] = { + 'primaryErrorMessage': primary_error_message, + } + self._send({'testResults': [r]}) def close(self): @@ -257,3 +264,31 @@ if not self.is_closed: self.is_closed = True self._session.close() + + +def _truncate_to_utf8_bytes(s, length): + """ Truncates a string to a given number of bytes when encoded as UTF-8. + + Ensures the given string does not take more than length bytes when encoded + as UTF-8. Adds trailing ellipsis (...) if truncation occurred. A truncated + string may end up encoding to a length slightly shorter than length + because only whole Unicode codepoints are dropped. + + Args: + s: The string to truncate. + length: the length (in bytes) to truncate to. + """ + try: + encoded = s.encode('utf-8') + # When encode throws UnicodeDecodeError in py2, it usually means the str is + # already encoded and has non-ascii chars. So skip re-encoding it. + except UnicodeDecodeError: + encoded = s + if len(encoded) > length: + # Truncate, leaving space for trailing ellipsis (...). + encoded = encoded[:length - 3] + # Truncating the string encoded as UTF-8 may have left the final + # codepoint only partially present. Pass 'ignore' to acknowledge + # and ensure this is dropped. + return encoded.decode('utf-8', 'ignore') + "..." + return s
diff --git a/third_party/blink/tools/blinkpy/web_tests/controllers/test_result_sink_unittest.py b/third_party/blink/tools/blinkpy/web_tests/controllers/test_result_sink_unittest.py index 16e8422..9251881f 100644 --- a/third_party/blink/tools/blinkpy/web_tests/controllers/test_result_sink_unittest.py +++ b/third_party/blink/tools/blinkpy/web_tests/controllers/test_result_sink_unittest.py
@@ -15,7 +15,7 @@ from blinkpy.common.path_finder import RELATIVE_WEB_TESTS from blinkpy.web_tests.controllers.test_result_sink import CreateTestResultSink from blinkpy.web_tests.controllers.test_result_sink import TestResultSink -from blinkpy.web_tests.models import test_results +from blinkpy.web_tests.models import test_results, failure_reason from blinkpy.web_tests.models.typ_types import ResultType from blinkpy.web_tests.port.test import add_manifest_to_mock_filesystem from blinkpy.web_tests.port.test import TestPort @@ -347,3 +347,32 @@ 'virtual/virtual_wpt/external/wpt/dom/ranges/Range-attributes.html', 'external/wpt/dom/ranges/Range-attributes.html', ) + + def test_failure_reason(self): + tr = test_results.TestResult(test_name='test-name') + tr.failure_reason = failure_reason.FailureReason( + 'primary error message') + sent_data = self.sink(True, tr) + self.assertDictEqual(sent_data['failureReason'], { + 'primaryErrorMessage': 'primary error message', + }) + + def test_failure_reason_truncated(self): + # Swedish "Place of interest symbol", which encodes as 3 bytes in + # UTF-8. This is one Unicode code point. + poi = b'\xE2\x8C\x98'.decode('utf-8') + primary_error_message = poi * 350 + + # Test that the primary error message is truncated to 1K bytes in + # UTF-8 encoding. + tr = test_results.TestResult(test_name='test-name') + tr.failure_reason = failure_reason.FailureReason(primary_error_message) + sent_data = self.sink(True, tr) + + # Ensure truncation has left only whole unicode code points. + # In this case, the output ends up being 1023 bytes, which is one + # byte less than the allowed size of 1024 bytes, as we do not want + # part of a unicode code point to be included in the output. + self.assertDictEqual(sent_data['failureReason'], { + 'primaryErrorMessage': (poi * 340) + '...', + })
diff --git a/third_party/blink/tools/blinkpy/web_tests/models/failure_reason.py b/third_party/blink/tools/blinkpy/web_tests/models/failure_reason.py new file mode 100644 index 0000000..6b20bbc --- /dev/null +++ b/third_party/blink/tools/blinkpy/web_tests/models/failure_reason.py
@@ -0,0 +1,20 @@ +# Copyright 2022 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +# Information about why a test failed. +# Modelled after https://source.chromium.org/chromium/infra/infra/+/master:go/src/go.chromium.org/luci/resultdb/proto/v1/failure_reason.proto +class FailureReason(object): + def __init__(self, primary_error_message): + """Initialises a new failure reason. + + Args: + primary_error_message: The error message that ultimately caused + the test to fail. This should/ only be the error message + and should not include any stack traces. In the case that + a test failed due to multiple expectation failures, any + immediately fatal failure should be chosen, or otherwise + the first expectation failure. + """ + self.primary_error_message = primary_error_message
diff --git a/third_party/blink/tools/blinkpy/web_tests/models/test_failures.py b/third_party/blink/tools/blinkpy/web_tests/models/test_failures.py index 8d5024d..aab7c7c 100644 --- a/third_party/blink/tools/blinkpy/web_tests/models/test_failures.py +++ b/third_party/blink/tools/blinkpy/web_tests/models/test_failures.py
@@ -25,11 +25,13 @@ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +import re import six from six.moves import cPickle from blinkpy.web_tests.controllers import repaint_overlay from blinkpy.web_tests.models.typ_types import ResultType +from blinkpy.web_tests.models.failure_reason import FailureReason from blinkpy.common.html_diff import html_diff from blinkpy.common.unified_diff import unified_diff @@ -101,6 +103,9 @@ _ext_to_file_type = {'.txt': 'text', '.png': 'image', '.wav': 'audio'} +# Matches new failures in TestHarness.js tests. +FAILURE_RE = re.compile(r'\+(?:FAIL|Harness Error\.) (.*)$') + def has_failure_type(failure_type, failure_list): return any(isinstance(failure, failure_type) for failure in failure_list) @@ -174,6 +179,13 @@ """Returns a string describing the failure in more detail.""" raise NotImplementedError + def failure_reason(self): + """Returns a FailureReason object describing why the test failed, if + the test failed and suitable reasons are available. + The information is used in LUCI result viewing UIs and will be + used to cluster similar failures together.""" + return None + def __eq__(self, other): return self.__class__.__name__ == other.__class__.__name__ @@ -309,38 +321,48 @@ expected_driver_output) self.has_repaint_overlay = ( repaint_overlay.result_contains_repaint_rects( - actual_driver_output.text) + self._actual_text()) or repaint_overlay.result_contains_repaint_rects( - expected_driver_output.text)) + self._expected_text())) self.file_ext = '.txt' + def _actual_text(self): + if self.actual_driver_output and\ + self.actual_driver_output.text is not None: + if six.PY3: + # TODO(crbug/1197331): We should not decode here looks like. + # html_diff expects it to be bytes for comparing to account + # various types of encodings. + # html_diff.py and unified_diff.py use str types during + # diff fixup. Will handle it later. + return self.actual_driver_output.text.decode('utf8', 'replace') + else: + return self.actual_driver_output.text + return '' + + def _expected_text(self): + if self.expected_driver_output and\ + self.expected_driver_output.text is not None: + if six.PY3: + # TODO(crbug/1197331): We should not decode here looks like. + # html_diff expects it to be bytes for comparing to account + # various types of encodings. + # html_diff.py and unified_diff.py use str types during + # diff fixup. Will handle it later. + return self.expected_driver_output.text.decode( + 'utf8', 'replace') + else: + return self.expected_driver_output.text + return '' + def create_artifacts(self, typ_artifacts, force_overwrite=False): # TODO (rmhasan): See if you can can only output diff files for # non empty text. super(FailureText, self).create_artifacts(typ_artifacts, force_overwrite) - actual_text = '' - expected_text = '' - if self.expected_driver_output.text is not None: - if six.PY3: - # TODO(crbug/1197331): We should not decode here looks like. - # html_diff expects it to be bytes for comparing to account - # various types of encodings. - # html_diff.py and unified_diff.py use str types during - # diff fixup. Will handle it later. - expected_text = self.expected_driver_output.text.decode( - 'utf8', 'replace') - else: - expected_text = self.expected_driver_output.text - - if self.actual_driver_output.text is not None: - if six.PY3: - # TODO(crbug/1197331): ditto as in the case of expected_text above. - actual_text = self.actual_driver_output.text.decode( - 'utf8', 'replace') - else: - actual_text = self.actual_driver_output.text + actual_text = self._actual_text() + expected_text = self._expected_text() artifacts_abs_path = self.filesystem.join( self.result_directory, typ_artifacts.ArtifactsSubDirectory()) @@ -374,6 +396,72 @@ def text_mismatch_category(self): raise NotImplementedError + def failure_reason(self): + actual_text = self._actual_text() + expected_text = self._expected_text() + diff_content = unified_diff(expected_text, actual_text, "expected", + "actual") + diff_lines = diff_content.splitlines() + + # Drop the standard diff header with the following lines: + # --- expected + # +++ actual + diff_lines = diff_lines[2:] + + # Find the first block of additions and/or deletions in the diff. + # E.g. + # Unchanged line + # -Old line 1 <-- Start of block + # -Old line 2 + # +New line 1 + # +New line 2 <-- End of block + # Unchanged line + deleted_lines = [] + added_lines = [] + match_state = '' + for i, line in enumerate(diff_lines): + # A block of diffs starts with removals (-) + # and then additions (+). Any variation from this + # pattern indicates an end of this block of diffs. + if ((line.startswith(' ') and match_state != '') + or (line.startswith('-') and match_state == '+')): + # End of block of additions and deletions. + break + if line.startswith('-'): + match_state = '-' + deleted_lines.append(line) + if line.startswith('+'): + match_state = '+' + added_lines.append(line) + + primary_error = None + + if 'This is a testharness.js-based test.' in actual_text: + # Testharness.js test. Find the first new failure (if any) and + # report it as the failure reason. + for i, line in enumerate(added_lines): + match = FAILURE_RE.match(line) + if match: + primary_error = match.group(1) + break + else: + # Reconstitute the first diff block, but put added lines before + # the deleted lines as they are usually more interesting. + # (New actual output more interesting than missing expected + # output, as it is likely to contain errors.) + first_diff_block = '\n'.join(added_lines + deleted_lines) + + if len(first_diff_block) >= 30: + # Only use the diff if it is not tiny. If it is only the + # addition of an empty line at the end of the file or + # similar, it is unlikely to be useful. + primary_error = ('Unexpected Diff (+got, -want):\n' + + first_diff_block) + + if primary_error: + return FailureReason(primary_error) + return None + class FailureMissingResult(FailureText): def message(self):
diff --git a/third_party/blink/tools/blinkpy/web_tests/models/test_failures_unittest.py b/third_party/blink/tools/blinkpy/web_tests/models/test_failures_unittest.py index acf0111..03514b9c 100644 --- a/third_party/blink/tools/blinkpy/web_tests/models/test_failures_unittest.py +++ b/third_party/blink/tools/blinkpy/web_tests/models/test_failures_unittest.py
@@ -36,7 +36,7 @@ PassWithStderr, FailureCrash, FailureTimeout, - TestFailure) + TestFailure, FailureText) class TestFailuresTest(unittest.TestCase): @@ -131,3 +131,61 @@ pass_with_stderr.create_artifacts(artifacts) self.assertEqual('timeout with stderr', host.filesystem.read_text_file('/dir/foo-stderr.txt')) + + def test_failure_text_failure_reason_testharness_js(self): + expected_text = '' + actual_text = """Content-Type: text/plain +This is a testharness.js-based test. +FAIL Tests that the document gets overscroll event with right deltaX/Y attributes. promise_test: Unhandled rejection with value: "Document did not receive scrollend event." +Harness: the test ran to completion.""" + + self._actual_output.text = actual_text.encode('utf8') + self._expected_output.text = expected_text.encode('utf8') + + failure_text = FailureText(self._actual_output, self._expected_output) + failure_reason = failure_text.failure_reason() + self.assertIsNotNone(failure_reason) + self.assertEqual( + failure_reason.primary_error_message, + 'Tests that the document gets overscroll event with right' + ' deltaX/Y attributes. promise_test: Unhandled rejection with' + ' value: "Document did not receive scrollend event."') + + def test_failure_text_failure_reason_other(self): + expected_text = """retained line 1 +deleted line 1 +deleted line 2 +retained line 2 +""" + + actual_text = """retained line 1 +new line 1 +retained line 2 +new line 2 +""" + + self._actual_output.text = actual_text.encode('utf8') + self._expected_output.text = expected_text.encode('utf8') + + failure_text = FailureText(self._actual_output, self._expected_output) + failure_reason = failure_text.failure_reason() + self.assertIsNotNone(failure_reason) + self.assertEqual( + failure_reason.primary_error_message, + 'Unexpected Diff (+got, -want):\n' + '+new line 1\n' + '-deleted line 1\n' + '-deleted line 2') + + def test_failure_text_failure_reason_empty(self): + # Construct a scenario in which the difference between the actual + # and expected text does not provide a useful failure reason. + expected_text = '' + actual_text = '\n' + + self._actual_output.text = actual_text.encode('utf8') + self._expected_output.text = expected_text.encode('utf8') + + failure_text = FailureText(self._actual_output, self._expected_output) + failure_reason = failure_text.failure_reason() + self.assertIsNone(failure_reason)
diff --git a/third_party/blink/tools/blinkpy/web_tests/models/test_results.py b/third_party/blink/tools/blinkpy/web_tests/models/test_results.py index 04f041e..9b68382 100644 --- a/third_party/blink/tools/blinkpy/web_tests/models/test_results.py +++ b/third_party/blink/tools/blinkpy/web_tests/models/test_results.py
@@ -113,6 +113,17 @@ # FIXME: Setting this in the constructor makes this class hard to mutate. self.type = results.pop() + self.failure_reason = None + for failure in self.failures: + # Take the failure reason from any failure that has one. + # At time of writing, only one type of failure defines failure + # reasons, if this changes, we may want to change this to be + # more deterministic. + failure_reason = failure.failure_reason() + if failure_reason: + self.failure_reason = failure_reason + break + # These are set by the worker, not by the driver, so they are not passed to the constructor. self.worker_name = '' self.shard_name = ''
diff --git a/third_party/blink/tools/blinkpy/web_tests/models/test_results_unittest.py b/third_party/blink/tools/blinkpy/web_tests/models/test_results_unittest.py index 8d2888b..db575d23 100644 --- a/third_party/blink/tools/blinkpy/web_tests/models/test_results_unittest.py +++ b/third_party/blink/tools/blinkpy/web_tests/models/test_results_unittest.py
@@ -58,7 +58,8 @@ self.assertTrue(result.has_stderr) def test_results_has_repaint_overlay(self): - driver_output = DriverOutput('"invalidations": [', None, None, None) + text = '"invalidations": ['.encode('utf8') + driver_output = DriverOutput(text, None, None, None) failures = [test_failures.FailureTextMismatch(driver_output, None)] result = TestResult('foo', failures=failures) self.assertTrue(result.has_repaint_overlay)
diff --git a/third_party/blink/web_tests/TestExpectations b/third_party/blink/web_tests/TestExpectations index 75957fc..f459501 100644 --- a/third_party/blink/web_tests/TestExpectations +++ b/third_party/blink/web_tests/TestExpectations
@@ -2355,6 +2355,9 @@ crbug.com/919789 images/image-zoom-to-25.html [ Timeout ] crbug.com/919789 images/image-zoom-to-500.html [ Timeout ] +# Early Hints +crbug.com/1305896 external/wpt/loading/early-hints/redirect-cross-origin-between-early-hints.h2.window.html [ Failure ] + # Sheriff 2020-02-06 # Flaking on Linux Leak crbug.com/1049599 [ Linux ] virtual/threaded-prefer-compositing/fast/scrolling/events/overscroll-event-fired-to-element-with-overscroll-behavior.html [ Failure Pass Skip Timeout ] @@ -4551,8 +4554,6 @@ crbug.com/619427 [ Mac ] fast/overflow/overflow-height-float-not-removed-crash3.html [ Failure Pass ] -crbug.com/670024 external/wpt/webmessaging/broadcastchannel/sandbox.html [ Failure ] -crbug.com/670024 external/wpt/webmessaging/broadcastchannel/opaque-origin.html [ Timeout ] crbug.com/660384 external/wpt/webmessaging/with-ports/001.html [ Failure ] crbug.com/660384 external/wpt/webmessaging/without-ports/001.html [ Failure ] crbug.com/660384 external/wpt/webmessaging/with-options/broken-origin.html [ Failure ]
diff --git a/third_party/blink/web_tests/android/ChromeWPTOverrideExpectations b/third_party/blink/web_tests/android/ChromeWPTOverrideExpectations index 791ec7d..d35b6183d 100644 --- a/third_party/blink/web_tests/android/ChromeWPTOverrideExpectations +++ b/third_party/blink/web_tests/android/ChromeWPTOverrideExpectations
@@ -821,7 +821,6 @@ crbug.com/1050754 external/wpt/forced-colors-mode/forced-colors-mode-40.html [ Pass ] crbug.com/1050754 external/wpt/fullscreen/api/element-request-fullscreen-options.tentative.html [ Failure ] crbug.com/1050754 external/wpt/geolocation-API/getCurrentPosition_IDL.https.html [ Timeout ] -crbug.com/1050754 external/wpt/geolocation-API/getCurrentPosition_permission_allow.https.html [ Timeout ] crbug.com/1050754 external/wpt/geolocation-API/getCurrentPosition_permission_deny.https.html [ Timeout ] crbug.com/1050754 external/wpt/geolocation-API/watchPosition_permission_deny.https.html [ Timeout ] crbug.com/1050754 external/wpt/gyroscope/Gyroscope.https.html [ Failure ]
diff --git a/third_party/blink/web_tests/android/WebLayerWPTOverrideExpectations b/third_party/blink/web_tests/android/WebLayerWPTOverrideExpectations index afeb2ee..220a172 100644 --- a/third_party/blink/web_tests/android/WebLayerWPTOverrideExpectations +++ b/third_party/blink/web_tests/android/WebLayerWPTOverrideExpectations
@@ -963,7 +963,6 @@ crbug.com/1050754 external/wpt/forced-colors-mode/forced-colors-mode-40.html [ Pass ] crbug.com/1050754 external/wpt/fullscreen/api/element-request-fullscreen-options.tentative.html [ Failure ] crbug.com/1050754 external/wpt/geolocation-API/getCurrentPosition_IDL.https.html [ Timeout ] -crbug.com/1050754 external/wpt/geolocation-API/getCurrentPosition_permission_allow.https.html [ Timeout ] crbug.com/1050754 external/wpt/geolocation-API/getCurrentPosition_permission_deny.https.html [ Timeout ] crbug.com/1050754 external/wpt/geolocation-API/non-fully-active.https.html [ Timeout ] crbug.com/1050754 external/wpt/geolocation-API/watchPosition_permission_deny.https.html [ Timeout ]
diff --git a/third_party/blink/web_tests/android/WebviewWPTExpectations b/third_party/blink/web_tests/android/WebviewWPTExpectations index 1ee949e5..186c4aa 100644 --- a/third_party/blink/web_tests/android/WebviewWPTExpectations +++ b/third_party/blink/web_tests/android/WebviewWPTExpectations
@@ -2338,7 +2338,6 @@ crbug.com/1050754 external/wpt/generic-sensor/generic-sensor-permission.https.html [ Crash Failure ] crbug.com/1050754 external/wpt/geolocation-API/PositionOptions.https.html [ Failure ] crbug.com/1050754 external/wpt/geolocation-API/getCurrentPosition_IDL.https.html [ Failure Pass ] -crbug.com/1050754 external/wpt/geolocation-API/getCurrentPosition_permission_allow.https.html [ Failure Pass ] crbug.com/1050754 external/wpt/geolocation-sensor/GeolocationSensor-disabled-by-feature-policy.https.html [ Failure Pass ] crbug.com/1050754 external/wpt/geolocation-sensor/GeolocationSensor-enabled-by-feature-policy-attribute-redirect-on-load.https.html [ Failure Pass ] crbug.com/1050754 external/wpt/geolocation-sensor/GeolocationSensor-enabled-by-feature-policy-attribute.https.html [ Failure Pass ]
diff --git a/third_party/blink/web_tests/external/Version b/third_party/blink/web_tests/external/Version index 7f1441b..136350b 100644 --- a/third_party/blink/web_tests/external/Version +++ b/third_party/blink/web_tests/external/Version
@@ -1 +1 @@ -Version: 3066f93d38af751093e8669d14e5c4a29fdc022c +Version: 7c61a4594a95682531367b6956d1c37f8b8fd486
diff --git a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json index fdc26d7..e0e43ec 100644 --- a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json +++ b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json
@@ -84575,6 +84575,84 @@ ], {} ] + ], + "table-cell-expansion-001.html": [ + "b10d516787ac03841f8720b2d84d2081fe73f52a", + [ + null, + [ + [ + "/css/reference/ref-filled-green-100px-square.xht", + "==" + ] + ], + {} + ] + ], + "table-cell-expansion-002.html": [ + "6df44aa7636ac37d5b33cdf40e7d08d9ea48f0b6", + [ + null, + [ + [ + "/css/reference/ref-filled-green-100px-square.xht", + "==" + ] + ], + {} + ] + ], + "table-cell-expansion-003.html": [ + "32e12012ac894558f695982516e9f95efe419606", + [ + null, + [ + [ + "/css/reference/ref-filled-green-100px-square.xht", + "==" + ] + ], + {} + ] + ], + "table-cell-expansion-004.html": [ + "2390e218c9ec8216957e8e71019b52203ad48b6d", + [ + null, + [ + [ + "/css/reference/ref-filled-green-100px-square.xht", + "==" + ] + ], + {} + ] + ], + "table-cell-expansion-005.html": [ + "23fcc73e166e95aafc3008981e0e961225c9816d", + [ + null, + [ + [ + "/css/reference/ref-filled-green-100px-square.xht", + "==" + ] + ], + {} + ] + ], + "table-cell-expansion-006.html": [ + "102866477454ab75a034f32269238345e3533e6e", + [ + null, + [ + [ + "/css/reference/ref-filled-green-100px-square.xht", + "==" + ] + ], + {} + ] ] }, "tall-break-inside-avoid-at-start.html": [ @@ -140168,7 +140246,7 @@ ] ], "overflow-body-propagation-010.html": [ - "7a9966c151afff318959fef9f6c760d6bde078cd", + "a3fcdaf3c5f1faf6d2675cf59c53a4d81e3f1031", [ null, [ @@ -234861,6 +234939,10 @@ "README.md": [ "05bacb7f16db124a998a98ce242775fae91078bd", [] + ], + "compute_pressure_take_records.tentative.https.window-expected.txt": [ + "375f8f449013c2d2f5a7c2f4f61d9999f4c236ac", + [] ] }, "console": { @@ -282511,8 +282593,12 @@ "4a86814fdf71b69e7b6b89d684a208131852cdbe", [] ], + "chrome-chromium-installation-detection.md": [ + "63fcd8688d41f09c3a8e73968197b23a069a5d67", + [] + ], "chrome.md": [ - "0c07b6fef9e68d3f905fe710d39be06c3960a064", + "45293af65ef3bb0e57cd59ee4f3f44961266df07", [] ], "chrome_android.md": [ @@ -289764,6 +289850,42 @@ "2a444bd5a75e385d1a68618c16f302a4df682246", [] ], + "anonymous-iframe": { + "anonymous-window.tentative.https.js": [ + "14ea26dab5bcf069e8b4d1179b4a3754b0865bf6", + [] + ], + "cookie.tentative.https.window-expected.txt": [ + "377c7296a781adb8ce5792cda50a4ded28472339", + [] + ], + "fenced-frame-bypass.tentative.https.window-expected.txt": [ + "dc538e12907885d23b2fa5b3a6f9c6364b88fdc4", + [] + ], + "fenced-frame.tentative.https.window-expected.txt": [ + "dc538e12907885d23b2fa5b3a6f9c6364b88fdc4", + [] + ], + "require-corp-embed-anonymous-iframe.tentative.https.window.js.headers": [ + "6604450991a122e3e241e40b1b9e0516c525389d", + [] + ], + "resources": { + "common.js": [ + "e83bd094670dd4a8541031c4a66d738045484dc1", + [] + ], + "serviceworker-partitioning-helper.js": [ + "288ad5954e2d51c17c1088dac428927f63321bbf", + [] + ], + "sharedworker-partitioning-helper.js": [ + "8b416c33d72cf55f080e1a1011bdb45718c8f258", + [] + ] + } + }, "browsers": { "browsing-the-web": { "back-forward-cache": { @@ -293735,42 +293857,6 @@ "6604450991a122e3e241e40b1b9e0516c525389d", [] ], - "anonymous-iframe": { - "anonymous-window.tentative.https.js": [ - "dc63dc262aa5dbbe1e905e7f8791fa54e0e33979", - [] - ], - "cookie.tentative.https.window-expected.txt": [ - "377c7296a781adb8ce5792cda50a4ded28472339", - [] - ], - "fenced-frame-bypass.tentative.https.window-expected.txt": [ - "dc538e12907885d23b2fa5b3a6f9c6364b88fdc4", - [] - ], - "fenced-frame.tentative.https.window-expected.txt": [ - "dc538e12907885d23b2fa5b3a6f9c6364b88fdc4", - [] - ], - "require-corp-embed-anonymous-iframe.tentative.https.window.js.headers": [ - "6604450991a122e3e241e40b1b9e0516c525389d", - [] - ], - "resources": { - "common.js": [ - "e83bd094670dd4a8541031c4a66d738045484dc1", - [] - ], - "serviceworker-partitioning-helper.js": [ - "288ad5954e2d51c17c1088dac428927f63321bbf", - [] - ], - "sharedworker-partitioning-helper.js": [ - "8b416c33d72cf55f080e1a1011bdb45718c8f258", - [] - ] - } - }, "blob.https.html.headers": [ "6604450991a122e3e241e40b1b9e0516c525389d", [] @@ -308039,7 +308125,7 @@ [] ], "multiple-early-hints-responses.h2.py": [ - "70f2476016cf4715d7ec36b8ac136e6f6b4c3676", + "3cc221abf23a452ac7abb35fc23bdebcdaedcb6b", [] ], "multiple-early-hints-responses.html": [ @@ -310521,6 +310607,10 @@ }, "return-value": { "resources": { + "204-205-download-on-second-visit.py": [ + "c18b0dec3dc6adc4a95b7b18bbe0f369d0dbcc7a", + [] + ], "back-forward-opaque-origin-page.html": [ "ec633639524aaa04917eb38505e47a59d9686e24", [] @@ -310543,7 +310633,7 @@ ], "resources": { "helpers.mjs": [ - "359774de4f72c4c0bcb19ff33081ab7325b1756a", + "341befc10565d0759fd517258b2a6883fe6d564a", [] ], "notify-top-early.html": [ @@ -315120,7 +315210,7 @@ ], "support": { "testcases.sub.js": [ - "9b75105de8b05909f5fb514f1874f29ee196c3f1", + "e0efa1c67c46deee7cc2cc24d2c157a02fbaa672", [] ] } @@ -325674,6 +325764,10 @@ "8070938baf26dbd0bfdc46ef60082cfbb30f5a8e", [] ], + "localstorage-about-blank-3P-iframe-opens-3P-window.partitioned.tentative-expected.txt": [ + "61813b8d683ba40dbd4b37a6cd3c9d3e33f2f12a", + [] + ], "localstorage-basic-partitioned.tentative.sub-expected.txt": [ "6cdbef6d2703cfeef2f7f24033335411cfa27aae", [] @@ -325703,10 +325797,18 @@ "7451594c898c40dbe7ddb14eee81469db3eab46d", [] ], - "localstorage-basic-partitioned-iframe.html": [ + "localstorage-about-blank-partitioned-iframe.html": [ "5cb2c4f7e2effae73ff52427d03c1a2c7243b2e4", [] ], + "localstorage-about-blank-partitioned-win-open.html": [ + "90d3a4309ec32596faa2084c91b21915d0c798a9", + [] + ], + "partitioning-utils.js": [ + "9d9e0b8ac5ccdff2fd4358766fa219979b1ad589", + [] + ], "session_change_item_iframe.html": [ "1e1867e51ec8b0cfc9a0d5053a942921c80c063a", [] @@ -328802,10 +328904,6 @@ [] ] }, - "opaque-origin-expected.txt": [ - "d912a280011abd9cc377d991b6c477d0866ef487", - [] - ], "postMessage_block.https.html.headers": [ "63b60e490f47f4db77d33d7a4ca2f5b9a4181de8", [] @@ -351845,86 +351943,107 @@ }, "compute-pressure": { "compute_pressure_arguments.tentative.https.window.js": [ - "515c9d72423b93f4f76ea32a3b94e0f89d540889", + "4b14fd0add8cf05757dfae107637015dd6f643cb", [ "compute-pressure/compute_pressure_arguments.tentative.https.window.html", {} ] ], "compute_pressure_basic.tentative.https.window.js": [ - "dac1dabee0fa40f5402ef02a3065a6ff434904b7", + "2cdd36e0183644b0e4967c77e4d1f392a66577de", [ "compute-pressure/compute_pressure_basic.tentative.https.window.html", {} ] ], - "compute_pressure_detached_iframe.tenative.https.html": [ - "be0b9380c35e430e84f00ab7ba9401199e8f6e2c", + "compute_pressure_detached_iframe.tentative.https.html": [ + "4ebb1ca4a59feda2745bf0834dadd27c29180f25", [ null, {} ] ], "compute_pressure_different_quantizations.tentative.https.window.js": [ - "6f1d6d8784187dbf3066e676ad9915b37a29530f", + "923a4b6890b9399f51a50c7c9d3aae2c1f74948c", [ "compute-pressure/compute_pressure_different_quantizations.tentative.https.window.html", {} ] ], "compute_pressure_different_quantizations_across_iframes.tentative.https.window.js": [ - "e0429b2d04fb6d25294d2fe3b06919135ce75eb2", + "b0bd879d1f4e1c1658e7f4642ca1246f324963c4", [ "compute-pressure/compute_pressure_different_quantizations_across_iframes.tentative.https.window.html", {} ] ], + "compute_pressure_disconnect.tentative.https.window.js": [ + "1abecf313558c9268089a9ccd7417169773237c4", + [ + "compute-pressure/compute_pressure_disconnect.tentative.https.window.html", + {} + ] + ], + "compute_pressure_disconnect_idempotent.tentative.https.window.js": [ + "766f8a90ccec20d3114293190df2361679b8725b", + [ + "compute-pressure/compute_pressure_disconnect_idempotent.tentative.https.window.html", + {} + ] + ], + "compute_pressure_disconnect_immediately.tentative.https.window.js": [ + "766f8a90ccec20d3114293190df2361679b8725b", + [ + "compute-pressure/compute_pressure_disconnect_immediately.tentative.https.window.html", + {} + ] + ], "compute_pressure_multiple.tentative.https.window.js": [ - "d1650cb873765e93ceff3b48448c8e3bf17ea3ee", + "25961893722831722feca91cd00806a3d937a789", [ "compute-pressure/compute_pressure_multiple.tentative.https.window.html", {} ] ], "compute_pressure_multiple_across_iframes.tentative.https.window.js": [ - "5a020ad8a0cc55326e618879c032da3ef3625954", + "1e00c9f7e037a39f5e1404939e10e3c50d2636ba", [ "compute-pressure/compute_pressure_multiple_across_iframes.tentative.https.window.html", {} ] ], "compute_pressure_observe_idempotent.tentative.https.window.js": [ - "773512f4be5cdadba59150be842929ef45885c92", + "b4e87dbfb270a654ab7c99d7a0f94b4f330f9e91", [ "compute-pressure/compute_pressure_observe_idempotent.tentative.https.window.html", {} ] ], - "compute_pressure_stop.tentative.https.window.js": [ - "5dbd50574692a95faab5286eba10cc5e8f1a4476", + "compute_pressure_observe_unobserve_failure.tentative.https.window.js": [ + "26d8c962122614f67ede751f0bfa3b77d5907714", [ - "compute-pressure/compute_pressure_stop.tentative.https.window.html", + "compute-pressure/compute_pressure_observe_unobserve_failure.tentative.https.window.html", {} ] ], - "compute_pressure_stop_idempotent.tentative.https.window.js": [ - "785c55be4dc0cc2b18563e3e5732e5f0652c5cfb", + "compute_pressure_supported_sources.tentative.https.window.js": [ + "692a92c52db3ad119b3f143d1d822ae1ea9cd6f1", [ - "compute-pressure/compute_pressure_stop_idempotent.tentative.https.window.html", + "compute-pressure/compute_pressure_supported_sources.tentative.https.window.html", {} ] ], - "compute_pressure_stop_immediately.tentative.https.window.js": [ - "0d9929c47a9cbeb645ab1e30c0610d3a505e7075", + "compute_pressure_take_records.tentative.https.window.js": [ + "fdd21592d26c2e2ce8d6aa2e36a017e231af73a4", [ - "compute-pressure/compute_pressure_stop_immediately.tentative.https.window.html", + "compute-pressure/compute_pressure_take_records.tentative.https.window.html", {} ] ], - "compute_pressure_values.tenative.https.window.js": [ - "837fa9d62df5805892f8db0c2cf1ff9742bde72c", + "compute_pressure_values.tentative.https.window.js": [ + "ebe384a5ad4cb7abefa829005da6d3b8cfa99595", [ - "compute-pressure/compute_pressure_values.tenative.https.window.html", + "compute-pressure/compute_pressure_values.tentative.https.window.html", {} ] ] @@ -364087,7 +364206,7 @@ ] ], "system-color-consistency.html": [ - "5c5cc796f6c0aca80a09ef10fda6fcedf4fff4a6", + "34570ede7ebf22f50c8171e66657bf7d1d4e298a", [ null, {} @@ -364549,6 +364668,13 @@ {} ] ], + "idlharness.html": [ + "4e329644aff7ea2e47344fea9d059980132b73ee", + [ + null, + {} + ] + ], "iframe-invalidation.html": [ "51f2be9cfa3375af7ace46c9490612bf9daa5382", [ @@ -424035,14 +424161,14 @@ ] ], "getCurrentPosition_TypeError.https.html": [ - "953efb259bf931bce9c45e126a9938b0f0cbdafd", + "9da8ac1d29247d981171946747b17f4d60fe0f4b", [ null, {} ] ], "getCurrentPosition_permission_allow.https.html": [ - "4ecb64324e9baa721b649193e00f6f4d74a6e269", + "102b8b4d11ea6d609de4e6f5e7be4b6ae370a425", [ null, { @@ -424109,7 +424235,7 @@ ] ], "watchPosition_TypeError.https.html": [ - "64f0616949f3c00ed0d24f7d34f173c69e8e65d6", + "4ae7a8903716dd792337de245fd85b313456611a", [ null, {} @@ -424494,6 +424620,306 @@ ] }, "html": { + "anonymous-iframe": { + "anonymous-iframe-popup.tentative.https.window.js": [ + "66ca0bf2938fcfbdc18a25317611dda63b1614a2", + [ + "html/anonymous-iframe/anonymous-iframe-popup.tentative.https.window.html", + { + "script_metadata": [ + [ + "timeout", + "long" + ], + [ + "script", + "/common/get-host-info.sub.js" + ], + [ + "script", + "/common/utils.js" + ], + [ + "script", + "/common/dispatcher/dispatcher.js" + ], + [ + "script", + "/html/cross-origin-embedder-policy/credentialless/resources/common.js" + ] + ], + "timeout": "long" + } + ] + ], + "cookie-store.tentative.https.window.js": [ + "5338c8551f01e1e8d7f472609fb958ad79864b23", + [ + "html/anonymous-iframe/cookie-store.tentative.https.window.html", + { + "script_metadata": [ + [ + "timeout", + "long" + ], + [ + "script", + "/common/get-host-info.sub.js" + ], + [ + "script", + "/common/utils.js" + ], + [ + "script", + "/common/dispatcher/dispatcher.js" + ], + [ + "script", + "/html/cross-origin-embedder-policy/credentialless/resources/common.js" + ], + [ + "script", + "./resources/common.js" + ] + ], + "timeout": "long" + } + ] + ], + "cookie.tentative.https.window.js": [ + "18d8f4b492d3d98ffa8ac3927889cd61b603111a", + [ + "html/anonymous-iframe/cookie.tentative.https.window.html", + { + "script_metadata": [ + [ + "script", + "/common/get-host-info.sub.js" + ], + [ + "script", + "/common/utils.js" + ], + [ + "script", + "/common/dispatcher/dispatcher.js" + ], + [ + "script", + "/html/cross-origin-embedder-policy/credentialless/resources/common.js" + ], + [ + "script", + "./resources/common.js" + ] + ] + } + ] + ], + "fenced-frame-bypass.tentative.https.window.js": [ + "6cfd2c34d19d52d8a59ef7b95746be593ad7e0d3", + [ + "html/anonymous-iframe/fenced-frame-bypass.tentative.https.window.html", + { + "script_metadata": [ + [ + "script", + "/common/get-host-info.sub.js" + ], + [ + "script", + "/common/utils.js" + ], + [ + "script", + "/common/dispatcher/dispatcher.js" + ], + [ + "script", + "/html/cross-origin-embedder-policy/credentialless/resources/common.js" + ], + [ + "script", + "./resources/common.js" + ], + [ + "timeout", + "long" + ] + ], + "timeout": "long" + } + ] + ], + "fenced-frame.tentative.https.window.js": [ + "552036ec1c135fd0c9c54900c5d226813683a9b7", + [ + "html/anonymous-iframe/fenced-frame.tentative.https.window.html", + { + "script_metadata": [ + [ + "script", + "/common/get-host-info.sub.js" + ], + [ + "script", + "/common/utils.js" + ], + [ + "script", + "/common/dispatcher/dispatcher.js" + ], + [ + "script", + "/html/cross-origin-embedder-policy/credentialless/resources/common.js" + ], + [ + "script", + "./resources/common.js" + ], + [ + "timeout", + "long" + ] + ], + "timeout": "long" + } + ] + ], + "local-storage.tentative.https.window.js": [ + "4ccb4c2eb12bb9e485d5a5b6e92bb130ec208756", + [ + "html/anonymous-iframe/local-storage.tentative.https.window.html", + { + "script_metadata": [ + [ + "script", + "/common/get-host-info.sub.js" + ], + [ + "script", + "/common/utils.js" + ], + [ + "script", + "/common/dispatcher/dispatcher.js" + ], + [ + "script", + "/html/cross-origin-embedder-policy/credentialless/resources/common.js" + ], + [ + "script", + "./resources/common.js" + ] + ] + } + ] + ], + "require-corp-embed-anonymous-iframe.tentative.https.window.js": [ + "d720008ccc744715b80784a7d2a7fc4aa38c1882", + [ + "html/anonymous-iframe/require-corp-embed-anonymous-iframe.tentative.https.window.html", + { + "script_metadata": [ + [ + "script", + "/common/utils.js" + ] + ] + } + ] + ], + "serviceworker-partitioning.tentative.https.window.js": [ + "dd78195a3c8ba9d2b8b84b14d89dd04de166c2ea", + [ + "html/anonymous-iframe/serviceworker-partitioning.tentative.https.window.html", + { + "script_metadata": [ + [ + "script", + "/common/utils.js" + ] + ] + } + ] + ], + "session-storage.tentative.https.window.js": [ + "5af2dc2b3bdf1957ef5cfafb25c8c54d66c425a2", + [ + "html/anonymous-iframe/session-storage.tentative.https.window.html", + { + "script_metadata": [ + [ + "script", + "/common/get-host-info.sub.js" + ], + [ + "script", + "/common/utils.js" + ], + [ + "script", + "/common/dispatcher/dispatcher.js" + ], + [ + "script", + "/html/cross-origin-embedder-policy/credentialless/resources/common.js" + ], + [ + "script", + "./resources/common.js" + ] + ] + } + ] + ], + "sharedworker-partitioning.tentative.https.window.js": [ + "a6eb551759d865059064fcfa43fdd6519a6b05f1", + [ + "html/anonymous-iframe/sharedworker-partitioning.tentative.https.window.html", + { + "script_metadata": [ + [ + "script", + "/common/utils.js" + ] + ] + } + ] + ], + "web-lock.tentative.https.window.js": [ + "ed1da0b9ad710696b530b3de3a6c12cbf15a7b15", + [ + "html/anonymous-iframe/web-lock.tentative.https.window.html", + { + "script_metadata": [ + [ + "script", + "/common/get-host-info.sub.js" + ], + [ + "script", + "/common/utils.js" + ], + [ + "script", + "/common/dispatcher/dispatcher.js" + ], + [ + "script", + "/html/cross-origin-embedder-policy/credentialless/resources/common.js" + ], + [ + "script", + "./resources/common.js" + ] + ] + } + ] + ] + }, "browsers": { "browsing-the-web": { "back-forward-cache": { @@ -447919,306 +448345,6 @@ {} ] ], - "anonymous-iframe": { - "anonymous-iframe-popup.tentative.https.window.js": [ - "6e82aefc65bc048dd552cd851db9f2276a8e5ed0", - [ - "html/cross-origin-embedder-policy/anonymous-iframe/anonymous-iframe-popup.tentative.https.window.html", - { - "script_metadata": [ - [ - "timeout", - "long" - ], - [ - "script", - "/common/get-host-info.sub.js" - ], - [ - "script", - "/common/utils.js" - ], - [ - "script", - "/common/dispatcher/dispatcher.js" - ], - [ - "script", - "../credentialless/resources/common.js" - ] - ], - "timeout": "long" - } - ] - ], - "cookie-store.tentative.https.window.js": [ - "60a856c7584681d20d12b72dcd951cd4fd43e2a1", - [ - "html/cross-origin-embedder-policy/anonymous-iframe/cookie-store.tentative.https.window.html", - { - "script_metadata": [ - [ - "timeout", - "long" - ], - [ - "script", - "/common/get-host-info.sub.js" - ], - [ - "script", - "/common/utils.js" - ], - [ - "script", - "/common/dispatcher/dispatcher.js" - ], - [ - "script", - "../credentialless/resources/common.js" - ], - [ - "script", - "./resources/common.js" - ] - ], - "timeout": "long" - } - ] - ], - "cookie.tentative.https.window.js": [ - "e9921330dde11d5b985ae835e5b1464aa6ea8a96", - [ - "html/cross-origin-embedder-policy/anonymous-iframe/cookie.tentative.https.window.html", - { - "script_metadata": [ - [ - "script", - "/common/get-host-info.sub.js" - ], - [ - "script", - "/common/utils.js" - ], - [ - "script", - "/common/dispatcher/dispatcher.js" - ], - [ - "script", - "../credentialless/resources/common.js" - ], - [ - "script", - "./resources/common.js" - ] - ] - } - ] - ], - "fenced-frame-bypass.tentative.https.window.js": [ - "f2c3090750661536774e00794d25db5887b9cfcb", - [ - "html/cross-origin-embedder-policy/anonymous-iframe/fenced-frame-bypass.tentative.https.window.html", - { - "script_metadata": [ - [ - "script", - "/common/get-host-info.sub.js" - ], - [ - "script", - "/common/utils.js" - ], - [ - "script", - "/common/dispatcher/dispatcher.js" - ], - [ - "script", - "../credentialless/resources/common.js" - ], - [ - "script", - "./resources/common.js" - ], - [ - "timeout", - "long" - ] - ], - "timeout": "long" - } - ] - ], - "fenced-frame.tentative.https.window.js": [ - "8f6bfd35d761a69725f88efe484a31555c5d5b8a", - [ - "html/cross-origin-embedder-policy/anonymous-iframe/fenced-frame.tentative.https.window.html", - { - "script_metadata": [ - [ - "script", - "/common/get-host-info.sub.js" - ], - [ - "script", - "/common/utils.js" - ], - [ - "script", - "/common/dispatcher/dispatcher.js" - ], - [ - "script", - "../credentialless/resources/common.js" - ], - [ - "script", - "./resources/common.js" - ], - [ - "timeout", - "long" - ] - ], - "timeout": "long" - } - ] - ], - "local-storage.tentative.https.window.js": [ - "9ce8b0f00250e3231cf3013b975426d92cf56d5a", - [ - "html/cross-origin-embedder-policy/anonymous-iframe/local-storage.tentative.https.window.html", - { - "script_metadata": [ - [ - "script", - "/common/get-host-info.sub.js" - ], - [ - "script", - "/common/utils.js" - ], - [ - "script", - "/common/dispatcher/dispatcher.js" - ], - [ - "script", - "../credentialless/resources/common.js" - ], - [ - "script", - "./resources/common.js" - ] - ] - } - ] - ], - "require-corp-embed-anonymous-iframe.tentative.https.window.js": [ - "a62c7a9a2e04fa679c6338dad518f867456ab7a2", - [ - "html/cross-origin-embedder-policy/anonymous-iframe/require-corp-embed-anonymous-iframe.tentative.https.window.html", - { - "script_metadata": [ - [ - "script", - "/common/utils.js" - ] - ] - } - ] - ], - "serviceworker-partitioning.tentative.https.window.js": [ - "dd78195a3c8ba9d2b8b84b14d89dd04de166c2ea", - [ - "html/cross-origin-embedder-policy/anonymous-iframe/serviceworker-partitioning.tentative.https.window.html", - { - "script_metadata": [ - [ - "script", - "/common/utils.js" - ] - ] - } - ] - ], - "session-storage.tentative.https.window.js": [ - "418e17f018373af23b807963f45fa3a57b87b947", - [ - "html/cross-origin-embedder-policy/anonymous-iframe/session-storage.tentative.https.window.html", - { - "script_metadata": [ - [ - "script", - "/common/get-host-info.sub.js" - ], - [ - "script", - "/common/utils.js" - ], - [ - "script", - "/common/dispatcher/dispatcher.js" - ], - [ - "script", - "../credentialless/resources/common.js" - ], - [ - "script", - "./resources/common.js" - ] - ] - } - ] - ], - "sharedworker-partitioning.tentative.https.window.js": [ - "a6eb551759d865059064fcfa43fdd6519a6b05f1", - [ - "html/cross-origin-embedder-policy/anonymous-iframe/sharedworker-partitioning.tentative.https.window.html", - { - "script_metadata": [ - [ - "script", - "/common/utils.js" - ] - ] - } - ] - ], - "web-lock.tentative.https.window.js": [ - "fad21dfec9b901c6c48be3d28c22825bf43d37b2", - [ - "html/cross-origin-embedder-policy/anonymous-iframe/web-lock.tentative.https.window.html", - { - "script_metadata": [ - [ - "script", - "/common/get-host-info.sub.js" - ], - [ - "script", - "/common/utils.js" - ], - [ - "script", - "/common/dispatcher/dispatcher.js" - ], - [ - "script", - "../credentialless/resources/common.js" - ], - [ - "script", - "./resources/common.js" - ] - ] - } - ] - ] - }, "blob.https.html": [ "ce72f247ef7b6fc6b54196dbc47582b5118d54ca", [ @@ -474306,7 +474432,7 @@ ] ], "multiple-early-hints-responses.h2.window.js": [ - "24230c07f503a2145ddccc575526426e9dd40e51", + "2aba051ead3a6ae3c856b11dd86db3275cc96044", [ "loading/early-hints/multiple-early-hints-responses.h2.window.html", { @@ -483084,6 +483210,13 @@ ] ], "return-value": { + "back-204-205-download.html": [ + "5bedbf21e8681250fede0c573c80985eea44d292", + [ + null, + {} + ] + ], "back-already-detached.html": [ "f9ff04f923c80b3d224a11c155f87f391ad1fe2d", [ @@ -483175,6 +483308,13 @@ {} ] ], + "navigate-204-205-download.html": [ + "f1e89b694057aae8c0ae2bff7f4ca8a9a08cf40f", + [ + null, + {} + ] + ], "navigate-already-detached.html": [ "33cdd6922d3f8eb90fde4cbf64cffd9c51d1fb8d", [ @@ -483682,6 +483822,13 @@ {} ] ], + "navigate-204-205-download-then-same-document.html": [ + "b7b6283fa70b9147c8c252a5fbba933448ad07d3", + [ + null, + {} + ] + ], "navigate-canceled.html": [ "2604a60e37bfc240e84df5c7bf02fda31425a303", [ @@ -483690,7 +483837,7 @@ ] ], "navigate-cross-document-double.html": [ - "353cfa1b4e4b5fbc98a1f5827024ab8e73b98058", + "147b8d55ef150e32493d0395df756a78a15a8018", [ null, {} @@ -536176,7 +536323,7 @@ ] ], "cross-partition.https.tentative.html": [ - "163e6c00a93a95364a044aa7c8f01e5d4b5a4fd5", + "97ae55b6b9ec80dfb25dd6330930db8fd3361764", [ null, {} @@ -550748,8 +550895,15 @@ } ] ], + "localstorage-about-blank-3P-iframe-opens-3P-window.partitioned.tentative.html": [ + "de94fb2cf435de13665e5d7aa0abc0ac2fcc035d", + [ + null, + {} + ] + ], "localstorage-basic-partitioned.tentative.sub.html": [ - "39209eaea97bcf2bd966e8d17951f632755c54fa", + "7ed49b1e9a0eb5f576a61674332ebb92611561e8", [ null, {}
diff --git a/third_party/blink/web_tests/external/wpt/css/css-contain/container-queries/at-container-serialization.html b/third_party/blink/web_tests/external/wpt/css/css-contain/container-queries/at-container-serialization.html new file mode 100644 index 0000000..758a7c3 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-contain/container-queries/at-container-serialization.html
@@ -0,0 +1,37 @@ +<!doctype html> +<title>CSS Container Queries: @container serialization</title> +<link rel="help" href="https://drafts.csswg.org/css-contain-3/#container-queries"> +<link rel="help" href="https://drafts.csswg.org/cssom/#serialize-a-css-rule"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/cq-testcommon.js"></script> +<style id="testSheet"> + @container (width=100px) { + @container \!-name (inline-size > 200px ) { + #id { color: lime } + } + #id { color: green } + } +</style> +<script> + setup(() => assert_implements_container_queries()); + + let rules = testSheet.sheet.cssRules; + + test(() => { + assert_equals(rules.length, 1); + assert_equals(rules[0].cssRules.length, 2); + + assert_equals(rules[0].conditionText, "(width = 100px)"); + assert_equals(rules[0].cssRules[0].conditionText, "(inline-size > 200px)"); + }, "Serialization of conditionText"); + + test(() => { + assert_equals(rules[0].cssRules[0].cssText, "@container \\!-name (inline-size > 200px) {\n #id { color: lime; }\n}"); + }, "Serialization of inner @container rule"); + + test(() => { + assert_equals(rules[0].cssText, "@container (width = 100px) {\n @container \\!-name (inline-size > 200px) {\n #id { color: lime; }\n}\n #id { color: green; }\n}"); + }, "Serialization of nested @container rule"); + +</script>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-contain/container-queries/container-name-computed.html b/third_party/blink/web_tests/external/wpt/css/css-contain/container-queries/container-name-computed.html index 8d88987..94e1737 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-contain/container-queries/container-name-computed.html +++ b/third_party/blink/web_tests/external/wpt/css/css-contain/container-queries/container-name-computed.html
@@ -19,4 +19,5 @@ test_computed_value('container-name', 'foo foo bar', 'foo bar'); test_computed_value('container-name', 'foo bar foo', 'foo bar'); test_computed_value('container-name', 'bar foo foo', 'bar foo'); +test_computed_value('container-name', '\\!escaped'); </script>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-contain/container-queries/container-name-parsing.html b/third_party/blink/web_tests/external/wpt/css/css-contain/container-queries/container-name-parsing.html index d4737ce..3e0ea059 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-contain/container-queries/container-name-parsing.html +++ b/third_party/blink/web_tests/external/wpt/css/css-contain/container-queries/container-name-parsing.html
@@ -19,6 +19,7 @@ test_valid_value('container-name', 'BAR'); test_valid_value('container-name', 'foo bar'); test_valid_value('container-name', 'foo foo'); +test_valid_value('container-name', '\\!escaped'); test_invalid_value('container-name', 'none none'); test_invalid_value('container-name', 'foo, bar');
diff --git a/third_party/blink/web_tests/external/wpt/css/css-contain/container-queries/idlharness.html b/third_party/blink/web_tests/external/wpt/css/css-contain/container-queries/idlharness.html index 4e32964..ac1a677 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-contain/container-queries/idlharness.html +++ b/third_party/blink/web_tests/external/wpt/css/css-contain/container-queries/idlharness.html
@@ -7,8 +7,8 @@ <script src="/resources/idlharness.js"></script> <!-- used to provide objects --> <style> - @container size(width=100px) { - @container size( inline-size >200% ) { + @container cont (width = 100px) { + @container (inline-size > 200em) { #id { color: lime } } #id { color: green }
diff --git a/third_party/blink/web_tests/external/wpt/css/css-overflow/overflow-body-propagation-010.html b/third_party/blink/web_tests/external/wpt/css/css-overflow/overflow-body-propagation-010.html index 7a9966c..a3fcdaf 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-overflow/overflow-body-propagation-010.html +++ b/third_party/blink/web_tests/external/wpt/css/css-overflow/overflow-body-propagation-010.html
@@ -7,7 +7,6 @@ <link rel="match" href="overflow-body-propagation-010-ref.html"> <style> body { - overflow: -moz-hidden-unscrollable; /* will be removed in bug 1531609 */ overflow: clip; contain: paint; width: 30px;
diff --git a/third_party/blink/web_tests/external/wpt/css/css-shapes/shape-outside/supported-shapes/inset/shape-outside-inset-031.html b/third_party/blink/web_tests/external/wpt/css/css-shapes/shape-outside/supported-shapes/inset/shape-outside-inset-031.html index dc2938d..8d323b0 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-shapes/shape-outside/supported-shapes/inset/shape-outside-inset-031.html +++ b/third_party/blink/web_tests/external/wpt/css/css-shapes/shape-outside/supported-shapes/inset/shape-outside-inset-031.html
@@ -8,7 +8,7 @@ <link rel="help" href="http://www.w3.org/TR/css-shapes-1/#shape-margin-property"> <link rel="match" href="reference/shape-outside-inset-010-ref.html"/> <meta name="flags" content="ahem" /> - <meta name="assert" content="The test verfies a shape with rectagular inset and + <meta name="assert" content="The test verifies a shape with rectangular inset and shape-margin has rounded corners."> <link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> </head>
diff --git a/third_party/blink/web_tests/external/wpt/docs/running-tests/chrome-chromium-installation-detection.md b/third_party/blink/web_tests/external/wpt/docs/running-tests/chrome-chromium-installation-detection.md new file mode 100644 index 0000000..63fcd868 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/docs/running-tests/chrome-chromium-installation-detection.md
@@ -0,0 +1,96 @@ +# Detection and Installation of Browser and WebDriver Binaries and for Chrome and Chromium + +This is a detailed description of the process in which WPT detects and installs the browser +components for Chrome and Chromium. This process can seem convoluted and difficult to +understand at first glance, but the reason for this process is to best ensure these components +are compatible with each other and are the intended items that the user is trying to test. + +## Chrome + +### Detection +**Browser**: Because WPT does not offer installation of Chrome browser binaries, it will +not attempt to detect a Chrome browser binary in the virtual environment directory. +Instead, commonly-used installation locations on various operating systems are checked to +detect a valid Chrome binary. This detection process is only used if the user has not passed +a binary path as an argument using the `--binary` flag. + +**WebDriver**: ChromeDriver detection for Chrome will only occur if a valid browser binary +has been found. Once the browser binary version is detected, the virtual environment +directory will be checked to see if a matching ChromeDriver version is already installed. +If the browser and ChromeDriver versions do not match, the ChromeDriver binary will be +removed from the directory and the user will be prompted to begin the webdriver installation +process. A ChromeDriver version is considered matching the browser version if ChromeDriver shares +the same major version, or next major version when testing Chrome Dev. For example, Chrome 98.x.x.x +is considered to match ChromeDriver version 98.x.x.x, or also ChromeDriver 99.x.x.x if testing +Chrome Dev. + +Note: Both Chrome and Chromium’s versions of ChromeDriver are stored in separate +directories in the virtual environment directory i.e +`_venv3/bin/{chrome|chromium}/{chromedriver}`. This safeguards from accidentally +using Chromium’s ChromeDriver for a Chrome run and vice versa. Additionally, there +is no need to reinstall ChromeDriver versions if switching between testing Chrome and Chromium. + +### Installation +**Browser**: Browser binary installation is not provided through WPT and will throw a +`NotImplementedError` if attempted via `./wpt install`. The user will need to +have a browser binary on their system that can be detected or provide a path explicitly +using the `--binary` flag. + +**WebDriver**: A version of ChromeDriver will only be installed once a Chrome browser binary +has been given or detected. A `FileNotFoundError` will be raised if the user tries to download +ChromeDriver via `./wpt install` and a browser binary is not located. After browser binary +detection, a version of ChromeDriver that matches the browser binary will be installed. +The download source for this ChromeDriver is +[described here](https://chromedriver.chromium.org/downloads/version-selection). +If a matching ChromeDriver version cannot be found using this process, it is assumed that +the Chrome browser binary is a dev version which does not have a ChromeDriver version available +through official releases. In this case, the Chromium revision associated with this version is +detected from [OmahaProxy](https://omahaproxy.appspot.com/) and used to download +Chromium's version of ChromeDriver for use from Chromium snapshots, as this is currently +the closest version we can match for Chrome Dev. Finally, if the revision number detected is +not available in Chromium snapshots, or if the version does not match any revision number, +the latest revision of Chromium's ChromeDriver is installed from Chromium snapshots. + +## Chromium + +### Detection +**Browser**: Chromium browser binary detection is only done in the virtual +environment directory `_venv3/browsers/{channel}/`, not on the user’s system +outside of this directory. This detection process is only used if the user has +not passed a binary path as an argument using the `--binary` flag. + +**WebDriver**: ChromeDriver detection for Chromium will only occur if a valid browser binary has +been found. Once the browser binary version is detected, the virtual environment directory will +be checked to see if a matching ChromeDriver version is already installed. If the versions do not +match, the ChromeDriver binary will be removed from the directory and the user will be prompted to +begin the webdriver installation process. For Chromium, the ChromeDriver and browser versions must be +the same to be considered matching. For example, Chromium 99.0.4844.74 will only match ChromeDriver +99.0.4844.74. + +### Installation +**Browser**: Chromium’s browser binary will be installed from +[Chromium snapshots storage](https://storage.googleapis.com/chromium-browser-snapshots/index.html). +The last revision associated with the user’s operating system will be downloaded +(this revision is obtained by the LAST_CHANGE designation from the snapshots bucket). +Chromium does not have varying channels, so the installation uses the default `nightly` +designation. The install path is `_venv3/browsers/nightly/{chromium_binary}`. + +Note: If this download process is successful, the Chromium snapshot URL that the browser +binary was downloaded from will be kept during the current invocation. If a Chromium ChromeDriver +is also downloaded later to match this browser binary, the same URL is used for that download to +ensure both components are downloaded from the same source. + +**WebDriver**: A version of ChromeDriver will only be installed once a Chromium browser binary +has been given or detected. A FileNotFoundError will be raised if the user tries to download +ChromeDriver via the install command and a browser binary is not located. A version of +ChromeDriver that matches the version of the browser binary will be installed. The download +source for this ChromeDriver will be the Chromium snapshots. If a Chromium browser +binary and webdriver are installed in the same invocation of `./wpt run` +(for example, by passing both `--install-browser` and `--install-webdriver` flags), then the +browser binary and ChromeDriver will be pulled from the same Chromium snapshots URL (see Note +from browser installation). Although unusual, if a Chromium browser binary is detected and +it is not the tip-of-tree revision and the browser binary was not downloaded and installed +during this invocation of `./wpt run` and the currently installed ChromeDriver version does +not match the browser version, then an attempt will be made to detect the revision number from +the browser binary version using the [OmahaProxy](https://omahaproxy.appspot.com/) +and download the matching ChromeDriver using this revision number from Chromium snapshots.
diff --git a/third_party/blink/web_tests/external/wpt/docs/running-tests/chrome.md b/third_party/blink/web_tests/external/wpt/docs/running-tests/chrome.md index 0c07b6f..45293af6 100644 --- a/third_party/blink/web_tests/external/wpt/docs/running-tests/chrome.md +++ b/third_party/blink/web_tests/external/wpt/docs/running-tests/chrome.md
@@ -1,4 +1,4 @@ -# Chrome +# Chrome and Chromium When running Chrome, there are some useful command line arguments. @@ -27,4 +27,7 @@ ./wpt run --binary-arg=--enable-blink-features=AsyncClipboard chrome clipboard-apis/ ``` +[A detailed explanation is available](running-tests/chrome-chromium-installation-detection.html) +for more information on how wpt detects and installs the components for Chrome and Chromium. + [1]: https://chromium.googlesource.com/chromium/src/+/main/third_party/blink/renderer/platform/RuntimeEnabledFeatures.md
diff --git a/third_party/blink/web_tests/external/wpt/geolocation-API/getCurrentPosition_TypeError.https.html b/third_party/blink/web_tests/external/wpt/geolocation-API/getCurrentPosition_TypeError.https.html index 953efb2..9da8ac1 100644 --- a/third_party/blink/web_tests/external/wpt/geolocation-API/getCurrentPosition_TypeError.https.html +++ b/third_party/blink/web_tests/external/wpt/geolocation-API/getCurrentPosition_TypeError.https.html
@@ -47,4 +47,15 @@ navigator.geolocation.getCurrentPosition(()=>{}, ()=>{}, 4); }); }, 'Call getCurrentPosition() with wrong type for third argument. Exception expected.'); + +test(function () { + const handleEvent = ()=>{}; + assert_throws_js(TypeError, function () { + navigator.geolocation.getCurrentPosition({ handleEvent }); + }); + + assert_throws_js(TypeError, function () { + navigator.geolocation.getCurrentPosition(()=>{}, { handleEvent }); + }); +}, "Calling getCurrentPosition() with a legacy event handler objects."); </script>
diff --git a/third_party/blink/web_tests/external/wpt/geolocation-API/getCurrentPosition_permission_allow.https.html b/third_party/blink/web_tests/external/wpt/geolocation-API/getCurrentPosition_permission_allow.https.html index 4ecb643..102b8b4 100644 --- a/third_party/blink/web_tests/external/wpt/geolocation-API/getCurrentPosition_permission_allow.https.html +++ b/third_party/blink/web_tests/external/wpt/geolocation-API/getCurrentPosition_permission_allow.https.html
@@ -31,4 +31,22 @@ "Expected GeolocationPosition" ); }, "User allows access, check that success callback is called."); + + promise_test(async (t) => { + t.add_cleanup(() => { + return test_driver.set_permission({ name: "geolocation" }, "prompt"); + }); + await test_driver.set_permission({ name: "geolocation" }, "granted"); + const position = await new Promise((resolve, reject) => { + try { + navigator.geolocation.getCurrentPosition(resolve, null); + } catch (err) { + reject(err); + } + }); + assert_true( + position instanceof GeolocationPosition, + "Expected GeolocationPosition" + ); + }, "Error callback is nullable for getCurrentPosition()."); </script>
diff --git a/third_party/blink/web_tests/external/wpt/geolocation-API/watchPosition_TypeError.https.html b/third_party/blink/web_tests/external/wpt/geolocation-API/watchPosition_TypeError.https.html index 64f0616..4ae7a89 100644 --- a/third_party/blink/web_tests/external/wpt/geolocation-API/watchPosition_TypeError.https.html +++ b/third_party/blink/web_tests/external/wpt/geolocation-API/watchPosition_TypeError.https.html
@@ -51,4 +51,15 @@ ); }); }, "Call watchPosition() with wrong type for third argument. Exception expected."); + + test(function () { + const handleEvent = function(){}; + assert_throws_js(TypeError, function () { + navigator.geolocation.watchPosition({ handleEvent }); + }); + + assert_throws_js(TypeError, function () { + navigator.geolocation.watchPosition(()=>{}, { handleEvent }); + }); + }, "Calling watchPosition() with a legacy event handler object."); </script>
diff --git a/third_party/blink/web_tests/external/wpt/loading/early-hints/multiple-early-hints-responses.h2.window.js b/third_party/blink/web_tests/external/wpt/loading/early-hints/multiple-early-hints-responses.h2.window.js index 24230c07..2aba051 100644 --- a/third_party/blink/web_tests/external/wpt/loading/early-hints/multiple-early-hints-responses.h2.window.js +++ b/third_party/blink/web_tests/external/wpt/loading/early-hints/multiple-early-hints-responses.h2.window.js
@@ -4,7 +4,8 @@ test(() => { const params = new URLSearchParams(); params.set("first-preload", SAME_ORIGIN_RESOURCES_URL + "/empty.js?" + token()); - params.set("second-preload", SAME_ORIGIN_RESOURCES_URL + "/empty.js?" + token()); + params.set("second-preload", CROSS_ORIGIN_RESOURCES_URL + "/empty.js?" + token()); + params.set("second-preload-origin", CROSS_ORIGIN); const test_url = "resources/multiple-early-hints-responses.h2.py?" + params.toString(); window.location.replace(new URL(test_url, window.location)); }); \ No newline at end of file
diff --git a/third_party/blink/web_tests/external/wpt/loading/early-hints/preload-in-flight-when-consumed.h2.window.js b/third_party/blink/web_tests/external/wpt/loading/early-hints/preload-in-flight-when-consumed.h2.window.js new file mode 100644 index 0000000..beaa45e2 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/loading/early-hints/preload-in-flight-when-consumed.h2.window.js
@@ -0,0 +1,11 @@ +// META: script=/common/utils.js +// META: script=resources/early-hints-helpers.sub.js + +test(() => { + const params = new URLSearchParams(); + const id = token(); + params.set("resource-url", SAME_ORIGIN_RESOURCES_URL + "/delayed-js.h2.py?id=" + id); + params.set("resource-id", id); + const test_url = "resources/preload-in-flight-when-consumed.h2.py?" + params.toString(); + window.location.replace(new URL(test_url, window.location)); +}); \ No newline at end of file
diff --git a/third_party/blink/web_tests/external/wpt/loading/early-hints/redirect-cross-origin-between-early-hints.h2.window.js b/third_party/blink/web_tests/external/wpt/loading/early-hints/redirect-cross-origin-between-early-hints.h2.window.js new file mode 100644 index 0000000..2ca92cf --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/loading/early-hints/redirect-cross-origin-between-early-hints.h2.window.js
@@ -0,0 +1,14 @@ +// META: script=/common/utils.js +// META: script=resources/early-hints-helpers.sub.js + +test(() => { + const params = new URLSearchParams(); + params.set("preload-before-redirect", SAME_ORIGIN_RESOURCES_URL + "/empty.js?" + token()); + params.set("preload-after-redirect", CROSS_ORIGIN_RESOURCES_URL + "/empty.js?" + token()); + params.set("redirect-url", CROSS_ORIGIN_RESOURCES_URL + "/redirect-between-early-hints.h2.py"); + params.set("final-test-page", "redirect-cross-origin-between-early-hints.html"); + + params.set("test-step", "redirect"); + const test_url = "resources/redirect-between-early-hints.h2.py?" + params.toString(); + window.location.replace(new URL(test_url, window.location)); +}); \ No newline at end of file
diff --git a/third_party/blink/web_tests/external/wpt/loading/early-hints/redirect-same-origin-between-early-hints.h2.window.js b/third_party/blink/web_tests/external/wpt/loading/early-hints/redirect-same-origin-between-early-hints.h2.window.js new file mode 100644 index 0000000..27630360 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/loading/early-hints/redirect-same-origin-between-early-hints.h2.window.js
@@ -0,0 +1,14 @@ +// META: script=/common/utils.js +// META: script=resources/early-hints-helpers.sub.js + +test(() => { + const params = new URLSearchParams(); + params.set("preload-before-redirect", SAME_ORIGIN_RESOURCES_URL + "/empty.js?" + token()); + params.set("preload-after-redirect", SAME_ORIGIN_RESOURCES_URL + "/empty.js?" + token()); + params.set("redirect-url", SAME_ORIGIN_RESOURCES_URL + "/redirect-between-early-hints.h2.py"); + params.set("final-test-page", "redirect-same-origin-between-early-hints.html"); + + params.set("test-step", "redirect"); + const test_url = "resources/redirect-between-early-hints.h2.py?" + params.toString(); + window.location.replace(new URL(test_url, window.location)); +}); \ No newline at end of file
diff --git a/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/delayed-js.h2.py b/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/delayed-js.h2.py new file mode 100644 index 0000000..b3d28e8 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/delayed-js.h2.py
@@ -0,0 +1,18 @@ +import time + + +def main(request, response): + id = request.GET.first(b"id") + url_dir = u'/'.join(request.url_parts.path.split(u'/')[:-1]) + u'/' + # Wait until the id is set via resume-delayed-js.h2.py. + while True: + if request.server.stash.take(id, url_dir): + break + time.sleep(0.1) + + headers = [ + ("Content-Type", "text/javascript"), + ("Cache-Control", "max-age=600"), + ] + body = "/*empty script*/" + return (200, "OK"), headers, body
diff --git a/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/multiple-early-hints-responses.h2.py b/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/multiple-early-hints-responses.h2.py index 70f2476..3cc221a 100644 --- a/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/multiple-early-hints-responses.h2.py +++ b/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/multiple-early-hints-responses.h2.py
@@ -8,6 +8,7 @@ link_header_value = "<{}>; rel=preload; as=script".format(first_preload) early_hints = [ (b":status", b"103"), + (b"content-security-policy", "script-src 'self' 'unsafe-inline'"), (b"link", link_header_value), ] response.writer.write_raw_header_frame(headers=early_hints, @@ -15,8 +16,11 @@ second_preload = request.GET.first(b"second-preload").decode() link_header_value = "<{}>; rel=preload; as=script".format(second_preload) + second_preload_origin = request.GET.first(b"second-preload-origin").decode() + csp_value = "script-src 'self' 'unsafe-inline' {}".format(second_preload_origin) early_hints = [ (b":status", b"103"), + (b"content-security-policy", csp_value), (b"link", link_header_value), ] response.writer.write_raw_header_frame(headers=early_hints,
diff --git a/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/preload-in-flight-when-consumed.h2.py b/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/preload-in-flight-when-consumed.h2.py new file mode 100644 index 0000000..c3d66160 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/preload-in-flight-when-consumed.h2.py
@@ -0,0 +1,24 @@ +import os + + +def handle_headers(frame, request, response): + resource_url = request.GET.first(b"resource-url").decode() + link_header_value = "<{}>; rel=preload; as=script".format(resource_url) + early_hints = [ + (b":status", b"103"), + (b"link", link_header_value), + ] + response.writer.write_raw_header_frame(headers=early_hints, + end_headers=True) + + response.status = 200 + response.headers[b"content-type"] = "text/html" + response.write_status_headers() + + +def main(request, response): + current_dir = os.path.dirname(os.path.realpath(__file__)) + file_path = os.path.join(current_dir, "preload-in-flight-when-consumed.html") + with open(file_path, "r") as f: + test_content = f.read() + response.writer.write_data(item=test_content, last=True)
diff --git a/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/preload-in-flight-when-consumed.html b/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/preload-in-flight-when-consumed.html new file mode 100644 index 0000000..5075d92 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/preload-in-flight-when-consumed.html
@@ -0,0 +1,19 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="early-hints-helpers.sub.js"></script> +<body> +<script> +promise_test(async (t) => { + const params = new URLSearchParams(window.location.search); + const resource_id = params.get("resource-id"); + const resource_url = params.get("resource-url"); + + const promise = fetchScript(resource_url); + await fetch("resume-delayed-js.h2.py?id=" + resource_id); + await promise; + assert_true(isPreloadedByEarlyHints(resource_url)); +}, "Early hints preload is in-flight when consumed."); +</script> +</body>
diff --git a/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/redirect-between-early-hints.h2.py b/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/redirect-between-early-hints.h2.py new file mode 100644 index 0000000..a1b3f15 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/redirect-between-early-hints.h2.py
@@ -0,0 +1,54 @@ +import os + + +def _send_early_hints(preload, writer): + link_header_value = "<{}>; rel=preload; as=script".format(preload) + early_hints = [ + (b":status", b"103"), + (b"link", link_header_value), + ] + writer.write_raw_header_frame(headers=early_hints, end_headers=True) + + +def handle_headers(frame, request, response): + step = request.GET.first(b"test-step").decode() + if step == "redirect": + preload = request.GET.first(b"preload-before-redirect").decode() + _send_early_hints(preload, response.writer) + + # Redirect to the final test page with parameters. + params = [] + for key, values in request.GET.items(): + if key == b"test-step": + params.append("test-step=final-response") + else: + params.append("{}={}".format(key.decode(), values[0].decode())) + + redirect_url = request.GET.first(b"redirect-url").decode() + location = "{}?{}".format(redirect_url, "&".join(params)) + + response.status = 302 + response.headers["location"] = location + response.write_status_headers() + elif step == "final-response": + preload = request.GET.first(b"preload-after-redirect").decode() + _send_early_hints(preload, response.writer) + + response.status = 200 + response.headers["content-type"] = "text/html" + response.write_status_headers() + else: + raise Exception("Invalid step: {}".format(step)) + + +def main(request, response): + step = request.GET.first(b"test-step").decode() + if step != "final-response": + return + + final_test_page = request.GET.first(b"final-test-page").decode() + current_dir = os.path.dirname(os.path.realpath(__file__)) + file_path = os.path.join(current_dir, final_test_page) + with open(file_path, "r") as f: + test_content = f.read() + response.writer.write_data(item=test_content, last=True)
diff --git a/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/redirect-cross-origin-between-early-hints.html b/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/redirect-cross-origin-between-early-hints.html new file mode 100644 index 0000000..46560bb --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/redirect-cross-origin-between-early-hints.html
@@ -0,0 +1,22 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="early-hints-helpers.sub.js"></script> +<body> +<script> +promise_test(async (t) => { + const params = new URLSearchParams(window.location.search); + + const preload_before_redirect = params.get("preload-before-redirect"); + await fetchScript(preload_before_redirect); + assert_false(isPreloadedByEarlyHints(preload_before_redirect), + "Early hints before cross origin redirect should not appear."); + + const preload_after_redirect = params.get("preload-after-redirect"); + await fetchScript(preload_after_redirect); + assert_true(isPreloadedByEarlyHints(preload_after_redirect), + "Early hints after cross origin redirect should preload."); +}, "Early hints -> cross origin redirect -> early hints -> final response."); +</script> +</body>
diff --git a/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/redirect-same-origin-between-early-hints.html b/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/redirect-same-origin-between-early-hints.html new file mode 100644 index 0000000..395f7f17 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/redirect-same-origin-between-early-hints.html
@@ -0,0 +1,22 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="early-hints-helpers.sub.js"></script> +<body> +<script> +promise_test(async (t) => { + const params = new URLSearchParams(window.location.search); + + const preload_before_redirect = params.get("preload-before-redirect"); + await fetchScript(preload_before_redirect); + assert_true(isPreloadedByEarlyHints(preload_before_redirect), + "Early hints before redirect should preload."); + + const preload_after_redirect = params.get("preload-after-redirect"); + await fetchScript(preload_after_redirect); + assert_false(isPreloadedByEarlyHints(preload_after_redirect), + "Early hints after same origin redirect should be ignored."); +}, "Early hints -> same origin redirect -> early hints -> final response."); +</script> +</body>
diff --git a/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/resume-delayed-js.h2.py b/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/resume-delayed-js.h2.py new file mode 100644 index 0000000..f1d9ab7 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/loading/early-hints/resources/resume-delayed-js.h2.py
@@ -0,0 +1,9 @@ +def main(request, response): + id = request.GET.first(b"id") + url_dir = u'/'.join(request.url_parts.path.split(u'/')[:-1]) + u'/' + request.server.stash.put(id, True, url_dir) + headers = [ + ("Content-Type", "text/plain"), + ] + body = "OK" + return (200, "OK"), headers, body
diff --git a/third_party/blink/web_tests/external/wpt/workers/opaque-origin-expected.txt b/third_party/blink/web_tests/external/wpt/workers/opaque-origin-expected.txt deleted file mode 100644 index d912a28..0000000 --- a/third_party/blink/web_tests/external/wpt/workers/opaque-origin-expected.txt +++ /dev/null
@@ -1,9 +0,0 @@ -This is a testharness.js-based test. -PASS Worker has an opaque origin. -PASS Worker can read its own blobs. -PASS Worker can read its owners blobs. -PASS Worker can XHR fetch a blob. -PASS Worker can fetch a blob. -FAIL Worker can access BroadcastChannel Failed to construct 'BroadcastChannel': Can't create BroadcastChannel in an opaque origin -Harness: the test ran to completion. -
diff --git a/third_party/blink/web_tests/http/tests/images/force-reload-image-document.html b/third_party/blink/web_tests/http/tests/images/force-reload-image-document.html index 9bdfa18..e9b4913 100644 --- a/third_party/blink/web_tests/http/tests/images/force-reload-image-document.html +++ b/third_party/blink/web_tests/http/tests/images/force-reload-image-document.html
@@ -11,7 +11,7 @@ var originalWidth = img.width; var originalHeight = img.height; - img.onerror = t.unreached_func(); + img.onerror = (message) => {assert_unreached(`onerror called: ${message}`)}; img.onload = t.step_func_done(function() { assert_not_equals(originalWidth, img.width, "Should be reloaded: width"); assert_not_equals(originalHeight, img.height, "Should be reloaded: height");
diff --git a/third_party/blink/web_tests/http/tests/images/force-reload.html b/third_party/blink/web_tests/http/tests/images/force-reload.html index e33b2d5..373ceffa 100644 --- a/third_party/blink/web_tests/http/tests/images/force-reload.html +++ b/third_party/blink/web_tests/http/tests/images/force-reload.html
@@ -8,7 +8,7 @@ var originalWidth = img.width; var originalHeight = img.height; - img.onerror = t.unreached_func(); + img.onerror = (message) => {assert_unreached(`onerror called: ${message}`)}; img.onload = t.step_func_done(function() { assert_not_equals(originalWidth, img.width, "Should be reloaded: width"); assert_not_equals(originalHeight, img.height, "Should be reloaded: height");
diff --git a/third_party/blink/web_tests/media/video-floated-controls-crash.html b/third_party/blink/web_tests/media/video-floated-controls-crash.html new file mode 100644 index 0000000..082aa67 --- /dev/null +++ b/third_party/blink/web_tests/media/video-floated-controls-crash.html
@@ -0,0 +1,18 @@ +<!DOCTYPE html> +<video width="200" height="200" controls src="whatever"></video> +<style></style> +<script src="../resources/testharness.js"></script> +<script src="../resources/testharnessreport.js"></script> +<script> + test(()=> { + document.body.offsetTop; + var sheet = document.styleSheets[0]; + sheet.insertRule("::-webkit-media-controls { float: left; }"); + + /* Trigger re-layout of something on the inside of the video AND something + on the outside. */ + document.body.offsetTop; + sheet.insertRule("::-webkit-media-controls-enclosure { width: 333px; }"); + document.body.style.width = "333px"; + }, "No crash"); +</script>
diff --git a/third_party/blink/web_tests/wpt_internal/digital-goods/digital-goods-interface.https.html b/third_party/blink/web_tests/wpt_internal/digital-goods/digital-goods-interface.https.html index 22067f5e..f65133cb 100644 --- a/third_party/blink/web_tests/wpt_internal/digital-goods/digital-goods-interface.https.html +++ b/third_party/blink/web_tests/wpt_internal/digital-goods/digital-goods-interface.https.html
@@ -192,6 +192,8 @@ assert_equals(response[1].purchaseToken, 'purchaseToken:1'); }, {title: 'ListPurchases round trip.'}); +// TODO (crbug.com/1250604): Add ListPurchaseHistory test with blink impl. + digital_goods_test(async service => { const response = await service.listPurchaseHistory(); assert_equals(response.length, 20);
diff --git a/third_party/breakpad/BUILD.gn b/third_party/breakpad/BUILD.gn index 48defa6e..1ff49cf4 100644 --- a/third_party/breakpad/BUILD.gn +++ b/third_party/breakpad/BUILD.gn
@@ -279,7 +279,7 @@ # Mac -------------------------------------------------------------------------- if (is_mac) { - if (current_toolchain == host_toolchain || target_os != "ios") { + if (current_toolchain == host_toolchain) { source_set("common") { sources = [ "breakpad/src/common/dwarf/bytereader.cc",
diff --git a/third_party/zlib/google/test/data/Mixed Paths.zip b/third_party/zlib/google/test/data/Mixed Paths.zip index 2af418b0..881f4985 100644 --- a/third_party/zlib/google/test/data/Mixed Paths.zip +++ b/third_party/zlib/google/test/data/Mixed Paths.zip Binary files differ
diff --git a/third_party/zlib/google/zip_reader.cc b/third_party/zlib/google/zip_reader.cc index b8143cd6..ff52f938 100644 --- a/third_party/zlib/google/zip_reader.cc +++ b/third_party/zlib/google/zip_reader.cc
@@ -59,6 +59,26 @@ #undef SWITCH_ERR } +bool IsValidFileNameCharacterOnWindows(char16_t c) { + if (c < 32) + return false; + + switch (c) { + case '<': // Less than + case '>': // Greater than + case ':': // Colon + case '"': // Double quote + case '|': // Vertical bar or pipe + case '?': // Question mark + case '*': // Asterisk + case '/': // Forward slash + case '\\': // Backslash + return false; + } + + return true; +} + // A writer delegate that writes to a given string. class StringWriterDelegate : public WriterDelegate { public: @@ -210,19 +230,11 @@ return false; } - entry_.path = base::FilePath::FromUTF16Unsafe(path_in_utf16); + // Normalize path. + Normalize(path_in_utf16); + entry_.original_size = info.uncompressed_size; - // Directory entries in ZIP have a path ending with "/". - entry_.is_directory = base::EndsWith(path_in_utf16, u"/"); - - // Check the entry path for directory traversal issues. We consider entry - // paths unsafe if they are absolute or if they contain "..". On Windows, - // IsAbsolute() returns false for paths starting with "/". - entry_.is_unsafe = entry_.path.ReferencesParent() || - entry_.path.IsAbsolute() || - base::StartsWith(path_in_utf16, u"/"); - // The file content of this entry is encrypted if flag bit 0 is set. entry_.is_encrypted = info.flag & 1; @@ -249,6 +261,73 @@ return true; } +void ZipReader::Normalize(base::StringPiece16 in) { + entry_.is_unsafe = true; + + // Directory entries in ZIP have a path ending with "/". + entry_.is_directory = base::EndsWith(in, u"/"); + + std::u16string normalized_path; + if (base::StartsWith(in, u"/")) { + normalized_path = u"ROOT"; + entry_.is_unsafe = false; + } + + for (;;) { + // Consume initial path separators. + const base::StringPiece16::size_type i = in.find_first_not_of(u'/'); + if (i == base::StringPiece16::npos) + break; + + in.remove_prefix(i); + DCHECK(!in.empty()); + + // Isolate next path component. + const base::StringPiece16 part = in.substr(0, in.find_first_of(u'/')); + DCHECK(!part.empty()); + + in.remove_prefix(part.size()); + + if (!normalized_path.empty()) + normalized_path += u'/'; + + if (part == u".") { + normalized_path += u"DOT"; + entry_.is_unsafe = true; + continue; + } + + if (part == u"..") { + normalized_path += u"UP"; + entry_.is_unsafe = true; + continue; + } + + // Windows has more restrictions than other systems when it comes to valid + // file paths. Replace Windows-invalid characters on all systems for + // consistency. In particular, this prevents a path component containing + // colon and backslash from being misinterpreted as an absolute path on + // Windows. + for (const char16_t c : part) { + normalized_path += IsValidFileNameCharacterOnWindows(c) ? c : 0xFFFD; + } + + entry_.is_unsafe = false; + } + + // If the entry is a directory, add the final path separator to the entry + // path. + if (entry_.is_directory && !normalized_path.empty()) { + normalized_path += u'/'; + entry_.is_unsafe = false; + } + + entry_.path = base::FilePath::FromUTF16Unsafe(normalized_path); + + // By construction, we should always get a relative path. + DCHECK(!entry_.path.IsAbsolute()) << entry_.path; +} + bool ZipReader::ExtractCurrentEntry(WriterDelegate* delegate, uint64_t num_bytes_to_extract) const { DCHECK(zip_file_); @@ -504,12 +583,26 @@ bool FileWriterDelegate::PrepareOutput() { DCHECK(file_); - const bool ok = file_->IsValid(); - if (ok) { - DCHECK_EQ(file_->GetLength(), 0) - << " The output file should be initially empty"; + + if (!file_->IsValid()) { + LOG(ERROR) << "File is not valid"; + return false; } - return ok; + + const int64_t length = file_->GetLength(); + if (length < 0) { + PLOG(ERROR) << "Cannot get length of file handle " + << file_->GetPlatformFile(); + return false; + } + + if (length > 0) { + PLOG(ERROR) << "File handle " << file_->GetPlatformFile() + << " is not empty: Its length is " << length << " bytes"; + return false; + } + + return true; } bool FileWriterDelegate::WriteBytes(const char* data, int num_bytes) { @@ -553,10 +646,25 @@ owned_file_.Initialize(output_file_path_, base::File::FLAG_CREATE | base::File::FLAG_WRITE); - PLOG_IF(ERROR, !owned_file_.IsValid()) - << "Cannot create file " << Redact(output_file_path_) << ": " - << base::File::ErrorToString(owned_file_.error_details()); - return FileWriterDelegate::PrepareOutput(); + if (!owned_file_.IsValid()) { + PLOG(ERROR) << "Cannot create file " << Redact(output_file_path_) << ": " + << base::File::ErrorToString(owned_file_.error_details()); + return false; + } + + const int64_t length = owned_file_.GetLength(); + if (length < 0) { + PLOG(ERROR) << "Cannot get length of file " << Redact(output_file_path_); + return false; + } + + if (length > 0) { + PLOG(ERROR) << "File " << Redact(output_file_path_) + << " is not empty: Its length is " << length << " bytes"; + return false; + } + + return true; } void FilePathWriterDelegate::OnError() {
diff --git a/third_party/zlib/google/zip_reader.h b/third_party/zlib/google/zip_reader.h index df7452a0..40fb1b9 100644 --- a/third_party/zlib/google/zip_reader.h +++ b/third_party/zlib/google/zip_reader.h
@@ -94,9 +94,14 @@ // if it wants to interpret this path correctly. std::string path_in_original_encoding; - // Path of the entry, converted to Unicode. This path is usually relative - // (eg "foo/bar.txt"), but it can also be absolute (eg "/foo/bar.txt") or - // parent-relative (eg "../foo/bar.txt"). See also |is_unsafe|. + // Path of the entry, converted to Unicode. This path is relative (eg + // "foo/bar.txt"). Absolute paths (eg "/foo/bar.txt") or paths containing + // ".." or "." components (eg "../foo/bar.txt") are converted to safe + // relative paths. Eg: + // (In ZIP) -> (Entry.path) + // /foo/bar -> ROOT/foo/bar + // ../a -> UP/a + // ./a -> DOT/a base::FilePath path; // Size of the original uncompressed file, or 0 if the entry is a directory. @@ -122,8 +127,8 @@ // False if the entry is a file. bool is_directory; - // True if the entry path is considered unsafe, ie if it is absolute or if - // it contains "..". + // True if the entry path cannot be converted to a safe relative path. This + // happens if a file entry (not a directory) has a filename "." or "..". bool is_unsafe; // True if the file content is encrypted. @@ -257,6 +262,10 @@ // reset automatically as needed. bool OpenEntry(); + // Normalizes the given path passed as UTF-16 string piece. Sets entry_.path, + // entry_.is_directory and entry_.is_unsafe. + void Normalize(base::StringPiece16 in); + // Extracts a chunk of the file to the target. Will post a task for the next // chunk and success/failure/progress callbacks as necessary. void ExtractChunk(base::File target_file,
diff --git a/third_party/zlib/google/zip_reader_unittest.cc b/third_party/zlib/google/zip_reader_unittest.cc index fc80637..31dceacc 100644 --- a/third_party/zlib/google/zip_reader_unittest.cc +++ b/third_party/zlib/google/zip_reader_unittest.cc
@@ -308,19 +308,18 @@ ZipReader reader; ASSERT_TRUE(reader.Open(data_dir_.AppendASCII("evil.zip"))); base::FilePath target_path(FILE_PATH_LITERAL( - "../levilevilevilevilevilevilevilevilevilevilevilevil")); + "UP/levilevilevilevilevilevilevilevilevilevilevilevil")); const ZipReader::Entry* entry = LocateAndOpenEntry(&reader, target_path); ASSERT_TRUE(entry); EXPECT_EQ(target_path, entry->path); - // This file is unsafe because of ".." in the file name. - EXPECT_TRUE(entry->is_unsafe); + EXPECT_FALSE(entry->is_unsafe); EXPECT_FALSE(entry->is_directory); } TEST_F(ZipReaderTest, InvalidUTF8File) { ZipReader reader; ASSERT_TRUE(reader.Open(data_dir_.AppendASCII("evil_via_invalid_utf8.zip"))); - base::FilePath target_path = base::FilePath::FromUTF8Unsafe(".�.\\evil.txt"); + base::FilePath target_path = base::FilePath::FromUTF8Unsafe(".�.�evil.txt"); const ZipReader::Entry* entry = LocateAndOpenEntry(&reader, target_path); ASSERT_TRUE(entry); EXPECT_EQ(target_path, entry->path); @@ -337,7 +336,7 @@ EXPECT_THAT( GetPaths(data_dir_.AppendASCII("SJIS Bug 846195.zip")), ElementsAre( - base::FilePath::FromUTF8Unsafe("�V�����t�H���_/SJIS_835C_�\\.txt"), + base::FilePath::FromUTF8Unsafe("�V�����t�H���_/SJIS_835C_��.txt"), base::FilePath::FromUTF8Unsafe( "�V�����t�H���_/�V�����e�L�X�g �h�L�������g.txt"))); } @@ -349,7 +348,7 @@ EXPECT_THAT( GetPaths(data_dir_.AppendASCII("SJIS Bug 846195.zip"), "windows-1252"), ElementsAre(base::FilePath::FromUTF8Unsafe( - "\u0090V‚µ‚¢ƒtƒHƒ‹ƒ_/SJIS_835C_ƒ\\.txt"), + "\u0090V‚µ‚¢ƒtƒHƒ‹ƒ_/SJIS_835C_ƒ�.txt"), base::FilePath::FromUTF8Unsafe( "\u0090V‚µ‚¢ƒtƒHƒ‹ƒ_/\u0090V‚µ‚¢ƒeƒLƒXƒg " "ƒhƒLƒ…ƒ\u0081ƒ“ƒg.txt"))); @@ -361,7 +360,7 @@ EXPECT_THAT( GetPaths(data_dir_.AppendASCII("SJIS Bug 846195.zip"), "IBM866"), ElementsAre( - base::FilePath::FromUTF8Unsafe("РVВ╡ВвГtГHГЛГ_/SJIS_835C_Г\\.txt"), + base::FilePath::FromUTF8Unsafe("РVВ╡ВвГtГHГЛГ_/SJIS_835C_Г�.txt"), base::FilePath::FromUTF8Unsafe( "РVВ╡ВвГtГHГЛГ_/РVВ╡ВвГeГLГXГg ГhГLГЕГБГУГg.txt"))); } @@ -380,12 +379,11 @@ ZipReader reader; ASSERT_TRUE( reader.Open(data_dir_.AppendASCII("evil_via_absolute_file_name.zip"))); - base::FilePath target_path(FILE_PATH_LITERAL("/evil.txt")); + base::FilePath target_path(FILE_PATH_LITERAL("ROOT/evil.txt")); const ZipReader::Entry* entry = LocateAndOpenEntry(&reader, target_path); ASSERT_TRUE(entry); EXPECT_EQ(target_path, entry->path); - // This file is unsafe because of the absolute file name. - EXPECT_TRUE(entry->is_unsafe); + EXPECT_FALSE(entry->is_unsafe); EXPECT_FALSE(entry->is_directory); }
diff --git a/third_party/zlib/google/zip_unittest.cc b/third_party/zlib/google/zip_unittest.cc index 8fbec32..3e0b178 100644 --- a/third_party/zlib/google/zip_unittest.cc +++ b/third_party/zlib/google/zip_unittest.cc
@@ -38,6 +38,7 @@ namespace { using testing::UnorderedElementsAre; +using testing::UnorderedElementsAreArray; std::vector<std::string> GetRelativePaths(const base::FilePath& dir, base::FileEnumerator::FileType type) { @@ -46,7 +47,7 @@ for (base::FilePath path = files.Next(); !path.empty(); path = files.Next()) { base::FilePath relative; EXPECT_TRUE(dir.AppendRelativePath(path, &relative)); - got_paths.push_back(relative.AsUTF8Unsafe()); + got_paths.push_back(relative.NormalizePathSeparatorsTo('/').AsUTF8Unsafe()); } EXPECT_EQ(base::File::FILE_OK, files.GetError()); @@ -401,11 +402,9 @@ // won't create a persistent file outside test_dir_ in case of a // failure. base::FilePath output_dir = test_dir_.AppendASCII("out"); - ASSERT_FALSE(zip::Unzip(path, output_dir)); - base::FilePath evil_file = output_dir; - evil_file = evil_file.AppendASCII( - "../levilevilevilevilevilevilevilevilevilevilevilevil"); - ASSERT_FALSE(base::PathExists(evil_file)); + EXPECT_TRUE(zip::Unzip(path, output_dir)); + EXPECT_TRUE(base::PathExists(output_dir.AppendASCII( + "UP/levilevilevilevilevilevilevilevilevilevilevilevil"))); } TEST_F(ZipTest, UnzipEvil2) { @@ -416,7 +415,7 @@ base::FilePath output_dir = test_dir_.AppendASCII("out"); ASSERT_TRUE(zip::Unzip(path, output_dir)); ASSERT_TRUE(base::PathExists( - output_dir.Append(base::FilePath::FromUTF8Unsafe(".�.\\evil.txt")))); + output_dir.Append(base::FilePath::FromUTF8Unsafe(".�.�evil.txt")))); ASSERT_FALSE(base::PathExists(output_dir.AppendASCII("../evil.txt"))); } @@ -695,45 +694,49 @@ std::unordered_set<std::string> want_paths = { #ifdef OS_WIN - "Dot", // - "Space→", // - "a\\b", // - "u\\v\\w\\x\\y\\z", // - "←Backslash2", // + "Dot", // + "Space→", // #else - " ", // Invalid on Windows - "Angle <>", // Invalid on Windows - "Backslash1→\\", // - "Backspace \x08", // Invalid on Windows - "Bell \a", // Invalid on Windows - "C:", // Invalid on Windows - "C:\\", // Absolute path on Windows - "C:\\Temp", // Absolute path on Windows - "C:\\Temp\\", // Absolute path on Windows - "C:\\Temp\\File", // Absolute path on Windows - "Carriage Return \r", // Invalid on Windows - "Colon :", // Invalid on Windows - "Dot .", // Becomes "Dot" on Windows - "Double quote \"", // Invalid on Windows - "Escape \x1B", // Invalid on Windows - "Line Feed \n", // Invalid on Windows + " ", // + "AUX", // Disappears on Windows + "COM1", // Disappears on Windows + "COM2", // Disappears on Windows + "COM3", // Disappears on Windows + "COM4", // Disappears on Windows + "COM5", // Disappears on Windows + "COM6", // Disappears on Windows + "COM7", // Disappears on Windows + "COM8", // Disappears on Windows + "COM9", // Disappears on Windows + "CON", // Disappears on Windows + "Dot .", // + "LPT1", // Disappears on Windows + "LPT2", // Disappears on Windows + "LPT3", // Disappears on Windows + "LPT4", // Disappears on Windows + "LPT5", // Disappears on Windows + "LPT6", // Disappears on Windows + "LPT7", // Disappears on Windows + "LPT8", // Disappears on Windows + "LPT9", // Disappears on Windows + "NUL ..txt", // Disappears on Windows + "NUL .txt", // Disappears on Windows + "NUL ", // Disappears on Windows + "NUL .", // Disappears on Windows "NUL .txt", // Disappears on Windows "NUL", // Disappears on Windows + "NUL.", // Disappears on Windows + "NUL...txt", // Disappears on Windows "NUL..txt", // Disappears on Windows "NUL.tar.gz", // Disappears on Windows "NUL.txt", // Disappears on Windows - "Pipe |", // Invalid on Windows - "Question ?", // Invalid on Windows - "Space→ ", // Becomes "Space→" on Windows - "Star *", // Invalid on Windows - "Tab \t", // Invalid on Windows - "\\\\server\\share\\file", // Absolute path on Windows - "\\←Backslash2", // Becomes "←Backslash2" on Windows - "a/b", // - "u/v/w/x/y/z", // + "PRN", // Disappears on Windows + "Space→ ", // + "c/NUL", // Disappears on Windows + "nul.very long extension", // Disappears on Windows #ifndef OS_MAC - "CASE", // - "Case", // + "CASE", // Conflicts with "Case" + "case", // Conflicts with "Case" #endif #endif " NUL.txt", // @@ -741,38 +744,67 @@ "$HOME", // "%TMP", // "-", // - "...Tree", // + "...Three", // "..Two", // ".One", // "Ampersand &", // + "Angle ��", // "At @", // - "Backslash3→\\←Backslash4", // + "Backslash1→�", // + "Backslash3→�←Backslash4", // + "Backspace �", // "Backtick `", // + "Bell �", // + "CLOCK$", // "Caret ^", // + "Carriage Return �", // + "Case", // + "Colon �", // "Comma ,", // "Curly {}", // + "C�", // + "C��", // + "C��Temp", // + "C��Temp�", // + "C��Temp�File", // "Dash -", // "Delete \x7F", // "Dollar $", // + "Double quote �", // "Equal =", // + "Escape �", // "Euro €", // "Exclamation !", // "FileOrDir", // "First", // "Hash #", // "Last", // + "Line Feed �", // "Percent %", // + "Pipe �", // "Plus +", // + "Question �", // "Quote '", // + "ROOT/At The Top", // + "ROOT/UP/Over The Top", // + "ROOT/dev/null", // "Round ()", // "Semicolon ;", // "Smile \U0001F642", // "Square []", // + "Star �", // "String Terminator \u009C", // + "Tab �", // "Tilde ~", // + "UP/One Level Up", // + "UP/UP/Two Levels Up", // "Underscore _", // - "case", // + "a/DOT/b", // + "a/UP/b", // + "u/v/w/x/y/z", // "~", // + "�←Backslash2", // + "��server�share�file", // }; const std::vector<std::string> got_paths = @@ -789,14 +821,24 @@ EXPECT_THAT( GetRelativePaths(test_dir_, base::FileEnumerator::FileType::DIRECTORIES), - UnorderedElementsAre( -#ifdef OS_WIN - "Backslash3→", "Empty", "a", "u", "u\\v", "u\\v\\w", "u\\v\\w\\x", - "u\\v\\w\\x\\y" -#else - "Empty", "a", "u", "u/v", "u/v/w", "u/v/w/x", "u/v/w/x/y" -#endif - )); + UnorderedElementsAreArray({ + "Empty", + "ROOT", + "ROOT/Empty", + "ROOT/UP", + "ROOT/dev", + "UP", + "UP/UP", + "a", + "a/DOT", + "a/UP", + "c", + "u", + "u/v", + "u/v/w", + "u/v/w/x", + "u/v/w/x/y", + })); } TEST_F(ZipTest, UnzipWithDelegates) { @@ -897,7 +939,7 @@ std::string contents; ASSERT_TRUE(base::ReadFileToString( - dir.Append(base::FilePath::FromUTF8Unsafe("SJIS_835C_�\\.txt")), + dir.Append(base::FilePath::FromUTF8Unsafe("SJIS_835C_��.txt")), &contents)); EXPECT_EQ( "This file's name contains 0x5c (backslash) as the 2nd byte of Japanese "
diff --git a/tools/clang/scripts/build.py b/tools/clang/scripts/build.py index 11e5926..fea7a1fd 100755 --- a/tools/clang/scripts/build.py +++ b/tools/clang/scripts/build.py
@@ -443,22 +443,6 @@ sys.exit(1) -# TODO(https://crbug.com/1286289): remove once Chrome targets don't rely on -# libstdc++.so existing in the clang package. -def CopyLibstdcpp(args, build_dir): - if not args.gcc_toolchain: - return - # Find libstdc++.so.6 - libstdcpp = subprocess.check_output([ - os.path.join(args.gcc_toolchain, 'bin', 'g++'), - '-print-file-name=libstdc++.so.6' - ], - universal_newlines=True).rstrip() - - EnsureDirExists(os.path.join(build_dir, 'lib')) - CopyFile(libstdcpp, os.path.join(build_dir, 'lib')) - - def gn_arg(v): if v == 'True': return True @@ -996,7 +980,6 @@ os.chdir(LLVM_BUILD_DIR) RunCommand(['cmake'] + cmake_args + [os.path.join(LLVM_DIR, 'llvm')], msvc_arch='x64', env=deployment_env) - CopyLibstdcpp(args, LLVM_BUILD_DIR) RunCommand(['ninja'], msvc_arch='x64') if chrome_tools:
diff --git a/tools/clang/scripts/package.py b/tools/clang/scripts/package.py index 53e32c3..a389e0a 100755 --- a/tools/clang/scripts/package.py +++ b/tools/clang/scripts/package.py
@@ -306,9 +306,6 @@ want.extend([ # pylint: disable=line-too-long - # Copy the stdlibc++.so.6 we linked the binaries against. - 'lib/libstdc++.so.6', - # Add llvm-objcopy for partition extraction on Android. 'bin/llvm-objcopy',
diff --git a/tools/clang/scripts/update.py b/tools/clang/scripts/update.py index ceeeedc..8cf820d7d 100755 --- a/tools/clang/scripts/update.py +++ b/tools/clang/scripts/update.py
@@ -36,7 +36,7 @@ # Reverting problematic clang rolls is safe, though. # This is the output of `git describe` and is usable as a commit-ish. CLANG_REVISION = 'llvmorg-15-init-3677-g8133778d' -CLANG_SUB_REVISION = 4 +CLANG_SUB_REVISION = 5 PACKAGE_VERSION = '%s-%s' % (CLANG_REVISION, CLANG_SUB_REVISION) RELEASE_VERSION = '15.0.0'
diff --git a/tools/json_schema_compiler/cpp_bundle_generator.py b/tools/json_schema_compiler/cpp_bundle_generator.py index c883b4d..63d6d5b 100644 --- a/tools/json_schema_compiler/cpp_bundle_generator.py +++ b/tools/json_schema_compiler/cpp_bundle_generator.py
@@ -149,6 +149,8 @@ # BUILDFLAG(IS_CHROMEOS) && BUILDFLAG(IS_CHROMEOS_ASH). ifdefs.append('(BUILDFLAG(IS_CHROMEOS) && ' '!BUILDFLAG(IS_CHROMEOS_LACROS))') + elif platform == Platforms.FUCHSIA: + ifdefs.append('BUILDFLAG(IS_FUCHSIA)') elif platform == Platforms.LACROS: # TODO(https://crbug.com/1052397): For readability, this should become # BUILDFLAG(IS_CHROMEOS) && BUILDFLAG(IS_CHROMEOS_LACROS).
diff --git a/tools/json_schema_compiler/cpp_bundle_generator_test.py b/tools/json_schema_compiler/cpp_bundle_generator_test.py index 49c2536..de1eb49 100755 --- a/tools/json_schema_compiler/cpp_bundle_generator_test.py +++ b/tools/json_schema_compiler/cpp_bundle_generator_test.py
@@ -35,8 +35,8 @@ cpp_bundle_generator, model = _createCppBundleGenerator( 'test/function_platform_all.json') self.assertEqual( - 'BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || ' - '(BUILDFLAG(IS_CHROMEOS) && !BUILDFLAG(IS_CHROMEOS_LACROS))', + '(BUILDFLAG(IS_CHROMEOS) && !BUILDFLAG(IS_CHROMEOS_LACROS)) || ' + 'BUILDFLAG(IS_FUCHSIA) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN)', _getPlatformIfdefs(cpp_bundle_generator, model)) def testIfDefsForChromeOS(self):
diff --git a/tools/json_schema_compiler/idl_schema_test.py b/tools/json_schema_compiler/idl_schema_test.py index 915d4629a..8ac40b7 100755 --- a/tools/json_schema_compiler/idl_schema_test.py +++ b/tools/json_schema_compiler/idl_schema_test.py
@@ -191,7 +191,7 @@ def testAllPlatformsNamespace(self): schema = idl_schema.Load('test/idl_namespace_all_platforms.idl')[0] self.assertEqual('idl_namespace_all_platforms', schema['namespace']) - expected = ['chromeos', 'linux', 'mac', 'win'] + expected = ['chromeos', 'fuchsia', 'linux', 'mac', 'win'] self.assertEqual(expected, schema['platforms']) def testNonSpecificPlatformsNamespace(self):
diff --git a/tools/json_schema_compiler/model.py b/tools/json_schema_compiler/model.py index d0c969f7..faed0c7 100644 --- a/tools/json_schema_compiler/model.py +++ b/tools/json_schema_compiler/model.py
@@ -877,6 +877,7 @@ """Enum of the possible platforms. """ CHROMEOS = _PlatformInfo("chromeos") + FUCHSIA = _PlatformInfo("fuchsia") LACROS = _PlatformInfo("lacros") LINUX = _PlatformInfo("linux") MAC = _PlatformInfo("mac")
diff --git a/tools/json_schema_compiler/model_test.py b/tools/json_schema_compiler/model_test.py index e111aa6..7ad34744 100755 --- a/tools/json_schema_compiler/model_test.py +++ b/tools/json_schema_compiler/model_test.py
@@ -202,7 +202,8 @@ self.assertEqual([Platforms.CHROMEOS], self.idl_namespace_chromeos.platforms) self.assertEqual( - [Platforms.CHROMEOS, Platforms.LINUX, Platforms.MAC, Platforms.WIN], + [Platforms.CHROMEOS, Platforms.FUCHSIA, Platforms.LINUX, Platforms.MAC, + Platforms.WIN], self.idl_namespace_all_platforms.platforms) self.assertEqual(None, self.idl_namespace_non_specific_platforms.platforms) @@ -232,6 +233,9 @@ function_cros = self.function_platforms.functions['function_cros'] self.assertEqual([Platforms.CHROMEOS], function_cros.platforms) + function_fuchsia = self.function_platforms.functions['function_fuchsia'] + self.assertEqual([Platforms.FUCHSIA], function_fuchsia.platforms) + def testPlatformsOnFunctionsJSON(self): test_function = self.function_platform_win_linux.functions['test'] self.assertEqual([Platforms.WIN, Platforms.LINUX], test_function.platforms)
diff --git a/tools/json_schema_compiler/test/function_platform_all.json b/tools/json_schema_compiler/test/function_platform_all.json index 8152ceac..0ddbd7fe 100644 --- a/tools/json_schema_compiler/test/function_platform_all.json +++ b/tools/json_schema_compiler/test/function_platform_all.json
@@ -9,7 +9,7 @@ "functions": [{ "name": "test", "type": "function", - "platforms": ["win", "linux", "chromeos"], + "platforms": ["chromeos", "fuchsia", "linux", "win"], "parameters": [] }] }
diff --git a/tools/json_schema_compiler/test/function_platforms.idl b/tools/json_schema_compiler/test/function_platforms.idl index ff10c44..84d5efc1f 100644 --- a/tools/json_schema_compiler/test/function_platforms.idl +++ b/tools/json_schema_compiler/test/function_platforms.idl
@@ -13,5 +13,8 @@ [platforms=("chromeos")] static void function_cros(); + + [platforms=("fuchsia")] + static void function_fuchsia(); }; };
diff --git a/tools/json_schema_compiler/test/idl_namespace_all_platforms.idl b/tools/json_schema_compiler/test/idl_namespace_all_platforms.idl index 9d75aa9..99b770b7 100644 --- a/tools/json_schema_compiler/test/idl_namespace_all_platforms.idl +++ b/tools/json_schema_compiler/test/idl_namespace_all_platforms.idl
@@ -4,7 +4,7 @@ // Tests a variety of basic API definition features. -[platforms=("chromeos", "linux", "mac", "win")] +[platforms=("chromeos", "fuchsia", "linux", "mac", "win")] namespace idl_namespace_all_platforms { };
diff --git a/tools/mb/mb_config.pyl b/tools/mb/mb_config.pyl index 588ea8d..eee0fbb2 100644 --- a/tools/mb/mb_config.pyl +++ b/tools/mb/mb_config.pyl
@@ -247,7 +247,7 @@ 'ASan Debug (32-bit x86 with V8-ARM)': 'asan_v8_heap_debug_bot_hybrid_reclient', 'ASan Release (32-bit x86 with V8-ARM)': 'asan_fuzzer_v8_heap_release_bot_hybrid_reclient', 'ASan Release Media (32-bit x86 with V8-ARM)': 'asan_fuzzer_v8_heap_chromeos_codecs_release_bot_hybrid_reclient', - 'Afl Upload Linux ASan': 'afl_asan_shared_release_bot', + 'Afl Upload Linux ASan': 'afl_asan_shared_release_bot_reclient', 'ChromiumOS ASAN Release': 'chromeos_asan_lsan_fuzzer_v8_heap_release_bot', 'Libfuzzer Upload Chrome OS ASan': 'libfuzzer_chromeos_asan_release_bot', 'Libfuzzer Upload iOS Catalyst Debug': 'ios_catalyst_debug_static_bot_compile_only_libfuzzer_no_dsyms_no_lld_no_remoting', @@ -1309,6 +1309,11 @@ 'optimize_for_fuzzing', 'shared_release_bot', 'disable_seed_corpus', ], + 'afl_asan_shared_release_bot_reclient': [ + 'afl', 'asan', 'chromeos_codecs', 'pdf_xfa', 'disable_nacl', + 'optimize_for_fuzzing', 'shared_release_bot_reclient', 'disable_seed_corpus', + ], + 'android_binary_size': [ 'android', 'chrome_with_codecs', 'goma', 'minimal_symbols', 'official_optimize', 'stable_channel', @@ -1959,7 +1964,7 @@ ], 'chromeos_amd64-generic_lacros_dbg': [ - 'chromeos_amd64-generic-crostoolchain', 'amd64-lacros', 'debug', + 'chromeos_amd64-generic-crostoolchain', 'amd64-lacros', 'debug', 'static', ], 'chromeos_amd64-generic_dbg': [
diff --git a/tools/mb/mb_config_expectations/chromium.chromiumos.json b/tools/mb/mb_config_expectations/chromium.chromiumos.json index 328cb67..06dfa6bd 100644 --- a/tools/mb/mb_config_expectations/chromium.chromiumos.json +++ b/tools/mb/mb_config_expectations/chromium.chromiumos.json
@@ -50,6 +50,7 @@ "cros_v8_snapshot_sysroot": "//build/linux/debian_sid_amd64-sysroot", "dcheck_always_on": false, "is_chromeos_device": true, + "is_component_build": false, "is_debug": true, "ozone_platform_headless": true, "target_os": "chromeos",
diff --git a/tools/mb/mb_config_expectations/chromium.fuzz.json b/tools/mb/mb_config_expectations/chromium.fuzz.json index 4c025a8..e7fd15e7 100644 --- a/tools/mb/mb_config_expectations/chromium.fuzz.json +++ b/tools/mb/mb_config_expectations/chromium.fuzz.json
@@ -96,7 +96,8 @@ "pdf_enable_xfa": true, "proprietary_codecs": true, "use_afl": true, - "use_goma": true + "use_rbe": true, + "use_remoteexec": true } }, "ChromiumOS ASAN Release": {
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index 911b7ab..65bfd4e 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -49313,6 +49313,9 @@ <int value="10" label="Failed to load policy for kiosk account"/> <int value="11" label="Unable to download crx"/> <int value="12" label="Unable to launch app"/> + <int value="13" label="Failed to authorise ARC session"/> + <int value="14" label="Timeout loading force-installed extensions"/> + <int value="15" label="Invalid ExtensionInstallForcelist policy"/> </enum> <enum name="KioskLaunchType"> @@ -52594,6 +52597,7 @@ <int value="-1525129540" label="OmniboxUIExperimentRevealSteadyStateUrlPathQueryAndRefOnHover:disabled"/> <int value="-1524323669" label="InstalledAppsInCbd:enabled"/> + <int value="-1522304497" label="kVirtualKeyboardMultitouch:enabled"/> <int value="-1521544926" label="OmniboxPreserveLongerShortcutsText:disabled"/> <int value="-1521339691" label="UseGles2ForOopR:disabled"/> <int value="-1521160841" label="DismissNtpPromos:enabled"/> @@ -52763,6 +52767,7 @@ <int value="-1420542268" label="AutofillEnableAccountWalletStorage:disabled"/> <int value="-1419788257" label="enable-experimental-hotwording"/> <int value="-1419449681" label="PermissionChipRequestTypeSensitive:enabled"/> + <int value="-1418200801" label="LauncherLacrosIntegration:enabled"/> <int value="-1417642561" label="AutofillCreditCardUploadFeedback:enabled"/> <int value="-1417122729" label="AutofillCreditCardAblationExperiment:disabled"/> @@ -54006,6 +54011,7 @@ <int value="-577982497" label="CupsPrintersUiOverhaul:enabled"/> <int value="-577503348" label="GridTabSwitcherForTablets:disabled"/> <int value="-576759065" label="HoldingSpaceInProgressAnimationV2:disabled"/> + <int value="-574965003" label="LauncherLacrosIntegration:disabled"/> <int value="-574354898" label="PostQuantumCECPQ2:enabled"/> <int value="-574217217" label="kSignInProfileCreationEnterprise:enabled"/> <int value="-574000901" label="AVIF:enabled"/> @@ -54042,6 +54048,7 @@ <int value="-552407626" label="ContextualSearchNewSettings:disabled"/> <int value="-551434067" label="QuickActionSearchWidgetAndroidDinoVariant:enabled"/> + <int value="-551334994" label="NotificationPermissionVariant:enabled"/> <int value="-549837954" label="RevenLogSource:enabled"/> <int value="-548082154" label="protect-sync-credential:disabled"/> <int value="-547763795" label="SystemEmojiPickerExtension:disabled"/> @@ -54929,6 +54936,7 @@ <int value="65245449" label="FilesBannerFramework:enabled"/> <int value="66897259" label="ModalPermissionDialogView:enabled"/> <int value="67639499" label="stop-loading-in-background:disabled"/> + <int value="69778786" label="NotificationPermissionVariant:disabled"/> <int value="71290103" label="ArcNearbySharing:enabled"/> <int value="72558615" label="TrafficCountersSettingsUi:enabled"/> <int value="73606763" label="XsurfaceMetricsReporting:disabled"/> @@ -56033,6 +56041,7 @@ <int value="840057845" label="HardwareMediaKeyHandling:enabled"/> <int value="840222947" label="AutofillEnableOfferNotificationForPromoCodes:enabled"/> + <int value="840372756" label="kVirtualKeyboardMultitouch:disabled"/> <int value="841098208" label="ThrottleForegroundTimers:enabled"/> <int value="841276069" label="ChromeHomeDoodle:disabled"/> <int value="841343322" label="disable-new-korean-ime"/>
diff --git a/tools/metrics/histograms/metadata/apps/histograms.xml b/tools/metrics/histograms/metadata/apps/histograms.xml index 63c336d2..63af976 100644 --- a/tools/metrics/histograms/metadata/apps/histograms.xml +++ b/tools/metrics/histograms/metadata/apps/histograms.xml
@@ -319,7 +319,7 @@ </histogram> <histogram name="Apps.AppList.AppsGridAddPage" enum="AppListAddPageType" - expires_after="2022-05-01"> + expires_after="2023-03-22"> <owner>anasalazar@chromium.org</owner> <owner>newcomer@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/arc/histograms.xml b/tools/metrics/histograms/metadata/arc/histograms.xml index 4b6f59c..6895b6ad 100644 --- a/tools/metrics/histograms/metadata/arc/histograms.xml +++ b/tools/metrics/histograms/metadata/arc/histograms.xml
@@ -733,10 +733,10 @@ </histogram> <histogram name="Arc.EngagementTime.ArcTotal" units="ms" - expires_after="2022-04-24"> - <owner>maajid@google.com</owner> - <owner>shaochuan@google.com</owner> - <owner>shihuis@google.com</owner> + expires_after="2023-04-01"> + <owner>mduggan@google.com</owner> + <owner>yhanada@google.com</owner> + <owner>arc-framework@google.com</owner> <summary> Total of Arc.EngagementTime.Background and Arc.EngagementTime.Foreground. Note that this differs from Arc.EngagementTime.Total in that this is the @@ -747,10 +747,10 @@ </histogram> <histogram name="Arc.EngagementTime.Background" units="ms" - expires_after="2022-04-17"> - <owner>maajid@google.com</owner> - <owner>shaochuan@google.com</owner> - <owner>shihuis@google.com</owner> + expires_after="2023-04-01"> + <owner>mduggan@google.com</owner> + <owner>yhanada@google.com</owner> + <owner>arc-framework@google.com</owner> <summary> Times when user is engaged and ARC++ apps are running in the background, but the user isn't focusing on an ARC++ app window. See Arc.EngagementTime.Total @@ -759,10 +759,10 @@ </histogram> <histogram name="Arc.EngagementTime.Foreground" units="ms" - expires_after="2022-04-03"> - <owner>maajid@google.com</owner> - <owner>shaochuan@google.com</owner> - <owner>shihuis@google.com</owner> + expires_after="2023-04-01"> + <owner>mduggan@google.com</owner> + <owner>yhanada@google.com</owner> + <owner>arc-framework@google.com</owner> <summary> Times when user is engaged and focuses on an ARC++ app window. See Arc.EngagementTime.Total for definition of engagement and details. @@ -770,10 +770,10 @@ </histogram> <histogram name="Arc.EngagementTime.Total" units="ms" - expires_after="2022-04-24"> - <owner>maajid@google.com</owner> - <owner>shaochuan@google.com</owner> - <owner>shihuis@google.com</owner> + expires_after="2023-04-01"> + <owner>mduggan@google.com</owner> + <owner>yhanada@google.com</owner> + <owner>arc-framework@google.com</owner> <summary> Total CrOS user session time (from login to logout) excluding times when user "disengages": screen is locked or dims down due to user idle.
diff --git a/tools/metrics/histograms/metadata/others/histograms.xml b/tools/metrics/histograms/metadata/others/histograms.xml index 6d26b68..86d203f 100644 --- a/tools/metrics/histograms/metadata/others/histograms.xml +++ b/tools/metrics/histograms/metadata/others/histograms.xml
@@ -6381,10 +6381,13 @@ </histogram> <histogram name="Kiosk.Launch.Error" enum="KioskLaunchError" - expires_after="2021-10-04"> + expires_after="2022-10-04"> <owner>xiyuan@chromium.org</owner> <owner>apotapchuk@chromium.org</owner> - <summary>Tracks kiosk launch errors.</summary> + <summary> + Tracks Chrome OS Kiosk launch errors. Recorded when a Kiosk app fails to + launch and returns to the login screen. + </summary> </histogram> <histogram name="Kiosk.LaunchDuration.{KioskType}" units="ms"
diff --git a/tools/perf/core/perfetto_binary_roller/binary_deps.json b/tools/perf/core/perfetto_binary_roller/binary_deps.json index 71d4603..ddc96770 100644 --- a/tools/perf/core/perfetto_binary_roller/binary_deps.json +++ b/tools/perf/core/perfetto_binary_roller/binary_deps.json
@@ -5,24 +5,24 @@ "remote_path": "perfetto_binaries/trace_processor_shell/linux_arm64/49b4b5dcbc312d8d2c3751cf29238b8efeb4e494/trace_processor_shell" }, "win": { - "hash": "7268cf44400656f50b5ba8a2e7cd45d187772b46", - "remote_path": "perfetto_binaries/trace_processor_shell/win/5ed301fb68e249da0551a15599a2f80111581497/trace_processor_shell.exe" + "hash": "0b82660af8fffa884f38a087f02439a8c3ec26fb", + "remote_path": "perfetto_binaries/trace_processor_shell/win/816b940e0a3c704c2112b3e2f42db53b9c832727/trace_processor_shell.exe" }, "linux_arm": { "hash": "58893933be305d3bfe0a72ebebcacde2ac3ca893", "remote_path": "perfetto_binaries/trace_processor_shell/linux_arm/49b4b5dcbc312d8d2c3751cf29238b8efeb4e494/trace_processor_shell" }, "mac": { - "hash": "26a32b1eee816e5c6c4da2ce42e928893cd78c7f", - "remote_path": "perfetto_binaries/trace_processor_shell/mac/5ed301fb68e249da0551a15599a2f80111581497/trace_processor_shell" + "hash": "ea627513b35e26b57860fc08df31b35946ecb35e", + "remote_path": "perfetto_binaries/trace_processor_shell/mac/816b940e0a3c704c2112b3e2f42db53b9c832727/trace_processor_shell" }, "mac_arm64": { "hash": "c0397e87456ad6c6a7aa0133e5b81c97adbab4ab", "remote_path": "perfetto_binaries/trace_processor_shell/mac_arm64/cefb3e0ec3a0580c996f801e854fe02963c03d5c/trace_processor_shell" }, "linux": { - "hash": "b4ce5a257b6894de4363377ce40b21b9c632db7e", - "remote_path": "perfetto_binaries/trace_processor_shell/linux/ae44ad76bdf06db6f4e11186dd30cfdbc7d852b0/trace_processor_shell" + "hash": "55ba8e9a82e96509045055b626380f4a5d1ef87d", + "remote_path": "perfetto_binaries/trace_processor_shell/linux/a8f0cd2c06fe26eb10b280c3c25db17b5d45519e/trace_processor_shell" } }, "power_profile.sql": {
diff --git a/ui/color/mac/native_color_mixers_mac.mm b/ui/color/mac/native_color_mixers_mac.mm index cc4974d..779557e 100644 --- a/ui/color/mac/native_color_mixers_mac.mm +++ b/ui/color/mac/native_color_mixers_mac.mm
@@ -88,8 +88,6 @@ if (!high_contrast) return; - mixer[kColorFrameActive] = {SK_ColorDKGRAY}; - mixer[kColorFrameInactive] = {SK_ColorGRAY}; mixer[kColorMenuItemBackgroundSelected] = {dark_mode ? SK_ColorLTGRAY : SK_ColorDKGRAY}; mixer[kColorMenuItemForegroundSelected] = {dark_mode ? SK_ColorBLACK
diff --git a/ui/file_manager/integration_tests/file_manager/zip_files.js b/ui/file_manager/integration_tests/file_manager/zip_files.js index ea9ce54..a591d10 100644 --- a/ui/file_manager/integration_tests/file_manager/zip_files.js +++ b/ui/file_manager/integration_tests/file_manager/zip_files.js
@@ -448,3 +448,111 @@ await remoteCall.waitForElement( appId, '[command="#zip-selection"]:not([hidden])'); }; + +/** + * Tests that extraction of a ZIP archive generates correct output files. + */ +testcase.zipExtractCheckContent = async () => { + const entry = ENTRIES.zipArchive; + + // Open files app. + const appId = await setupAndWaitUntilReady(RootPath.DOWNLOADS, [entry], []); + + // Select the file. + chrome.test.assertTrue(await remoteCall.callRemoteTestUtil( + 'selectFile', appId, [entry.nameText])); + + // Right-click the selected file. + chrome.test.assertTrue( + !!await remoteCall.callRemoteTestUtil( + 'fakeMouseRightClick', appId, ['.table-row[selected]']), + 'fakeMouseRightClick failed'); + + // Check: the context menu should appear. + await remoteCall.waitForElement(appId, '#file-context-menu:not([hidden])'); + + // Click the 'Extract all' menu command. + const extract = '[command="#extract-all"]'; + chrome.test.assertTrue( + !!await remoteCall.callRemoteTestUtil('fakeMouseClick', appId, [extract]), + 'fakeMouseClick failed'); + + const directoryQuery = + '#file-list [file-name="' + entry.nameText.split('.')[0] + '"]'; + // Check: the extract directory should appear. + await remoteCall.waitForElement(appId, directoryQuery); + + // Double click the created directory to open it. + chrome.test.assertTrue( + !!await remoteCall.callRemoteTestUtil( + 'fakeMouseDoubleClick', appId, [directoryQuery]), + 'fakeMouseDoubleClick failed'); + + // Check: File content in the ZIP should appear. + await remoteCall.waitForElement(appId, '#file-list [file-name="folder"]'); + await remoteCall.waitForElement(appId, '#file-list [file-name="text.txt"]'); + await remoteCall.waitForElement(appId, '#file-list [file-name="image.png"]'); +}; + +/** + * Tests that repeated extraction of a ZIP archive generates extra directories. + */ +testcase.zipExtractCheckDuplicates = async () => { + const entry = ENTRIES.zipArchive; + + // Open files app. + const appId = await setupAndWaitUntilReady(RootPath.DOWNLOADS, [entry], []); + + // Select the file. + chrome.test.assertTrue(await remoteCall.callRemoteTestUtil( + 'selectFile', appId, [entry.nameText])); + + // Right-click the selected file. + chrome.test.assertTrue( + !!await remoteCall.callRemoteTestUtil( + 'fakeMouseRightClick', appId, ['.table-row[selected]']), + 'fakeMouseRightClick failed'); + + // Check: the context menu should appear. + await remoteCall.waitForElement(appId, '#file-context-menu:not([hidden])'); + + // Click the 'Extract all' menu command. + const extract = '[command="#extract-all"]'; + chrome.test.assertTrue( + !!await remoteCall.callRemoteTestUtil('fakeMouseClick', appId, [extract]), + 'fakeMouseClick failed'); + + const directory = entry.nameText.split('.')[0]; + let directoryQuery = '#file-list [file-name="' + directory + '"]'; + // Check: the extract directory should appear. + await remoteCall.waitForElement(appId, directoryQuery); + + // Right-click the selected file. + chrome.test.assertTrue( + !!await remoteCall.callRemoteTestUtil( + 'fakeMouseRightClick', appId, ['.table-row[selected]']), + 'fakeMouseRightClick failed'); + + // Check: the context menu should appear. + await remoteCall.waitForElement(appId, '#file-context-menu:not([hidden])'); + + // Click the 'Extract all' menu command. + chrome.test.assertTrue( + !!await remoteCall.callRemoteTestUtil('fakeMouseClick', appId, [extract]), + 'fakeMouseClick failed'); + + directoryQuery = '#file-list [file-name="' + directory + ' (1)"]'; + // Check: the duplicate named extract directory should appear. + await remoteCall.waitForElement(appId, directoryQuery); + + // Double click the duplicate created directory to open it. + chrome.test.assertTrue( + !!await remoteCall.callRemoteTestUtil( + 'fakeMouseDoubleClick', appId, [directoryQuery]), + 'fakeMouseDoubleClick failed'); + + // Check: File content in the ZIP should appear. + await remoteCall.waitForElement(appId, '#file-list [file-name="folder"]'); + await remoteCall.waitForElement(appId, '#file-list [file-name="text.txt"]'); + await remoteCall.waitForElement(appId, '#file-list [file-name="image.png"]'); +};
diff --git a/ui/gfx/geometry/insets.h b/ui/gfx/geometry/insets.h index f134b9b..6d230bb 100644 --- a/ui/gfx/geometry/insets.h +++ b/ui/gfx/geometry/insets.h
@@ -24,23 +24,38 @@ // Avoid this constructor in blink code because it's easy to make mistakes in // the order of the parameters. Use the other constructors and set_*() - // methods instead. + // methods instead. TODO(crbug.com/1302500): Remove this constructor after + // migrating UI code to TLBR()/VH(). constexpr Insets(int vertical, int horizontal) : Insets(vertical, horizontal, vertical, horizontal) {} // Avoid this constructor in blink code because it's easy to make mistakes in // the order of the parameters. Use the other constructors and set_*() - // methods instead. + // methods instead. TODO(crbug.com/1302500): Remove this constructor after + // migrating UI code to TLBR()/VH(). constexpr Insets(int top, int left, int bottom, int right) { set_left_right(left, right); set_top_bottom(top, bottom); } + // These are for Chromium UI code to replace the original usages of + // Insets::Insets(top, left, bottom, right) and Insets(vertical, horizontal). + static constexpr Insets TLBR(int top, int left, int bottom, int right) { + return Insets().set_top_bottom(top, bottom).set_left_right(left, right); + } + static constexpr Insets VH(int vertical, int horizontal) { + return Insets() + .set_top_bottom(vertical, vertical) + .set_left_right(horizontal, horizontal); + } + // Conversion from Insets to Outsets negates all components. Outsets ToOutsets() const; // Avoid this method in blink code because it's easy to make mistakes in the // order of the parameters. Use set_*() methods instead. + // TODO(crbug.com/1302500): Remove this method after migrating UI code to + // TLBR()/VH(). void Set(int top, int left, int bottom, int right) { set_left_right(left, right); set_top_bottom(top, bottom);
diff --git a/ui/gfx/geometry/insets_f.h b/ui/gfx/geometry/insets_f.h index e74fd7c..90940b79 100644 --- a/ui/gfx/geometry/insets_f.h +++ b/ui/gfx/geometry/insets_f.h
@@ -19,13 +19,15 @@ // Avoid this constructor in blink code because it's easy to make mistakes in // the order of the parameters. Use the other constructors and set_*() - // methods instead. + // methods instead. TODO(crbug.com/1302500): Remove this constructor after + // migrating UI code to TLBR()/VH(). constexpr InsetsF(float vertical, float horizontal) : InsetsF(vertical, horizontal, vertical, horizontal) {} // Avoid this constructor in blink code because it's easy to make mistakes in // the order of the parameters. Use the other constructors and set_*() - // methods instead. + // methods instead. TODO(crbug.com/1302500): Remove this constructor after + // migrating UI code to TLBR()/VH(). constexpr InsetsF(float top, float left, float bottom, float right) { set_top(top); set_left(left); @@ -33,11 +35,30 @@ set_right(right); } + // These are for Chromium UI code to replace the original usages of + // InsetsF(top, left, bottom, right) and InsetsF(vertical, horizontal). + static constexpr inline InsetsF TLBR(float top, + float left, + float bottom, + float right) { + return InsetsF().set_top(top).set_left(left).set_bottom(bottom).set_right( + right); + } + static constexpr inline InsetsF VH(float vertical, float horizontal) { + return InsetsF() + .set_top(vertical) + .set_left(horizontal) + .set_bottom(vertical) + .set_right(horizontal); + } + // Conversion from InsetsF to OutsetsF negates all components. OutsetsF ToOutsets() const; // Avoid this method in blink code because it's easy to make mistakes in the // order of the parameters. Use the setter methods instead. + // TODO(crbug.com/1302500): Remove this method after migrating UI code to + // TLBR()/VH(). void Set(float top, float left, float bottom, float right) { set_top(top); set_left(left);
diff --git a/ui/gfx/geometry/insets_f_unittest.cc b/ui/gfx/geometry/insets_f_unittest.cc index f783321..85fbe14 100644 --- a/ui/gfx/geometry/insets_f_unittest.cc +++ b/ui/gfx/geometry/insets_f_unittest.cc
@@ -28,6 +28,22 @@ EXPECT_EQ(4.875f, insets.right()); } +TEST(InsetsFTest, InsetsFTLBR) { + InsetsF insets = InsetsF::TLBR(1.25f, 2.5f, 3.75f, 4.875f); + EXPECT_EQ(1.25f, insets.top()); + EXPECT_EQ(2.5f, insets.left()); + EXPECT_EQ(3.75f, insets.bottom()); + EXPECT_EQ(4.875f, insets.right()); +} + +TEST(InsetsFTest, InsetsFVH) { + InsetsF insets = InsetsF::VH(1.25f, 2.5f); + EXPECT_EQ(1.25f, insets.top()); + EXPECT_EQ(2.5f, insets.left()); + EXPECT_EQ(1.25f, insets.bottom()); + EXPECT_EQ(2.5f, insets.right()); +} + TEST(InsetsFTest, SetTop) { InsetsF insets = InsetsF(1.5f); insets.set_top(2.75f);
diff --git a/ui/gfx/geometry/insets_unittest.cc b/ui/gfx/geometry/insets_unittest.cc index 5f273f5..2ba29725 100644 --- a/ui/gfx/geometry/insets_unittest.cc +++ b/ui/gfx/geometry/insets_unittest.cc
@@ -28,6 +28,22 @@ EXPECT_EQ(4, insets.right()); } +TEST(InsetsTest, InsetsTLBR) { + Insets insets = Insets::TLBR(1, 2, 3, 4); + EXPECT_EQ(1, insets.top()); + EXPECT_EQ(2, insets.left()); + EXPECT_EQ(3, insets.bottom()); + EXPECT_EQ(4, insets.right()); +} + +TEST(InsetsTest, InsetsVH) { + Insets insets = Insets::VH(1, 2); + EXPECT_EQ(1, insets.top()); + EXPECT_EQ(2, insets.left()); + EXPECT_EQ(1, insets.bottom()); + EXPECT_EQ(2, insets.right()); +} + TEST(InsetsTest, SetLeftRight) { Insets insets(1); insets.set_left_right(3, 4);
diff --git a/ui/gtk/gtk_ui.cc b/ui/gtk/gtk_ui.cc index d5eb5ce..136f081 100644 --- a/ui/gtk/gtk_ui.cc +++ b/ui/gtk/gtk_ui.cc
@@ -519,6 +519,7 @@ case base::nix::DESKTOP_ENVIRONMENT_CINNAMON: case base::nix::DESKTOP_ENVIRONMENT_GNOME: case base::nix::DESKTOP_ENVIRONMENT_PANTHEON: + case base::nix::DESKTOP_ENVIRONMENT_UKUI: case base::nix::DESKTOP_ENVIRONMENT_UNITY: case base::nix::DESKTOP_ENVIRONMENT_XFCE: return true;