diff --git a/DEPS b/DEPS index 9ea69e52..1dd63aa 100644 --- a/DEPS +++ b/DEPS
@@ -245,11 +245,11 @@ # 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': '575d0c5e1d1122420265ad09ffb3a70a30bb5914', + 'skia_revision': '6dece64b9d7a8b9df41fed0bdde772b7d35b905b', # 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': '9535766935a4e6563f552f1d41bb1c959201d161', + 'v8_revision': '597eaea44e5d7183f961faefcfd7a1cd747d1e0c', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling ANGLE # and whatever else without interference from each other. @@ -292,7 +292,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling freetype # and whatever else without interference from each other. - 'freetype_revision': 'b647dbdeb8d5389a7e05ca5284842b4b757ee723', + 'freetype_revision': 'ee52b57121c2dcb74e0c30d98cdb3bae5b3e7cb9', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling freetype # and whatever else without interference from each other. @@ -300,7 +300,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling HarfBuzz # and whatever else without interference from each other. - 'harfbuzz_revision': 'b8c2c1ab3778755a23ea449ba334959693388687', + 'harfbuzz_revision': '0acf466c44143de2e9b9cc0375cb25ec67cb132f', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling Emoji Segmenter # and whatever else without interference from each other. @@ -320,7 +320,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': '298322adb15e02ae13d0d2b516256c7c71bd4d75', + 'devtools_frontend_revision': 'b598d9c0d6eb5b7d7c0475a10877e89fdfd6a46a', # 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. @@ -360,7 +360,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': '3148b49730b762b130c8e4d90b025d87ebdbf303', + 'dawn_revision': 'bd767283c86d1cc101c89a1f66ebb0c75d8f38d7', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. @@ -617,7 +617,7 @@ Var('chromium_git') + '/external/github.com/toji/webvr.info.git' + '@' + 'c58ae99b9ff9e2aa4c524633519570bf33536248', 'src/docs/website': { - 'url': Var('chromium_git') + '/website.git' + '@' + '258a2f0e63b26255a141c8271f8ca28d74e21cb9', + 'url': Var('chromium_git') + '/website.git' + '@' + 'ea4df8bc39091983ec4f0beb57c5fdf4e8b5f970', }, 'src/ios/third_party/earl_grey2/src': { @@ -722,7 +722,7 @@ 'packages': [ { 'package': 'chromium/rts/model/linux-amd64', - 'version': '2ziIAVPDZxRGVQtk5pg4EtgbsUP7QqpBfaDdELSfCYYC', + 'version': '1FetDdE4jNLqy8fNlge6dIZXQ1VWOkjYXvNdaxCc_foC', }, ], 'dep_type': 'cipd', @@ -1044,7 +1044,7 @@ }, 'src/third_party/depot_tools': - Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '42afe9a2d34e88a5dbad922f493a3d81726a5221', + Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '5fe7c91547a3dedfc0512cb7019c839405a414bd', 'src/third_party/devtools-frontend/src': Var('chromium_git') + '/devtools/devtools-frontend' + '@' + Var('devtools_frontend_revision'), @@ -1583,7 +1583,7 @@ Var('swiftshader_git') + '/SwiftShader.git' + '@' + Var('swiftshader_revision'), 'src/third_party/text-fragments-polyfill/src': { - 'url': Var('chromium_git') + '/external/github.com/GoogleChromeLabs/text-fragments-polyfill.git' + '@' + '0e2ffd03245b31c8cad7f6bbbbce3d95a5bbb49d', + 'url': Var('chromium_git') + '/external/github.com/GoogleChromeLabs/text-fragments-polyfill.git' + '@' + '95de7c17930c0364dc265c08df389e3115263531', 'condition': 'checkout_ios', }, @@ -1645,10 +1645,10 @@ Var('chromium_git') + '/external/khronosgroup/webgl.git' + '@' + 'b1f3776e4913637221733a4da09f3339e783b771', 'src/third_party/webgpu-cts/src': - Var('chromium_git') + '/external/github.com/gpuweb/cts.git' + '@' + 'fca7b339442bd70c5dc49bb33ee7f9466b560a97', + Var('chromium_git') + '/external/github.com/gpuweb/cts.git' + '@' + '72561785742eab5afee480368659cde144bca33c', 'src/third_party/webrtc': - Var('webrtc_git') + '/src.git' + '@' + '6b667a8fe2bbe69c0857c2dd93b66c159c3378f0', + Var('webrtc_git') + '/src.git' + '@' + '1e12f2a800345cf133b30f63dce2a6f8f12f4946', 'src/third_party/libgifcodec': Var('skia_git') + '/libgifcodec' + '@'+ Var('libgifcodec_revision'), @@ -1718,7 +1718,7 @@ Var('chromium_git') + '/v8/v8.git' + '@' + Var('v8_revision'), 'src-internal': { - 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@b9aa1bc1822c8011619775275c799e3a92fce390', + 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@6d566394f19d8bd979c2440c8d6f9ac850b437d6', 'condition': 'checkout_src_internal', },
diff --git a/android_webview/browser/aw_print_manager.cc b/android_webview/browser/aw_print_manager.cc index e73626b..6b6b2cc 100644 --- a/android_webview/browser/aw_print_manager.cc +++ b/android_webview/browser/aw_print_manager.cc
@@ -64,6 +64,8 @@ bool AwPrintManager::PrintNow() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); auto* rfh = web_contents()->GetMainFrame(); + if (!rfh->IsRenderFrameLive()) + return false; GetPrintRenderFrame(rfh)->PrintRequestedPages(); return true; }
diff --git a/android_webview/browser/aw_web_contents_delegate.cc b/android_webview/browser/aw_web_contents_delegate.cc index 814587e..81a42773 100644 --- a/android_webview/browser/aw_web_contents_delegate.cc +++ b/android_webview/browser/aw_web_contents_delegate.cc
@@ -300,14 +300,6 @@ return is_fullscreen_; } -void AwWebContentsDelegate::UpdateUserGestureCarryoverInfo( - content::WebContents* web_contents) { - auto* intercept_navigation_delegate = - navigation_interception::InterceptNavigationDelegate::Get(web_contents); - if (intercept_navigation_delegate) - intercept_navigation_delegate->UpdateLastUserGestureCarryoverTimestamp(); -} - scoped_refptr<content::FileSelectListener> AwWebContentsDelegate::TakeFileSelectListener() { return std::move(file_select_listener_);
diff --git a/android_webview/browser/aw_web_contents_delegate.h b/android_webview/browser/aw_web_contents_delegate.h index e565c40..6d6387d 100644 --- a/android_webview/browser/aw_web_contents_delegate.h +++ b/android_webview/browser/aw_web_contents_delegate.h
@@ -72,8 +72,6 @@ void ExitFullscreenModeForTab(content::WebContents* web_contents) override; bool IsFullscreenForTabOrPending( const content::WebContents* web_contents) override; - void UpdateUserGestureCarryoverInfo( - content::WebContents* web_contents) override; scoped_refptr<content::FileSelectListener> TakeFileSelectListener();
diff --git a/android_webview/support_library/boundary_interfaces/BUILD.gn b/android_webview/support_library/boundary_interfaces/BUILD.gn index 68b6ca52..3938d4e 100644 --- a/android_webview/support_library/boundary_interfaces/BUILD.gn +++ b/android_webview/support_library/boundary_interfaces/BUILD.gn
@@ -20,6 +20,7 @@ "src/org/chromium/support_lib_boundary/StaticsBoundaryInterface.java", "src/org/chromium/support_lib_boundary/TracingControllerBoundaryInterface.java", "src/org/chromium/support_lib_boundary/VisualStateCallbackBoundaryInterface.java", + "src/org/chromium/support_lib_boundary/WebAuthnCallbackBoundaryInterface.java", "src/org/chromium/support_lib_boundary/WebMessageBoundaryInterface.java", "src/org/chromium/support_lib_boundary/WebMessageCallbackBoundaryInterface.java", "src/org/chromium/support_lib_boundary/WebMessageListenerBoundaryInterface.java",
diff --git a/android_webview/support_library/boundary_interfaces/src/org/chromium/support_lib_boundary/WebAuthnCallbackBoundaryInterface.java b/android_webview/support_library/boundary_interfaces/src/org/chromium/support_lib_boundary/WebAuthnCallbackBoundaryInterface.java new file mode 100644 index 0000000..8b6efc1 --- /dev/null +++ b/android_webview/support_library/boundary_interfaces/src/org/chromium/support_lib_boundary/WebAuthnCallbackBoundaryInterface.java
@@ -0,0 +1,18 @@ +// Copyright 2021 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.support_lib_boundary; + +import android.content.Intent; + +/** + * Boundary interface for the response to a WebAuthn intent. + * <p> + * An instance of this object is given to the embedder in <code>onWebAuthnIntent</code>. + * Once the result of the intent is known the method in this interface is called so that the + * embedder can pass the result back into Chromium. + */ +public interface WebAuthnCallbackBoundaryInterface { + void onResult(int resultCode, Intent intent); +}
diff --git a/android_webview/support_library/boundary_interfaces/src/org/chromium/support_lib_boundary/WebSettingsBoundaryInterface.java b/android_webview/support_library/boundary_interfaces/src/org/chromium/support_lib_boundary/WebSettingsBoundaryInterface.java index 426eb6d2..38ee17e 100644 --- a/android_webview/support_library/boundary_interfaces/src/org/chromium/support_lib_boundary/WebSettingsBoundaryInterface.java +++ b/android_webview/support_library/boundary_interfaces/src/org/chromium/support_lib_boundary/WebSettingsBoundaryInterface.java
@@ -41,4 +41,15 @@ void setForceDarkBehavior(@ForceDarkBehavior int forceDarkBehavior); @ForceDarkBehavior int getForceDarkBehavior(); + + @Retention(RetentionPolicy.SOURCE) + @interface WebAuthnSupport { + int NONE = 0; + int APP = 1; + int BROWSER = 2; + } + + void setWebAuthnSupport(@WebAuthnSupport int support); + @WebAuthnSupport + int getWebAuthnSupport(); }
diff --git a/android_webview/support_library/boundary_interfaces/src/org/chromium/support_lib_boundary/WebViewClientBoundaryInterface.java b/android_webview/support_library/boundary_interfaces/src/org/chromium/support_lib_boundary/WebViewClientBoundaryInterface.java index 9cdde0d8..fc60168 100644 --- a/android_webview/support_library/boundary_interfaces/src/org/chromium/support_lib_boundary/WebViewClientBoundaryInterface.java +++ b/android_webview/support_library/boundary_interfaces/src/org/chromium/support_lib_boundary/WebViewClientBoundaryInterface.java
@@ -4,6 +4,7 @@ package org.chromium.support_lib_boundary; +import android.app.PendingIntent; import android.webkit.WebResourceRequest; import android.webkit.WebResourceResponse; import android.webkit.WebView; @@ -22,4 +23,6 @@ void onSafeBrowsingHit(WebView view, WebResourceRequest request, int threatType, /* SafeBrowsingResponse */ InvocationHandler callback); boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request); + boolean onWebAuthnIntent(WebView view, PendingIntent intent, + /* WebAuthnCallbackBoundaryInterface */ InvocationHandler callback); }
diff --git a/android_webview/support_library/boundary_interfaces/src/org/chromium/support_lib_boundary/util/Features.java b/android_webview/support_library/boundary_interfaces/src/org/chromium/support_lib_boundary/util/Features.java index 3038a4f..d2b8ec9 100644 --- a/android_webview/support_library/boundary_interfaces/src/org/chromium/support_lib_boundary/util/Features.java +++ b/android_webview/support_library/boundary_interfaces/src/org/chromium/support_lib_boundary/util/Features.java
@@ -185,4 +185,8 @@ // WebViewCompat.addDocumentStartJavascript public static final String DOCUMENT_START_SCRIPT = "DOCUMENT_START_SCRIPT"; + + // WebSettingsCompat.setWebAuthnSupport + // WebSettingsCompat.getWebAuthnSupport + public static final String WEB_AUTHENTICATION = "WEB_AUTHENTICATION"; }
diff --git a/android_webview/support_library/java/src/org/chromium/support_lib_glue/SupportLibWebSettingsAdapter.java b/android_webview/support_library/java/src/org/chromium/support_lib_glue/SupportLibWebSettingsAdapter.java index 14c40f2..4ff898e9 100644 --- a/android_webview/support_library/java/src/org/chromium/support_lib_glue/SupportLibWebSettingsAdapter.java +++ b/android_webview/support_library/java/src/org/chromium/support_lib_glue/SupportLibWebSettingsAdapter.java
@@ -109,4 +109,15 @@ } return ForceDarkBehavior.PREFER_MEDIA_QUERY_OVER_FORCE_DARK; } + + @Override + public void setWebAuthnSupport(int support) { + // Currently a no-op while this functionality is built out. + } + + @Override + public int getWebAuthnSupport() { + // Currently a no-op while this functionality is built out. + return WebAuthnSupport.NONE; + } }
diff --git a/ash/BUILD.gn b/ash/BUILD.gn index 650a614b..e06a240 100644 --- a/ash/BUILD.gn +++ b/ash/BUILD.gn
@@ -167,6 +167,8 @@ "ambient/model/ambient_slideshow_photo_config.cc", "ambient/model/ambient_slideshow_photo_config.h", "ambient/resources/ambient_animation_static_resources.h", + "ambient/ui/ambient_animation_view.cc", + "ambient/ui/ambient_animation_view.h", "ambient/ui/ambient_background_image_view.cc", "ambient/ui/ambient_background_image_view.h", "ambient/ui/ambient_container_view.cc", @@ -2003,6 +2005,7 @@ "//ui/gfx", "//ui/gfx/geometry", "//ui/gfx/geometry/mojom", + "//ui/lottie", "//ui/resources", "//ui/strings", "//ui/views", @@ -2280,6 +2283,7 @@ "ambient/model/ambient_animation_photo_config_unittest.cc", "ambient/model/ambient_animation_photo_provider_unittest.cc", "ambient/model/ambient_backend_model_unittest.cc", + "ambient/ui/ambient_animation_view_unittest.cc", "ambient/ui/ambient_container_view_unittest.cc", "ambient/ui/media_string_view_unittest.cc", "ambient/ui/photo_view_unittest.cc", @@ -2940,6 +2944,8 @@ "ambient/test/ambient_test_util.h", "ambient/test/fake_ambient_animation_static_resources.cc", "ambient/test/fake_ambient_animation_static_resources.h", + "ambient/test/mock_ambient_view_event_handler.cc", + "ambient/test/mock_ambient_view_event_handler.h", "ambient/test/test_ambient_client.cc", "ambient/test/test_ambient_client.h", "app_list/app_list_test_api.cc",
diff --git a/ash/ambient/DEPS b/ash/ambient/DEPS index 32791e2c..6e01ae7 100644 --- a/ash/ambient/DEPS +++ b/ash/ambient/DEPS
@@ -6,4 +6,7 @@ "ambient_controller.cc": [ "+chromeos/assistant/buildflags.h", ], + ".*test.cc": [ + "+cc/test", + ], }
diff --git a/ash/ambient/model/ambient_photo_config.h b/ash/ambient/model/ambient_photo_config.h index 3f8766af..84f41326 100644 --- a/ash/ambient/model/ambient_photo_config.h +++ b/ash/ambient/model/ambient_photo_config.h
@@ -68,7 +68,8 @@ // single paired topic. It may need to prepare 2 topics at a time. }; -std::ostream& operator<<(std::ostream& os, AmbientPhotoConfig::Marker marker); +ASH_EXPORT std::ostream& operator<<(std::ostream& os, + AmbientPhotoConfig::Marker marker); } // namespace ash
diff --git a/ash/ambient/test/fake_ambient_animation_static_resources.cc b/ash/ambient/test/fake_ambient_animation_static_resources.cc index 62a2d7a6..a1df775 100644 --- a/ash/ambient/test/fake_ambient_animation_static_resources.cc +++ b/ash/ambient/test/fake_ambient_animation_static_resources.cc
@@ -17,6 +17,11 @@ FakeAmbientAnimationStaticResources::~FakeAmbientAnimationStaticResources() = default; +void FakeAmbientAnimationStaticResources::SetLottieData( + std::string lottie_data) { + lottie_data_ = std::move(lottie_data); +} + void FakeAmbientAnimationStaticResources::SetStaticImageAsset( base::StringPiece asset_id, gfx::ImageSkia image) { @@ -24,8 +29,7 @@ } base::StringPiece FakeAmbientAnimationStaticResources::GetLottieData() const { - NOTIMPLEMENTED(); - return base::StringPiece(); + return lottie_data_; } gfx::ImageSkia FakeAmbientAnimationStaticResources::GetStaticImageAsset(
diff --git a/ash/ambient/test/fake_ambient_animation_static_resources.h b/ash/ambient/test/fake_ambient_animation_static_resources.h index 2b099b6..6c0b1ca 100644 --- a/ash/ambient/test/fake_ambient_animation_static_resources.h +++ b/ash/ambient/test/fake_ambient_animation_static_resources.h
@@ -6,6 +6,7 @@ #define ASH_AMBIENT_TEST_FAKE_AMBIENT_ANIMATION_STATIC_RESOURCES_H_ #include <memory> +#include <string> #include "ash/ambient/resources/ambient_animation_static_resources.h" #include "ash/ash_export.h" @@ -28,6 +29,10 @@ const FakeAmbientAnimationStaticResources&) = delete; ~FakeAmbientAnimationStaticResources() override; + // Sets the output for all future calls to GetLottieData(). If not set, + // GetLottieData() will return an empty string. + void SetLottieData(std::string lottie_data); + // Sets the |image| that will be returned in future calls to // GetStaticImageAsset(asset_id). If the image is not set for an asset, // GetStaticImageAsset() will return a null image. @@ -38,6 +43,7 @@ gfx::ImageSkia GetStaticImageAsset(base::StringPiece asset_id) const override; private: + std::string lottie_data_; base::flat_map</*asset_id*/ std::string, gfx::ImageSkia> images_; };
diff --git a/ash/ambient/test/mock_ambient_view_event_handler.cc b/ash/ambient/test/mock_ambient_view_event_handler.cc new file mode 100644 index 0000000..08b686c --- /dev/null +++ b/ash/ambient/test/mock_ambient_view_event_handler.cc
@@ -0,0 +1,13 @@ +// 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 "ash/ambient/test/mock_ambient_view_event_handler.h" + +namespace ash { + +MockAmbientViewEventHandler::MockAmbientViewEventHandler() = default; + +MockAmbientViewEventHandler::~MockAmbientViewEventHandler() = default; + +} // namespace ash
diff --git a/ash/ambient/test/mock_ambient_view_event_handler.h b/ash/ambient/test/mock_ambient_view_event_handler.h new file mode 100644 index 0000000..261e11b --- /dev/null +++ b/ash/ambient/test/mock_ambient_view_event_handler.h
@@ -0,0 +1,29 @@ +// 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 ASH_AMBIENT_TEST_MOCK_AMBIENT_VIEW_EVENT_HANDLER_H_ +#define ASH_AMBIENT_TEST_MOCK_AMBIENT_VIEW_EVENT_HANDLER_H_ + +#include "ash/ambient/ui/ambient_view_delegate.h" +#include "testing/gmock/include/gmock/gmock.h" + +namespace ash { + +class MockAmbientViewEventHandler : public AmbientViewEventHandler { + public: + MockAmbientViewEventHandler(); + MockAmbientViewEventHandler(const MockAmbientViewEventHandler&) = delete; + MockAmbientViewEventHandler& operator=(const MockAmbientViewEventHandler&) = + delete; + ~MockAmbientViewEventHandler(); + + MOCK_METHOD(void, + OnMarkerHit, + (AmbientPhotoConfig::Marker marker), + (override)); +}; + +} // namespace ash + +#endif // ASH_AMBIENT_TEST_MOCK_AMBIENT_VIEW_EVENT_HANDLER_H_
diff --git a/ash/ambient/ui/ambient_animation_view.cc b/ash/ambient/ui/ambient_animation_view.cc new file mode 100644 index 0000000..1cda0cec --- /dev/null +++ b/ash/ambient/ui/ambient_animation_view.cc
@@ -0,0 +1,85 @@ +// 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 "ash/ambient/ui/ambient_animation_view.h" + +#include <cstdint> +#include <utility> +#include <vector> + +#include "ash/ambient/model/ambient_backend_model.h" +#include "ash/ambient/model/ambient_photo_config.h" +#include "ash/ambient/resources/ambient_animation_static_resources.h" +#include "ash/ambient/ui/ambient_view_delegate.h" +#include "base/check.h" +#include "base/containers/span.h" +#include "base/logging.h" +#include "cc/paint/skottie_color_map.h" +#include "cc/paint/skottie_wrapper.h" +#include "ui/base/metadata/metadata_impl_macros.h" +#include "ui/lottie/animation.h" +#include "ui/views/controls/animated_image_view.h" +#include "ui/views/controls/image_view.h" +#include "ui/views/layout/fill_layout.h" + +namespace ash { + +AmbientAnimationView::AmbientAnimationView( + const AmbientBackendModel* model, + AmbientViewEventHandler* event_handler, + std::unique_ptr<const AmbientAnimationStaticResources> static_resources) + : event_handler_(event_handler), + static_resources_(std::move(static_resources)), + animation_photo_provider_(static_resources_.get(), model) { + Init(); +} + +AmbientAnimationView::~AmbientAnimationView() = default; + +void AmbientAnimationView::Init() { + SetUseDefaultFillLayout(true); + animated_image_view_ = + AddChildView(std::make_unique<views::AnimatedImageView>()); + base::span<const uint8_t> lottie_data_bytes = + base::as_bytes(base::make_span(static_resources_->GetLottieData())); + // Create a serializable SkottieWrapper since the SkottieWrapper may have to + // be serialized and transmitted over IPC for out-of-process rasterization. + auto animation = std::make_unique<lottie::Animation>( + cc::SkottieWrapper::CreateSerializable(std::vector<uint8_t>( + lottie_data_bytes.begin(), lottie_data_bytes.end())), + cc::SkottieColorMap(), &animation_photo_provider_); + animation->SetAnimationObserver(this); + animated_image_view_->SetAnimatedImage(std::move(animation)); +} + +void AmbientAnimationView::AnimationWillStartPlaying( + const lottie::Animation* animation) { + event_handler_->OnMarkerHit(AmbientPhotoConfig::Marker::kUiStartRendering); +} + +void AmbientAnimationView::AnimationCycleEnded( + const lottie::Animation* animation) { + event_handler_->OnMarkerHit(AmbientPhotoConfig::Marker::kUiCycleEnded); +} + +void AmbientAnimationView::OnBoundsChanged(const gfx::Rect& previous_bounds) { + DVLOG(4) << __func__ << " from " << previous_bounds.ToString() << " to " + << bounds().ToString(); + if (size().IsEmpty()) + return; + + // By default, the |animated_image_view_| will render the animation with the + // fixed dimensions specified in the Lottie file. To render the animation + // at the view's full bounds, wait for the view's initial layout to happen + // so that its proper bounds become available (they are 0x0 initially) before + // starting the animation playback. + DVLOG(4) << "View bounds available. Beginning rendering..."; + animated_image_view_->SetImageSize(size()); + animated_image_view_->Play(); +} + +BEGIN_METADATA(AmbientAnimationView, views::View) +END_METADATA + +} // namespace ash
diff --git a/ash/ambient/ui/ambient_animation_view.h b/ash/ambient/ui/ambient_animation_view.h new file mode 100644 index 0000000..f390852 --- /dev/null +++ b/ash/ambient/ui/ambient_animation_view.h
@@ -0,0 +1,57 @@ +// 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 ASH_AMBIENT_UI_AMBIENT_ANIMATION_VIEW_H_ +#define ASH_AMBIENT_UI_AMBIENT_ANIMATION_VIEW_H_ + +#include <memory> + +#include "ash/ambient/model/ambient_animation_photo_provider.h" +#include "ash/ash_export.h" +#include "ui/lottie/animation_observer.h" +#include "ui/views/view.h" + +namespace views { +class AnimatedImageView; +} // namespace views + +namespace ash { + +class AmbientAnimationStaticResources; +class AmbientBackendModel; +class AmbientViewEventHandler; + +class ASH_EXPORT AmbientAnimationView : public views::View, + public lottie::AnimationObserver { + public: + METADATA_HEADER(AmbientAnimationView); + + AmbientAnimationView( + const AmbientBackendModel* model, + AmbientViewEventHandler* event_handler, + std::unique_ptr<const AmbientAnimationStaticResources> static_resources); + AmbientAnimationView(const AmbientAnimationView&) = delete; + AmbientAnimationView& operator=(AmbientAnimationView&) = delete; + ~AmbientAnimationView() override; + + private: + void Init(); + + void AnimationWillStartPlaying(const lottie::Animation* animation) override; + void AnimationCycleEnded(const lottie::Animation* animation) override; + + void OnBoundsChanged(const gfx::Rect& previous_bounds) override; + + AmbientViewEventHandler* const event_handler_; + + const std::unique_ptr<const AmbientAnimationStaticResources> + static_resources_; + AmbientAnimationPhotoProvider animation_photo_provider_; + + views::AnimatedImageView* animated_image_view_ = nullptr; +}; + +} // namespace ash + +#endif // ASH_AMBIENT_UI_AMBIENT_ANIMATION_VIEW_H_
diff --git a/ash/ambient/ui/ambient_animation_view_unittest.cc b/ash/ambient/ui/ambient_animation_view_unittest.cc new file mode 100644 index 0000000..7dc98b8 --- /dev/null +++ b/ash/ambient/ui/ambient_animation_view_unittest.cc
@@ -0,0 +1,129 @@ +// 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 "ash/ambient/ui/ambient_animation_view.h" + +#include <memory> + +#include "ash/ambient/model/ambient_animation_photo_config.h" +#include "ash/ambient/model/ambient_backend_model.h" +#include "ash/ambient/test/ambient_test_util.h" +#include "ash/ambient/test/fake_ambient_animation_static_resources.h" +#include "ash/ambient/test/mock_ambient_view_event_handler.h" +#include "base/memory/scoped_refptr.h" +#include "base/test/task_environment.h" +#include "base/time/time.h" +#include "cc/paint/display_item_list.h" +#include "cc/paint/paint_op_buffer.h" +#include "cc/paint/skottie_wrapper.h" +#include "cc/test/lottie_test_data.h" +#include "cc/test/skia_common.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "ui/gfx/geometry/rect.h" +#include "ui/gfx/geometry/size.h" +#include "ui/gfx/image/image_unittest_util.h" +#include "ui/views/test/views_test_base.h" +#include "ui/views/widget/widget.h" + +namespace ash { + +using ::testing::_; +using ::testing::Mock; +using ::testing::NotNull; + +namespace { + +const cc::DrawSkottieOp* FindSkottieOp( + const cc::PaintOpBuffer& paint_op_buffer) { + for (const cc::PaintOp* op : cc::PaintOpBuffer::Iterator(&paint_op_buffer)) { + if (op->GetType() == cc::PaintOpType::DrawSkottie) + return static_cast<const cc::DrawSkottieOp*>(op); + + if (op->GetType() == cc::PaintOpType::DrawRecord) { + const cc::DrawSkottieOp* skottie_op = + FindSkottieOp(*static_cast<const cc::DrawRecordOp*>(op)->record); + if (skottie_op) + return skottie_op; + } + } + return nullptr; +} + +} // namespace + +class AmbientAnimationViewTest : public views::ViewsTestBase { + protected: + AmbientAnimationViewTest() + : views::ViewsTestBase( + base::test::TaskEnvironment::TimeSource::MOCK_TIME) {} + + void SetUp() override { + ViewsTestBase::SetUp(); + + auto static_resources = + std::make_unique<FakeAmbientAnimationStaticResources>(); + static_resources->SetLottieData(cc::CreateCustomLottieDataWith2Assets( + GenerateTestLottieDynamicAssetId(/*unique_id=*/0), + GenerateTestLottieDynamicAssetId(/*unique_id=*/1))); + + model_ = + std::make_unique<AmbientBackendModel>(CreateAmbientAnimationPhotoConfig( + cc::CreateSkottieFromString(static_resources->GetLottieData()) + ->GetImageAssetMetadata())); + PhotoWithDetails image; + image.photo = gfx::test::CreateImageSkia(100, 100); + model_->AddNextImage(image); + model_->AddNextImage(image); + + widget_ = CreateTestWidget(); + view_ = widget_->GetRootView()->AddChildView( + std::make_unique<AmbientAnimationView>(model_.get(), &event_handler_, + std::move(static_resources))); + } + + MockAmbientViewEventHandler event_handler_; + std::unique_ptr<AmbientBackendModel> model_; + std::unique_ptr<views::Widget> widget_; + AmbientAnimationView* view_; +}; + +TEST_F(AmbientAnimationViewTest, NotifiesDelegateOfAnimationCycleMarkers) { + view_->SetBoundsRect(widget_->GetWindowBoundsInScreen()); + widget_->Show(); + + EXPECT_CALL(event_handler_, + OnMarkerHit(AmbientPhotoConfig::Marker::kUiStartRendering)); + task_environment()->FastForwardBy(cc::kLottieDataWith2AssetsDuration * 0.1); + Mock::VerifyAndClearExpectations(&event_handler_); + + EXPECT_CALL(event_handler_, + OnMarkerHit(AmbientPhotoConfig::Marker::kUiCycleEnded)); + task_environment()->FastForwardBy(cc::kLottieDataWith2AssetsDuration); + Mock::VerifyAndClearExpectations(&event_handler_); + + EXPECT_CALL(event_handler_, + OnMarkerHit(AmbientPhotoConfig::Marker::kUiCycleEnded)); + task_environment()->FastForwardBy(cc::kLottieDataWith2AssetsDuration); + Mock::VerifyAndClearExpectations(&event_handler_); +} + +TEST_F(AmbientAnimationViewTest, WaitsForViewBoundariesBeforeRendering) { + gfx::Rect widget_bounds = widget_->GetWindowBoundsInScreen(); + + widget_->Show(); + + EXPECT_CALL(event_handler_, OnMarkerHit(_)).Times(0); + task_environment()->FastForwardBy(cc::kLottieDataWith2AssetsDuration * 0.1); + Mock::VerifyAndClearExpectations(&event_handler_); + + view_->SetBoundsRect(widget_bounds); + + EXPECT_CALL(event_handler_, + OnMarkerHit(AmbientPhotoConfig::Marker::kUiStartRendering)); + task_environment()->FastForwardBy(cc::kLottieDataWith2AssetsDuration * 0.1); + Mock::VerifyAndClearExpectations(&event_handler_); +} + +} // namespace ash
diff --git a/ash/app_list/views/search_result_list_view_unittest.cc b/ash/app_list/views/search_result_list_view_unittest.cc index edb371e..0c3a243 100644 --- a/ash/app_list/views/search_result_list_view_unittest.cc +++ b/ash/app_list/views/search_result_list_view_unittest.cc
@@ -14,10 +14,12 @@ #include "ash/app_list/model/search/search_model.h" #include "ash/app_list/model/search/test_search_result.h" #include "ash/app_list/views/search_result_view.h" +#include "ash/constants/ash_features.h" #include "ash/public/cpp/app_list/app_list_features.h" #include "ash/public/cpp/test/test_app_list_color_provider.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "base/test/scoped_feature_list.h" #include "ui/views/test/views_test_base.h" #include "ui/views/test/widget_test.h" @@ -25,7 +27,7 @@ namespace test { namespace { -int kDefaultSearchItems = 5; +int kDefaultSearchItems = 3; // Preferred sizing for different types of search result views. constexpr int kPreferredWidth = 640; @@ -44,7 +46,9 @@ } // namespace -class SearchResultListViewTest : public views::test::WidgetTest { +class SearchResultListViewTest : public views::test::WidgetTest, + + public testing::WithParamInterface<bool> { public: SearchResultListViewTest() = default; @@ -55,6 +59,8 @@ // Overridden from testing::Test: void SetUp() override { + scoped_feature_list_.InitWithFeatureState(features::kProductivityLauncher, + IsProductivityLauncherEnabled()); views::test::WidgetTest::SetUp(); widget_ = CreateTopLevelPlatformWidget(); @@ -95,6 +101,7 @@ } protected: + bool IsProductivityLauncherEnabled() const { return GetParam(); } SearchResultListView* unified_view() const { return unified_view_.get(); } SearchResultListView* default_view() const { return default_view_.get(); } SearchResultListView* answer_card_view() const { @@ -147,6 +154,7 @@ std::make_unique<TestSearchResult>(); result->set_display_type(ash::SearchResultDisplayType::kList); result->set_title(base::UTF8ToUTF16(base::StringPrintf("Result %d", i))); + result->set_best_match(true); if (i < 2) result->set_details(u"Detail"); results->Add(std::move(result)); @@ -165,8 +173,12 @@ int GetUnifiedViewResultCount() const { return unified_view_->num_results(); } - void AddTestResultAtIndex(int index) { - GetResults()->Add(std::make_unique<TestSearchResult>()); + void AddTestResult() { + std::unique_ptr<TestSearchResult> result = + std::make_unique<TestSearchResult>(); + result->set_display_type(ash::SearchResultDisplayType::kList); + result->set_best_match(true); + GetResults()->Add(std::move(result)); } void DeleteResultAt(int index) { GetResults()->DeleteAt(index); } @@ -177,18 +189,22 @@ } void ExpectConsistent() { - // Adding results will schedule Update(). RunPendingMessages(); - SearchModel::SearchResults* results = GetResults(); + for (size_t i = 0; i < results->item_count(); ++i) { - EXPECT_EQ(results->GetItemAt(i), GetUnifiedResultViewAt(i)->result()); + SearchResultView* result_view = IsProductivityLauncherEnabled() + ? GetDefaultResultViewAt(i) + : GetUnifiedResultViewAt(i); + ASSERT_TRUE(result_view) << "result view at " << i; + EXPECT_EQ(results->GetItemAt(i), result_view->result()); } } void DoUpdate() { unified_view()->DoUpdate(); } private: + base::test::ScopedFeatureList scoped_feature_list_; TestAppListColorProvider color_provider_; // Needed by AppListView. AppListTestViewDelegate view_delegate_; std::unique_ptr<SearchResultListView> unified_view_; @@ -197,7 +213,11 @@ views::Widget* widget_; }; -TEST_F(SearchResultListViewTest, SpokenFeedback) { +// Run search result list view tests with and without productivity launcher +// enabled. +INSTANTIATE_TEST_SUITE_P(All, SearchResultListViewTest, testing::Bool()); + +TEST_P(SearchResultListViewTest, SpokenFeedback) { SetUpSearchResults(); // Result 0 has a detail text. Expect that the detail is appended to the @@ -209,7 +229,7 @@ EXPECT_EQ(u"Result 2", GetUnifiedResultViewAt(2)->ComputeAccessibleName()); } -TEST_F(SearchResultListViewTest, CorrectEnumLength) { +TEST_P(SearchResultListViewTest, CorrectEnumLength) { EXPECT_EQ( // Check that all types except for SearchResultListType::kUnified are // included in GetAllListTypesForCategoricalSearch. @@ -227,7 +247,7 @@ 1 /*0 indexing offset*/ - num_category_without_list_type); } -TEST_F(SearchResultListViewTest, SearchResultViewLayout) { +TEST_P(SearchResultListViewTest, SearchResultViewLayout) { // Set SearchResultListView bounds and check views are default size. unified_view()->SetBounds(0, 0, kPreferredWidth, 400); SetUpSearchResults(); @@ -261,7 +281,7 @@ views::LayoutOrientation::kHorizontal); } -TEST_F(SearchResultListViewTest, BorderTest) { +TEST_P(SearchResultListViewTest, BorderTest) { unified_view()->SetBounds(0, 0, kPreferredWidth, 400); SetUpSearchResults(); DoUpdate(); @@ -271,7 +291,7 @@ EXPECT_EQ(gfx::Insets(), GetDefaultResultViewAt(0)->GetBorder()->GetInsets()); } -TEST_F(SearchResultListViewTest, ModelObservers) { +TEST_P(SearchResultListViewTest, ModelObservers) { SetUpSearchResults(); ExpectConsistent(); @@ -279,16 +299,14 @@ DeleteResultAt(kDefaultSearchItems - 1); ExpectConsistent(); - // Insert at start. - AddTestResultAtIndex(0); + AddTestResult(); ExpectConsistent(); // Remove from end. DeleteResultAt(kDefaultSearchItems - 1); ExpectConsistent(); - // Insert at end. - AddTestResultAtIndex(kDefaultSearchItems); + AddTestResult(); ExpectConsistent(); // Delete from start. @@ -296,7 +314,7 @@ ExpectConsistent(); } -TEST_F(SearchResultListViewTest, HidesAssistantResultWhenTilesVisible) { +TEST_P(SearchResultListViewTest, HidesAssistantResultWhenTilesVisible) { SetUpSearchResults(); // No assistant results available.
diff --git a/ash/components/fwupd/firmware_update_manager.cc b/ash/components/fwupd/firmware_update_manager.cc index 191c082..da938f3 100644 --- a/ash/components/fwupd/firmware_update_manager.cc +++ b/ash/components/fwupd/firmware_update_manager.cc
@@ -407,6 +407,8 @@ chromeos::FwupdDeviceList* devices) { DCHECK(devices); DCHECK(!HasPendingUpdates()); + // Clear all cached updates prior to fetching the new update list. + updates_.clear(); // Fire the observer with an empty list if there are no devices in the // response.
diff --git a/ash/components/fwupd/firmware_update_manager.h b/ash/components/fwupd/firmware_update_manager.h index 5f26edc..9cef6bb 100644 --- a/ash/components/fwupd/firmware_update_manager.h +++ b/ash/components/fwupd/firmware_update_manager.h
@@ -134,6 +134,8 @@ fake_url_for_testing_ = fake_url; } + int GetNumUpdatesForTesting() { return updates_.size(); } + // Resets the mojo::Receiver |install_controller_receiver_| // and |update_progress_observer_|. void ResetInstallState();
diff --git a/ash/components/fwupd/firmware_update_manager_unittest.cc b/ash/components/fwupd/firmware_update_manager_unittest.cc index 1bf29f72c..05369d3 100644 --- a/ash/components/fwupd/firmware_update_manager_unittest.cc +++ b/ash/components/fwupd/firmware_update_manager_unittest.cc
@@ -169,6 +169,12 @@ loop.Run(); } + int GetNumUpdatesCached() { + return firmware_update_manager_->GetNumUpdatesForTesting(); + } + + void RequestDevices() { firmware_update_manager_->RequestDevices(); } + void SetFakeUrlForTesting(const std::string& fake_url) { firmware_update_manager_->SetFakeUrlForTesting(fake_url); } @@ -442,6 +448,34 @@ EXPECT_EQ(kFakeUpdateFileNameForTesting, updates[0]->filepath.value()); } +TEST_F(FirmwareUpdateManagerTest, RequestUpdatesClearsCache) { + EXPECT_CALL(*proxy_, DoCallMethodWithErrorResponse(_, _, _)) + .WillRepeatedly(Invoke(this, &FirmwareUpdateManagerTest::OnMethodCalled)); + + dbus_responses_.push_back(CreateOneDeviceResponse()); + dbus_responses_.push_back(CreateOneUpdateResponse()); + FakeUpdateObserver update_observer; + SetupObserver(&update_observer); + const std::vector<firmware_update::mojom::FirmwareUpdatePtr>& updates = + update_observer.updates(); + + base::RunLoop().RunUntilIdle(); + ASSERT_EQ(1U, updates.size()); + ASSERT_EQ(1, GetNumUpdatesCached()); + + dbus_responses_.push_back(CreateOneDeviceResponse()); + dbus_responses_.push_back(CreateOneUpdateResponse()); + + RequestDevices(); + base::RunLoop().RunUntilIdle(); + + // Expect cache to clear and only 1 updates now instead of 2. + const std::vector<firmware_update::mojom::FirmwareUpdatePtr>& new_updates = + update_observer.updates(); + ASSERT_EQ(1U, new_updates.size()); + ASSERT_EQ(1, GetNumUpdatesCached()); +} + TEST_F(FirmwareUpdateManagerTest, RequestAllUpdatesTwoDeviceOneWithUpdate) { EXPECT_CALL(*proxy_, DoCallMethodWithErrorResponse(_, _, _)) .WillRepeatedly(Invoke(this, &FirmwareUpdateManagerTest::OnMethodCalled));
diff --git a/ash/constants/ash_features.cc b/ash/constants/ash_features.cc index 1a1bb2a..db44b09 100644 --- a/ash/constants/ash_features.cc +++ b/ash/constants/ash_features.cc
@@ -383,7 +383,7 @@ // Enables or disables Sync for desk templates on Chrome OS. const base::Feature kDeskTemplateSync{"DeskTemplateSync", - base::FEATURE_DISABLED_BY_DEFAULT}; + base::FEATURE_ENABLED_BY_DEFAULT}; const base::Feature kDesksTemplates{"DesksTemplates", base::FEATURE_DISABLED_BY_DEFAULT};
diff --git a/ash/quick_pair/common/fast_pair/fast_pair_feature_usage_metrics_logger.cc b/ash/quick_pair/common/fast_pair/fast_pair_feature_usage_metrics_logger.cc index ff7efff3..81fed02 100644 --- a/ash/quick_pair/common/fast_pair/fast_pair_feature_usage_metrics_logger.cc +++ b/ash/quick_pair/common/fast_pair/fast_pair_feature_usage_metrics_logger.cc
@@ -32,6 +32,24 @@ return true; } +absl::optional<bool> FastPairFeatureUsageMetricsLogger::IsAccessible() const { + PrefService* pref_service = + QuickPairBrowserDelegate::Get()->GetActivePrefService(); + + if (!pref_service) + return false; + + // |PrefService::IsManagedPreference()| determines if a feature is set by + // enterprise policy. If Fast Pair is not controlled by enterprise policy, + // then the feature is accessible. + if (!pref_service->IsManagedPreference(ash::prefs::kFastPairEnabled)) + return true; + + // If the feature is controlled by enterprise policy, then we match + // |IsAccessible| to whether the feature is enabled or disabled by policy. + return pref_service->GetBoolean(ash::prefs::kFastPairEnabled); +} + bool FastPairFeatureUsageMetricsLogger::IsEnabled() const { PrefService* pref_service = QuickPairBrowserDelegate::Get()->GetActivePrefService();
diff --git a/ash/quick_pair/common/fast_pair/fast_pair_feature_usage_metrics_logger.h b/ash/quick_pair/common/fast_pair/fast_pair_feature_usage_metrics_logger.h index 38a1003..794deea 100644 --- a/ash/quick_pair/common/fast_pair/fast_pair_feature_usage_metrics_logger.h +++ b/ash/quick_pair/common/fast_pair/fast_pair_feature_usage_metrics_logger.h
@@ -7,6 +7,7 @@ #include "base/component_export.h" #include "chromeos/components/feature_usage/feature_usage_metrics.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace ash { namespace quick_pair { @@ -27,6 +28,7 @@ // feature_usage::FeatureUsageMetrics::Delegate: bool IsEligible() const override; bool IsEnabled() const override; + absl::optional<bool> IsAccessible() const override; void RecordUsage(bool success); private:
diff --git a/ash/quick_pair/common/fast_pair/fast_pair_feature_usage_metrics_logger_unittest.cc b/ash/quick_pair/common/fast_pair/fast_pair_feature_usage_metrics_logger_unittest.cc index d2c6ee7..590cb97 100644 --- a/ash/quick_pair/common/fast_pair/fast_pair_feature_usage_metrics_logger_unittest.cc +++ b/ash/quick_pair/common/fast_pair/fast_pair_feature_usage_metrics_logger_unittest.cc
@@ -36,6 +36,13 @@ pref_service_.SetBoolean(ash::prefs::kFastPairEnabled, is_enabled); } + void SetManagedEnabled(bool is_enabled) { + pref_service_.SetManagedPref(ash::prefs::kFastPairEnabled, + std::make_unique<base::Value>(is_enabled)); + ASSERT_TRUE( + pref_service_.IsManagedPreference(ash::prefs::kFastPairEnabled)); + } + base::test::TaskEnvironment task_environment_; std::unique_ptr<MockQuickPairBrowserDelegate> browser_delegate_; TestingPrefServiceSimple pref_service_; @@ -86,5 +93,36 @@ feature_usage::FeatureUsageMetrics::Event::kUsedWithFailure, 1); } +TEST_F(FastPairFeatureUsageMetricsLoggerTest, IsAccessible_Unmanaged_Enabled) { + FastPairFeatureUsageMetricsLogger feature_usage_metrics; + + EXPECT_TRUE(feature_usage_metrics.IsAccessible().value()); + EXPECT_TRUE(feature_usage_metrics.IsEnabled()); +} + +TEST_F(FastPairFeatureUsageMetricsLoggerTest, IsAccessible_Unmanaged_Disabled) { + FastPairFeatureUsageMetricsLogger feature_usage_metrics; + + SetEnabled(/*is_enabled=*/false); + EXPECT_TRUE(feature_usage_metrics.IsAccessible().value()); + EXPECT_FALSE(feature_usage_metrics.IsEnabled()); +} + +TEST_F(FastPairFeatureUsageMetricsLoggerTest, IsAccessible_Managed_Enabled) { + FastPairFeatureUsageMetricsLogger feature_usage_metrics; + + SetManagedEnabled(/*is_enabled=*/true); + EXPECT_TRUE(feature_usage_metrics.IsAccessible().value()); + EXPECT_TRUE(feature_usage_metrics.IsEnabled()); +} + +TEST_F(FastPairFeatureUsageMetricsLoggerTest, IsAccessible_Managed_Disabled) { + FastPairFeatureUsageMetricsLogger feature_usage_metrics; + + SetManagedEnabled(/*is_enabled=*/false); + EXPECT_FALSE(feature_usage_metrics.IsAccessible().value()); + EXPECT_FALSE(feature_usage_metrics.IsEnabled()); +} + } // namespace quick_pair } // namespace ash
diff --git a/ash/quick_pair/keyed_service/quick_pair_metrics_logger.cc b/ash/quick_pair/keyed_service/quick_pair_metrics_logger.cc index bdf8abf..93ee916 100644 --- a/ash/quick_pair/keyed_service/quick_pair_metrics_logger.cc +++ b/ash/quick_pair/keyed_service/quick_pair_metrics_logger.cc
@@ -129,6 +129,7 @@ *device, FastPairEngagementFlowEvent:: kDiscoveryUiDismissedByUserAfterLearnMorePressed); discovery_learn_more_devices_.erase(device); + feature_usage_metrics_logger_->RecordUsage(/*success=*/true); break; } @@ -142,6 +143,7 @@ *device, FastPairEngagementFlowEvent:: kDiscoveryUiDismissedAfterLearnMorePressed); discovery_learn_more_devices_.erase(device); + feature_usage_metrics_logger_->RecordUsage(/*success=*/true); break; }
diff --git a/ash/system/message_center/ash_notification_view.cc b/ash/system/message_center/ash_notification_view.cc index 4a98fd3..9b5f59a 100644 --- a/ash/system/message_center/ash_notification_view.cc +++ b/ash/system/message_center/ash_notification_view.cc
@@ -828,6 +828,10 @@ // Always hide snooze button in control buttons since we show this snooze // button in actions button view. control_buttons_view()->ShowSnoozeButton(false); + + // Hide settings button for grouped child notifications. + if (is_grouped_child_view_) + control_buttons_view()->ShowSettingsButton(false); } bool AshNotificationView::IsIconViewShown() const { @@ -911,11 +915,16 @@ NotificationViewBase::ToggleInlineSettings(event); - // In settings UI, we only show the app icon and header row along with the - // inline settings UI. - header_row()->SetVisible(true); - left_content()->SetVisible(!should_show_inline_settings); - right_content()->SetVisible(!should_show_inline_settings); + if (is_grouped_parent_view_) { + grouped_notifications_scroll_view_->SetVisible( + !should_show_inline_settings); + } else { + // In settings UI, we only show the app icon and header row along with the + // inline settings UI. + header_row()->SetVisible(true); + left_content()->SetVisible(!should_show_inline_settings); + right_content()->SetVisible(!should_show_inline_settings); + } expand_button_->SetVisible(!should_show_inline_settings); PreferredSizeChanged(); @@ -1252,24 +1261,25 @@ message_center_utils::InitLayerForAnimations(main_right_view_); message_center_utils::InitLayerForAnimations(inline_settings_row()); - message_center_utils::InitLayerForAnimations(left_content()); - message_center_utils::InitLayerForAnimations(icon_view()); // Fade out views. if (should_show_inline_settings) { - message_center_utils::FadeOutView( - left_content(), - base::BindRepeating( - [](base::WeakPtr<ash::AshNotificationView> parent, - views::View* left_content) { - if (parent) { - left_content->layer()->SetOpacity(1.0f); - left_content->SetVisible(false); - } - }, - weak_factory_.GetWeakPtr(), left_content()), - /*delay_in_ms=*/0, kToggleInlineSettingsFadeOutDurationMs); - + // Fade out left_content if it's visible. + if (left_content_->GetVisible()) { + message_center_utils::InitLayerForAnimations(left_content()); + message_center_utils::FadeOutView( + left_content(), + base::BindRepeating( + [](base::WeakPtr<ash::AshNotificationView> parent, + views::View* left_content) { + if (parent) { + left_content->layer()->SetOpacity(1.0f); + left_content->SetVisible(false); + } + }, + weak_factory_.GetWeakPtr(), left_content()), + /*delay_in_ms=*/0, kToggleInlineSettingsFadeOutDurationMs); + } message_center_utils::FadeOutView( expand_button_, base::BindRepeating( @@ -1285,6 +1295,7 @@ // Fade out icon_view() if it exists. if (icon_view()) { + message_center_utils::InitLayerForAnimations(icon_view()); message_center_utils::FadeOutView( icon_view(), base::BindRepeating(
diff --git a/ash/system/message_center/notification_grouping_controller.cc b/ash/system/message_center/notification_grouping_controller.cc index b49cce3a..2973ec4 100644 --- a/ash/system/message_center/notification_grouping_controller.cc +++ b/ash/system/message_center/notification_grouping_controller.cc
@@ -258,6 +258,9 @@ /*delegate=*/nullptr); child_copy->set_timestamp(parent_notification.timestamp() - base::Milliseconds(1)); + child_copy->set_settings_button_handler( + parent_notification.rich_notification_data().settings_button_handler); + child_copy->set_delegate(parent_notification.delegate()); child_copy->SetGroupChild(); return child_copy;
diff --git a/ash/system/message_center/unified_message_list_view.cc b/ash/system/message_center/unified_message_list_view.cc index aabf421..7dcf6f0 100644 --- a/ash/system/message_center/unified_message_list_view.cc +++ b/ash/system/message_center/unified_message_list_view.cc
@@ -145,6 +145,9 @@ control_view_->UpdateCornerRadius(top_radius, bottom_radius); } + // Reset rounding the corner of the view. This is called when we end a slide. + void ResetCornerRadius() { message_view_->UpdateCornerRadius(0, 0); } + // Collapses the notification if its state haven't changed manually by a user. void Collapse() { if (!message_view_->IsManuallyExpandedOrCollapsed()) @@ -255,6 +258,45 @@ // MessageView::Observer: void OnSlideChanged(const std::string& notification_id) override { control_view_->UpdateButtonsVisibility(); + + if (!features::IsNotificationsRefreshEnabled() || + notification_id != GetNotificationId() || + message_view_->GetSlideAmount() == 0 || !need_update_corner_radius_) + return; + + need_update_corner_radius_ = false; + + message_view_->UpdateCornerRadius(kBubbleCornerRadius, kBubbleCornerRadius); + + // Also update `above_view_`'s bottom and `below_view_`'s top corner radius + // when sliding. + int index = list_view_->GetIndexOf(this); + auto list_child_views = list_view_->children(); + + above_view_ = (index == 0) ? nullptr : AsMVC(list_child_views[index - 1]); + if (above_view_) + above_view_->message_view()->UpdateCornerRadius(0, kBubbleCornerRadius); + + below_view_ = (index == static_cast<int>(list_child_views.size()) - 1) + ? nullptr + : AsMVC(list_child_views[index + 1]); + if (below_view_) + below_view_->message_view()->UpdateCornerRadius(kBubbleCornerRadius, 0); + } + + void OnSlideEnded(const std::string& notification_id) override { + if (!features::IsNotificationsRefreshEnabled() || + notification_id != GetNotificationId()) + return; + + // Reset the corner radius of views to their normal state. + ResetCornerRadius(); + if (above_view_ && !above_view_->is_slid_out()) + above_view_->ResetCornerRadius(); + if (below_view_ && !below_view_->is_slid_out()) + below_view_->ResetCornerRadius(); + + need_update_corner_radius_ = true; } void OnPreSlideOut(const std::string& notification_id) override { @@ -323,6 +365,15 @@ // Set to flag the view as requiring an expand or collapse animation. bool needs_bounds_animation_ = false; + // The views directly above or below this view in the list. Used to update + // corner radius when sliding. + MessageViewContainer* above_view_ = nullptr; + MessageViewContainer* below_view_ = nullptr; + + // `need_update_corner_radius_` indicates that we need to update the corner + // radius of the view when sliding. + bool need_update_corner_radius_ = true; + MessageView* const message_view_; UnifiedMessageListView* const list_view_; NotificationSwipeControlView* const control_view_;
diff --git a/ash/system/message_center/unified_message_list_view_unittest.cc b/ash/system/message_center/unified_message_list_view_unittest.cc index 1cf97e3..63006e4 100644 --- a/ash/system/message_center/unified_message_list_view_unittest.cc +++ b/ash/system/message_center/unified_message_list_view_unittest.cc
@@ -51,12 +51,21 @@ bottom_radius); } + float GetSlideAmount() const override { + return slide_amount_.value_or( + message_center::NotificationViewBase::GetSlideAmount()); + } + int top_radius() const { return top_radius_; } int bottom_radius() const { return bottom_radius_; } + void set_slide_amount(float slide_amount) { slide_amount_ = slide_amount; } + private: int top_radius_ = 0; int bottom_radius_ = 0; + + absl::optional<float> slide_amount_; }; class TestUnifiedMessageListView : public UnifiedMessageListView { @@ -739,6 +748,13 @@ UnifiedMessageListViewTest::SetUp(); } + // Start sliding the message view at the given index in the list. + void StartSliding(size_t index) { + auto* message_view = GetMessageViewAt(index); + message_view->set_slide_amount(1); + message_view->OnSlideChanged(/*in_progress=*/true); + } + private: std::unique_ptr<base::test::ScopedFeatureList> scoped_feature_list_; }; @@ -986,4 +1002,81 @@ to_be_collapsed_message_view_container->GetPreferredSize().height()); } +TEST_F(RefreshedUnifiedMessageListView, SlideNotification) { + // Show message list with four notifications. + auto id0 = AddNotification(); + auto id1 = AddNotification(); + auto id2 = AddNotification(); + auto id3 = AddNotification(); + CreateMessageListView(); + + // At first, there should be no rounded corners for any notification. + for (int i = 0; i <= 3; i++) { + EXPECT_EQ(0, GetMessageViewAt(i)->top_radius()); + EXPECT_EQ(0, GetMessageViewAt(i)->bottom_radius()); + } + + // Start sliding notification 2 away. + StartSliding(2); + EXPECT_EQ(kBubbleCornerRadius, GetMessageViewAt(2)->bottom_radius()); + + // Notification 1's bottom corner and notification 3's top corner should also + // be rounded. + EXPECT_EQ(0, GetMessageViewAt(1)->top_radius()); + EXPECT_EQ(kBubbleCornerRadius, GetMessageViewAt(1)->bottom_radius()); + EXPECT_EQ(kBubbleCornerRadius, GetMessageViewAt(3)->top_radius()); + EXPECT_EQ(0, GetMessageViewAt(3)->bottom_radius()); + + // Notification 0 should not change. + EXPECT_EQ(0, GetMessageViewAt(0)->top_radius()); + EXPECT_EQ(0, GetMessageViewAt(0)->bottom_radius()); + + // Slide out notification 2, the 3 notifications left should have no rounded + // corner after slide out done. + MessageCenter::Get()->RemoveNotification(id2, /*by_user=*/true); + FinishSlideOutAnimation(); + AnimateUntilIdle(); + + for (int i = 0; i <= 2; i++) { + EXPECT_EQ(0, GetMessageViewAt(i)->top_radius()); + EXPECT_EQ(0, GetMessageViewAt(i)->bottom_radius()); + } + + // Test with notification 1. Same behavior should happen. + StartSliding(1); + EXPECT_EQ(kBubbleCornerRadius, GetMessageViewAt(1)->top_radius()); + EXPECT_EQ(kBubbleCornerRadius, GetMessageViewAt(1)->bottom_radius()); + EXPECT_EQ(0, GetMessageViewAt(0)->top_radius()); + EXPECT_EQ(kBubbleCornerRadius, GetMessageViewAt(0)->bottom_radius()); + EXPECT_EQ(kBubbleCornerRadius, GetMessageViewAt(2)->top_radius()); + EXPECT_EQ(0, GetMessageViewAt(2)->bottom_radius()); + + // Cancel the slide. Everything goes back to normal. + GetMessageViewAt(1)->OnSlideChanged(/*in_progress=*/false); + for (int i = 0; i <= 2; i++) { + EXPECT_EQ(0, GetMessageViewAt(i)->top_radius()); + EXPECT_EQ(0, GetMessageViewAt(i)->bottom_radius()); + } + + // Test with the top notification. + StartSliding(0); + EXPECT_EQ(kBubbleCornerRadius, GetMessageViewAt(0)->top_radius()); + EXPECT_EQ(kBubbleCornerRadius, GetMessageViewAt(0)->bottom_radius()); + EXPECT_EQ(kBubbleCornerRadius, GetMessageViewAt(1)->top_radius()); + EXPECT_EQ(0, GetMessageViewAt(1)->bottom_radius()); + EXPECT_EQ(0, GetMessageViewAt(2)->top_radius()); + EXPECT_EQ(0, GetMessageViewAt(2)->bottom_radius()); + GetMessageViewAt(0)->OnSlideChanged(/*in_progress=*/false); + + // Test with the bottom notification. + StartSliding(2); + EXPECT_EQ(0, GetMessageViewAt(0)->top_radius()); + EXPECT_EQ(0, GetMessageViewAt(0)->bottom_radius()); + EXPECT_EQ(0, GetMessageViewAt(1)->top_radius()); + EXPECT_EQ(kBubbleCornerRadius, GetMessageViewAt(1)->bottom_radius()); + EXPECT_EQ(kBubbleCornerRadius, GetMessageViewAt(2)->top_radius()); + EXPECT_EQ(kBubbleCornerRadius, GetMessageViewAt(2)->bottom_radius()); + GetMessageViewAt(2)->OnSlideChanged(/*in_progress=*/false); +} + } // namespace ash
diff --git a/ash/webui/firmware_update_ui/firmware_update_app_ui.cc b/ash/webui/firmware_update_ui/firmware_update_app_ui.cc index 7616778..da721fd 100644 --- a/ash/webui/firmware_update_ui/firmware_update_app_ui.cc +++ b/ash/webui/firmware_update_ui/firmware_update_app_ui.cc
@@ -46,6 +46,8 @@ {"cancelButton", IDS_FIRMWARE_CANCEL_BUTTON_TEXT}, {"doneButton", IDS_FIRMWARE_DONE_BUTTON_TEXT}, {"updateButton", IDS_FIRMWARE_UPDATE_BUTTON_TEXT}, + {"updateFailedBodyText", IDS_FIRMWARE_UPDATE_FAILED_BODY_TEXT}, + {"updateFailedTitleText", IDS_FIRMWARE_UPDATE_FAILED_TITLE_TEXT}, {"updating", IDS_FIRMWARE_UPDATING_TEXT}, {"deviceUpToDate", IDS_FIRMWARE_DEVICE_UP_TO_DATE_TEXT}, {"hasBeenUpdated", IDS_FIRMWARE_HAS_BEEN_UPDATED_TEXT},
diff --git a/ash/webui/firmware_update_ui/resources/fake_data.js b/ash/webui/firmware_update_ui/resources/fake_data.js index 95ea08f..88fca11 100644 --- a/ash/webui/firmware_update_ui/resources/fake_data.js +++ b/ash/webui/firmware_update_ui/resources/fake_data.js
@@ -45,6 +45,14 @@ {percentage: 100, state: UpdateState.kSuccess}, ]; +/** @type {!Array<!InstallationProgress>} */ +export const fakeInstallationProgressFailure = [ + {percentage: 33, state: UpdateState.kUpdating}, + {percentage: 66, state: UpdateState.kUpdating}, + {percentage: 100, state: UpdateState.kRestarting}, + {percentage: 100, state: UpdateState.kFailed}, +]; + /** @type {!FirmwareUpdate} */ export const fakeFirmwareUpdate = { deviceId: '1',
diff --git a/ash/webui/firmware_update_ui/resources/fake_update_controller.js b/ash/webui/firmware_update_ui/resources/fake_update_controller.js index ddfcf378..9bfed70c 100644 --- a/ash/webui/firmware_update_ui/resources/fake_update_controller.js +++ b/ash/webui/firmware_update_ui/resources/fake_update_controller.js
@@ -6,7 +6,7 @@ import {assert} from 'chrome://resources/js/assert.m.js'; import {PromiseResolver} from 'chrome://resources/js/promise_resolver.m.js'; -import {fakeFirmwareUpdates, fakeInstallationProgress} from './fake_data.js'; +import {fakeFirmwareUpdates, fakeInstallationProgress, fakeInstallationProgressFailure} from './fake_data.js'; import {FakeUpdateProviderInterface, FirmwareUpdate, InstallationProgress, InstallControllerInterface, UpdateProgressObserver, UpdateProviderInterface, UpdateState} from './firmware_update_types.js'; import {getUpdateProvider, setUseFakeProviders} from './mojo_interface_provider.js'; @@ -55,7 +55,8 @@ this.startUpdatePromise_ = this.observeWithArg_(ON_PROGRESS_CHANGED, this.deviceId_, (update) => { remote.onStatusChanged(update); - if (update.state === UpdateState.kSuccess) { + if (update.state === UpdateState.kSuccess || + update.state === UpdateState.kFailed) { this.isUpdateInProgress_ = false; this.completedFirmwareUpdates_.add(this.deviceId_); this.updateDeviceList_(); @@ -106,7 +107,13 @@ this.observables_.registerObservableWithArg(ON_PROGRESS_CHANGED); // Set up fake installation progress data for each fake firmware update. fakeFirmwareUpdates.flat().forEach(({deviceId}) => { - this.setFakeInstallationProgress(deviceId, fakeInstallationProgress); + // Use the third fake firmware update to mock a failed installalation. + if (deviceId === '3') { + this.setFakeInstallationProgress( + deviceId, fakeInstallationProgressFailure); + } else { + this.setFakeInstallationProgress(deviceId, fakeInstallationProgress); + } }); }
diff --git a/ash/webui/firmware_update_ui/resources/firmware_update_dialog.js b/ash/webui/firmware_update_ui/resources/firmware_update_dialog.js index 8abb2f9..de05c22 100644 --- a/ash/webui/firmware_update_ui/resources/firmware_update_dialog.js +++ b/ash/webui/firmware_update_ui/resources/firmware_update_dialog.js
@@ -206,8 +206,8 @@ * @return {boolean} */ isUpdateDone_() { - // TODO(michaelcheco): Handle failed state. - return this.installationProgress.state === UpdateState.kSuccess; + return this.installationProgress.state === UpdateState.kSuccess || + this.installationProgress.state === UpdateState.kFailed; } /** @@ -230,6 +230,12 @@ body: this.i18n('restartingBodyText'), footer: this.i18n('restartingFooterText'), }, + [UpdateState.kFailed]: { + title: this.i18n( + 'updateFailedTitleText', mojoString16ToString(deviceName)), + body: this.i18n('updateFailedBodyText'), + footer: '', + }, [UpdateState.kSuccess]: { title: this.i18n('deviceUpToDate', mojoString16ToString(deviceName)), body: this.i18n( @@ -253,7 +259,7 @@ } if (this.isUpdateDone_()) { - return this.createDialogContentObj_(UpdateState.kSuccess); + return this.createDialogContentObj_(this.installationProgress.state); } return initialDialogContent; }
diff --git a/ash/webui/projector_app/untrusted_projector_ui.cc b/ash/webui/projector_app/untrusted_projector_ui.cc index c826990..308d322 100644 --- a/ash/webui/projector_app/untrusted_projector_ui.cc +++ b/ash/webui/projector_app/untrusted_projector_ui.cc
@@ -51,7 +51,7 @@ // "wasm-eval" is added to allow wasm. source->OverrideContentSecurityPolicy( network::mojom::CSPDirectiveName::ScriptSrc, - "script-src 'self' 'wasm-eval' 'chrome-untrusted://resources/';"); + "script-src 'self' 'wasm-eval' chrome-untrusted://resources;"); // Need to explicitly set |worker-src| because CSP falls back to |child-src| // which is none. source->OverrideContentSecurityPolicy(
diff --git a/ash/wm/base_state.cc b/ash/wm/base_state.cc index 2a90334..6d9a934 100644 --- a/ash/wm/base_state.cc +++ b/ash/wm/base_state.cc
@@ -35,8 +35,9 @@ return; } if ((window_state->IsTrustedPinned() || window_state->IsPinned()) && - (event->type() != WM_EVENT_NORMAL && event->IsTransitionEvent())) { - // PIN state can be exited only by normal event. + (event->type() != WM_EVENT_NORMAL && event->type() != WM_EVENT_RESTORE && + event->IsTransitionEvent())) { + // PIN state can be exited only by normal event or restore event. return; } @@ -75,6 +76,8 @@ return WindowStateType::kPrimarySnapped; case WM_EVENT_SNAP_SECONDARY: return WindowStateType::kSecondarySnapped; + case WM_EVENT_RESTORE: + return window_state->GetRestoreWindowState(); case WM_EVENT_SHOW_INACTIVE: return WindowStateType::kInactive; case WM_EVENT_PIN:
diff --git a/ash/wm/client_controlled_state.cc b/ash/wm/client_controlled_state.cc index fa5709f..3bbda6c 100644 --- a/ash/wm/client_controlled_state.cc +++ b/ash/wm/client_controlled_state.cc
@@ -59,6 +59,8 @@ const WMEvent* event) { if (!delegate_) return; + + const WMEventType event_type = event->type(); bool pin_transition = window_state->IsTrustedPinned() || window_state->IsPinned() || event->IsPinEvent(); // Pinned State transition is handled on server side. @@ -79,7 +81,7 @@ set_next_bounds_change_animation_type(kAnimationCrossFade); EnterNextState(window_state, next_state_type); - VLOG(1) << "Processing Pinned Transtion: event=" << event->type() + VLOG(1) << "Processing Pinned Transtion: event=" << event_type << ", state=" << old_state_type << "=>" << next_state_type << ", pinned=" << was_pinned << "=>" << window_state->IsPinned() << ", trusted pinned=" << was_trusted_pinned << "=>" @@ -87,54 +89,22 @@ return; } - auto* window = window_state->window(); - switch (event->type()) { + switch (event_type) { case WM_EVENT_NORMAL: case WM_EVENT_MAXIMIZE: case WM_EVENT_MINIMIZE: - case WM_EVENT_FULLSCREEN: { - // Clients handle a window state change asynchronously. So in the case - // that the window is in a transitional state (already snapped but not - // applied to its window state yet), we here skip to pass WM_EVENT. - if (SplitViewController::Get(window)->IsWindowInTransitionalState(window)) - return; - - // Reset window state - window_state->UpdateWindowPropertiesFromStateType(); - WindowStateType next_state = - GetResolvedNextWindowStateType(window_state, event); - VLOG(1) << "Processing State Transtion: event=" << event->type() - << ", state=" << state_type_ << ", next_state=" << next_state; - // Then ask delegate to handle the window state change. - delegate_->HandleWindowStateRequest(window_state, next_state); - break; - } + case WM_EVENT_FULLSCREEN: case WM_EVENT_SNAP_PRIMARY: case WM_EVENT_SNAP_SECONDARY: { - if (window_state->CanSnap()) { - HandleWindowSnapping(window_state, event->type()); - // Get the desired window bounds for the snap state. - gfx::Rect bounds = GetSnappedWindowBoundsInParent( - window, event->type() == WM_EVENT_SNAP_PRIMARY - ? WindowStateType::kPrimarySnapped - : WindowStateType::kSecondarySnapped); - - // We don't want Unminimize() to restore the pre-snapped state during - // the transition. - window->ClearProperty(aura::client::kPreMinimizedShowStateKey); - - window_state->UpdateWindowPropertiesFromStateType(); - WindowStateType next_state = - GetResolvedNextWindowStateType(window_state, event); - VLOG(1) << "Processing State Transtion: event=" << event->type() - << ", state=" << state_type_ << ", next_state=" << next_state; - - // Then ask delegate to set the desired bounds for the snap state. - delegate_->HandleBoundsRequest(window_state, next_state, bounds, - window_state->GetDisplay().id()); - } + WindowStateType next_state = + GetResolvedNextWindowStateType(window_state, event); + UpdateWindowForTransitionEvents(window_state, next_state, event_type); break; } + case WM_EVENT_RESTORE: + UpdateWindowForTransitionEvents( + window_state, window_state->GetRestoreWindowState(), event_type); + break; case WM_EVENT_SHOW_INACTIVE: NOTREACHED(); break; @@ -329,4 +299,50 @@ return next; } +void ClientControlledState::UpdateWindowForTransitionEvents( + WindowState* window_state, + chromeos::WindowStateType next_state_type, + WMEventType event_type) { + aura::Window* window = window_state->window(); + + if (next_state_type == WindowStateType::kPrimarySnapped || + next_state_type == WindowStateType::kSecondarySnapped) { + if (window_state->CanSnap()) { + HandleWindowSnapping(window_state, + next_state_type == WindowStateType::kPrimarySnapped + ? WM_EVENT_SNAP_PRIMARY + : WM_EVENT_SNAP_SECONDARY); + // Get the desired window bounds for the snap state. + gfx::Rect bounds = + GetSnappedWindowBoundsInParent(window, next_state_type); + // We don't want Unminimize() to restore the pre-snapped state during the + // transition. + window->ClearProperty(aura::client::kPreMinimizedShowStateKey); + + window_state->UpdateWindowPropertiesFromStateType(); + VLOG(1) << "Processing State Transtion: event=" << event_type + << ", state=" << state_type_ + << ", next_state=" << next_state_type; + + // Then ask delegate to set the desired bounds for the snap state. + delegate_->HandleBoundsRequest(window_state, next_state_type, bounds, + window_state->GetDisplay().id()); + } + } else { + // Clients handle a window state change asynchronously. So in the case + // that the window is in a transitional state (already snapped but not + // applied to its window state yet), we here skip to pass WM_EVENT. + if (SplitViewController::Get(window)->IsWindowInTransitionalState(window)) + return; + + // Reset window state. + window_state->UpdateWindowPropertiesFromStateType(); + VLOG(1) << "Processing State Transtion: event=" << event_type + << ", state=" << state_type_ << ", next_state=" << next_state_type; + + // Then ask delegate to handle the window state change. + delegate_->HandleWindowStateRequest(window_state, next_state_type); + } +} + } // namespace ash
diff --git a/ash/wm/client_controlled_state.h b/ash/wm/client_controlled_state.h index fadf4c9e..b778e7a3 100644 --- a/ash/wm/client_controlled_state.h +++ b/ash/wm/client_controlled_state.h
@@ -105,6 +105,11 @@ WindowState* window_state, const WMEvent* event); + void UpdateWindowForTransitionEvents( + WindowState* window_state, + chromeos::WindowStateType next_state_type, + WMEventType event_type); + std::unique_ptr<Delegate> delegate_; bool set_bounds_locally_ = false;
diff --git a/ash/wm/lock_window_state.cc b/ash/wm/lock_window_state.cc index bb58a7e0..5481d947 100644 --- a/ash/wm/lock_window_state.cc +++ b/ash/wm/lock_window_state.cc
@@ -58,6 +58,7 @@ case WM_EVENT_SNAP_PRIMARY: case WM_EVENT_SNAP_SECONDARY: case WM_EVENT_NORMAL: + case WM_EVENT_RESTORE: case WM_EVENT_MAXIMIZE: UpdateWindow(window_state, GetMaximizedOrCenteredWindowType(window_state));
diff --git a/ash/wm/overview/overview_item.cc b/ash/wm/overview/overview_item.cc index e5cd36bc..57f072b6 100644 --- a/ash/wm/overview/overview_item.cc +++ b/ash/wm/overview/overview_item.cc
@@ -216,11 +216,11 @@ GetWindow()->SetProperty(kForceVisibleInMiniViewKey, true); DCHECK(item_widget_); - PerformFadeOutLayer(item_widget_->GetLayer()); + item_widget_->GetLayer()->SetOpacity(0.0f); for (aura::Window* transient_child : GetTransientTreeIterator(GetWindow())) { transient_child->SetProperty(kForceVisibleInMiniViewKey, true); - PerformFadeOutLayer(transient_child->layer()); + transient_child->layer()->SetOpacity(0.0f); } item_widget_event_blocker_ =
diff --git a/ash/wm/tablet_mode/tablet_mode_window_manager_unittest.cc b/ash/wm/tablet_mode/tablet_mode_window_manager_unittest.cc index bd3561b..de57214 100644 --- a/ash/wm/tablet_mode/tablet_mode_window_manager_unittest.cc +++ b/ash/wm/tablet_mode/tablet_mode_window_manager_unittest.cc
@@ -1807,4 +1807,87 @@ EXPECT_TRUE(home_screen_window->TargetVisibility()); } +// Test the basic restore behavior in tablet mode. Different with the restore +// behavior in clamshell mode, a window can not be restored to kNormal window +// state if it's maximizable. +TEST_F(TabletModeWindowManagerTest, BasicRestoreBehaviors) { + TabletModeWindowManager* manager = CreateTabletModeWindowManager(); + EXPECT_TRUE(manager); + gfx::Rect rect(10, 10, 200, 50); + std::unique_ptr<aura::Window> window( + CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); + + WindowState* window_state = WindowState::Get(window.get()); + EXPECT_TRUE(window_state->IsMaximized()); + + // Restoring a maximized window in tablet mode will still keep it in maximized + // state. + window_state->Restore(); + EXPECT_TRUE(window_state->IsMaximized()); + + // Transition to kPrimarySnapped window state. + const WMEvent snap_left(WM_EVENT_SNAP_PRIMARY); + window_state->OnWMEvent(&snap_left); + // Restoring a snapped window in tablet mode will change the window back to + // maximized window state. + window_state->Restore(); + EXPECT_TRUE(window_state->IsMaximized()); + + // Transition to kFullscreen window state. + const WMEvent fullscreen_event(WM_EVENT_FULLSCREEN); + window_state->OnWMEvent(&fullscreen_event); + // Restoring a fullscreen window in tablet mode will change the window back to + // maximized window state. + window_state->Restore(); + EXPECT_TRUE(window_state->IsMaximized()); + + // Transition to kMinimized window state. + const WMEvent minimized_event(WM_EVENT_MINIMIZE); + window_state->OnWMEvent(&minimized_event); + window_state->Restore(); + EXPECT_TRUE(window_state->IsMaximized()); + + // Transition to kPrimarySnapped first and then to kFullscreen and then try to + // restore it. + window_state->OnWMEvent(&snap_left); + window_state->OnWMEvent(&fullscreen_event); + window_state->Restore(); + EXPECT_TRUE(window_state->IsSnapped()); + + // Minimize and then restore it will still restore the window back to snapped + // window state. + window_state->OnWMEvent(&minimized_event); + window_state->Restore(); + EXPECT_TRUE(window_state->IsSnapped()); +} + +TEST_F(TabletModeWindowManagerTest, NonMaximizableWindowRestore) { + TabletModeWindowManager* manager = CreateTabletModeWindowManager(); + EXPECT_TRUE(manager); + + gfx::Rect rect(10, 10, 200, 50); + gfx::Size max_size(300, 200); + std::unique_ptr<aura::Window> window(CreateNonMaximizableWindow( + aura::client::WINDOW_TYPE_NORMAL, rect, max_size)); + + WindowState* window_state = WindowState::Get(window.get()); + EXPECT_FALSE(window_state->IsMaximized()); + EXPECT_EQ(window_state->GetStateType(), WindowStateType::kNormal); + + const WMEvent maximize_event(WM_EVENT_MAXIMIZE); + window_state->OnWMEvent(&maximize_event); + EXPECT_EQ(window_state->GetStateType(), WindowStateType::kNormal); + + const WMEvent fullscreen_event(WM_EVENT_FULLSCREEN); + window_state->OnWMEvent(&fullscreen_event); + EXPECT_EQ(window_state->GetStateType(), WindowStateType::kFullscreen); + + window_state->Restore(); + EXPECT_EQ(window_state->GetStateType(), WindowStateType::kNormal); + + // Restoring a kNormal window will keep it in the same kNormal state. + window_state->Restore(); + EXPECT_EQ(window_state->GetStateType(), WindowStateType::kNormal); +} + } // namespace ash
diff --git a/ash/wm/tablet_mode/tablet_mode_window_state.cc b/ash/wm/tablet_mode/tablet_mode_window_state.cc index ca965b8..54d909bd 100644 --- a/ash/wm/tablet_mode/tablet_mode_window_state.cc +++ b/ash/wm/tablet_mode/tablet_mode_window_state.cc
@@ -211,7 +211,7 @@ DCHECK(!snap || SplitViewController::Get(Shell::GetPrimaryRootWindow()) ->CanSnapWindow(window)); state_type_on_attach_ = - snap ? current_state_type_ : GetMaximizedOrCenteredWindowType(state); + snap ? current_state_type_ : state->GetMaximizedOrCenteredWindowType(); // TODO(oshima|sammiequon): consider SplitView scenario. WindowState::ScopedBoundsChangeAnimation bounds_animation( window, entering_tablet_mode && !IsTopWindow(window) @@ -287,9 +287,21 @@ case WM_EVENT_CENTER: case WM_EVENT_NORMAL: case WM_EVENT_MAXIMIZE: - UpdateWindow(window_state, GetMaximizedOrCenteredWindowType(window_state), + UpdateWindow(window_state, + window_state->GetMaximizedOrCenteredWindowType(), true /* animated */); return; + case WM_EVENT_RESTORE: { + // We special handle WM_EVENT_RESTORE event here. + WindowStateType restore_state = window_state->GetRestoreWindowState(); + if (restore_state == WindowStateType::kPrimarySnapped) + DoTabletSnap(window_state, WM_EVENT_SNAP_PRIMARY); + else if (restore_state == WindowStateType::kSecondarySnapped) + DoTabletSnap(window_state, WM_EVENT_SNAP_SECONDARY); + else + UpdateWindow(window_state, restore_state, /*animate=*/true); + break; + } case WM_EVENT_SNAP_PRIMARY: case WM_EVENT_SNAP_SECONDARY: DoTabletSnap(window_state, event->type()); @@ -355,7 +367,7 @@ const WindowStateType new_state = IsSnapped(current_state_type_) ? window_state->GetStateType() - : GetMaximizedOrCenteredWindowType(window_state); + : window_state->GetMaximizedOrCenteredWindowType(); UpdateWindow(window_state, new_state, /*animated=*/true); } break; @@ -459,14 +471,6 @@ } } -WindowStateType TabletModeWindowState::GetMaximizedOrCenteredWindowType( - WindowState* window_state) { - return (window_state->CanMaximize() && - ::wm::GetTransientParent(window_state->window()) == nullptr) - ? WindowStateType::kMaximized - : WindowStateType::kNormal; -} - WindowStateType TabletModeWindowState::GetSnappedWindowStateType( WindowState* window_state, WindowStateType target_state) { @@ -475,7 +479,7 @@ return SplitViewController::Get(Shell::GetPrimaryRootWindow()) ->CanSnapWindow(window_state->window()) ? target_state - : GetMaximizedOrCenteredWindowType(window_state); + : window_state->GetMaximizedOrCenteredWindowType(); } void TabletModeWindowState::UpdateBounds(WindowState* window_state, @@ -523,7 +527,7 @@ SplitViewController* split_view_controller = SplitViewController::Get(window); // If |window| is already snapped in |snap_position|, then unsnap |window|. if (window == split_view_controller->GetSnappedWindow(snap_position)) { - UpdateWindow(window_state, GetMaximizedOrCenteredWindowType(window_state), + UpdateWindow(window_state, window_state->GetMaximizedOrCenteredWindowType(), /*animated=*/true); return; }
diff --git a/ash/wm/tablet_mode/tablet_mode_window_state.h b/ash/wm/tablet_mode/tablet_mode_window_state.h index 1facb7a..70be2e4 100644 --- a/ash/wm/tablet_mode/tablet_mode_window_state.h +++ b/ash/wm/tablet_mode/tablet_mode_window_state.h
@@ -70,11 +70,6 @@ chromeos::WindowStateType new_state_type, bool animate); - // Depending on the capabilities of the window we either return - // |WindowStateType::kMaximized| or |WindowStateType::kNormal|. - chromeos::WindowStateType GetMaximizedOrCenteredWindowType( - WindowState* window_state); - // If |target_state| is PRIMARY/SECONDARY_SNAPPED and the window can be // snapped, returns |target_state|. Otherwise depending on the capabilities // of the window either returns |WindowStateType::kMaximized| or
diff --git a/ash/wm/window_state.cc b/ash/wm/window_state.cc index 17560df..5f63dbf2 100644 --- a/ash/wm/window_state.cc +++ b/ash/wm/window_state.cc
@@ -162,36 +162,6 @@ return WM_EVENT_NORMAL; } -WMEventType WMEventTypeFromWindowStateType(WindowStateType window_state_type) { - switch (window_state_type) { - case WindowStateType::kDefault: - case WindowStateType::kNormal: - return WM_EVENT_NORMAL; - case WindowStateType::kMinimized: - return WM_EVENT_MINIMIZE; - case WindowStateType::kMaximized: - return WM_EVENT_MAXIMIZE; - case WindowStateType::kInactive: - return WM_EVENT_SHOW_INACTIVE; - case WindowStateType::kFullscreen: - return WM_EVENT_FULLSCREEN; - case WindowStateType::kPrimarySnapped: - return WM_EVENT_SNAP_PRIMARY; - case WindowStateType::kSecondarySnapped: - return WM_EVENT_SNAP_SECONDARY; - case WindowStateType::kPinned: - return WM_EVENT_PIN; - case WindowStateType::kTrustedPinned: - return WM_EVENT_TRUSTED_PIN; - case WindowStateType::kPip: - return WM_EVENT_PIP; - case WindowStateType::kAutoPositioned: - NOTREACHED() << "No WMEvent defined for the window state type: " - << window_state_type; - } - return WM_EVENT_NORMAL; -} - float GetCurrentSnapRatio(aura::Window* window) { gfx::Rect maximized_bounds = screen_util::GetMaximizedWindowBoundsInParent(window); @@ -414,7 +384,7 @@ } void WindowState::Restore() { - const WMEvent event(WMEventTypeFromWindowStateType(GetRestoreWindowState())); + const WMEvent event(WM_EVENT_RESTORE); OnWMEvent(&event); } @@ -671,11 +641,22 @@ } WindowStateType WindowState::GetRestoreWindowState() const { - return window_state_restore_history_.empty() || - window_state_restore_history_.back() == - WindowStateType::kDefault - ? WindowStateType::kNormal - : window_state_restore_history_.back(); + WindowStateType restore_state = + window_state_restore_history_.empty() || + window_state_restore_history_.back() == WindowStateType::kDefault + ? WindowStateType::kNormal + : window_state_restore_history_.back(); + + // Different with the restore behaviors in clamshell mode, a window can not be + // restored to kNormal window state if it's a maximize-able window. + // We should still be able to restore a fullscreen/minimized/snapped window to + // kMaximized window state for a maximize-able window, and also should be able + // to support restoring a fullscreen/minimized/maximized window to snapped + // window states. + if (IsTabletModeEnabled() && restore_state == WindowStateType::kNormal) + restore_state = GetMaximizedOrCenteredWindowType(); + + return restore_state; } void WindowState::CreateDragDetails(const gfx::PointF& point_in_parent, @@ -1027,6 +1008,13 @@ } } +chromeos::WindowStateType WindowState::GetMaximizedOrCenteredWindowType() + const { + return CanMaximize() && ::wm::GetTransientParent(window_) == nullptr + ? WindowStateType::kMaximized + : WindowStateType::kNormal; +} + // static WindowState* WindowState::Get(aura::Window* window) { if (!window)
diff --git a/ash/wm/window_state.h b/ash/wm/window_state.h index bca3a14..aaddcf5 100644 --- a/ash/wm/window_state.h +++ b/ash/wm/window_state.h
@@ -163,8 +163,7 @@ void Activate(); void Deactivate(); - // Set the window state to normal. - // TODO(oshima): Change to use RESTORE event. + // Set the window state to its previous applicable window state. void Restore(); // Caches, then disables z-ordering state and then stacks |window_| below @@ -484,6 +483,12 @@ void UpdateWindowStateRestoreHistoryStack( chromeos::WindowStateType previous_state_type); + // Depending on the capabilities of the window we either return + // |WindowStateType::kMaximized| or |WindowStateType::kNormal|. + // |WindowStateType::kMaximized| can only be returned if the window can be + // maximized and is not a transient child window. + chromeos::WindowStateType GetMaximizedOrCenteredWindowType() const; + // aura::WindowObserver: void OnWindowPropertyChanged(aura::Window* window, const void* key,
diff --git a/ash/wm/window_state_unittest.cc b/ash/wm/window_state_unittest.cc index 761ed87..0e45cd9 100644 --- a/ash/wm/window_state_unittest.cc +++ b/ash/wm/window_state_unittest.cc
@@ -1194,6 +1194,22 @@ EXPECT_EQ(window_state->GetRestoreWindowState(), WindowStateType::kNormal); } +// Tests the restore behavior for default or normal window. +TEST_F(WindowStateTest, NormalOrDefaultRestore) { + // Start with kDefault window state. + std::unique_ptr<aura::Window> window = CreateAppWindow(); + WindowState* window_state = WindowState::Get(window.get()); + EXPECT_EQ(window_state->GetStateType(), WindowStateType::kDefault); + + // Restoring a kDefault window will change its window state to kNormal. + window_state->Restore(); + EXPECT_EQ(window_state->GetStateType(), WindowStateType::kNormal); + + // Restoring kNormal window will do nothing. + window_state->Restore(); + EXPECT_EQ(window_state->GetStateType(), WindowStateType::kNormal); +} + // Test WindowStateTest functionalities with portrait display. This test is // parameterized to enable vertical layout or horizontal layout snap in // portrait display.
diff --git a/ash/wm/wm_event.cc b/ash/wm/wm_event.cc index 292a7d0..ea6ec42 100644 --- a/ash/wm/wm_event.cc +++ b/ash/wm/wm_event.cc
@@ -73,6 +73,7 @@ case WM_EVENT_FULLSCREEN: case WM_EVENT_SNAP_PRIMARY: case WM_EVENT_SNAP_SECONDARY: + case WM_EVENT_RESTORE: case WM_EVENT_SHOW_INACTIVE: case WM_EVENT_PIN: case WM_EVENT_TRUSTED_PIN:
diff --git a/ash/wm/wm_event.h b/ash/wm/wm_event.h index da09e8c..bff0f00 100644 --- a/ash/wm/wm_event.h +++ b/ash/wm/wm_event.h
@@ -21,7 +21,6 @@ // Note that this does not mean the window will be in corresponding // state and the request may not be fullfilled. - // NORMAL is used as a restore operation with a few exceptions. WM_EVENT_NORMAL = 0, WM_EVENT_MAXIMIZE, WM_EVENT_MINIMIZE, @@ -36,6 +35,10 @@ // SECONDARY is right. WM_EVENT_SNAP_SECONDARY, + // The restore event will change the window state back to its previous + // applicable window state. + WM_EVENT_RESTORE, + // A window is requested to be the given bounds. The request may or // may not be fulfilled depending on the requested bounds and window's // state. This will not change the window state type.
diff --git a/base/allocator/partition_alloc_support.cc b/base/allocator/partition_alloc_support.cc index 8dbff6d..d17c557 100644 --- a/base/allocator/partition_alloc_support.cc +++ b/base/allocator/partition_alloc_support.cc
@@ -220,19 +220,16 @@ // Whether PartitionAllocBackupRefPtr is enabled (as determined by // FeatureList::IsEnabled). - bool brp_finch_enabled = false; - ALLOW_UNUSED_LOCAL(brp_finch_enabled); + [[maybe_unused]] bool brp_finch_enabled = false; // Whether PartitionAllocBackupRefPtr is set up for the default behavior. The // default behavior is when either the Finch flag is disabled, or is enabled // in brp-mode=disabled (these two options are equivalent). - bool brp_nondefault_behavior = false; - ALLOW_UNUSED_LOCAL(brp_nondefault_behavior); + [[maybe_unused]] bool brp_nondefault_behavior = false; // Whether PartitionAllocBackupRefPtr is set up to enable BRP protection. It // requires the Finch flag to be enabled and brp-mode!=disabled*. Some modes, // e.g. disabled-but-3-way-split, do something (hence can't be considered the // default behavior), but don't enable BRP protection. - bool brp_truly_enabled = false; - ALLOW_UNUSED_LOCAL(brp_truly_enabled); + [[maybe_unused]] bool brp_truly_enabled = false; #if BUILDFLAG(USE_BACKUP_REF_PTR) if (FeatureList::IsEnabled(features::kPartitionAllocBackupRefPtr)) brp_finch_enabled = true; @@ -243,13 +240,12 @@ features::BackupRefPtrMode::kEnabled) brp_truly_enabled = true; #endif // BUILDFLAG(USE_BACKUP_REF_PTR) - bool pcscan_enabled = + [[maybe_unused]] bool pcscan_enabled = #if defined(PA_ALLOW_PCSCAN) FeatureList::IsEnabled(features::kPartitionAllocPCScanBrowserOnly); #else false; #endif - ALLOW_UNUSED_LOCAL(pcscan_enabled); std::string brp_group_name = "Unavailable"; #if BUILDFLAG(USE_BACKUP_REF_PTR)
diff --git a/base/allocator/partition_alloc_support_unittest.cc b/base/allocator/partition_alloc_support_unittest.cc index 9ab42a5..dd19210b 100644 --- a/base/allocator/partition_alloc_support_unittest.cc +++ b/base/allocator/partition_alloc_support_unittest.cc
@@ -11,7 +11,6 @@ #include "base/allocator/buildflags.h" #include "base/allocator/partition_alloc_features.h" #include "base/allocator/partition_allocator/partition_alloc_config.h" -#include "base/compiler_specific.h" #include "base/feature_list.h" #include "base/test/scoped_feature_list.h" #include "testing/gtest/include/gtest/gtest.h" @@ -120,10 +119,8 @@ {{"brp-mode", mode.first}, {"enabled-processes", process_set.first}}); - bool brp_truly_enabled = false; - ALLOW_UNUSED_LOCAL(brp_truly_enabled); - bool brp_nondefault_behavior = false; - ALLOW_UNUSED_LOCAL(brp_nondefault_behavior); + [[maybe_unused]] bool brp_truly_enabled = false; + [[maybe_unused]] bool brp_nondefault_behavior = false; brp_expectation = "Unavailable"; #if BUILDFLAG(USE_BACKUP_REF_PTR) brp_expectation = pcscan_enabled ? "Ignore_PCScanIsOn" : mode.second;
diff --git a/base/allocator/partition_allocator/allocation_guard.h b/base/allocator/partition_allocator/allocation_guard.h index e100c0a14..4f034bd 100644 --- a/base/allocator/partition_allocator/allocation_guard.h +++ b/base/allocator/partition_allocator/allocation_guard.h
@@ -32,17 +32,8 @@ #else -// TODO(lizeb): Remove once NaCl is either gone, or the compiler gets updated. -#if defined(OS_NACL) -#define PA_MAYBE_UNUSED __attribute__((unused)) -#else -#define PA_MAYBE_UNUSED [[maybe_unused]] -#endif - -struct PA_MAYBE_UNUSED ScopedDisallowAllocations {}; -struct PA_MAYBE_UNUSED ScopedAllowAllocations {}; - -#undef PA_MAYBE_UNUSED +struct [[maybe_unused]] ScopedDisallowAllocations{}; +struct [[maybe_unused]] ScopedAllowAllocations{}; #endif // defined(PA_HAS_ALLOCATION_GUARD)
diff --git a/base/allocator/partition_allocator/partition_lock_perftest.cc b/base/allocator/partition_allocator/partition_lock_perftest.cc index 282c74c..ecae3fde 100644 --- a/base/allocator/partition_allocator/partition_lock_perftest.cc +++ b/base/allocator/partition_allocator/partition_lock_perftest.cc
@@ -5,7 +5,6 @@ #include <vector> #include "base/allocator/partition_allocator/partition_lock.h" -#include "base/compiler_specific.h" #include "base/threading/platform_thread.h" #include "base/time/time.h" #include "base/timer/lap_timer.h" @@ -70,7 +69,7 @@ TEST(PartitionLockPerfTest, Simple) { base::LapTimer timer(kWarmupRuns, kTimeLimit, kTimeCheckInterval); - ALLOW_UNUSED_TYPE uint32_t data = 0; + [[maybe_unused]] uint32_t data = 0; Lock lock;
diff --git a/base/allocator/partition_allocator/starscan/pcscan_unittest.cc b/base/allocator/partition_allocator/starscan/pcscan_unittest.cc index 81620ad..5200496a 100644 --- a/base/allocator/partition_allocator/starscan/pcscan_unittest.cc +++ b/base/allocator/partition_allocator/starscan/pcscan_unittest.cc
@@ -662,7 +662,7 @@ PCScan::NotifyThreadCreated(GetStackPointer()); [this]() NOINLINE { // This writes the pointer to the stack. - ALLOW_UNUSED_TYPE auto* volatile stack_ref = dangling_reference; + [[maybe_unused]] auto* volatile stack_ref = dangling_reference; [this]() NOINLINE { // Schedule PCScan but don't scan. SchedulePCScan();
diff --git a/base/allocator/partition_allocator/starscan/stack/stack.cc b/base/allocator/partition_allocator/starscan/stack/stack.cc index 23b9c2fe..eb68de82 100644 --- a/base/allocator/partition_allocator/starscan/stack/stack.cc +++ b/base/allocator/partition_allocator/starscan/stack/stack.cc
@@ -94,8 +94,7 @@ namespace { -ALLOW_UNUSED_TYPE -void IterateSafeStackIfNecessary(StackVisitor* visitor) { +[[maybe_unused]] void IterateSafeStackIfNecessary(StackVisitor* visitor) { #if defined(__has_feature) #if __has_feature(safe_stack) // Source: @@ -118,10 +117,10 @@ // should never be inlined to ensure that a possible redzone cannot contain // any data that needs to be scanned. // No ASAN support as method accesses redzones while walking the stack. -NOINLINE NO_SANITIZE("address") ALLOW_UNUSED_TYPE - void IteratePointersImpl(const Stack* stack, - StackVisitor* visitor, - uintptr_t* stack_ptr) { +[[maybe_unused]] NOINLINE NO_SANITIZE("address") void IteratePointersImpl( + const Stack* stack, + StackVisitor* visitor, + uintptr_t* stack_ptr) { PA_DCHECK(stack); PA_DCHECK(visitor); PA_CHECK(nullptr != stack->stack_top());
diff --git a/base/allocator/partition_allocator/starscan/stack/stack_unittest.cc b/base/allocator/partition_allocator/starscan/stack/stack_unittest.cc index 867ae81..d5307974 100644 --- a/base/allocator/partition_allocator/starscan/stack/stack_unittest.cc +++ b/base/allocator/partition_allocator/starscan/stack/stack_unittest.cc
@@ -66,7 +66,7 @@ // No check that the needle is initially not found as on some platforms it // may be part of temporaries after setting it up through StackScanner. { - ALLOW_UNUSED_TYPE int* volatile tmp = scanner->needle(); + [[maybe_unused]] int* volatile tmp = scanner->needle(); GetStack()->IteratePointers(scanner.get()); EXPECT_TRUE(scanner->found()); } @@ -79,8 +79,8 @@ // No check that the needle is initially not found as on some platforms it // may be part of temporaries after setting it up through StackScanner. { - ALLOW_UNUSED_TYPE char a = 'c'; - ALLOW_UNUSED_TYPE int* volatile tmp = scanner->needle(); + [[maybe_unused]] char a = 'c'; + [[maybe_unused]] int* volatile tmp = scanner->needle(); GetStack()->IteratePointers(scanner.get()); EXPECT_TRUE(scanner->found()); } @@ -326,7 +326,7 @@ void VisitStack(uintptr_t*, uintptr_t*) final { // Check that the stack doesn't get misaligned by asm trampolines. float f[4] = {0.}; - ALLOW_UNUSED_TYPE volatile auto xmm = ::_mm_load_ps(f); + [[maybe_unused]] volatile auto xmm = ::_mm_load_ps(f); } };
diff --git a/base/android/library_loader/library_prefetcher.cc b/base/android/library_loader/library_prefetcher.cc index 88dd068a..411260e 100644 --- a/base/android/library_loader/library_prefetcher.cc +++ b/base/android/library_loader/library_prefetcher.cc
@@ -177,13 +177,12 @@ void Prefetch(size_t start, size_t end) { unsigned char* start_ptr = reinterpret_cast<unsigned char*>(start); unsigned char* end_ptr = reinterpret_cast<unsigned char*>(end); - unsigned char dummy = 0; + [[maybe_unused]] unsigned char dummy = 0; for (unsigned char* ptr = start_ptr; ptr < end_ptr; ptr += kPageSize) { // Volatile is required to prevent the compiler from eliminating this // loop. dummy ^= *static_cast<volatile unsigned char*>(ptr); } - ALLOW_UNUSED_LOCAL(dummy); } // These values were used in the past for recording
diff --git a/base/android/linker/linker_jni.h b/base/android/linker/linker_jni.h index 47a8109..33492d6 100644 --- a/base/android/linker/linker_jni.h +++ b/base/android/linker/linker_jni.h
@@ -44,8 +44,6 @@ #define PLOG_ERROR(FORMAT, ...) \ LOG_ERROR(FORMAT ": %s", ##__VA_ARGS__, strerror(errno)) -#define UNUSED __attribute__((unused)) - #if defined(ARCH_CPU_X86) // Dalvik JIT generated code doesn't guarantee 16-byte stack alignment on // x86 - use force_align_arg_pointer to realign the stack at the JNI
diff --git a/base/android/linker/modern_linker_unittest.cc b/base/android/linker/modern_linker_unittest.cc index 07bbd321..c9a921a 100644 --- a/base/android/linker/modern_linker_unittest.cc +++ b/base/android/linker/modern_linker_unittest.cc
@@ -43,7 +43,7 @@ size_t relro_size() const { return relro_size_; } static int VisitLibraryPhdrs(dl_phdr_info* info, - size_t size UNUSED, + [[maybe_unused]] size_t size, void* data); private: @@ -59,7 +59,7 @@ // corresponding phdr(s). // static int LibraryRangeFinder::VisitLibraryPhdrs(dl_phdr_info* info, - size_t size UNUSED, + [[maybe_unused]] size_t size, void* data) { auto* finder = reinterpret_cast<LibraryRangeFinder*>(data); ElfW(Addr) lookup_address = static_cast<ElfW(Addr)>(finder->load_address());
diff --git a/base/debug/stack_trace_unittest.cc b/base/debug/stack_trace_unittest.cc index f8651041..8f81929 100644 --- a/base/debug/stack_trace_unittest.cc +++ b/base/debug/stack_trace_unittest.cc
@@ -383,11 +383,10 @@ // SIGFPE being raised outside of EXPECT_EXIT. volatile int const nominator = 23; volatile int const denominator = 0; - volatile int result; + [[maybe_unused]] volatile int result; EXPECT_EXIT(result = nominator / denominator, ::testing::KilledBySignal(SIGFPE), ""); - ALLOW_UNUSED_LOCAL(result); } #endif // !defined(ARCH_CPU_ARM_FAMILY)
diff --git a/base/immediate_crash_unittest.cc b/base/immediate_crash_unittest.cc index 1389a6b..1d767fb 100644 --- a/base/immediate_crash_unittest.cc +++ b/base/immediate_crash_unittest.cc
@@ -8,7 +8,6 @@ #include "base/base_paths.h" #include "base/clang_profiling_buildflags.h" -#include "base/compiler_specific.h" #include "base/containers/span.h" #include "base/files/file_path.h" #include "base/path_service.h" @@ -26,7 +25,7 @@ // If IMMEDIATE_CRASH() is not treated as noreturn by the compiler, the compiler // will complain that not all paths through this function return a value. -int ALLOW_UNUSED_TYPE TestImmediateCrashTreatedAsNoReturn() { +[[maybe_unused]] int TestImmediateCrashTreatedAsNoReturn() { IMMEDIATE_CRASH(); }
diff --git a/base/location_unittest.cc b/base/location_unittest.cc index dd54d392..f9e8450 100644 --- a/base/location_unittest.cc +++ b/base/location_unittest.cc
@@ -4,7 +4,6 @@ #include "base/location.h" -#include "base/compiler_specific.h" #include "base/debug/debugging_buildflags.h" #include "base/trace_event/base_tracing.h" #include "testing/gmock/include/gmock/gmock.h" @@ -28,7 +27,7 @@ } // namespace TEST(LocationTest, CurrentYieldsCorrectValue) { - int previous_line = __LINE__; + [[maybe_unused]] int previous_line = __LINE__; Location here = WhereAmI(); EXPECT_NE(here.program_counter(), WhereAmI().program_counter()); #if SUPPORTS_LOCATION_BUILTINS @@ -42,7 +41,6 @@ #elif BUILDFLAG(FROM_HERE_USES_LOCATION_BUILTINS) #error FROM_HERE requires location builtins to be supported. #endif - ALLOW_UNUSED_LOCAL(previous_line); } #if BUILDFLAG(ENABLE_BASE_TRACING)
diff --git a/base/logging_unittest.cc b/base/logging_unittest.cc index a2fd962..0df1c1aa 100644 --- a/base/logging_unittest.cc +++ b/base/logging_unittest.cc
@@ -8,7 +8,6 @@ #include "base/bind.h" #include "base/callback.h" #include "base/command_line.h" -#include "base/compiler_specific.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/logging.h" @@ -694,8 +693,8 @@ // looking in the global namespace. namespace nested_test { class Streamable {}; - ALLOW_UNUSED_TYPE std::ostream& operator<<(std::ostream& out, - const Streamable&) { + [[maybe_unused]] std::ostream& operator<<(std::ostream& out, + const Streamable&) { return out << "Streamable"; } TEST_F(LoggingTest, StreamingWstringFindsCorrectOperator) {
diff --git a/base/mac/foundation_util_unittest.mm b/base/mac/foundation_util_unittest.mm index d6993df..c48e2bf 100644 --- a/base/mac/foundation_util_unittest.mm +++ b/base/mac/foundation_util_unittest.mm
@@ -7,7 +7,6 @@ #include <limits.h> #include <stddef.h> -#include "base/compiler_specific.h" #include "base/cxx17_backports.h" #include "base/files/file_path.h" #include "base/format_macros.h" @@ -346,12 +345,12 @@ #endif // defined(ARCH_CPU_64_BITS) NSInteger some_nsinteger; - FormatNSIntegerAsType* pointer_to_some_nsinteger = &some_nsinteger; - ALLOW_UNUSED_LOCAL(pointer_to_some_nsinteger); + [[maybe_unused]] FormatNSIntegerAsType* pointer_to_some_nsinteger = + &some_nsinteger; NSUInteger some_nsuinteger; - FormatNSUIntegerAsType* pointer_to_some_nsuinteger = &some_nsuinteger; - ALLOW_UNUSED_LOCAL(pointer_to_some_nsuinteger); + [[maybe_unused]] FormatNSUIntegerAsType* pointer_to_some_nsuinteger = + &some_nsuinteger; // Check that format specifier works correctly for NSInteger. const struct {
diff --git a/base/memory/discardable_shared_memory.cc b/base/memory/discardable_shared_memory.cc index b7e0050a..ca2629d 100644 --- a/base/memory/discardable_shared_memory.cc +++ b/base/memory/discardable_shared_memory.cc
@@ -66,21 +66,21 @@ // Serialize to Unix time when using 4-byte wire format. // Note: 19 January 2038, this will cease to work. template <> -Time ALLOW_UNUSED_TYPE TimeFromWireFormat<4>(int64_t value) { +[[maybe_unused]] Time TimeFromWireFormat<4>(int64_t value) { return value ? Time::UnixEpoch() + Seconds(value) : Time(); } template <> -int64_t ALLOW_UNUSED_TYPE TimeToWireFormat<4>(Time time) { +[[maybe_unused]] int64_t TimeToWireFormat<4>(Time time) { return time > Time::UnixEpoch() ? (time - Time::UnixEpoch()).InSeconds() : 0; } // Standard serialization format when using 8-byte wire format. template <> -Time ALLOW_UNUSED_TYPE TimeFromWireFormat<8>(int64_t value) { +[[maybe_unused]] Time TimeFromWireFormat<8>(int64_t value) { return Time::FromInternalValue(value); } template <> -int64_t ALLOW_UNUSED_TYPE TimeToWireFormat<8>(Time time) { +[[maybe_unused]] int64_t TimeToWireFormat<8>(Time time) { return time.ToInternalValue(); }
diff --git a/base/memory/raw_ptr_unittest.cc b/base/memory/raw_ptr_unittest.cc index c5f0c35..dfa3a01 100644 --- a/base/memory/raw_ptr_unittest.cc +++ b/base/memory/raw_ptr_unittest.cc
@@ -12,7 +12,6 @@ #include "base/allocator/buildflags.h" #include "base/allocator/partition_allocator/partition_alloc.h" -#include "base/compiler_specific.h" #include "base/logging.h" #include "build/build_config.h" #include "build/buildflag.h" @@ -211,7 +210,7 @@ is_valid = ptr || is_valid; // volatile, so won't be optimized if (ptr) is_valid = true; - ALLOW_UNUSED_TYPE bool is_not_valid = !ptr; + [[maybe_unused]] bool is_not_valid = !ptr; if (!ptr) is_not_valid = true; std::ignore = IsValidNoCast(ptr); @@ -233,7 +232,7 @@ // costly, so the caller has to be careful not to trigger this path. TEST_F(RawPtrTest, CastNotBoolOp) { CountingRawPtr<int> ptr = nullptr; - ALLOW_UNUSED_TYPE bool is_valid = ptr; + [[maybe_unused]] bool is_valid = ptr; is_valid = IsValidWithCast(ptr); FuncThatAcceptsBool(ptr); EXPECT_EQ(g_get_for_comparison_cnt, 0);
diff --git a/base/memory/tagging.cc b/base/memory/tagging.cc index a4a1af7..50e9218 100644 --- a/base/memory/tagging.cc +++ b/base/memory/tagging.cc
@@ -4,7 +4,6 @@ #include "base/memory/tagging.h" -#include "base/compiler_specific.h" #include "base/cpu.h" #include "base/logging.h" #include "build/build_config.h" @@ -138,7 +137,7 @@ } namespace { -ALLOW_UNUSED_TYPE static bool CheckTagRegionParameters(void* ptr, size_t sz) { +[[maybe_unused]] static bool CheckTagRegionParameters(void* ptr, size_t sz) { // Check that ptr and size are correct for MTE uintptr_t ptr_as_uint = reinterpret_cast<uintptr_t>(ptr); bool ret = (ptr_as_uint % kMemTagGranuleSize == 0) &&
diff --git a/base/posix/safe_strerror.cc b/base/posix/safe_strerror.cc index aab8b879..2fa41961 100644 --- a/base/posix/safe_strerror.cc +++ b/base/posix/safe_strerror.cc
@@ -13,33 +13,24 @@ namespace base { #if defined(__GLIBC__) || defined(OS_NACL) -#define USE_HISTORICAL_STRERRO_R 1 +#define USE_HISTORICAL_STRERROR_R 1 // Post-L versions of bionic define the GNU-specific strerror_r if _GNU_SOURCE // is defined, but the symbol is renamed to __gnu_strerror_r which only exists // on those later versions. For parity, add the same condition as bionic. #elif defined(__BIONIC__) && defined(_GNU_SOURCE) && __ANDROID_API__ >= 23 -#define USE_HISTORICAL_STRERRO_R 1 +#define USE_HISTORICAL_STRERROR_R 1 #else -#define USE_HISTORICAL_STRERRO_R 0 +#define USE_HISTORICAL_STRERROR_R 0 #endif -#if USE_HISTORICAL_STRERRO_R && defined(__GNUC__) -// GCC will complain about the unused second wrap function unless we tell it -// that we meant for them to be potentially unused, which is exactly what this -// attribute is for. -#define POSSIBLY_UNUSED __attribute__((unused)) -#else -#define POSSIBLY_UNUSED -#endif - -#if USE_HISTORICAL_STRERRO_R +#if USE_HISTORICAL_STRERROR_R // glibc has two strerror_r functions: a historical GNU-specific one that // returns type char *, and a POSIX.1-2001 compliant one available since 2.3.4 // that returns int. This wraps the GNU-specific one. -static void POSSIBLY_UNUSED wrap_posix_strerror_r( - char *(*strerror_r_ptr)(int, char *, size_t), +[[maybe_unused]] static void wrap_posix_strerror_r( + char* (*strerror_r_ptr)(int, char*, size_t), int err, - char *buf, + char* buf, size_t len) { // GNU version. char *rc = (*strerror_r_ptr)(err, buf, len); @@ -52,17 +43,17 @@ // The GNU version never fails. Unknown errors get an "unknown error" message. // The result is always null terminated. } -#endif // USE_HISTORICAL_STRERRO_R +#endif // USE_HISTORICAL_STRERROR_R // Wrapper for strerror_r functions that implement the POSIX interface. POSIX // does not define the behaviour for some of the edge cases, so we wrap it to // guarantee that they are handled. This is compiled on all POSIX platforms, but // it will only be used on Linux if the POSIX strerror_r implementation is // being used (see below). -static void POSSIBLY_UNUSED wrap_posix_strerror_r( - int (*strerror_r_ptr)(int, char *, size_t), +[[maybe_unused]] static void wrap_posix_strerror_r( + int (*strerror_r_ptr)(int, char*, size_t), int err, - char *buf, + char* buf, size_t len) { int old_errno = errno; // Have to cast since otherwise we get an error if this is the GNU version
diff --git a/base/profiler/stack_sampling_profiler_test_util.cc b/base/profiler/stack_sampling_profiler_test_util.cc index 878e676..115358b8 100644 --- a/base/profiler/stack_sampling_profiler_test_util.cc +++ b/base/profiler/stack_sampling_profiler_test_util.cc
@@ -9,7 +9,6 @@ #include "base/bind.h" #include "base/callback.h" -#include "base/compiler_specific.h" #include "base/location.h" #include "base/path_service.h" #include "base/profiler/profiler_buildflags.h" @@ -92,8 +91,7 @@ std::move(*wait_for_sample).Run(); // Prevent tail call. - volatile int i = 0; - ALLOW_UNUSED_LOCAL(i); + [[maybe_unused]] volatile int i = 0; } #if defined(OS_ANDROID) && BUILDFLAG(ENABLE_ARM_CFI_TABLE)
diff --git a/base/security_unittest.cc b/base/security_unittest.cc index 2e6622f..93305e2 100644 --- a/base/security_unittest.cc +++ b/base/security_unittest.cc
@@ -85,7 +85,8 @@ const size_t kArraySize = 4096; // We want something "dynamic" here, so that the compiler doesn't // immediately reject crazy arrays. - const size_t kDynamicArraySize = HideValueFromCompiler(kArraySize); + [[maybe_unused]] const size_t kDynamicArraySize = + HideValueFromCompiler(kArraySize); const size_t kMaxSizeT = std::numeric_limits<size_t>::max(); const size_t kArraySize2 = kMaxSizeT / kArraySize + 10; const size_t kDynamicArraySize2 = HideValueFromCompiler(kArraySize2); @@ -96,10 +97,9 @@ char* volatile p = reinterpret_cast<char*>(array_pointer.get()); OverflowTestsSoftExpectTrue(!p); } - // On windows, the compiler prevents static array sizes of more than - // 0x7fffffff (error C2148). #if defined(OS_WIN) && defined(ARCH_CPU_64_BITS) - ALLOW_UNUSED_LOCAL(kDynamicArraySize); + // On Windows, the compiler prevents static array sizes of more than + // 0x7fffffff (error C2148). #else { std::unique_ptr<char[][kArraySize2]> array_pointer(
diff --git a/base/stack_canary_linux_unittest.cc b/base/stack_canary_linux_unittest.cc index 639a4bd..aea20755 100644 --- a/base/stack_canary_linux_unittest.cc +++ b/base/stack_canary_linux_unittest.cc
@@ -4,7 +4,6 @@ #include "base/stack_canary_linux.h" -#include "base/compiler_specific.h" #include "build/build_config.h" #include "testing/gtest/include/gtest/gtest.h" @@ -19,8 +18,7 @@ // which should work as long as -fno-stack-protector isn't passed in the // default options. We compile this file with -fstack-protector-all, but it // may be overridden with -fstack-protector or -fstack-protector-strong. - char buffer[10]; - ALLOW_UNUSED_LOCAL(buffer); + [[maybe_unused]] char buffer[10]; ResetStackCanaryIfPossible(); } } // namespace
diff --git a/base/synchronization/lock_perftest.cc b/base/synchronization/lock_perftest.cc index e5bcae4a..0c72fc9a 100644 --- a/base/synchronization/lock_perftest.cc +++ b/base/synchronization/lock_perftest.cc
@@ -63,7 +63,7 @@ TEST(LockPerfTest, Simple) { LapTimer timer(kWarmupRuns, kTimeLimit, kTimeCheckInterval); - uint32_t data = 0; + [[maybe_unused]] uint32_t data = 0; Lock lock; @@ -74,7 +74,6 @@ timer.NextLap(); } while (!timer.HasTimeLimitExpired()); - ALLOW_UNUSED_LOCAL(data); auto reporter = SetUpReporter(kStoryBaseline); reporter.AddResult(kMetricLockUnlockThroughput, timer.LapsPerSecond()); }
diff --git a/base/task/lazy_thread_pool_task_runner.h b/base/task/lazy_thread_pool_task_runner.h index d8a8096..8ff407c 100644 --- a/base/task/lazy_thread_pool_task_runner.h +++ b/base/task/lazy_thread_pool_task_runner.h
@@ -9,7 +9,6 @@ #include "base/atomicops.h" #include "base/callback.h" -#include "base/compiler_specific.h" #include "base/task/common/checked_lock.h" #include "base/task/sequenced_task_runner.h" #include "base/task/single_thread_task_runner.h" @@ -95,7 +94,7 @@ // |traits| are TaskTraits used when creating the SequencedTaskRunner. #define LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(traits) \ base::LazyThreadPoolSequencedTaskRunner::CreateInternal(traits); \ - ALLOW_UNUSED_TYPE constexpr base::TaskTraits \ + [[maybe_unused]] constexpr base::TaskTraits \ LAZY_TASK_RUNNER_CONCATENATE_INTERNAL(kVerifyTraitsAreConstexpr, \ __LINE__) = traits @@ -106,10 +105,10 @@ thread_mode) \ base::LazyThreadPoolSingleThreadTaskRunner::CreateInternal(traits, \ thread_mode); \ - ALLOW_UNUSED_TYPE constexpr base::TaskTraits \ + [[maybe_unused]] constexpr base::TaskTraits \ LAZY_TASK_RUNNER_CONCATENATE_INTERNAL(kVerifyTraitsAreConstexpr, \ __LINE__) = traits; \ - ALLOW_UNUSED_TYPE constexpr base::SingleThreadTaskRunnerThreadMode \ + [[maybe_unused]] constexpr base::SingleThreadTaskRunnerThreadMode \ LAZY_TASK_RUNNER_CONCATENATE_INTERNAL(kVerifyThreadModeIsConstexpr, \ __LINE__) = thread_mode @@ -119,10 +118,10 @@ // SingleThreadTaskRunners. #define LAZY_COM_STA_TASK_RUNNER_INITIALIZER(traits, thread_mode) \ base::LazyThreadPoolCOMSTATaskRunner::CreateInternal(traits, thread_mode); \ - ALLOW_UNUSED_TYPE constexpr base::TaskTraits \ + [[maybe_unused]] constexpr base::TaskTraits \ LAZY_TASK_RUNNER_CONCATENATE_INTERNAL(kVerifyTraitsAreConstexpr, \ __LINE__) = traits; \ - ALLOW_UNUSED_TYPE constexpr base::SingleThreadTaskRunnerThreadMode \ + [[maybe_unused]] constexpr base::SingleThreadTaskRunnerThreadMode \ LAZY_TASK_RUNNER_CONCATENATE_INTERNAL(kVerifyThreadModeIsConstexpr, \ __LINE__) = thread_mode
diff --git a/base/task/sequence_manager/sequence_manager_impl_unittest.cc b/base/task/sequence_manager/sequence_manager_impl_unittest.cc index d34b5ec7..da789c85 100644 --- a/base/task/sequence_manager/sequence_manager_impl_unittest.cc +++ b/base/task/sequence_manager/sequence_manager_impl_unittest.cc
@@ -3866,8 +3866,6 @@ [](int* counter, const Task& task, TaskQueue::TaskTiming* task_timing, LazyNow* lazy_now) { ++(*counter); }, complete_counter)); - task_queue->GetTaskQueueImpl()->SetOnTaskPostedHandler( - internal::TaskQueueImpl::OnTaskPostedHandler()); } void UnsetOnTaskHandlers(scoped_refptr<TestTaskQueue> task_queue) { @@ -3875,8 +3873,6 @@ internal::TaskQueueImpl::OnTaskStartedHandler()); task_queue->GetTaskQueueImpl()->SetOnTaskCompletedHandler( internal::TaskQueueImpl::OnTaskCompletedHandler()); - task_queue->GetTaskQueueImpl()->SetOnTaskPostedHandler( - internal::TaskQueueImpl::OnTaskPostedHandler()); } } // namespace @@ -5357,6 +5353,41 @@ EXPECT_THAT(run_order, ElementsAre(1u, 2u, 3u, 4u)); } +TEST_P(SequenceManagerTest, OnTaskPostedCallbacks) { + int counter1 = 0; + int counter2 = 0; + + auto queue = CreateTaskQueue(); + + std::unique_ptr<TaskQueue::OnTaskPostedCallbackHandle> handle1 = + queue->AddOnTaskPostedHandler(BindRepeating( + [](int* counter, const Task& task) { ++(*counter); }, &counter1)); + + queue->task_runner()->PostTask(FROM_HERE, BindOnce(NullTask)); + EXPECT_EQ(1, counter1); + EXPECT_EQ(0, counter2); + + std::unique_ptr<TaskQueue::OnTaskPostedCallbackHandle> handle2 = + queue->AddOnTaskPostedHandler(BindRepeating( + [](int* counter, const Task& task) { ++(*counter); }, &counter2)); + + queue->task_runner()->PostTask(FROM_HERE, BindOnce(NullTask)); + EXPECT_EQ(2, counter1); + EXPECT_EQ(1, counter2); + + handle1.reset(); + + queue->task_runner()->PostTask(FROM_HERE, BindOnce(NullTask)); + EXPECT_EQ(2, counter1); + EXPECT_EQ(2, counter2); + + handle2.reset(); + + queue->task_runner()->PostTask(FROM_HERE, BindOnce(NullTask)); + EXPECT_EQ(2, counter1); + EXPECT_EQ(2, counter2); +} + } // namespace internal } // namespace sequence_manager } // namespace base
diff --git a/base/task/sequence_manager/task_queue.cc b/base/task/sequence_manager/task_queue.cc index c698e6b..c54c76e 100644 --- a/base/task/sequence_manager/task_queue.cc +++ b/base/task/sequence_manager/task_queue.cc
@@ -181,11 +181,6 @@ return; } impl_->SetBlameContext(nullptr); - impl_->SetOnTaskStartedHandler( - internal::TaskQueueImpl::OnTaskStartedHandler()); - impl_->SetOnTaskCompletedHandler( - internal::TaskQueueImpl::OnTaskCompletedHandler()); - impl_->SetOnTaskPostedHandler(internal::TaskQueueImpl::OnTaskPostedHandler()); sequence_manager_->UnregisterTaskQueueImpl(TakeTaskQueueImpl()); } @@ -372,12 +367,13 @@ impl_->SetOnTaskCompletedHandler(std::move(handler)); } -void TaskQueue::SetOnTaskPostedHandler(OnTaskPostedHandler handler) { +std::unique_ptr<TaskQueue::OnTaskPostedCallbackHandle> +TaskQueue::AddOnTaskPostedHandler(OnTaskPostedHandler handler) { DCHECK_CALLED_ON_VALID_THREAD(associated_thread_->thread_checker); if (!impl_) - return; + return nullptr; - impl_->SetOnTaskPostedHandler(std::move(handler)); + return impl_->AddOnTaskPostedHandler(std::move(handler)); } void TaskQueue::SetTaskExecutionTraceLogger(TaskExecutionTraceLogger logger) {
diff --git a/base/task/sequence_manager/task_queue.h b/base/task/sequence_manager/task_queue.h index 909820f..e45d64c 100644 --- a/base/task/sequence_manager/task_queue.h +++ b/base/task/sequence_manager/task_queue.h
@@ -7,6 +7,7 @@ #include <memory> +#include "base/compiler_specific.h" #include "base/memory/weak_ptr.h" #include "base/task/common/checked_lock.h" #include "base/task/sequence_manager/lazy_now.h" @@ -401,12 +402,29 @@ // finalize the task, and use the resulting timing. void SetOnTaskCompletedHandler(OnTaskCompletedHandler handler); - // Set a callback for adding custom functionality for processing posted task. + // RAII handle associated with an OnTaskPostedHandler. Unregisters the handler + // upon destruction. + class OnTaskPostedCallbackHandle { + public: + OnTaskPostedCallbackHandle(const OnTaskPostedCallbackHandle&) = delete; + OnTaskPostedCallbackHandle& operator=(const OnTaskPostedCallbackHandle&) = + delete; + virtual ~OnTaskPostedCallbackHandle() = default; + + protected: + OnTaskPostedCallbackHandle() = default; + }; + + // Add a callback for adding custom functionality for processing posted task. // Callback will be dispatched while holding a scheduler lock. As a result, // callback should not call scheduler APIs directly, as this can lead to // deadlocks. For example, PostTask should not be called directly and - // ScopedDeferTaskPosting::PostOrDefer should be used instead. - void SetOnTaskPostedHandler(OnTaskPostedHandler handler); + // ScopedDeferTaskPosting::PostOrDefer should be used instead. `handler` must + // not be a null callback. Must be called on the thread this task queue is + // associated with, and the handle returned must be destroyed on the same + // thread. + std::unique_ptr<OnTaskPostedCallbackHandle> AddOnTaskPostedHandler( + OnTaskPostedHandler handler) WARN_UNUSED_RESULT; // Set a callback to fill trace event arguments associated with the task // execution.
diff --git a/base/task/sequence_manager/task_queue_impl.cc b/base/task/sequence_manager/task_queue_impl.cc index 025cff1..4ac675e9 100644 --- a/base/task/sequence_manager/task_queue_impl.cc +++ b/base/task/sequence_manager/task_queue_impl.cc
@@ -14,10 +14,12 @@ #include "base/containers/stack_container.h" #include "base/feature_list.h" #include "base/logging.h" +#include "base/memory/scoped_refptr.h" #include "base/ranges/algorithm.h" #include "base/strings/stringprintf.h" #include "base/task/common/scoped_defer_task_posting.h" #include "base/task/default_delayed_task_handle_delegate.h" +#include "base/task/sequence_manager/associated_thread_id.h" #include "base/task/sequence_manager/delayed_task_handle_delegate.h" #include "base/task/sequence_manager/fence.h" #include "base/task/sequence_manager/sequence_manager_impl.h" @@ -286,17 +288,24 @@ } TaskDeque immediate_incoming_queue; + base::flat_map<raw_ptr<OnTaskPostedCallbackHandleImpl>, OnTaskPostedHandler> + on_task_posted_handlers; { base::internal::CheckedAutoLock lock(any_thread_lock_); any_thread_.unregistered = true; immediate_incoming_queue.swap(any_thread_.immediate_incoming_queue); + + for (auto& handler : any_thread_.on_task_posted_handlers) + handler.first->UnregisterTaskQueue(); + any_thread_.on_task_posted_handlers.swap(on_task_posted_handlers); } if (main_thread_only().wake_up_queue) { main_thread_only().wake_up_queue->UnregisterQueue(this); } + main_thread_only().on_task_started_handler = OnTaskStartedHandler(); main_thread_only().on_task_completed_handler = OnTaskCompletedHandler(); main_thread_only().wake_up_queue = nullptr; main_thread_only().throttler = nullptr; @@ -433,9 +442,10 @@ &any_thread_.immediate_incoming_queue.back(), name_); MaybeReportIpcTaskQueuedFromAnyThreadLocked( any_thread_.immediate_incoming_queue.back(), name_); - if (!any_thread_.on_task_posted_handler.is_null()) { - any_thread_.on_task_posted_handler.Run( - any_thread_.immediate_incoming_queue.back()); + + for (auto& handler : any_thread_.on_task_posted_handlers) { + DCHECK(!handler.second.is_null()); + handler.second.Run(any_thread_.immediate_incoming_queue.back()); } // If this queue was completely empty, then the SequenceManager needs to be @@ -1336,10 +1346,23 @@ !main_thread_only().on_task_completed_handler.is_null(); } -void TaskQueueImpl::SetOnTaskPostedHandler(OnTaskPostedHandler handler) { - DCHECK(should_notify_observers_ || handler.is_null()); +std::unique_ptr<TaskQueue::OnTaskPostedCallbackHandle> +TaskQueueImpl::AddOnTaskPostedHandler(OnTaskPostedHandler handler) { + DCHECK(should_notify_observers_ && !handler.is_null()); base::internal::CheckedAutoLock lock(any_thread_lock_); - any_thread_.on_task_posted_handler = std::move(handler); + std::unique_ptr<OnTaskPostedCallbackHandleImpl> handle = + std::make_unique<OnTaskPostedCallbackHandleImpl>(this, + associated_thread_); + any_thread_.on_task_posted_handlers.insert( + {handle.get(), std::move(handler)}); + return handle; +} + +void TaskQueueImpl::RemoveOnTaskPostedHandler( + TaskQueueImpl::OnTaskPostedCallbackHandleImpl* + on_task_posted_callback_handle) { + base::internal::CheckedAutoLock lock(any_thread_lock_); + any_thread_.on_task_posted_handlers.erase(on_task_posted_callback_handle); } void TaskQueueImpl::SetTaskExecutionTraceLogger( @@ -1550,6 +1573,21 @@ return state; } +TaskQueueImpl::OnTaskPostedCallbackHandleImpl::OnTaskPostedCallbackHandleImpl( + TaskQueueImpl* task_queue_impl, + scoped_refptr<AssociatedThreadId> associated_thread) + : task_queue_impl_(task_queue_impl), + associated_thread_(std::move(associated_thread)) { + DCHECK_CALLED_ON_VALID_THREAD(associated_thread_->thread_checker); +} + +TaskQueueImpl::OnTaskPostedCallbackHandleImpl:: + ~OnTaskPostedCallbackHandleImpl() { + DCHECK_CALLED_ON_VALID_THREAD(associated_thread_->thread_checker); + if (task_queue_impl_) + task_queue_impl_->RemoveOnTaskPostedHandler(this); +} + } // namespace internal } // namespace sequence_manager } // namespace base
diff --git a/base/task/sequence_manager/task_queue_impl.h b/base/task/sequence_manager/task_queue_impl.h index bb1d8ae..c976e50 100644 --- a/base/task/sequence_manager/task_queue_impl.h +++ b/base/task/sequence_manager/task_queue_impl.h
@@ -15,8 +15,11 @@ #include <vector> #include "base/callback.h" +#include "base/compiler_specific.h" +#include "base/containers/flat_map.h" #include "base/containers/intrusive_heap.h" #include "base/memory/raw_ptr.h" +#include "base/memory/scoped_refptr.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "base/pending_task.h" @@ -259,12 +262,14 @@ LazyNow* lazy_now); bool RequiresTaskTiming() const; - // Set a callback for adding custom functionality for processing posted task. + // Add a callback for adding custom functionality for processing posted task. // Callback will be dispatched while holding a scheduler lock. As a result, // callback should not call scheduler APIs directly, as this can lead to // deadlocks. For example, PostTask should not be called directly and - // ScopedDeferTaskPosting::PostOrDefer should be used instead. - void SetOnTaskPostedHandler(OnTaskPostedHandler handler); + // ScopedDeferTaskPosting::PostOrDefer should be used instead. `handler` must + // not be a null callback. + std::unique_ptr<TaskQueue::OnTaskPostedCallbackHandle> AddOnTaskPostedHandler( + OnTaskPostedHandler handler) WARN_UNUSED_RESULT; // Set a callback to fill trace event arguments associated with the task // execution. @@ -363,6 +368,23 @@ const TaskType task_type_; }; + class OnTaskPostedCallbackHandleImpl + : public TaskQueue::OnTaskPostedCallbackHandle { + public: + OnTaskPostedCallbackHandleImpl( + TaskQueueImpl* task_queue_impl, + scoped_refptr<AssociatedThreadId> associated_thread_); + ~OnTaskPostedCallbackHandleImpl() override; + + // Callback handles can outlive the associated TaskQueueImpl, so the + // reference needs to be cleared when the queue is unregistered. + void UnregisterTaskQueue() { task_queue_impl_ = nullptr; } + + private: + raw_ptr<TaskQueueImpl> task_queue_impl_; + scoped_refptr<AssociatedThreadId> associated_thread_; + }; + // A queue for holding delayed tasks before their delay has expired. struct DelayedIncomingQueue { public: @@ -524,6 +546,9 @@ void InsertFence(Fence fence); + void RemoveOnTaskPostedHandler( + OnTaskPostedCallbackHandleImpl* on_task_posted_callback_handle); + const char* name_; const raw_ptr<SequenceManagerImpl> sequence_manager_; @@ -556,7 +581,8 @@ bool unregistered = false; - OnTaskPostedHandler on_task_posted_handler; + base::flat_map<raw_ptr<OnTaskPostedCallbackHandleImpl>, OnTaskPostedHandler> + on_task_posted_handlers; #if DCHECK_IS_ON() // A cache of |immediate_work_queue->work_queue_set_index()| which is used
diff --git a/base/time/time.cc b/base/time/time.cc index ba0ba95..a0b7e50 100644 --- a/base/time/time.cc +++ b/base/time/time.cc
@@ -18,7 +18,6 @@ #include <tuple> #include <utility> -#include "base/compiler_specific.h" #include "base/strings/stringprintf.h" #include "base/third_party/nspr/prtime.h" #include "base/time/time_override.h" @@ -249,14 +248,14 @@ // midnight). In this case, midnight should be defined as 01:00:00am. DCHECK(is_local); exploded.hour = 1; - const bool result = FromExploded(is_local, exploded, &out_time); -// TODO(crbug.com/1263873): DCHECKs have limited coverage during automated -// testing on CrOS and this check failed when tested on an experimental builder. -// Testing for ARCH_CPU_ARM_FAMILY prevents regressing coverage on x86_64, -// which is already enabled. -// See go/chrome-dcheck-on-cros or http://crbug.com/1113456 for more details. + [[maybe_unused]] const bool result = + FromExploded(is_local, exploded, &out_time); #if BUILDFLAG(IS_CHROMEOS_ASH) && defined(ARCH_CPU_ARM_FAMILY) - ALLOW_UNUSED_LOCAL(result); + // TODO(crbug.com/1263873): DCHECKs have limited coverage during automated + // testing on CrOS and this check failed when tested on an experimental + // builder. Testing for ARCH_CPU_ARM_FAMILY prevents regressing coverage on + // x86_64, which is already enabled. See go/chrome-dcheck-on-cros or + // http://crbug.com/1113456 for more details. #else DCHECK(result); // This function must not fail. #endif
diff --git a/base/trace_event/process_memory_dump.cc b/base/trace_event/process_memory_dump.cc index b3a0b63..25666cea 100644 --- a/base/trace_event/process_memory_dump.cc +++ b/base/trace_event/process_memory_dump.cc
@@ -112,9 +112,12 @@ #endif while (offset < mapped_size) { - uintptr_t chunk_start = (start_pointer + offset); + // TODO(fuchsia): Port and remove [[maybe_unused]], see + // https://crbug.com/706592. + [[maybe_unused]] uintptr_t chunk_start = (start_pointer + offset); const size_t chunk_size = std::min(mapped_size - offset, kMaxChunkSize); - const size_t page_count = GetSystemPageCount(chunk_size, page_size); + [[maybe_unused]] const size_t page_count = + GetSystemPageCount(chunk_size, page_size); size_t resident_page_count = 0; #if defined(OS_WIN) for (size_t i = 0; i < page_count; i++) { @@ -129,8 +132,6 @@ resident_page_count += vec[i].VirtualAttributes.Valid; #elif defined(OS_FUCHSIA) // TODO(fuchsia): Port, see https://crbug.com/706592. - ALLOW_UNUSED_LOCAL(chunk_start); - ALLOW_UNUSED_LOCAL(page_count); #elif defined(OS_APPLE) // mincore in MAC does not fail with EAGAIN. failure =
diff --git a/base/tuple_unittest.cc b/base/tuple_unittest.cc index 4b38797..a8afb0a 100644 --- a/base/tuple_unittest.cc +++ b/base/tuple_unittest.cc
@@ -4,7 +4,6 @@ #include "base/tuple.h" -#include "base/compiler_specific.h" #include "testing/gtest/include/gtest/gtest.h" namespace base { @@ -32,14 +31,7 @@ } // namespace TEST(TupleTest, Basic) { - std::tuple<> t0 = std::make_tuple(); - ALLOW_UNUSED_LOCAL(t0); std::tuple<int> t1(1); - std::tuple<int, const char*> t2 = - std::make_tuple(1, static_cast<const char*>("wee")); - ALLOW_UNUSED_LOCAL(t2); - std::tuple<int, int, int> t3(1, 2, 3); - ALLOW_UNUSED_LOCAL(t3); std::tuple<int, int, int, int*> t4(1, 2, 3, &std::get<0>(t1)); std::tuple<int, int, int, int, int*> t5(1, 2, 3, 4, &std::get<0>(t4)); std::tuple<int, int, int, int, int, int*> t6(1, 2, 3, 4, 5, &std::get<0>(t4));
diff --git a/build/android/pylib/local/device/local_device_test_run_test.py b/build/android/pylib/local/device/local_device_test_run_test.py index 0de865e9..019e648 100755 --- a/build/android/pylib/local/device/local_device_test_run_test.py +++ b/build/android/pylib/local/device/local_device_test_run_test.py
@@ -62,6 +62,11 @@ class LocalDeviceTestRunTest(unittest.TestCase): + def testSortTests(self): + test_run = TestLocalDeviceTestRun() + self.assertEqual(test_run._SortTests(['a', 'b', 'c', 'd', 'e', 'f', 'g']), + ['d', 'f', 'c', 'b', 'e', 'a', 'g']) + def testGetTestsToRetry_allTestsPassed(self): results = [ base_test_result.BaseTestResult(
diff --git a/build/fuchsia/linux.sdk.sha1 b/build/fuchsia/linux.sdk.sha1 index 80fa063..2c6d18a 100644 --- a/build/fuchsia/linux.sdk.sha1 +++ b/build/fuchsia/linux.sdk.sha1
@@ -1 +1 @@ -7.20220113.1.1 +7.20220113.2.1
diff --git a/build/fuchsia/mac.sdk.sha1 b/build/fuchsia/mac.sdk.sha1 index 0fce7a1..2c6d18a 100644 --- a/build/fuchsia/mac.sdk.sha1 +++ b/build/fuchsia/mac.sdk.sha1
@@ -1 +1 @@ -7.20220113.0.1 +7.20220113.2.1
diff --git a/cc/BUILD.gn b/cc/BUILD.gn index 2893ad4..2ad4752 100644 --- a/cc/BUILD.gn +++ b/cc/BUILD.gn
@@ -550,6 +550,7 @@ "test/layer_tree_pixel_test.h", "test/layer_tree_test.cc", "test/layer_tree_test.h", + "test/lottie_test_data.cc", "test/lottie_test_data.h", "test/mock_latency_info_swap_promise_monitor.cc", "test/mock_latency_info_swap_promise_monitor.h",
diff --git a/cc/test/lottie_test_data.cc b/cc/test/lottie_test_data.cc new file mode 100644 index 0000000..022b282 --- /dev/null +++ b/cc/test/lottie_test_data.cc
@@ -0,0 +1,24 @@ +// 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 "cc/test/lottie_test_data.h" + +#include "base/strings/string_util.h" + +namespace cc { + +std::string CreateCustomLottieDataWith2Assets( + base::StringPiece custom_asset_id_0, + base::StringPiece custom_asset_id_1) { + CHECK(!custom_asset_id_0.empty()); + CHECK(!custom_asset_id_1.empty()); + std::string output(kLottieDataWith2Assets); + base::ReplaceSubstringsAfterOffset(&output, /*start_offset=*/0, "image_0", + custom_asset_id_0); + base::ReplaceSubstringsAfterOffset(&output, /*start_offset=*/0, "image_1", + custom_asset_id_1); + return output; +} + +} // namespace cc
diff --git a/cc/test/lottie_test_data.h b/cc/test/lottie_test_data.h index 4fe9c68..ad9bfe2 100644 --- a/cc/test/lottie_test_data.h +++ b/cc/test/lottie_test_data.h
@@ -5,7 +5,10 @@ #ifndef CC_TEST_LOTTIE_TEST_DATA_H_ #define CC_TEST_LOTTIE_TEST_DATA_H_ +#include <string> + #include "base/strings/string_piece.h" +#include "base/time/time.h" namespace cc { @@ -75,6 +78,7 @@ // then image_1 for another second. constexpr int kLottieDataWith2AssetsWidth = 690; constexpr int kLottieDataWith2AssetsHeight = 455; +constexpr base::TimeDelta kLottieDataWith2AssetsDuration = base::Seconds(2); constexpr base::StringPiece kLottieDataWith2Assets = R"({ "v": "5.7.4", @@ -277,6 +281,12 @@ "markers": [] })"; +// Returns an animation with the same structure as |kLottieDataWith2Assets| +// except with asset ids specified by the caller. +std::string CreateCustomLottieDataWith2Assets( + base::StringPiece custom_asset_id_0, + base::StringPiece custom_asset_id_1); + } // namespace cc #endif // CC_TEST_LOTTIE_TEST_DATA_H_
diff --git a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/PriceTrackingUtilities.java b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/PriceTrackingUtilities.java index ac6d256..688033c 100644 --- a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/PriceTrackingUtilities.java +++ b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/PriceTrackingUtilities.java
@@ -14,6 +14,7 @@ import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.signin.services.IdentityServicesProvider; import org.chromium.chrome.browser.signin.services.UnifiedConsentServiceBridge; +import org.chromium.chrome.browser.subscriptions.CommerceSubscriptionsServiceConfig; import org.chromium.chrome.browser.sync.SyncService; import org.chromium.chrome.browser.tabmodel.TabModel; import org.chromium.components.signin.identitymanager.ConsentLevel; @@ -167,6 +168,7 @@ */ public static boolean isPriceAlertsMessageCardEnabled() { return isPriceDropNotificationEligible() + && CommerceSubscriptionsServiceConfig.isImplicitSubscriptionsEnabled() && SHARED_PREFERENCES_MANAGER.readBoolean( PRICE_ALERTS_MESSAGE_CARD, isPriceTrackingEnabled()) && (!(new PriceDropNotificationManager()).canPostNotification());
diff --git a/chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/PriceAlertsMessageCardTest.java b/chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/PriceAlertsMessageCardTest.java index ee34299..9d53800 100644 --- a/chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/PriceAlertsMessageCardTest.java +++ b/chrome/android/features/tab_ui/javatests/src/org/chromium/chrome/browser/tasks/tab_management/PriceAlertsMessageCardTest.java
@@ -82,7 +82,8 @@ public class PriceAlertsMessageCardTest { // clang-format on private static final String BASE_PARAMS = - "force-fieldtrial-params=Study.Group:enable_price_notification/true"; + "force-fieldtrial-params=Study.Group:enable_price_notification/true" + + "/implicit_subscriptions_enabled/true"; private static final String ACTION_APP_NOTIFICATION_SETTINGS = "android.settings.APP_NOTIFICATION_SETTINGS"; private static final String METRICS_IDENTIFIER = @@ -194,8 +195,10 @@ @Test @MediumTest - @CommandLineFlags.Add({"force-fieldtrial-params=Study.Group:enable_price_notification/false"}) - public void testMessageCardNotShowing_ParameterDisabled() { + @CommandLineFlags.Add({"force-fieldtrial-params=Study.Group:enable_price_notification/false" + + "/implicit_subscriptions_enabled/true"}) + public void + testMessageCardNotShowing_NotificationParameterDisabled() { final ChromeTabbedActivity cta = mActivityTestRule.getActivity(); assertFalse(PriceTrackingUtilities.isPriceDropNotificationEligible()); mMockNotificationManager.setNotificationsEnabled(false); @@ -208,6 +211,22 @@ @Test @MediumTest + @CommandLineFlags.Add({"force-fieldtrial-params=Study.Group:enable_price_notification/true" + + "/implicit_subscriptions_enabled/false"}) + public void + testMessageCardNotShowing_ImplicitSubscriptionsParameterDisabled() { + final ChromeTabbedActivity cta = mActivityTestRule.getActivity(); + assertTrue(PriceTrackingUtilities.isPriceDropNotificationEligible()); + mMockNotificationManager.setNotificationsEnabled(false); + assertFalse(mPriceDropNotificationManager.canPostNotification()); + assertFalse(PriceTrackingUtilities.isPriceAlertsMessageCardEnabled()); + + enterTabSwitcher(cta); + onView(withId(R.id.large_message_card_item)).check(doesNotExist()); + } + + @Test + @MediumTest @CommandLineFlags.Add({BASE_PARAMS}) @MinAndroidSdkLevel(Build.VERSION_CODES.O) public void testReviewMessage_AppNotificationsEnabled() {
diff --git a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/PriceMessageServiceUnitTest.java b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/PriceMessageServiceUnitTest.java index 246b18a5..58580bb 100644 --- a/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/PriceMessageServiceUnitTest.java +++ b/chrome/android/features/tab_ui/junit/src/org/chromium/chrome/browser/tasks/tab_management/PriceMessageServiceUnitTest.java
@@ -31,6 +31,7 @@ import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.price_tracking.PriceDropNotificationManager; +import org.chromium.chrome.browser.subscriptions.CommerceSubscriptionsServiceConfig; import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.state.ShoppingPersistedTabData; import org.chromium.chrome.browser.tasks.tab_management.MessageService.MessageType; @@ -80,6 +81,8 @@ testValues.addFeatureFlagOverride(ChromeFeatureList.COMMERCE_PRICE_TRACKING, true); testValues.addFieldTrialParamOverride(ChromeFeatureList.COMMERCE_PRICE_TRACKING, PriceTrackingUtilities.PRICE_NOTIFICATION_PARAM, "true"); + testValues.addFieldTrialParamOverride(ChromeFeatureList.COMMERCE_PRICE_TRACKING, + CommerceSubscriptionsServiceConfig.IMPLICIT_SUBSCRIPTIONS_ENABLED_PARAM, "true"); FeatureList.setTestValues(testValues); PriceTrackingUtilities.setIsSignedInAndSyncEnabledForTesting(true);
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkBridge.java index d56d1b0..bf89dbf 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkBridge.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/bookmarks/BookmarkBridge.java
@@ -327,6 +327,7 @@ mSubscriptionManager = new CommerceSubscriptionsServiceFactory() .getForLastUsedProfile() .getSubscriptionsManager(); + mSubscriptionManager.addObserver(mSubscriptionsObserver); } }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java index 56dc776..8f65cca 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java
@@ -1255,8 +1255,7 @@ ExternalNavigationHandler externalNavHandler, NavigationParams navigationParams) { assert mSearchPanel != null; mRedirectHandler.updateNewUrlLoading(navigationParams.pageTransitionType, - navigationParams.isRedirect, - navigationParams.hasUserGesture || navigationParams.hasUserGestureCarryover, + navigationParams.isRedirect, navigationParams.hasUserGesture, mLastUserInteractionTimeSupplier.get(), RedirectHandler.INVALID_ENTRY_INDEX, true /* isInitialNavigation */); ExternalNavigationParams params =
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/paint_preview/StartupPaintPreviewHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/paint_preview/StartupPaintPreviewHelper.java index 30b18d2..aab1a27c 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/paint_preview/StartupPaintPreviewHelper.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/paint_preview/StartupPaintPreviewHelper.java
@@ -35,7 +35,7 @@ public class StartupPaintPreviewHelper { public static final BooleanCachedFieldTrialParameter ACCESSIBILITY_SUPPORT_PARAM = new BooleanCachedFieldTrialParameter(ChromeFeatureList.PAINT_PREVIEW_SHOW_ON_STARTUP, - "has_accessibility_support", false); + "has_accessibility_support", true); /** * Tracks whether a paint preview should be shown on tab restore. We use this to only attempt * to display a paint preview on the first tab restoration that happens on Chrome startup when
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java index 45ab0b33..3923866 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java
@@ -2598,8 +2598,7 @@ GURL.emptyGURL(), 0 /* navigationId */, false /* isPost */, true /* hasUserGesture */, PageTransition.LINK, false /* isRedirect */, true /* isExternalProtocol */, true /* isMainFrame */, - true /* isRendererInitiated */, false /* hasUserGestureCarryover */, - null /* initiatorOrigin */); + true /* isRendererInitiated */, null /* initiatorOrigin */); InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { @@ -2630,19 +2629,17 @@ final ExternalNavigationHandler externalNavHandler = new ExternalNavigationHandler(delegate); - final NavigationParams initialNavigationParams = - new NavigationParams(new GURL("http://test.com"), GURL.emptyGURL(), - 0 /* navigationId */, false /* isPost */, true /* hasUserGesture */, - PageTransition.LINK, false /* isRedirect */, false /* isExternalProtocol */, - true /* isMainFrame */, true /* isRendererInitiated */, - false /* hasUserGestureCarryover */, null /* initiatorOrigin */); + final NavigationParams initialNavigationParams = new NavigationParams( + new GURL("http://test.com"), GURL.emptyGURL(), 0 /* navigationId */, + false /* isPost */, true /* hasUserGesture */, PageTransition.LINK, + false /* isRedirect */, false /* isExternalProtocol */, true /* isMainFrame */, + true /* isRendererInitiated */, null /* initiatorOrigin */); final NavigationParams redirectedNavigationParams = new NavigationParams( new GURL("intent://test/#Intent;scheme=test;package=com.chrome.test;end"), GURL.emptyGURL(), 0 /* navigationId */, false /* isPost */, false /* hasUserGesture */, PageTransition.LINK, true /* isRedirect */, true /* isExternalProtocol */, true /* isMainFrame */, - true /* isRendererInitiated */, false /* hasUserGestureCarryover */, - null /* initiatorOrigin */); + true /* isRendererInitiated */, null /* initiatorOrigin */); InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { @Override @@ -2679,8 +2676,7 @@ GURL.emptyGURL(), 0 /* navigationId */, false /* isPost */, false /* hasUserGesture */, PageTransition.LINK, false /* isRedirect */, true /* isExternalProtocol */, true /* isMainFrame */, - true /* isRendererInitiated */, false /* hasUserGestureCarryover */, - null /* initiatorOrigin */); + true /* isRendererInitiated */, null /* initiatorOrigin */); InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() {
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/tab/InterceptNavigationDelegateTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/tab/InterceptNavigationDelegateTest.java index 5cc1270..4e58907 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/tab/InterceptNavigationDelegateTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/tab/InterceptNavigationDelegateTest.java
@@ -136,7 +136,6 @@ waitTillExpectedCallsComplete(2, DEFAULT_MAX_TIME_TO_WAIT_IN_MS); Assert.assertFalse(mNavParamHistory.get(1).hasUserGesture); - Assert.assertFalse(mNavParamHistory.get(1).hasUserGestureCarryover); } @Test @@ -149,8 +148,6 @@ DOMUtils.clickNode(mActivity.getActivityTab().getWebContents(), "first"); waitTillExpectedCallsComplete(2, DEFAULT_MAX_TIME_TO_WAIT_IN_MS); Assert.assertTrue(mNavParamHistory.get(1).hasUserGesture); - // TODO(mustaq): Not clear why cary-over is different here vs the next test. - Assert.assertFalse(mNavParamHistory.get(1).hasUserGestureCarryover); } @Test @@ -164,7 +161,6 @@ waitTillExpectedCallsComplete(2, DEFAULT_MAX_TIME_TO_WAIT_IN_MS); Assert.assertTrue(mNavParamHistory.get(1).hasUserGesture); - Assert.assertFalse(mNavParamHistory.get(1).hasUserGestureCarryover); } @Test @@ -179,7 +175,6 @@ waitTillExpectedCallsComplete(2, DEFAULT_MAX_TIME_TO_WAIT_IN_MS); Assert.assertTrue(mNavParamHistory.get(1).hasUserGesture); - Assert.assertFalse(mNavParamHistory.get(1).hasUserGestureCarryover); } @Test @@ -193,7 +188,6 @@ DOMUtils.clickNode(mActivity.getActivityTab().getWebContents(), "first"); waitTillExpectedCallsComplete(2, LONG_MAX_TIME_TO_WAIT_IN_MS); Assert.assertFalse(mNavParamHistory.get(1).hasUserGesture); - Assert.assertFalse(mNavParamHistory.get(1).hasUserGestureCarryover); } @Test @@ -207,7 +201,6 @@ waitTillExpectedCallsComplete(2, DEFAULT_MAX_TIME_TO_WAIT_IN_MS); Assert.assertTrue(mNavParamHistory.get(1).hasUserGesture); - Assert.assertFalse(mNavParamHistory.get(1).hasUserGestureCarryover); } @Test
diff --git a/chrome/app/settings_strings.grdp b/chrome/app/settings_strings.grdp index 90cb261..3ff0c45 100644 --- a/chrome/app/settings_strings.grdp +++ b/chrome/app/settings_strings.grdp
@@ -1384,9 +1384,6 @@ <message name="IDS_SETTINGS_PRIVACY_REVIEW_WELCOME_CARD_START_BUTTON" desc="Text of a button in the welcome card in the privacy review that starts the privacy review."> Get started </message> - <message name="IDS_SETTINGS_PRIVACY_REVIEW_WELCOME_CARD_DONT_SHOW_AGAIN_CHECKBOX" desc="Text of a checkbox in the welcome card in the privacy review that prevents the welcome card from being shown again in the future."> - Don’t show this step again - </message> <message name="IDS_SETTINGS_PRIVACY_REVIEW_COMPLETION_CARD_HEADER" desc="A header shown at the top of the completion card in the privacy review that informs users that they completed the privacy review."> Review complete! </message>
diff --git a/chrome/app/settings_strings_grdp/IDS_SETTINGS_PRIVACY_REVIEW_WELCOME_CARD_DONT_SHOW_AGAIN_CHECKBOX.png.sha1 b/chrome/app/settings_strings_grdp/IDS_SETTINGS_PRIVACY_REVIEW_WELCOME_CARD_DONT_SHOW_AGAIN_CHECKBOX.png.sha1 deleted file mode 100644 index 39fbcd8..0000000 --- a/chrome/app/settings_strings_grdp/IDS_SETTINGS_PRIVACY_REVIEW_WELCOME_CARD_DONT_SHOW_AGAIN_CHECKBOX.png.sha1 +++ /dev/null
@@ -1 +0,0 @@ -0cad1f7f9664087f03c7dc1a154351effe149a6b \ No newline at end of file
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index fad4570..555fa3d3 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc
@@ -4855,11 +4855,6 @@ flag_descriptions::kTabGroupsAutoCreateDescription, kOsDesktop, FEATURE_VALUE_TYPE(features::kTabGroupsAutoCreate)}, - {"tab-groups-collapse-freezing", - flag_descriptions::kTabGroupsCollapseFreezingName, - flag_descriptions::kTabGroupsCollapseFreezingDescription, kOsDesktop, - FEATURE_VALUE_TYPE(features::kTabGroupsCollapseFreezing)}, - {"tab-groups-new-badge-promo", flag_descriptions::kTabGroupsNewBadgePromoName, flag_descriptions::kTabGroupsNewBadgePromoDescription, kOsDesktop, @@ -5453,13 +5448,6 @@ FEATURE_VALUE_TYPE(features::kVaapiWebPImageDecodeAcceleration)}, #endif -#if defined(OS_WIN) - {"calculate-native-win-occlusion", - flag_descriptions::kCalculateNativeWinOcclusionName, - flag_descriptions::kCalculateNativeWinOcclusionDescription, kOsWin, - FEATURE_VALUE_TYPE(features::kCalculateNativeWinOcclusion)}, -#endif // OS_WIN - #if !defined(OS_ANDROID) {"happiness-tracking-surveys-for-desktop-demo", flag_descriptions::kHappinessTrackingSurveysForDesktopDemoName,
diff --git a/chrome/browser/android/ntp/recent_tabs_page_prefs.cc b/chrome/browser/android/ntp/recent_tabs_page_prefs.cc index 35e8eac..b63cc84d 100644 --- a/chrome/browser/android/ntp/recent_tabs_page_prefs.cc +++ b/chrome/browser/android/ntp/recent_tabs_page_prefs.cc
@@ -83,10 +83,9 @@ // Store session tags for collapsed sessions in a preference so that the // collapsed state persists. PrefService* prefs = profile_->GetPrefs(); - DictionaryPrefUpdateDeprecated update(prefs, - prefs::kNtpCollapsedForeignSessions); + DictionaryPrefUpdate update(prefs, prefs::kNtpCollapsedForeignSessions); if (is_collapsed) - update.Get()->SetBoolean(ConvertJavaStringToUTF8(env, session_tag), true); + update.Get()->SetBoolKey(ConvertJavaStringToUTF8(env, session_tag), true); else update.Get()->RemoveKey(ConvertJavaStringToUTF8(env, session_tag)); }
diff --git a/chrome/browser/android/tab_web_contents_delegate_android.cc b/chrome/browser/android/tab_web_contents_delegate_android.cc index 3dec809..f0ab922b 100644 --- a/chrome/browser/android/tab_web_contents_delegate_android.cc +++ b/chrome/browser/android/tab_web_contents_delegate_android.cc
@@ -441,14 +441,6 @@ ShowFramebustBlockInfobarInternal(web_contents, blocked_url); } -void TabWebContentsDelegateAndroid::UpdateUserGestureCarryoverInfo( - content::WebContents* web_contents) { - auto* intercept_navigation_delegate = - navigation_interception::InterceptNavigationDelegate::Get(web_contents); - if (intercept_navigation_delegate) - intercept_navigation_delegate->UpdateLastUserGestureCarryoverTimestamp(); -} - content::PictureInPictureResult TabWebContentsDelegateAndroid::EnterPictureInPicture( content::WebContents* web_contents,
diff --git a/chrome/browser/android/tab_web_contents_delegate_android.h b/chrome/browser/android/tab_web_contents_delegate_android.h index 65c6861..2a3022a 100644 --- a/chrome/browser/android/tab_web_contents_delegate_android.h +++ b/chrome/browser/android/tab_web_contents_delegate_android.h
@@ -95,8 +95,6 @@ const GURL& blocked_url, const GURL& initiator_url, blink::mojom::NavigationBlockedReason reason) override; - void UpdateUserGestureCarryoverInfo( - content::WebContents* web_contents) override; content::PictureInPictureResult EnterPictureInPicture( content::WebContents* web_contents, const viz::SurfaceId&,
diff --git a/chrome/browser/apps/app_service/intent_util.cc b/chrome/browser/apps/app_service/intent_util.cc index 5b303f1f..2dc9441 100644 --- a/chrome/browser/apps/app_service/intent_util.cc +++ b/chrome/browser/apps/app_service/intent_util.cc
@@ -14,6 +14,7 @@ #include "base/notreached.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" +#include "build/build_config.h" #include "chrome/browser/apps/app_service/file_utils.h" #include "chrome/browser/ui/extensions/application_launch.h" #include "chrome/browser/web_applications/web_app.h" @@ -29,7 +30,7 @@ #include "mojo/public/cpp/bindings/struct_ptr.h" #include "url/gurl.h" -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) #include "base/files/file_path.h" #include "base/files/safe_base_name.h" #include "chromeos/crosapi/mojom/app_service_types.mojom.h" @@ -750,7 +751,7 @@ } #endif // BUILDFLAG(IS_CHROMEOS_ASH) -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) crosapi::mojom::IntentPtr ConvertAppServiceToCrosapiIntent( const apps::mojom::IntentPtr& app_service_intent, Profile* profile) {
diff --git a/chrome/browser/apps/app_service/intent_util.h b/chrome/browser/apps/app_service/intent_util.h index 5d7996f..8f877b0b 100644 --- a/chrome/browser/apps/app_service/intent_util.h +++ b/chrome/browser/apps/app_service/intent_util.h
@@ -9,12 +9,13 @@ #include <vector> #include "base/containers/flat_map.h" +#include "build/build_config.h" #include "build/buildflag.h" #include "build/chromeos_buildflags.h" #include "components/services/app_service/public/mojom/types.mojom-forward.h" #include "third_party/abseil-cpp/absl/types/optional.h" -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) #include "chromeos/crosapi/mojom/app_service_types.mojom-forward.h" #endif @@ -111,7 +112,7 @@ const arc::IntentFilter& arc_intent_filter); #endif -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) // Convert App Service Intent to Crosapi Intent. // |profile| is only needed when the intent contains files, can be filled with // null otherwise.
diff --git a/chrome/browser/apps/app_service/intent_util_unittest.cc b/chrome/browser/apps/app_service/intent_util_unittest.cc index 14e0679f..1f290f74 100644 --- a/chrome/browser/apps/app_service/intent_util_unittest.cc +++ b/chrome/browser/apps/app_service/intent_util_unittest.cc
@@ -2,6 +2,8 @@ // 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/intent_util.h" + #include <initializer_list> #include <memory> #include <string> @@ -13,8 +15,8 @@ #include "base/check.h" #include "base/containers/flat_map.h" #include "base/values.h" +#include "build/build_config.h" #include "build/chromeos_buildflags.h" -#include "chrome/browser/apps/app_service/intent_util.h" #include "chrome/browser/ash/file_manager/fileapi_util.h" #include "chrome/browser/web_applications/test/web_app_test_utils.h" #include "chrome/browser/web_applications/web_app.h" @@ -594,7 +596,7 @@ } } -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) TEST_F(IntentUtilsTest, CrosapiIntentConversion) { apps::mojom::IntentPtr original_intent = apps_util::CreateIntentFromUrl(GURL("www.google.com"));
diff --git a/chrome/browser/apps/app_service/launch_result_type.cc b/chrome/browser/apps/app_service/launch_result_type.cc index 170e40ed..6165864 100644 --- a/chrome/browser/apps/app_service/launch_result_type.cc +++ b/chrome/browser/apps/app_service/launch_result_type.cc
@@ -4,13 +4,15 @@ #include "chrome/browser/apps/app_service/launch_result_type.h" -#if defined(OS_CHROMEOS) +#include "build/build_config.h" + +#if BUILDFLAG(IS_CHROMEOS) #include "chromeos/crosapi/mojom/app_service_types.mojom.h" -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) namespace apps { -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) LaunchResult ConvertMojomLaunchResultToLaunchResult( crosapi::mojom::LaunchResultPtr mojom_launch_result) { auto launch_result = LaunchResult(); @@ -29,6 +31,6 @@ }, std::move(callback)); } -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) } // namespace apps
diff --git a/chrome/browser/apps/app_service/launch_result_type.h b/chrome/browser/apps/app_service/launch_result_type.h index b9059cb7..acd30aac 100644 --- a/chrome/browser/apps/app_service/launch_result_type.h +++ b/chrome/browser/apps/app_service/launch_result_type.h
@@ -7,10 +7,11 @@ #include "base/callback_forward.h" #include "base/unguessable_token.h" +#include "build/build_config.h" -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) #include "chromeos/crosapi/mojom/app_service_types.mojom-forward.h" -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) namespace apps { // LaunchResult, and LaunchCallback can be used in Chrome Ash, lacros, and other @@ -22,13 +23,13 @@ using LaunchCallback = base::OnceCallback<void(LaunchResult&&)>; -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) LaunchResult ConvertMojomLaunchResultToLaunchResult( crosapi::mojom::LaunchResultPtr mojom_launch_result); base::OnceCallback<void(crosapi::mojom::LaunchResultPtr)> LaunchResultToMojomLaunchResultCallback(LaunchCallback callback); -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) } // namespace apps
diff --git a/chrome/browser/apps/app_service/launch_utils.cc b/chrome/browser/apps/app_service/launch_utils.cc index a71f6b6..19f4c74 100644 --- a/chrome/browser/apps/app_service/launch_utils.cc +++ b/chrome/browser/apps/app_service/launch_utils.cc
@@ -33,11 +33,11 @@ #include "ui/events/event_constants.h" #include "url/gurl.h" -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) #include "chromeos/crosapi/mojom/app_service_types.mojom.h" -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) namespace { // Use manual mapping for launch container and window open disposition because // we cannot use mojom traits for crosapi::mojom::LaunchParams yet. Move to auto @@ -129,7 +129,7 @@ } } // namespace -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) namespace apps { @@ -142,7 +142,7 @@ launch_files.reserve(command_line.GetArgs().size()); for (const auto& arg : command_line.GetArgs()) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) GURL url(base::AsStringPiece16(arg)); #else GURL url(arg); @@ -354,7 +354,7 @@ } #endif // BUILDFLAG(IS_CHROMEOS_ASH) -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) crosapi::mojom::LaunchParamsPtr ConvertLaunchParamsToCrosapi( const apps::AppLaunchParams& params, Profile* profile) { @@ -430,6 +430,6 @@ ConvertWindowModeToAppLaunchContainer(window_mode)); return apps::ConvertLaunchParamsToCrosapi(launch_params, proxy->profile()); } -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) } // namespace apps
diff --git a/chrome/browser/apps/app_service/launch_utils.h b/chrome/browser/apps/app_service/launch_utils.h index 697ee049..2b77d20 100644 --- a/chrome/browser/apps/app_service/launch_utils.h +++ b/chrome/browser/apps/app_service/launch_utils.h
@@ -8,16 +8,17 @@ #include <string> #include <vector> +#include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "chrome/browser/apps/app_service/app_launch_params.h" #include "components/services/app_service/public/mojom/types.mojom.h" #include "extensions/common/constants.h" #include "ui/base/window_open_disposition.h" -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) #include "chrome/browser/apps/app_service/app_service_proxy_forward.h" #include "chromeos/crosapi/mojom/app_service_types.mojom-forward.h" -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) #if BUILDFLAG(IS_CHROMEOS_ASH) #include "ash/components/arc/mojom/app.mojom.h" @@ -92,7 +93,7 @@ apps::mojom::WindowInfoPtr window_info); #endif // BUILDFLAG(IS_CHROMEOS_ASH) -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) // Helper to convert apps::AppLaunchParams to crosapi::mojom::LaunchParams. // This is needed because we cannot use traits to convert Intent at the moment, // After that is done, this can be moved to the mojom type traits. @@ -113,7 +114,7 @@ int event_flags, apps::mojom::LaunchSource launch_source, int64_t display_id); -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) } // namespace apps
diff --git a/chrome/browser/apps/app_service/launch_utils_unittest.cc b/chrome/browser/apps/app_service/launch_utils_unittest.cc index 009d46d..095cf3a 100644 --- a/chrome/browser/apps/app_service/launch_utils_unittest.cc +++ b/chrome/browser/apps/app_service/launch_utils_unittest.cc
@@ -4,6 +4,7 @@ #include "chrome/browser/apps/app_service/launch_utils.h" +#include "build/build_config.h" #include "chrome/browser/apps/app_service/app_launch_params.h" #include "chrome/common/chrome_switches.h" #include "chrome/test/base/testing_profile.h" @@ -12,9 +13,9 @@ #include "testing/gtest/include/gtest/gtest.h" #include "ui/display/types/display_constants.h" -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) #include "chromeos/crosapi/mojom/app_service_types.mojom.h" -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) class LaunchUtilsTest : public testing::Test { protected: @@ -201,7 +202,7 @@ EXPECT_EQ(0U, launch_files.size()); } -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) // Verifies that convert params (with no override url, intent, files) to crosapi // and back works. TEST_F(LaunchUtilsTest, ConvertToCrosapi) { @@ -337,4 +338,4 @@ } #endif // BUILDFLAG(IS_CHROMEOS_LACROS) -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS)
diff --git a/chrome/browser/apps/app_service/web_contents_app_id_utils.cc b/chrome/browser/apps/app_service/web_contents_app_id_utils.cc index e0a40ff..6712898 100644 --- a/chrome/browser/apps/app_service/web_contents_app_id_utils.cc +++ b/chrome/browser/apps/app_service/web_contents_app_id_utils.cc
@@ -4,6 +4,7 @@ #include "chrome/browser/apps/app_service/web_contents_app_id_utils.h" +#include "build/build_config.h" #include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h" #include "chrome/browser/apps/app_service/launch_utils.h" @@ -44,7 +45,7 @@ return app_installed; } -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) const extensions::Extension* GetExtensionForWebContents( Profile* profile, content::WebContents* tab) { @@ -68,7 +69,7 @@ } // namespace -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) absl::optional<std::string> GetInstanceAppIdForWebContents( content::WebContents* tab) { Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext());
diff --git a/chrome/browser/apps/app_service/web_contents_app_id_utils.h b/chrome/browser/apps/app_service/web_contents_app_id_utils.h index d5ddaa2..c4e219e 100644 --- a/chrome/browser/apps/app_service/web_contents_app_id_utils.h +++ b/chrome/browser/apps/app_service/web_contents_app_id_utils.h
@@ -7,6 +7,7 @@ #include <string> +#include "build/build_config.h" #include "third_party/abseil-cpp/absl/types/optional.h" class Profile; @@ -31,7 +32,7 @@ namespace apps { -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) // Get ID of the app running in WebContents as defined by the instance registry // and the shelf. Checks for web apps, and extension-based apps (hosted app, // packaged v1 apps).
diff --git a/chrome/browser/apps/guest_view/app_view_browsertest.cc b/chrome/browser/apps/guest_view/app_view_browsertest.cc index 0a399d7..294923f 100644 --- a/chrome/browser/apps/guest_view/app_view_browsertest.cc +++ b/chrome/browser/apps/guest_view/app_view_browsertest.cc
@@ -119,8 +119,8 @@ // Tests that <appview> correctly processes parameters passed on connect. // Flaky on Windows, Linux and Mac. See https://crbug.com/875908 -#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ - defined(OS_MAC) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || \ + BUILDFLAG(IS_MAC) #define MAYBE_TestAppViewRefusedDataShouldFail \ DISABLED_TestAppViewRefusedDataShouldFail #else
diff --git a/chrome/browser/apps/guest_view/web_view_browsertest.cc b/chrome/browser/apps/guest_view/web_view_browsertest.cc index cdda7e5..a5065a5 100644 --- a/chrome/browser/apps/guest_view/web_view_browsertest.cc +++ b/chrome/browser/apps/guest_view/web_view_browsertest.cc
@@ -1397,8 +1397,8 @@ TestHelper("testDisplayNoneWebviewLoad", "web_view/shim", NO_TEST_SERVER); } -#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ - defined(OS_MAC) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || \ + BUILDFLAG(IS_MAC) #define MAYBE_Shim_TestDisplayNoneWebviewRemoveChild \ DISABLED_Shim_TestDisplayNoneWebviewRemoveChild #else @@ -1489,7 +1489,7 @@ NEEDS_TEST_SERVER); } -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) #define MAYBE_Shim_TestAddContentScriptsWithNewWindowAPI \ DISABLED_Shim_TestAddContentScriptsWithNewWindowAPI #else @@ -1584,7 +1584,7 @@ "web_view/shim", NEEDS_TEST_SERVER); } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Flaky on Mac. See https://crbug.com/674904. #define MAYBE_Shim_TestNestedSubframes DISABLED_Shim_TestNestedSubframes #else @@ -2092,7 +2092,7 @@ // Test makes sure that interstitial pages renders in <webview>. // Flaky on Win dbg: crbug.com/779973 -#if defined(OS_WIN) && !defined(NDEBUG) +#if BUILDFLAG(IS_WIN) && !defined(NDEBUG) #define MAYBE_InterstitialPage DISABLED_InterstitialPage #else #define MAYBE_InterstitialPage InterstitialPage @@ -2112,7 +2112,7 @@ // Test makes sure that interstitial pages are registered in the // RenderWidgetHostInputEventRouter when inside a <webview>. // Flaky on Win dbg: crbug.com/779973 -#if defined(OS_WIN) && !defined(NDEBUG) +#if BUILDFLAG(IS_WIN) && !defined(NDEBUG) #define MAYBE_InterstitialPageRouteEvents DISABLED_InterstitialPageRouteEvents #else #define MAYBE_InterstitialPageRouteEvents InterstitialPageRouteEvents @@ -2135,7 +2135,7 @@ // Test makes sure that the browser does not crash when a <webview> navigates // out of an interstitial. // Flaky on Win dbg: crbug.com/779973 -#if defined(OS_WIN) && !defined(NDEBUG) +#if BUILDFLAG(IS_WIN) && !defined(NDEBUG) #define MAYBE_InterstitialPageDetach DISABLED_InterstitialPageDetach #else #define MAYBE_InterstitialPageDetach InterstitialPageDetach @@ -2159,7 +2159,7 @@ // This test makes sure the browser process does not crash if app is closed // while an interstitial page is being shown in guest. // Flaky on Win dbg: crbug.com/779973 -#if defined(OS_WIN) && !defined(NDEBUG) +#if BUILDFLAG(IS_WIN) && !defined(NDEBUG) #define MAYBE_InterstitialTeardown DISABLED_InterstitialTeardown #else #define MAYBE_InterstitialTeardown InterstitialTeardown @@ -3109,7 +3109,7 @@ << message_; } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Test is disabled on Windows because it fails often (~9% time) // http://crbug.com/489088 #define MAYBE_ClearDataCache DISABLED_ClearDataCache @@ -3237,7 +3237,7 @@ } // namespace // TODO(crbug.com/994789): Flaky on MSan, Linux, and Chrome OS. -#if defined(MEMORY_SANITIZER) || defined(OS_LINUX) || defined(OS_CHROMEOS) +#if defined(MEMORY_SANITIZER) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #define MAYBE_DownloadCookieIsolation DISABLED_DownloadCookieIsolation #else #define MAYBE_DownloadCookieIsolation DownloadCookieIsolation @@ -3382,8 +3382,8 @@ // TODO(crbug.com/994789): Flaky on MSan, Linux, and ChromeOS. // TODO(crbug.com/1204299): Flaky on Windows. Consistently failing on Mac. -#if defined(MEMORY_SANITIZER) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ - defined(OS_WIN) || defined(OS_MAC) +#if defined(MEMORY_SANITIZER) || BUILDFLAG(IS_LINUX) || \ + BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) #define MAYBE_DownloadCookieIsolation_CrossSession \ DISABLED_DownloadCookieIsolation_CrossSession #else @@ -3622,7 +3622,7 @@ } // Disable due to runloop time out. https://crbug.com/937461 -#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #define MAYBE_Dialog_TestConfirmDialogDefaultGCCancel \ DISABLED_Dialog_TestConfirmDialogDefaultGCCancel #else @@ -3663,8 +3663,8 @@ // https://crbug.com/1087381 // TODO(crbug.com/1052397): Revisit once build flag switch of lacros-chrome is // complete. -#if defined(OS_CHROMEOS) || \ - ((defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && \ +#if BUILDFLAG(IS_CHROMEOS) || \ + ((BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && \ defined(ADDRESS_SANITIZER)) #define MAYBE_Shim_TestZoomAPI DISABLED_Shim_TestZoomAPI #else @@ -4652,7 +4652,7 @@ } }; -#if defined(OS_LINUX) || defined(OS_MAC) || defined(OS_WIN) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) // This verifies the fix for http://crbug.com/667708. IN_PROC_BROWSER_TEST_F(ChromeSignInWebViewTest, ClosingChromeSignInShouldNotCrash) {
diff --git a/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc b/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc index c8da16d..4aad4c8 100644 --- a/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc +++ b/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc
@@ -70,7 +70,7 @@ using guest_view::TestGuestViewManager; using guest_view::TestGuestViewManagerFactory; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // This class observes the RenderWidgetHostViewCocoa corresponding to the outer // most WebContents provided for newly added subviews. The added subview // corresponds to a NSPopUpButtonCell which will be removed shortly after being @@ -181,7 +181,7 @@ void SendCopyKeyPressToPlatformApp() { ASSERT_EQ(1U, GetAppWindowCount()); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Send Cmd+C on MacOSX. ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( GetPlatformAppWindow(), ui::VKEY_C, false, false, false, true)); @@ -193,7 +193,7 @@ } void SendStartOfLineKeyPressToPlatformApp() { -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Send Cmd+Left on MacOSX. ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( GetPlatformAppWindow(), ui::VKEY_LEFT, false, false, false, true)); @@ -205,7 +205,7 @@ } void SendBackShortcutToPlatformApp() { -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Send Cmd+[ on MacOSX. ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( GetPlatformAppWindow(), ui::VKEY_OEM_4, false, false, false, true)); @@ -218,7 +218,7 @@ } void SendForwardShortcutToPlatformApp() { -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Send Cmd+] on MacOSX. ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( GetPlatformAppWindow(), ui::VKEY_OEM_6, false, false, false, true)); @@ -562,7 +562,7 @@ // Timeouts flakily: crbug.com/1003345 // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch // of lacros-chrome is complete. -#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) IN_PROC_BROWSER_TEST_F(WebViewPointerLockInteractiveTest, DISABLED_PointerLock) { SetupTest("web_view/pointer_lock", @@ -588,7 +588,7 @@ gfx::Point(corner().x() + 74, corner().y() + 74))); MoveMouseInsideWindowWithListener(gfx::Point(75, 75), "mouse-move"); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // When the mouse is unlocked on win aura, sending a test mouse click clicks // where the mouse moved to while locked. I was unable to figure out why, and // since the issue only occurs with the test mouse events, just fix it with @@ -659,7 +659,7 @@ ASSERT_TRUE(unlocked_listener.WaitUntilSatisfied()); } -#endif // defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) // Tests that if a <webview> is focused before navigation then the guest starts // off focused. @@ -702,7 +702,7 @@ } // Flaky on Mac and Linux - https://crbug.com/707648 -#if defined(OS_MAC) || defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #define MAYBE_Focus_FocusTracksEmbedder DISABLED_Focus_FocusTracksEmbedder #else #define MAYBE_Focus_FocusTracksEmbedder Focus_FocusTracksEmbedder @@ -864,7 +864,7 @@ ExtensionTestMessageListener start_of_line_listener("StartOfLine", false); SendStartOfLineKeyPressToPlatformApp(); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // On macOS, sending an accelerator [key-down] will also cause the subsequent // key-up to be swallowed. The implementation of guest.html is waiting for a // key-up to send the caret-position message. So we send a key-down/key-up of @@ -880,7 +880,7 @@ // the NSEvent is sent to NSApplication in ui/base/test/ui_controls_mac.mm . // This test is disabled on only the Mac until the problem is resolved. // See http://crbug.com/425859 for more information. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_NewWindow_OpenInNewTab DISABLED_NewWindow_OpenInNewTab #else #define MAYBE_NewWindow_OpenInNewTab NewWindow_OpenInNewTab @@ -895,7 +895,7 @@ NEEDS_TEST_SERVER, &embedder_web_contents)); EXPECT_TRUE(loaded_listener.WaitUntilSatisfied()); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( GetPlatformAppWindow(), ui::VKEY_RETURN, false, false, false, true /* cmd */)); @@ -968,7 +968,7 @@ // Trips over a DCHECK in content::MouseLockDispatcher::OnLockMouseACK; see // https://crbug.com/761783. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_PointerLock_PointerLockLostWithFocus \ PointerLock_PointerLockLostWithFocus #else @@ -992,7 +992,7 @@ // // In addition to the above, these tests are flaky on some platforms: // http://crbug.com/468660 -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_FullscreenAllow_EmbedderHasPermission \ FullscreenAllow_EmbedderHasPermission #else @@ -1005,7 +1005,7 @@ "web_view/fullscreen/embedder_has_permission"); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_FullscreenDeny_EmbedderHasPermission \ FullscreenDeny_EmbedderHasPermission #else @@ -1018,7 +1018,7 @@ "web_view/fullscreen/embedder_has_permission"); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_FullscreenAllow_EmbedderHasNoPermission \ FullscreenAllow_EmbedderHasNoPermission #else @@ -1031,7 +1031,7 @@ "web_view/fullscreen/embedder_has_no_permission"); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_FullscreenDeny_EmbedderHasNoPermission \ FullscreenDeny_EmbedderHasNoPermission #else @@ -1101,7 +1101,7 @@ ASSERT_TRUE(next_step_listener.WaitUntilSatisfied()); // |text_input_client| is not available for mac and android. -#if !defined(OS_MAC) && !defined(OS_ANDROID) +#if !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_ANDROID) ui::TextInputClient* text_input_client = embedder_web_contents->GetMainFrame() ->GetRenderViewHost() ->GetWidget() @@ -1114,8 +1114,8 @@ } // ui::TextInputClient is NULL for mac and android. -#if !defined(OS_MAC) && !defined(OS_ANDROID) -#if defined(ADDRESS_SANITIZER) || defined(OS_WIN) +#if !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_ANDROID) +#if defined(ADDRESS_SANITIZER) || BUILDFLAG(IS_WIN) #define MAYBE_Focus_InputMethod DISABLED_Focus_InputMethod #else #define MAYBE_Focus_InputMethod Focus_InputMethod @@ -1195,13 +1195,13 @@ } #endif -#if defined(OS_LINUX) || \ - defined(OS_CHROMEOS) // TODO(https://crbug.com/801552): Flaky. +#if BUILDFLAG(IS_LINUX) || \ + BUILDFLAG(IS_CHROMEOS) // TODO(https://crbug.com/801552): Flaky. #define MAYBE_LongPressSelection DISABLED_LongPressSelection #else #define MAYBE_LongPressSelection LongPressSelection #endif -#if !defined(OS_MAC) +#if !BUILDFLAG(IS_MAC) IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, MAYBE_LongPressSelection) { SetupTest("web_view/text_selection", "/extensions/platform_apps/web_view/text_selection/guest.html"); @@ -1211,7 +1211,7 @@ blink::WebInputEvent::Type context_menu_gesture_event_type = blink::WebInputEvent::Type::kGestureLongPress; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) context_menu_gesture_event_type = blink::WebInputEvent::Type::kGestureLongTap; #endif auto filter = std::make_unique<content::InputMsgWatcher>( @@ -1246,7 +1246,7 @@ message_loop_runner->Run(); // TODO: Fix quick menu opening on Windows. -#if !defined(OS_WIN) +#if !BUILDFLAG(IS_WIN) EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); #endif @@ -1254,7 +1254,7 @@ } #endif -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, TextSelection) { SetupTest("web_view/text_selection", "/extensions/platform_apps/web_view/text_selection/guest.html"); @@ -1306,8 +1306,8 @@ // Flaky on Mac: http://crbug.com/811893 // Flaky on Linux/ChromeOS/Windows: http://crbug.com/845638 -#if defined(OS_MAC) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ - defined(OS_WIN) +#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || \ + BUILDFLAG(IS_WIN) #define MAYBE_FocusAndVisibility DISABLED_FocusAndVisibility #else #define MAYBE_FocusAndVisibility FocusAndVisibility @@ -1326,7 +1326,7 @@ // least once. ExtensionTestMessageListener key_processed_listener( "WebViewInteractiveTest.KeyUp", false); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // On mac, the event listener seems one key event behind and deadlocks. Send // an extra tab to get things unblocked. See http://crbug.com/685281 when // fixed, this can be removed. @@ -1374,8 +1374,8 @@ // Flaky on MacOSX, crbug.com/817066. // Flaky timeouts on Linux. https://crbug.com/709202 // Flaky timeouts on Win. https://crbug.com/846695 -#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_MAC) || \ - defined(OS_WIN) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_MAC) || \ + BUILDFLAG(IS_WIN) #define MAYBE_KeyboardFocusSimple DISABLED_KeyboardFocusSimple #else #define MAYBE_KeyboardFocusSimple KeyboardFocusSimple @@ -1420,8 +1420,8 @@ // Flaky on MacOSX, crbug.com/817067. // Flaky on linux, crbug.com/706830. // Flaky on Windows, crbug.com/847201. -#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_MAC) || \ - defined(OS_WIN) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_MAC) || \ + BUILDFLAG(IS_WIN) #define MAYBE_KeyboardFocusWindowCycle DISABLED_KeyboardFocusWindowCycle #else #define MAYBE_KeyboardFocusWindowCycle KeyboardFocusWindowCycle @@ -1490,7 +1490,7 @@ ASSERT_TRUE(next_step_listener.WaitUntilSatisfied()); } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // This test verifies that replacement range for IME works with <webview>s. To // verify this, a <webview> with an <input> inside is loaded. Then the <input> // is focused and populated with some text. The test then sends an IPC to @@ -1608,7 +1608,7 @@ observer.WaitForCompositionRangeLength(3U); } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // This test verifies that drop-down lists appear correctly inside OOPIF-based // webviews which have offset inside embedder. This is a test for all guest // views as the logic for showing such popups is inside content/ layer. For more
diff --git a/chrome/browser/apps/intent_helper/intent_picker_helpers.cc b/chrome/browser/apps/intent_helper/intent_picker_helpers.cc index e012a63..2f102cb 100644 --- a/chrome/browser/apps/intent_helper/intent_picker_helpers.cc +++ b/chrome/browser/apps/intent_helper/intent_picker_helpers.cc
@@ -21,12 +21,12 @@ #include "content/public/browser/navigation_handle.h" #include "content/public/browser/web_contents.h" -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) #include "chrome/browser/apps/intent_helper/chromeos_intent_picker_helpers.h" #include "chrome/browser/apps/intent_helper/metrics/intent_handling_metrics.h" -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) #include "chrome/browser/apps/intent_helper/mac_intent_picker_helpers.h" -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) namespace apps { @@ -36,11 +36,11 @@ content::WebContents* web_contents, const GURL& url, std::vector<IntentPickerAppInfo> apps) { -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // On the Mac, if there is a Universal Link, it goes first. if (absl::optional<IntentPickerAppInfo> mac_app = FindMacAppForUrl(url)) apps.push_back(std::move(mac_app.value())); -#endif // defined(OS_MAC) +#endif // BUILDFLAG(IS_MAC) Profile* profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); @@ -64,7 +64,7 @@ const GURL& url, const std::string& launch_name, PickerEntryType app_type) { -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) LaunchAppFromIntentPickerChromeOs(web_contents, url, launch_name, app_type); #else switch (app_type) { @@ -72,16 +72,16 @@ web_app::ReparentWebContentsIntoAppBrowser(web_contents, launch_name); break; case PickerEntryType::kMacOs: -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) LaunchMacApp(url, launch_name); break; -#endif // defined(OS_MAC) +#endif // BUILDFLAG(IS_MAC) case PickerEntryType::kArc: case PickerEntryType::kDevice: case PickerEntryType::kUnknown: NOTREACHED(); } -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) } void OnIntentPickerClosed( @@ -92,7 +92,7 @@ PickerEntryType entry_type, IntentPickerCloseReason close_reason, bool should_persist) { -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) OnIntentPickerClosedChromeOs(web_contents, ui_auto_display_service, PickerShowState::kOmnibox, url, launch_name, entry_type, close_reason, should_persist); @@ -111,7 +111,7 @@ // the UI from showing after 2+ dismissals. ui_auto_display_service->IncrementCounter(url); } -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) } void OnAppIconsLoaded(content::WebContents* web_contents, @@ -120,13 +120,13 @@ std::vector<IntentPickerAppInfo> apps) { ShowIntentPickerBubbleForApps( web_contents, std::move(apps), -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) /*show_stay_in_chrome=*/true, /*show_remember_selection=*/true, #else /*show_stay_in_chrome=*/false, /*show_remember_selection=*/false, -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) base::BindOnce(&OnIntentPickerClosed, web_contents, ui_auto_display_service, url)); } @@ -155,9 +155,9 @@ content::WebContents* web_contents = navigation_handle->GetWebContents(); std::vector<IntentPickerAppInfo> apps = GetAppsForIntentPicker(web_contents); bool show_intent_icon = !apps.empty(); -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) MaybeShowIntentPickerBubble(navigation_handle, std::move(apps)); -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) return show_intent_icon; } @@ -172,7 +172,7 @@ if (apps.empty()) return; -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) apps::IntentHandlingMetrics::RecordIntentPickerIconEvent( apps::IntentHandlingMetrics::IntentPickerIconEvent::kIconClicked); #endif
diff --git a/chrome/browser/apps/platform_apps/api/media_galleries/media_galleries_apitest.cc b/chrome/browser/apps/platform_apps/api/media_galleries/media_galleries_apitest.cc index b45879e..91c5fc1f 100644 --- a/chrome/browser/apps/platform_apps/api/media_galleries/media_galleries_apitest.cc +++ b/chrome/browser/apps/platform_apps/api/media_galleries/media_galleries_apitest.cc
@@ -45,7 +45,7 @@ #include "media/base/test_data_util.h" #include "media/media_buildflags.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "base/mac/foundation_util.h" #include "base/strings/sys_string_conversions.h" #endif // OS_MAC @@ -298,7 +298,7 @@ // Test is flaky, it fails on certain bots, namely WinXP Tests(1) and Linux // (dbg)(1)(32). See crbug.com/354425. -#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #define MAYBE_MediaGalleriesNoAccess DISABLED_MediaGalleriesNoAccess #else #define MAYBE_MediaGalleriesNoAccess MediaGalleriesNoAccess @@ -336,7 +336,7 @@ // Test is flaky, it fails on certain bots, namely WinXP Tests(1) and Linux // (dbg)(1)(32). See crbug.com/354425. -#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #define MAYBE_MediaGalleriesCopyTo DISABLED_MediaGalleriesCopyTo #else #define MAYBE_MediaGalleriesCopyTo MediaGalleriesCopyTo
diff --git a/chrome/browser/apps/platform_apps/api/media_galleries/media_galleries_watch_apitest.cc b/chrome/browser/apps/platform_apps/api/media_galleries/media_galleries_watch_apitest.cc index a32b4c3..e080d20 100644 --- a/chrome/browser/apps/platform_apps/api/media_galleries/media_galleries_watch_apitest.cc +++ b/chrome/browser/apps/platform_apps/api/media_galleries/media_galleries_watch_apitest.cc
@@ -185,7 +185,7 @@ }; // TODO(crbug.com/1177103): Re-enable. Flaky on Linux and Windows. -#if defined(OS_LINUX) || defined(OS_WIN) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) #define MAYBE_BasicGalleryWatch DISABLED_BasicGalleryWatch #else #define MAYBE_BasicGalleryWatch BasicGalleryWatch @@ -216,7 +216,7 @@ } // TODO(crbug.com/1047645): Flaky on Linux and Windows. -#if defined(OS_LINUX) || defined(OS_WIN) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) #define MAYBE_CorrectResponseOnModifyingWatchedGallery \ DISABLED_CorrectResponseOnModifyingWatchedGallery #else @@ -243,7 +243,7 @@ // Test is flaky on windows and linux: crbug.com/1150017. // TODO(crbug.com/1052397): Revisit once build flag switch of lacros-chrome is // complete. -#if defined(OS_WIN) || (defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) +#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) #define MAYBE_RemoveListenerAndModifyGallery \ DISABLED_RemoveListenerAndModifyGallery #else
diff --git a/chrome/browser/apps/platform_apps/api/music_manager_private/music_manager_private_browsertest.cc b/chrome/browser/apps/platform_apps/api/music_manager_private/music_manager_private_browsertest.cc index 5618d03..fd5c62d 100644 --- a/chrome/browser/apps/platform_apps/api/music_manager_private/music_manager_private_browsertest.cc +++ b/chrome/browser/apps/platform_apps/api/music_manager_private/music_manager_private_browsertest.cc
@@ -9,7 +9,7 @@ #include "rlz/buildflags/buildflags.h" // Supported on all platforms, but on Windows only if RLZ is enabled. -#if !defined(OS_WIN) || BUILDFLAG(ENABLE_RLZ) +#if !BUILDFLAG(IS_WIN) || BUILDFLAG(ENABLE_RLZ) using MusicManagerPrivateTest = extensions::PlatformAppBrowserTest;
diff --git a/chrome/browser/apps/platform_apps/app_browsertest.cc b/chrome/browser/apps/platform_apps/app_browsertest.cc index 7b21950c..b7c22a1 100644 --- a/chrome/browser/apps/platform_apps/app_browsertest.cc +++ b/chrome/browser/apps/platform_apps/app_browsertest.cc
@@ -185,7 +185,7 @@ #endif // ENABLE_PRINT_PREVIEW -#if !BUILDFLAG(IS_CHROMEOS_ASH) && !defined(OS_WIN) +#if !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_WIN) bool CopyTestDataAndGetTestFilePath(const base::FilePath& test_data_file, const base::FilePath& temp_dir, const char* filename, @@ -198,7 +198,7 @@ *file_path = path; return true; } -#endif // !BUILDFLAG(IS_CHROMEOS_ASH) && !defined(OS_WIN) +#endif // !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_WIN) class PlatformAppWithFileBrowserTest : public PlatformAppBrowserTest { public: @@ -394,7 +394,7 @@ } // Flaky on Mac10.13 Tests (dbg). See https://crbug.com/1155013 -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_AppWithContextMenuTextField DISABLED_AppWithContextMenuTextField #else #define MAYBE_AppWithContextMenuTextField AppWithContextMenuTextField @@ -509,7 +509,7 @@ } // Failing on some Win and Linux buildbots. See crbug.com/354425. -#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #define MAYBE_Iframes DISABLED_Iframes #else #define MAYBE_Iframes Iframes @@ -571,7 +571,7 @@ } // See crbug.com/248441 -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_ExtensionWindowingApis DISABLED_ExtensionWindowingApis #else #define MAYBE_ExtensionWindowingApis ExtensionWindowingApis @@ -675,7 +675,7 @@ << message_; } -#if !defined(OS_WIN) +#if !BUILDFLAG(IS_WIN) // Tests that launch data is sent through for a file with an empty extension if // a handler accepts "". IN_PROC_BROWSER_TEST_F(PlatformAppWithFileBrowserTest, @@ -842,8 +842,8 @@ // This appears to be unreliable. // TODO(stevenjb): Investigate and enable -#if (defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) || defined(OS_WIN) || \ - defined(OS_MAC) +#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) || \ + BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) #define MAYBE_AppWindowRestoreState DISABLED_AppWindowRestoreState #else #define MAYBE_AppWindowRestoreState AppWindowRestoreState @@ -971,7 +971,7 @@ // Test that showing a permission request as a constrained window works and is // correctly parented. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_ConstrainedWindowRequest DISABLED_ConstrainedWindowRequest #else // TODO(sail): Enable this on other platforms once http://crbug.com/95455 is @@ -1209,7 +1209,7 @@ } // Fails on Win7. http://crbug.com/171450 -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_Messaging DISABLED_Messaging #else #define MAYBE_Messaging Messaging
diff --git a/chrome/browser/apps/platform_apps/app_window_browsertest.cc b/chrome/browser/apps/platform_apps/app_window_browsertest.cc index 2c1842fd..1ad6ae97 100644 --- a/chrome/browser/apps/platform_apps/app_window_browsertest.cc +++ b/chrome/browser/apps/platform_apps/app_window_browsertest.cc
@@ -154,7 +154,7 @@ // Flaky on Linux. http://crbug.com/424399. // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch // of lacros-chrome is complete. -#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) #define MAYBE_TestMinimize DISABLED_TestMinimize #else #define MAYBE_TestMinimize TestMinimize @@ -173,7 +173,7 @@ } // These tests will be flaky in Linux as window bounds change asynchronously. -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #define MAYBE_TestDeprecatedBounds DISABLED_TestDeprecatedBounds #define MAYBE_TestInitialBounds DISABLED_TestInitialBounds #define MAYBE_TestInitialConstraints DISABLED_TestInitialConstraints
diff --git a/chrome/browser/apps/platform_apps/app_window_interactive_uitest.cc b/chrome/browser/apps/platform_apps/app_window_interactive_uitest.cc index e84329b..14307f8 100644 --- a/chrome/browser/apps/platform_apps/app_window_interactive_uitest.cc +++ b/chrome/browser/apps/platform_apps/app_window_interactive_uitest.cc
@@ -16,11 +16,11 @@ #include "extensions/test/extension_test_message_listener.h" #include "extensions/test/result_catcher.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "base/mac/mac_util.h" #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <windows.h> #include "ui/aura/window.h" #include "ui/aura/window_tree_host.h" @@ -248,7 +248,7 @@ EXPECT_TRUE(GetFirstAppWindow()->GetBaseWindow()->IsFullscreen()); } -#if defined(OS_MAC) || defined(THREAD_SANITIZER) || defined(OS_LINUX) +#if BUILDFLAG(IS_MAC) || defined(THREAD_SANITIZER) || BUILDFLAG(IS_LINUX) // http://crbug.com/404081 // http://crbug.com/1263448 (tsan) // http://crbug.com/1263661 (linux) @@ -275,7 +275,7 @@ gfx::Rect window_bounds; gfx::Size min_size, max_size; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Get the bounds from the HWND. HWND hwnd = views::HWNDForNativeWindow(window->GetNativeWindow()); RECT rect; @@ -301,7 +301,7 @@ max_size.width() ? max_size.width() + insets.left() + insets.right() : 0, max_size.height() ? max_size.height() + insets.top() + insets.bottom() : 0); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) // These match the values in the outer_bounds/test.js EXPECT_EQ(gfx::Rect(10, 11, 300, 301), window_bounds); @@ -313,7 +313,7 @@ } // TODO(jackhou): Make this test work for other OSes. -#if !defined(OS_WIN) +#if !BUILDFLAG(IS_WIN) #define MAYBE_TestOuterBoundsFrameChrome DISABLED_TestOuterBoundsFrameChrome #define MAYBE_TestOuterBoundsFrameNone DISABLED_TestOuterBoundsFrameNone #define MAYBE_TestOuterBoundsFrameColor DISABLED_TestOuterBoundsFrameColor @@ -344,8 +344,8 @@ // Those tests should be disabled on Linux GTK when they are enabled on the // other platforms, see http://crbug.com/328829. // Flaky failures on Windows; see https://crbug.com/788283. -#if ((defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(USE_AURA)) || \ - defined(OS_MAC) || defined(OS_WIN) +#if ((BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && defined(USE_AURA)) || \ + BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) #define MAYBE_TestCreate DISABLED_TestCreate #else #define MAYBE_TestCreate TestCreate @@ -363,8 +363,8 @@ // ::Show() because of Cocoa conventions. See http://crbug.com/326987 // Those tests should be disabled on Linux GTK when they are enabled on the // other platforms, see http://crbug.com/328829 -#if ((defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(USE_AURA)) || \ - defined(OS_WIN) || defined(OS_MAC) +#if ((BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && defined(USE_AURA)) || \ + BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) #define MAYBE_TestShow DISABLED_TestShow #else #define MAYBE_TestShow TestShow @@ -421,7 +421,7 @@ } // Only Linux and Windows use keep-alive to determine when to shut down. -#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_WIN) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_WIN) // In general, hidden windows should not keep Chrome alive. The exception is // when windows are created hidden, we allow the app some time to show the
diff --git a/chrome/browser/apps/platform_apps/platform_app_launch.cc b/chrome/browser/apps/platform_apps/platform_app_launch.cc index c7c0af5..c57966f 100644 --- a/chrome/browser/apps/platform_apps/platform_app_launch.cc +++ b/chrome/browser/apps/platform_apps/platform_app_launch.cc
@@ -4,6 +4,7 @@ #include "chrome/browser/apps/platform_apps/platform_app_launch.h" +#include "build/build_config.h" #include "chrome/browser/apps/app_service/app_launch_params.h" #include "chrome/browser/apps/app_service/launch_utils.h" #include "chrome/browser/extensions/launch_util.h" @@ -17,13 +18,13 @@ #include "extensions/common/constants.h" #include "extensions/common/extension.h" -#if defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/web_applications/extension_status_utils.h" #include "chrome/common/webui_url_constants.h" -#endif // defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX) +#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) namespace apps { @@ -119,7 +120,7 @@ return app_tab != nullptr; } -#if defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) bool OpenDeprecatedApplicationPrompt(Profile* profile, const std::string& app_id) { if (!extensions::IsExtensionUnsupportedDeprecatedApp(profile, app_id)) @@ -139,7 +140,7 @@ // TODO(crbug.com/1225779): Show the deprecated apps dialog. return true; } -#endif // defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX) +#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) bool OpenExtensionApplicationWithReenablePrompt( Profile* profile,
diff --git a/chrome/browser/apps/platform_apps/platform_app_launch.h b/chrome/browser/apps/platform_apps/platform_app_launch.h index 66e74df..15c659e 100644 --- a/chrome/browser/apps/platform_apps/platform_app_launch.h +++ b/chrome/browser/apps/platform_apps/platform_app_launch.h
@@ -36,7 +36,7 @@ // and false otherwise. bool OpenExtensionApplicationTab(Profile* profile, const std::string& app_id); -#if defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) // Opens the deprecated Chrome Apps flow if |app_id| refers to a Chrome App and // Chrome Apps are deprecated on the |profile|. Returns true if that was the // case, or false otherwise.
diff --git a/chrome/browser/apps/platform_apps/shortcut_manager.cc b/chrome/browser/apps/platform_apps/shortcut_manager.cc index 1ae3dda..9ec5fb0 100644 --- a/chrome/browser/apps/platform_apps/shortcut_manager.cc +++ b/chrome/browser/apps/platform_apps/shortcut_manager.cc
@@ -30,7 +30,7 @@ #include "extensions/browser/extension_system.h" #include "extensions/common/extension_set.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "chrome/common/mac/app_mode_common.h" #endif @@ -38,7 +38,7 @@ namespace { -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // This version number is stored in local prefs to check whether app shortcuts // need to be recreated. This might happen when we change various aspects of app // shortcuts like command-line flags or associated icons, binaries, etc.
diff --git a/chrome/browser/ash/app_mode/kiosk_app_manager.cc b/chrome/browser/ash/app_mode/kiosk_app_manager.cc index 6733805..6208911 100644 --- a/chrome/browser/ash/app_mode/kiosk_app_manager.cc +++ b/chrome/browser/ash/app_mode/kiosk_app_manager.cc
@@ -821,11 +821,11 @@ base::DictionaryValue entry; if (apps_[i]->update_url().is_valid()) { - entry.SetString(extensions::ExternalProviderImpl::kExternalUpdateUrl, - apps_[i]->update_url().spec()); + entry.SetStringKey(extensions::ExternalProviderImpl::kExternalUpdateUrl, + apps_[i]->update_url().spec()); } else { - entry.SetString(extensions::ExternalProviderImpl::kExternalUpdateUrl, - extension_urls::GetWebstoreUpdateUrl().spec()); + entry.SetStringKey(extensions::ExternalProviderImpl::kExternalUpdateUrl, + extension_urls::GetWebstoreUpdateUrl().spec()); } prefs->SetPath(apps_[i]->app_id(), std::move(entry));
diff --git a/chrome/browser/ash/app_mode/kiosk_app_manager_browsertest.cc b/chrome/browser/ash/app_mode/kiosk_app_manager_browsertest.cc index cf62012e..03ee2fa 100644 --- a/chrome/browser/ash/app_mode/kiosk_app_manager_browsertest.cc +++ b/chrome/browser/ash/app_mode/kiosk_app_manager_browsertest.cc
@@ -104,15 +104,15 @@ const std::string& id, const std::string& required_platform_version) { base::DictionaryValue value; - value.SetString("name", name); - value.SetString("version", version); + value.SetStringKey("name", name); + value.SetStringKey("version", version); base::ListValue scripts; scripts.Append("main.js"); value.SetPath("app.background.scripts", std::move(scripts)); value.SetBoolean("kiosk_enabled", true); if (!required_platform_version.empty()) { - value.SetString("kiosk.required_platform_version", - required_platform_version); + value.SetStringPath("kiosk.required_platform_version", + required_platform_version); } std::string err; @@ -318,10 +318,10 @@ CopyFileToTempDir(data_dir.AppendASCII(icon_file_name)); base::DictionaryValue apps_dict; - apps_dict.SetString(app_id + ".name", app_name); - apps_dict.SetString(app_id + ".icon", icon_path.MaybeAsASCII()); - apps_dict.SetString(app_id + ".required_platform_version", - required_platform_version); + apps_dict.SetStringPath(app_id + ".name", app_name); + apps_dict.SetStringPath(app_id + ".icon", icon_path.MaybeAsASCII()); + apps_dict.SetStringPath(app_id + ".required_platform_version", + required_platform_version); PrefService* local_state = g_browser_process->local_state(); DictionaryPrefUpdateDeprecated dict_update(
diff --git a/chrome/browser/ash/app_mode/kiosk_external_updater.cc b/chrome/browser/ash/app_mode/kiosk_external_updater.cc index 3272717..4bd7b4e 100644 --- a/chrome/browser/ash/app_mode/kiosk_external_updater.cc +++ b/chrome/browser/ash/app_mode/kiosk_external_updater.cc
@@ -238,16 +238,18 @@ continue; } - std::string external_crx_str; - if (!extension->GetString(kExternalCrx, &external_crx_str)) { + const std::string* external_crx_str = + extension->FindStringKey(kExternalCrx); + if (!external_crx_str) { LOG(ERROR) << "Can't find external crx in manifest " << app_id; continue; } - std::string external_version_str; - if (extension->GetString(kExternalVersion, &external_version_str)) { - if (!ShouldUpdateForHigherVersion( - cached_version_str, external_version_str, false)) { + const std::string* external_version_str = + extension->FindStringKey(kExternalVersion); + if (external_version_str) { + if (!ShouldUpdateForHigherVersion(cached_version_str, + *external_version_str, false)) { LOG(WARNING) << "External app " << app_id << " is at the same or lower version comparing to " << " the existing one."; @@ -263,7 +265,7 @@ NOTREACHED(); } update.external_crx = extensions::CRXFileInfo( - external_update_path_.AppendASCII(external_crx_str), + external_update_path_.AppendASCII(*external_crx_str), extensions::GetExternalVerifierFormat()); update.external_crx.extension_id = app_id; update.update_status = UpdateStatus::kPending;
diff --git a/chrome/browser/ash/arc/arc_support_host.cc b/chrome/browser/ash/arc/arc_support_host.cc index 8657023..31010b7 100644 --- a/chrome/browser/ash/arc/arc_support_host.cc +++ b/chrome/browser/ash/arc/arc_support_host.cc
@@ -270,7 +270,7 @@ } base::DictionaryValue message; - message.SetString(kAction, kActionCloseWindow); + message.SetStringKey(kAction, kActionCloseWindow); message_host_->SendMessage(message); // Disconnect immediately, so that onWindowClosed event will not be @@ -309,18 +309,18 @@ } base::DictionaryValue message; - message.SetString(kAction, kActionShowPage); + message.SetStringKey(kAction, kActionShowPage); switch (ui_page) { case UIPage::TERMS: - message.SetString(kPage, "terms"); + message.SetStringKey(kPage, "terms"); break; case UIPage::ARC_LOADING: - message.SetString(kPage, "arc-loading"); + message.SetStringKey(kPage, "arc-loading"); break; case UIPage::ACTIVE_DIRECTORY_AUTH: DCHECK(active_directory_auth_federation_url_.is_valid()); DCHECK(!active_directory_auth_device_management_url_prefix_.empty()); - message.SetString(kPage, "active-directory-auth"); + message.SetStringKey(kPage, "active-directory-auth"); message.SetPath( {kOptions, kFederationUrl}, base::Value(active_directory_auth_federation_url_.spec())); @@ -357,7 +357,7 @@ } base::DictionaryValue message_args; - message_args.SetString(kAction, kActionShowErrorPage); + message_args.SetStringKey(kAction, kActionShowErrorPage); int message_id; #define MAP_ERROR(name, id) \ case Error::name: \ @@ -413,7 +413,7 @@ break; } - message_args.SetString(kErrorMessage, message); + message_args.SetStringKey(kErrorMessage, message); message_args.SetBoolean(kShouldShowSendFeedback, should_show_send_feedback); message_args.SetBoolean( kShouldShowNetworkTests, @@ -449,7 +449,7 @@ return; base::DictionaryValue message; - message.SetString(kAction, action_name); + message.SetStringKey(kAction, action_name); message.SetBoolean(kEnabled, data.is_enabled); message.SetBoolean(kManaged, data.is_managed); message_host_->SendMessage(message); @@ -529,129 +529,133 @@ user_manager::UserManager::Get()->IsLoggedInAsChildUser(); base::DictionaryValue loadtime_data; - loadtime_data.SetString("appWindow", l10n_util::GetStringUTF16( - IDS_ARC_PLAYSTORE_ICON_TITLE_BETA)); - loadtime_data.SetString( + loadtime_data.SetStringKey( + "appWindow", + l10n_util::GetStringUTF16(IDS_ARC_PLAYSTORE_ICON_TITLE_BETA)); + loadtime_data.SetStringKey( "greetingHeader", l10n_util::GetStringUTF16(IDS_ARC_OOBE_TERMS_HEADING)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "initializingHeader", l10n_util::GetStringUTF16(IDS_ARC_PLAYSTORE_SETTING_UP_TITLE)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "greetingDescription", l10n_util::GetStringUTF16(IDS_ARC_OOBE_TERMS_DESCRIPTION)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "buttonAgree", l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_BUTTON_AGREE)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "buttonCancel", l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_BUTTON_CANCEL)); - loadtime_data.SetString("buttonNext", l10n_util::GetStringUTF16( - IDS_ARC_OPT_IN_DIALOG_BUTTON_NEXT)); - loadtime_data.SetString( + loadtime_data.SetStringKey( + "buttonNext", + l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_BUTTON_NEXT)); + loadtime_data.SetStringKey( "buttonSendFeedback", l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_BUTTON_SEND_FEEDBACK)); - loadtime_data.SetString("buttonRunNetworkTests", - l10n_util::GetStringUTF16( - IDS_ARC_OPT_IN_DIALOG_BUTTON_RUN_NETWORK_TESTS)); - loadtime_data.SetString( + loadtime_data.SetStringKey( + "buttonRunNetworkTests", + l10n_util::GetStringUTF16( + IDS_ARC_OPT_IN_DIALOG_BUTTON_RUN_NETWORK_TESTS)); + loadtime_data.SetStringKey( "buttonRetry", l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_BUTTON_RETRY)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "progressTermsLoading", l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_PROGRESS_TERMS)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "progressAndroidLoading", l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_PROGRESS_ANDROID)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "authorizationFailed", l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_AUTHORIZATION_FAILED)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "termsOfService", l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_DIALOG_TERMS_OF_SERVICE)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "textMetricsEnabled", l10n_util::GetStringUTF16( is_child ? IDS_ARC_OPT_IN_DIALOG_METRICS_ENABLED_CHILD : IDS_ARC_OPT_IN_DIALOG_METRICS_ENABLED)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "textMetricsDisabled", l10n_util::GetStringUTF16( is_child ? IDS_ARC_OPT_IN_DIALOG_METRICS_DISABLED_CHILD : IDS_ARC_OPT_IN_DIALOG_METRICS_DISABLED)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "textMetricsManagedEnabled", l10n_util::GetStringUTF16( is_child ? IDS_ARC_OPT_IN_DIALOG_METRICS_MANAGED_ENABLED_CHILD : IDS_ARC_OPT_IN_DIALOG_METRICS_MANAGED_ENABLED)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "textMetricsManagedDisabled", l10n_util::GetStringUTF16( is_child ? IDS_ARC_OPT_IN_DIALOG_METRICS_MANAGED_DISABLED_CHILD : IDS_ARC_OPT_IN_DIALOG_METRICS_MANAGED_DISABLED)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "textBackupRestore", l10n_util::GetStringUTF16(is_child ? IDS_ARC_OPT_IN_DIALOG_BACKUP_RESTORE_CHILD : IDS_ARC_OPT_IN_DIALOG_BACKUP_RESTORE)); - loadtime_data.SetString("textPaiService", - l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_PAI)); - loadtime_data.SetString( + loadtime_data.SetStringKey("textPaiService", + l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_PAI)); + loadtime_data.SetStringKey( "textGoogleServiceConfirmation", l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_GOOGLE_SERVICE_CONFIRMATION)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "textLocationService", l10n_util::GetStringUTF16(is_child ? IDS_ARC_OPT_IN_LOCATION_SETTING_CHILD : IDS_ARC_OPT_IN_LOCATION_SETTING)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "serverError", l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "controlledByPolicy", l10n_util::GetStringUTF16(IDS_CONTROLLED_SETTING_POLICY)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "learnMoreStatisticsTitle", l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_LEARN_MORE_STATISTICS_TITLE)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "learnMoreStatistics", l10n_util::GetStringUTF16(is_child ? IDS_ARC_OPT_IN_LEARN_MORE_STATISTICS_CHILD : IDS_ARC_OPT_IN_LEARN_MORE_STATISTICS)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "learnMoreBackupAndRestoreTitle", l10n_util::GetStringUTF16( IDS_ARC_OPT_IN_LEARN_MORE_BACKUP_AND_RESTORE_TITLE)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "learnMoreBackupAndRestore", l10n_util::GetStringUTF16( is_child ? IDS_ARC_OPT_IN_LEARN_MORE_BACKUP_AND_RESTORE_CHILD : IDS_ARC_OPT_IN_LEARN_MORE_BACKUP_AND_RESTORE)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "learnMoreLocationServicesTitle", l10n_util::GetStringUTF16( IDS_ARC_OPT_IN_LEARN_MORE_LOCATION_SERVICES_TITLE)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "learnMoreLocationServices", l10n_util::GetStringUTF16( is_child ? IDS_ARC_OPT_IN_LEARN_MORE_LOCATION_SERVICES_CHILD : IDS_ARC_OPT_IN_LEARN_MORE_LOCATION_SERVICES)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "learnMorePaiServiceTitle", l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_LEARN_MORE_PAI_SERVICE_TITLE)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "learnMorePaiService", l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_LEARN_MORE_PAI_SERVICE)); - loadtime_data.SetString("overlayClose", l10n_util::GetStringUTF16( - IDS_ARC_OPT_IN_LEARN_MORE_CLOSE)); - loadtime_data.SetString( + loadtime_data.SetStringKey( + "overlayClose", + l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_LEARN_MORE_CLOSE)); + loadtime_data.SetStringKey( "privacyPolicyLink", l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_PRIVACY_POLICY_LINK)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "activeDirectoryAuthTitle", l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_ACTIVE_DIRECTORY_AUTH_TITLE)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "activeDirectoryAuthDesc", l10n_util::GetStringUTF16(IDS_ARC_OPT_IN_ACTIVE_DIRECTORY_AUTH_DESC)); - loadtime_data.SetString( + loadtime_data.SetStringKey( "overlayLoading", l10n_util::GetStringUTF16(IDS_ARC_POPUP_HELP_LOADING)); loadtime_data.SetBoolean(kArcManaged, is_arc_managed_); @@ -659,19 +663,19 @@ ash::ProfileHelper::IsOwnerProfile(profile_)); const std::string& country_code = base::CountryCodeForCurrentTimezone(); - loadtime_data.SetString("countryCode", country_code); + loadtime_data.SetStringKey("countryCode", country_code); const std::string& app_locale = g_browser_process->GetApplicationLocale(); webui::SetLoadTimeDataDefaults(app_locale, &loadtime_data); - loadtime_data.SetString("locale", app_locale); + loadtime_data.SetStringKey("locale", app_locale); base::DictionaryValue message; - message.SetString(kAction, kActionInitialize); + message.SetStringKey(kAction, kActionInitialize); message.SetKey(kData, std::move(loadtime_data)); const std::string device_id = user_manager::known_user::GetDeviceId( multi_user_util::GetAccountIdFromProfile(profile_)); - message.SetString(kDeviceId, device_id); + message.SetStringKey(kDeviceId, device_id); message_host_->SendMessage(message); return true; @@ -683,18 +687,18 @@ return; base::DictionaryValue message; - message.SetString(kAction, kActionSetWindowBounds); + message.SetStringKey(kAction, kActionSetWindowBounds); message_host_->SendMessage(message); } void ArcSupportHost::OnMessage(const base::DictionaryValue& message) { - std::string event; - if (!message.GetString(kEvent, &event)) { + const std::string* event = message.FindStringKey(kEvent); + if (!event) { NOTREACHED(); return; } - if (event == kEventOnWindowClosed) { + if (*event == kEventOnWindowClosed) { // If ToS negotiation is ongoing, call the specific function. if (tos_delegate_) { tos_delegate_->OnTermsRejected(); @@ -702,25 +706,24 @@ DCHECK(error_delegate_); error_delegate_->OnWindowClosed(); } - } else if (event == kEventOnAuthSucceeded) { + } else if (*event == kEventOnAuthSucceeded) { DCHECK(auth_delegate_); auth_delegate_->OnAuthSucceeded(); - } else if (event == kEventOnAuthFailed) { + } else if (*event == kEventOnAuthFailed) { DCHECK(auth_delegate_); - std::string error_message; - if (!message.GetString(kAuthErrorMessage, &error_message)) { + const std::string* error_message = message.FindStringKey(kAuthErrorMessage); + if (!error_message) { NOTREACHED(); return; } // TODO(https://crbug.com/756144): Remove once reason for crash has been // determined. LOG_IF(ERROR, !auth_delegate_) - << "auth_delegate_ is NULL, error: " << error_message; - auth_delegate_->OnAuthFailed(error_message); - } else if (event == kEventOnAgreed || event == kEventOnCanceled) { + << "auth_delegate_ is NULL, error: " << *error_message; + auth_delegate_->OnAuthFailed(*error_message); + } else if (*event == kEventOnAgreed || *event == kEventOnCanceled) { DCHECK(tos_delegate_); absl::optional<bool> tos_shown = message.FindBoolKey(kTosShown); - std::string tos_content; absl::optional<bool> is_metrics_enabled = message.FindBoolKey(kIsMetricsEnabled); absl::optional<bool> is_backup_restore_enabled = @@ -731,8 +734,10 @@ message.FindBoolKey(kIsLocationServiceEnabled); absl::optional<bool> is_location_service_managed = message.FindBoolKey(kIsLocationServiceManaged); - if (!message.GetString(kTosContent, &tos_content) || - !tos_shown.has_value() || !is_metrics_enabled.has_value() || + + const std::string* tos_content = message.FindStringKey(kTosContent); + if (!tos_content || !tos_shown.has_value() || + !is_metrics_enabled.has_value() || !is_backup_restore_enabled.has_value() || !is_backup_restore_managed.has_value() || !is_location_service_enabled.has_value() || @@ -741,7 +746,7 @@ return; } - bool accepted = event == kEventOnAgreed; + bool accepted = *event == kEventOnAgreed; if (!accepted) { // Cancel is equivalent to not granting consent to the individual // features, so ensure we don't record consent. @@ -765,9 +770,9 @@ play_consent.set_consent_flow( UserConsentTypes::ArcPlayTermsOfServiceConsent::SETUP); if (tos_shown.value()) { - play_consent.set_play_terms_of_service_text_length(tos_content.length()); + play_consent.set_play_terms_of_service_text_length(tos_content->length()); play_consent.set_play_terms_of_service_hash( - base::SHA1HashString(tos_content)); + base::SHA1HashString(*tos_content)); } ConsentAuditorFactory::GetForProfile(profile_)->RecordArcPlayConsent( account_id, play_consent); @@ -814,7 +819,7 @@ is_backup_restore_enabled.value(), is_location_service_enabled.value()); } - } else if (event == kEventOnRetryClicked) { + } else if (*event == kEventOnRetryClicked) { // If ToS negotiation or manual authentication is ongoing, call the // corresponding delegate. Otherwise, call the general retry function. if (tos_delegate_) { @@ -825,16 +830,16 @@ DCHECK(error_delegate_); error_delegate_->OnRetryClicked(); } - } else if (event == kEventOnSendFeedbackClicked) { + } else if (*event == kEventOnSendFeedbackClicked) { DCHECK(error_delegate_); error_delegate_->OnSendFeedbackClicked(); - } else if (event == kEventOnRunNetworkTestsClicked) { + } else if (*event == kEventOnRunNetworkTestsClicked) { DCHECK(error_delegate_); error_delegate_->OnRunNetworkTestsClicked(); - } else if (event == kEventOnOpenPrivacySettingsPageClicked) { + } else if (*event == kEventOnOpenPrivacySettingsPageClicked) { chrome::ShowSettingsSubPageForProfile(profile_, chrome::kPrivacySubPage); } else { - LOG(ERROR) << "Unknown message: " << event; + LOG(ERROR) << "Unknown message: " << *event; NOTREACHED(); } }
diff --git a/chrome/browser/ash/arc/extensions/arc_support_message_host_unittest.cc b/chrome/browser/ash/arc/extensions/arc_support_message_host_unittest.cc index a4b765f..bb38186 100644 --- a/chrome/browser/ash/arc/extensions/arc_support_message_host_unittest.cc +++ b/chrome/browser/ash/arc/extensions/arc_support_message_host_unittest.cc
@@ -102,7 +102,7 @@ TEST_F(ArcSupportMessageHostTest, SendMessage) { base::DictionaryValue value; - value.SetString("foo", "bar"); + value.SetStringKey("foo", "bar"); value.SetBoolean("baz", true); message_host()->SendMessage(value); @@ -115,7 +115,7 @@ TEST_F(ArcSupportMessageHostTest, ReceiveMessage) { base::DictionaryValue value; - value.SetString("foo", "bar"); + value.SetStringKey("foo", "bar"); value.SetBoolean("baz", true); TestObserver observer;
diff --git a/chrome/browser/ash/arc/extensions/fake_arc_support.cc b/chrome/browser/ash/arc/extensions/fake_arc_support.cc index b6016ee..db549d5 100644 --- a/chrome/browser/ash/arc/extensions/fake_arc_support.cc +++ b/chrome/browser/ash/arc/extensions/fake_arc_support.cc
@@ -64,7 +64,7 @@ void FakeArcSupport::EmulateAuthSuccess() { DCHECK_EQ(ArcSupportHost::UIPage::ACTIVE_DIRECTORY_AUTH, ui_page_); base::DictionaryValue message; - message.SetString("event", "onAuthSucceeded"); + message.SetStringKey("event", "onAuthSucceeded"); SerializeAndSend(native_message_host_.get(), message); } @@ -72,16 +72,16 @@ DCHECK(native_message_host_); DCHECK_EQ(ArcSupportHost::UIPage::ACTIVE_DIRECTORY_AUTH, ui_page_); base::DictionaryValue message; - message.SetString("event", "onAuthFailed"); - message.SetString("errorMessage", error_msg); + message.SetStringKey("event", "onAuthFailed"); + message.SetStringKey("errorMessage", error_msg); SerializeAndSend(native_message_host_.get(), message); } void FakeArcSupport::ClickAgreeButton() { DCHECK_EQ(ui_page_, ArcSupportHost::UIPage::TERMS); base::DictionaryValue message; - message.SetString("event", "onAgreed"); - message.SetString("tosContent", tos_content_); + message.SetStringKey("event", "onAgreed"); + message.SetStringKey("tosContent", tos_content_); message.SetBoolean("tosShown", tos_shown_); message.SetBoolean("isMetricsEnabled", metrics_mode_); message.SetBoolean("isBackupRestoreEnabled", backup_and_restore_mode_); @@ -94,8 +94,8 @@ void FakeArcSupport::ClickCancelButton() { DCHECK_EQ(ui_page_, ArcSupportHost::UIPage::TERMS); base::DictionaryValue message; - message.SetString("event", "onCanceled"); - message.SetString("tosContent", tos_content_); + message.SetStringKey("event", "onCanceled"); + message.SetStringKey("tosContent", tos_content_); message.SetBoolean("tosShown", tos_shown_); message.SetBoolean("isMetricsEnabled", metrics_mode_); message.SetBoolean("isBackupRestoreEnabled", backup_and_restore_mode_); @@ -155,26 +155,26 @@ base::JSONReader::ReadDeprecated(message_string)); DCHECK(message); - std::string action; - if (!message->GetString("action", &action)) { + const std::string* action = message->FindStringKey("action"); + if (!action) { NOTREACHED() << message_string; return; } ArcSupportHost::UIPage prev_ui_page = ui_page_; - if (action == "initialize") { + if (*action == "initialize") { // Do nothing as emulation. - } else if (action == "showPage") { - std::string page; - if (!message->GetString("page", &page)) { + } else if (*action == "showPage") { + const std::string* page = message->FindStringKey("page"); + if (!page) { NOTREACHED() << message_string; return; } - if (page == "terms") { + if (*page == "terms") { ui_page_ = ArcSupportHost::UIPage::TERMS; - } else if (page == "arc-loading") { + } else if (*page == "arc-loading") { ui_page_ = ArcSupportHost::UIPage::ARC_LOADING; - } else if (page == "active-directory-auth") { + } else if (*page == "active-directory-auth") { ui_page_ = ArcSupportHost::UIPage::ACTIVE_DIRECTORY_AUTH; const base::Value* federation_url = message->FindPathOfType( {"options", "federationUrl"}, base::Value::Type::STRING); @@ -190,32 +190,32 @@ } else { NOTREACHED() << message_string; } - } else if (action == "showErrorPage") { + } else if (*action == "showErrorPage") { ui_page_ = ArcSupportHost::UIPage::ERROR; - } else if (action == "setMetricsMode") { + } else if (*action == "setMetricsMode") { absl::optional<bool> opt = message->FindBoolKey("enabled"); if (!opt) { NOTREACHED() << message_string; return; } metrics_mode_ = opt.value(); - } else if (action == "setBackupAndRestoreMode") { + } else if (*action == "setBackupAndRestoreMode") { absl::optional<bool> opt = message->FindBoolKey("enabled"); if (!opt) { NOTREACHED() << message_string; return; } backup_and_restore_mode_ = opt.value(); - } else if (action == "setLocationServiceMode") { + } else if (*action == "setLocationServiceMode") { absl::optional<bool> opt = message->FindBoolKey("enabled"); if (!opt) { NOTREACHED() << message_string; return; } location_service_mode_ = opt.value(); - } else if (action == "closeWindow") { + } else if (*action == "closeWindow") { // Do nothing as emulation. - } else if (action == "setWindowBounds") { + } else if (*action == "setWindowBounds") { // Do nothing as emulation. } else { // Unknown or unsupported action.
diff --git a/chrome/browser/ash/arc/instance_throttle/arc_boot_phase_throttle_observer_unittest.cc b/chrome/browser/ash/arc/instance_throttle/arc_boot_phase_throttle_observer_unittest.cc index 3167b2d..56ae368 100644 --- a/chrome/browser/ash/arc/instance_throttle/arc_boot_phase_throttle_observer_unittest.cc +++ b/chrome/browser/ash/arc/instance_throttle/arc_boot_phase_throttle_observer_unittest.cc
@@ -25,7 +25,7 @@ #include "chrome/test/base/testing_profile.h" #include "chromeos/dbus/concierge/concierge_client.h" #include "chromeos/dbus/dbus_thread_manager.h" -#include "components/arc/intent_helper/arc_intent_helper_bridge.h" +#include "components/arc/test/fake_intent_helper_host.h" #include "components/arc/test/fake_intent_helper_instance.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "components/user_manager/scoped_user_manager.h" @@ -68,9 +68,8 @@ app_host_ = std::make_unique<FakeAppHost>( arc_service_manager_.arc_bridge_service()->app()); app_instance_ = std::make_unique<FakeAppInstance>(app_host_.get()); - // TODO(yusukes): Implement and use FakeIntentHelperHost just like above. - arc_intent_helper_bridge_ = std::make_unique<ArcIntentHelperBridge>( - testing_profile_.get(), arc_service_manager_.arc_bridge_service()); + intent_helper_host_ = std::make_unique<FakeIntentHelperHost>( + arc_service_manager_.arc_bridge_service()->intent_helper()); intent_helper_instance_ = std::make_unique<FakeIntentHelperInstance>(); } @@ -136,8 +135,7 @@ std::unique_ptr<FakeAppHost> app_host_; std::unique_ptr<FakeAppInstance> app_instance_; - // TODO(yusukes): Implement and use FakeIntentHelperHost. - std::unique_ptr<ArcIntentHelperBridge> arc_intent_helper_bridge_; + std::unique_ptr<FakeIntentHelperHost> intent_helper_host_; std::unique_ptr<FakeIntentHelperInstance> intent_helper_instance_; };
diff --git a/chrome/browser/ash/arc/intent_helper/arc_settings_service.cc b/chrome/browser/ash/arc/intent_helper/arc_settings_service.cc index fee437a..130c047f 100644 --- a/chrome/browser/ash/arc/intent_helper/arc_settings_service.cc +++ b/chrome/browser/ash/arc/intent_helper/arc_settings_service.cc
@@ -523,8 +523,8 @@ // code (e.g. fr_FR). Since Android expects locale to contain country code, // ARC will derive a likely locale with country code from such GetLocaleAndPreferredLanguages(profile_, &locale, &preferred_languages); - extras.SetString("locale", locale); - extras.SetString("preferredLanguages", preferred_languages); + extras.SetStringKey("locale", locale); + extras.SetStringKey("preferredLanguages", preferred_languages); SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_LOCALE", extras); } @@ -552,7 +552,7 @@ } base::DictionaryValue extras; - extras.SetString("mode", ProxyPrefs::ProxyModeToString(mode)); + extras.SetStringKey("mode", ProxyPrefs::ProxyModeToString(mode)); switch (mode) { case ProxyPrefs::MODE_DIRECT: @@ -563,10 +563,10 @@ case ProxyPrefs::MODE_AUTO_DETECT: { // WPAD with DHCP has a higher priority than DNS. if (dhcp_wpad_url_.is_valid()) { - extras.SetString("pacUrl", dhcp_wpad_url_.spec()); + extras.SetStringKey("pacUrl", dhcp_wpad_url_.spec()); } else { // Fallback to WPAD via DNS. - extras.SetString("pacUrl", "http://wpad/wpad.dat"); + extras.SetStringKey("pacUrl", "http://wpad/wpad.dat"); } break; } @@ -576,7 +576,7 @@ LOG(ERROR) << "No pac URL for pac_script proxy mode."; return; } - extras.SetString("pacUrl", pac_url); + extras.SetStringKey("pacUrl", pac_url); break; } case ProxyPrefs::MODE_FIXED_SERVERS: { @@ -586,7 +586,7 @@ LOG(ERROR) << "No Http proxy server is sent."; return; } - extras.SetString("host", host); + extras.SetStringKey("host", host); extras.SetInteger("port", port); std::string bypass_list; @@ -600,7 +600,7 @@ base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); bypass_list = base::JoinString(bypassed_hosts, kArcProxyBypassListDelimiter); - extras.SetString("bypassList", bypass_list); + extras.SetStringKey("bypassList", bypass_list); } break; } @@ -634,9 +634,9 @@ return; base::DictionaryValue extras; - extras.SetString( + extras.SetStringKey( "mode", ProxyPrefs::ProxyModeToString(ProxyPrefs::MODE_FIXED_SERVERS)); - extras.SetString("host", host); + extras.SetStringKey("host", host); extras.SetInteger("port", port); SendSettingsBroadcast(kSetProxyAction, extras); } @@ -697,7 +697,7 @@ TimezoneSettings* timezone_settings = TimezoneSettings::GetInstance(); std::u16string timezoneID = timezone_settings->GetCurrentTimezoneID(); base::DictionaryValue extras; - extras.SetString("olsonTimeZone", timezoneID); + extras.SetStringKey("olsonTimeZone", timezoneID); SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_TIME_ZONE", extras); }
diff --git a/chrome/browser/ash/arc/policy/arc_policy_bridge.cc b/chrome/browser/ash/arc/policy/arc_policy_bridge.cc index 9ebedd2..24e7240d 100644 --- a/chrome/browser/ash/arc/policy/arc_policy_bridge.cc +++ b/chrome/browser/ash/arc/policy/arc_policy_bridge.cc
@@ -675,15 +675,17 @@ serializer.Serialize(*report); bool is_arc_plus_plus_report_successful = report->FindBoolKey("isArcPlusPlusReportSuccessful").value_or(false); - std::string reported_policies_hash; - report->GetString("policyHash", &reported_policies_hash); - if (!is_arc_plus_plus_report_successful || reported_policies_hash.empty()) + const std::string* reported_policies_hash = + report->FindStringKey("policyHash"); + if (!is_arc_plus_plus_report_successful || !reported_policies_hash || + reported_policies_hash->empty()) { return; + } const base::TimeTicks now = base::TimeTicks::Now(); ArcSessionManager* const session_manager = ArcSessionManager::Get(); - if (reported_policies_hash == initial_policies_hash_ && + if (*reported_policies_hash == initial_policies_hash_ && !first_compliance_timing_reported_) { const base::TimeTicks sign_in_start_time = session_manager->sign_in_start_time(); @@ -696,7 +698,7 @@ first_compliance_timing_reported_ = true; } - if (reported_policies_hash == update_notification_policies_hash_ && + if (*reported_policies_hash == update_notification_policies_hash_ && !compliance_since_update_timing_reported_) { UpdateComplianceSinceUpdateTiming(now - update_notification_time_); compliance_since_update_timing_reported_ = true;
diff --git a/chrome/browser/ash/arc/policy/arc_policy_bridge_unittest.cc b/chrome/browser/ash/arc/policy/arc_policy_bridge_unittest.cc index 1e5da4e..4bd5c69 100644 --- a/chrome/browser/ash/arc/policy/arc_policy_bridge_unittest.cc +++ b/chrome/browser/ash/arc/policy/arc_policy_bridge_unittest.cc
@@ -504,8 +504,8 @@ TEST_F(ArcPolicyBridgeTest, WallpaperImageSetTest) { base::DictionaryValue dict; - dict.SetString("url", "https://example.com/wallpaper.jpg"); - dict.SetString("hash", "somehash"); + dict.SetStringKey("url", "https://example.com/wallpaper.jpg"); + dict.SetStringKey("hash", "somehash"); policy_map().Set(policy::key::kWallpaperImage, policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, dict.Clone(), nullptr);
diff --git a/chrome/browser/ash/arc/tracing/arc_tracing_model.cc b/chrome/browser/ash/arc/tracing/arc_tracing_model.cc index d9abdbf6..e91c1a4 100644 --- a/chrome/browser/ash/arc/tracing/arc_tracing_model.cc +++ b/chrome/browser/ash/arc/tracing/arc_tracing_model.cc
@@ -357,9 +357,10 @@ return false; } - std::string sys_traces; - if (dictionary->GetString("systemTraceEvents", &sys_traces)) { - if (!ConvertSysTraces(sys_traces)) { + const std::string* sys_traces = + dictionary->FindStringKey("systemTraceEvents"); + if (sys_traces) { + if (!ConvertSysTraces(*sys_traces)) { LOG(ERROR) << "Failed to convert systrace data"; return false; }
diff --git a/chrome/browser/ash/customization/customization_document.cc b/chrome/browser/ash/customization/customization_document.cc index 0b24ee89..10d6055 100644 --- a/chrome/browser/ash/customization/customization_document.cc +++ b/chrome/browser/ash/customization/customization_document.cc
@@ -160,16 +160,16 @@ const base::DictionaryValue* locale_dictionary = NULL; if (dictionary_content->GetDictionary(locale, &locale_dictionary)) { - std::string result; - if (locale_dictionary->GetString(entry_name, &result)) - return result; + const std::string* result = locale_dictionary->FindStringKey(entry_name); + if (result) + return *result; } const base::DictionaryValue* default_dictionary = NULL; if (dictionary_content->GetDictionary(kDefaultAttr, &default_dictionary)) { - std::string result; - if (default_dictionary->GetString(entry_name, &result)) - return result; + const std::string* result = default_dictionary->FindStringKey(entry_name); + if (result) + return *result; } return std::string(); @@ -287,8 +287,8 @@ return false; } - std::string result; - if (!root_->GetString(kVersionAttr, &result) || result != accepted_version_) { + const std::string* result = root_->FindStringKey(kVersionAttr); + if (!result || *result != accepted_version_) { LOG(ERROR) << "Wrong customization manifest version"; root_.reset(); return false; @@ -340,9 +340,20 @@ void StartupCustomizationDocument::Init( chromeos::system::StatisticsProvider* statistics_provider) { if (IsReady()) { - root_->GetString(kInitialLocaleAttr, &initial_locale_); - root_->GetString(kInitialTimezoneAttr, &initial_timezone_); - root_->GetString(kKeyboardLayoutAttr, &keyboard_layout_); + const std::string* initial_locale_ptr = + root_->FindStringKey(kInitialLocaleAttr); + if (initial_locale_ptr) + initial_locale_ = *initial_locale_ptr; + + const std::string* initial_timezone_ptr = + root_->FindStringKey(kInitialTimezoneAttr); + if (initial_timezone_ptr) + initial_timezone_ = *initial_timezone_ptr; + + const std::string* keyboard_layout_ptr = + root_->FindStringKey(kKeyboardLayoutAttr); + if (keyboard_layout_ptr) + keyboard_layout_ = *keyboard_layout_ptr; std::string hwid; if (statistics_provider->GetMachineStatistic( @@ -354,21 +365,27 @@ if (hwid_value.is_dict()) hwid_dictionary = &base::Value::AsDictionaryValue(hwid_value); - std::string hwid_mask; - if (hwid_dictionary && - hwid_dictionary->GetString(kHwidMaskAttr, &hwid_mask)) { - if (base::MatchPattern(hwid, hwid_mask)) { + const std::string* hwid_mask = + hwid_dictionary ? hwid_dictionary->FindStringKey(kHwidMaskAttr) + : nullptr; + if (hwid_mask) { + if (base::MatchPattern(hwid, *hwid_mask)) { // If HWID for this machine matches some mask, use HWID specific // settings. - std::string result; - if (hwid_dictionary->GetString(kInitialLocaleAttr, &result)) - initial_locale_ = result; + const std::string* initial_locale = + hwid_dictionary->FindStringKey(kInitialLocaleAttr); + if (initial_locale) + initial_locale_ = *initial_locale; - if (hwid_dictionary->GetString(kInitialTimezoneAttr, &result)) - initial_timezone_ = result; + const std::string* initial_timezone = + hwid_dictionary->FindStringKey(kInitialTimezoneAttr); + if (initial_timezone) + initial_timezone_ = *initial_timezone; - if (hwid_dictionary->GetString(kKeyboardLayoutAttr, &result)) - keyboard_layout_ = result; + const std::string* keyboard_layout = + hwid_dictionary->FindStringKey(kKeyboardLayoutAttr); + if (keyboard_layout) + keyboard_layout_ = *keyboard_layout; } // Don't break here to allow other entires to be applied if match. } else { @@ -701,11 +718,11 @@ if (!IsReady()) return false; - std::string url; - if (!root_->GetString(kDefaultWallpaperAttr, &url)) + const std::string* url = root_->FindStringKey(kDefaultWallpaperAttr); + if (!url) return false; - *out_url = GURL(url); + *out_url = GURL(*url); return true; } @@ -741,11 +758,13 @@ } else if (app_entry_value.is_dict()) { const base::DictionaryValue& app_entry = base::Value::AsDictionaryValue(app_entry_value); - if (!app_entry.GetString(kIdAttr, &app_id)) { + const std::string* app_id_ptr = app_entry.FindStringKey(kIdAttr); + if (!app_id_ptr) { LOG(ERROR) << "Wrong format of default application list"; prefs->DictClear(); break; } + app_id = *app_id_ptr; entry = app_entry.CreateDeepCopy(); entry->RemoveKey(kIdAttr); } else { @@ -755,8 +774,9 @@ } if (!entry->FindKey( extensions::ExternalProviderImpl::kExternalUpdateUrl)) { - entry->SetString(extensions::ExternalProviderImpl::kExternalUpdateUrl, - extension_urls::GetWebstoreUpdateUrl().spec()); + entry->SetStringKey( + extensions::ExternalProviderImpl::kExternalUpdateUrl, + extension_urls::GetWebstoreUpdateUrl().spec()); } prefs->SetPath(app_id, base::Value::FromUniquePtrValue(std::move(entry))); }
diff --git a/chrome/browser/ash/customization/customization_document_browsertest.cc b/chrome/browser/ash/customization/customization_document_browsertest.cc index b028388..368daadb 100644 --- a/chrome/browser/ash/customization/customization_document_browsertest.cc +++ b/chrome/browser/ash/customization/customization_document_browsertest.cc
@@ -244,15 +244,15 @@ ASSERT_TRUE(ui_language_list->GetDictionary(i, &language_info)) << "Test failed for initial_locale='" << GetParam() << "', i=" << i; - std::string value; - ASSERT_TRUE(language_info->GetString("value", &value)) - << "Test failed for initial_locale='" << GetParam() << "', i=" << i; + const std::string* value = language_info->FindStringKey("value"); + ASSERT_TRUE(value) << "Test failed for initial_locale='" << GetParam() + << "', i=" << i; if (i < locales.size()) { - EXPECT_EQ(locales[i], value) << "Test failed for initial_locale='" - << GetParam() << "', i=" << i; + EXPECT_EQ(locales[i], *value) + << "Test failed for initial_locale='" << GetParam() << "', i=" << i; } else { - EXPECT_EQ(kMostRelevantLanguagesDivider, value) + EXPECT_EQ(kMostRelevantLanguagesDivider, *value) << "Test failed for initial_locale='" << GetParam() << "', i=" << i; break; }
diff --git a/chrome/browser/ash/file_manager/fileapi_util.cc b/chrome/browser/ash/file_manager/fileapi_util.cc index e7d2e344..ee5a81cc 100644 --- a/chrome/browser/ash/file_manager/fileapi_util.cc +++ b/chrome/browser/ash/file_manager/fileapi_util.cc
@@ -609,9 +609,9 @@ std::unique_ptr<base::DictionaryValue> ConvertEntryDefinitionToValue( const EntryDefinition& entry_definition) { auto entry = std::make_unique<base::DictionaryValue>(); - entry->SetString("fileSystemName", entry_definition.file_system_name); - entry->SetString("fileSystemRoot", entry_definition.file_system_root_url); - entry->SetString( + entry->SetStringKey("fileSystemName", entry_definition.file_system_name); + entry->SetStringKey("fileSystemRoot", entry_definition.file_system_root_url); + entry->SetStringKey( "fileFullPath", base::FilePath("/").Append(entry_definition.full_path).AsUTF8Unsafe()); entry->SetBoolean("fileIsDirectory", entry_definition.is_directory);
diff --git a/chrome/browser/ash/file_manager/url_util.cc b/chrome/browser/ash/file_manager/url_util.cc index 59273a7..67474600 100644 --- a/chrome/browser/ash/file_manager/url_util.cc +++ b/chrome/browser/ash/file_manager/url_util.cc
@@ -77,14 +77,14 @@ const std::string& search_query, bool show_android_picker_apps) { base::DictionaryValue arg_value; - arg_value.SetString("type", GetDialogTypeAsString(type)); - arg_value.SetString("title", title); - arg_value.SetString("currentDirectoryURL", current_directory_url.spec()); - arg_value.SetString("selectionURL", selection_url.spec()); + arg_value.SetStringKey("type", GetDialogTypeAsString(type)); + arg_value.SetStringKey("title", title); + arg_value.SetStringKey("currentDirectoryURL", current_directory_url.spec()); + arg_value.SetStringKey("selectionURL", selection_url.spec()); // |targetName| is only relevant for SaveAs. if (type == ui::SelectFileDialog::Type::SELECT_SAVEAS_FILE) - arg_value.SetString("targetName", target_name); - arg_value.SetString("searchQuery", search_query); + arg_value.SetStringKey("targetName", target_name); + arg_value.SetStringKey("searchQuery", search_query); arg_value.SetBoolean("showAndroidPickerApps", show_android_picker_apps); if (file_types) { @@ -100,7 +100,7 @@ if (i < file_types->extension_description_overrides.size()) { std::u16string desc = file_types->extension_description_overrides[i]; - dict->SetString("description", desc); + dict->SetStringKey("description", desc); } // file_type_index is 1-based. 0 means no selection at all. @@ -117,17 +117,17 @@ if (file_types) { switch (file_types->allowed_paths) { case ui::SelectFileDialog::FileTypeInfo::NATIVE_PATH: - arg_value.SetString(kAllowedPaths, kNativePath); + arg_value.SetStringKey(kAllowedPaths, kNativePath); break; case ui::SelectFileDialog::FileTypeInfo::ANY_PATH: - arg_value.SetString(kAllowedPaths, kAnyPath); + arg_value.SetStringKey(kAllowedPaths, kAnyPath); break; case ui::SelectFileDialog::FileTypeInfo::ANY_PATH_OR_URL: - arg_value.SetString(kAllowedPaths, kAnyPathOrUrl); + arg_value.SetStringKey(kAllowedPaths, kAnyPathOrUrl); break; } } else { - arg_value.SetString(kAllowedPaths, kNativePath); + arg_value.SetStringKey(kAllowedPaths, kNativePath); } std::string json_args;
diff --git a/chrome/browser/ash/input_method/component_extension_ime_manager_delegate_impl.cc b/chrome/browser/ash/input_method/component_extension_ime_manager_delegate_impl.cc index 5ecedfe..4a36ae335b 100644 --- a/chrome/browser/ash/input_method/component_extension_ime_manager_delegate_impl.cc +++ b/chrome/browser/ash/input_method/component_extension_ime_manager_delegate_impl.cc
@@ -255,12 +255,21 @@ const base::DictionaryValue& dict, ComponentExtensionEngine* out) { DCHECK(out); - if (!dict.GetString(extensions::manifest_keys::kId, &out->engine_id)) + const std::string* engine_id = + dict.FindStringKey(extensions::manifest_keys::kId); + if (!engine_id) return false; - if (!dict.GetString(extensions::manifest_keys::kName, &out->display_name)) + out->engine_id = *engine_id; + + const std::string* display_name = + dict.FindStringKey(extensions::manifest_keys::kName); + if (!display_name) return false; - if (!dict.GetString(extensions::manifest_keys::kIndicator, &out->indicator)) - out->indicator = ""; + out->display_name = *display_name; + + const std::string* indicator = + dict.FindStringKey(extensions::manifest_keys::kIndicator); + out->indicator = indicator ? *indicator : ""; std::set<std::string> languages; const base::Value* language_value = nullptr; @@ -303,7 +312,10 @@ return false; out->input_view_url = url; #else - if (dict.GetString(extensions::manifest_keys::kInputView, &url_string)) { + const std::string* input_view = + dict.FindStringKey(extensions::manifest_keys::kInputView); + if (input_view) { + url_string = *input_view; GURL url = extensions::Extension::GetResourceURL( extensions::Extension::GetBaseURLFromExtensionId( component_extension.id), @@ -314,7 +326,10 @@ } #endif - if (dict.GetString(extensions::manifest_keys::kOptionsPage, &url_string)) { + const std::string* option_page = + dict.FindStringKey(extensions::manifest_keys::kOptionsPage); + if (option_page) { + url_string = *option_page; GURL url = extensions::Extension::GetResourceURL( extensions::Extension::GetBaseURLFromExtensionId( component_extension.id), @@ -335,18 +350,21 @@ const base::DictionaryValue& manifest, const std::string& extension_id, ComponentExtensionIME* out) { - if (!manifest.GetString(extensions::manifest_keys::kDescription, - &out->description)) + const std::string* description = + manifest.FindStringKey(extensions::manifest_keys::kDescription); + if (!description) return false; - std::string path; - if (manifest.GetString(kImePathKeyName, &path)) - out->path = base::FilePath(path); - std::string url_string; - if (manifest.GetString(extensions::manifest_keys::kOptionsPage, - &url_string)) { + out->description = *description; + + const std::string* path = manifest.FindStringKey(kImePathKeyName); + if (path) + out->path = base::FilePath(*path); + const std::string* url_string = + manifest.FindStringKey(extensions::manifest_keys::kOptionsPage); + if (url_string) { GURL url = extensions::Extension::GetResourceURL( extensions::Extension::GetBaseURLFromExtensionId(extension_id), - url_string); + *url_string); if (!url.is_valid()) return false; out->options_page_url = url;
diff --git a/chrome/browser/ash/login/chrome_restart_request.cc b/chrome/browser/ash/login/chrome_restart_request.cc index d9bb52d..e2e2de2 100644 --- a/chrome/browser/ash/login/chrome_restart_request.cc +++ b/chrome/browser/ash/login/chrome_restart_request.cc
@@ -365,19 +365,20 @@ const base::CommandLine& base_command_line, base::CommandLine* command_line) { base::DictionaryValue otr_switches; - otr_switches.SetString(switches::kGuestSession, std::string()); - otr_switches.SetString(::switches::kIncognito, std::string()); - otr_switches.SetString(::switches::kLoggingLevel, kGuestModeLoggingLevel); - otr_switches.SetString( + otr_switches.SetStringKey(switches::kGuestSession, std::string()); + otr_switches.SetStringKey(::switches::kIncognito, std::string()); + otr_switches.SetStringKey(::switches::kLoggingLevel, kGuestModeLoggingLevel); + otr_switches.SetStringKey( switches::kLoginUser, cryptohome::Identification(user_manager::GuestAccountId()).id()); if (!base::SysInfo::IsRunningOnChromeOS()) { - otr_switches.SetString(switches::kLoginProfile, chrome::kLegacyProfileDir); + otr_switches.SetStringKey(switches::kLoginProfile, + chrome::kLegacyProfileDir); } // Override the home page. - otr_switches.SetString(::switches::kHomePage, - GURL(chrome::kChromeUINewTabURL).spec()); + otr_switches.SetStringKey(::switches::kHomePage, + GURL(chrome::kChromeUINewTabURL).spec()); DeriveCommandLine(start_url, base_command_line, otr_switches, command_line); DeriveEnabledFeatures(command_line);
diff --git a/chrome/browser/ash/login/easy_unlock/easy_unlock_service.cc b/chrome/browser/ash/login/easy_unlock/easy_unlock_service.cc index 3a9f3371..331b6bc 100644 --- a/chrome/browser/ash/login/easy_unlock/easy_unlock_service.cc +++ b/chrome/browser/ash/login/easy_unlock/easy_unlock_service.cc
@@ -152,8 +152,7 @@ if (!local_state) return; - DictionaryPrefUpdateDeprecated update(local_state, - prefs::kEasyUnlockHardlockState); + DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState); update->RemoveKey(account_id.GetUserEmail()); EasyUnlockTpmKeyManager::ResetLocalStateForUser(account_id); @@ -549,10 +548,8 @@ return; } - DictionaryPrefUpdateDeprecated update(local_state, - prefs::kEasyUnlockHardlockState); - update->SetKey(account_id.GetUserEmail(), - base::Value(static_cast<int>(state))); + DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState); + update->SetIntKey(account_id.GetUserEmail(), static_cast<int>(state)); if (GetAccountId() == account_id) SetSmartLockHardlockedState(state);
diff --git a/chrome/browser/ash/login/easy_unlock/easy_unlock_service_regular.cc b/chrome/browser/ash/login/easy_unlock/easy_unlock_service_regular.cc index 9368a10c..ec09ead 100644 --- a/chrome/browser/ash/login/easy_unlock/easy_unlock_service_regular.cc +++ b/chrome/browser/ash/login/easy_unlock/easy_unlock_service_regular.cc
@@ -279,8 +279,8 @@ JSONStringValueSerializer serializer(&remote_devices_json); serializer.Serialize(devices); - DictionaryPrefUpdateDeprecated pairing_update(profile()->GetPrefs(), - prefs::kEasyUnlockPairing); + DictionaryPrefUpdate pairing_update(profile()->GetPrefs(), + prefs::kEasyUnlockPairing); if (devices.GetList().empty()) pairing_update->RemoveKey(kKeyDevices); else
diff --git a/chrome/browser/ash/login/easy_unlock/easy_unlock_tpm_key_manager.cc b/chrome/browser/ash/login/easy_unlock/easy_unlock_tpm_key_manager.cc index ba3e2af..b5014171 100644 --- a/chrome/browser/ash/login/easy_unlock/easy_unlock_tpm_key_manager.cc +++ b/chrome/browser/ash/login/easy_unlock/easy_unlock_tpm_key_manager.cc
@@ -197,8 +197,7 @@ if (!local_state) return; - DictionaryPrefUpdateDeprecated update(local_state, - prefs::kEasyUnlockLocalStateTpmKeys); + DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockLocalStateTpmKeys); update->RemoveKey(account_id.GetUserEmail()); } @@ -305,9 +304,9 @@ std::string encoded; base::Base64Encode(value, &encoded); - DictionaryPrefUpdateDeprecated update(local_state_, - prefs::kEasyUnlockLocalStateTpmKeys); - update->SetKey(account_id.GetUserEmail(), base::Value(encoded)); + DictionaryPrefUpdate update(local_state_, + prefs::kEasyUnlockLocalStateTpmKeys); + update->SetStringKey(account_id.GetUserEmail(), encoded); } void EasyUnlockTpmKeyManager::OnUserTPMInitialized(
diff --git a/chrome/browser/ash/login/easy_unlock/easy_unlock_tpm_key_manager_unittest.cc b/chrome/browser/ash/login/easy_unlock/easy_unlock_tpm_key_manager_unittest.cc index 48d5e38b..1cf07ca 100644 --- a/chrome/browser/ash/login/easy_unlock/easy_unlock_tpm_key_manager_unittest.cc +++ b/chrome/browser/ash/login/easy_unlock/easy_unlock_tpm_key_manager_unittest.cc
@@ -339,9 +339,9 @@ const std::string& value) { std::string encoded; base::Base64Encode(value, &encoded); - DictionaryPrefUpdateDeprecated update(g_browser_process->local_state(), - prefs::kEasyUnlockLocalStateTpmKeys); - update->SetKey(account_id.GetUserEmail(), base::Value(encoded)); + DictionaryPrefUpdate update(g_browser_process->local_state(), + prefs::kEasyUnlockLocalStateTpmKeys); + update->SetStringKey(account_id.GetUserEmail(), encoded); } protected:
diff --git a/chrome/browser/ash/login/existing_user_controller.cc b/chrome/browser/ash/login/existing_user_controller.cc index 2cbe7e1..783fc9a 100644 --- a/chrome/browser/ash/login/existing_user_controller.cc +++ b/chrome/browser/ash/login/existing_user_controller.cc
@@ -1494,7 +1494,9 @@ base::DictionaryValue* entry = nullptr; keyboard_layouts->GetDictionary(i, &entry); if (entry->FindBoolKey("selected").value_or(false)) { - entry->GetString("value", &keyboard_layout); + const std::string* keyboard_layout_ptr = entry->FindStringKey("value"); + if (keyboard_layout_ptr) + keyboard_layout = *keyboard_layout_ptr; break; } }
diff --git a/chrome/browser/ash/login/login_manager_test.cc b/chrome/browser/ash/login/login_manager_test.cc index b8b53b64..b2ef8043 100644 --- a/chrome/browser/ash/login/login_manager_test.cc +++ b/chrome/browser/ash/login/login_manager_test.cc
@@ -63,8 +63,7 @@ } void LoginManagerTest::RegisterUser(const AccountId& account_id) { - ListPrefUpdateDeprecated users_pref(g_browser_process->local_state(), - "LoggedInUsers"); + ListPrefUpdate users_pref(g_browser_process->local_state(), "LoggedInUsers"); base::Value email_value(account_id.GetUserEmail()); if (!base::Contains(users_pref->GetList(), email_value)) users_pref->Append(std::move(email_value));
diff --git a/chrome/browser/ash/login/screens/packaged_license_screen_browsertest.cc b/chrome/browser/ash/login/screens/packaged_license_screen_browsertest.cc index 24ed170..68d9cae 100644 --- a/chrome/browser/ash/login/screens/packaged_license_screen_browsertest.cc +++ b/chrome/browser/ash/login/screens/packaged_license_screen_browsertest.cc
@@ -41,11 +41,9 @@ } void SetUpLicense(bool value) { - DictionaryPrefUpdateDeprecated dict(local_state(), - prefs::kServerBackedDeviceState); + DictionaryPrefUpdate dict(local_state(), prefs::kServerBackedDeviceState); if (value) { - dict.Get()->SetKey(policy::kDeviceStatePackagedLicense, - base::Value(true)); + dict.Get()->SetBoolKey(policy::kDeviceStatePackagedLicense, true); } else { dict.Get()->RemoveKey(policy::kDeviceStatePackagedLicense); }
diff --git a/chrome/browser/ash/login/test/embedded_policy_test_server_mixin.cc b/chrome/browser/ash/login/test/embedded_policy_test_server_mixin.cc index a4bf429..729bb78 100644 --- a/chrome/browser/ash/login/test/embedded_policy_test_server_mixin.cc +++ b/chrome/browser/ash/login/test/embedded_policy_test_server_mixin.cc
@@ -21,13 +21,17 @@ #include "components/policy/core/common/cloud/cloud_policy_constants.h" #include "components/policy/core/common/cloud/test/policy_builder.h" #include "components/policy/core/common/policy_switches.h" +#include "components/policy/proto/chrome_extension_policy.pb.h" #include "components/policy/test_support/client_storage.h" #include "components/policy/test_support/embedded_policy_test_server.h" #include "components/policy/test_support/policy_storage.h" #include "components/policy/test_support/signature_provider.h" +#include "crypto/sha2.h" #include "net/http/http_status_code.h" #include "third_party/abseil-cpp/absl/types/optional.h" +namespace em = enterprise_management; + namespace ash { namespace { @@ -122,6 +126,23 @@ serialized_policy); } +void EmbeddedPolicyTestServerMixin::UpdateExternalPolicy( + const std::string& type, + const std::string& entity_id, + const std::string& raw_policy) { + // Register raw policy to be served by external endpoint. + policy_test_server_->policy_storage()->SetExternalPolicyPayload( + type, entity_id, raw_policy); + + // Register proto policy with details on how to fetch the raw policy. + em::ExternalPolicyData external_policy_data; + external_policy_data.set_download_url( + policy_test_server_->GetExternalPolicyDataURL(type, entity_id).spec()); + external_policy_data.set_secure_hash(crypto::SHA256HashString(raw_policy)); + policy_test_server_->policy_storage()->SetPolicyPayload( + type, entity_id, external_policy_data.SerializeAsString()); +} + void EmbeddedPolicyTestServerMixin::SetUpdateDeviceAttributesPermission( bool allowed) { policy_test_server_->policy_storage()->set_allow_set_device_attributes(
diff --git a/chrome/browser/ash/login/test/embedded_policy_test_server_mixin.h b/chrome/browser/ash/login/test/embedded_policy_test_server_mixin.h index f1bd1f4..a8f9b9e 100644 --- a/chrome/browser/ash/login/test/embedded_policy_test_server_mixin.h +++ b/chrome/browser/ash/login/test/embedded_policy_test_server_mixin.h
@@ -80,6 +80,14 @@ const std::string& entity_id, const std::string& serialized_policy); + // Updates policy selected by |type| and optional |entity_id|. The + // |raw_policy| is served via an external data point. This does not trigger + // policy invalidation, hence test authors must manually trigger a policy + // fetch. + void UpdateExternalPolicy(const std::string& type, + const std::string& entity_id, + const std::string& raw_policy); + // Configures whether the server should indicate that the client is // allowed to update device attributes in response to // DeviceAttributeUpdatePermissionRequest.
diff --git a/chrome/browser/ash/login/test/login_manager_mixin.cc b/chrome/browser/ash/login/test/login_manager_mixin.cc index c9f6928..5cb910d 100644 --- a/chrome/browser/ash/login/test/login_manager_mixin.cc +++ b/chrome/browser/ash/login/test/login_manager_mixin.cc
@@ -127,21 +127,21 @@ void LoginManagerMixin::SetUpLocalState() { for (const auto& user : initial_users_) { - ListPrefUpdateDeprecated users_pref(g_browser_process->local_state(), - "LoggedInUsers"); + ListPrefUpdate users_pref(g_browser_process->local_state(), + "LoggedInUsers"); base::Value email_value(user.account_id.GetUserEmail()); if (!base::Contains(users_pref->GetList(), email_value)) users_pref->Append(std::move(email_value)); - DictionaryPrefUpdateDeprecated user_type_update( - g_browser_process->local_state(), "UserType"); - user_type_update->SetKey(user.account_id.GetAccountIdKey(), - base::Value(static_cast<int>(user.user_type))); + DictionaryPrefUpdate user_type_update(g_browser_process->local_state(), + "UserType"); + user_type_update->SetIntKey(user.account_id.GetAccountIdKey(), + static_cast<int>(user.user_type)); - DictionaryPrefUpdateDeprecated user_token_update( - g_browser_process->local_state(), "OAuthTokenStatus"); - user_token_update->SetKey(user.account_id.GetUserEmail(), - base::Value(static_cast<int>(user.token_status))); + DictionaryPrefUpdate user_token_update(g_browser_process->local_state(), + "OAuthTokenStatus"); + user_token_update->SetIntKey(user.account_id.GetUserEmail(), + static_cast<int>(user.token_status)); user_manager::known_user::UpdateId(user.account_id);
diff --git a/chrome/browser/ash/login/users/avatar/user_image_manager_impl.cc b/chrome/browser/ash/login/users/avatar/user_image_manager_impl.cc index 95bc4c0..2d41080 100644 --- a/chrome/browser/ash/login/users/avatar/user_image_manager_impl.cc +++ b/chrome/browser/ash/login/users/avatar/user_image_manager_impl.cc
@@ -465,7 +465,7 @@ return; } - DictionaryPrefUpdateDeprecated update(local_state, kUserImageProperties); + DictionaryPrefUpdate update(local_state, kUserImageProperties); update->SetKey(account_id().GetUserEmail(), std::move(entry)); @@ -855,19 +855,19 @@ void UserImageManagerImpl::DeleteUserImageAndLocalStateEntry( const char* prefs_dict_root) { - DictionaryPrefUpdateDeprecated update(g_browser_process->local_state(), - prefs_dict_root); - const base::DictionaryValue* image_properties; - if (!update->GetDictionaryWithoutPathExpansion(account_id_.GetUserEmail(), - &image_properties)) + DictionaryPrefUpdate update(g_browser_process->local_state(), + prefs_dict_root); + const base::Value* image_properties = + update->FindDictKey(account_id_.GetUserEmail()); + if (!image_properties) return; - std::string image_path; - image_properties->GetString(kImagePathNodeName, &image_path); - if (!image_path.empty()) { + const std::string* image_path = + image_properties->FindStringKey(kImagePathNodeName); + if (image_path && !image_path->empty()) { background_task_runner_->PostTask( FROM_HERE, base::BindOnce(base::GetDeleteFileCallback(), - base::FilePath(image_path))); + base::FilePath(*image_path))); } update->RemoveKey(account_id_.GetUserEmail()); }
diff --git a/chrome/browser/ash/login/users/avatar/user_image_sync_observer.cc b/chrome/browser/ash/login/users/avatar/user_image_sync_observer.cc index c994652..2e41f20 100644 --- a/chrome/browser/ash/login/users/avatar/user_image_sync_observer.cc +++ b/chrome/browser/ash/login/users/avatar/user_image_sync_observer.cc
@@ -143,9 +143,9 @@ int synced_index; if (GetSyncedImageIndex(&synced_index) && (synced_index == local_index)) return; - DictionaryPrefUpdateDeprecated update(prefs_, kUserImageInfo); - base::DictionaryValue* dict = update.Get(); - dict->SetInteger(kImageIndex, local_index); + DictionaryPrefUpdate update(prefs_, kUserImageInfo); + base::Value* dict = update.Get(); + dict->SetIntKey(kImageIndex, local_index); VLOG(1) << "Saved avatar index " << local_index << " to sync."; }
diff --git a/chrome/browser/ash/login/users/chrome_user_manager_impl.cc b/chrome/browser/ash/login/users/chrome_user_manager_impl.cc index f4f2918..c798aa7 100644 --- a/chrome/browser/ash/login/users/chrome_user_manager_impl.cc +++ b/chrome/browser/ash/login/users/chrome_user_manager_impl.cc
@@ -789,8 +789,8 @@ // If ephemeral users are enabled and we are on the login screen, take this // opportunity to clean up by removing all regular users except the owner. if (GetEphemeralUsersEnabled() && !IsUserLoggedIn()) { - ListPrefUpdateDeprecated prefs_users_update( - GetLocalState(), user_manager::kRegularUsersPref); + ListPrefUpdate prefs_users_update(GetLocalState(), + user_manager::kRegularUsersPref); prefs_users_update->ClearList(); for (user_manager::UserList::iterator it = users_.begin(); it != users_.end();) { @@ -956,8 +956,7 @@ // TODO(tbarzic): Forward data removal request to HammerDeviceHandler, // instead of removing the prefs value here. if (GetLocalState()->FindPreference(prefs::kDetachableBaseDevices)) { - DictionaryPrefUpdateDeprecated update(GetLocalState(), - prefs::kDetachableBaseDevices); + DictionaryPrefUpdate update(GetLocalState(), prefs::kDetachableBaseDevices); update->RemoveKey(account_id.HasAccountIdKey() ? account_id.GetAccountIdKey() : account_id.GetUserEmail()); @@ -1052,7 +1051,7 @@ // will be loaded in LoadDeviceLocalAccounts() on the next reboot regardless // of whether they still exist in kAccountsPrefDeviceLocalAccounts, allowing // us to clean up associated data if they disappear from policy. - ListPrefUpdateDeprecated prefs_device_local_accounts_update( + ListPrefUpdate prefs_device_local_accounts_update( GetLocalState(), kDeviceLocalAccountsWithSavedData); prefs_device_local_accounts_update->ClearList(); for (const auto& account : device_local_accounts) @@ -1349,16 +1348,14 @@ } void ChromeUserManagerImpl::AddReportingUser(const AccountId& account_id) { - ListPrefUpdateDeprecated users_update(GetLocalState(), - ::prefs::kReportingUsers); + ListPrefUpdate users_update(GetLocalState(), ::prefs::kReportingUsers); base::Value email_value(account_id.GetUserEmail()); if (!base::Contains(users_update->GetList(), email_value)) users_update->Append(std::move(email_value)); } void ChromeUserManagerImpl::RemoveReportingUser(const AccountId& account_id) { - ListPrefUpdateDeprecated users_update(GetLocalState(), - ::prefs::kReportingUsers); + ListPrefUpdate users_update(GetLocalState(), ::prefs::kReportingUsers); users_update->EraseListIter( std::find(users_update->GetList().begin(), users_update->GetList().end(), base::Value(FullyCanonicalize(account_id.GetUserEmail()))));
diff --git a/chrome/browser/ash/login/users/multi_profile_user_controller.cc b/chrome/browser/ash/login/users/multi_profile_user_controller.cc index 5f5f54f..fc0a51ed 100644 --- a/chrome/browser/ash/login/users/multi_profile_user_controller.cc +++ b/chrome/browser/ash/login/users/multi_profile_user_controller.cc
@@ -161,8 +161,8 @@ void MultiProfileUserController::RemoveCachedValues( const std::string& user_email) { - DictionaryPrefUpdateDeprecated update(local_state_, - prefs::kCachedMultiProfileUserBehavior); + DictionaryPrefUpdate update(local_state_, + prefs::kCachedMultiProfileUserBehavior); update->RemoveKey(user_email); } @@ -182,8 +182,8 @@ void MultiProfileUserController::SetCachedValue(const std::string& user_email, const std::string& behavior) { - DictionaryPrefUpdateDeprecated update(local_state_, - prefs::kCachedMultiProfileUserBehavior); + DictionaryPrefUpdate update(local_state_, + prefs::kCachedMultiProfileUserBehavior); update->SetKey(user_email, base::Value(SanitizeBehaviorValue(behavior))); } @@ -209,8 +209,8 @@ ->IsDefaultValue()) { // Migration code to clear cached default behavior. // TODO(xiyuan): Remove this after M35. - DictionaryPrefUpdateDeprecated update( - local_state_, prefs::kCachedMultiProfileUserBehavior); + DictionaryPrefUpdate update(local_state_, + prefs::kCachedMultiProfileUserBehavior); update->RemoveKey(user_email); } else { const std::string behavior =
diff --git a/chrome/browser/ash/login/users/supervised_user_manager_impl.cc b/chrome/browser/ash/login/users/supervised_user_manager_impl.cc index ee19187..4cbcd5a 100644 --- a/chrome/browser/ash/login/users/supervised_user_manager_impl.cc +++ b/chrome/browser/ash/login/users/supervised_user_manager_impl.cc
@@ -229,31 +229,30 @@ const char* key, const std::string& value) { PrefService* local_state = g_browser_process->local_state(); - DictionaryPrefUpdateDeprecated update(local_state, key); - update->SetKey(user_id, base::Value(value)); + DictionaryPrefUpdate update(local_state, key); + update->SetStringKey(user_id, value); } void SupervisedUserManagerImpl::SetUserIntegerValue(const std::string& user_id, const char* key, const int value) { PrefService* local_state = g_browser_process->local_state(); - DictionaryPrefUpdateDeprecated update(local_state, key); - update->SetKey(user_id, base::Value(value)); + DictionaryPrefUpdate update(local_state, key); + update->SetIntKey(user_id, value); } void SupervisedUserManagerImpl::SetUserBooleanValue(const std::string& user_id, const char* key, const bool value) { PrefService* local_state = g_browser_process->local_state(); - DictionaryPrefUpdateDeprecated update(local_state, key); - update->SetKey(user_id, base::Value(value)); + DictionaryPrefUpdate update(local_state, key); + update->SetBoolKey(user_id, value); } void SupervisedUserManagerImpl::RemoveNonCryptohomeData( const std::string& user_id) { PrefService* prefs = g_browser_process->local_state(); - ListPrefUpdateDeprecated prefs_new_users_update(prefs, - kSupervisedUsersFirstRun); + ListPrefUpdate prefs_new_users_update(prefs, kSupervisedUsersFirstRun); prefs_new_users_update->EraseListValue(base::Value(user_id)); CleanPref(user_id, kSupervisedUserSyncId); @@ -270,13 +269,13 @@ void SupervisedUserManagerImpl::CleanPref(const std::string& user_id, const char* key) { PrefService* prefs = g_browser_process->local_state(); - DictionaryPrefUpdateDeprecated dict_update(prefs, key); + DictionaryPrefUpdate dict_update(prefs, key); dict_update->RemoveKey(user_id); } bool SupervisedUserManagerImpl::CheckForFirstRun(const std::string& user_id) { - ListPrefUpdateDeprecated prefs_new_users_update( - g_browser_process->local_state(), kSupervisedUsersFirstRun); + ListPrefUpdate prefs_new_users_update(g_browser_process->local_state(), + kSupervisedUsersFirstRun); return prefs_new_users_update->EraseListValue(base::Value(user_id)); }
diff --git a/chrome/browser/ash/login/wizard_controller_browsertest.cc b/chrome/browser/ash/login/wizard_controller_browsertest.cc index 66108cbb..0d85546 100644 --- a/chrome/browser/ash/login/wizard_controller_browsertest.cc +++ b/chrome/browser/ash/login/wizard_controller_browsertest.cc
@@ -1207,9 +1207,10 @@ EXPECT_EQ(AutoEnrollmentCheckScreenView::kScreenId.AsId(), GetErrorScreen()->GetParentScreen()); base::DictionaryValue device_state; - device_state.SetString(policy::kDeviceStateMode, - policy::kDeviceStateModeDisabled); - device_state.SetString(policy::kDeviceStateDisabledMessage, kDisabledMessage); + device_state.SetStringKey(policy::kDeviceStateMode, + policy::kDeviceStateModeDisabled); + device_state.SetStringKey(policy::kDeviceStateDisabledMessage, + kDisabledMessage); g_browser_process->local_state()->Set(prefs::kServerBackedDeviceState, device_state); EXPECT_CALL(*device_disabled_screen_view_, Show(_, _, kDisabledMessage)) @@ -1317,8 +1318,9 @@ ->clear_forced_re_enrollment_vpd_call_count()); base::DictionaryValue device_state; - device_state.SetString(policy::kDeviceStateMode, - policy::kDeviceStateRestoreModeReEnrollmentEnforced); + device_state.SetStringKey( + policy::kDeviceStateMode, + policy::kDeviceStateRestoreModeReEnrollmentEnforced); g_browser_process->local_state()->Set(prefs::kServerBackedDeviceState, device_state); EXPECT_CALL(*mock_enrollment_screen_, ShowImpl()).Times(1); @@ -1402,8 +1404,9 @@ test::OobeJS().ExpectHiddenPath(kGuestSessionLink); base::DictionaryValue device_state; - device_state.SetString(policy::kDeviceStateMode, - policy::kDeviceStateRestoreModeReEnrollmentEnforced); + device_state.SetStringKey( + policy::kDeviceStateMode, + policy::kDeviceStateRestoreModeReEnrollmentEnforced); g_browser_process->local_state()->Set(prefs::kServerBackedDeviceState, device_state); EXPECT_CALL(*mock_enrollment_screen_, ShowImpl()).Times(1); @@ -1522,8 +1525,9 @@ EXPECT_EQ(AutoEnrollmentCheckScreenView::kScreenId.AsId(), GetErrorScreen()->GetParentScreen()); base::DictionaryValue device_state; - device_state.SetString(policy::kDeviceStateMode, - policy::kDeviceStateRestoreModeReEnrollmentEnforced); + device_state.SetStringKey( + policy::kDeviceStateMode, + policy::kDeviceStateRestoreModeReEnrollmentEnforced); g_browser_process->local_state()->Set(prefs::kServerBackedDeviceState, device_state); EXPECT_CALL(*mock_enrollment_screen_, ShowImpl()).Times(1); @@ -1628,8 +1632,9 @@ test::OobeJS().ExpectVisiblePath(kGuestSessionLink); base::DictionaryValue device_state; - device_state.SetString(policy::kDeviceStateMode, - policy::kDeviceStateRestoreModeReEnrollmentEnforced); + device_state.SetStringKey( + policy::kDeviceStateMode, + policy::kDeviceStateRestoreModeReEnrollmentEnforced); g_browser_process->local_state()->Set(prefs::kServerBackedDeviceState, device_state); EXPECT_CALL(*mock_enrollment_screen_, ShowImpl()).Times(1); @@ -1842,8 +1847,9 @@ system::kEnterpriseManagementEmbargoEndDateKey, GenerateEmbargoEndDate(-1 /* days_offset */)); base::DictionaryValue device_state; - device_state.SetString(policy::kDeviceStateMode, - policy::kDeviceStateRestoreModeReEnrollmentEnforced); + device_state.SetStringKey( + policy::kDeviceStateMode, + policy::kDeviceStateRestoreModeReEnrollmentEnforced); g_browser_process->local_state()->Set(prefs::kServerBackedDeviceState, device_state); @@ -2689,9 +2695,10 @@ EXPECT_EQ(AutoEnrollmentCheckScreenView::kScreenId.AsId(), GetErrorScreen()->GetParentScreen()); base::DictionaryValue device_state; - device_state.SetString(policy::kDeviceStateMode, - policy::kDeviceStateModeDisabled); - device_state.SetString(policy::kDeviceStateDisabledMessage, kDisabledMessage); + device_state.SetStringKey(policy::kDeviceStateMode, + policy::kDeviceStateModeDisabled); + device_state.SetStringKey(policy::kDeviceStateDisabledMessage, + kDisabledMessage); g_browser_process->local_state()->Set(prefs::kServerBackedDeviceState, device_state);
diff --git a/chrome/browser/ash/notifications/idle_app_name_notification_view_unittest.cc b/chrome/browser/ash/notifications/idle_app_name_notification_view_unittest.cc index 1aa6543..f8d8fe3d 100644 --- a/chrome/browser/ash/notifications/idle_app_name_notification_view_unittest.cc +++ b/chrome/browser/ash/notifications/idle_app_name_notification_view_unittest.cc
@@ -43,20 +43,20 @@ BrowserWithTestWindowTest::SetUp(); base::DictionaryValue manifest; - manifest.SetString(extensions::manifest_keys::kName, "Test"); - manifest.SetString(extensions::manifest_keys::kVersion, "1"); + manifest.SetStringKey(extensions::manifest_keys::kName, "Test"); + manifest.SetStringKey(extensions::manifest_keys::kVersion, "1"); manifest.SetInteger(extensions::manifest_keys::kManifestVersion, 2); - manifest.SetString(extensions::manifest_keys::kDescription, "Test app"); - manifest.SetString("author.email", "Someone"); + manifest.SetStringKey(extensions::manifest_keys::kDescription, "Test app"); + manifest.SetStringPath("author.email", "Someone"); std::string error; correct_extension_ = extensions::Extension::Create( base::FilePath(), extensions::mojom::ManifestLocation::kUnpacked, manifest, extensions::Extension::NO_FLAGS, kTestAppName, &error); base::DictionaryValue manifest2; - manifest2.SetString(extensions::manifest_keys::kName, "Test"); - manifest2.SetString(extensions::manifest_keys::kVersion, "1"); - manifest2.SetString(extensions::manifest_keys::kDescription, "Test app"); + manifest2.SetStringKey(extensions::manifest_keys::kName, "Test"); + manifest2.SetStringKey(extensions::manifest_keys::kVersion, "1"); + manifest2.SetStringKey(extensions::manifest_keys::kDescription, "Test app"); incorrect_extension_ = extensions::Extension::Create( base::FilePath(), extensions::mojom::ManifestLocation::kUnpacked,
diff --git a/chrome/browser/ash/policy/core/device_local_account_browsertest.cc b/chrome/browser/ash/policy/core/device_local_account_browsertest.cc index 6f010dc..184f8d3 100644 --- a/chrome/browser/ash/policy/core/device_local_account_browsertest.cc +++ b/chrome/browser/ash/policy/core/device_local_account_browsertest.cc
@@ -53,8 +53,8 @@ #include "chrome/browser/ash/login/session/user_session_manager.h" #include "chrome/browser/ash/login/session/user_session_manager_test_api.h" #include "chrome/browser/ash/login/signin_specifics.h" +#include "chrome/browser/ash/login/test/embedded_policy_test_server_mixin.h" #include "chrome/browser/ash/login/test/js_checker.h" -#include "chrome/browser/ash/login/test/local_policy_test_server_mixin.h" #include "chrome/browser/ash/login/test/login_or_lock_screen_visible_waiter.h" #include "chrome/browser/ash/login/test/oobe_base_test.h" #include "chrome/browser/ash/login/test/oobe_screen_waiter.h" @@ -502,9 +502,9 @@ void UploadDeviceLocalAccountPolicy() { BuildDeviceLocalAccountPolicy(); - ASSERT_TRUE(local_policy_mixin_.server()->UpdatePolicy( + policy_test_server_mixin_.UpdatePolicy( dm_protocol::kChromePublicAccountPolicyType, kAccountId1, - device_local_account_policy_.payload().SerializeAsString())); + device_local_account_policy_.payload().SerializeAsString()); } void UploadAndInstallDeviceLocalAccountPolicy() { @@ -545,7 +545,7 @@ em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); DeviceLocalAccountTestHelper::AddPublicSession(&proto, username); RefreshDevicePolicy(); - ASSERT_TRUE(local_policy_mixin_.UpdateDevicePolicy(proto)); + policy_test_server_mixin_.UpdateDevicePolicy(proto); } void SetManagedSessionsEnabled(bool managed_sessions_enabled) { @@ -562,7 +562,7 @@ device_local_accounts->set_auto_login_id(kAccountId1); device_local_accounts->set_auto_login_delay(0); RefreshDevicePolicy(); - ASSERT_TRUE(local_policy_mixin_.UpdateDevicePolicy(proto)); + policy_test_server_mixin_.UpdateDevicePolicy(proto); } void CheckPublicSessionPresent(const AccountId& account_id) { @@ -583,7 +583,7 @@ LocalStateValueWaiter(prefs::kSystemTimezoneAutomaticDetectionPolicy, base::Value(policy)) .Wait(); - ASSERT_TRUE(local_policy_mixin_.UpdateDevicePolicy(proto)); + policy_test_server_mixin_.UpdateDevicePolicy(proto); } base::FilePath GetExtensionCacheDirectoryForAccountID( @@ -739,7 +739,7 @@ std::unique_ptr<base::RunLoop> local_state_changed_run_loop_; UserPolicyBuilder device_local_account_policy_; - ash::LocalPolicyTestServerMixin local_policy_mixin_{&mixin_host_}; + ash::EmbeddedPolicyTestServerMixin policy_test_server_mixin_{&mixin_host_}; content::WebContents* contents_; @@ -964,7 +964,7 @@ account1->set_type( em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_PUBLIC_SESSION); - local_policy_mixin_.UpdateDevicePolicy(policy); + policy_test_server_mixin_.UpdateDevicePolicy(policy); g_browser_process->policy_service()->RefreshPolicies(base::OnceClosure()); // Make sure the second device-local account disappears. @@ -2128,13 +2128,13 @@ // Note that the policy for the device-local account will be fetched before // the session is started, so the policy for the app must be installed before // the first device policy fetch. - ASSERT_TRUE(local_policy_mixin_.server()->UpdatePolicyData( + policy_test_server_mixin_.UpdateExternalPolicy( dm_protocol::kChromeExtensionPolicyType, kShowManagedStorageID, "{" " \"string\": {" " \"Value\": \"policy test value one\"" " }" - "}")); + "}"); // Install and refresh the device policy now. This will also fetch the initial // user policy for the device-local account now. @@ -2177,13 +2177,13 @@ *policy_service->GetPolicies(ns).GetValue("string")); // Now update the policy at the server. - ASSERT_TRUE(local_policy_mixin_.server()->UpdatePolicyData( + policy_test_server_mixin_.UpdateExternalPolicy( dm_protocol::kChromeExtensionPolicyType, kShowManagedStorageID, "{" " \"string\": {" " \"Value\": \"policy test value two\"" " }" - "}")); + "}"); // And issue a policy refresh. { @@ -2229,7 +2229,7 @@ proto.mutable_managed_guest_session_privacy_warnings(); managed_sessions_warnings->set_enabled(false); RefreshDevicePolicy(); - ASSERT_TRUE(local_policy_mixin_.UpdateDevicePolicy(proto)); + policy_test_server_mixin_.UpdateDevicePolicy(proto); } };
diff --git a/chrome/browser/ash/policy/enrollment/device_cloud_policy_initializer_unittest.cc b/chrome/browser/ash/policy/enrollment/device_cloud_policy_initializer_unittest.cc index 63a273f..a623c99b 100644 --- a/chrome/browser/ash/policy/enrollment/device_cloud_policy_initializer_unittest.cc +++ b/chrome/browser/ash/policy/enrollment/device_cloud_policy_initializer_unittest.cc
@@ -103,9 +103,9 @@ // Server-backed state: advertised enrollment. base::DictionaryValue state_dict; - state_dict.SetString(kDeviceStateMode, - kDeviceStateRestoreModeReEnrollmentRequested); - state_dict.SetString(kDeviceStateManagementDomain, "example.com"); + state_dict.SetStringKey(kDeviceStateMode, + kDeviceStateRestoreModeReEnrollmentRequested); + state_dict.SetStringKey(kDeviceStateManagementDomain, "example.com"); local_state_.Set(prefs::kServerBackedDeviceState, state_dict); config = device_cloud_policy_initializer_.GetPrescribedEnrollmentConfig(); EXPECT_EQ(EnrollmentConfig::MODE_SERVER_ADVERTISED, config.mode); @@ -134,8 +134,8 @@ EXPECT_EQ(GetParam().auth_mechanism, config.auth_mechanism); // Server-backed state: forced enrollment. - state_dict.SetString(kDeviceStateMode, - kDeviceStateRestoreModeReEnrollmentEnforced); + state_dict.SetStringKey(kDeviceStateMode, + kDeviceStateRestoreModeReEnrollmentEnforced); local_state_.Set(prefs::kServerBackedDeviceState, state_dict); config = device_cloud_policy_initializer_.GetPrescribedEnrollmentConfig(); EXPECT_EQ(EnrollmentConfig::MODE_SERVER_FORCED, config.mode);
diff --git a/chrome/browser/ash/policy/reporting/arc_app_install_event_logger_unittest.cc b/chrome/browser/ash/policy/reporting/arc_app_install_event_logger_unittest.cc index fb7219d..585079e 100644 --- a/chrome/browser/ash/policy/reporting/arc_app_install_event_logger_unittest.cc +++ b/chrome/browser/ash/policy/reporting/arc_app_install_event_logger_unittest.cc
@@ -407,24 +407,24 @@ // Test that REQUIRED, PREINSTALLED and FORCE_INSTALLED are markers to include // app to the tracking. BLOCKED and AVAILABLE are excluded. auto package1 = std::make_unique<base::DictionaryValue>(); - package1->SetString("installType", "REQUIRED"); - package1->SetString("packageName", kPackageName); + package1->SetStringKey("installType", "REQUIRED"); + package1->SetStringKey("packageName", kPackageName); list->Append(std::move(package1)); auto package2 = std::make_unique<base::DictionaryValue>(); - package2->SetString("installType", "PREINSTALLED"); - package2->SetString("packageName", kPackageName2); + package2->SetStringKey("installType", "PREINSTALLED"); + package2->SetStringKey("packageName", kPackageName2); list->Append(std::move(package2)); auto package3 = std::make_unique<base::DictionaryValue>(); - package3->SetString("installType", "FORCE_INSTALLED"); - package3->SetString("packageName", kPackageName3); + package3->SetStringKey("installType", "FORCE_INSTALLED"); + package3->SetStringKey("packageName", kPackageName3); list->Append(std::move(package3)); auto package4 = std::make_unique<base::DictionaryValue>(); - package4->SetString("installType", "BLOCKED"); - package4->SetString("packageName", kPackageName4); + package4->SetStringKey("installType", "BLOCKED"); + package4->SetStringKey("packageName", kPackageName4); list->Append(std::move(package4)); auto package5 = std::make_unique<base::DictionaryValue>(); - package5->SetString("installType", "AVAILABLE"); - package5->SetString("packageName", kPackageName5); + package5->SetStringKey("installType", "AVAILABLE"); + package5->SetStringKey("packageName", kPackageName5); list->Append(std::move(package5)); arc_policy.SetList("applications", std::move(list));
diff --git a/chrome/browser/ash/settings/device_settings_provider_unittest.cc b/chrome/browser/ash/settings/device_settings_provider_unittest.cc index 9d99304c..9458dab 100644 --- a/chrome/browser/ash/settings/device_settings_provider_unittest.cc +++ b/chrome/browser/ash/settings/device_settings_provider_unittest.cc
@@ -760,8 +760,8 @@ base::ListValue expected_accounts; std::unique_ptr<base::DictionaryValue> entry_dict( new base::DictionaryValue()); - entry_dict->SetString(kAccountsPrefDeviceLocalAccountsKeyId, - policy::PolicyBuilder::kFakeUsername); + entry_dict->SetStringKey(kAccountsPrefDeviceLocalAccountsKeyId, + policy::PolicyBuilder::kFakeUsername); entry_dict->SetInteger(kAccountsPrefDeviceLocalAccountsKeyType, policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION); expected_accounts.Append(std::move(entry_dict));
diff --git a/chrome/browser/ash/system/device_disabling_manager_unittest.cc b/chrome/browser/ash/system/device_disabling_manager_unittest.cc index 8410393..ee3c61a 100644 --- a/chrome/browser/ash/system/device_disabling_manager_unittest.cc +++ b/chrome/browser/ash/system/device_disabling_manager_unittest.cc
@@ -178,15 +178,15 @@ } void DeviceDisablingManagerOOBETest::SetDeviceDisabled(bool disabled) { - DictionaryPrefUpdateDeprecated dict(&local_state_, - prefs::kServerBackedDeviceState); + DictionaryPrefUpdate dict(&local_state_, prefs::kServerBackedDeviceState); if (disabled) { - dict->SetString(policy::kDeviceStateMode, policy::kDeviceStateModeDisabled); + dict->SetStringKey(policy::kDeviceStateMode, + policy::kDeviceStateModeDisabled); } else { dict->RemoveKey(policy::kDeviceStateMode); } - dict->SetString(policy::kDeviceStateManagementDomain, kEnrollmentDomain); - dict->SetString(policy::kDeviceStateDisabledMessage, kDisabledMessage1); + dict->SetStringKey(policy::kDeviceStateManagementDomain, kEnrollmentDomain); + dict->SetStringKey(policy::kDeviceStateDisabledMessage, kDisabledMessage1); } void DeviceDisablingManagerOOBETest::OnDeviceDisabledChecked(
diff --git a/chrome/browser/cart/cart_service.cc b/chrome/browser/cart/cart_service.cc index a354832..5d191ae 100644 --- a/chrome/browser/cart/cart_service.cc +++ b/chrome/browser/cart/cart_service.cc
@@ -946,8 +946,7 @@ VLOG(1) << "Empty rule based discounts, cache nothing"; return; } - DictionaryPrefUpdateDeprecated update(profile_->GetPrefs(), - prefs::kCartUsedDiscounts); + DictionaryPrefUpdate update(profile_->GetPrefs(), prefs::kCartUsedDiscounts); for (auto discount_info : proto.discount_info().rule_discount_info()) { update->SetBoolKey(discount_info.rule_id(), true); }
diff --git a/chrome/browser/cart/cart_service_unittest.cc b/chrome/browser/cart/cart_service_unittest.cc index 4571721..955b0eb 100644 --- a/chrome/browser/cart/cart_service_unittest.cc +++ b/chrome/browser/cart/cart_service_unittest.cc
@@ -1898,13 +1898,13 @@ profile_->GetPrefs()->SetBoolean(prefs::kCartDiscountEnabled, true); EXPECT_CALL(coupon_service_, MaybeFeatureStatusChanged(false)).Times(2); - ListPrefUpdateDeprecated(profile_->GetPrefs(), prefs::kNtpDisabledModules) + ListPrefUpdate(profile_->GetPrefs(), prefs::kNtpDisabledModules) ->Append(base::Value("chrome_cart")); - ListPrefUpdateDeprecated(profile_->GetPrefs(), prefs::kNtpDisabledModules) + ListPrefUpdate(profile_->GetPrefs(), prefs::kNtpDisabledModules) ->Append(base::Value("something_unrelated")); EXPECT_CALL(coupon_service_, MaybeFeatureStatusChanged(true)).Times(1); - ListPrefUpdateDeprecated(profile_->GetPrefs(), prefs::kNtpDisabledModules) + ListPrefUpdate(profile_->GetPrefs(), prefs::kNtpDisabledModules) ->EraseListValue(base::Value("chrome_cart")); }
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index 9d63ff3f..c7a8daa 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc
@@ -395,9 +395,9 @@ // Clear kProfilesLastActive since the user only wants to launch a specific // profile. Don't clear it if the user launched a web app, in order to not // break any subsequent multi-profile session restore. - ListPrefUpdateDeprecated update(g_browser_process->local_state(), - prefs::kProfilesLastActive); - base::ListValue* profile_list = update.Get(); + ListPrefUpdate update(g_browser_process->local_state(), + prefs::kProfilesLastActive); + base::Value* profile_list = update.Get(); profile_list->ClearList(); }
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index fdbdfb1..2e6c8c3 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc
@@ -4391,15 +4391,15 @@ auto* pref_service = profile->GetPrefs(); DCHECK(pref_service); - DictionaryPrefUpdateDeprecated pref_update( + DictionaryPrefUpdate pref_update( pref_service, prefs::kDevToolsBackgroundServicesExpirationDict); - base::DictionaryValue* exp_dict = pref_update.Get(); + base::Value* exp_dict = pref_update.Get(); // Convert |expiration_time| to minutes since that is the most granular // option that returns an int. base::Value does not accept int64. int expiration_time_minutes = expiration_time.ToDeltaSinceWindowsEpoch().InMinutes(); - exp_dict->SetInteger(base::NumberToString(service), expiration_time_minutes); + exp_dict->SetIntKey(base::NumberToString(service), expiration_time_minutes); } base::flat_map<int, base::Time>
diff --git a/chrome/browser/chrome_origin_trials_browsertest.cc b/chrome/browser/chrome_origin_trials_browsertest.cc index 4b130a6..32302aa 100644 --- a/chrome/browser/chrome_origin_trials_browsertest.cc +++ b/chrome/browser/chrome_origin_trials_browsertest.cc
@@ -57,23 +57,23 @@ } void AddDisabledFeaturesToPrefs(const std::vector<std::string>& features) { - base::ListValue disabled_feature_list; + base::Value disabled_feature_list(base::Value::Type::LIST); for (const std::string& feature : features) { disabled_feature_list.Append(feature); } - ListPrefUpdateDeprecated update( + ListPrefUpdate update( local_state(), embedder_support::prefs::kOriginTrialDisabledFeatures); - update->Swap(&disabled_feature_list); + *update = std::move(disabled_feature_list); } void AddDisabledTokensToPrefs(const std::vector<std::string>& tokens) { - base::ListValue disabled_token_list; + base::Value disabled_token_list(base::Value::Type::LIST); for (const std::string& token : tokens) { disabled_token_list.Append(token); } - ListPrefUpdateDeprecated update( - local_state(), embedder_support::prefs::kOriginTrialDisabledTokens); - update->Swap(&disabled_token_list); + ListPrefUpdate update(local_state(), + embedder_support::prefs::kOriginTrialDisabledTokens); + *update = std::move(disabled_token_list); } PrefService* local_state() { return g_browser_process->local_state(); }
diff --git a/chrome/browser/chromeos/extensions/echo_private_api.cc b/chrome/browser/chromeos/extensions/echo_private_api.cc index 4617be4..d2c2894 100644 --- a/chrome/browser/chromeos/extensions/echo_private_api.cc +++ b/chrome/browser/chromeos/extensions/echo_private_api.cc
@@ -100,8 +100,7 @@ params->offer_info.additional_properties.DeepCopyWithoutEmptyChildren(); PrefService* local_state = g_browser_process->local_state(); - DictionaryPrefUpdateDeprecated offer_update(local_state, - prefs::kEchoCheckedOffers); + DictionaryPrefUpdate offer_update(local_state, prefs::kEchoCheckedOffers); offer_update->SetKey("echo." + service_id, base::Value::FromUniquePtrValue(std::move(dict))); return RespondNow(NoArguments());
diff --git a/chrome/browser/chromeos/extensions/input_method_api.cc b/chrome/browser/chromeos/extensions/input_method_api.cc index 8151083..89ba5ce3 100644 --- a/chrome/browser/chromeos/extensions/input_method_api.cc +++ b/chrome/browser/chromeos/extensions/input_method_api.cc
@@ -393,7 +393,7 @@ const auto params = SetSettings::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params.get()); - DictionaryPrefUpdateDeprecated update( + DictionaryPrefUpdate update( Profile::FromBrowserContext(browser_context())->GetPrefs(), prefs::kLanguageInputMethodSpecificSettings); update->SetPath(params->engine_id, params->settings.ToValue()->Clone());
diff --git a/chrome/browser/commerce/subscriptions/android/java/src/org/chromium/chrome/browser/subscriptions/CommerceSubscriptionsServiceConfig.java b/chrome/browser/commerce/subscriptions/android/java/src/org/chromium/chrome/browser/subscriptions/CommerceSubscriptionsServiceConfig.java index 04da4850..1087bc85 100644 --- a/chrome/browser/commerce/subscriptions/android/java/src/org/chromium/chrome/browser/subscriptions/CommerceSubscriptionsServiceConfig.java +++ b/chrome/browser/commerce/subscriptions/android/java/src/org/chromium/chrome/browser/subscriptions/CommerceSubscriptionsServiceConfig.java
@@ -24,7 +24,8 @@ private static final String STALE_TAB_LOWER_BOUND_SECONDS_PARAM = "price_tracking_stale_tab_lower_bound_seconds"; - private static final String IMPLICIT_SUBSCRIPTIONS_ENABLED_PARAM = + @VisibleForTesting + public static final String IMPLICIT_SUBSCRIPTIONS_ENABLED_PARAM = "implicit_subscriptions_enabled"; private static final int DEFAULT_STALE_TAB_LOWER_BOUND_DAYS = 1;
diff --git a/chrome/browser/commerce/subscriptions/android/java/src/org/chromium/chrome/browser/subscriptions/SubscriptionsManagerImpl.java b/chrome/browser/commerce/subscriptions/android/java/src/org/chromium/chrome/browser/subscriptions/SubscriptionsManagerImpl.java index e3ee81f..84ba336 100644 --- a/chrome/browser/commerce/subscriptions/android/java/src/org/chromium/chrome/browser/subscriptions/SubscriptionsManagerImpl.java +++ b/chrome/browser/commerce/subscriptions/android/java/src/org/chromium/chrome/browser/subscriptions/SubscriptionsManagerImpl.java
@@ -4,11 +4,14 @@ package org.chromium.chrome.browser.subscriptions; +import android.os.Build; + import androidx.annotation.IntDef; import androidx.annotation.VisibleForTesting; import org.chromium.base.Callback; import org.chromium.base.ObserverList; +import org.chromium.chrome.browser.price_tracking.PriceDropNotificationManager; import org.chromium.chrome.browser.profiles.Profile; import java.lang.annotation.Retention; @@ -137,6 +140,16 @@ return; } + // Make sure the notification channel is initialized if there is a user-managed PRICE_TRACK + // subscription. For chrome-managed subscriptions, channel will be initialized via message + // card in tab switcher. + if (CommerceSubscription.CommerceSubscriptionType.PRICE_TRACK.equals(type) + && CommerceSubscription.SubscriptionManagementType.USER_MANAGED.equals( + subscriptions.get(0).getManagementType()) + && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + (new PriceDropNotificationManager()).createNotificationChannel(); + } + if (!mCanHandleRequests) { mDeferredTasks.add(new DeferredSubscriptionOperation( Operation.SUBSCRIBE, subscriptions, wrappedCallback));
diff --git a/chrome/browser/component_updater/metadata_table_chromeos.cc b/chrome/browser/component_updater/metadata_table_chromeos.cc index 25855ba..46cbb9d 100644 --- a/chrome/browser/component_updater/metadata_table_chromeos.cc +++ b/chrome/browser/component_updater/metadata_table_chromeos.cc
@@ -171,7 +171,7 @@ DCHECK(pref_service_); DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - DictionaryPrefUpdateDeprecated update(pref_service_, kMetadataPrefPath); + DictionaryPrefUpdate update(pref_service_, kMetadataPrefPath); update->SetKey(kMetadataContentKey, installed_items_.Clone()); }
diff --git a/chrome/browser/enterprise/browser_management/browser_management_status_provider.cc b/chrome/browser/enterprise/browser_management/browser_management_status_provider.cc index a3ebeb0..eddff62 100644 --- a/chrome/browser/enterprise/browser_management/browser_management_status_provider.cc +++ b/chrome/browser/enterprise/browser_management/browser_management_status_provider.cc
@@ -12,7 +12,7 @@ #include "chrome/browser/profiles/profile.h" #include "components/enterprise/browser/controller/browser_dm_token_storage.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "components/policy/core/common/management/platform_management_status_provider_win.h" #elif BUILDFLAG(IS_CHROMEOS_ASH) #include "chrome/browser/ash/profiles/profile_helper.h" @@ -66,10 +66,10 @@ if (g_browser_process->browser_policy_connector() ->HasMachineLevelPolicies()) { result = EnterpriseManagementAuthority::COMPUTER_LOCAL; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) if (policy::DomainEnrollmentStatusProvider::IsEnrolledToDomain()) result = EnterpriseManagementAuthority::DOMAIN_LOCAL; -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) } return result; #endif // BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chrome/browser/enterprise/connectors/analysis/content_analysis_delegate_unittest.cc b/chrome/browser/enterprise/connectors/analysis/content_analysis_delegate_unittest.cc index c5944540..72542b2 100644 --- a/chrome/browser/enterprise/connectors/analysis/content_analysis_delegate_unittest.cc +++ b/chrome/browser/enterprise/connectors/analysis/content_analysis_delegate_unittest.cc
@@ -986,7 +986,7 @@ } // Flaky on Mac: https://crbug.com/1143782: -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_FileIsEncrypted_PolicyAllows DISABLED_FileIsEncrypted_PolicyAllows #else #define MAYBE_FileIsEncrypted_PolicyAllows FileIsEncrypted_PolicyAllows
diff --git a/chrome/browser/enterprise/connectors/analysis/content_analysis_dialog_browsertest.cc b/chrome/browser/enterprise/connectors/analysis/content_analysis_dialog_browsertest.cc index 68bd0389..9467548b 100644 --- a/chrome/browser/enterprise/connectors/analysis/content_analysis_dialog_browsertest.cc +++ b/chrome/browser/enterprise/connectors/analysis/content_analysis_dialog_browsertest.cc
@@ -176,7 +176,7 @@ EXPECT_FALSE(dialog_updated_); // TODO(crbug/1131565): Re-enable this for Mac. -#if !defined(OS_MAC) +#if !BUILDFLAG(IS_MAC) // The dialog being updated implies an accessibility alert is sent. EXPECT_EQ(ax_events_count_when_first_shown_ + 1, ax_event_counter_.GetCount(ax::mojom::Event::kAlert));
diff --git a/chrome/browser/enterprise/connectors/connectors_service.cc b/chrome/browser/enterprise/connectors/connectors_service.cc index 140ecbf..37931ef 100644 --- a/chrome/browser/enterprise/connectors/connectors_service.cc +++ b/chrome/browser/enterprise/connectors/connectors_service.cc
@@ -10,6 +10,7 @@ #include "base/no_destructor.h" #include "base/path_service.h" #include "base/strings/utf_string_conversions.h" +#include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/enterprise/connectors/common.h" @@ -486,7 +487,7 @@ absl::optional<ConnectorsService::DmToken> ConnectorsService::GetDmToken( const char* scope_pref) const { -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) // On CrOS the settings from primary profile applies to all profiles. return GetBrowserDmToken(); #else @@ -507,7 +508,7 @@ return DmToken(dm_token.value(), policy::POLICY_SCOPE_MACHINE); } -#if !defined(OS_CHROMEOS) +#if !BUILDFLAG(IS_CHROMEOS) absl::optional<ConnectorsService::DmToken> ConnectorsService::GetProfileDmToken() const { if (!CanUseProfileDmToken()) @@ -534,7 +535,7 @@ return chrome::enterprise_util::IsProfileAffiliated(profile); } -#endif // !defined(OS_CHROMEOS) +#endif // !BUILDFLAG(IS_CHROMEOS) policy::PolicyScope ConnectorsService::GetPolicyScope( const char* scope_pref) const {
diff --git a/chrome/browser/enterprise/connectors/connectors_service.h b/chrome/browser/enterprise/connectors/connectors_service.h index 2d6b91c..eb4360f0 100644 --- a/chrome/browser/enterprise/connectors/connectors_service.h +++ b/chrome/browser/enterprise/connectors/connectors_service.h
@@ -9,6 +9,7 @@ #include "base/feature_list.h" #include "base/memory/raw_ptr.h" +#include "build/build_config.h" #include "chrome/browser/enterprise/connectors/connectors_manager.h" #include "components/enterprise/common/proto/connectors.pb.h" #include "components/keyed_service/content/browser_context_keyed_service_factory.h" @@ -112,7 +113,7 @@ // contain either POLICY_SCOPE_MACHINE or POLICY_SCOPE_USER. absl::optional<DmToken> GetDmToken(const char* scope_pref) const; absl::optional<DmToken> GetBrowserDmToken() const; -#if !defined(OS_CHROMEOS) +#if !BUILDFLAG(IS_CHROMEOS) absl::optional<DmToken> GetProfileDmToken() const; // Returns true if the browser isn't managed by CBCM, otherwise this checks if
diff --git a/chrome/browser/enterprise/connectors/connectors_service_browsertest.cc b/chrome/browser/enterprise/connectors/connectors_service_browsertest.cc index 3906e02..3c7620b6 100644 --- a/chrome/browser/enterprise/connectors/connectors_service_browsertest.cc +++ b/chrome/browser/enterprise/connectors/connectors_service_browsertest.cc
@@ -8,6 +8,7 @@ #include "base/json/json_reader.h" #include "base/path_service.h" +#include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/enterprise/connectors/common.h" @@ -65,7 +66,7 @@ constexpr char kAffiliationId2[] = "affiliation-id-2"; #endif -#if !defined(OS_CHROMEOS) +#if !BUILDFLAG(IS_CHROMEOS) constexpr char kFakeEnrollmentToken[] = "fake-enrollment-token"; constexpr char kUsername1[] = "user@domain1.com"; constexpr char kUsername2[] = "admin@domain2.com"; @@ -111,7 +112,7 @@ ManagementStatus management_status) : management_status_(management_status) { if (management_status_ != ManagementStatus::UNMANAGED) { -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) policy::SetDMTokenForTesting( policy::DMToken::CreateValidTokenForTesting(kFakeBrowserDMToken)); #else @@ -285,7 +286,7 @@ auto settings = ConnectorsServiceFactory::GetForBrowserContext(browser()->profile()) ->GetReportingSettings(connector()); -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) if (management_status() == ManagementStatus::UNMANAGED) { ASSERT_FALSE(settings.has_value()); } else { @@ -351,7 +352,7 @@ void ValidateClientMetadata(const ClientMetadata& metadata, bool profile_reporting) { -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) bool includes_device_info = management_status() == ManagementStatus::AFFILIATED; #else @@ -393,7 +394,7 @@ ASSERT_EQ(metadata.device().dm_token(), *reporting_metadata.FindStringPath("device.dmToken")); -#if !defined(OS_CHROMEOS) +#if !BUILDFLAG(IS_CHROMEOS) ASSERT_TRUE(metadata.device().has_client_id()); ASSERT_EQ(metadata.device().client_id(), *reporting_metadata.FindStringPath("device.clientId")); @@ -469,7 +470,7 @@ /*profile_reporting*/ false); } -#if !defined(OS_CHROMEOS) +#if !BUILDFLAG(IS_CHROMEOS) ASSERT_EQ((management_status() == ManagementStatus::UNAFFILIATED) ? kDomain2 : kDomain1, ConnectorsServiceFactory::GetForBrowserContext(browser()->profile()) @@ -488,7 +489,7 @@ ConnectorsServiceFactory::GetForBrowserContext(browser()->profile()) ->GetAnalysisSettings(GURL(kTestUrl), connector()); -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) if (management_status() == ManagementStatus::UNMANAGED) { ASSERT_FALSE(settings.has_value()); } else { @@ -536,7 +537,7 @@ ConnectorsServiceFactory::GetForBrowserContext(browser()->profile()) ->GetAnalysisSettings(GURL(kTestUrl), connector()); -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) if (management_status() == ManagementStatus::UNMANAGED) { ASSERT_FALSE(settings.has_value()); } else { @@ -597,7 +598,7 @@ ConnectorsServiceFactory::GetForBrowserContext(browser()->profile()) ->GetAppliedRealTimeUrlCheck(); -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) if (management_status() == ManagementStatus::UNMANAGED) { ASSERT_FALSE(maybe_dm_token.has_value()); ASSERT_EQ(safe_browsing::REAL_TIME_CHECK_DISABLED, url_check_pref);
diff --git a/chrome/browser/enterprise/connectors/device_trust/device_trust_connector_service_factory.cc b/chrome/browser/enterprise/connectors/device_trust/device_trust_connector_service_factory.cc index 89eeb9f..46e16152 100644 --- a/chrome/browser/enterprise/connectors/device_trust/device_trust_connector_service_factory.cc +++ b/chrome/browser/enterprise/connectors/device_trust/device_trust_connector_service_factory.cc
@@ -12,13 +12,13 @@ #include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/core/keyed_service.h" -#if defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) #include "chrome/browser/browser_process.h" #include "chrome/browser/enterprise/connectors/device_trust/browser/browser_device_trust_connector_service.h" #include "chrome/browser/policy/chrome_browser_policy_connector.h" #include "components/enterprise/browser/controller/chrome_browser_cloud_management_controller.h" #include "components/enterprise/browser/device_trust/device_trust_key_manager.h" -#endif // defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) namespace enterprise_connectors { @@ -37,11 +37,11 @@ bool DeviceTrustConnectorServiceFactory::ServiceIsCreatedWithBrowserContext() const { -#if defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) return IsDeviceTrustConnectorFeatureEnabled(); #else return false; -#endif // defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) } DeviceTrustConnectorServiceFactory::DeviceTrustConnectorServiceFactory() @@ -58,7 +58,7 @@ DeviceTrustConnectorService* service = nullptr; -#if defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) if (IsDeviceTrustConnectorFeatureEnabled()) { auto* key_manager = g_browser_process->browser_policy_connector() ->chrome_browser_cloud_management_controller() @@ -68,7 +68,7 @@ } #else service = new DeviceTrustConnectorService(profile->GetPrefs()); -#endif // defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) if (service) service->Initialize();
diff --git a/chrome/browser/enterprise/connectors/device_trust/device_trust_service_factory.cc b/chrome/browser/enterprise/connectors/device_trust/device_trust_service_factory.cc index 2b78f90..47267fab 100644 --- a/chrome/browser/enterprise/connectors/device_trust/device_trust_service_factory.cc +++ b/chrome/browser/enterprise/connectors/device_trust/device_trust_service_factory.cc
@@ -21,13 +21,13 @@ #include "components/policy/content/policy_blocklist_service.h" #include "content/public/browser/browser_context.h" -#if defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) #include "chrome/browser/browser_process.h" #include "chrome/browser/enterprise/connectors/device_trust/attestation/desktop/desktop_attestation_service.h" #include "chrome/browser/policy/chrome_browser_policy_connector.h" #include "components/enterprise/browser/controller/chrome_browser_cloud_management_controller.h" #include "components/enterprise/browser/device_trust/device_trust_key_manager.h" -#endif // defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_CHROMEOS_ASH) #include "chrome/browser/enterprise/connectors/device_trust/attestation/ash/ash_attestation_service.h"
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/key_rotation_command_factory.cc b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/key_rotation_command_factory.cc index 15eca71..2d21e637 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/key_rotation_command_factory.cc +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/key_rotation_command_factory.cc
@@ -10,9 +10,9 @@ #include "chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/key_rotation_command.h" #include "third_party/abseil-cpp/absl/types/optional.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command.h" -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) namespace enterprise_connectors { @@ -37,11 +37,11 @@ } std::unique_ptr<KeyRotationCommand> KeyRotationCommandFactory::CreateCommand() { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return std::make_unique<WinKeyRotationCommand>(); #else return nullptr; -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) } // static
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/core/network/key_network_delegate_factory.cc b/chrome/browser/enterprise/connectors/device_trust/key_management/core/network/key_network_delegate_factory.cc index 640557da..6d61f44 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/core/network/key_network_delegate_factory.cc +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/core/network/key_network_delegate_factory.cc
@@ -8,19 +8,19 @@ #include "build/build_config.h" #include "chrome/browser/enterprise/connectors/device_trust/key_management/core/network/key_network_delegate.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "chrome/browser/enterprise/connectors/device_trust/key_management/core/network/win_key_network_delegate.h" #endif namespace enterprise_connectors { std::unique_ptr<KeyNetworkDelegate> CreateKeyNetworkDelegate() { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return std::make_unique<WinKeyNetworkDelegate>(); #else NOTREACHED(); return nullptr; -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) } } // namespace enterprise_connectors
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/core/persistence/key_persistence_delegate_factory.cc b/chrome/browser/enterprise/connectors/device_trust/key_management/core/persistence/key_persistence_delegate_factory.cc index 9883ca01..906a766d 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/core/persistence/key_persistence_delegate_factory.cc +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/core/persistence/key_persistence_delegate_factory.cc
@@ -9,11 +9,11 @@ #include "build/build_config.h" #include "chrome/browser/enterprise/connectors/device_trust/key_management/core/persistence/key_persistence_delegate.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "chrome/browser/enterprise/connectors/device_trust/key_management/core/persistence/win_key_persistence_delegate.h" -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) #include "chrome/browser/enterprise/connectors/device_trust/key_management/core/persistence/mac_key_persistence_delegate.h" -#elif defined(OS_LINUX) +#elif BUILDFLAG(IS_LINUX) #include "chrome/browser/enterprise/connectors/device_trust/key_management/core/persistence/linux_key_persistence_delegate.h" #endif @@ -40,11 +40,11 @@ std::unique_ptr<KeyPersistenceDelegate> KeyPersistenceDelegateFactory::CreateKeyPersistenceDelegate() { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return std::make_unique<WinKeyPersistenceDelegate>(); -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) return std::make_unique<MacKeyPersistenceDelegate>(); -#elif defined(OS_LINUX) +#elif BUILDFLAG(IS_LINUX) return std::make_unique<LinuxKeyPersistenceDelegate>(); #else NOTREACHED();
diff --git a/chrome/browser/enterprise/connectors/device_trust/signals/decorators/common/common_signals_decorator_unittest.cc b/chrome/browser/enterprise/connectors/device_trust/signals/decorators/common/common_signals_decorator_unittest.cc index 35267ca..ef4360c 100644 --- a/chrome/browser/enterprise/connectors/device_trust/signals/decorators/common/common_signals_decorator_unittest.cc +++ b/chrome/browser/enterprise/connectors/device_trust/signals/decorators/common/common_signals_decorator_unittest.cc
@@ -22,9 +22,9 @@ #include "chromeos/system/fake_statistics_provider.h" #endif // BUILDFLAG(IS_CHROMEOS_ASH) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "components/component_updater/pref_names.h" -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) namespace enterprise_connectors { @@ -44,14 +44,14 @@ safe_browsing::RegisterProfilePrefs(fake_profile_prefs_.registry()); fake_local_state_.registry()->RegisterBooleanPref( prefs::kBuiltInDnsClientEnabled, false); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) fake_local_state_.registry()->RegisterBooleanPref(prefs::kSwReporterEnabled, false); #if BUILDFLAG(GOOGLE_CHROME_BRANDING) fake_local_state_.registry()->RegisterBooleanPref( prefs::kThirdPartyBlockingEnabled, false); #endif // BUILDFLAG(GOOGLE_CHROME_BRANDING) -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) decorator_.emplace(&fake_local_state_, &fake_profile_prefs_); } @@ -87,16 +87,16 @@ EXPECT_TRUE(signals.has_safe_browsing_protection_level()); EXPECT_TRUE(signals.has_password_protection_warning_trigger()); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) EXPECT_TRUE(signals.has_chrome_cleanup_enabled()); #if BUILDFLAG(GOOGLE_CHROME_BRANDING) EXPECT_TRUE(signals.has_third_party_blocking_enabled()); #else // BUILDFLAG(GOOGLE_CHROME_BRANDING) EXPECT_FALSE(signals.has_third_party_blocking_enabled()); #endif // BUILDFLAG(GOOGLE_CHROME_BRANDING) -#else // defined(OS_WIN) +#else // BUILDFLAG(IS_WIN) EXPECT_FALSE(signals.has_chrome_cleanup_enabled()); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) histogram_tester_.ExpectTotalCount(kLatencyHistogram, 1); histogram_tester_.ExpectTotalCount(kCachedLatencyHistogram, 0);
diff --git a/chrome/browser/enterprise/connectors/device_trust/signals/signals_service_factory.cc b/chrome/browser/enterprise/connectors/device_trust/signals/signals_service_factory.cc index 10a16e2..973ceca3 100644 --- a/chrome/browser/enterprise/connectors/device_trust/signals/signals_service_factory.cc +++ b/chrome/browser/enterprise/connectors/device_trust/signals/signals_service_factory.cc
@@ -14,14 +14,14 @@ #include "chrome/browser/enterprise/connectors/device_trust/signals/signals_service_impl.h" #include "chrome/browser/profiles/profile.h" -#if defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) #include "base/check.h" #include "chrome/browser/enterprise/connectors/device_trust/signals/decorators/browser/browser_signals_decorator.h" #include "chrome/browser/policy/chrome_browser_policy_connector.h" #include "components/enterprise/browser/controller/browser_dm_token_storage.h" #include "components/policy/core/common/cloud/machine_level_user_cloud_policy_manager.h" #include "components/policy/core/common/cloud/machine_level_user_cloud_policy_store.h" -#endif // defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_CHROMEOS_ASH) #include "chrome/browser/browser_process_platform_part.h" @@ -44,7 +44,7 @@ decorators.push_back( std::make_unique<ContentSignalsDecorator>(policy_blocklist_service)); -#if defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) policy::ChromeBrowserPolicyConnector* browser_policy_connector = g_browser_process->browser_policy_connector(); DCHECK(browser_policy_connector); @@ -53,7 +53,7 @@ policy::BrowserDMTokenStorage::Get(), browser_policy_connector->machine_level_user_cloud_policy_manager() ->store())); -#endif // defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_CHROMEOS_ASH) decorators.push_back(std::make_unique<AshSignalsDecorator>(
diff --git a/chrome/browser/enterprise/connectors/file_system/box_captured_sites_interactive_uitest.cc b/chrome/browser/enterprise/connectors/file_system/box_captured_sites_interactive_uitest.cc index b47f6a6..91e838f 100644 --- a/chrome/browser/enterprise/connectors/file_system/box_captured_sites_interactive_uitest.cc +++ b/chrome/browser/enterprise/connectors/file_system/box_captured_sites_interactive_uitest.cc
@@ -77,7 +77,7 @@ } std::string FilePathToUTF8(const base::FilePath::StringType& str) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return base::WideToUTF8(str); #else return str; @@ -194,7 +194,7 @@ } bool StartWebPageRecordServer(const base::FilePath& capture_file_path) { -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) base::FilePath script_dir; if (!GetWPRSupportScriptDir(&script_dir)) { ADD_FAILURE() << "Failed to extract the WPR support script directory!"; @@ -293,17 +293,17 @@ .AppendASCII("telemetry") .AppendASCII("bin"); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) base::FilePath wpr_executable_binary = base::FilePath(FILE_PATH_LITERAL("win")) .AppendASCII("AMD64") .AppendASCII("wpr.exe"); -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) base::FilePath wpr_executable_binary = base::FilePath(FILE_PATH_LITERAL("mac")) .AppendASCII("x86_64") .AppendASCII("wpr"); -#elif defined(OS_POSIX) +#elif BUILDFLAG(IS_POSIX) base::FilePath wpr_executable_binary = base::FilePath(FILE_PATH_LITERAL("linux")) .AppendASCII("x86_64") @@ -451,7 +451,7 @@ // Disable GPU acceleration on Linux to avoid the GPU process // crashing, and inadvertently block page load. -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) command_line->AppendSwitch(switches::kDisableGpu); command_line->AppendSwitch(switches::kDisableSoftwareRasterizer); #endif
diff --git a/chrome/browser/enterprise/remote_commands/cbcm_remote_commands_factory.cc b/chrome/browser/enterprise/remote_commands/cbcm_remote_commands_factory.cc index 496d5c05..9e61839 100644 --- a/chrome/browser/enterprise/remote_commands/cbcm_remote_commands_factory.cc +++ b/chrome/browser/enterprise/remote_commands/cbcm_remote_commands_factory.cc
@@ -11,13 +11,13 @@ #include "chrome/browser/profiles/profile_manager.h" #include "components/policy/core/common/remote_commands/remote_command_job.h" -#if defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) #include "chrome/browser/enterprise/connectors/device_trust/device_trust_features.h" #include "chrome/browser/enterprise/remote_commands/rotate_attestation_credential_job.h" #include "chrome/browser/policy/chrome_browser_policy_connector.h" #include "components/enterprise/browser/controller/chrome_browser_cloud_management_controller.h" #include "components/enterprise/browser/device_trust/device_trust_key_manager.h" -#endif // defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) namespace enterprise_commands { @@ -31,7 +31,7 @@ g_browser_process->profile_manager()); } -#if defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) if (enterprise_connectors::IsDeviceTrustConnectorFeatureEnabled() && type == enterprise_management:: RemoteCommand_Type_BROWSER_ROTATE_ATTESTATION_CREDENTIAL) { @@ -40,7 +40,7 @@ ->chrome_browser_cloud_management_controller() ->GetDeviceTrustKeyManager()); } -#endif // defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) NOTREACHED() << "Received an unsupported remote command type: " << type; return nullptr;
diff --git a/chrome/browser/enterprise/remote_commands/clear_browsing_data_job.cc b/chrome/browser/enterprise/remote_commands/clear_browsing_data_job.cc index 9a7488f..49839f4 100644 --- a/chrome/browser/enterprise/remote_commands/clear_browsing_data_job.cc +++ b/chrome/browser/enterprise/remote_commands/clear_browsing_data_job.cc
@@ -78,7 +78,7 @@ // path from UTF8, and ending up with an invalid path will fail later in // RunImpl when we attempt to get the profile from the path. profile_path_ = base::FilePath::FromUTF8Unsafe(*path); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // For Windows machines, the path that Chrome reports for the profile is // "Normalized" to all lower-case on the reporting server. This means that // when the server sends the command, the path will be all lower case and
diff --git a/chrome/browser/enterprise/remote_commands/clear_browsing_data_job_unittest.cc b/chrome/browser/enterprise/remote_commands/clear_browsing_data_job_unittest.cc index 371ec8d..8860d2f 100644 --- a/chrome/browser/enterprise/remote_commands/clear_browsing_data_job_unittest.cc +++ b/chrome/browser/enterprise/remote_commands/clear_browsing_data_job_unittest.cc
@@ -307,7 +307,7 @@ bool done = false; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // On windows, paths are case-insensitive so passing a lowercase path should // still result in success. auto expected = policy::RemoteCommandJob::SUCCEEDED;
diff --git a/chrome/browser/enterprise/reporting/browser_report_generator_unittest.cc b/chrome/browser/enterprise/reporting/browser_report_generator_unittest.cc index 399e9884..5d10a2a 100644 --- a/chrome/browser/enterprise/reporting/browser_report_generator_unittest.cc +++ b/chrome/browser/enterprise/reporting/browser_report_generator_unittest.cc
@@ -28,9 +28,9 @@ #include "device_management_backend.pb.h" #include "testing/gtest/include/gtest/gtest.h" -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) #include "chrome/browser/upgrade_detector/build_state.h" -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) #if BUILDFLAG(IS_CHROMEOS_ASH) #include "chrome/common/chrome_constants.h" @@ -38,17 +38,17 @@ #if BUILDFLAG(GOOGLE_CHROME_BRANDING) && !BUILDFLAG(IS_CHROMEOS_ASH) #include "chrome/test/base/scoped_channel_override.h" -#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING) && !defined(OS_CHROMEOS) +#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING) && !BUILDFLAG(IS_CHROMEOS) #if BUILDFLAG(ENABLE_PLUGINS) #include "content/public/browser/plugin_service.h" #endif // BUILDFLAG(ENABLE_PLUGINS) -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "chrome/browser/enterprise/reporting/reporting_delegate_factory_android.h" #else #include "chrome/browser/enterprise/reporting/reporting_delegate_factory_desktop.h" -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) namespace em = enterprise_management; @@ -86,7 +86,7 @@ } void VerifyBuildState(em::BrowserReport* report) { -#if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) const auto* build_state = g_browser_process->GetBuildState(); if (build_state->update_type() == BuildState::UpdateType::kNone || !build_state->installed_version()) { @@ -95,7 +95,7 @@ EXPECT_EQ(report->installed_browser_version(), build_state->installed_version()->GetString()); } -#endif // !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) +#endif // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) } void VerifyExtendedStableChannel(em::BrowserReport* report) { @@ -107,7 +107,7 @@ } else { EXPECT_FALSE(report->has_is_extended_stable_channel()); // On Android, local Chrome branded builds report "CHANNEL_UNKNOWN". -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) EXPECT_NE(report->channel(), em::Channel::CHANNEL_UNKNOWN); #endif } @@ -126,7 +126,7 @@ } void VerifyPlugins(em::BrowserReport* report) { -#if BUILDFLAG(ENABLE_PLUGINS) && !defined(OS_ANDROID) && \ +#if BUILDFLAG(ENABLE_PLUGINS) && !BUILDFLAG(IS_ANDROID) && \ !BUILDFLAG(IS_CHROMEOS_ASH) EXPECT_LE(1, report->plugins_size()); em::Plugin plugin = report->plugins(0); @@ -136,17 +136,17 @@ EXPECT_EQ(kPluginDescription, plugin.description()); #else EXPECT_EQ(0, report->plugins_size()); -#endif // BUILDFLAG(ENABLE_PLUGINS) && !defined(OS_ANDROID) && +#endif // BUILDFLAG(ENABLE_PLUGINS) && !BUILDFLAG(IS_ANDROID) && // !BUILDFLAG(IS_CHROMEOS_ASH) } } // namespace -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) typedef ReportingDelegateFactoryAndroid PlatformReportingDelegateFactory; #else typedef ReportingDelegateFactoryDesktop PlatformReportingDelegateFactory; -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) class BrowserReportGeneratorTest : public ::testing::Test { public: @@ -203,13 +203,13 @@ #endif // BUILDFLAG(ENABLE_PLUGINS) } -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) void InitializeUpdate() { auto* build_state = g_browser_process->GetBuildState(); build_state->SetUpdate(BuildState::UpdateType::kNormalUpdate, base::Version("1.2.3.4"), absl::nullopt); } -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) void GenerateAndVerify() { base::RunLoop run_loop; @@ -285,7 +285,7 @@ GenerateProfileReportAndVerify(); } -#if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) TEST_F(BrowserReportGeneratorTest, GenerateBasicReportWithUpdate) { InitializeUpdate(); InitializeProfile(); @@ -293,9 +293,9 @@ InitializePlugin(); GenerateAndVerify(); } -#endif // !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) +#endif // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) -#if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) && \ +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) && \ BUILDFLAG(GOOGLE_CHROME_BRANDING) TEST_F(BrowserReportGeneratorTest, ExtendedStableChannel) { chrome::ScopedChannelOverride channel_override( @@ -307,7 +307,7 @@ InitializePlugin(); GenerateAndVerify(); } -#endif // !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) && +#endif // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) && // BUILDFLAG(GOOGLE_CHROME_BRANDING) } // namespace enterprise_reporting
diff --git a/chrome/browser/enterprise/reporting/extension_request/extension_request_policy_handler.cc b/chrome/browser/enterprise/reporting/extension_request/extension_request_policy_handler.cc index c8dcf37..ab03f5c 100644 --- a/chrome/browser/enterprise/reporting/extension_request/extension_request_policy_handler.cc +++ b/chrome/browser/enterprise/reporting/extension_request/extension_request_policy_handler.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/enterprise/reporting/extension_request/extension_request_policy_handler.h" #include "base/values.h" +#include "build/build_config.h" #include "chrome/common/pref_names.h" #include "components/policy/core/browser/policy_error_map.h" #include "components/policy/core/common/policy_map.h" @@ -46,7 +47,7 @@ return false; } -#if !defined(OS_CHROMEOS) +#if !BUILDFLAG(IS_CHROMEOS) // Disable extension workflow when it's set by user cloud policy but machine // is not managed or managed by a different domain. if (extension_request_policy->scope == policy::POLICY_SCOPE_USER &&
diff --git a/chrome/browser/enterprise/reporting/policy_info_unittest.cc b/chrome/browser/enterprise/reporting/policy_info_unittest.cc index 74594a8..fb5eec7 100644 --- a/chrome/browser/enterprise/reporting/policy_info_unittest.cc +++ b/chrome/browser/enterprise/reporting/policy_info_unittest.cc
@@ -23,11 +23,11 @@ #include "content/public/test/browser_task_environment.h" #include "testing/gtest/include/gtest/gtest.h" -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) #include "extensions/browser/extension_registry.h" #include "extensions/common/extension_builder.h" #include "extensions/common/manifest_constants.h" -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) namespace em = enterprise_management; @@ -134,7 +134,7 @@ EXPECT_NE("", policy2.error()); } -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) TEST_F(PolicyInfoTest, ExtensionPolicy) { EXPECT_CALL(*policy_service(), GetPolicies(_)).Times(3); extensions::ExtensionRegistry* extension_registry = @@ -177,7 +177,7 @@ EXPECT_EQ(em::Policy_PolicySource_SOURCE_PLATFORM, policy1.source()); EXPECT_NE(std::string(), policy1.error()); } -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) TEST_F(PolicyInfoTest, MachineLevelUserCloudPolicyFetchTimestamp) { em::ChromeUserProfileInfo profile_info;
diff --git a/chrome/browser/enterprise/reporting/prefs.cc b/chrome/browser/enterprise/reporting/prefs.cc index 7caf84df..f26fe87 100644 --- a/chrome/browser/enterprise/reporting/prefs.cc +++ b/chrome/browser/enterprise/reporting/prefs.cc
@@ -30,11 +30,11 @@ } void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) registry->RegisterBooleanPref(prefs::kCloudExtensionRequestEnabled, false); registry->RegisterDictionaryPref(prefs::kCloudExtensionRequestIds); registry->RegisterDictionaryPref(kCloudExtensionRequestUploadedIds); -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) } } // namespace enterprise_reporting
diff --git a/chrome/browser/enterprise/reporting/profile_report_generator_unittest.cc b/chrome/browser/enterprise/reporting/profile_report_generator_unittest.cc index 7c913f0..bd0adb6 100644 --- a/chrome/browser/enterprise/reporting/profile_report_generator_unittest.cc +++ b/chrome/browser/enterprise/reporting/profile_report_generator_unittest.cc
@@ -31,11 +31,11 @@ #include "extensions/browser/pref_names.h" #include "testing/gtest/include/gtest/gtest.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "chrome/browser/enterprise/reporting/reporting_delegate_factory_android.h" #else #include "chrome/browser/enterprise/reporting/reporting_delegate_factory_desktop.h" -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) using ::testing::NiceMock; @@ -49,7 +49,7 @@ constexpr char kIdleProfile[] = "IdleProfile"; constexpr char16_t kIdleProfile16[] = u"IdleProfile"; -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) const int kMaxNumberOfExtensionRequest = 1000; constexpr char kExtensionId[] = "abcdefghijklmnopabcdefghijklmnop"; constexpr char kExtensionId2[] = "abcdefghijklmnopabcdefghijklmnpo"; @@ -67,15 +67,15 @@ "installation_mode": "blocked" } })"; -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) } // namespace -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) typedef ReportingDelegateFactoryAndroid PlatformReportingDelegateFactory; #else typedef ReportingDelegateFactoryDesktop PlatformReportingDelegateFactory; -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) class ProfileReportGeneratorTest : public ::testing::Test { public: @@ -136,7 +136,7 @@ return report; } -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) void SetExtensionToPendingList(const std::vector<std::string>& ids) { std::unique_ptr<base::Value> id_values = std::make_unique<base::Value>(base::Value::Type::DICTIONARY); @@ -164,7 +164,7 @@ extensions::pref_names::kExtensionManagement, base::Value::ToUniquePtrValue(std::move(*settings))); } -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) TestingProfile* profile() { return profile_; } TestingProfileManager* profile_manager() { return &profile_manager_; } @@ -238,7 +238,7 @@ EXPECT_NE(report->id(), report3->id()); } -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) TEST_F(ProfileReportGeneratorTest, PoliciesDisabled) { // Users' profile info is collected by default. std::unique_ptr<em::ChromeUserProfileInfo> report = GenerateReport(); @@ -346,6 +346,6 @@ report2->extension_requests(id).id()); } -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) } // namespace enterprise_reporting
diff --git a/chrome/browser/enterprise/reporting/report_generator_unittest.cc b/chrome/browser/enterprise/reporting/report_generator_unittest.cc index 7a002a8..ff36f520 100644 --- a/chrome/browser/enterprise/reporting/report_generator_unittest.cc +++ b/chrome/browser/enterprise/reporting/report_generator_unittest.cc
@@ -34,13 +34,13 @@ #include "chrome/browser/ui/app_list/arc/arc_app_test.h" #endif -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "chrome/browser/enterprise/reporting/reporting_delegate_factory_android.h" #else #include "chrome/browser/enterprise/reporting/reporting_delegate_factory_desktop.h" #include "extensions/browser/extension_registry.h" #include "extensions/common/extension_builder.h" -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) #if BUILDFLAG(ENABLE_PLUGINS) #include "content/public/browser/plugin_service.h" @@ -76,7 +76,7 @@ #if !BUILDFLAG(IS_CHROMEOS_ASH) // We only upload serial number on Windows. void VerifySerialNumber(const std::string& serial_number) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) EXPECT_NE(std::string(), serial_number); #else EXPECT_EQ(std::string(), serial_number); @@ -103,7 +103,7 @@ } void AddExtensionToProfile(TestingProfile* profile) { -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) extensions::ExtensionRegistry* extension_registry = extensions::ExtensionRegistry::Get(profile); @@ -113,7 +113,7 @@ extension_registry->AddEnabled(extensions::ExtensionBuilder(extension_name) .SetID("abcdefghijklmnoabcdefghijklmnoab") .Build()); -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) } #if BUILDFLAG(IS_CHROMEOS_ASH) @@ -307,11 +307,11 @@ .AsUTF8Unsafe(); } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) ReportingDelegateFactoryAndroid delegate_factory_; #else ReportingDelegateFactoryDesktop delegate_factory_; -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) ReportGenerator generator_; content::BrowserTaskEnvironment task_environment_; @@ -319,7 +319,7 @@ std::unique_ptr<base::HistogramTester> histogram_tester_; }; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) TEST_F(ReportGeneratorTest, GenerateBasicReport) { auto requests = GenerateRequests(ReportType::kFull); @@ -359,7 +359,7 @@ EXPECT_NE(std::string(), browser_report.executable_path()); } -#else // defined(OS_ANDROID) +#else // BUILDFLAG(IS_ANDROID) TEST_F(ReportGeneratorTest, GenerateBasicReport) { auto profile_names = CreateProfiles(/*number*/ 2, kIdle); @@ -474,7 +474,7 @@ profile_names, browser_report); } -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) #if BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chrome/browser/enterprise/reporting/report_request_queue_generator_unittest.cc b/chrome/browser/enterprise/reporting/report_request_queue_generator_unittest.cc index 801dd96..071bc62 100644 --- a/chrome/browser/enterprise/reporting/report_request_queue_generator_unittest.cc +++ b/chrome/browser/enterprise/reporting/report_request_queue_generator_unittest.cc
@@ -26,13 +26,13 @@ #include "content/public/test/browser_task_environment.h" #include "testing/gtest/include/gtest/gtest.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "chrome/browser/enterprise/reporting/reporting_delegate_factory_android.h" #else #include "chrome/browser/enterprise/reporting/reporting_delegate_factory_desktop.h" #include "extensions/browser/extension_registry.h" #include "extensions/common/extension_builder.h" -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) #if BUILDFLAG(ENABLE_PLUGINS) #include "content/public/browser/plugin_service.h" @@ -88,13 +88,13 @@ return std::set<std::string>{kActiveProfileName1, kActiveProfileName2}; } -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) std::set<std::string> CreateActiveProfilesWithContent() { CreateActiveProfileWithContent(kActiveProfileName1); CreateActiveProfileWithContent(kActiveProfileName2); return std::set<std::string>{kActiveProfileName1, kActiveProfileName2}; } -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) void CreateIdleProfile(const std::string& profile_name) { ProfileAttributesInitParams params; @@ -119,7 +119,7 @@ absl::nullopt, std::move(policy_service)); } -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) void CreateActiveProfileWithContent(const std::string& profile_name) { TestingProfile* active_profile = CreateActiveProfile(profile_name); @@ -133,7 +133,7 @@ .SetID("abcdefghijklmnoabcdefghijklmnoab") .Build()); } -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) std::unique_ptr<ReportRequest> GenerateBasicRequest() { auto request = std::make_unique<ReportRequest>(ReportType::kFull); @@ -227,7 +227,7 @@ content::BrowserTaskEnvironment task_environment_; TestingProfileManager profile_manager_; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) ReportingDelegateFactoryAndroid reporting_delegate_factory_; #else ReportingDelegateFactoryDesktop reporting_delegate_factory_; @@ -304,7 +304,7 @@ // Android has only one profile which is always `active` and no extensions. So // we only check a subset of desktop tests. -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) TEST_F(ReportRequestQueueGeneratorTest, GenerateReport) { auto idle_profile_names = CreateIdleProfiles(); @@ -393,6 +393,6 @@ /*report size floor to KB*/ 0, 2); } -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) } // namespace enterprise_reporting
diff --git a/chrome/browser/enterprise/reporting/report_scheduler_unittest.cc b/chrome/browser/enterprise/reporting/report_scheduler_unittest.cc index 96286739..1aacbf8 100644 --- a/chrome/browser/enterprise/reporting/report_scheduler_unittest.cc +++ b/chrome/browser/enterprise/reporting/report_scheduler_unittest.cc
@@ -37,12 +37,12 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "chrome/browser/enterprise/reporting/reporting_delegate_factory_android.h" #else #include "chrome/browser/enterprise/reporting/report_scheduler_desktop.h" #include "chrome/browser/enterprise/reporting/reporting_delegate_factory_desktop.h" -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) using ::base::test::RunOnceCallback; using ::testing::_; @@ -62,7 +62,7 @@ constexpr char kClientId[] = "client_id"; constexpr base::TimeDelta kDefaultUploadInterval = base::Hours(24); -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) constexpr char kUploadTriggerMetricName[] = "Enterprise.CloudReportingUploadTrigger"; #endif @@ -79,7 +79,7 @@ class MockReportGenerator : public ReportGenerator { public: -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) explicit MockReportGenerator( ReportingDelegateFactoryAndroid* delegate_factory) : ReportGenerator(delegate_factory) {} @@ -87,7 +87,7 @@ explicit MockReportGenerator( ReportingDelegateFactoryDesktop* delegate_factory) : ReportGenerator(delegate_factory) {} -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) void Generate(ReportType report_type, ReportCallback callback) override { OnGenerate(report_type, callback); } @@ -110,7 +110,7 @@ class MockRealTimeReportGenerator : public RealTimeReportGenerator { public: -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) explicit MockRealTimeReportGenerator( ReportingDelegateFactoryAndroid* delegate_factory) : RealTimeReportGenerator(delegate_factory) {} @@ -118,7 +118,7 @@ explicit MockRealTimeReportGenerator( ReportingDelegateFactoryDesktop* delegate_factory) : RealTimeReportGenerator(delegate_factory) {} -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) MOCK_METHOD2(Generate, std::vector<std::unique_ptr<google::protobuf::MessageLite>>( @@ -253,22 +253,22 @@ #endif } -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) void TriggerExtensionRequestReport(Profile* profile) { static_cast<ReportSchedulerDesktop*>(scheduler_->GetDelegateForTesting()) ->TriggerExtensionRequest(profile); } -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) content::BrowserTaskEnvironment task_environment_; ScopedTestingLocalState local_state_; TestingProfileManager profile_manager_; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) ReportingDelegateFactoryAndroid report_delegate_factory_; #else ReportingDelegateFactoryDesktop report_delegate_factory_; -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) std::unique_ptr<ReportScheduler> scheduler_; raw_ptr<policy::MockCloudPolicyClient> client_; raw_ptr<MockReportGenerator> generator_; @@ -490,7 +490,7 @@ } // Android does not support version updates nor extensions -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) #if !BUILDFLAG(IS_CHROMEOS_ASH) @@ -700,6 +700,6 @@ histogram_tester_.ExpectUniqueSample(kUploadTriggerMetricName, 5, 1); } -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) } // namespace enterprise_reporting
diff --git a/chrome/browser/enterprise/signals/context_info_fetcher.cc b/chrome/browser/enterprise/signals/context_info_fetcher.cc index 13a6e22..fb7a4f0 100644 --- a/chrome/browser/enterprise/signals/context_info_fetcher.cc +++ b/chrome/browser/enterprise/signals/context_info_fetcher.cc
@@ -27,16 +27,16 @@ #include "content/public/browser/site_isolation_policy.h" #include "device_management_backend.pb.h" -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) #include "net/dns/public/resolv_reader.h" #include "net/dns/public/scoped_res_state.h" #endif -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include <CoreFoundation/CoreFoundation.h> #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <netfw.h> #include <windows.h> #include <wrl/client.h> @@ -52,7 +52,7 @@ namespace { -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) const char** GetUfwConfigPath() { static const char* path = "/etc/ufw/ufw.conf"; return &path; @@ -81,9 +81,9 @@ else return SettingValue::UNKNOWN; } -#endif // defined(OS_LINUX) +#endif // BUILDFLAG(IS_LINUX) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) SettingValue GetWinOSFirewall() { Microsoft::WRL::ComPtr<INetFwPolicy2> firewall_policy; HRESULT hr = CoCreateInstance(CLSID_NetFwPolicy2, nullptr, CLSCTX_ALL, @@ -119,7 +119,7 @@ } #endif -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) SettingValue GetMacOSFirewall() { // There is no official Apple documentation on how to obtain the enabled // status of the firewall (System Preferences> Security & Privacy> Firewall). @@ -225,7 +225,7 @@ info.password_protection_warning_trigger = utils::GetPasswordProtectionWarningTrigger(profile->GetPrefs()); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) base::ThreadPool::CreateCOMSTATaskRunner({base::MayBlock()}) .get() ->PostTaskAndReplyWithResult( @@ -273,11 +273,11 @@ } SettingValue ContextInfoFetcher::GetOSFirewall() { -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) return GetUfwStatus(); -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) return GetWinOSFirewall(); -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) return GetMacOSFirewall(); #elif BUILDFLAG(IS_CHROMEOS_ASH) return GetChromeosFirewall(); @@ -286,7 +286,7 @@ #endif } -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) ScopedUfwConfigPathForTesting::ScopedUfwConfigPathForTesting(const char* path) : initial_path_(*GetUfwConfigPath()) { *GetUfwConfigPath() = path; @@ -295,11 +295,11 @@ ScopedUfwConfigPathForTesting::~ScopedUfwConfigPathForTesting() { *GetUfwConfigPath() = initial_path_; } -#endif // defined(OS_LINUX) +#endif // BUILDFLAG(IS_LINUX) std::vector<std::string> ContextInfoFetcher::GetDnsServers() { std::vector<std::string> dns_addresses; -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) std::unique_ptr<net::ScopedResState> res = net::ResolvReader().GetResState(); if (res) { absl::optional<std::vector<net::IPEndPoint>> nameservers = @@ -314,7 +314,7 @@ } } } -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) absl::optional<std::vector<net::IPEndPoint>> nameservers; absl::optional<net::WinDnsSystemSettings> settings = net::ReadWinSystemDnsSettings();
diff --git a/chrome/browser/enterprise/signals/context_info_fetcher.h b/chrome/browser/enterprise/signals/context_info_fetcher.h index 1dcd4d33..7b5e811 100644 --- a/chrome/browser/enterprise/signals/context_info_fetcher.h +++ b/chrome/browser/enterprise/signals/context_info_fetcher.h
@@ -105,7 +105,7 @@ raw_ptr<enterprise_connectors::ConnectorsService> connectors_service_; }; -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) class ScopedUfwConfigPathForTesting { public: explicit ScopedUfwConfigPathForTesting(const char* path); @@ -118,7 +118,7 @@ private: const char* initial_path_; }; -#endif // defined(OS_LINUX) +#endif // BUILDFLAG(IS_LINUX) } // namespace enterprise_signals
diff --git a/chrome/browser/enterprise/signals/device_info_fetcher.cc b/chrome/browser/enterprise/signals/device_info_fetcher.cc index cf9cac3..1225aec 100644 --- a/chrome/browser/enterprise/signals/device_info_fetcher.cc +++ b/chrome/browser/enterprise/signals/device_info_fetcher.cc
@@ -6,11 +6,11 @@ #include "build/build_config.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "chrome/browser/enterprise/signals/device_info_fetcher_mac.h" -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) #include "chrome/browser/enterprise/signals/device_info_fetcher_win.h" -#elif defined(OS_LINUX) || defined(OS_CHROMEOS) +#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #include "chrome/browser/enterprise/signals/device_info_fetcher_linux.h" #endif @@ -66,11 +66,11 @@ // TODO(pastarmovj): Instead of the if-defs implement the CreateInstance // function in the platform specific classes. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) return std::make_unique<DeviceInfoFetcherMac>(); -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) return std::make_unique<DeviceInfoFetcherWin>(); -#elif defined(OS_LINUX) || defined(OS_CHROMEOS) +#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) return std::make_unique<DeviceInfoFetcherLinux>(); #else return std::make_unique<StubDeviceFetcher>();
diff --git a/chrome/browser/enterprise/signals/signals_utils.cc b/chrome/browser/enterprise/signals/signals_utils.cc index b64402f..6129171 100644 --- a/chrome/browser/enterprise/signals/signals_utils.cc +++ b/chrome/browser/enterprise/signals/signals_utils.cc
@@ -12,9 +12,9 @@ #include "components/prefs/pref_service.h" #include "components/safe_browsing/core/common/safe_browsing_prefs.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "components/component_updater/pref_names.h" -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) namespace enterprise_signals { namespace utils { @@ -53,7 +53,7 @@ absl::optional<bool> GetThirdPartyBlockingEnabled(PrefService* local_state) { DCHECK(local_state); -#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) +#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) return local_state->GetBoolean(prefs::kThirdPartyBlockingEnabled); #else return absl::nullopt; @@ -76,7 +76,7 @@ absl::optional<bool> GetChromeCleanupEnabled(PrefService* local_state) { DCHECK(local_state); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return local_state->GetBoolean(prefs::kSwReporterEnabled); #else return absl::nullopt;
diff --git a/chrome/browser/enterprise/util/managed_browser_utils.cc b/chrome/browser/enterprise/util/managed_browser_utils.cc index 5364746..43cd868 100644 --- a/chrome/browser/enterprise/util/managed_browser_utils.cc +++ b/chrome/browser/enterprise/util/managed_browser_utils.cc
@@ -11,6 +11,7 @@ #include "base/feature_list.h" #include "base/notreached.h" #include "base/values.h" +#include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "chrome/browser/browser_features.h" #include "chrome/browser/browser_process.h" @@ -33,7 +34,7 @@ #include "net/ssl/client_cert_identity.h" #include "url/gurl.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include <jni.h> #include "base/android/jni_string.h" @@ -41,7 +42,7 @@ #include "chrome/browser/enterprise/util/jni_headers/ManagedBrowserUtils_jni.h" #include "chrome/browser/profiles/profile_android.h" #include "chrome/browser/ui/managed_ui.h" -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) #if BUILDFLAG(IS_CHROMEOS_ASH) #include "chrome/browser/ash/policy/core/browser_policy_connector_ash.h" @@ -232,7 +233,7 @@ return entry && entry->CanBeManaged(); } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) std::string GetAccountManagerName(Profile* profile) { DCHECK(profile); @@ -258,7 +259,7 @@ env, GetAccountManagerName(ProfileAndroid::FromProfileAndroid(profile))); } -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) } // namespace enterprise_util } // namespace chrome
diff --git a/chrome/browser/enterprise/util/managed_browser_utils.h b/chrome/browser/enterprise/util/managed_browser_utils.h index 1d044e7..14e273d 100644 --- a/chrome/browser/enterprise/util/managed_browser_utils.h +++ b/chrome/browser/enterprise/util/managed_browser_utils.h
@@ -58,13 +58,13 @@ // management through the enterprise account confirmation dialog. bool ProfileCanBeManaged(Profile* profile); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Returns the UTF8-encoded string representation of the entity that manages // `profile` or nullopt if unmanaged. `profile` must be not-null. std::string GetAccountManagerName(Profile* profile); -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) } // namespace enterprise_util } // namespace chrome
diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc b/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc index d9965e46..e369a468 100644 --- a/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc +++ b/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc
@@ -660,7 +660,9 @@ IN_PROC_BROWSER_TEST_P(WebNavigationApiFencedFrameTest, Load) { ASSERT_TRUE(StartEmbeddedTestServer()); - ASSERT_TRUE(RunExtensionTest("webnavigation/fencedFrames")) << message_; + ASSERT_TRUE(RunExtensionTest("webnavigation/fencedFrames", + {.custom_arg = !GetParam() ? "MPArch" : ""})) + << message_; } INSTANTIATE_TEST_SUITE_P(WebNavigationApiFencedFrameTest,
diff --git a/chrome/browser/extensions/api/web_request/web_request_apitest.cc b/chrome/browser/extensions/api/web_request/web_request_apitest.cc index 3e88775..c39fbd53 100644 --- a/chrome/browser/extensions/api/web_request/web_request_apitest.cc +++ b/chrome/browser/extensions/api/web_request/web_request_apitest.cc
@@ -577,7 +577,7 @@ // Pass "debug" as a custom arg to debug test flakiness. ASSERT_TRUE(RunExtensionTest("webrequest", {.page_url = "test_auth_required.html", - .custom_arg = "debug", + .custom_arg = R"({"debug": true})", .open_in_incognito = GetEnableIncognito()}, {.allow_in_incognito = GetEnableIncognito()})) << message_; @@ -594,7 +594,7 @@ // Pass "debug" as a custom arg to debug test flakiness. ASSERT_TRUE(RunExtensionTest("webrequest", {.page_url = "test_auth_required_async.html", - .custom_arg = "debug", + .custom_arg = R"({"debug": true})", .open_in_incognito = GetEnableIncognito()}, {.allow_in_incognito = GetEnableIncognito()})) << message_; @@ -687,8 +687,9 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestRedirectsWithExtraHeaders) { ASSERT_TRUE(StartEmbeddedTestServer()); - ASSERT_TRUE(RunExtensionTest("webrequest", {.page_url = "test_redirects.html", - .custom_arg = "useExtraHeaders"})) + ASSERT_TRUE(RunExtensionTest("webrequest", + {.page_url = "test_redirects.html", + .custom_arg = R"({"useExtraHeaders": true})"})) << message_; } @@ -730,7 +731,7 @@ ASSERT_TRUE(StartEmbeddedTestServer()); ASSERT_TRUE(RunExtensionTest("webrequest", {.page_url = "test_subresource_redirects.html", - .custom_arg = "useExtraHeaders"})) + .custom_arg = R"({"useExtraHeaders": true})"})) << message_; } @@ -4707,7 +4708,8 @@ DeclarativeSendMessage) { ASSERT_TRUE(StartEmbeddedTestServer()); ASSERT_TRUE(RunExtensionTest( - "webrequest", {.page_url = "test_fenced_frames_send_message.html"})) + "webrequest", {.page_url = "test_fenced_frames_send_message.html", + .custom_arg = !GetParam() ? R"({"mparch": true})" : ""})) << message_; }
diff --git a/chrome/browser/feed/android/BUILD.gn b/chrome/browser/feed/android/BUILD.gn index 1c774ba..d3d1311 100644 --- a/chrome/browser/feed/android/BUILD.gn +++ b/chrome/browser/feed/android/BUILD.gn
@@ -230,7 +230,6 @@ ":java", "//base:base_java", "//base:base_java_test_support", - "//chrome/android:chrome_java", "//chrome/browser/feature_engagement:java", "//chrome/browser/flags:java", "//chrome/browser/preferences:java",
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json index 8c82451..7579fdc5 100644 --- a/chrome/browser/flag-metadata.json +++ b/chrome/browser/flag-metadata.json
@@ -623,11 +623,6 @@ "expiry_milestone": 95 }, { - "name": "calculate-native-win-occlusion", - "owners": [ "davidbienvenu", "fdoray" ], - "expiry_milestone": 96 - }, - { "name": "calendar-view", "owners": ["jiamingc"], "expiry_milestone" : 103 @@ -1115,7 +1110,7 @@ "name": "deprecate-alt-click", "owners": [ "zentaro@google.com", "jimmyxgong@google.com", "cros-peripherals@google.com"], - "expiry_milestone": 97 + "expiry_milestone": 105 }, { "name": "deprecate-low-usage-codecs", @@ -3489,7 +3484,7 @@ }, { "name": "improved-desks-keyboard-shortcuts", - "owners": [ "chinsenj", "janetmac"], + "owners": [ "zxdan", "janetmac"], "expiry_milestone": 101 }, { @@ -4019,7 +4014,7 @@ { "name": "new-shortcut-mapping", "owners": [ "zentaro@google.com", "jimmyxgong@google.com", "cros-peripherals@google.com"], - "expiry_milestone": 98 + "expiry_milestone": 105 }, { "name": "new-usb-backend", @@ -5272,7 +5267,7 @@ { "name": "sync-settings-categorization", "owners": [ "bsazonov", "rsorokin", "cros-oac@google.com" ], - "expiry_milestone": 98 + "expiry_milestone": 101 }, { "name": "sync-trusted-vault-passphrase-ios-rpc", @@ -5318,16 +5313,6 @@ "expiry_milestone": 95 }, { - "name": "tab-groups-collapse-freezing", - "owners": [ "chrome-desktop-ui-sea@google.com", "cyan" ], - "expiry_milestone": 95 - }, - { - "name": "tab-groups-feedback", - "owners": [ "chrome-desktop-ui-sea@google.com", "cyan" ], - "expiry_milestone": 95 - }, - { "name": "tab-groups-new-badge-promo", "owners": [ "chrome-desktop-ui-sea@google.com", "dfried" ], "expiry_milestone": 90
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc index 0b2b252..45f243c 100644 --- a/chrome/browser/flag_descriptions.cc +++ b/chrome/browser/flag_descriptions.cc
@@ -2377,10 +2377,6 @@ const char kTabGroupsAutoCreateDescription[] = "Automatically creates groups for users, if tab groups are enabled."; -const char kTabGroupsCollapseFreezingName[] = "Tab Groups Collapse Freezing"; -const char kTabGroupsCollapseFreezingDescription[] = - "Experimental tab freezing upon collapsing a tab group."; - const char kTabGroupsNewBadgePromoName[] = "Tab Groups 'New' Badge Promo"; const char kTabGroupsNewBadgePromoDescription[] = "Causes a 'New' badge to appear on the entry point for creating a tab " @@ -3746,12 +3742,6 @@ #if defined(OS_WIN) -const char kCalculateNativeWinOcclusionName[] = - "Calculate window occlusion on Windows"; -const char kCalculateNativeWinOcclusionDescription[] = - "Calculate window occlusion on Windows will be used in the future " - "to throttle and potentially unload foreground tabs in occluded windows"; - const char kEnableIncognitoShortcutOnDesktopName[] = "Enable Incognito Desktop Shortcut"; const char kEnableIncognitoShortcutOnDesktopDescription[] =
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h index b4c8853..f44de23 100644 --- a/chrome/browser/flag_descriptions.h +++ b/chrome/browser/flag_descriptions.h
@@ -1366,9 +1366,6 @@ extern const char kTabGroupsAutoCreateName[]; extern const char kTabGroupsAutoCreateDescription[]; -extern const char kTabGroupsCollapseFreezingName[]; -extern const char kTabGroupsCollapseFreezingDescription[]; - extern const char kTabGroupsNewBadgePromoName[]; extern const char kTabGroupsNewBadgePromoDescription[]; @@ -2144,9 +2141,6 @@ #if defined(OS_WIN) -extern const char kCalculateNativeWinOcclusionName[]; -extern const char kCalculateNativeWinOcclusionDescription[]; - extern const char kEnableIncognitoShortcutOnDesktopName[]; extern const char kEnableIncognitoShortcutOnDesktopDescription[];
diff --git a/chrome/browser/flags/BUILD.gn b/chrome/browser/flags/BUILD.gn index 6f136cf..6f0435e 100644 --- a/chrome/browser/flags/BUILD.gn +++ b/chrome/browser/flags/BUILD.gn
@@ -102,7 +102,6 @@ "//base:base_java", "//base:base_java_test_support", "//base/test:test_support_java", - "//chrome/android:chrome_java", "//chrome/test/android:chrome_java_test_support", "//third_party/android_sdk:android_test_mock_java", "//third_party/android_support_test_runner:runner_java",
diff --git a/chrome/browser/history_clusters/history_clusters_metrics_browsertest.cc b/chrome/browser/history_clusters/history_clusters_metrics_browsertest.cc index a46ffc9..3c1bc197 100644 --- a/chrome/browser/history_clusters/history_clusters_metrics_browsertest.cc +++ b/chrome/browser/history_clusters/history_clusters_metrics_browsertest.cc
@@ -83,8 +83,8 @@ EXPECT_EQ(0u, entries.size()); } -// Flaky on Win and Linux. http://crbug.com/1282122 -#if defined(OS_WIN) || defined(OS_LINUX) +// Flaky on Win, Linux and Mac. http://crbug.com/1282122 +#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MAC) #define MAYBE_DirectNavigationNoInteraction \ DISABLED_DirectNavigationNoInteraction #else @@ -114,8 +114,8 @@ histogram_tester.ExpectTotalCount("History.Clusters.Actions.NumQueries", 0); } -// TODO(crbug.com/1282087): Flaky on Linux and Windows. -#if defined(OS_LINUX) || defined(OS_WIN) +// TODO(crbug.com/1282087): Flaky on Linux, Windows and Mac. +#if defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) #define MAYBE_DirectNavigationWithQuery DISABLED_DirectNavigationWithQuery #else #define MAYBE_DirectNavigationWithQuery DirectNavigationWithQuery
diff --git a/chrome/browser/media/audio_service_util.cc b/chrome/browser/media/audio_service_util.cc index b66a7d7..d9dafbe3 100644 --- a/chrome/browser/media/audio_service_util.cc +++ b/chrome/browser/media/audio_service_util.cc
@@ -8,6 +8,7 @@ #include "base/feature_list.h" #include "base/values.h" +#include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/policy/chrome_browser_policy_connector.h" @@ -20,8 +21,8 @@ namespace { -#if defined(OS_WIN) || defined(OS_MAC) || \ - (defined(OS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS)) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || \ + (BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS)) bool GetPolicyOrFeature(const char* policy_name, const base::Feature& feature) { const policy::PolicyMap& policies = g_browser_process->browser_policy_connector() @@ -40,8 +41,8 @@ bool IsAudioServiceSandboxEnabled() { // TODO(crbug.com/1052397): Remove !IS_CHROMEOS_LACROS once lacros starts being // built with OS_CHROMEOS instead of OS_LINUX. -#if defined(OS_WIN) || defined(OS_MAC) || \ - (defined(OS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS)) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || \ + (BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS)) return GetPolicyOrFeature(policy::key::kAudioSandboxEnabled, features::kAudioServiceSandbox); #else @@ -49,7 +50,7 @@ #endif } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) bool IsAudioProcessHighPriorityEnabled() { return GetPolicyOrFeature(policy::key::kAudioProcessHighPriorityEnabled, features::kAudioProcessHighPriorityWin);
diff --git a/chrome/browser/media/audio_service_util.h b/chrome/browser/media/audio_service_util.h index 85d9e13..4b20bc89 100644 --- a/chrome/browser/media/audio_service_util.h +++ b/chrome/browser/media/audio_service_util.h
@@ -9,7 +9,7 @@ bool IsAudioServiceSandboxEnabled(); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) bool IsAudioProcessHighPriorityEnabled(); #endif
diff --git a/chrome/browser/media/autoplay_metrics_browsertest.cc b/chrome/browser/media/autoplay_metrics_browsertest.cc index 0040263..c06256f 100644 --- a/chrome/browser/media/autoplay_metrics_browsertest.cc +++ b/chrome/browser/media/autoplay_metrics_browsertest.cc
@@ -65,7 +65,7 @@ }; // Flaky on various platforms. https://crbug.com/1101841 -#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #define MAYBE_RecordAutoplayAttemptUkm DISABLED_RecordAutoplayAttemptUkm #else #define MAYBE_RecordAutoplayAttemptUkm RecordAutoplayAttemptUkm
diff --git a/chrome/browser/media/cast_remoting_connector.cc b/chrome/browser/media/cast_remoting_connector.cc index be96b39..9878a14 100644 --- a/chrome/browser/media/cast_remoting_connector.cc +++ b/chrome/browser/media/cast_remoting_connector.cc
@@ -464,7 +464,7 @@ return; } sink_metadata_ = *metadata; -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) sink_metadata_.features.push_back( media::mojom::RemotingSinkFeature::RENDERING); #endif @@ -512,7 +512,7 @@ void CastRemotingConnector::StartObservingPref() { pref_change_registrar_.Init(pref_service_); -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) pref_change_registrar_.Add( media_router::prefs::kMediaRouterMediaRemotingEnabled, base::BindRepeating(&CastRemotingConnector::OnPrefChanged, @@ -521,7 +521,7 @@ } void CastRemotingConnector::OnPrefChanged() { -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) const PrefService::Preference* pref = pref_service_->FindPreference( media_router::prefs::kMediaRouterMediaRemotingEnabled); bool enabled = pref->GetValue()->GetIfBool().value_or(false);
diff --git a/chrome/browser/media/cdm_document_service_impl.cc b/chrome/browser/media/cdm_document_service_impl.cc index 489ce54..bd662dc 100644 --- a/chrome/browser/media/cdm_document_service_impl.cc +++ b/chrome/browser/media/cdm_document_service_impl.cc
@@ -7,6 +7,7 @@ #include <utility> #include "base/bind.h" +#include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" @@ -20,7 +21,7 @@ #include "content/public/browser/render_process_host.h" #endif -#if BUILDFLAG(ENABLE_CDM_STORAGE_ID) || defined(OS_CHROMEOS) +#if BUILDFLAG(ENABLE_CDM_STORAGE_ID) || BUILDFLAG(IS_CHROMEOS) #include "chrome/browser/profiles/profile.h" #include "content/public/browser/render_frame_host.h" #endif @@ -35,11 +36,11 @@ #include "chromeos/lacros/lacros_service.h" #endif // BUILDFLAG(IS_CHROMEOS_LACROS) -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) #include "chrome/browser/media/platform_verification_chromeos.h" #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <windows.h> #include "base/files/file_enumerator.h" @@ -52,7 +53,7 @@ #include "chrome/browser/media/cdm_pref_service_helper.h" #include "media/cdm/win/media_foundation_cdm.h" #include "sandbox/policy/win/lpac_capability.h" -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) namespace { @@ -72,7 +73,7 @@ #endif // BUILDFLAG(ENABLE_CDM_STORAGE_ID) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) const char kCdmStore[] = "MediaFoundationCdmStore"; base::FilePath GetCdmStorePathRootForProfile( @@ -80,11 +81,11 @@ return profile_path.AppendASCII(kCdmStore).AppendASCII( base::SysInfo::ProcessCPUArchitecture()); } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) } // namespace -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) bool CreateCdmStorePathRootAndGrantAccessIfNeeded( const base::FilePath& cdm_store_path_root) { if (!media::MediaFoundationCdm::IsAvailable()) { @@ -125,7 +126,7 @@ return std::make_unique<media::MediaFoundationCdmData>( pref_data->origin_id(), pref_data->client_token(), cdm_store_path_root); } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) // static void CdmDocumentServiceImpl::Create( @@ -163,7 +164,7 @@ // TODO(crbug.com/676224). This should be commented out at the mojom // level so that it's only available for ChromeOS. -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) bool success = platform_verification::PerformBrowserChecks( render_frame_host()->GetMainFrame()); if (!success) { @@ -283,7 +284,7 @@ } #endif // BUILDFLAG(ENABLE_CDM_STORAGE_ID) -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) void CdmDocumentServiceImpl::IsVerifiedAccessEnabled( IsVerifiedAccessEnabledCallback callback) { // If we are in guest/incognito mode, then verified access is effectively @@ -315,9 +316,9 @@ std::move(callback).Run(enabled_for_device); #endif // else BUILDFLAG(IS_CHROMEOS_LACROS) } -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) void CdmDocumentServiceImpl::GetMediaFoundationCdmData( GetMediaFoundationCdmDataCallback callback) { const url::Origin cdm_origin = origin(); @@ -459,4 +460,4 @@ std::move(origin_id_mapping), start, end, filter), std::move(complete_cb)); } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN)
diff --git a/chrome/browser/media/cdm_document_service_impl.h b/chrome/browser/media/cdm_document_service_impl.h index 3ebbfcb..1e36ac3 100644 --- a/chrome/browser/media/cdm_document_service_impl.h +++ b/chrome/browser/media/cdm_document_service_impl.h
@@ -44,10 +44,10 @@ const std::string& challenge, ChallengePlatformCallback callback) final; void GetStorageId(uint32_t version, GetStorageIdCallback callback) final; -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) void IsVerifiedAccessEnabled(IsVerifiedAccessEnabledCallback callback) final; #endif // BUILDFLAG(IS_CHROMEOS_ASH) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) void GetMediaFoundationCdmData( GetMediaFoundationCdmDataCallback callback) final; void SetCdmClientToken(const std::vector<uint8_t>& client_token) final; @@ -58,7 +58,7 @@ base::Time end, const base::RepeatingCallback<bool(const GURL&)>& filter, base::OnceClosure complete_cb); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) private: // |this| can only be destructed as a DocumentService.
diff --git a/chrome/browser/media/cdm_storage_id.cc b/chrome/browser/media/cdm_storage_id.cc index 252e8a3..474dd88 100644 --- a/chrome/browser/media/cdm_storage_id.cc +++ b/chrome/browser/media/cdm_storage_id.cc
@@ -16,7 +16,7 @@ #include "rlz/buildflags/buildflags.h" #include "url/origin.h" -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) #include "base/bind.h" #include "mojo/public/cpp/bindings/callback_helpers.h" #endif @@ -30,13 +30,13 @@ #include "chromeos/lacros/lacros_service.h" #endif -#if defined(OS_WIN) || defined(OS_MAC) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) #if BUILDFLAG(ENABLE_RLZ) #include "rlz/lib/machine_id.h" #else #error "RLZ must be enabled on Windows/Mac" #endif // BUILDFLAG(ENABLE_RLZ) -#endif // defined(OS_WIN) || defined(OS_MAC) +#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) namespace { @@ -89,7 +89,7 @@ return result; } -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) void ComputeAndReturnStorageId(const std::vector<uint8_t>& profile_salt, const url::Origin& origin, CdmStorageIdCallback callback, @@ -98,14 +98,14 @@ std::move(callback).Run( CalculateStorageId(storage_id_key, profile_salt, origin, machine_id)); } -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) } // namespace void ComputeStorageId(const std::vector<uint8_t>& profile_salt, const url::Origin& origin, CdmStorageIdCallback callback) { -#if defined(OS_WIN) || defined(OS_MAC) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) std::string machine_id; std::string storage_id_key = GetCdmStorageIdKey(); rlz_lib::GetMachineId(&machine_id);
diff --git a/chrome/browser/media/encrypted_media_browsertest.cc b/chrome/browser/media/encrypted_media_browsertest.cc index e14e1a91..16f1f90c 100644 --- a/chrome/browser/media/encrypted_media_browsertest.cc +++ b/chrome/browser/media/encrypted_media_browsertest.cc
@@ -39,7 +39,7 @@ #include "third_party/widevine/cdm/buildflags.h" #include "third_party/widevine/cdm/widevine_cdm_common.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/win/windows_version.h" #endif @@ -621,7 +621,7 @@ TestSimplePlayback("bear-320x240-v_frag-vp9-cenc.mp4"); } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // TODO(https://crbug.com/1250305): Fails on dcheck-enabled builds on 11.0. #define MAYBE_Playback_VideoOnly_WebM_VP9Profile2 \ DISABLED_Playback_VideoOnly_WebM_VP9Profile2 @@ -634,7 +634,7 @@ TestSimplePlayback("bear-320x240-v-vp9_profile2_subsample_cenc-v.webm"); } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // TODO(https://crbug.com/1250305): Fails on dcheck-enabled builds on 11.0. #define MAYBE_Playback_VideoOnly_MP4_VP9Profile2 \ DISABLED_Playback_VideoOnly_MP4_VP9Profile2 @@ -802,7 +802,7 @@ } // TODO(1019187): Failing on win7. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_CDMCrashDuringDecode DISABLED_CDMCrashDuringDecode #else #define MAYBE_CDMCrashDuringDecode CDMCrashDuringDecode
diff --git a/chrome/browser/media/encrypted_media_supported_types_browsertest.cc b/chrome/browser/media/encrypted_media_supported_types_browsertest.cc index 5b3019b..67e7342 100644 --- a/chrome/browser/media/encrypted_media_supported_types_browsertest.cc +++ b/chrome/browser/media/encrypted_media_supported_types_browsertest.cc
@@ -41,7 +41,7 @@ #include "media/cdm/cdm_paths.h" #endif -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #error This file needs to be updated to run on Android. #endif @@ -1219,7 +1219,7 @@ auto result = IsSessionTypeSupported(kWidevine, SessionType::kPersistentLicense); -#if BUILDFLAG(IS_CHROMEOS_ASH) || defined(OS_WIN) || defined(OS_MAC) +#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) // Persistent license session supported by Widevine key system on Windows and // Mac. On ChromeOS, it is supported when the protected media identifier // permission is allowed. See kUnsafelyAllowProtectedMediaIdentifierForDomain @@ -1458,7 +1458,7 @@ EXPECT_WV(IsAudioRobustnessSupported(kWidevine, "SW_SECURE_CRYPTO")); // Widevine experiment key system is only supported on Windows. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Widevine key system doesn't support hardware security. EXPECT_UNSUPPORTED(IsVideoRobustnessSupported(kWidevine, "HW_SECURE_CRYPTO")); EXPECT_UNSUPPORTED(IsVideoRobustnessSupported(kWidevine, "HW_SECURE_ALL"));
diff --git a/chrome/browser/media/history/media_history_browsertest.cc b/chrome/browser/media/history/media_history_browsertest.cc index 1987612..408c6692 100644 --- a/chrome/browser/media/history/media_history_browsertest.cc +++ b/chrome/browser/media/history/media_history_browsertest.cc
@@ -735,7 +735,7 @@ } // TODO(crbug.com/1176025): Flaking on Linux. -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) #define MAYBE_SaveImagesWithDifferentSessions \ DISABLED_SaveImagesWithDifferentSessions #else @@ -819,7 +819,7 @@ GetPlaybackSessionsSync(GetOTRMediaHistoryService(browser), 2)); } -#if defined(OS_MAC) && !defined(NDEBUG) +#if BUILDFLAG(IS_MAC) && !defined(NDEBUG) // TODO(crbug.com/1152073): This test has flaky timeouts on Mac Debug. #define MAYBE_RecordWatchtime_AudioVideo DISABLED_RecordWatchtime_AudioVideo #else @@ -1103,7 +1103,7 @@ } // TODO(crbug.com/1086828): Test is flaky on Linux, Windows, Mac and Lacros. -#if defined(OS_LINUX) || defined(OS_WIN) || defined(OS_MAC) || \ +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || \ BUILDFLAG(IS_CHROMEOS_LACROS) #define MAYBE_DoNotRecordWatchtime_Background \ DISABLED_DoNotRecordWatchtime_Background
diff --git a/chrome/browser/media/media_browsertest.cc b/chrome/browser/media/media_browsertest.cc index 0ef4cb8..4d02794 100644 --- a/chrome/browser/media/media_browsertest.cc +++ b/chrome/browser/media/media_browsertest.cc
@@ -34,7 +34,7 @@ switches::autoplay::kNoUserGestureRequiredPolicy); std::vector<base::Feature> enabled_features = { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) features::kLogJsConsoleMessages, #endif }; @@ -44,7 +44,7 @@ // the fallback path. media::kFallbackAfterDecodeError, -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Disable out of process audio on Linux due to process spawn // failures. http://crbug.com/986021 features::kAudioServiceOutOfProcess,
diff --git a/chrome/browser/media/media_engagement_autoplay_browsertest.cc b/chrome/browser/media/media_engagement_autoplay_browsertest.cc index 15414887..2161dd5 100644 --- a/chrome/browser/media/media_engagement_autoplay_browsertest.cc +++ b/chrome/browser/media/media_engagement_autoplay_browsertest.cc
@@ -291,7 +291,7 @@ } // Disabled due to being flaky. crbug.com/1212507 -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_UsePreloadedData_Allowed DISABLED_UsePreloadedData_Allowed #else #define MAYBE_UsePreloadedData_Allowed UsePreloadedData_Allowed
diff --git a/chrome/browser/media/media_engagement_browsertest.cc b/chrome/browser/media/media_engagement_browsertest.cc index aa6f09b..9da99524 100644 --- a/chrome/browser/media/media_engagement_browsertest.cc +++ b/chrome/browser/media/media_engagement_browsertest.cc
@@ -511,8 +511,8 @@ ExpectScores(1, 0); } -#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ - defined(OS_MAC) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || \ + BUILDFLAG(IS_MAC) // Flaky timeout. https://crbug.com/1014229 #define MAYBE_RecordSingleVisitOnSameOrigin \ DISABLED_RecordSingleVisitOnSameOrigin @@ -534,7 +534,7 @@ ExpectScores(1, 0); } -#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Flaky: https://crbug.com/1115238 #define MAYBE_RecordVisitOnNewOrigin DISABLED_RecordVisitOnNewOrigin #else @@ -626,7 +626,7 @@ ExpectScores(1, 0); } -#if defined(OS_MAC) && defined(ARCH_CPU_ARM64) +#if BUILDFLAG(IS_MAC) && defined(ARCH_CPU_ARM64) // https://crbug.com/1222896 #define MAYBE_SessionNewTabNavigateSameURL DISABLED_SessionNewTabNavigateSameURL #else @@ -648,7 +648,7 @@ ExpectScores(2, 2); } -#if defined(OS_MAC) && defined(ARCH_CPU_ARM64) +#if BUILDFLAG(IS_MAC) && defined(ARCH_CPU_ARM64) // https://crbug.com/1222896 #define MAYBE_SessionNewTabSameURL DISABLED_SessionNewTabSameURL #else @@ -732,7 +732,7 @@ EXPECT_TRUE(MediaEngagementPreloadedList::GetInstance()->loaded()); } -#if defined(OS_MAC) && defined(ARCH_CPU_ARM64) +#if BUILDFLAG(IS_MAC) && defined(ARCH_CPU_ARM64) // https://crbug.com/1222896 #define MAYBE_SessionNewTabNavigateSameURLWithOpener_Typed \ DISABLED_SessionNewTabNavigateSameURLWithOpener_Typed @@ -759,7 +759,7 @@ ExpectScores(2, 2); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_Ignored DISABLED_Ignored #else #define MAYBE_Ignored Ignored
diff --git a/chrome/browser/media/media_engagement_contents_observer.cc b/chrome/browser/media/media_engagement_contents_observer.cc index bbceee5..b1167d78 100644 --- a/chrome/browser/media/media_engagement_contents_observer.cc +++ b/chrome/browser/media/media_engagement_contents_observer.cc
@@ -24,11 +24,11 @@ #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" #include "third_party/blink/public/mojom/autoplay/autoplay.mojom.h" -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) namespace { @@ -618,7 +618,7 @@ } content::WebContents* MediaEngagementContentsObserver::GetOpener() const { -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) for (auto* browser : *BrowserList::GetInstance()) { if (browser->profile() != service_->profile()) continue; @@ -631,7 +631,7 @@ // Whether or not the |opener| is null, this is the right tab strip. return browser->tab_strip_model()->GetOpenerOfWebContentsAt(index); } -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) return nullptr; }
diff --git a/chrome/browser/media/media_engagement_contents_observer_unittest.cc b/chrome/browser/media/media_engagement_contents_observer_unittest.cc index 27f1549..f94a14bd 100644 --- a/chrome/browser/media/media_engagement_contents_observer_unittest.cc +++ b/chrome/browser/media/media_engagement_contents_observer_unittest.cc
@@ -36,7 +36,7 @@ #include "third_party/abseil-cpp/absl/types/optional.h" // TODO(crbug/1004580) All these tests crash on Android -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) class MediaEngagementContentsObserverTest : public ChromeRenderViewHostTestHarness { public: @@ -1362,4 +1362,4 @@ EXPECT_EQ(0u, GetStoredPlayerStatesCount()); } -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID)
diff --git a/chrome/browser/media/media_engagement_preloaded_list_unittest.cc b/chrome/browser/media/media_engagement_preloaded_list_unittest.cc index f2387415..f8af91c2 100644 --- a/chrome/browser/media/media_engagement_preloaded_list_unittest.cc +++ b/chrome/browser/media/media_engagement_preloaded_list_unittest.cc
@@ -18,7 +18,7 @@ namespace { -#if defined(OS_FUCHSIA) +#if BUILDFLAG(IS_FUCHSIA) // Generated files are re-homed to the package root. const base::FilePath kTestDataPath = base::FilePath( FILE_PATH_LITERAL("chrome/test/data/media/engagement/preload")); @@ -208,12 +208,12 @@ ExpectCheckResultNotLoadedCount(1); } -#if defined(OS_FUCHSIA) +#if BUILDFLAG(IS_FUCHSIA) // ".." is not a file that can be opened on Fuchsia. #define MAYBE_LoadFileReadFailed DISABLED_LoadFileReadFailed #else #define MAYBE_LoadFileReadFailed LoadFileReadFailed -#endif // defined(OS_FUCHSIA) +#endif // BUILDFLAG(IS_FUCHSIA) TEST_F(MediaEngagementPreloadedListTest, MAYBE_LoadFileReadFailed) { ASSERT_FALSE(LoadFromFile(kFileReadFailedPath)); EXPECT_FALSE(IsLoaded());
diff --git a/chrome/browser/media/media_engagement_service_unittest.cc b/chrome/browser/media/media_engagement_service_unittest.cc index fa09a0f..d5cbd2a 100644 --- a/chrome/browser/media/media_engagement_service_unittest.cc +++ b/chrome/browser/media/media_engagement_service_unittest.cc
@@ -602,7 +602,7 @@ } // The test is flaky: crbug.com/1042417. -#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) #define MAYBE_CleanUpDatabaseWhenHistoryIsExpired \ DISABLED_CleanUpDatabaseWhenHistoryIsExpired #else @@ -886,7 +886,7 @@ : public ChromeRenderViewHostTestHarness {}; TEST_F(MediaEngagementServiceEnabledTest, IsEnabled) { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Make sure these flags are disabled on Android EXPECT_FALSE(base::FeatureList::IsEnabled( media::kMediaEngagementBypassAutoplayPolicies));
diff --git a/chrome/browser/media/protected_media_identifier_permission_context.cc b/chrome/browser/media/protected_media_identifier_permission_context.cc index 82cefe69..9c4144d2 100644 --- a/chrome/browser/media/protected_media_identifier_permission_context.cc +++ b/chrome/browser/media/protected_media_identifier_permission_context.cc
@@ -39,7 +39,7 @@ #include "components/user_prefs/user_prefs.h" #endif -#if !(defined(OS_ANDROID) || defined(OS_WIN) || defined(OS_CHROMEOS)) +#if !(BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_CHROMEOS)) #error This file currently only supports Chrome OS, Android and Windows. #endif @@ -72,7 +72,7 @@ permissions::PermissionContextBase::GetPermissionStatusInternal( render_frame_host, requesting_origin, embedding_origin); DCHECK(content_setting == CONTENT_SETTING_ALLOW || -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) content_setting == CONTENT_SETTING_ASK || #endif content_setting == CONTENT_SETTING_BLOCK); @@ -134,7 +134,7 @@ // across platforms. bool ProtectedMediaIdentifierPermissionContext:: IsProtectedMediaIdentifierEnabled() const { -#if BUILDFLAG(IS_CHROMEOS_ASH) || defined(OS_WIN) +#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_WIN) Profile* profile = Profile::FromBrowserContext(browser_context()); // Identifier is not allowed in incognito or guest mode. if (profile->IsOffTheRecord() || profile->IsGuestSession()) { @@ -162,7 +162,7 @@ return false; } #endif // BUILDFLAG(IS_CHROMEOS_ASH) -#endif // BUILDFLAG(IS_CHROMEOS_ASH) || defined(OS_WIN) +#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_WIN) return true; }
diff --git a/chrome/browser/media/router/chrome_media_router_factory.cc b/chrome/browser/media/router/chrome_media_router_factory.cc index 23520265..5561ae3 100644 --- a/chrome/browser/media/router/chrome_media_router_factory.cc +++ b/chrome/browser/media/router/chrome_media_router_factory.cc
@@ -11,7 +11,7 @@ #include "components/media_router/browser/media_router_dialog_controller.h" #include "content/public/browser/browser_context.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "chrome/browser/media/android/router/chrome_media_router_client.h" #include "components/media_router/browser/android/media_router_android.h" #include "components/media_router/browser/android/media_router_dialog_controller_android.h" @@ -37,7 +37,7 @@ // static void ChromeMediaRouterFactory::DoPlatformInit() { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) InitChromeMediaRouterJavaClient(); // The desktop (Views) version of this is in ChromeBrowserMainExtraPartsViews @@ -71,7 +71,7 @@ return nullptr; } MediaRouterBase* media_router = nullptr; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) media_router = new MediaRouterAndroid(); #else media_router = new MediaRouterDesktop(context);
diff --git a/chrome/browser/media/router/discovery/discovery_network_list_posix.cc b/chrome/browser/media/router/discovery/discovery_network_list_posix.cc index 6bae320..ec45daa 100644 --- a/chrome/browser/media/router/discovery/discovery_network_list_posix.cc +++ b/chrome/browser/media/router/discovery/discovery_network_list_posix.cc
@@ -18,7 +18,7 @@ #include "chrome/browser/media/router/discovery/discovery_network_list_wifi.h" #include "net/base/net_errors.h" -#if !defined(OS_MAC) +#if !BUILDFLAG(IS_MAC) #include <netpacket/packet.h> #else #include <net/if_dl.h> @@ -27,12 +27,12 @@ namespace media_router { namespace { -#if !defined(OS_MAC) +#if !BUILDFLAG(IS_MAC) using sll = struct sockaddr_ll; #define SOCKET_ARP_TYPE(s) ((s)->sll_hatype) #define SOCKET_ADDRESS_LEN(s) ((s)->sll_halen) #define SOCKET_ADDRESS(s) ((s)->sll_addr) -#else // defined(OS_MAC) +#else // BUILDFLAG(IS_MAC) #define AF_PACKET AF_LINK using sll = struct sockaddr_dl; #define SOCKET_ARP_TYPE(s) ((s)->sdl_type)
diff --git a/chrome/browser/media/router/discovery/mdns/cast_media_sink_service.cc b/chrome/browser/media/router/discovery/mdns/cast_media_sink_service.cc index 76c8f9f..3983687 100644 --- a/chrome/browser/media/router/discovery/mdns/cast_media_sink_service.cc +++ b/chrome/browser/media/router/discovery/mdns/cast_media_sink_service.cc
@@ -55,7 +55,7 @@ FROM_HERE, base::BindOnce(&CastMediaSinkServiceImpl::Start, base::Unretained(impl_.get()))); -#if !defined(OS_WIN) +#if !BUILDFLAG(IS_WIN) StartMdnsDiscovery(); #endif }
diff --git a/chrome/browser/media/router/media_router_feature.cc b/chrome/browser/media/router/media_router_feature.cc index 2379ee9..ded3ce2 100644 --- a/chrome/browser/media/router/media_router_feature.cc +++ b/chrome/browser/media/router/media_router_feature.cc
@@ -11,6 +11,7 @@ #include "base/feature_list.h" #include "base/no_destructor.h" #include "base/strings/string_util.h" +#include "build/build_config.h" #include "chrome/common/pref_names.h" #include "components/prefs/pref_service.h" #include "components/user_prefs/user_prefs.h" @@ -20,13 +21,13 @@ #include "media/base/media_switches.h" #include "ui/base/buildflags.h" -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) #include "components/prefs/pref_registry_simple.h" #endif namespace media_router { -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) const base::Feature kMediaRouter{"MediaRouter", base::FEATURE_ENABLED_BY_DEFAULT}; const base::Feature kCastAllowAllIPsFeature{"CastAllowAllIPs", @@ -39,7 +40,7 @@ base::FEATURE_ENABLED_BY_DEFAULT}; const base::Feature kDialEnforceUrlIPAddress{"DialEnforceUrlIPAddress", base::FEATURE_DISABLED_BY_DEFAULT}; -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) namespace { const PrefService::Preference* GetMediaRouterPref( @@ -61,10 +62,10 @@ } bool MediaRouterEnabled(content::BrowserContext* context) { -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) if (!base::FeatureList::IsEnabled(kMediaRouter)) return false; -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) // If the Media Router was already enabled or disabled for |context|, then it // must remain so. The Media Router does not support dynamic @@ -86,7 +87,7 @@ return true; } -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) void RegisterLocalStatePrefs(PrefRegistrySimple* registry) { registry->RegisterBooleanPref(prefs::kMediaRouterCastAllowAllIPs, false, PrefRegistry::PUBLIC); @@ -140,15 +141,15 @@ } bool GetAccessCodeCastEnabledPref(PrefService* pref_service) { -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) return pref_service->GetBoolean(prefs::kAccessCodeCastEnabled); #else return false; -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) } base::TimeDelta GetAccessCodeDeviceDurationPref(PrefService* pref_service) { -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) if (!GetAccessCodeCastEnabledPref(pref_service)) { return base::Seconds(0); } @@ -156,9 +157,9 @@ pref_service->GetInteger(prefs::kAccessCodeCastDeviceDuration)); #else return base::Seconds(0); -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) } -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) } // namespace media_router
diff --git a/chrome/browser/media/router/media_router_feature.h b/chrome/browser/media/router/media_router_feature.h index 43a5540..af84126 100644 --- a/chrome/browser/media/router/media_router_feature.h +++ b/chrome/browser/media/router/media_router_feature.h
@@ -26,7 +26,7 @@ // process. void ClearMediaRouterStoredPrefsForTesting(); -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) // Enables the media router. Can be disabled in tests unrelated to // Media Router where it interferes. Can also be useful to disable for local @@ -100,7 +100,7 @@ // in the cast list. base::TimeDelta GetAccessCodeDeviceDurationPref(PrefService* pref_service); -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) } // namespace media_router
diff --git a/chrome/browser/media/router/mojo/media_router_desktop.cc b/chrome/browser/media/router/mojo/media_router_desktop.cc index edb6d92c..5505cde 100644 --- a/chrome/browser/media/router/mojo/media_router_desktop.cc +++ b/chrome/browser/media/router/mojo/media_router_desktop.cc
@@ -7,6 +7,7 @@ #include "base/bind.h" #include "base/callback_helpers.h" #include "base/strings/string_util.h" +#include "build/build_config.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/media/router/media_router_feature.h" #include "chrome/browser/media/router/mojo/media_router_mojo_metrics.h" @@ -22,13 +23,13 @@ #include "content/public/browser/browser_thread.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/remote.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "chrome/browser/media/router/mojo/media_route_provider_util_win.h" #endif namespace media_router { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) constexpr char kLoggerComponent[] = "MediaRouterDesktop"; #endif @@ -51,7 +52,7 @@ media_sink_service_status_.GetWeakPtr())); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) if (!media_sink_service_->MdnsDiscoveryStarted()) { GetLogger()->LogInfo( mojom::LogCategory::kDiscovery, kLoggerComponent, @@ -90,7 +91,7 @@ MediaRouterDesktop::MediaRouterDesktop(content::BrowserContext* context) : MediaRouterDesktop(context, DualMediaSinkService::GetInstance()) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) CanFirewallUseLocalPorts( base::BindOnce(&MediaRouterDesktop::OnFirewallCheckComplete, weak_factory_.GetWeakPtr())); @@ -210,7 +211,7 @@ std::move(dial_provider_remote)); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) void MediaRouterDesktop::EnsureMdnsDiscoveryEnabled() { media_sink_service_->StartMdnsDiscovery(); }
diff --git a/chrome/browser/media/router/mojo/media_router_desktop.h b/chrome/browser/media/router/mojo/media_router_desktop.h index a70d409..10cd341 100644 --- a/chrome/browser/media/router/mojo/media_router_desktop.h +++ b/chrome/browser/media/router/mojo/media_router_desktop.h
@@ -71,7 +71,7 @@ void InitializeCastMediaRouteProvider(); void InitializeDialMediaRouteProvider(); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Ensures that mDNS discovery is enabled in the Cast MRP. This can be // called many times but the MRPM will only be called once per registration // period.
diff --git a/chrome/browser/media/router/presentation/presentation_service_delegate_impl_unittest.cc b/chrome/browser/media/router/presentation/presentation_service_delegate_impl_unittest.cc index 2ecd163..431fd952 100644 --- a/chrome/browser/media/router/presentation/presentation_service_delegate_impl_unittest.cc +++ b/chrome/browser/media/router/presentation/presentation_service_delegate_impl_unittest.cc
@@ -62,7 +62,7 @@ return expected.url == arg.url && expected.id == arg.id; } -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) // Set the user preference for |origin| to prefer tab mirroring. void EnableTabMirroringForOrigin(PrefService* prefs, const std::string& origin) { @@ -766,7 +766,7 @@ delegate_impl_->Reset(main_frame_process_id_, main_frame_routing_id_); } -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) TEST_F(PresentationServiceDelegateImplTest, AutoJoinRequest) { std::string origin(frame_origin_.Serialize()); content::WebContentsTester::For(GetWebContents()) @@ -872,6 +872,6 @@ &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError, base::Unretained(&mock_create_connection_callbacks))); } -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) } // namespace media_router
diff --git a/chrome/browser/media/webrtc/capture_handle_browsertest.cc b/chrome/browser/media/webrtc/capture_handle_browsertest.cc index 08a69f7..cff5de5 100644 --- a/chrome/browser/media/webrtc/capture_handle_browsertest.cc +++ b/chrome/browser/media/webrtc/capture_handle_browsertest.cc
@@ -374,7 +374,7 @@ } // TODO(crbug.com/1217873): Test disabled on Mac due to multiple failing bots. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_HandleNotExposedIfTopLevelAllowlistedButCallingFrameNotAllowlisted \ DISABLED_HandleNotExposedIfTopLevelAllowlistedButCallingFrameNotAllowlisted #else @@ -413,7 +413,7 @@ } // TODO(crbug.com/1217873): Test disabled on Mac due to multiple failing bots. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_HandleExposedIfCallingFrameAllowlistedEvenIfTopLevelNotAllowlisted \ DISABLED_HandleExposedIfCallingFrameAllowlistedEvenIfTopLevelNotAllowlisted #else @@ -701,7 +701,7 @@ } // TODO(crbug/1219998): Disabled because of flakiness. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_RegularTabCannotReadIncognitoTabCaptureHandle \ DISABLED_RegularTabCannotReadIncognitoTabCaptureHandle #else @@ -761,7 +761,7 @@ } // TODO(crbug/1219998): Disabled because of flakiness. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_IncognitoTabCanReadIncognitoTabCaptureHandleIfSelfCapture \ DISABLED_IncognitoTabCanReadIncognitoTabCaptureHandleIfSelfCapture #else
diff --git a/chrome/browser/media/webrtc/capture_policy_utils.cc b/chrome/browser/media/webrtc/capture_policy_utils.cc index 6ca55e8a..bbba5b3b 100644 --- a/chrome/browser/media/webrtc/capture_policy_utils.cc +++ b/chrome/browser/media/webrtc/capture_policy_utils.cc
@@ -14,7 +14,7 @@ #include "content/public/browser/web_contents.h" #include "url/origin.h" -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) #include "chrome/browser/ui/tab_modal_confirm_dialog.h" #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" #include "ui/base/l10n/l10n_util.h" @@ -144,7 +144,7 @@ }); } -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) class CaptureTerminatedDialogDelegate : public TabModalConfirmDialogDelegate { public: explicit CaptureTerminatedDialogDelegate(content::WebContents* web_contents) @@ -164,7 +164,7 @@ #endif void ShowCaptureTerminatedDialog(content::WebContents* contents) { -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) TabModalConfirmDialog::Create( std::make_unique<CaptureTerminatedDialogDelegate>(contents), contents); #endif
diff --git a/chrome/browser/media/webrtc/chrome_camera_pan_tilt_zoom_permission_context_delegate.cc b/chrome/browser/media/webrtc/chrome_camera_pan_tilt_zoom_permission_context_delegate.cc index 466adeb..c982ce0 100644 --- a/chrome/browser/media/webrtc/chrome_camera_pan_tilt_zoom_permission_context_delegate.cc +++ b/chrome/browser/media/webrtc/chrome_camera_pan_tilt_zoom_permission_context_delegate.cc
@@ -10,7 +10,7 @@ #include "content/public/browser/render_frame_host.h" #include "url/origin.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "base/compiler_specific.h" #endif @@ -36,7 +36,7 @@ GetPermissionStatusInternal(const GURL& requesting_origin, const GURL& embedding_origin, ContentSetting* content_setting_result) { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // The PTZ permission is automatically granted on Android. It is safe to do so // because pan and tilt are not supported on Android. *content_setting_result = CONTENT_SETTING_ALLOW;
diff --git a/chrome/browser/media/webrtc/conditional_focus_browsertest.cc b/chrome/browser/media/webrtc/conditional_focus_browsertest.cc index e4cbfbd..af7e20e 100644 --- a/chrome/browser/media/webrtc/conditional_focus_browsertest.cc +++ b/chrome/browser/media/webrtc/conditional_focus_browsertest.cc
@@ -167,7 +167,7 @@ }; // Flaky on Win bots and on linux release bots http://crbug.com/1264744 -#if defined(OS_WIN) || (defined(OS_LINUX) && defined(NDEBUG)) +#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_LINUX) && defined(NDEBUG)) #define MAYBE_CapturedTabFocusedIfNoExplicitCallToFocus \ DISABLED_CapturedTabFocusedIfNoExplicitCallToFocus #else @@ -182,7 +182,7 @@ } // Flaky on Win bots and on linux release bots http://crbug.com/1264744 -#if defined(OS_WIN) || (defined(OS_LINUX) && defined(NDEBUG)) +#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_LINUX) && defined(NDEBUG)) #define MAYBE_CapturedTabFocusedIfExplicitlyCallingFocus \ DISABLED_CapturedTabFocusedIfExplicitlyCallingFocus #else @@ -207,7 +207,7 @@ EXPECT_EQ(ActiveTab(), Tab::kCapturingTab); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Flaky on Win7 CI builder. See https://crbug.com/1255957. #define MAYBE_CapturedTabFocusedIfAppWaitsTooLongBeforeCallingFocus \ DISABLED_CapturedTabFocusedIfAppWaitsTooLongBeforeCallingFocus @@ -259,7 +259,7 @@ } // TODO(crbug.com/1285418): Flaky on Win and Linux bots. -#if defined(OS_WIN) || defined(OS_LINUX) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) #define MAYBE_ExceptionRaisedIfFocusCalledMultipleTimes \ DISABLED_ExceptionRaisedIfFocusCalledMultipleTimes #else
diff --git a/chrome/browser/media/webrtc/desktop_capture_access_handler.cc b/chrome/browser/media/webrtc/desktop_capture_access_handler.cc index 0f245ac..de815ac 100644 --- a/chrome/browser/media/webrtc/desktop_capture_access_handler.cc +++ b/chrome/browser/media/webrtc/desktop_capture_access_handler.cc
@@ -61,9 +61,9 @@ #include "ui/base/ui_base_features.h" #endif // BUILDFLAG(IS_CHROMEOS_ASH) -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "chrome/browser/media/webrtc/system_media_capture_permissions_mac.h" -#endif // defined(OS_MAC) +#endif // BUILDFLAG(IS_MAC) using content::BrowserThread; using extensions::mojom::ManifestLocation; @@ -71,7 +71,7 @@ namespace { // Currently, loopback audio capture is only supported on Windows and ChromeOS. -#if defined(USE_CRAS) || defined(OS_WIN) +#if defined(USE_CRAS) || BUILDFLAG(IS_WIN) constexpr bool kIsLoopbackAudioSupported = true; #else constexpr bool kIsLoopbackAudioSupported = false; @@ -107,7 +107,7 @@ base::FeatureList::IsEnabled(features::kWebUIFeedback)); } -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) // Find browser or app window from a given |web_contents|. gfx::NativeWindow FindParentWindowForWebContents( content::WebContents* web_contents) { @@ -190,7 +190,7 @@ return true; } -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) gfx::NativeWindow parent_window = FindParentWindowForWebContents(web_contents); #else @@ -366,7 +366,7 @@ /*ui=*/nullptr); return; } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) if (system_media_permissions::CheckSystemScreenCapturePermission() != system_media_permissions::SystemPermission::kAllowed) { std::move(pending_request->callback) @@ -428,7 +428,7 @@ /*ui=*/nullptr); return; } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) if (media_id.type != content::DesktopMediaID::TYPE_WEB_CONTENTS && system_media_permissions::CheckSystemScreenCapturePermission() != system_media_permissions::SystemPermission::kAllowed) {
diff --git a/chrome/browser/media/webrtc/desktop_capture_access_handler_unittest.cc b/chrome/browser/media/webrtc/desktop_capture_access_handler_unittest.cc index bdf723fb..7e0dabe 100644 --- a/chrome/browser/media/webrtc/desktop_capture_access_handler_unittest.cc +++ b/chrome/browser/media/webrtc/desktop_capture_access_handler_unittest.cc
@@ -36,7 +36,7 @@ #include "ui/aura/window.h" #endif -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "base/test/scoped_feature_list.h" #include "chrome/common/chrome_features.h" #endif @@ -64,7 +64,7 @@ blink::mojom::MediaStreamRequestResult* request_result, blink::MediaStreamDevices* devices_result, bool expect_result = true) { -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitAndDisableFeature( features::kMacSystemScreenCapturePermissionCheck);
diff --git a/chrome/browser/media/webrtc/desktop_media_picker_controller.cc b/chrome/browser/media/webrtc/desktop_media_picker_controller.cc index e8f8781..d0c8bea 100644 --- a/chrome/browser/media/webrtc/desktop_media_picker_controller.cc +++ b/chrome/browser/media/webrtc/desktop_media_picker_controller.cc
@@ -91,7 +91,7 @@ // system-wide audio loopback) at this time. content::DesktopMediaID media_id = source_list->GetSource(0).id; DCHECK_EQ(media_id.type, content::DesktopMediaID::TYPE_SCREEN); -#if defined(USE_CRAS) || defined(OS_WIN) +#if defined(USE_CRAS) || BUILDFLAG(IS_WIN) media_id.audio_share = params_.request_audio; #else media_id.audio_share = false;
diff --git a/chrome/browser/media/webrtc/display_media_access_handler.cc b/chrome/browser/media/webrtc/display_media_access_handler.cc index fb8c88f..8232508 100644 --- a/chrome/browser/media/webrtc/display_media_access_handler.cc +++ b/chrome/browser/media/webrtc/display_media_access_handler.cc
@@ -35,13 +35,13 @@ #include "third_party/blink/public/mojom/mediastream/media_stream.mojom-shared.h" #include "third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom.h" -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) #include "chrome/browser/chromeos/policy/dlp/dlp_content_manager.h" -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "chrome/browser/media/webrtc/system_media_capture_permissions_mac.h" -#endif // defined(OS_MAC) +#endif // BUILDFLAG(IS_MAC) namespace { @@ -122,7 +122,7 @@ return; } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Do not allow picker UI to be shown on a page that isn't in the foreground // in Mac, because the UI implementation in Mac pops a window over any content // which might be confusing for the users. See https://crbug.com/1407733 for @@ -136,7 +136,7 @@ blink::mojom::MediaStreamRequestResult::INVALID_STATE, /*ui=*/nullptr); return; } -#endif // defined(OS_MAC) +#endif // BUILDFLAG(IS_MAC) if (request.request_type == blink::MEDIA_DEVICE_UPDATE) { DCHECK(!request.requested_video_device_id.empty()); @@ -436,7 +436,7 @@ return; } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Check screen capture permissions on Mac if necessary. if ((media_id.type == content::DesktopMediaID::TYPE_SCREEN || media_id.type == content::DesktopMediaID::TYPE_WINDOW) && @@ -447,9 +447,9 @@ blink::mojom::MediaStreamRequestResult::SYSTEM_PERMISSION_DENIED); return; } -#endif // defined(OS_MAC) +#endif // BUILDFLAG(IS_MAC) -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) // Check Data Leak Prevention restrictions on Chrome. // base::Unretained(this) is safe because DisplayMediaAccessHandler is owned // by MediaCaptureDevicesDispatcher, which is a lazy singleton which is @@ -471,7 +471,7 @@ pending_requests_.erase(web_contents); } -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) void DisplayMediaAccessHandler::OnDlpRestrictionChecked( base::WeakPtr<content::WebContents> web_contents, const content::DesktopMediaID& media_id, @@ -488,7 +488,7 @@ } AcceptRequest(web_contents.get(), media_id); } -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) void DisplayMediaAccessHandler::DeletePendingAccessRequest( int render_process_id,
diff --git a/chrome/browser/media/webrtc/display_media_access_handler.h b/chrome/browser/media/webrtc/display_media_access_handler.h index ae9a7c4..c969ae338 100644 --- a/chrome/browser/media/webrtc/display_media_access_handler.h +++ b/chrome/browser/media/webrtc/display_media_access_handler.h
@@ -9,6 +9,7 @@ #include "base/containers/flat_map.h" #include "base/memory/weak_ptr.h" +#include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "chrome/browser/media/capture_access_handler_base.h" #include "chrome/browser/media/media_access_handler.h" @@ -95,12 +96,12 @@ void OnDisplaySurfaceSelected(content::WebContents* web_contents, content::DesktopMediaID media_id); -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) // Called back after checking Data Leak Prevention (DLP) restrictions. void OnDlpRestrictionChecked(base::WeakPtr<content::WebContents> web_contents, const content::DesktopMediaID& media_id, bool is_dlp_allowed); -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) void DeletePendingAccessRequest(int render_process_id, int render_frame_id,
diff --git a/chrome/browser/media/webrtc/display_media_access_handler_unittest.cc b/chrome/browser/media/webrtc/display_media_access_handler_unittest.cc index c910cbf..e9bc6aa 100644 --- a/chrome/browser/media/webrtc/display_media_access_handler_unittest.cc +++ b/chrome/browser/media/webrtc/display_media_access_handler_unittest.cc
@@ -27,13 +27,13 @@ #include "third_party/blink/public/common/mediastream/media_stream_request.h" #include "third_party/blink/public/mojom/mediastream/media_stream.mojom-shared.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "base/mac/mac_util.h" #endif -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) #include "chrome/browser/chromeos/policy/dlp/mock_dlp_content_manager.h" -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) class DisplayMediaAccessHandlerTest : public ChromeRenderViewHostTestHarness { public: @@ -214,7 +214,7 @@ content::DesktopMediaID::kFakeId), &result, &devices, false /* request_audio */); // TODO(https://crbug.com/1266425): Fix screen-capture tests on MacOS -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Starting from macOS 10.15, screen capture requires system permissions // that are disabled by default. if (base::mac::IsAtLeastOS10_15()) { @@ -239,7 +239,7 @@ true /* audio_share */); ProcessRequest(fake_media_id, &result, &devices, true /* request_audio */); // TODO(https://crbug.com/1266425): Fix screen-capture tests on MacOS -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Starting from macOS 10.15, screen capture requires system permissions // that are disabled by default. if (base::mac::IsAtLeastOS10_15()) { @@ -267,7 +267,7 @@ EXPECT_EQ(0u, devices.size()); } -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) TEST_F(DisplayMediaAccessHandlerTest, DlpRestricted) { const content::DesktopMediaID media_id(content::DesktopMediaID::TYPE_SCREEN, content::DesktopMediaID::kFakeId); @@ -341,7 +341,7 @@ EXPECT_EQ(blink::mojom::MediaStreamRequestResult::NOT_SUPPORTED, result); EXPECT_EQ(0u, devices.size()); } -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) TEST_F(DisplayMediaAccessHandlerTest, UpdateMediaRequestStateWithClosing) { const int render_process_id = @@ -525,7 +525,7 @@ EXPECT_TRUE(test_flags_[0].picker_created); EXPECT_TRUE(test_flags_[0].picker_deleted); // TODO(https://crbug.com/1266425): Fix screen-capture tests on MacOS -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Starting from macOS 10.15, screen capture requires system permissions // that are disabled by default. if (base::mac::IsAtLeastOS10_15()) { @@ -571,7 +571,7 @@ /*expected_number_of_devices=*/2u); } -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) TEST_F(DisplayMediaAccessHandlerTest, ChangeSourceDlpRestricted) { const content::DesktopMediaID media_id( content::DesktopMediaID::TYPE_WEB_CONTENTS, @@ -617,7 +617,7 @@ blink::mojom::MediaStreamRequestResult::OK, /*expected_number_of_devices=*/1u); } -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) TEST_F(DisplayMediaAccessHandlerTest, ChangeSourceWithPendingPickerRequest) { SetTestFlags({MakePickerTestFlags(false /*request_audio*/), @@ -636,7 +636,7 @@ EXPECT_TRUE(test_flags_[0].picker_created); EXPECT_TRUE(test_flags_[0].picker_deleted); // TODO(https://crbug.com/1266425): Fix screen-capture tests on MacOS -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Starting from macOS 10.15, screen capture requires system permissions // that are disabled by default. if (base::mac::IsAtLeastOS10_15()) { @@ -675,7 +675,7 @@ wait_loop[0].Run(); // TODO(https://crbug.com/1266425): Fix screen-capture tests on MacOS -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Starting from macOS 10.15, screen capture requires system permissions // that are disabled by default. if (base::mac::IsAtLeastOS10_15()) { @@ -715,7 +715,7 @@ EXPECT_TRUE(test_flags_[0].picker_created); EXPECT_TRUE(test_flags_[0].picker_deleted); // TODO(https://crbug.com/1266425): Fix screen-capture tests on MacOS -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Starting from macOS 10.15, screen capture requires system permissions // that are disabled by default. if (base::mac::IsAtLeastOS10_15()) {
diff --git a/chrome/browser/media/webrtc/media_capture_devices_dispatcher.cc b/chrome/browser/media/webrtc/media_capture_devices_dispatcher.cc index f10e660..ff863f1 100644 --- a/chrome/browser/media/webrtc/media_capture_devices_dispatcher.cc +++ b/chrome/browser/media/webrtc/media_capture_devices_dispatcher.cc
@@ -37,11 +37,11 @@ #include "third_party/blink/public/common/features.h" #include "third_party/blink/public/mojom/mediastream/media_stream.mojom-shared.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "content/public/common/content_features.h" #else // !OS_ANDROID #include "chrome/browser/media/webrtc/display_media_access_handler.h" -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) #if BUILDFLAG(IS_CHROMEOS_ASH) #include "chrome/browser/media/chromeos_login_media_access_handler.h" @@ -83,10 +83,10 @@ media_stream_capture_indicator_(new MediaStreamCaptureIndicator()) { DCHECK_CURRENTLY_ON(BrowserThread::UI); -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) media_access_handlers_.push_back( std::make_unique<DisplayMediaAccessHandler>()); -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) #if BUILDFLAG(ENABLE_EXTENSIONS) #if BUILDFLAG(IS_CHROMEOS_ASH) @@ -141,7 +141,7 @@ const extensions::Extension* extension) { DCHECK_CURRENTLY_ON(BrowserThread::UI); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Kill switch for getDisplayMedia() on browser side to prevent renderer from // bypassing blink side checks. if (request.video_type ==
diff --git a/chrome/browser/media/webrtc/media_stream_capture_indicator.cc b/chrome/browser/media/webrtc/media_stream_capture_indicator.cc index 9e6e9b4..0627cae 100644 --- a/chrome/browser/media/webrtc/media_stream_capture_indicator.cc +++ b/chrome/browser/media/webrtc/media_stream_capture_indicator.cc
@@ -31,7 +31,7 @@ #include "extensions/buildflags/buildflags.h" #include "ui/gfx/image/image_skia.h" -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) #include "chrome/browser/media/webrtc/media_stream_focus_delegate.h" #include "chrome/grit/chromium_strings.h" #include "components/vector_icons/vector_icons.h" @@ -203,7 +203,7 @@ : device_usage_(device_usage), devices_(devices), ui_(std::move(ui)), -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) focus_delegate_(web_contents), #endif application_title_(std::move(application_title)) { @@ -266,7 +266,7 @@ #endif } -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) void SetFocus(const content::DesktopMediaID& media_id, bool focus, bool is_from_microtask, @@ -278,7 +278,7 @@ base::WeakPtr<WebContentsDeviceUsage> device_usage_; const blink::MediaStreamDevices devices_; const std::unique_ptr<::MediaStreamUI> ui_; -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) MediaStreamFocusDelegate focus_delegate_; #endif const std::u16string application_title_; @@ -623,9 +623,9 @@ bool video, gfx::ImageSkia* image, std::u16string* tool_tip) { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) NOTREACHED(); -#else // !defined(OS_ANDROID) +#else // !BUILDFLAG(IS_ANDROID) DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(audio || video); DCHECK(image); @@ -646,5 +646,5 @@ *tool_tip = l10n_util::GetStringUTF16(message_id); *image = gfx::CreateVectorIcon(*icon, 16, gfx::kChromeIconGrey); -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) }
diff --git a/chrome/browser/media/webrtc/media_stream_device_permission_context_unittest.cc b/chrome/browser/media/webrtc/media_stream_device_permission_context_unittest.cc index 8b9d124..089b089 100644 --- a/chrome/browser/media/webrtc/media_stream_device_permission_context_unittest.cc +++ b/chrome/browser/media/webrtc/media_stream_device_permission_context_unittest.cc
@@ -20,7 +20,7 @@ #include "content/public/test/web_contents_tester.h" #include "testing/gtest/include/gtest/gtest.h" -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) #include "components/permissions/permission_request_manager.h" #endif @@ -106,7 +106,7 @@ // ChromeRenderViewHostTestHarness: void SetUp() override { ChromeRenderViewHostTestHarness::SetUp(); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) infobars::ContentInfoBarManager::CreateForWebContents(web_contents()); #else permissions::PermissionRequestManager::CreateForWebContents(web_contents());
diff --git a/chrome/browser/media/webrtc/media_stream_focus_delegate.cc b/chrome/browser/media/webrtc/media_stream_focus_delegate.cc index bf554ff..88619a0f 100644 --- a/chrome/browser/media/webrtc/media_stream_focus_delegate.cc +++ b/chrome/browser/media/webrtc/media_stream_focus_delegate.cc
@@ -6,9 +6,9 @@ #include "build/build_config.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #error "Unsupported on Android." -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) #include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_macros.h"
diff --git a/chrome/browser/media/webrtc/media_stream_focus_delegate.h b/chrome/browser/media/webrtc/media_stream_focus_delegate.h index 185d0c1..8c41a6e 100644 --- a/chrome/browser/media/webrtc/media_stream_focus_delegate.h +++ b/chrome/browser/media/webrtc/media_stream_focus_delegate.h
@@ -7,9 +7,9 @@ #include "build/build_config.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #error "Unsupported on Android." -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) #include "base/compiler_specific.h" #include "base/time/time.h"
diff --git a/chrome/browser/media/webrtc/native_desktop_media_list.cc b/chrome/browser/media/webrtc/native_desktop_media_list.cc index 04dbc1f..91da584 100644 --- a/chrome/browser/media/webrtc/native_desktop_media_list.cc +++ b/chrome/browser/media/webrtc/native_desktop_media_list.cc
@@ -36,7 +36,7 @@ #include "ui/snapshot/snapshot_aura.h" #endif -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "components/remote_cocoa/browser/scoped_cg_window_id.h" #endif @@ -94,7 +94,7 @@ return gfx::ImageSkia::CreateFrom1xBitmap(result); } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) const base::Feature kWindowCaptureMacV2{"WindowCaptureMacV2", base::FEATURE_ENABLED_BY_DEFAULT}; #endif @@ -316,7 +316,7 @@ thread_("DesktopMediaListCaptureThread") { type_ = type; -#if defined(OS_WIN) || defined(OS_MAC) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) // On Windows/OSX the thread must be a UI thread. base::MessagePumpType thread_type = base::MessagePumpType::UI; #else @@ -383,7 +383,7 @@ DesktopMediaID::TYPE_WINDOW, aura_window); source.id.window_id = aura_id.window_id; } -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) if (base::FeatureList::IsEnabled(kWindowCaptureMacV2)) { if (remote_cocoa::ScopedCGWindowID::Get(source.id.id)) source.id.window_id = source.id.id;
diff --git a/chrome/browser/media/webrtc/native_desktop_media_list_unittest.cc b/chrome/browser/media/webrtc/native_desktop_media_list_unittest.cc index fe6f26e..3ff0de7 100644 --- a/chrome/browser/media/webrtc/native_desktop_media_list_unittest.cc +++ b/chrome/browser/media/webrtc/native_desktop_media_list_unittest.cc
@@ -230,7 +230,7 @@ // Get the native window's id. gfx::AcceleratedWidget widget = host->GetAcceleratedWidget(); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) window.id = reinterpret_cast<DesktopMediaID::Id>(widget); #else window.id = widget; @@ -251,7 +251,7 @@ aura::Window* aura_window = desktop_widgets_[index]->GetNativeWindow(); gfx::AcceleratedWidget widget = aura_window->GetHost()->GetAcceleratedWidget(); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) int native_id = reinterpret_cast<DesktopMediaID::Id>(widget); #else int native_id = widget;
diff --git a/chrome/browser/media/webrtc/permission_bubble_media_access_handler.cc b/chrome/browser/media/webrtc/permission_bubble_media_access_handler.cc index f499e10..4cf04db 100644 --- a/chrome/browser/media/webrtc/permission_bubble_media_access_handler.cc +++ b/chrome/browser/media/webrtc/permission_bubble_media_access_handler.cc
@@ -30,16 +30,16 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include <vector> #include "chrome/browser/media/webrtc/screen_capture_infobar_delegate_android.h" #include "components/permissions/permission_uma_util.h" #include "components/permissions/permission_util.h" #include "content/public/common/content_features.h" -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "base/metrics/histogram_macros.h" #include "chrome/browser/content_settings/chrome_content_settings_utils.h" #include "chrome/browser/media/webrtc/system_media_capture_permissions_mac.h" @@ -53,7 +53,7 @@ blink::mojom::MediaStreamRequestResult result, std::unique_ptr<content::MediaStreamUI> ui)>; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) using system_media_permissions::SystemPermission; #endif @@ -155,7 +155,7 @@ content::WebContents* web_contents, const blink::mojom::MediaStreamType type, const extensions::Extension* extension) { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) return type == blink::mojom::MediaStreamType::DEVICE_VIDEO_CAPTURE || type == blink::mojom::MediaStreamType::DEVICE_AUDIO_CAPTURE || type == blink::mojom::MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE || @@ -195,7 +195,7 @@ const extensions::Extension* extension) { DCHECK_CURRENTLY_ON(BrowserThread::UI); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) if (blink::IsScreenCaptureMediaType(request.video_type) && !base::FeatureList::IsEnabled(features::kUserMediaScreenCapturing)) { // If screen capturing isn't enabled on Android, we'll use "invalid state" @@ -205,7 +205,7 @@ blink::mojom::MediaStreamRequestResult::INVALID_STATE, nullptr); return; } -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) // Ensure we are observing the deletion of |web_contents|. web_contents_collection_.StartObserving(web_contents); @@ -235,7 +235,7 @@ const int64_t request_id = it->second.begin()->first; const content::MediaStreamRequest& request = it->second.begin()->second.request; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) if (blink::IsScreenCaptureMediaType(request.video_type)) { ScreenCaptureInfoBarDelegateAndroid::Create( web_contents, request, @@ -348,7 +348,7 @@ blink::mojom::MediaStreamRequestResult final_result = result; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // If the request was approved, ask for system permissions if needed, and run // this function again when done. if (result == blink::mojom::MediaStreamRequestResult::OK) { @@ -410,7 +410,7 @@ } } } -#endif // defined(OS_MAC) +#endif // BUILDFLAG(IS_MAC) MediaResponseCallback callback = std::move(request_it->second.callback); requests_map.erase(request_it);
diff --git a/chrome/browser/media/webrtc/webrtc_apprtc_browsertest.cc b/chrome/browser/media/webrtc/webrtc_apprtc_browsertest.cc index f0c7444..ab0d9da 100644 --- a/chrome/browser/media/webrtc/webrtc_apprtc_browsertest.cc +++ b/chrome/browser/media/webrtc/webrtc_apprtc_browsertest.cc
@@ -116,7 +116,7 @@ const std::string& collider_port) { // The go workspace should be created, and collidermain built, at the // runhooks stage when webrtc.DEPS/build_apprtc_collider.py runs. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) base::FilePath collider_server = GetSourceDir().Append( FILE_PATH_LITERAL("third_party/webrtc/rtc_tools/testing/" "browsertest/collider/collidermain.exe"));
diff --git a/chrome/browser/media/webrtc/webrtc_browsertest_base.cc b/chrome/browser/media/webrtc/webrtc_browsertest_base.cc index 9cf2dd6..bfc8e75 100644 --- a/chrome/browser/media/webrtc/webrtc_browsertest_base.cc +++ b/chrome/browser/media/webrtc/webrtc_browsertest_base.cc
@@ -33,7 +33,7 @@ #include "extensions/browser/extension_registry.h" #include "net/test/embedded_test_server/embedded_test_server.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // For fine-grained suppression. #include "base/win/windows_version.h" #endif @@ -507,7 +507,7 @@ } bool WebRtcTestBase::OnWin8OrHigher() const { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return base::win::GetVersion() >= base::win::Version::WIN8; #else return false;
diff --git a/chrome/browser/media/webrtc/webrtc_browsertest_common.cc b/chrome/browser/media/webrtc/webrtc_browsertest_common.cc index 23e2ccb..3787245 100644 --- a/chrome/browser/media/webrtc/webrtc_browsertest_common.cc +++ b/chrome/browser/media/webrtc/webrtc_browsertest_common.cc
@@ -72,14 +72,14 @@ base::FilePath GetToolForPlatform(const std::string& tool_name) { base::FilePath tools_dir = GetReferenceFilesDir().Append(FILE_PATH_LITERAL("tools")); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return tools_dir .Append(FILE_PATH_LITERAL("win")) .AppendASCII(tool_name) .AddExtension(FILE_PATH_LITERAL("exe")); -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) return tools_dir.Append(FILE_PATH_LITERAL("mac")).AppendASCII(tool_name); -#elif defined(OS_LINUX) || defined(OS_CHROMEOS) +#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) return tools_dir.Append(FILE_PATH_LITERAL("linux")).AppendASCII(tool_name); #else CHECK(false) << "Can't retrieve tool " << tool_name << " on this platform.";
diff --git a/chrome/browser/media/webrtc/webrtc_desktop_capture_browsertest.cc b/chrome/browser/media/webrtc/webrtc_desktop_capture_browsertest.cc index cca5e7c..bf65ace 100644 --- a/chrome/browser/media/webrtc/webrtc_desktop_capture_browsertest.cc +++ b/chrome/browser/media/webrtc/webrtc_desktop_capture_browsertest.cc
@@ -270,7 +270,7 @@ content::WebContents* second_tab) { StartDetectingVideo(first_tab, "remote-view"); StartDetectingVideo(second_tab, "remote-view"); -#if !defined(OS_MAC) +#if !BUILDFLAG(IS_MAC) // Video is choppy on Mac OS X. http://crbug.com/443542. WaitForVideoToPlay(first_tab); WaitForVideoToPlay(second_tab); @@ -306,7 +306,7 @@ } // TODO(crbug.com/1282292): Test is flaky on Linux and ChromeOS. -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #define MAYBE_RunP2PScreenshareWhileSharingTab \ DISABLED_RunP2PScreenshareWhileSharingTab #else
diff --git a/chrome/browser/media/webrtc/webrtc_disable_encryption_flag_browsertest.cc b/chrome/browser/media/webrtc/webrtc_disable_encryption_flag_browsertest.cc index 557358c..4cf219f 100644 --- a/chrome/browser/media/webrtc/webrtc_disable_encryption_flag_browsertest.cc +++ b/chrome/browser/media/webrtc/webrtc_disable_encryption_flag_browsertest.cc
@@ -52,10 +52,10 @@ // TODO(crbug.com/910216): De-flake this for ChromeOs. // TODO(crbug.com/984879): De-flake this for ASAN/MSAN Linux. // TODO(crbug.com/1211144): De-flake this for MacOS. -#if defined(OS_CHROMEOS) || defined(OS_MAC) || \ - (defined(OS_LINUX) && \ +#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_MAC) || \ + (BUILDFLAG(IS_LINUX) && \ (defined(MEMORY_SANITIZER) || defined(ADDRESS_SANITIZER))) || \ - (defined(OS_WIN) && defined(ADDRESS_SANITIZER)) + (BUILDFLAG(IS_WIN) && defined(ADDRESS_SANITIZER)) #define MAYBE_VerifyEncryption DISABLED_VerifyEncryption #else #define MAYBE_VerifyEncryption VerifyEncryption @@ -87,7 +87,7 @@ channel == version_info::Channel::DEV) { should_detect_encryption = false; } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) if (channel == version_info::Channel::BETA) should_detect_encryption = false; #endif
diff --git a/chrome/browser/media/webrtc/webrtc_event_log_manager.cc b/chrome/browser/media/webrtc/webrtc_event_log_manager.cc index 69d9c1d..07744e2 100644 --- a/chrome/browser/media/webrtc/webrtc_event_log_manager.cc +++ b/chrome/browser/media/webrtc/webrtc_event_log_manager.cc
@@ -87,7 +87,7 @@ // 1. Certain platforms (mobile) are blocked from remote-bound logging. // 2. There is a Finch-controlled kill-switch for the feature. bool IsRemoteLoggingFeatureEnabled() { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) bool enabled = false; #else bool enabled = base::FeatureList::IsEnabled(features::kWebRtcRemoteEventLog); @@ -429,7 +429,7 @@ WebRtcEventLogManager::CreateRemoteLogFileWriterFactory() { if (remote_log_file_writer_factory_for_testing_) { return std::move(remote_log_file_writer_factory_for_testing_); -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) } else if (base::FeatureList::IsEnabled( features::kWebRtcRemoteEventLogGzipped)) { return std::make_unique<GzippedLogFileWriterFactory>(
diff --git a/chrome/browser/media/webrtc/webrtc_event_log_manager_common_unittest.cc b/chrome/browser/media/webrtc/webrtc_event_log_manager_common_unittest.cc index b343911..f5fb2c3 100644 --- a/chrome/browser/media/webrtc/webrtc_event_log_manager_common_unittest.cc +++ b/chrome/browser/media/webrtc/webrtc_event_log_manager_common_unittest.cc
@@ -345,14 +345,14 @@ EXPECT_TRUE(CreateWriter(log_file_writer_factory_->MinFileSizeBytes())); } -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) TEST_P(LogFileWriterTest, FactoryReturnsEmptyUniquePtrIfCantCreateFile) { Init(GetParam()); RemoveWritePermissions(temp_dir_.GetPath()); auto writer = CreateWriter(kMaxRemoteLogFileSizeBytes); EXPECT_FALSE(writer); } -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) TEST_P(LogFileWriterTest, CloseSucceedsWhenNoErrorsOccurred) { Init(GetParam()); @@ -426,7 +426,7 @@ EXPECT_FALSE(base::PathExists(path_)); } -#if !defined(OS_WIN) // Deleting the open file does not work on Windows. +#if !BUILDFLAG(IS_WIN) // Deleting the open file does not work on Windows. TEST_P(LogFileWriterTest, WriteDoesNotCrashIfFileRemovedExternally) { Init(GetParam()); @@ -465,7 +465,7 @@ // It's up to the OS whether this will succeed or fail, but it must not crash. writer->Delete(); } -#endif // !defined(OS_WIN) +#endif // !BUILDFLAG(IS_WIN) TEST_P(LogFileWriterTest, PathReturnsTheCorrectPath) { Init(GetParam());
diff --git a/chrome/browser/media/webrtc/webrtc_event_log_manager_local.cc b/chrome/browser/media/webrtc/webrtc_event_log_manager_local.cc index 9dcdd46..878bc1a 100644 --- a/chrome/browser/media/webrtc/webrtc_event_log_manager_local.cc +++ b/chrome/browser/media/webrtc/webrtc_event_log_manager_local.cc
@@ -11,7 +11,7 @@ #include "build/build_config.h" #include "content/public/browser/browser_thread.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define NumberToStringType base::NumberToString16 #else #define NumberToStringType base::NumberToString @@ -19,7 +19,7 @@ namespace webrtc_event_logging { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) const size_t kDefaultMaxLocalLogFileSizeBytes = 10000000; const size_t kMaxNumberLocalWebRtcEventLogFiles = 3; #else
diff --git a/chrome/browser/media/webrtc/webrtc_event_log_manager_unittest.cc b/chrome/browser/media/webrtc/webrtc_event_log_manager_unittest.cc index 3e4ad39..2530757 100644 --- a/chrome/browser/media/webrtc/webrtc_event_log_manager_unittest.cc +++ b/chrome/browser/media/webrtc/webrtc_event_log_manager_unittest.cc
@@ -63,7 +63,7 @@ #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/zlib/google/compression_utils.h" -#if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) #include "chrome/browser/policy/chrome_browser_policy_connector.h" #include "components/policy/core/common/mock_configuration_policy_provider.h" #include "components/policy/core/common/policy_map.h" @@ -78,7 +78,7 @@ namespace webrtc_event_logging { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define NumberToStringType base::NumberToWString #else #define NumberToStringType base::NumberToString @@ -98,7 +98,7 @@ namespace { -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) auto SaveFilePathTo(absl::optional<base::FilePath>* output) { return [output](PeerConnectionKey ignored_key, base::FilePath file_path, @@ -313,13 +313,13 @@ SetLocalLogsObserver(&local_observer_); SetRemoteLogsObserver(&remote_observer_); LoadMainTestProfile(); -#if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) policy::BrowserPolicyConnectorBase::SetPolicyProviderForTesting(&provider_); #endif } void TearDown() override { -#if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) TestingBrowserProcess::GetGlobal()->ShutdownBrowserPolicyConnector(); #endif } @@ -684,7 +684,7 @@ policy_allows_remote_logging.value()); } -#if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) policy::PolicyMap policy_map; if (has_device_level_policies) { policy_map.Set("test-policy", policy::POLICY_LEVEL_MANDATORY, @@ -830,7 +830,7 @@ scoped_refptr<network::SharedURLLoaderFactory> test_shared_url_loader_factory_; -#if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) policy::MockConfigurationPolicyProvider provider_; #endif @@ -901,7 +901,7 @@ NiceMock<MockWebRtcRemoteEventLogsObserver> remote_observer_; }; -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) class WebRtcEventLogManagerTest : public WebRtcEventLogManagerTestBase, public ::testing::WithParamInterface<bool> { @@ -1894,7 +1894,7 @@ EXPECT_TRUE(base::IsDirectoryEmpty(local_logs_base_dir_.GetPath())); } -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) TEST_F(WebRtcEventLogManagerTest, LocalLogLegalPathWithoutPermissionsSanity) { RemoveWritePermissions(local_logs_base_dir_.GetPath()); @@ -1921,7 +1921,7 @@ EXPECT_TRUE(DisableLocalLogging()); EXPECT_TRUE(base::IsDirectoryEmpty(local_logs_base_dir_.GetPath())); } -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) TEST_F(WebRtcEventLogManagerTest, LocalLogEmptyStringHandledGracefully) { const auto key = GetPeerConnectionKey(rph_.get(), kLid); @@ -2610,7 +2610,7 @@ EXPECT_EQ(OnWebRtcEventLogWrite(key, log), std::make_pair(false, true)); } -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) // TODO(crbug.com/775415): Add unit tests for lacking read permissions when // looking to upload the file. TEST_F(WebRtcEventLogManagerTest, @@ -2676,7 +2676,7 @@ EXPECT_EQ(OnWebRtcEventLogWrite(key, "abc"), std::make_pair(false, false)); EXPECT_TRUE(base::IsDirectoryEmpty(remote_logs_path)); } -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) TEST_F(WebRtcEventLogManagerTest, RemoteLogLimitActiveLogFiles) { for (int i = 0; i < kMaxActiveRemoteLogFiles + 1; ++i) { @@ -3098,7 +3098,7 @@ std::accumulate(std::begin(logs), std::end(logs), std::string())); } -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) TEST_F(WebRtcEventLogManagerTest, UnopenedRemoteLogFilesNotCountedTowardsActiveLogsLimit) { std::unique_ptr<TestingProfile> browser_contexts[2]; @@ -3136,7 +3136,7 @@ EXPECT_TRUE(StartRemoteLogging(with_permissions_key)); } } -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) TEST_F(WebRtcEventLogManagerTest, NoStartWebRtcSendingEventLogsWhenLocalEnabledWithoutPeerConnection) { @@ -4079,7 +4079,7 @@ } #endif -#if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) TEST_F(WebRtcEventLogManagerTestPolicy, OnlyManagedByPlatformPoliciesDoesNotAllowRemoteLoggingByDefault) { SetUp(true); // Feature generally enabled (kill-switch not engaged). @@ -5037,7 +5037,7 @@ // TODO(crbug.com/775415): Add a test for the limit on the number of history // files allowed to remain on disk. -#else // defined(OS_ANDROID) +#else // BUILDFLAG(IS_ANDROID) class WebRtcEventLogManagerTestOnMobileDevices : public WebRtcEventLogManagerTestBase {
diff --git a/chrome/browser/media/webrtc/webrtc_event_log_manager_unittest_helpers.cc b/chrome/browser/media/webrtc/webrtc_event_log_manager_unittest_helpers.cc index f30942b9..a38e81dd 100644 --- a/chrome/browser/media/webrtc/webrtc_event_log_manager_unittest_helpers.cc +++ b/chrome/browser/media/webrtc/webrtc_event_log_manager_unittest_helpers.cc
@@ -7,6 +7,7 @@ #include "base/check.h" #include "base/files/file_util.h" #include "base/notreached.h" +#include "build/build_config.h" #include "testing/gtest/include/gtest/gtest.h" namespace webrtc_event_logging { @@ -30,7 +31,7 @@ return nullptr; // Appease compiler. } -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) void RemoveWritePermissions(const base::FilePath& path) { int permissions; ASSERT_TRUE(base::GetPosixFilePermissions(path, &permissions)); @@ -40,7 +41,7 @@ permissions &= ~write_permissions; ASSERT_TRUE(base::SetPosixFilePermissions(path, permissions)); } -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) std::unique_ptr<CompressedSizeEstimator> NullEstimator::Factory::Create() const {
diff --git a/chrome/browser/media/webrtc/webrtc_event_log_manager_unittest_helpers.h b/chrome/browser/media/webrtc/webrtc_event_log_manager_unittest_helpers.h index 0fe270e..1ce4eb2 100644 --- a/chrome/browser/media/webrtc/webrtc_event_log_manager_unittest_helpers.h +++ b/chrome/browser/media/webrtc/webrtc_event_log_manager_unittest_helpers.h
@@ -25,9 +25,9 @@ std::unique_ptr<LogFileWriter::Factory> CreateLogFileWriterFactory( WebRtcEventLogCompression compression); -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) void RemoveWritePermissions(const base::FilePath& path); -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) // Always estimates strings to be compressed to zero bytes. class NullEstimator : public CompressedSizeEstimator {
diff --git a/chrome/browser/media/webrtc/webrtc_event_log_uploader.cc b/chrome/browser/media/webrtc/webrtc_event_log_uploader.cc index 6c7da791..f7253cd 100644 --- a/chrome/browser/media/webrtc/webrtc_event_log_uploader.cc +++ b/chrome/browser/media/webrtc/webrtc_event_log_uploader.cc
@@ -34,17 +34,17 @@ constexpr size_t kExpectedMimeOverheadBytes = 1000; // Intentional overshot. // TODO(crbug.com/817495): Eliminate the duplication with other uploaders. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) const char kProduct[] = "Chrome"; -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) const char kProduct[] = "Chrome_Mac"; #elif BUILDFLAG(IS_CHROMEOS_ASH) const char kProduct[] = "Chrome_ChromeOS"; -#elif defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) +#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) const char kProduct[] = "Chrome_Linux"; -#elif defined(OS_ANDROID) +#elif BUILDFLAG(IS_ANDROID) const char kProduct[] = "Chrome_Android"; -#elif defined(OS_FUCHSIA) +#elif BUILDFLAG(IS_FUCHSIA) const char kProduct[] = "Chrome_Fuchsia"; #else #error Platform not supported.
diff --git a/chrome/browser/media/webrtc/webrtc_event_log_uploader_impl_unittest.cc b/chrome/browser/media/webrtc/webrtc_event_log_uploader_impl_unittest.cc index 40a9e83..cbd5678 100644 --- a/chrome/browser/media/webrtc/webrtc_event_log_uploader_impl_unittest.cc +++ b/chrome/browser/media/webrtc/webrtc_event_log_uploader_impl_unittest.cc
@@ -53,7 +53,7 @@ base::OnceClosure on_complete_callback_; }; -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) void RemovePermissions(const base::FilePath& path, int removed_permissions) { int permissions; ASSERT_TRUE(base::GetPosixFilePermissions(path, &permissions)); @@ -67,7 +67,7 @@ base::FILE_PERMISSION_READ_BY_OTHERS; RemovePermissions(path, read_permissions); } -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) } // namespace class WebRtcEventLogUploaderImplTest : public ::testing::Test { @@ -236,7 +236,7 @@ EXPECT_FALSE(base::PathExists(log_file_)); } -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) TEST_F(WebRtcEventLogUploaderImplTest, FailureToReadFileReportedToObserver) { // Show the failure was independent of the URLLoaderFactory's primed return // value. @@ -256,7 +256,7 @@ EXPECT_CALL(observer_, CompletionCallback(log_file_, false)).Times(1); StartAndWaitForUpload(); } -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) TEST_F(WebRtcEventLogUploaderImplTest, FilesUpToMaxSizeUploaded) { int64_t log_file_size_bytes;
diff --git a/chrome/browser/media/webrtc/webrtc_getdisplaymedia_browsertest.cc b/chrome/browser/media/webrtc/webrtc_getdisplaymedia_browsertest.cc index adc3216..75e5d962 100644 --- a/chrome/browser/media/webrtc/webrtc_getdisplaymedia_browsertest.cc +++ b/chrome/browser/media/webrtc/webrtc_getdisplaymedia_browsertest.cc
@@ -33,7 +33,7 @@ #include "third_party/blink/public/common/features.h" #include "ui/base/l10n/l10n_util.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "base/mac/mac_util.h" #include "chrome/browser/media/webrtc/system_media_capture_permissions_mac.h" #endif @@ -107,7 +107,7 @@ constraints.c_str()), &result)); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) if (!is_fake_ui && !is_tab_capture && system_media_permissions::CheckSystemScreenCapturePermission() != system_media_permissions::SystemPermission::kAllowed) { @@ -213,11 +213,11 @@ }; // TODO(1170479): Real desktop capture is flaky on below platforms. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_ScreenCaptureVideo DISABLED_ScreenCaptureVideo #else #define MAYBE_ScreenCaptureVideo ScreenCaptureVideo -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) IN_PROC_BROWSER_TEST_P(WebRtcScreenCaptureBrowserTestWithPicker, MAYBE_ScreenCaptureVideo) { ASSERT_TRUE(embedded_test_server()->Start()); @@ -271,18 +271,19 @@ #endif // BUILDFLAG(IS_CHROMEOS_ASH) // TODO(1170479): Real desktop capture is flaky on below platforms. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_ScreenCaptureVideoAndAudio DISABLED_ScreenCaptureVideoAndAudio // On linux debug bots, it's flaky as well. -#elif ((defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && !defined(NDEBUG)) +#elif ((BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && \ + !defined(NDEBUG)) #define MAYBE_ScreenCaptureVideoAndAudio DISABLED_ScreenCaptureVideoAndAudio // On linux asan bots, it's flaky as well - msan and other rel bot are fine. -#elif ((defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && \ +#elif ((BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && \ defined(ADDRESS_SANITIZER)) #define MAYBE_ScreenCaptureVideoAndAudio DISABLED_ScreenCaptureVideoAndAudio #else #define MAYBE_ScreenCaptureVideoAndAudio ScreenCaptureVideoAndAudio -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) IN_PROC_BROWSER_TEST_P(WebRtcScreenCaptureBrowserTestWithPicker, MAYBE_ScreenCaptureVideoAndAudio) { ASSERT_TRUE(embedded_test_server()->Start()); @@ -451,7 +452,7 @@ /*allowlisted_by_policy=*/true))); // Flaky on Win bots http://crbug.com/1264805 -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_ScreenShareFromEmbedded DISABLED_ScreenShareFromEmbedded #else #define MAYBE_ScreenShareFromEmbedded ScreenShareFromEmbedded
diff --git a/chrome/browser/media/webrtc/webrtc_interactive_uitest.cc b/chrome/browser/media/webrtc/webrtc_interactive_uitest.cc index ab37a849..f6a631d9 100644 --- a/chrome/browser/media/webrtc/webrtc_interactive_uitest.cc +++ b/chrome/browser/media/webrtc/webrtc_interactive_uitest.cc
@@ -30,7 +30,7 @@ #include "third_party/blink/public/common/features.h" #include "third_party/blink/public/common/switches.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "base/mac/mac_util.h" #endif @@ -148,7 +148,7 @@ void DetectVideoAndHangUp() { StartDetectingVideo(left_tab_, "remote-view"); StartDetectingVideo(right_tab_, "remote-view"); -#if !defined(OS_MAC) +#if !BUILDFLAG(IS_MAC) // Video is choppy on Mac OS X. http://crbug.com/443542. WaitForVideoToPlay(left_tab_); WaitForVideoToPlay(right_tab_); @@ -185,7 +185,7 @@ return; } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // TODO(jam): this test only on 10.12. if (base::mac::IsOS10_12()) return;
diff --git a/chrome/browser/media/webrtc/webrtc_log_buffer.h b/chrome/browser/media/webrtc/webrtc_log_buffer.h index 66b3c283f..d7c2a4c7 100644 --- a/chrome/browser/media/webrtc/webrtc_log_buffer.h +++ b/chrome/browser/media/webrtc/webrtc_log_buffer.h
@@ -11,7 +11,7 @@ #include "build/build_config.h" #include "components/webrtc_logging/common/partial_circular_buffer.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) const size_t kWebRtcLogSize = 1 * 1024 * 1024; // 1 MB #else const size_t kWebRtcLogSize = 6 * 1024 * 1024; // 6 MB
diff --git a/chrome/browser/media/webrtc/webrtc_log_uploader.cc b/chrome/browser/media/webrtc/webrtc_log_uploader.cc index aff1c0a..843c632 100644 --- a/chrome/browser/media/webrtc/webrtc_log_uploader.cc +++ b/chrome/browser/media/webrtc/webrtc_log_uploader.cc
@@ -345,23 +345,23 @@ const base::FilePath& incoming_rtp_dump, const base::FilePath& outgoing_rtp_dump, const std::map<std::string, std::string>& meta_data) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) const char product[] = "Chrome"; -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) const char product[] = "Chrome_Mac"; // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch // of lacros-chrome is complete. -#elif defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) +#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) #if !defined(ADDRESS_SANITIZER) const char product[] = "Chrome_Linux"; #else const char product[] = "Chrome_Linux_ASan"; #endif -#elif defined(OS_ANDROID) +#elif BUILDFLAG(IS_ANDROID) const char product[] = "Chrome_Android"; #elif BUILDFLAG(IS_CHROMEOS_ASH) const char product[] = "Chrome_ChromeOS"; -#elif defined(OS_FUCHSIA) +#elif BUILDFLAG(IS_FUCHSIA) const char product[] = "Chrome_Fuchsia"; #else #error Platform not supported.
diff --git a/chrome/browser/media/webrtc/webrtc_logging_controller.cc b/chrome/browser/media/webrtc/webrtc_logging_controller.cc index 7b02c6a..9021cf7 100644 --- a/chrome/browser/media/webrtc/webrtc_logging_controller.cc +++ b/chrome/browser/media/webrtc/webrtc_logging_controller.cc
@@ -17,6 +17,7 @@ #include "base/task/post_task.h" #include "base/task/task_runner_util.h" #include "base/threading/sequenced_task_runner_handle.h" +#include "build/build_config.h" #include "chrome/browser/media/webrtc/webrtc_event_log_manager.h" #include "chrome/browser/media/webrtc/webrtc_log_uploader.h" #include "chrome/browser/media/webrtc/webrtc_rtp_dump_handler.h" @@ -24,10 +25,10 @@ #include "content/public/browser/browser_context.h" #include "content/public/browser/render_process_host.h" -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #include "content/public/browser/child_process_security_policy.h" #include "storage/browser/file_system/isolated_context.h" -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) using webrtc_event_logging::WebRtcEventLogManager; @@ -281,7 +282,7 @@ web_app_id, callback); } -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) void WebRtcLoggingController::GetLogsDirectory( LogsDirectoryCallback callback, LogsDirectoryErrorCallback error_callback) { @@ -327,7 +328,7 @@ FROM_HERE, base::BindOnce(std::move(callback), file_system.id(), registered_name)); } -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) void WebRtcLoggingController::OnRtpPacket( std::unique_ptr<uint8_t[]> packet_header,
diff --git a/chrome/browser/media/webrtc/webrtc_logging_controller.h b/chrome/browser/media/webrtc/webrtc_logging_controller.h index dd02964..a287a38 100644 --- a/chrome/browser/media/webrtc/webrtc_logging_controller.h +++ b/chrome/browser/media/webrtc/webrtc_logging_controller.h
@@ -132,13 +132,13 @@ size_t web_app_id, const StartEventLoggingCallback& callback); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Ensures that the WebRTC Logs directory exists and then grants render // process access to the 'WebRTC Logs' directory, and invokes |callback| with // the ids necessary to create a DirectoryEntry object. void GetLogsDirectory(LogsDirectoryCallback callback, LogsDirectoryErrorCallback error_callback); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // chrome::mojom::WebRtcLoggingClient methods: void OnAddMessages( @@ -191,7 +191,7 @@ bool success, const std::string& error_message); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Grants the render process access to the 'WebRTC Logs' directory, and // invokes |callback| with the ids necessary to create a DirectoryEntry // object. If the |logs_path| couldn't be created or found, |error_callback| @@ -199,7 +199,7 @@ void GrantLogsDirectoryAccess(LogsDirectoryCallback callback, LogsDirectoryErrorCallback error_callback, const base::FilePath& logs_path); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) static base::FilePath GetLogDirectoryAndEnsureExists( const base::FilePath& browser_context_directory_path);
diff --git a/chrome/browser/media/webrtc/webrtc_mediadevices_interactive_uitest.cc b/chrome/browser/media/webrtc/webrtc_mediadevices_interactive_uitest.cc index 6e6cd41a..e23839c 100644 --- a/chrome/browser/media/webrtc/webrtc_mediadevices_interactive_uitest.cc +++ b/chrome/browser/media/webrtc/webrtc_mediadevices_interactive_uitest.cc
@@ -34,7 +34,7 @@ #include "media/base/media_switches.h" #include "net/test/embedded_test_server/embedded_test_server.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include <CoreGraphics/CoreGraphics.h> #endif @@ -405,8 +405,8 @@ IN_PROC_BROWSER_TEST_F(WebRtcMediaDevicesPrerenderingBrowserTest, EnumerateDevicesInPrerendering) { -#if defined(OS_MAC) - // Test will fail if the window it's runnig in contains the mouse pointer. +#if BUILDFLAG(IS_MAC) + // Test will fail if the window it's running in contains the mouse pointer. // Here we warp the cursor, hopefully, out of the window. CGWarpMouseCursorPosition({0, 0}); #endif
diff --git a/chrome/browser/media/webrtc/webrtc_rtp_dump_writer_unittest.cc b/chrome/browser/media/webrtc/webrtc_rtp_dump_writer_unittest.cc index ac0cafc..18b7139 100644 --- a/chrome/browser/media/webrtc/webrtc_rtp_dump_writer_unittest.cc +++ b/chrome/browser/media/webrtc/webrtc_rtp_dump_writer_unittest.cc
@@ -281,7 +281,7 @@ } // Flaky test disabled on Windows (https://crbug.com/1044271). -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_WriteOverMaxLimit DISABLED_WriteOverMaxLimit #else #define MAYBE_WriteOverMaxLimit WriteOverMaxLimit
diff --git a/chrome/browser/media/webrtc/webrtc_stats_perf_browsertest.cc b/chrome/browser/media/webrtc/webrtc_stats_perf_browsertest.cc index 3233cc8..11c8098 100644 --- a/chrome/browser/media/webrtc/webrtc_stats_perf_browsertest.cc +++ b/chrome/browser/media/webrtc/webrtc_stats_perf_browsertest.cc
@@ -320,7 +320,7 @@ } // TODO(crbug.com/1241344): test fails on some mac bots. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_MANUAL_RunsAudioAndVideoCallCollectingMetrics_VideoCodec_VP9Profile2 \ DISABLED_MANUAL_RunsAudioAndVideoCallCollectingMetrics_VideoCodec_VP9Profile2 #else
diff --git a/chrome/browser/media/webrtc/webrtc_text_log_handler.cc b/chrome/browser/media/webrtc/webrtc_text_log_handler.cc index a7c3224..1b673646 100644 --- a/chrome/browser/media/webrtc/webrtc_text_log_handler.cc +++ b/chrome/browser/media/webrtc/webrtc_text_log_handler.cc
@@ -42,12 +42,12 @@ #include "net/base/network_interfaces.h" #include "services/network/public/mojom/network_service.mojom.h" -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #include "base/linux_util.h" #include "base/task/thread_pool.h" #endif -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "base/mac/mac_util.h" #endif @@ -412,7 +412,7 @@ void WebRtcTextLogHandler::OnGetNetworkInterfaceList( GenericDoneCallback callback, const absl::optional<net::NetworkInterfaceList>& networks) { -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Hop to a background thread to get the distro string, which can block. base::ThreadPool::PostTaskAndReplyWithResult( FROM_HERE, {base::MayBlock()}, base::BindOnce(&base::GetLinuxDistro), @@ -458,7 +458,7 @@ LogToCircularBuffer(base::SysInfo::OperatingSystemName() + " " + base::SysInfo::OperatingSystemVersion() + " " + base::SysInfo::OperatingSystemArchitecture()); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) { LogToCircularBuffer("Linux distribution: " + linux_distro); } #endif @@ -473,7 +473,7 @@ // Computer model std::string computer_model = "Not available"; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) computer_model = base::mac::GetModelIdentifier(); #elif BUILDFLAG(IS_CHROMEOS_ASH) chromeos::system::StatisticsProvider::GetInstance()->GetMachineStatistic(
diff --git a/chrome/browser/media/webrtc/webrtc_video_quality_browsertest.cc b/chrome/browser/media/webrtc/webrtc_video_quality_browsertest.cc index 90be6fb..cbd89497 100644 --- a/chrome/browser/media/webrtc/webrtc_video_quality_browsertest.cc +++ b/chrome/browser/media/webrtc/webrtc_video_quality_browsertest.cc
@@ -49,7 +49,7 @@ } // namespace static const base::FilePath::CharType kFrameAnalyzerExecutable[] = -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) FILE_PATH_LITERAL("frame_analyzer.exe"); #else FILE_PATH_LITERAL("frame_analyzer"); @@ -347,7 +347,7 @@ // component build. // TODO(crbug.com/1008766): re-enable when flakiness is investigated, diagnosed // and resolved. -#if defined(OS_WIN) || defined(COMPONENT_BUILD) +#if BUILDFLAG(IS_WIN) || defined(COMPONENT_BUILD) #define MAYBE_MANUAL_TestVideoQualityVp9 DISABLED_MANUAL_TestVideoQualityVp9 #else #define MAYBE_MANUAL_TestVideoQualityVp9 MANUAL_TestVideoQualityVp9 @@ -362,7 +362,7 @@ // Flaky on mac (crbug.com/754684) and WebRTC's frame_analyzer doesn't build // from a Chromium's component build. -#if defined(OS_MAC) || defined(COMPONENT_BUILD) +#if BUILDFLAG(IS_MAC) || defined(COMPONENT_BUILD) #define MAYBE_MANUAL_TestVideoQualityH264 DISABLED_MANUAL_TestVideoQualityH264 #else #define MAYBE_MANUAL_TestVideoQualityH264 MANUAL_TestVideoQualityH264
diff --git a/chrome/browser/media/webrtc/webrtc_webcam_browsertest.cc b/chrome/browser/media/webrtc/webrtc_webcam_browsertest.cc index f8ad96e..8ee180d 100644 --- a/chrome/browser/media/webrtc/webrtc_webcam_browsertest.cc +++ b/chrome/browser/media/webrtc/webrtc_webcam_browsertest.cc
@@ -25,14 +25,14 @@ enum class TargetVideoCaptureImplementation { DEFAULT, -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) WIN_MEDIA_FOUNDATION #endif }; const TargetVideoCaptureImplementation kTargetVideoCaptureImplementations[] = { TargetVideoCaptureImplementation::DEFAULT, -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) TargetVideoCaptureImplementation::WIN_MEDIA_FOUNDATION #endif }; @@ -47,7 +47,7 @@ public testing::WithParamInterface<TargetVideoCaptureImplementation> { public: WebRtcWebcamBrowserTest() { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) if (GetParam() == TargetVideoCaptureImplementation::WIN_MEDIA_FOUNDATION) { scoped_feature_list_.InitAndEnableFeature( media::kMediaFoundationVideoCapture);
diff --git a/chrome/browser/media/wv_test_license_server_config.cc b/chrome/browser/media/wv_test_license_server_config.cc index 7cd95ff..c99eae7 100644 --- a/chrome/browser/media/wv_test_license_server_config.cc +++ b/chrome/browser/media/wv_test_license_server_config.cc
@@ -70,7 +70,7 @@ // Needed to dynamically load .so libraries used by license server. // TODO(shadi): Remove need to set env variable once b/12932983 is fixed. -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) std::unique_ptr<base::Environment> env(base::Environment::Create()); const char kLibraryPathEnvVarName[] = "LD_LIBRARY_PATH"; std::string library_paths(license_server_path.DirName().value()); @@ -78,7 +78,7 @@ if (env->GetVar(kLibraryPathEnvVarName, &old_path)) library_paths.append(":").append(old_path); env->SetVar(kLibraryPathEnvVarName, library_paths); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Since it is a Python command line, we need to AppendArg instead of // AppendSwitch so that the arguments are passed to the Python server instead @@ -131,11 +131,11 @@ bool WVTestLicenseServerConfig::IsPlatformSupported() { // TODO(crbug.com/1175344): Reenable OS_LINUX once license server // (or Widevine CDM) updated. -#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_64) +#if BUILDFLAG(IS_CHROMEOS) && defined(ARCH_CPU_X86_64) return true; #else return false; -#endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_64) +#endif // BUILDFLAG(IS_CHROMEOS) && defined(ARCH_CPU_X86_64) } std::string WVTestLicenseServerConfig::GetServerURL() { @@ -147,12 +147,12 @@ GetLicenseServerRootPath(&server_root); // Platform-specific license server binary path relative to root. *path = -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) server_root.Append(FILE_PATH_LITERAL("linux")) .Append(FILE_PATH_LITERAL("license_server.py")); #else server_root.Append(FILE_PATH_LITERAL("unsupported_platform")); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) } void WVTestLicenseServerConfig::GetLicenseServerRootPath(
diff --git a/chrome/browser/nearby_sharing/scheduling/nearby_share_scheduler_base.cc b/chrome/browser/nearby_sharing/scheduling/nearby_share_scheduler_base.cc index cf37951..ff4ca18 100644 --- a/chrome/browser/nearby_sharing/scheduling/nearby_share_scheduler_base.cc +++ b/chrome/browser/nearby_sharing/scheduling/nearby_share_scheduler_base.cc
@@ -176,20 +176,20 @@ void NearbyShareSchedulerBase::SetLastAttemptTime( base::Time last_attempt_time) { - DictionaryPrefUpdateDeprecated(pref_service_, pref_name_) + DictionaryPrefUpdate(pref_service_, pref_name_) .Get() ->SetKey(kLastAttemptTimeKeyName, base::TimeToValue(last_attempt_time)); } void NearbyShareSchedulerBase::SetLastSuccessTime( base::Time last_success_time) { - DictionaryPrefUpdateDeprecated(pref_service_, pref_name_) + DictionaryPrefUpdate(pref_service_, pref_name_) .Get() ->SetKey(kLastSuccessTimeKeyName, base::TimeToValue(last_success_time)); } void NearbyShareSchedulerBase::SetNumConsecutiveFailures(size_t num_failures) { - DictionaryPrefUpdateDeprecated(pref_service_, pref_name_) + DictionaryPrefUpdate(pref_service_, pref_name_) .Get() ->SetStringKey(kNumConsecutiveFailuresKeyName, base::NumberToString(num_failures)); @@ -197,7 +197,7 @@ void NearbyShareSchedulerBase::SetHasPendingImmediateRequest( bool has_pending_immediate_request) { - DictionaryPrefUpdateDeprecated(pref_service_, pref_name_) + DictionaryPrefUpdate(pref_service_, pref_name_) .Get() ->SetBoolKey(kHasPendingImmediateRequestKeyName, has_pending_immediate_request); @@ -205,7 +205,7 @@ void NearbyShareSchedulerBase::SetIsWaitingForResult( bool is_waiting_for_result) { - DictionaryPrefUpdateDeprecated(pref_service_, pref_name_) + DictionaryPrefUpdate(pref_service_, pref_name_) .Get() ->SetBoolKey(kIsWaitingForResultKeyName, is_waiting_for_result); }
diff --git a/chrome/browser/new_tab_page/modules/task_module/task_module_service.cc b/chrome/browser/new_tab_page/modules/task_module/task_module_service.cc index 3ea37ca..6b071b2 100644 --- a/chrome/browser/new_tab_page/modules/task_module/task_module_service.cc +++ b/chrome/browser/new_tab_page/modules/task_module/task_module_service.cc
@@ -256,8 +256,8 @@ void TaskModuleService::DismissTask( task_module::mojom::TaskModuleType task_module_type, const std::string& task_name) { - ListPrefUpdateDeprecated update(profile_->GetPrefs(), - GetDismissedTasksPrefName(task_module_type)); + ListPrefUpdate update(profile_->GetPrefs(), + GetDismissedTasksPrefName(task_module_type)); base::Value task_name_value(task_name); if (!base::Contains(update->GetList(), task_name_value)) update->Append(std::move(task_name_value)); @@ -266,8 +266,8 @@ void TaskModuleService::RestoreTask( task_module::mojom::TaskModuleType task_module_type, const std::string& task_name) { - ListPrefUpdateDeprecated update(profile_->GetPrefs(), - GetDismissedTasksPrefName(task_module_type)); + ListPrefUpdate update(profile_->GetPrefs(), + GetDismissedTasksPrefName(task_module_type)); update->EraseListValue(base::Value(task_name)); }
diff --git a/chrome/browser/new_tab_page/promos/promo_service.cc b/chrome/browser/new_tab_page/promos/promo_service.cc index 39e713b..0893ff2 100644 --- a/chrome/browser/new_tab_page/promos/promo_service.cc +++ b/chrome/browser/new_tab_page/promos/promo_service.cc
@@ -252,8 +252,7 @@ return; } - DictionaryPrefUpdateDeprecated update(profile_->GetPrefs(), - prefs::kNtpPromoBlocklist); + DictionaryPrefUpdate update(profile_->GetPrefs(), prefs::kNtpPromoBlocklist); double now = base::Time::Now().ToDeltaSinceWindowsEpoch().InSecondsF(); update->SetDoubleKey(promo_id, now); @@ -305,8 +304,8 @@ } if (!expired_ids.empty()) { - DictionaryPrefUpdateDeprecated update(profile_->GetPrefs(), - prefs::kNtpPromoBlocklist); + DictionaryPrefUpdate update(profile_->GetPrefs(), + prefs::kNtpPromoBlocklist); for (const std::string& key : expired_ids) update->RemoveKey(key); }
diff --git a/chrome/browser/new_tab_page/promos/promo_service_unittest.cc b/chrome/browser/new_tab_page/promos/promo_service_unittest.cc index f48a7d8..ef3866e 100644 --- a/chrome/browser/new_tab_page/promos/promo_service_unittest.cc +++ b/chrome/browser/new_tab_page/promos/promo_service_unittest.cc
@@ -206,7 +206,7 @@ feature_list.InitAndEnableFeature(ntp_features::kDismissPromos); { - DictionaryPrefUpdateDeprecated update(prefs(), prefs::kNtpPromoBlocklist); + DictionaryPrefUpdate update(prefs(), prefs::kNtpPromoBlocklist); base::Time recent = base::Time::Now() - base::Hours(2); update->SetDoubleKey("42", recent.ToDeltaSinceWindowsEpoch().InSecondsF()); } @@ -264,7 +264,7 @@ feature_list.InitAndEnableFeature(ntp_features::kDismissPromos); { - DictionaryPrefUpdateDeprecated update(prefs(), prefs::kNtpPromoBlocklist); + DictionaryPrefUpdate update(prefs(), prefs::kNtpPromoBlocklist); ASSERT_EQ(0u, update->DictSize()); base::Time past = base::Time::Now() - base::Days(365); update->SetDoubleKey("42", past.ToDeltaSinceWindowsEpoch().InSecondsF()); @@ -298,7 +298,7 @@ feature_list.InitAndEnableFeature(ntp_features::kDismissPromos); { - DictionaryPrefUpdateDeprecated update(prefs(), prefs::kNtpPromoBlocklist); + DictionaryPrefUpdate update(prefs(), prefs::kNtpPromoBlocklist); ASSERT_EQ(0u, update->DictSize()); update->SetDoubleKey("42", 5); update->SetStringKey("84", "wrong type");
diff --git a/chrome/browser/optimization_guide/optimization_guide_keyed_service_browsertest.cc b/chrome/browser/optimization_guide/optimization_guide_keyed_service_browsertest.cc index e4bf849..be072dc 100644 --- a/chrome/browser/optimization_guide/optimization_guide_keyed_service_browsertest.cc +++ b/chrome/browser/optimization_guide/optimization_guide_keyed_service_browsertest.cc
@@ -636,11 +636,11 @@ } #endif -class OptimizationGuideKeyedServiceDataSaverUserWithInfobarShownTest +class OptimizationGuideKeyedServicePermissionsCheckDisabledTest : public OptimizationGuideKeyedServiceBrowserTest { public: - OptimizationGuideKeyedServiceDataSaverUserWithInfobarShownTest() = default; - ~OptimizationGuideKeyedServiceDataSaverUserWithInfobarShownTest() override = + OptimizationGuideKeyedServicePermissionsCheckDisabledTest() = default; + ~OptimizationGuideKeyedServicePermissionsCheckDisabledTest() override = default; void SetUp() override { @@ -659,7 +659,9 @@ void SetUpCommandLine(base::CommandLine* cmd) override { OptimizationGuideKeyedServiceBrowserTest::SetUpCommandLine(cmd); - cmd->AppendSwitch("enable-spdy-proxy-auth"); + cmd->AppendSwitch(optimization_guide::switches:: + kDisableCheckingUserPermissionsForTesting); + // Add switch to avoid racing navigations in the test. cmd->AppendSwitch(optimization_guide::switches:: kDisableFetchingHintsAtNavigationStartForTesting); @@ -670,7 +672,7 @@ }; IN_PROC_BROWSER_TEST_F( - OptimizationGuideKeyedServiceDataSaverUserWithInfobarShownTest, + OptimizationGuideKeyedServicePermissionsCheckDisabledTest, RemoteFetchingAllowed) { // ChromeOS has multiple profiles and optimization guide currently does not // run on non-Android. @@ -683,7 +685,7 @@ } IN_PROC_BROWSER_TEST_F( - OptimizationGuideKeyedServiceDataSaverUserWithInfobarShownTest, + OptimizationGuideKeyedServicePermissionsCheckDisabledTest, IncognitoCanStillReadFromComponentHints) { // Wait until initialization logic finishes running and component pushed to // both incognito and regular browsers. @@ -714,7 +716,7 @@ } IN_PROC_BROWSER_TEST_F( - OptimizationGuideKeyedServiceDataSaverUserWithInfobarShownTest, + OptimizationGuideKeyedServicePermissionsCheckDisabledTest, IncognitoStillProcessesBloomFilter) { PushHintsComponentAndWaitForCompletion();
diff --git a/chrome/browser/page_load_metrics/observers/core/LCP.md b/chrome/browser/page_load_metrics/observers/core/LCP.md new file mode 100644 index 0000000..ac1eb42 --- /dev/null +++ b/chrome/browser/page_load_metrics/observers/core/LCP.md
@@ -0,0 +1,86 @@ +# Largest Contentful Paint + +[Largest Contentful Paint](https://web.dev/lcp) is a [Core Web Vital](https://web.dev/vitals) metric that reports the time until the largest image or text element is painted to the screen, as a heuristic for page load time. + +This document details: +* [Where it is computed in the renderer](#Computation-in-Renderer) +* [How it is reported in trace events and web performance APIs](#Reporting-in-web-performance-APIs-and-trace-events) +* [How values from different frames are merged](#Merging-multiple-frames) +* [How it is reported to UKM/UMA](#Reporting-in-UKM-and-UMA) + +## Computation in Renderer + +Since largest contentful paint can report either the largest text block or the +largest image, there are parallel classes in the renderer which track images and +text. + +* [`PaintTimingDetector`](/third_party/blink/renderer/core/paint/paint_timing_detector.h) + provides common infrastructure between image and text paint tracking. Its + `NotifyTextPaint` and `NotifyImagePaint` methods are called by the paint code + as text and image paints occur. It tracks the largest image and text paint + size and time, and calls + [`DocumentLoader::DidChangePerformanceTiming()`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/loader/document_loader.cc;l=639;drc=bff7fcba732aa420926466bf53dbd1d9504ba22f) + which eventually results in a mojo IPC being scheduled in + [`PageTimingMetricsSender::Update`()](https://source.chromium.org/chromium/chromium/src/+/main:components/page_load_metrics/renderer/page_timing_metrics_sender.cc;l=103;drc=054e08864177603f17edbc111db7ebc8586906bd;bpv=1;bpt=1?q=page_timing_metrics_sender.h&ss=chromium%2Fchromium%2Fsrc). + (More info on the data flow + [here](../../passing_data_from_renderer_to_browser.md)). + + In this codepath, + [`MetricsRenderFrameObserver::GetTiming()`](https://source.chromium.org/chromium/chromium/src/+/main:components/page_load_metrics/renderer/metrics_render_frame_observer.cc;l=5;drc=bff7fcba732aa420926466bf53dbd1d9504ba22f;bpv=1;bpt=1?q=metrics_render_frame_&ss=chromium%2Fchromium%2Fsrc) + gets the values to report to the browser process about the largest contentful + image and text from `WebPerformance`, which gets them from + [`LargestContentfulPaintCalculator`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/paint/largest_contentful_paint_calculator.cc;l=73;drc=11b5b115b432e67d5c2a572d11cebe6a81ced05e). +* [`ImagePaintTimingDetector`](/third_party/blink/renderer/core/paint/image_paint_timing_detector.cc) + manages records of image paints in a frame and tracks the largest. +* [`TextPaintTimingDetector`](/third_party/blink/renderer/core/paint/text_paint_timing_detector.h) + manages records of text paints in a frame and tracks the largest. +* [`LargestContentfulPaintCalculator`](/third_party/blink/renderer/core/paint/largest_contentful_paint_calculator.h) + reports new largest image and text paints to performance timeline and tracing. + +## Reporting in web performance APIs and trace events + +* The [Largest Contentful Paint API](https://wicg.github.io/largest-contentful-paint/) + reports each candidate (the largest contentful paint *so far*) as it is + painted. + + [`LargestContentfulPaintCalculator::UpdateLargestContentfulPaintCandidate()`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/paint/largest_contentful_paint_calculator.cc;l=25;drc=bff7fcba732aa420926466bf53dbd1d9504ba22f;bpv=1;bpt=1) + is called from the paint timing detector each time a new largest text + or image candidate is found. If the candidate is larger than the previous + largest candidate of either type, either `UpdateLargestContentfulImage()` or + `UpdateLargestContentfulText()` is called, depending on the type of the + new largest candidate. Both methods call + [`WindowPerformance::OnLargestContentfulPaintUpdated()`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/timing/window_performance.cc;l=655;drc=bff7fcba732aa420926466bf53dbd1d9504ba22f), + which report the timing via the API. +* Each of the above methods also emits a trace event with the following + categories: "loading,rail,devtools.timeline". The title of the trace event is + "largestContentfulPaint::Candidate". + +## Merging multiple frames + +The data is sent from renderer to browser via the page load metrics +infrastructure. +[You can read more about the data flow here](../../passing_data_from_renderer_to_browser.md). + +In the browser, PageLoadMetricsObservers can call +`GetDelegate().GetLargestContentfulPaintHandler().MergeMainFrameAndSubFrames()`. + +[`LargestContentfulPaintHandler::MergeMainFrameAndSubframes()`](https://source.chromium.org/chromium/chromium/src/+/main:components/page_load_metrics/browser/observers/core/largest_contentful_paint_handler.cc;l=225;drc=bff7fcba732aa420926466bf53dbd1d9504ba22f;bpv=1;bpt=1) +returns the largest text or image candidate across the main frame and all +subframes. + +## Reporting in UKM and UMA + +All Core Web Vitals UKM are reported via +[PageLoadMetricsObserver](/chrome/browser/page_load_metrics/observers/README.md). +This ensures consistent reporting of only main frames, excluding error pages, +etc. + +UKM for LCP are: +* Most navigations: `PageLoad.PaintTiming.NavigationToLargestContentfulPaint2` +* BFCache navigations: + `HistoryNavigation.NavigationToFirstPaintAfterBackForwardCacheRestore` + +UMA for LCP are: +* Most navigations: `PageLoad.PaintTiming.NavigationToLargestContentfulPaint2` +* BFCache navigations: + `PageLoad.PaintTiming.NavigationToFirstPaint.BFCachePolyfillSecond` \ No newline at end of file
diff --git a/chrome/browser/page_load_metrics/passing_data_from_renderer_to_browser.md b/chrome/browser/page_load_metrics/passing_data_from_renderer_to_browser.md new file mode 100644 index 0000000..59422a3 --- /dev/null +++ b/chrome/browser/page_load_metrics/passing_data_from_renderer_to_browser.md
@@ -0,0 +1,65 @@ +# How data is passed from renderer to browser for page load metrics observers + +1. Blink's core rendering code hooks into a "detector" that implements the + semantics of the metric. Example: + [`PaintTimingDetector`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/paint/paint_timing_detector.cc). + (This is more of a convention and not a specific shared interface.) + +2. The detector notifies the + [LocalFrameClient](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/frame/local_frame_client.h) + that the metric's value has changed. For some metrics, this uses the generic + `DidChangePerformanceTiming` method, but other metrics have dedicated methods + on this interface. + +3. The `LocalFrameClientImpl` notifies the + [`RenderFrame`](https://source.chromium.org/chromium/chromium/src/+/main:content/public/renderer/render_frame.h) + that the metric's value has changed. + +4. The `RenderFrameImpl` notifies `PageLoadMetrics`' + [`MetricsRenderFrameObserver`](https://source.chromium.org/chromium/chromium/src/+/main:components/page_load_metrics/renderer/metrics_render_frame_observer.h) + (through a generic observer interface) that the metric's value has changed. + +5. Sometimes, new data is passed in to `MetricsRenderFrameObserver` in the same + method that notifies it of the change. + + But for metrics that rely on `DidChangePerformanceTiming`, + `MetricsRenderFrameObserver` has to go back to Blink to ask for the actual + data, by querying the [`WebPerformance`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/public/web/web_performance.h) + object, which in turn queries the detector from step 1. + +6. `MetricsRenderFrameObserver` passes the new data into `PageLoadMetrics`'s + [`PageTimingMetricsSender`](https://source.chromium.org/chromium/chromium/src/+/main:components/page_load_metrics/renderer/page_timing_metrics_sender.h. + +7. `PageTimingMetricsSender` [buffers](http://go/plm-flushing) the data for up + to 1000 ms, then issues an IPC to the browser which is handled by + [`MetricsWebContentsObserver`](https://source.chromium.org/chromium/chromium/src/+/main:components/page_load_metrics/browser/metrics_web_contents_observer.h). + +8. `MetricsWebContentsObserver` passes the data to the + [`PageLoadMetricsUpdateDispatcher`](https://source.chromium.org/chromium/chromium/src/+/main:components/page_load_metrics/browser/page_load_metrics_update_dispatcher.h) + for the currently tracked page load. + +9. For some metrics, like FCP, `PageLoadMetricsUpdateDispatcher` "merges" + updates from all frames (using `PageLoadTimingMerger`) into a single + page-wide value, which it then passes up to its owner, the + [`PageLoadTracker`](https://source.chromium.org/chromium/chromium/src/+/main:components/page_load_metrics/browser/page_load_tracker.h). + + But for other metrics, `PageLoadMetricsUpdateDispatcher` passes per-frame + values up to `PageLoadTracker`. This is the case for LCP, which is merged by + a `PageLoadTracker`-owned object + ([`LargestContentfulPaintHandler`](https://source.chromium.org/chromium/chromium/src/+/main:components/page_load_metrics/browser/observers/core/largest_contentful_paint_handler.h)) + and not by `PageLoadMetricsUpdateDispatcher`. + +10. `PageLoadTracker` broadcasts metric values (some page-wide, some + frame-specific) to various + [`PageLoadMetricsObserver`](https://source.chromium.org/chromium/chromium/src/+/main:components/page_load_metrics/browser/page_load_metrics_observer.h) + implementers. Some metrics pass through the generic `OnTimingUpdate` + method, while others have dedicated methods on the observer interface. + +11. `PageLoadMetricsObserver` implementations like + [`UmaPageLoadMetricsObserver`](https://source.chromium.org/chromium/chromium/src/+/main:components/page_load_metrics/browser/observers/core/uma_page_load_metrics_observer.h) + and [`UkmPageLoadMetricsObserver`](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/page_load_metrics/observers/core/ukm_page_load_metrics_observer.h) + perform the final step of recording to UMA/UKM, calling into generic + components like + [`base::Histogram`](https://source.chromium.org/chromium/chromium/src/+/main:base/metrics/histogram.h) + and + [`UkmRecorder`](https://source.chromium.org/chromium/chromium/src/+/main:services/metrics/public/cpp/ukm_recorder.h). \ No newline at end of file
diff --git a/chrome/browser/payments/chrome_payment_request_delegate.cc b/chrome/browser/payments/chrome_payment_request_delegate.cc index 4ffbf2c..7806283 100644 --- a/chrome/browser/payments/chrome_payment_request_delegate.cc +++ b/chrome/browser/payments/chrome_payment_request_delegate.cc
@@ -66,7 +66,7 @@ } bool FrameSupportsPayments(content::RenderFrameHost* rfh) { - return rfh && rfh->IsActive() && + return rfh && rfh->IsActive() && rfh->IsRenderFrameLive() && rfh->IsFeatureEnabled( blink::mojom::PermissionsPolicyFeature::kPayment); } @@ -244,9 +244,16 @@ // displays the top-level origin in its UI before the user can click on the // [Verify] button to invoke this authenticator. auto* rfh = content::RenderFrameHost::FromID(frame_routing_id_); - return FrameSupportsPayments(rfh) - ? std::make_unique<content::InternalAuthenticatorImpl>(rfh) - : nullptr; + // Lifetime of the created authenticator is externally managed by the + // authenticator factory, but is generally tied to the RenderFrame by + // listening for `RenderFrameDeleted()`. `FrameSupportsPayments()` already + // performs this check on our behalf, so the DCHECK() here is just for + // documentation purposes: this ensures that `RenderFrameDeleted()` will be + // called at some point. + if (!FrameSupportsPayments(rfh)) + return nullptr; + DCHECK(rfh->IsRenderFrameLive()); + return std::make_unique<content::InternalAuthenticatorImpl>(rfh); } scoped_refptr<PaymentManifestWebDataService>
diff --git a/chrome/browser/plugins/plugin_prefs.cc b/chrome/browser/plugins/plugin_prefs.cc index ce965d7f..a86ac62 100644 --- a/chrome/browser/plugins/plugin_prefs.cc +++ b/chrome/browser/plugins/plugin_prefs.cc
@@ -113,8 +113,8 @@ } { // Scoped update of prefs::kPluginsPluginsList. - ListPrefUpdateDeprecated update(prefs_, prefs::kPluginsPluginsList); - base::ListValue* saved_plugins_list = update.Get(); + ListPrefUpdate update(prefs_, prefs::kPluginsPluginsList); + base::Value* saved_plugins_list = update.Get(); if (saved_plugins_list) { for (auto& plugin_value : saved_plugins_list->GetList()) { base::DictionaryValue* plugin;
diff --git a/chrome/browser/policy/browser_signin_policy_handler.cc b/chrome/browser/policy/browser_signin_policy_handler.cc index 6a0f28a3..d10a50c 100644 --- a/chrome/browser/policy/browser_signin_policy_handler.cc +++ b/chrome/browser/policy/browser_signin_policy_handler.cc
@@ -29,7 +29,7 @@ void BrowserSigninPolicyHandler::ApplyPolicySettings(const PolicyMap& policies, PrefValueMap* prefs) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Browser sign in policies shouldn't be enforced on gcpw signin // mode as gcpw is invoked in windows login UI screen. // Also note that GCPW launches chrome in incognito mode using a @@ -43,13 +43,13 @@ const base::Value* value = policies.GetValue(policy_name()); switch (static_cast<BrowserSigninMode>(value->GetInt())) { case BrowserSigninMode::kForced: -#if !defined(OS_LINUX) && !defined(OS_CHROMEOS) +#if !BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS) prefs->SetValue(prefs::kForceBrowserSignin, base::Value(true)); #endif [[fallthrough]]; case BrowserSigninMode::kEnabled: prefs->SetValue( -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // The new kSigninAllowedOnNextStartup pref is only used on Desktop. // Keep the old kSigninAllowed pref for Android until the policy is // fully deprecated in M71 and can be removed. @@ -61,7 +61,7 @@ break; case BrowserSigninMode::kDisabled: prefs->SetValue( -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // The new kSigninAllowedOnNextStartup pref is only used on Desktop. // Keep the old kSigninAllowed pref for Android until the policy is // fully deprecated in M71 and can be removed.
diff --git a/chrome/browser/policy/chrome_browser_cloud_management_controller_desktop.cc b/chrome/browser/policy/chrome_browser_cloud_management_controller_desktop.cc index c0f4bfb..9be4e1ba 100644 --- a/chrome/browser/policy/chrome_browser_cloud_management_controller_desktop.cc +++ b/chrome/browser/policy/chrome_browser_cloud_management_controller_desktop.cc
@@ -34,42 +34,42 @@ #include "content/public/browser/network_service_instance.h" #include "services/network/public/cpp/shared_url_loader_factory.h" -#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) +#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) #include "base/base_paths_win.h" #include "chrome/install_static/install_modes.h" #else #include "chrome/common/chrome_switches.h" -#endif // defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) +#endif // BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "chrome/browser/app_controller_mac.h" #include "chrome/browser/policy/browser_dm_token_storage_mac.h" -#endif // defined(OS_MAC) +#endif // BUILDFLAG(IS_MAC) -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #include "chrome/browser/policy/browser_dm_token_storage_linux.h" -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "chrome/browser/policy/browser_dm_token_storage_win.h" #include "chrome/install_static/install_util.h" -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) -#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MAC) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC) #include "chrome/browser/enterprise/connectors/device_trust/device_trust_features.h" #include "chrome/browser/enterprise/connectors/device_trust/key_management/browser/device_trust_key_manager_impl.h" #include "chrome/browser/enterprise/connectors/device_trust/key_management/browser/key_rotation_launcher.h" -#endif // defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MAC) +#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC) -#if defined(OS_FUCHSIA) +#if BUILDFLAG(IS_FUCHSIA) #include "chrome/browser/policy/browser_dm_token_storage_fuchsia.h" -#endif // defined(OS_FUCHSIA) +#endif // BUILDFLAG(IS_FUCHSIA) namespace policy { namespace { -#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) +#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) constexpr base::FilePath::StringPieceType kCachedPolicyDirname = FILE_PATH_LITERAL("Policies"); #endif @@ -86,13 +86,13 @@ SetDMTokenStorageDelegate() { std::unique_ptr<BrowserDMTokenStorage::Delegate> storage_delegate; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) storage_delegate = std::make_unique<BrowserDMTokenStorageMac>(); -#elif defined(OS_LINUX) || defined(OS_CHROMEOS) +#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) storage_delegate = std::make_unique<BrowserDMTokenStorageLinux>(); -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) storage_delegate = std::make_unique<BrowserDMTokenStorageWin>(); -#elif defined(OS_FUCHSIA) +#elif BUILDFLAG(IS_FUCHSIA) storage_delegate = std::make_unique<BrowserDMTokenStorageFuchsia>(); #else NOTREACHED(); @@ -108,7 +108,7 @@ base::FilePath ChromeBrowserCloudManagementControllerDesktop::GetExternalPolicyDir() { base::FilePath external_policy_path; -#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) +#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) base::PathService::Get(base::DIR_PROGRAM_FILESX86, &external_policy_path); external_policy_path = @@ -153,7 +153,7 @@ kEnrollmentSuccess: case ChromeBrowserCloudManagementController::RegisterResult:: kEnrollmentFailedSilently: -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) app_controller_mac::EnterpriseStartupDialogClosed(); #endif return true; @@ -243,7 +243,7 @@ std::unique_ptr<enterprise_connectors::DeviceTrustKeyManager> ChromeBrowserCloudManagementControllerDesktop::CreateDeviceTrustKeyManager() { -#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MAC) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC) if (enterprise_connectors::IsDeviceTrustConnectorFeatureEnabled()) { auto key_rotation_launcher = enterprise_connectors::KeyRotationLauncher::Create( @@ -251,7 +251,7 @@ return std::make_unique<enterprise_connectors::DeviceTrustKeyManagerImpl>( std::move(key_rotation_launcher)); } -#endif // defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MAC) +#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC) return nullptr; }
diff --git a/chrome/browser/policy/chrome_browser_policy_connector.cc b/chrome/browser/policy/chrome_browser_policy_connector.cc index 85abf709..4c744b2 100644 --- a/chrome/browser/policy/chrome_browser_policy_connector.cc +++ b/chrome/browser/policy/chrome_browser_policy_connector.cc
@@ -39,18 +39,18 @@ #include "extensions/buildflags/buildflags.h" #include "services/network/public/cpp/shared_url_loader_factory.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/win/registry.h" #include "components/policy/core/common/policy_loader_win.h" -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) #include <CoreFoundation/CoreFoundation.h> #include "base/mac/foundation_util.h" #include "base/strings/sys_string_conversions.h" #include "components/policy/core/common/policy_loader_mac.h" #include "components/policy/core/common/preferences_mac.h" -#elif defined(OS_POSIX) && !defined(OS_ANDROID) +#elif BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) #include "components/policy/core/common/config_dir_policy_loader.h" -#elif defined(OS_ANDROID) +#elif BUILDFLAG(IS_ANDROID) #include "components/policy/core/common/android/android_combined_policy_provider.h" #endif @@ -60,13 +60,13 @@ #include "components/policy/core/common/proxy_policy_provider.h" #endif -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "chrome/browser/policy/chrome_browser_cloud_management_controller_android.h" #elif !BUILDFLAG(IS_CHROMEOS_ASH) #include "chrome/browser/policy/chrome_browser_cloud_management_controller_desktop.h" #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "chrome/browser/browser_switcher/browser_switcher_policy_migrator.h" #endif @@ -86,7 +86,7 @@ : BrowserPolicyConnector(base::BindRepeating(&BuildHandlerList)) { #if !BUILDFLAG(IS_CHROMEOS_ASH) std::unique_ptr<ChromeBrowserCloudManagementController::Delegate> delegate = -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) std::make_unique<ChromeBrowserCloudManagementControllerAndroid>(); #else std::make_unique<ChromeBrowserCloudManagementControllerDesktop>(); @@ -116,7 +116,7 @@ device_management_service->ScheduleInitialization( kServiceInitializationStartupDelay); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) policy_cache_updater_ = std::make_unique<android::PolicyCacheUpdater>( GetPolicyService(), GetHandlerList()); #endif @@ -256,14 +256,14 @@ std::unique_ptr<ConfigurationPolicyProvider> ChromeBrowserPolicyConnector::CreatePlatformProvider() { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) std::unique_ptr<AsyncPolicyLoader> loader(PolicyLoaderWin::Create( base::ThreadPool::CreateSequencedTaskRunner( {base::MayBlock(), base::TaskPriority::BEST_EFFORT}), ManagementServiceFactory::GetForPlatform(), kRegistryChromePolicyKey)); return std::make_unique<AsyncPolicyProvider>(GetSchemaRegistry(), std::move(loader)); -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) #if BUILDFLAG(GOOGLE_CHROME_BRANDING) // Explicitly watch the "com.google.Chrome" bundle ID, no matter what this // app's bundle ID actually is. All channels of Chrome should obey the same @@ -288,7 +288,7 @@ device_account_policy_loader_ = loader.get(); return std::make_unique<AsyncPolicyProvider>(GetSchemaRegistry(), std::move(loader)); -#elif defined(OS_POSIX) && !defined(OS_ANDROID) +#elif BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) base::FilePath config_dir_path; if (base::PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) { std::unique_ptr<AsyncPolicyLoader> loader(new ConfigDirPolicyLoader( @@ -300,7 +300,7 @@ } else { return nullptr; } -#elif defined(OS_ANDROID) +#elif BUILDFLAG(IS_ANDROID) return std::make_unique<policy::android::AndroidCombinedPolicyProvider>( GetSchemaRegistry()); #else
diff --git a/chrome/browser/policy/chrome_browser_policy_connector.h b/chrome/browser/policy/chrome_browser_policy_connector.h index d493b44..1dddd3b 100644 --- a/chrome/browser/policy/chrome_browser_policy_connector.h +++ b/chrome/browser/policy/chrome_browser_policy_connector.h
@@ -19,7 +19,7 @@ #include "components/policy/core/browser/browser_policy_connector.h" #include "components/policy/core/common/policy_service.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "components/policy/core/browser/android/policy_cache_updater_android.h" #endif @@ -169,9 +169,9 @@ machine_level_user_cloud_policy_manager_; #endif // !BUILDFLAG(IS_CHROMEOS_ASH) -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) std::unique_ptr<android::PolicyCacheUpdater> policy_cache_updater_; -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) // Owned by base class. raw_ptr<ConfigurationPolicyProvider> platform_provider_ = nullptr;
diff --git a/chrome/browser/policy/client_data_delegate_desktop_unittest.cc b/chrome/browser/policy/client_data_delegate_desktop_unittest.cc index 23f97e8..5ae033a 100644 --- a/chrome/browser/policy/client_data_delegate_desktop_unittest.cc +++ b/chrome/browser/policy/client_data_delegate_desktop_unittest.cc
@@ -15,17 +15,17 @@ #include "components/policy/proto/device_management_backend.pb.h" #include "testing/gtest/include/gtest/gtest.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/win/scoped_com_initializer.h" -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) namespace policy { TEST(ClientDataDelegateDesktopTest, FillRegisterBrowserRequest_BrowserDeviceIdentifier) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) base::win::ScopedCOMInitializer com_initializer; -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) base::test::TaskEnvironment task_environment; base::test::ScopedFeatureList scoped_feature_list( @@ -47,9 +47,9 @@ TEST(ClientDataDelegateDesktopTest, FillRegisterBrowserRequest_NoBrowserDeviceIdentifier) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) base::win::ScopedCOMInitializer com_initializer; -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) base::test::TaskEnvironment task_environment; base::test::ScopedFeatureList scoped_feature_list;
diff --git a/chrome/browser/policy/cloud/chrome_browser_cloud_management_browsertest.cc b/chrome/browser/policy/cloud/chrome_browser_cloud_management_browsertest.cc index a2ada58a..a957c9a 100644 --- a/chrome/browser/policy/cloud/chrome_browser_cloud_management_browsertest.cc +++ b/chrome/browser/policy/cloud/chrome_browser_cloud_management_browsertest.cc
@@ -59,18 +59,18 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "chrome/browser/policy/cloud/chrome_browser_cloud_management_browsertest_delegate_android.h" #else #include "chrome/browser/device_identity/device_oauth2_token_service.h" #include "chrome/browser/device_identity/device_oauth2_token_service_factory.h" #include "chrome/browser/policy/cloud/chrome_browser_cloud_management_browsertest_delegate_desktop.h" #include "chrome/browser/ui/browser_finder.h" -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "chrome/browser/policy/cloud/chrome_browser_cloud_management_browsertest_mac_util.h" -#endif // defined(OS_MAC) +#endif // BUILDFLAG(IS_MAC) using testing::_; using testing::DoAll; @@ -92,13 +92,13 @@ const char kUnenrollmentSuccessMetrics[] = "Enterprise.MachineLevelUserCloudPolicyEnrollment.UnenrollSuccess"; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) typedef ChromeBrowserCloudManagementBrowserTestDelegateAndroid ChromeBrowserCloudManagementBrowserTestDelegateType; #else typedef ChromeBrowserCloudManagementBrowserTestDelegateDesktop ChromeBrowserCloudManagementBrowserTestDelegateType; -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) void UpdatePolicyStorage(PolicyStorage* policy_storage) { em::CloudPolicySettings settings; @@ -392,13 +392,13 @@ EXPECT_NE(token_.empty(), expect_success); } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // TODO(http://crbug.com/1091438): Enable this test on Android once reporting is // implemented. #define MAYBE_ChromeDesktopReport DISABLED_ChromeDesktopReport #else #define MAYBE_ChromeDesktopReport ChromeDesktopReport -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) IN_PROC_BROWSER_TEST_P(ChromeBrowserCloudManagementServiceIntegrationTest, MAYBE_ChromeDesktopReport) { em::ChromeDesktopReportRequest chrome_desktop_report; @@ -579,7 +579,7 @@ }; // Consistently timing out on Windows. http://crbug.com/1025220 -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_Test DISABLED_Test #else #define MAYBE_Test Test @@ -595,7 +595,7 @@ delegate_.MaybeCheckTotalBrowserCount(1u); VerifyEnrollmentResult(); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Verify the last mericis of launch is recorded in // applicationDidFinishNotification. EXPECT_EQ(1u, histogram_tester_ @@ -604,7 +604,7 @@ #endif } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // No need to run this test with |should_display_error_message| equals true on // Android. INSTANTIATE_TEST_SUITE_P( @@ -620,7 +620,7 @@ ::testing::Combine(::testing::Bool(), ::testing::Bool(), ::testing::Bool())); -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) class MachineLevelUserCloudPolicyPolicyFetchObserver : public ChromeBrowserCloudManagementControllerObserver { @@ -715,13 +715,13 @@ base::ScopedTempDir temp_dir_; }; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Flaky on android-pie-x86-rel. https://crbug.com/1235367 IN_PROC_BROWSER_TEST_P(MachineLevelUserCloudPolicyPolicyFetchTest, DISABLED_Test) { #else IN_PROC_BROWSER_TEST_P(MachineLevelUserCloudPolicyPolicyFetchTest, Test) { -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) MachineLevelUserCloudPolicyManager* manager = g_browser_process->browser_policy_connector() ->machine_level_user_cloud_policy_manager(); @@ -802,7 +802,7 @@ ::testing::Combine(::testing::Values(kDMToken, kInvalidDMToken, ""), ::testing::Bool())); -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) class MachineLevelUserCloudPolicyRobotAuthTest : public PlatformBrowserTest { public: MachineLevelUserCloudPolicyRobotAuthTest() : observer_(&delegate_) { @@ -871,8 +871,8 @@ }; // namespace policy // Flaky on linux & win: https://crbug.com/1105167 -#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \ - defined(OS_MAC) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || \ + BUILDFLAG(IS_MAC) #define MAYBE_Test DISABLED_Test #else #define MAYBE_Test Test @@ -919,6 +919,6 @@ EXPECT_TRUE( DeviceOAuth2TokenServiceFactory::Get()->RefreshTokenIsAvailable()); } -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) } // namespace policy
diff --git a/chrome/browser/policy/cloud/chrome_browser_cloud_management_browsertest_delegate_desktop.cc b/chrome/browser/policy/cloud/chrome_browser_cloud_management_browsertest_delegate_desktop.cc index 3a801d3..be3e897 100644 --- a/chrome/browser/policy/cloud/chrome_browser_cloud_management_browsertest_delegate_desktop.cc +++ b/chrome/browser/policy/cloud/chrome_browser_cloud_management_browsertest_delegate_desktop.cc
@@ -9,9 +9,9 @@ #include "testing/gtest/include/gtest/gtest.h" #include "ui/views/test/widget_test.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "chrome/browser/policy/cloud/chrome_browser_cloud_management_browsertest_mac_util.h" -#endif // defined(OS_MAC) +#endif // BUILDFLAG(IS_MAC) namespace policy { @@ -19,7 +19,7 @@ MaybeCheckDialogClosingAfterPolicyRegistration(bool popup_expected) const { if (popup_expected) { MaybeCheckTotalBrowserCount(0u); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) PostAppControllerNSNotifications(); #endif // Close the error dialog.
diff --git a/chrome/browser/policy/cloud/cloud_policy_browsertest.cc b/chrome/browser/policy/cloud/cloud_policy_browsertest.cc index cadc21a..804ea04 100644 --- a/chrome/browser/policy/cloud/cloud_policy_browsertest.cc +++ b/chrome/browser/policy/cloud/cloud_policy_browsertest.cc
@@ -74,9 +74,9 @@ #include "components/signin/public/identity_manager/identity_test_utils.h" #endif -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) #include "chrome/browser/ui/browser.h" -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) using testing::_; using testing::AnyNumber;
diff --git a/chrome/browser/policy/cloud/cloud_policy_test_utils.cc b/chrome/browser/policy/cloud/cloud_policy_test_utils.cc index 93f52af..39284af4 100644 --- a/chrome/browser/policy/cloud/cloud_policy_test_utils.cc +++ b/chrome/browser/policy/cloud/cloud_policy_test_utils.cc
@@ -13,7 +13,7 @@ namespace policy { void GetExpectedDefaultPolicy(PolicyMap* policy_map) { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) policy_map->Set(key::kNTPContentSuggestionsEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_ENTERPRISE_DEFAULT, base::Value(false), nullptr);
diff --git a/chrome/browser/policy/cloud/component_cloud_policy_browsertest.cc b/chrome/browser/policy/cloud/component_cloud_policy_browsertest.cc index 8081e2d..7e093eb 100644 --- a/chrome/browser/policy/cloud/component_cloud_policy_browsertest.cc +++ b/chrome/browser/policy/cloud/component_cloud_policy_browsertest.cc
@@ -247,7 +247,7 @@ // crbug.com/1230268 not working on Lacros. // TODO(crbug.com/1254962): flaky on Mac builders -#if BUILDFLAG(IS_CHROMEOS_LACROS) || defined(OS_MAC) +#if BUILDFLAG(IS_CHROMEOS_LACROS) || BUILDFLAG(IS_MAC) #define MAYBE_FetchExtensionPolicy DISABLED_FetchExtensionPolicy #else #define MAYBE_FetchExtensionPolicy FetchExtensionPolicy @@ -261,7 +261,7 @@ // crbug.com/1230268 not working on Lacros. // TODO(crbug.com/1254962): flaky on Mac builders -#if BUILDFLAG(IS_CHROMEOS_LACROS) || defined(OS_MAC) +#if BUILDFLAG(IS_CHROMEOS_LACROS) || BUILDFLAG(IS_MAC) #define MAYBE_UpdateExtensionPolicy DISABLED_UpdateExtensionPolicy #else #define MAYBE_UpdateExtensionPolicy UpdateExtensionPolicy @@ -333,7 +333,7 @@ // policy caches are dropped, and that it's still possible to sign back in and // get policy for components working again. // Signing out on Lacros is not possible. -#if !defined(OS_CHROMEOS) +#if !BUILDFLAG(IS_CHROMEOS) IN_PROC_BROWSER_TEST_F(ComponentCloudPolicyTest, SignOutAndBackIn) { // Read the initial policy. ExtensionTestMessageListener initial_policy_listener(kTestPolicyJSON, true); @@ -393,7 +393,7 @@ // And the cache is back. EXPECT_TRUE(base::PathExists(cache_path)); } -#endif // !defined(OS_CHROMEOS) +#endif // !BUILDFLAG(IS_CHROMEOS) // Test of the component cloud policy when the policy test server is configured // to perform the signing key rotation for each policy fetch.
diff --git a/chrome/browser/policy/cloud/device_management_service_browsertest.cc b/chrome/browser/policy/cloud/device_management_service_browsertest.cc index 9d061da..b8e5bb04 100644 --- a/chrome/browser/policy/cloud/device_management_service_browsertest.cc +++ b/chrome/browser/policy/cloud/device_management_service_browsertest.cc
@@ -200,7 +200,7 @@ scoped_refptr<network::SharedURLLoaderFactory> test_shared_loader_factory_; }; -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) // Very flaky on ChromeOS: https://crbug.com/1262952 #define MAYBE_Registration DISABLED_Registration #else @@ -236,7 +236,7 @@ } // TODO(crbug.com/1254962): flaky on Mac builders -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_PolicyFetch DISABLED_PolicyFetch #else #define MAYBE_PolicyFetch PolicyFetch @@ -260,7 +260,7 @@ run_loop.Run(); } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Flaky on Mac: https://crbug.com/1254962 #define MAYBE_Unregistration DISABLED_Unregistration #else @@ -284,7 +284,7 @@ run_loop.Run(); } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Flaky on Mac: https://crbug.com/1254962 #define MAYBE_AutoEnrollment DISABLED_AutoEnrollment #else
diff --git a/chrome/browser/policy/cloud/user_policy_signin_service_browsertest.cc b/chrome/browser/policy/cloud/user_policy_signin_service_browsertest.cc index 35af0a3..a905f57 100644 --- a/chrome/browser/policy/cloud/user_policy_signin_service_browsertest.cc +++ b/chrome/browser/policy/cloud/user_policy_signin_service_browsertest.cc
@@ -464,7 +464,7 @@ // crbug.com/1230268 not working on Lacros. // TODO(crbug.com/1254962): flaky on Mac builders -#if BUILDFLAG(IS_CHROMEOS_LACROS) || defined(OS_MAC) +#if BUILDFLAG(IS_CHROMEOS_LACROS) || BUILDFLAG(IS_MAC) #define MAYBE_AcceptManagementDeclineSync DISABLED_AcceptManagementDeclineSync #else #define MAYBE_AcceptManagementDeclineSync AcceptManagementDeclineSync
diff --git a/chrome/browser/policy/cloud/user_policy_signin_service_factory.cc b/chrome/browser/policy/cloud/user_policy_signin_service_factory.cc index 44af5e6..a9a28a5 100644 --- a/chrome/browser/policy/cloud/user_policy_signin_service_factory.cc +++ b/chrome/browser/policy/cloud/user_policy_signin_service_factory.cc
@@ -18,7 +18,7 @@ #include "components/prefs/pref_service.h" #include "services/network/public/cpp/shared_url_loader_factory.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "chrome/browser/policy/cloud/user_policy_signin_service_mobile.h" #else #include "chrome/browser/policy/cloud/user_policy_signin_service.h" @@ -86,7 +86,7 @@ void UserPolicySigninServiceFactory::RegisterProfilePrefs( user_prefs::PrefRegistrySyncable* user_prefs) { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) user_prefs->RegisterInt64Pref(prefs::kLastPolicyCheckTime, 0); #endif }
diff --git a/chrome/browser/policy/cloud/user_policy_signin_service_mobile.cc b/chrome/browser/policy/cloud/user_policy_signin_service_mobile.cc index 4e5399b..bf04a68 100644 --- a/chrome/browser/policy/cloud/user_policy_signin_service_mobile.cc +++ b/chrome/browser/policy/cloud/user_policy_signin_service_mobile.cc
@@ -32,7 +32,7 @@ namespace { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) const em::DeviceRegisterRequest::Type kCloudPolicyRegistrationType = em::DeviceRegisterRequest::ANDROID_BROWSER; #else
diff --git a/chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc b/chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc index 7db6c42..30f4816 100644 --- a/chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc +++ b/chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc
@@ -57,7 +57,7 @@ #include "chromeos/lacros/lacros_test_helper.h" #endif -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "chrome/browser/policy/cloud/user_policy_signin_service_mobile.h" #else #include "chrome/browser/policy/cloud/user_policy_signin_service.h" @@ -338,7 +338,7 @@ ASSERT_FALSE(manager_->core()->service()); } -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) TEST_F(UserPolicySigninServiceTest, InitRefreshTokenAvailableBeforeSignin) { // Make sure user is not signed in. ASSERT_FALSE(identity_test_env()->identity_manager()->HasPrimaryAccount( @@ -365,12 +365,12 @@ EXPECT_EQ(mock_store_->signin_account_id(), test_account_id_); ASSERT_TRUE(IsRequestActive()); } -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) // TODO(joaodasilva): these tests rely on issuing the OAuth2 login refresh // token after signin. Revisit this after figuring how to handle that on // Android. -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) TEST_F(UserPolicySigninServiceSignedInTest, InitWhileSignedIn) { // UserCloudPolicyManager should be initialized. @@ -531,7 +531,7 @@ job_type); } -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) TEST_F(UserPolicySigninServiceSignedInTest, SignOutAfterInit) { // UserCloudPolicyManager should be initialized.
diff --git a/chrome/browser/policy/configuration_policy_handler_list_factory.cc b/chrome/browser/policy/configuration_policy_handler_list_factory.cc index 11eac87..3af8aff 100644 --- a/chrome/browser/policy/configuration_policy_handler_list_factory.cc +++ b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
@@ -108,11 +108,11 @@ #include "ppapi/buildflags/buildflags.h" #include "printing/buildflags/buildflags.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "chrome/browser/first_run/android/first_run_prefs.h" #include "chrome/browser/lens/android/lens_prefs.h" #include "chrome/browser/search/contextual_search_policy_handler_android.h" -#else // defined(OS_ANDROID) +#else // BUILDFLAG(IS_ANDROID) #include "chrome/browser/download/default_download_dir_policy_handler.h" #include "chrome/browser/download/download_auto_open_policy_handler.h" #include "chrome/browser/download/download_dir_policy_handler.h" @@ -123,13 +123,13 @@ #include "chrome/browser/policy/local_sync_policy_handler.h" #include "chrome/browser/policy/managed_account_policy_handler.h" #include "components/history_clusters/core/history_clusters_prefs.h" -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) -#if !defined(OS_CHROMEOS) +#if !BUILDFLAG(IS_CHROMEOS) #include "chrome/browser/policy/browser_signin_policy_handler.h" #else #include "chrome/browser/policy/system_features_disable_list_policy_handler.h" -#endif // !defined(OS_CHROMEOS) +#endif // !BUILDFLAG(IS_CHROMEOS) #if BUILDFLAG(IS_CHROMEOS_ASH) #include "ash/components/arc/arc_prefs.h" @@ -152,10 +152,10 @@ #include "components/user_manager/user_manager.h" #endif // BUILDFLAG(IS_CHROMEOS_ASH) -#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS) #include "chrome/browser/browser_switcher/browser_switcher_prefs.h" #include "chrome/browser/external_protocol/auto_launch_protocols_policy_handler.h" -#endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS) +#endif // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS) #if BUILDFLAG(ENABLE_EXTENSIONS) #include "chrome/browser/extensions/api/messaging/native_messaging_policy_handler.h" @@ -575,11 +575,11 @@ { key::kSitePerProcess, prefs::kSitePerProcess, base::Value::Type::BOOLEAN }, -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) { key::kSharedArrayBufferUnrestrictedAccessAllowed, prefs::kSharedArrayBufferUnrestrictedAccessAllowed, base::Value::Type::BOOLEAN }, -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) { key::kSandboxExternalProtocolBlocked, prefs::kSandboxExternalProtocolBlocked, base::Value::Type::BOOLEAN }, @@ -607,7 +607,7 @@ { key::kWebUsbBlockedForUrls, prefs::kManagedWebUsbBlockedForUrls, base::Value::Type::LIST }, -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) { key::kDefaultSerialGuardSetting, prefs::kManagedDefaultSerialGuardSetting, base::Value::Type::INTEGER }, @@ -620,7 +620,7 @@ { key::kSerialAllowAllPortsForUrls, prefs::kManagedSerialAllowAllPortsForUrls, base::Value::Type::LIST }, -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) { key::kDefaultFileHandlingGuardSetting, prefs::kManagedDefaultFileHandlingGuardSetting, base::Value::Type::INTEGER }, @@ -703,7 +703,7 @@ language::prefs::kForcedLanguages, base::Value::Type::LIST }, -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) { key::kDataCompressionProxyEnabled, data_reduction_proxy::prefs::kDataSaverEnabled, base::Value::Type::BOOLEAN }, @@ -722,7 +722,7 @@ { key::kWebXRImmersiveArEnabled, prefs::kWebXRImmersiveArEnabled, base::Value::Type::BOOLEAN }, -#else // defined(OS_ANDROID) +#else // BUILDFLAG(IS_ANDROID) { key::kDefaultInsecureContentSetting, prefs::kManagedDefaultInsecureContentSetting, base::Value::Type::INTEGER }, @@ -777,13 +777,13 @@ { key::kHistoryClustersVisible, history_clusters::prefs::kVisible, base::Value::Type::BOOLEAN }, -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) -#if !defined(OS_CHROMEOS) +#if !BUILDFLAG(IS_CHROMEOS) { key::kMetricsReportingEnabled, metrics::prefs::kMetricsReportingEnabled, base::Value::Type::BOOLEAN }, -#endif // !defined(OS_CHROMEOS) +#endif // !BUILDFLAG(IS_CHROMEOS) #if BUILDFLAG(IS_CHROMEOS_ASH) { key::kChromeOsLockOnIdleSuspend, @@ -1301,7 +1301,7 @@ base::Value::Type::BOOLEAN }, #endif // BUILDFLAG(IS_CHROMEOS_ASH) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) { key::kChromeCleanupEnabled, prefs::kSwReporterEnabled, base::Value::Type::BOOLEAN }, @@ -1332,23 +1332,23 @@ { key::kNetworkServiceSandboxEnabled, prefs::kNetworkServiceSandboxEnabled, base::Value::Type::BOOLEAN }, -#else // defined(OS_WIN) +#else // BUILDFLAG(IS_WIN) { key::kNtlmV2Enabled, prefs::kNtlmV2Enabled, base::Value::Type::BOOLEAN }, -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) -#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) +#if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) { key::kThirdPartyBlockingEnabled, prefs::kThirdPartyBlockingEnabled, base::Value::Type::BOOLEAN }, -#endif // defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) +#endif // BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) -#if defined(OS_WIN) || defined(OS_MAC) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) { key::kPrintPdfAsImageAvailability, prefs::kPrintPdfAsImageAvailability, base::Value::Type::BOOLEAN }, -#endif // defined(OS_WIN) || defined(OS_MAC) +#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) #if BUILDFLAG(ENABLE_PRINT_PREVIEW) { key::kPrintRasterizePdfDpi, @@ -1360,7 +1360,7 @@ base::Value::Type::BOOLEAN }, #endif // BUILDFLAGS(ENABLE_PRINT_PREVIEW) -#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS) { key::kNativeMessagingUserLevelHosts, extensions::pref_names::kNativeMessagingUserLevelHosts, base::Value::Type::BOOLEAN }, @@ -1415,9 +1415,9 @@ { key::kDesktopSharingHubEnabled, prefs::kDesktopSharingHubEnabled, base::Value::Type::BOOLEAN }, -#endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS) +#endif // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS) -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) { key::kLacrosSecondaryProfilesAllowed, prefs::kLacrosSecondaryProfilesAllowed, base::Value::Type::BOOLEAN }, @@ -1433,31 +1433,31 @@ { key::kDataLeakPreventionClipboardCheckSizeLimit, policy_prefs::kDlpClipboardCheckSizeLimit, base::Value::Type::INTEGER }, -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) -#if !defined(OS_MAC) && !defined(OS_CHROMEOS) +#if !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_CHROMEOS) { key::kBackgroundModeEnabled, prefs::kBackgroundModeEnabled, base::Value::Type::BOOLEAN }, -#endif // !defined(OS_MAC) && !defined(OS_CHROMEOS) +#endif // !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_CHROMEOS) -#if defined(OS_LINUX) || defined(OS_MAC) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS) { key::kAuthNegotiateDelegateByKdcPolicy, prefs::kAuthNegotiateDelegateByKdcPolicy, base::Value::Type::BOOLEAN }, -#endif // defined(OS_LINUX) || defined(OS_MAC) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS) -#if !defined(OS_MAC) +#if !BUILDFLAG(IS_MAC) { key::kFullscreenAllowed, prefs::kFullscreenAllowed, base::Value::Type::BOOLEAN }, -#endif // !defined(OS_MAC) +#endif // !BUILDFLAG(IS_MAC) -#if !defined(OS_MAC) && BUILDFLAG(ENABLE_EXTENSIONS) +#if !BUILDFLAG(IS_MAC) && BUILDFLAG(ENABLE_EXTENSIONS) { key::kFullscreenAllowed, extensions::pref_names::kAppFullscreenAllowed, base::Value::Type::BOOLEAN }, -#endif // !defined(OS_MAC) && BUILDFLAG(ENABLE_EXTENSIONS) +#endif // !BUILDFLAG(IS_MAC) && BUILDFLAG(ENABLE_EXTENSIONS) #if BUILDFLAG(ENABLE_EXTENSIONS) { key::kSecurityKeyPermitAttestation, @@ -1468,11 +1468,11 @@ base::Value::Type::BOOLEAN }, #endif // BUILDFLAG(ENABLE_EXTENSIONS) -#if !defined(OS_CHROMEOS) && BUILDFLAG(ENABLE_EXTENSIONS) +#if !BUILDFLAG(IS_CHROMEOS) && BUILDFLAG(ENABLE_EXTENSIONS) { key::kBlockExternalExtensions, extensions::pref_names::kBlockExternalExtensions, base::Value::Type::BOOLEAN }, -#endif // !defined(OS_CHROMEOS) && BUILDFLAG(ENABLE_EXTENSIONS) +#endif // !BUILDFLAG(IS_CHROMEOS) && BUILDFLAG(ENABLE_EXTENSIONS) #if BUILDFLAG(BUILTIN_CERT_VERIFIER_POLICY_SUPPORTED) { key::kBuiltinCertificateVerifierEnabled, @@ -1519,20 +1519,20 @@ { key::kTargetBlankImpliesNoOpener, policy::policy_prefs::kTargetBlankImpliesNoOpener, base::Value::Type::BOOLEAN }, -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) { key::kLensRegionSearchEnabled, prefs::kLensRegionSearchEnabled, base::Value::Type::BOOLEAN }, #endif -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) { key::kFetchKeepaliveDurationSecondsOnShutdown, prefs::kFetchKeepaliveDurationOnShutdown, base::Value::Type::INTEGER }, { key::kDeviceAttributesAllowedForOrigins, prefs::kDeviceAttributesAllowedForOrigins, base::Value::Type::LIST }, -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) { key::kSuppressDifferentOriginSubframeDialogs, prefs::kSuppressDifferentOriginSubframeJSDialogs, @@ -1550,7 +1550,7 @@ base::Value::Type::BOOLEAN }, #endif // BUILDFLAG(IS_CHROMEOS_ASH) -#if BUILDFLAG(ENABLE_EXTENSIONS) && (defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX)) +#if BUILDFLAG(ENABLE_EXTENSIONS) && (BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)) { key::kChromeAppsEnabled, extensions::pref_names::kChromeAppsEnabled, base::Value::Type::BOOLEAN }, @@ -1654,7 +1654,7 @@ handlers->AddHandler(std::make_unique<HomepageLocationPolicyHandler>()); handlers->AddHandler(std::make_unique<proxy_config::ProxyPolicyHandler>()); handlers->AddHandler(std::make_unique<SecureDnsPolicyHandler>()); -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) handlers->AddHandler(std::make_unique<SimpleSchemaValidatingPolicyHandler>( key::kSerialAllowUsbDevicesForUrls, prefs::kManagedSerialAllowUsbDevicesForUrls, chrome_schema, @@ -1663,7 +1663,7 @@ SimpleSchemaValidatingPolicyHandler::MANDATORY_ALLOWED)); handlers->AddHandler( std::make_unique<ManagedAccountRestrictionsPolicyHandler>(chrome_schema)); -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) handlers->AddHandler(std::make_unique<SimpleSchemaValidatingPolicyHandler>( key::kCertificateTransparencyEnforcementDisabledForUrls, certificate_transparency::prefs::kCTExcludedHosts, chrome_schema, @@ -1738,10 +1738,10 @@ key::kBrowsingDataLifetime, browsing_data::prefs::kBrowsingDataLifetime, chrome_schema)); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) handlers->AddHandler( std::make_unique<ContextualSearchPolicyHandlerAndroid>()); -#else // defined(OS_ANDROID) +#else // BUILDFLAG(IS_ANDROID) handlers->AddHandler( std::make_unique<NtpCustomBackgroundEnabledPolicyHandler>()); handlers->AddHandler(std::make_unique<DefaultDownloadDirPolicyHandler>()); @@ -1837,20 +1837,20 @@ handlers->AddHandler(std::make_unique<CopyPreventionSettingsPolicyHandler>( key::kCopyPreventionSettings, enterprise::content::kCopyPreventionSettings, chrome_schema)); -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) -#if defined(OS_LINUX) || defined(OS_MAC) || defined(OS_WIN) || \ - defined(OS_CHROMEOS) || defined(OS_FUCHSIA) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) || \ + BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_FUCHSIA) handlers->AddHandler( std::make_unique< enterprise_connectors::EnterpriseConnectorsPolicyHandler>( key::kContextAwareAccessSignalsAllowlist, enterprise_connectors::kContextAwareAccessSignalsAllowlistPref, chrome_schema)); -#endif // defined(OS_LINUX) || defined(OS_MAC) || defined(OS_WIN) || - // defined(OS_CHROMEOS) || defined(OS_FUCHSIA) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) || + // BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_FUCHSIA) -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) handlers->AddHandler(std::make_unique<extensions::ExtensionListPolicyHandler>( key::kAttestationExtensionAllowlist, prefs::kAttestationExtensionAllowlist, false)); @@ -1866,7 +1866,7 @@ key::kPrintingAPIExtensionsAllowlist, prefs::kPrintingAPIExtensionsAllowlist, /*allow_wildcards=*/false)); #endif // defined(USE_CUPS) -#else // defined(OS_CHROMEOS) +#else // BUILDFLAG(IS_CHROMEOS) std::vector<std::unique_ptr<ConfigurationPolicyHandler>> signin_legacy_policies; signin_legacy_policies.push_back(std::make_unique<SimplePolicyHandler>( @@ -1874,19 +1874,19 @@ base::Value::Type::BOOLEAN)); signin_legacy_policies.push_back(std::make_unique<SimplePolicyHandler>( key::kSigninAllowed, -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // The new kSigninAllowedOnNextStartup pref is only used on Desktop. // Keep the old kSigninAllowed pref for Android until the policy is // fully deprecated in M71 and can be removed. prefs::kSigninAllowed, -#else // defined(OS_ANDROID) +#else // BUILDFLAG(IS_ANDROID) prefs::kSigninAllowedOnNextStartup, -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) base::Value::Type::BOOLEAN)); handlers->AddHandler(std::make_unique<LegacyPoliciesDeprecatingPolicyHandler>( std::move(signin_legacy_policies), std::make_unique<BrowserSigninPolicyHandler>(chrome_schema))); -#endif // defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_CHROMEOS) #if BUILDFLAG(IS_CHROMEOS_ASH) std::vector<std::unique_ptr<ConfigurationPolicyHandler>> @@ -2134,7 +2134,7 @@ // kOverrideSecurityRestrictionsOnInsecureOrigins. The legacy policy was never // supported on ChromeOS or Android, so on those platforms, simply use the new // one. -#if defined(OS_CHROMEOS) || defined(OS_ANDROID) +#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) handlers->AddHandler(std::make_unique<SecureOriginPolicyHandler>( key::kOverrideSecurityRestrictionsOnInsecureOrigin, chrome_schema)); #else @@ -2147,9 +2147,9 @@ std::move(secure_origin_legacy_policy), std::make_unique<SecureOriginPolicyHandler>( key::kOverrideSecurityRestrictionsOnInsecureOrigin, chrome_schema))); -#endif // defined(OS_CHROMEOS) || defined(OS_ANDROID) +#endif // BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) -#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) +#if !BUILDFLAG(IS_CHROMEOS) && !BUILDFLAG(IS_ANDROID) handlers->AddHandler(std::make_unique<DiskCacheDirPolicyHandler>()); handlers->AddHandler( std::make_unique<extensions::NativeMessagingHostListPolicyHandler>( @@ -2167,7 +2167,7 @@ SCHEMA_ALLOW_UNKNOWN, SimpleSchemaValidatingPolicyHandler::RECOMMENDED_PROHIBITED, SimpleSchemaValidatingPolicyHandler::MANDATORY_ALLOWED)); -#endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_CHROMEOS) && !BUILDFLAG(IS_ANDROID) #if BUILDFLAG(ENABLE_EXTENSIONS) handlers->AddHandler(std::make_unique<extensions::ExtensionListPolicyHandler>( @@ -2204,15 +2204,15 @@ SimpleSchemaValidatingPolicyHandler::RECOMMENDED_PROHIBITED, SimpleSchemaValidatingPolicyHandler::MANDATORY_ALLOWED)); -#if defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX) || \ - defined(OS_FUCHSIA) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || \ + BUILDFLAG(IS_FUCHSIA) handlers->AddHandler(std::make_unique<SimpleSchemaValidatingPolicyHandler>( key::kWebAppSettings, prefs::kWebAppSettings, chrome_schema, SCHEMA_ALLOW_UNKNOWN, SimpleSchemaValidatingPolicyHandler::RECOMMENDED_PROHIBITED, SimpleSchemaValidatingPolicyHandler::MANDATORY_ALLOWED)); -#endif // defined(OS_WIN) || defined(OS_MAC) || defined(OS_LINUX) || - // defined(OS_FUCHSIA) +#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || + // BUILDFLAG(IS_FUCHSIA) #endif // BUILDFLAG(ENABLE_EXTENSIONS) @@ -2236,7 +2236,7 @@ policy::key::kSpellcheckLanguageBlocklist)); #endif // BUILDFLAG(ENABLE_SPELLCHECK) -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) handlers->AddHandler(std::make_unique<SimpleDeprecatingPolicyHandler>( std::make_unique<SimplePolicyHandler>(key::kAllowNativeNotifications, prefs::kAllowNativeNotifications, @@ -2244,7 +2244,7 @@ std::make_unique<SimplePolicyHandler>(key::kAllowSystemNotifications, prefs::kAllowSystemNotifications, base::Value::Type::BOOLEAN))); -#endif // defined(OS_LINUX) +#endif // BUILDFLAG(IS_LINUX) return handlers; }
diff --git a/chrome/browser/policy/device_management_service_configuration.cc b/chrome/browser/policy/device_management_service_configuration.cc index cee197c..61e9757b 100644 --- a/chrome/browser/policy/device_management_service_configuration.cc +++ b/chrome/browser/policy/device_management_service_configuration.cc
@@ -19,8 +19,9 @@ #include "chromeos/system/statistics_provider.h" #endif -#if defined(OS_WIN) || defined(OS_MAC) || \ - ((defined(OS_LINUX) || defined(OS_CHROMEOS)) && !defined(OS_ANDROID)) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || \ + ((BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && \ + !BUILDFLAG(IS_ANDROID)) #include "chrome/browser/enterprise/connectors/common.h" #include "chrome/browser/enterprise/connectors/connectors_service.h" #endif @@ -67,7 +68,7 @@ #endif std::string os_version("-"); -#if defined(OS_WIN) || defined(OS_MAC) || BUILDFLAG(IS_CHROMEOS_ASH) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS_ASH) int32_t os_major_version = 0; int32_t os_minor_version = 0; int32_t os_bugfix_version = 0; @@ -97,8 +98,9 @@ std::string DeviceManagementServiceConfiguration::GetReportingConnectorServerUrl( content::BrowserContext* context) const { -#if defined(OS_WIN) || defined(OS_MAC) || \ - ((defined(OS_LINUX) || defined(OS_CHROMEOS)) && !defined(OS_ANDROID)) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || \ + ((BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && \ + !BUILDFLAG(IS_ANDROID)) auto* service = enterprise_connectors::ConnectorsServiceFactory::GetForBrowserContext( context);
diff --git a/chrome/browser/policy/dm_token_utils.cc b/chrome/browser/policy/dm_token_utils.cc index da2bcaec..d422b53 100644 --- a/chrome/browser/policy/dm_token_utils.cc +++ b/chrome/browser/policy/dm_token_utils.cc
@@ -87,7 +87,7 @@ policy_manager->core()->client()->dm_token()); } } -#elif !defined(OS_ANDROID) +#elif !BUILDFLAG(IS_ANDROID) if (dm_token.is_empty() && ChromeBrowserCloudManagementController::IsEnabled()) { dm_token = BrowserDMTokenStorage::Get()->RetrieveDMToken();
diff --git a/chrome/browser/policy/extension_policy_browsertest.cc b/chrome/browser/policy/extension_policy_browsertest.cc index aee5a39..d7b30fbe 100644 --- a/chrome/browser/policy/extension_policy_browsertest.cc +++ b/chrome/browser/policy/extension_policy_browsertest.cc
@@ -81,7 +81,7 @@ #include "net/test/embedded_test_server/http_response.h" #include "third_party/blink/public/common/switches.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/win/win_util.h" #endif @@ -448,7 +448,7 @@ } // Flaky on windows; http://crbug.com/307994. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_ExtensionInstallBlocklistWildcard \ DISABLED_ExtensionInstallBlocklistWildcard #else @@ -1160,7 +1160,7 @@ // the |id|. void SetExtensionSettingsPolicy(const std::string& update_url_suffix, const std::string& id) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Unless enterprise managed, policy handler only allows extensions from the // Chrome Webstore to be force installed. Mark enterprise managed for // windows. @@ -1550,7 +1550,7 @@ // Verifies that corrupted non-webstore policy-based extension is automatically // repaired (reinstalled) even if hashes file is damaged too. // crbug.com/1131634: flaky on win -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_CorruptedNonWebstoreExtensionWithDamagedHashesRepaired \ DISABLED_CorruptedNonWebstoreExtensionWithDamagedHashesRepaired #else @@ -1856,7 +1856,7 @@ embedded_test_server()->GetURL("/extensions/good_v1_update_manifest.xml"); // Mark as enterprise managed. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) base::win::ScopedDomainStateForTesting scoped_domain(true); #endif @@ -1929,7 +1929,7 @@ // installation prompt without further user interaction when the source is // allowlisted by policy. // Flaky on windows; http://crbug.com/295729 . -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_ExtensionInstallSources DISABLED_ExtensionInstallSources #else #define MAYBE_ExtensionInstallSources ExtensionInstallSources @@ -2140,7 +2140,7 @@ ExtensionRequestInterceptor interceptor; // Mark as enterprise managed. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) base::win::ScopedDomainStateForTesting scoped_domain(true); #endif extensions::ExtensionRegistry* registry = extension_registry();
diff --git a/chrome/browser/policy/local_sync_policy_handler.cc b/chrome/browser/policy/local_sync_policy_handler.cc index b6cc949..294fd109 100644 --- a/chrome/browser/policy/local_sync_policy_handler.cc +++ b/chrome/browser/policy/local_sync_policy_handler.cc
@@ -30,7 +30,7 @@ std::string string_value; if (value && value->GetAsString(&string_value)) { base::FilePath::StringType expanded_value = -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) policy::path_parser::ExpandPathVariables( base::UTF8ToWide(string_value)); #else
diff --git a/chrome/browser/policy/messaging_layer/util/get_cloud_policy_client.cc b/chrome/browser/policy/messaging_layer/util/get_cloud_policy_client.cc index b8a81f3..72bbed5 100644 --- a/chrome/browser/policy/messaging_layer/util/get_cloud_policy_client.cc +++ b/chrome/browser/policy/messaging_layer/util/get_cloud_policy_client.cc
@@ -53,7 +53,7 @@ g_browser_process->platform_part() ->browser_policy_connector_ash() ->GetDeviceCloudPolicyManager(); -#elif defined(OS_ANDROID) +#elif BUILDFLAG(IS_ANDROID) // Android doesn't have access to a device level CloudPolicyClient, so get the // PrimaryUserProfile CloudPolicyClient. policy::CloudPolicyManager* const cloud_policy_manager =
diff --git a/chrome/browser/policy/policy_initialization_browsertest.cc b/chrome/browser/policy/policy_initialization_browsertest.cc index 7cf64fe..85383c4 100644 --- a/chrome/browser/policy/policy_initialization_browsertest.cc +++ b/chrome/browser/policy/policy_initialization_browsertest.cc
@@ -16,7 +16,7 @@ #include "components/prefs/pref_service.h" #include "content/public/test/browser_test.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <windows.h> #include "base/test/test_reg_util_win.h" #include "base/win/registry.h" @@ -24,7 +24,7 @@ namespace { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) const char kMockPolicyName[] = "AllowFileSelectionDialogs"; #endif @@ -75,7 +75,7 @@ } private: -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Set up policy value for windows platform void SetUpPlatformPolicyValue() { HKEY root = HKEY_CURRENT_USER; @@ -96,7 +96,7 @@ #endif }; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) IN_PROC_BROWSER_TEST_F(PolicyInitializationBrowserTest, VerifyLocalState) { VerifyLocalState(); }
diff --git a/chrome/browser/policy/policy_network_browsertest.cc b/chrome/browser/policy/policy_network_browsertest.cc index dc45896..b72495fb 100644 --- a/chrome/browser/policy/policy_network_browsertest.cc +++ b/chrome/browser/policy/policy_network_browsertest.cc
@@ -546,7 +546,7 @@ // Then QuicAllowed=false policy is dynamically set for both profiles. // // Disabled due to flakiness on windows: https://crbug.com/947931. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_QuicAllowedFalseAfterTwoProfilesCreated \ DISABLED_QuicAllowedFalseAfterTwoProfilesCreated #else
diff --git a/chrome/browser/policy/policy_path_parser.h b/chrome/browser/policy/policy_path_parser.h index 227b81ad..937ce89 100644 --- a/chrome/browser/policy/policy_path_parser.h +++ b/chrome/browser/policy/policy_path_parser.h
@@ -52,7 +52,7 @@ base::FilePath::StringType ExpandPathVariables( const base::FilePath::StringType& untranslated_string); -#if defined(OS_WIN) || defined(OS_MAC) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) // A helper function used to read the UserDataDir path policy without relying on // any policy infrastructure. This is required because this policy is needed // much earlier before the PrefService is initialized. @@ -63,7 +63,7 @@ // profile path is not read from the PathService which already takes this into // account. void CheckUserDataDirPolicy(base::FilePath* user_data_dir); -#endif // defined(OS_WIN) || defined(OS_MAC) +#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) } // namespace path_parser
diff --git a/chrome/browser/policy/policy_path_parser_unittest.cc b/chrome/browser/policy/policy_path_parser_unittest.cc index 1a244467..73218c8 100644 --- a/chrome/browser/policy/policy_path_parser_unittest.cc +++ b/chrome/browser/policy/policy_path_parser_unittest.cc
@@ -79,7 +79,7 @@ FILE_PATH_LITERAL("${machine_name}")); } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) TEST_F(PolicyPathParserTests, MacVariables) { CheckForSubstitution(FILE_PATH_LITERAL("//$C/${users}"), @@ -88,7 +88,7 @@ FILE_PATH_LITERAL("${documents}")); } -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) TEST_F(PolicyPathParserTests, WinVariables) { CheckForSubstitution(FILE_PATH_LITERAL("//$C/${documents}"),
diff --git a/chrome/browser/policy/policy_prefs_browsertest.cc b/chrome/browser/policy/policy_prefs_browsertest.cc index 7455b3a..bcdb2f8 100644 --- a/chrome/browser/policy/policy_prefs_browsertest.cc +++ b/chrome/browser/policy/policy_prefs_browsertest.cc
@@ -87,7 +87,7 @@ } MockConfigurationPolicyProvider* GetMockPolicyProvider() { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Trying to delete the mock provider on Android leads to a cascade of // crashes due to ChromeBrowserPolicyConnector and ProfileImpl not being // deleted. Those crashes are caused by checks that ensure that observer @@ -104,12 +104,12 @@ // by ChromeBrowserPolicyConnector and ProfileImpl destructors. Thus it's // safe to define a provider object that is deleted on scope destruction. return &provider_; -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) } -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) testing::NiceMock<MockConfigurationPolicyProvider> provider_; -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) }; // Verifies that policies make their corresponding preferences become managed,
diff --git a/chrome/browser/policy/policy_test_utils.cc b/chrome/browser/policy/policy_test_utils.cc index b54f819..9600590 100644 --- a/chrome/browser/policy/policy_test_utils.cc +++ b/chrome/browser/policy/policy_test_utils.cc
@@ -13,6 +13,7 @@ #include "base/task/current_thread.h" #include "base/test/bind.h" #include "base/values.h" +#include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/net/safe_search_util.h" @@ -59,7 +60,7 @@ void PolicyTest::UpdateProviderPolicy(const PolicyMap& policy) { PolicyMap policy_with_defaults = policy.Clone(); -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) SetEnterpriseUsersDefaults(&policy_with_defaults); #endif provider_.UpdateChromePolicy(policy_with_defaults);
diff --git a/chrome/browser/policy/printing_restrictions_policy_handler.cc b/chrome/browser/policy/printing_restrictions_policy_handler.cc index 28a8e531..88cd659 100644 --- a/chrome/browser/policy/printing_restrictions_policy_handler.cc +++ b/chrome/browser/policy/printing_restrictions_policy_handler.cc
@@ -295,7 +295,7 @@ if (!TypeCheckingPolicyHandler::CheckPolicySettings(policies, errors)) return false; -#if defined(OS_WIN) || defined(OS_MAC) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) // Platforms which require a policy to enable the "Print as image" option // should have that policy specified with availability enabled before trying // to specify a default behavior for the option. @@ -310,7 +310,7 @@ return false; } } -#endif // defined(OS_WIN) || defined(OS_MAC) +#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) return true; }
diff --git a/chrome/browser/policy/printing_restrictions_policy_handler_unittest.cc b/chrome/browser/policy/printing_restrictions_policy_handler_unittest.cc index 1437dde..63d5c3f 100644 --- a/chrome/browser/policy/printing_restrictions_policy_handler_unittest.cc +++ b/chrome/browser/policy/printing_restrictions_policy_handler_unittest.cc
@@ -166,7 +166,7 @@ PrefValueMap prefs_; }; -#if defined(OS_WIN) || defined(OS_MAC) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) TEST_F(PrintPdfAsImageRestrictionsPolicyHandlerTest, DefaultWithAvailabilityEnabled) { // For platforms that require PrintPdfAsImageAvailability, demonstrate that @@ -208,9 +208,9 @@ CheckInvalidPolicy(key::kPrintPdfAsImageDefault, default_value.Clone()); } -#endif // defined(OS_WIN) || defined(OS_MAC) +#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) TEST_F(PrintPdfAsImageRestrictionsPolicyHandlerTest, DefaultWithoutAvailability) { // For platforms that do not require PrintPdfAsImageAvailability, demonstrate @@ -226,7 +226,7 @@ ASSERT_TRUE(value); EXPECT_EQ(*value, default_value); } -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
diff --git a/chrome/browser/policy/profile_policy_connector.cc b/chrome/browser/policy/profile_policy_connector.cc index c006d95..6df2515 100644 --- a/chrome/browser/policy/profile_policy_connector.cc +++ b/chrome/browser/policy/profile_policy_connector.cc
@@ -223,7 +223,7 @@ #endif std::vector<std::unique_ptr<PolicyMigrator>> migrators; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) migrators.push_back( std::make_unique<browser_switcher::BrowserSwitcherPolicyMigrator>()); #endif
diff --git a/chrome/browser/policy/site_isolation_policy_browsertest.cc b/chrome/browser/policy/site_isolation_policy_browsertest.cc index cd6cf79..3f3c83b0 100644 --- a/chrome/browser/policy/site_isolation_policy_browsertest.cc +++ b/chrome/browser/policy/site_isolation_policy_browsertest.cc
@@ -93,7 +93,7 @@ policy::PolicyMap values; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) const char* kPolicyName = policy::key::kSitePerProcessAndroid; #else const char* kPolicyName = policy::key::kSitePerProcess; @@ -155,7 +155,7 @@ NoOverrideSitePerProcessPolicyBrowserTest() = default; void SetUpCommandLine(base::CommandLine* command_line) override { command_line->AppendSwitch(switches::kDisableSiteIsolation); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) command_line->AppendSwitch(switches::kDisableSiteIsolationForPolicy); #endif } @@ -218,7 +218,7 @@ // SitePerProcessPolicyBrowserTestFieldTrialTest tests should not be run on any // other platform. Note that browser_tests won't run on Android until // https://crbug.com/611756 is fixed. -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) class SitePerProcessPolicyBrowserTestFieldTrialTest : public SitePerProcessPolicyBrowserTestDisabled { public: @@ -267,12 +267,12 @@ // without an explicit enterprise policy). EXPECT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kDisableSiteIsolation)); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) EXPECT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kDisableSiteIsolationForPolicy)); EXPECT_EQ(content::SiteIsolationPolicy::UseDedicatedProcessesForAllSites(), base::FeatureList::IsEnabled(features::kSitePerProcess)); #else EXPECT_TRUE(content::SiteIsolationPolicy::UseDedicatedProcessesForAllSites()); -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) }
diff --git a/chrome/browser/policy/test/accessibility_policy_browsertest.cc b/chrome/browser/policy/test/accessibility_policy_browsertest.cc index 44909f3c..42b6c60 100644 --- a/chrome/browser/policy/test/accessibility_policy_browsertest.cc +++ b/chrome/browser/policy/test/accessibility_policy_browsertest.cc
@@ -354,7 +354,7 @@ } // https://crbug.com/1225510 -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) #define MAYBE_CaretHighlightEnabled DISABLED_CaretHighlightEnabled #else #define MAYBE_CaretHighlightEnabled CaretHighlightEnabled @@ -432,7 +432,7 @@ } // Flaky on chromeos: crbug.com/1184225 -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) #define MAYBE_AutoclickEnabled DISABLED_AutoclickEnabled #else #define MAYBE_AutoclickEnabled AutoclickEnabled
diff --git a/chrome/browser/policy/test/autoplay_policy_browsertest.cc b/chrome/browser/policy/test/autoplay_policy_browsertest.cc index 24ee6df..57d6ff80d 100644 --- a/chrome/browser/policy/test/autoplay_policy_browsertest.cc +++ b/chrome/browser/policy/test/autoplay_policy_browsertest.cc
@@ -99,7 +99,7 @@ } // Flaky on Linux. See: crbug.com/1189597. -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) #define MAYBE_AutoplayAllowlist_Allowed DISABLED_AutoplayAllowlist_Allowed #else #define MAYBE_AutoplayAllowlist_Allowed AutoplayAllowlist_Allowed @@ -171,7 +171,7 @@ } // Flaky on Linux and ChromeOS. See: crbug.com/1172978. -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #define MAYBE_AutoplayDeniedByPolicy DISABLED_AutoplayDeniedByPolicy #else #define MAYBE_AutoplayDeniedByPolicy AutoplayDeniedByPolicy @@ -208,7 +208,7 @@ } // Flaky on Linux. See: crbug.com/1172978. -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #define MAYBE_AutoplayDeniedAllowedWithURL DISABLED_AutoplayDeniedAllowedWithURL #else #define MAYBE_AutoplayDeniedAllowedWithURL AutoplayDeniedAllowedWithURL
diff --git a/chrome/browser/policy/test/hide_webstore_icon_policy_browsertest.cc b/chrome/browser/policy/test/hide_webstore_icon_policy_browsertest.cc index 4dad711..d27591a8 100644 --- a/chrome/browser/policy/test/hide_webstore_icon_policy_browsertest.cc +++ b/chrome/browser/policy/test/hide_webstore_icon_policy_browsertest.cc
@@ -64,7 +64,7 @@ content::WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); -#if !defined(OS_CHROMEOS) +#if !BUILDFLAG(IS_CHROMEOS) // Look for web store's app ID in the apps page. EXPECT_TRUE( ContainsVisibleElement(contents, "ahfgeienlihckogmohjhadlkjgocpleb"));
diff --git a/chrome/browser/policy/test/network_service_sandbox_enabled_browsertest.cc b/chrome/browser/policy/test/network_service_sandbox_enabled_browsertest.cc index b4da869..fad71c9 100644 --- a/chrome/browser/policy/test/network_service_sandbox_enabled_browsertest.cc +++ b/chrome/browser/policy/test/network_service_sandbox_enabled_browsertest.cc
@@ -17,7 +17,7 @@ #include "content/public/test/browser_test.h" #include "testing/gtest/include/gtest/gtest.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "sandbox/policy/features.h" #endif @@ -55,7 +55,7 @@ // Policy always overrides the default. bool expected_value = GetParam().value_or(content_client.ShouldSandboxNetworkService()); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // On Windows, the policy is ignored if the platform does not support // sandboxing at all, e.g. pre Windows 10. if (!sandbox::policy::features::IsWinNetworkServiceSandboxSupported())
diff --git a/chrome/browser/policy/test/policy_browsertest.cc b/chrome/browser/policy/test/policy_browsertest.cc index 05794570..c663abb 100644 --- a/chrome/browser/policy/test/policy_browsertest.cc +++ b/chrome/browser/policy/test/policy_browsertest.cc
@@ -54,7 +54,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" -#if !defined(OS_MAC) +#if !BUILDFLAG(IS_MAC) #include "base/compiler_specific.h" #endif @@ -85,7 +85,7 @@ } // namespace // This test is flaky on Windows 10: https://crbug.com/1069558 -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define MAYBE_Disable3DAPIs DISABLED_Disable3DAPIs #else #define MAYBE_Disable3DAPIs Disable3DAPIs @@ -123,7 +123,7 @@ EXPECT_TRUE(IsWebGLEnabled(contents)); } -#if defined(OS_MAC) && !defined(NDEBUG) +#if BUILDFLAG(IS_MAC) && !defined(NDEBUG) // Times out on mac-debug. // TODO(crbug.com/1159423): Re-enable #define MAYBE_HomepageLocation DISABLED_HomepageLocation @@ -165,7 +165,7 @@ contents->GetLastCommittedURL()); } -#if defined(OS_MAC) && defined(ADDRESS_SANITIZER) +#if BUILDFLAG(IS_MAC) && defined(ADDRESS_SANITIZER) // Flaky on ASAN on Mac. See https://crbug.com/674497. #define MAYBE_IncognitoEnabled DISABLED_IncognitoEnabled #else
diff --git a/chrome/browser/policy/test/promotional_tabs_enabled_policy_browsertest.cc b/chrome/browser/policy/test/promotional_tabs_enabled_policy_browsertest.cc index 03d97377..35146a2 100644 --- a/chrome/browser/policy/test/promotional_tabs_enabled_policy_browsertest.cc +++ b/chrome/browser/policy/test/promotional_tabs_enabled_policy_browsertest.cc
@@ -13,6 +13,7 @@ #include "base/test/test_timeouts.h" #include "base/threading/thread_task_runner_handle.h" #include "base/values.h" +#include "build/build_config.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/policy/policy_test_utils.h" #include "chrome/browser/prefs/session_startup_pref.h" @@ -38,7 +39,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" -#if !defined(OS_CHROMEOS) +#if !BUILDFLAG(IS_CHROMEOS) #include "chrome/browser/ui/webui/welcome/helpers.h" #endif @@ -58,7 +59,7 @@ PromotionalTabsEnabledPolicyTest() { const std::vector<base::Feature> kEnabledFeatures = { features::kChromeWhatsNewUI, -#if !defined(OS_CHROMEOS) +#if !BUILDFLAG(IS_CHROMEOS) welcome::kForceEnabled, #endif }; @@ -100,7 +101,7 @@ base::test::ScopedFeatureList scoped_feature_list_; }; -#if !defined(OS_CHROMEOS) +#if !BUILDFLAG(IS_CHROMEOS) // Tests that the PromotionalTabsEnabled policy properly suppresses the welcome // page for browser first-runs. class PromotionalTabsEnabledPolicyWelcomeTest @@ -148,7 +149,7 @@ ::testing::Values(PolicyTest::BooleanPolicy::kNotConfigured, PolicyTest::BooleanPolicy::kFalse, PolicyTest::BooleanPolicy::kTrue)); -#endif // !defined(OS_CHROMEOS) +#endif // !BUILDFLAG(IS_CHROMEOS) // Tests that the PromotionalTabsEnabled policy properly suppresses the What's // New page.
diff --git a/chrome/browser/policy/test/url_blocklist_policy_browsertest.cc b/chrome/browser/policy/test/url_blocklist_policy_browsertest.cc index b63732d..657410cc 100644 --- a/chrome/browser/policy/test/url_blocklist_policy_browsertest.cc +++ b/chrome/browser/policy/test/url_blocklist_policy_browsertest.cc
@@ -30,7 +30,7 @@ #include "net/test/embedded_test_server/http_response.h" #include "url/gurl.h" -#if !defined(OS_MAC) +#if !BUILDFLAG(IS_MAC) #include "extensions/browser/app_window/app_window.h" #include "ui/base/window_open_disposition.h" #endif
diff --git a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_params.cc b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_params.cc index 2f570bcc..0b64f4b 100644 --- a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_params.cc +++ b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_params.cc
@@ -60,11 +60,6 @@ return "chrome-tunnel"; } -bool PrefetchProxyOnlyForLiteMode() { - return base::GetFieldTrialParamByFeatureAsBool(features::kIsolatePrerenders, - "lite_mode_only", true); -} - bool PrefetchProxyNoStatePrefetchSubresources() { return base::CommandLine::ForCurrentProcess()->HasSwitch( kIsolatedPrerenderEnableNSPCmdLineFlag) ||
diff --git a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_params.h b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_params.h index d8ea94e1..d792339 100644 --- a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_params.h +++ b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_params.h
@@ -29,9 +29,6 @@ // The header name used to connect to the tunnel proxy. std::string PrefetchProxyProxyHeaderKey(); -// Whether the feature is only enabled for Lite Mode users. -bool PrefetchProxyOnlyForLiteMode(); - // Returns true when prefetched pages should run no state prefetch. bool PrefetchProxyNoStatePrefetchSubresources();
diff --git a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper.cc b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper.cc index e0926ef..a0ffa02 100644 --- a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper.cc +++ b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper.cc
@@ -32,7 +32,6 @@ #include "chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_subresource_manager.h" #include "chrome/browser/prefetch/prefetch_proxy/prefetch_type.h" #include "chrome/browser/profiles/profile.h" -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h" #include "components/google/core/common/google_util.h" #include "components/language/core/browser/pref_names.h" #include "components/no_state_prefetch/browser/no_state_prefetch_manager.h" @@ -341,11 +340,6 @@ return false; } - if (PrefetchProxyOnlyForLiteMode()) { - return data_reduction_proxy::DataReductionProxySettings:: - IsDataSaverEnabledByUser(profile->IsOffTheRecord(), - profile->GetPrefs()); - } return true; }
diff --git a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper_unittest.cc b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper_unittest.cc index 6a29aa9..69b2202 100644 --- a/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper_unittest.cc +++ b/chrome/browser/prefetch/prefetch_proxy/prefetch_proxy_tab_helper_unittest.cc
@@ -25,7 +25,6 @@ #include "chrome/browser/prefetch/prefetch_proxy/prefetched_mainframe_response_container.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h" #include "components/prefs/pref_service.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/service_worker_context.h" @@ -138,8 +137,6 @@ tab_helper_ = std::make_unique<TestPrefetchProxyTabHelper>(web_contents()); tab_helper_->SetURLLoaderFactory(test_shared_loader_factory_); tab_helper_->SetServiceWorkerContextForTest(&service_worker_context_); - - SetDataSaverEnabled(true); } void TearDown() override { @@ -147,11 +144,6 @@ ChromeRenderViewHostTestHarness::TearDown(); } - void SetDataSaverEnabled(bool enabled) { - data_reduction_proxy::DataReductionProxySettings:: - SetDataSaverEnabledForTesting(profile()->GetPrefs(), enabled); - } - void MakeNavigationPrediction(content::WebContents* web_contents, const GURL& doc_url, const std::vector<GURL>& predicted_urls) { @@ -412,84 +404,6 @@ EXPECT_FALSE(HasAfterSRPMetrics()); } -class PrefetchProxyTabHelperDataSaverDisabledTest - : public PrefetchProxyTabHelperTestBase { - public: - PrefetchProxyTabHelperDataSaverDisabledTest() { - scoped_feature_list_.InitAndEnableFeatureWithParameters( - features::kIsolatePrerenders, - {{"lite_mode_only", "true"}, - {"ineligible_decoy_request_probability", "0"}}); - } -}; - -TEST_F(PrefetchProxyTabHelperDataSaverDisabledTest, - DataSaverDisabled_Required) { - base::HistogramTester histogram_tester; - - SetDataSaverEnabled(false); - - NavigateSomewhere(); - GURL doc_url("https://www.google.com/search?q=cats"); - GURL prediction_url("https://www.cat-food.com/"); - MakeNavigationPrediction(web_contents(), doc_url, {prediction_url}); - - EXPECT_EQ(RequestCount(), 0); - EXPECT_EQ(predicted_urls_count(), 0U); - EXPECT_EQ(prefetch_eligible_count(), 0U); - EXPECT_EQ(prefetch_attempted_count(), 0U); - EXPECT_EQ(prefetch_successful_count(), 0U); - EXPECT_EQ(prefetch_total_redirect_count(), 0U); - EXPECT_FALSE(navigation_to_prefetch_start().has_value()); - - histogram_tester.ExpectTotalCount("PrefetchProxy.Prefetch.Mainframe.RespCode", - 0); - histogram_tester.ExpectTotalCount( - "PrefetchProxy.Prefetch.Mainframe.BodyLength", 0); - histogram_tester.ExpectTotalCount( - "PrefetchProxy.Prefetch.Mainframe.TotalTime", 0); - histogram_tester.ExpectTotalCount( - "PrefetchProxy.Prefetch.Mainframe.ConnectTime", 0); - - Navigate(prediction_url); - - histogram_tester.ExpectTotalCount( - "PrefetchProxy.Prefetch.Mainframe.TotalRedirects", 0); - - EXPECT_FALSE(HasAfterSRPMetrics()); -} - -class PrefetchProxyTabHelperDataSaverDisabledNotRequiredTest - : public PrefetchProxyTabHelperTestBase { - public: - PrefetchProxyTabHelperDataSaverDisabledNotRequiredTest() { - scoped_feature_list_.InitAndEnableFeatureWithParameters( - features::kIsolatePrerenders, - {{"lite_mode_only", "false"}, - {"ineligible_decoy_request_probability", "0"}}); - } -}; - -TEST_F(PrefetchProxyTabHelperDataSaverDisabledNotRequiredTest, - DataSaverDisabled_NotRequired) { - base::HistogramTester histogram_tester; - - SetDataSaverEnabled(false); - - NavigateSomewhere(); - GURL doc_url("https://www.google.com/search?q=cats"); - GURL prediction_url("https://www.cat-food.com/"); - MakeNavigationPrediction(web_contents(), doc_url, {prediction_url}); - - EXPECT_EQ(RequestCount(), 1); - EXPECT_EQ(predicted_urls_count(), 1U); - EXPECT_EQ(prefetch_eligible_count(), 1U); - EXPECT_EQ(prefetch_attempted_count(), 1U); - EXPECT_EQ(prefetch_successful_count(), 0U); - EXPECT_EQ(prefetch_total_redirect_count(), 0U); - EXPECT_TRUE(navigation_to_prefetch_start().has_value()); -} - class PrefetchProxyTabHelperTest : public PrefetchProxyTabHelperTestBase { public: PrefetchProxyTabHelperTest() {
diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc index baba1c5..a3acac2 100644 --- a/chrome/browser/printing/print_view_manager.cc +++ b/chrome/browser/printing/print_view_manager.cc
@@ -101,8 +101,10 @@ return false; // Don't print if `print_preview_rfh_` is no longer live. - if (!content::RenderFrameHost::FromID(rfh_id)) + if (!content::RenderFrameHost::FromID(rfh_id) || + !print_preview_rfh_->IsRenderFrameLive()) { return false; + } // TODO(crbug.com/809738) Register with `PrintBackendServiceManager` when // system print is enabled out-of-process. @@ -143,6 +145,9 @@ DCHECK(rfh); DCHECK(IsPrintRenderFrameConnected(rfh)); + // All callers should already ensure this condition holds; CHECK to + // aggressively protect against future unsafety. + CHECK(rfh->IsRenderFrameLive()); DCHECK(!print_preview_rfh_); print_preview_rfh_ = rfh; print_preview_state_ = USER_INITIATED_PREVIEW; @@ -177,9 +182,16 @@ bool send_message = !is_switching_to_system_dialog_; #endif if (send_message) { - // Only send a message about having closed if it is still connected. - if (IsPrintRenderFrameConnected(print_preview_rfh_)) + // Only send a message about having closed if the RenderFrame is live and + // PrintRenderFrame is connected. Normally IsPrintRenderFrameConnected() + // implies IsRenderFrameLive(). However, when a renderer process exits + // (e.g. due to a crash), RenderFrameDeleted() and PrintPreviewDone() are + // triggered by independent observers. Since there is no guarantee which + // observer will run first, both conditions are explicitly checked here. + if (print_preview_rfh_->IsRenderFrameLive() && + IsPrintRenderFrameConnected(print_preview_rfh_)) { GetPrintRenderFrame(print_preview_rfh_)->OnPrintPreviewDialogClosed(); + } } is_switching_to_system_dialog_ = false; @@ -244,7 +256,7 @@ return false; // Don't print / print preview crashed tabs. - if (IsCrashed()) + if (IsCrashed() || !rfh->IsRenderFrameLive()) return false; GetPrintRenderFrame(rfh)->InitiatePrintPreview(std::move(print_renderer), @@ -272,6 +284,9 @@ SetupScriptedPrintPreviewCallback callback) { DCHECK_CURRENTLY_ON(BrowserThread::UI); content::RenderFrameHost* rfh = GetCurrentTargetFrame(); + // The Mojo receiver endpoint is owned by a RenderFrameHostReceiverSet, so + // this DCHECK should always hold. + DCHECK(rfh->IsRenderFrameLive()); content::RenderProcessHost* rph = rfh->GetProcess(); if (rfh->IsNestedWithinFencedFrame()) { @@ -398,9 +413,11 @@ OnPrintPreviewRequestRejected(render_process_id, render_frame_id); return; } + // Double-check that the RenderFrameHost is still alive and has a live + // RenderFrame, since the DLP check is potentially asynchronous. auto* render_frame_host = content::RenderFrameHost::FromID(render_process_id, render_frame_id); - if (!render_frame_host) { + if (!render_frame_host || !render_frame_host->IsRenderFrameLive()) { return; } if (params->webnode_only) {
diff --git a/chrome/browser/printing/print_view_manager_base.cc b/chrome/browser/printing/print_view_manager_base.cc index 9fd9c0a9..2b37ff74 100644 --- a/chrome/browser/printing/print_view_manager_base.cc +++ b/chrome/browser/printing/print_view_manager_base.cc
@@ -347,7 +347,7 @@ return false; // Don't print if `rfh` is no longer live. - if (!content::RenderFrameHost::FromID(rfh_id)) + if (!content::RenderFrameHost::FromID(rfh_id) || !rfh->IsRenderFrameLive()) return false; // TODO(crbug.com/809738) Register with `PrintBackendServiceManager` when @@ -955,8 +955,12 @@ if (!print_job_) return; - if (rfh) + if (rfh) { + // printing_rfh_ should only ever point to a RenderFrameHost with a live + // RenderFrame. + DCHECK(rfh->IsRenderFrameLive()); GetPrintRenderFrame(rfh)->PrintingDone(printing_succeeded_); + } print_job_->RemoveObserver(*this); @@ -1043,6 +1047,10 @@ return; } DCHECK(!printing_rfh_); + // Protect against future unsafety, since printing_rfh_ is cleared by + // RenderFrameDeleted(), which will not be called if the render frame is not + // live. + CHECK(rfh->IsRenderFrameLive()); printing_rfh_ = rfh; } @@ -1069,7 +1077,8 @@ void PrintViewManagerBase::SendPrintingEnabled(bool enabled, content::RenderFrameHost* rfh) { - GetPrintRenderFrame(rfh)->SetPrintingEnabled(enabled); + if (rfh->IsRenderFrameLive()) + GetPrintRenderFrame(rfh)->SetPrintingEnabled(enabled); } } // namespace printing
diff --git a/chrome/browser/resources/settings/privacy_page/privacy_review/privacy_review_page.html b/chrome/browser/resources/settings/privacy_page/privacy_review/privacy_review_page.html index 915043d..e190c12 100644 --- a/chrome/browser/resources/settings/privacy_page/privacy_review/privacy_review_page.html +++ b/chrome/browser/resources/settings/privacy_page/privacy_review/privacy_review_page.html
@@ -45,8 +45,8 @@ <div class="privacy-review-card"> <cr-view-manager id="viewManager"> <privacy-review-welcome-fragment id="[[privacyReviewStepEnum_.WELCOME]]" - class="managed-fragment" prefs="{{prefs}}" - on-start-button-click="onNextButtonClick_" slot="view"> + class="managed-fragment" on-start-button-click="onNextButtonClick_" + slot="view"> </privacy-review-welcome-fragment> <privacy-review-msbb-fragment id="[[privacyReviewStepEnum_.MSBB]]" class="managed-fragment" prefs="{{prefs}}" slot="view">
diff --git a/chrome/browser/resources/settings/privacy_page/privacy_review/privacy_review_page.ts b/chrome/browser/resources/settings/privacy_page/privacy_review/privacy_review_page.ts index 69e5712..2cfc610 100644 --- a/chrome/browser/resources/settings/privacy_page/privacy_review/privacy_review_page.ts +++ b/chrome/browser/resources/settings/privacy_page/privacy_review/privacy_review_page.ts
@@ -160,7 +160,7 @@ PrivacyReviewStep.WELCOME, { nextStep: PrivacyReviewStep.MSBB, - isAvailable: () => this.shouldShowWelcomeCard_(), + isAvailable: () => true, }, ], [ @@ -361,10 +361,6 @@ return !!this.syncStatus_.signedIn && !this.syncStatus_.hasError; } - private shouldShowWelcomeCard_(): boolean { - return this.getPref('privacy_review.show_welcome_card').value; - } - private shouldShowCookiesCard_(): boolean { const currentCookieSetting = this.getPref('generated.cookie_primary_setting').value;
diff --git a/chrome/browser/resources/settings/privacy_page/privacy_review/privacy_review_welcome_fragment.html b/chrome/browser/resources/settings/privacy_page/privacy_review/privacy_review_welcome_fragment.html index 288476e..7aa0c05a 100644 --- a/chrome/browser/resources/settings/privacy_page/privacy_review/privacy_review_welcome_fragment.html +++ b/chrome/browser/resources/settings/privacy_page/privacy_review/privacy_review_welcome_fragment.html
@@ -17,7 +17,7 @@ .footer { align-items: center; display: flex; - justify-content: space-between; + justify-content: flex-end; padding: 8px 0; } </style> @@ -32,11 +32,6 @@ <div class="cr-secondary-text">$i18n{privacyReviewWelcomeCardSubHeader}</div> </div> <div class="footer"> - <settings-checkbox id="dontShowAgainCheckbox" - pref="{{prefs.privacy_review.show_welcome_card}}" - label="$i18n{privacyReviewWelcomeCardDontShowAgainCheckbox}" - inverted no-set-pref> - </settings-checkbox> <cr-button class="action-button" id="startButton" on-click="onStartButtonClick_"> $i18n{privacyReviewWelcomeCardStartButton}
diff --git a/chrome/browser/resources/settings/privacy_page/privacy_review/privacy_review_welcome_fragment.ts b/chrome/browser/resources/settings/privacy_page/privacy_review/privacy_review_welcome_fragment.ts index 9340c78..e134c160 100644 --- a/chrome/browser/resources/settings/privacy_page/privacy_review/privacy_review_welcome_fragment.ts +++ b/chrome/browser/resources/settings/privacy_page/privacy_review/privacy_review_welcome_fragment.ts
@@ -8,7 +8,6 @@ * card that contains the welcome screen and its description. */ import 'chrome://resources/cr_elements/cr_button/cr_button.m.js'; -import '../../controls/settings_checkbox.js'; import './privacy_review_fragment_shared_css.js'; import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; @@ -28,21 +27,8 @@ return html`{__html_template__}`; } - static get properties() { - return { - /** - * Preferences state. - */ - prefs: { - type: Object, - notify: true, - }, - }; - } - private onStartButtonClick_(e: Event) { e.stopPropagation(); - this.shadowRoot!.querySelector('settings-checkbox')!.sendPrefChange(); this.dispatchEvent( new CustomEvent('start-button-click', {bubbles: true, composed: true})); }
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc index fcf4349..07e7b6b 100644 --- a/chrome/browser/sessions/session_restore.cc +++ b/chrome/browser/sessions/session_restore.cc
@@ -539,23 +539,6 @@ } for (auto i = windows->begin(); i != windows->end(); ++i) { - // Check if a collapse tab group will be restored and if the feature flag - // |kTabGroupsCollapseFreezing| is enabled. UMA metrics for features are - // gathered based on the check of the feature flag. The goal of this code - // is to ensure the feature is initialized before the first UMA snapshot - // gets uploaded. - // TODO(1110108): Remove this check once the feature is fully launched. - for (auto& session_tab_group : (*i)->tab_groups) { - // Ensure that the user has a collapsed group before checking if the - // freezing experiment is enabled to ensure our metrics accurately track - // the impact of freezing for users with collapsed tab groups. - if (session_tab_group->visual_data.is_collapsed() && - base::FeatureList::IsEnabled( - features::kTabGroupsCollapseFreezing)) { - break; - } - } - ++(*window_count); // 1. Choose between restoring tabs in an existing browser or in a newly // created browser.
diff --git a/chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/share_sheet/ChromeProvidedSharingOptionsProvider.java b/chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/share_sheet/ChromeProvidedSharingOptionsProvider.java index 32897aa..2810c86 100644 --- a/chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/share_sheet/ChromeProvidedSharingOptionsProvider.java +++ b/chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/share_sheet/ChromeProvidedSharingOptionsProvider.java
@@ -297,7 +297,7 @@ mOrderedFirstPartyOptions.add(createCopyFirstPartyOption()); mOrderedFirstPartyOptions.add(createCopyTextFirstPartyOption()); mOrderedFirstPartyOptions.add(createSendTabToSelfFirstPartyOption()); - if (!mTabProvider.get().getWebContents().isIncognito()) { + if (!mTabProvider.get().isIncognito()) { mOrderedFirstPartyOptions.add(createQrCodeFirstPartyOption()); } if (UserPrefs.get(Profile.getLastUsedRegularProfile()).getBoolean(Pref.PRINTING_ENABLED)) {
diff --git a/chrome/browser/share/android/javatests/src/org/chromium/chrome/browser/share/share_sheet/ChromeProvidedSharingOptionsProviderTest.java b/chrome/browser/share/android/javatests/src/org/chromium/chrome/browser/share/share_sheet/ChromeProvidedSharingOptionsProviderTest.java index 669ed7b..42dfc03 100644 --- a/chrome/browser/share/android/javatests/src/org/chromium/chrome/browser/share/share_sheet/ChromeProvidedSharingOptionsProviderTest.java +++ b/chrome/browser/share/android/javatests/src/org/chromium/chrome/browser/share/share_sheet/ChromeProvidedSharingOptionsProviderTest.java
@@ -119,7 +119,7 @@ Mockito.when(mTabProvider.get()).thenReturn(mTab); Mockito.when(mTab.getWebContents()).thenReturn(mWebContents); Mockito.when(mTab.getUrl()).thenReturn(new GURL(URL)); - Mockito.when(mWebContents.isIncognito()).thenReturn(false); + Mockito.when(mTab.isIncognito()).thenReturn(false); Mockito.doNothing().when(mBottomSheetController).hideContent(any(), anyBoolean()); TrackerFactory.setTrackerForTests(mTracker);
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index f9d0f9a..772eb84 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn
@@ -1136,8 +1136,6 @@ "media_router/cloud_services_dialog.h", "media_router/media_cast_mode.cc", "media_router/media_cast_mode.h", - "media_router/media_router_file_dialog.cc", - "media_router/media_router_file_dialog.h", "media_router/media_router_ui.cc", "media_router/media_router_ui.h", "media_router/media_router_ui_helper.cc",
diff --git a/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc b/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc index b27ad03..9ccafab 100644 --- a/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc +++ b/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc
@@ -108,9 +108,9 @@ explicit NotificationsEnabledDeferred(PrefService* prefs) : prefs_(prefs) {} void Put(const std::string& app_id, bool enabled) { - DictionaryPrefUpdateDeprecated update( + DictionaryPrefUpdate update( prefs_, arc::prefs::kArcSetNotificationsEnabledDeferred); - base::DictionaryValue* const dict = update.Get(); + base::Value* const dict = update.Get(); dict->SetKey(app_id, base::Value(enabled)); } @@ -121,9 +121,9 @@ } void Remove(const std::string& app_id) { - DictionaryPrefUpdateDeprecated update( + DictionaryPrefUpdate update( prefs_, arc::prefs::kArcSetNotificationsEnabledDeferred); - base::DictionaryValue* const dict = update.Get(); + base::Value* const dict = update.Get(); dict->RemoveKey(app_id); } @@ -1391,8 +1391,8 @@ ScheduleAppFolderDeletion(app_id); // Remove from prefs. - DictionaryPrefUpdateDeprecated update(prefs_, arc::prefs::kArcApps); - base::DictionaryValue* apps = update.Get(); + DictionaryPrefUpdate update(prefs_, arc::prefs::kArcApps); + base::Value* apps = update.Get(); const bool removed = apps->RemoveKey(app_id); DCHECK(removed); @@ -1504,7 +1504,7 @@ } void ArcAppListPrefs::RemovePackageFromPrefs(const std::string& package_name) { - DictionaryPrefUpdateDeprecated(prefs_, arc::prefs::kArcPackages) + DictionaryPrefUpdate(prefs_, arc::prefs::kArcPackages) .Get() ->RemoveKey(package_name); }
diff --git a/chrome/browser/ui/ash/desks_templates/desks_templates_client_browsertest.cc b/chrome/browser/ui/ash/desks_templates/desks_templates_client_browsertest.cc index 56f219e9..54d1d491 100644 --- a/chrome/browser/ui/ash/desks_templates/desks_templates_client_browsertest.cc +++ b/chrome/browser/ui/ash/desks_templates/desks_templates_client_browsertest.cc
@@ -255,7 +255,7 @@ scoped_feature_list_.InitWithFeatures( /*enabled_features=*/{full_restore::features::kFullRestore, ash::features::kDesksTemplates}, - /*disabled_features=*/{}); + /*disabled_features=*/{ash::features::kDeskTemplateSync}); } DesksTemplatesClientTest(const DesksTemplatesClientTest&) = delete; DesksTemplatesClientTest& operator=(const DesksTemplatesClientTest&) = delete; @@ -1246,7 +1246,7 @@ scoped_feature_list_.InitWithFeatures( /*enabled_features=*/{full_restore::features::kFullRestore, ash::features::kDesksTemplates}, - /*disabled_features=*/{}); + /*disabled_features=*/{ash::features::kDeskTemplateSync}); } DesksTemplatesClientArcTest(const DesksTemplatesClientArcTest&) = delete; DesksTemplatesClientArcTest& operator=(const DesksTemplatesClientArcTest&) = @@ -1364,8 +1364,9 @@ account_id2_ = login_mixin_.users()[1].account_id; // This feature depends on full restore feature, so need to enable it. - scoped_feature_list_.InitAndEnableFeature( - full_restore::features::kFullRestore); + scoped_feature_list_.InitWithFeatures( + /*enabled_features=*/{full_restore::features::kFullRestore}, + /*disabled_features=*/{ash::features::kDeskTemplateSync}); } ~DesksTemplatesClientMultiProfileTest() override = default;
diff --git a/chrome/browser/ui/ash/holding_space/holding_space_persistence_delegate.cc b/chrome/browser/ui/ash/holding_space/holding_space_persistence_delegate.cc index 7a84e80..589a888 100644 --- a/chrome/browser/ui/ash/holding_space/holding_space_persistence_delegate.cc +++ b/chrome/browser/ui/ash/holding_space/holding_space_persistence_delegate.cc
@@ -64,7 +64,7 @@ return; // Write the new finalized `items` to persistent storage. - ListPrefUpdateDeprecated update(profile()->GetPrefs(), kPersistencePath); + ListPrefUpdate update(profile()->GetPrefs(), kPersistencePath); for (const HoldingSpaceItem* item : items) { if (item->progress().IsComplete()) update->Append(item->Serialize()); @@ -77,7 +77,7 @@ return; // Remove the `items` from persistent storage. - ListPrefUpdateDeprecated update(profile()->GetPrefs(), kPersistencePath); + ListPrefUpdate update(profile()->GetPrefs(), kPersistencePath); update->EraseListValueIf([&items](const base::Value& persisted_item) { const std::string& persisted_item_id = HoldingSpaceItem::DeserializeId( base::Value::AsDictionaryValue(persisted_item)); @@ -99,7 +99,7 @@ return; // Attempt to find the finalized `item` in persistent storage. - ListPrefUpdateDeprecated update(profile()->GetPrefs(), kPersistencePath); + ListPrefUpdate update(profile()->GetPrefs(), kPersistencePath); auto item_it = std::find_if( update->GetList().begin(), update->GetList().end(), [&item](const base::Value& persisted_item) {
diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc index 8f2ae40..4f30842 100644 --- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc
@@ -379,7 +379,7 @@ } // Update renderer side settings to allow active mixed content. - web_contents()->ForEachFrame( + GetPage().GetMainDocument().ForEachRenderFrameHost( base::BindRepeating(&::SetAllowRunningInsecureContent)); }
diff --git a/chrome/browser/ui/media_router/cast_dialog_controller.h b/chrome/browser/ui/media_router/cast_dialog_controller.h index beb7cc3f..270d60a 100644 --- a/chrome/browser/ui/media_router/cast_dialog_controller.h +++ b/chrome/browser/ui/media_router/cast_dialog_controller.h
@@ -11,10 +11,6 @@ #include "components/media_router/common/media_route.h" #include "components/media_router/common/media_sink.h" -namespace ui { -struct SelectedFileInfo; -} // namespace ui - namespace media_router { class CastDialogModel; @@ -49,11 +45,6 @@ // is invalid. virtual void StopCasting(const MediaRoute::Id& route_id) = 0; - // Prompts the user to select a local file to cast. The callback is called - // with the info for the selected file, or nullptr if the user declined. - virtual void ChooseLocalFile( - base::OnceCallback<void(const ui::SelectedFileInfo*)> callback) = 0; - // Removes the specified issue. No-op if the ID is invalid. virtual void ClearIssue(const Issue::Id& issue_id) = 0; };
diff --git a/chrome/browser/ui/media_router/media_cast_mode.cc b/chrome/browser/ui/media_router/media_cast_mode.cc index af736bf0..e984585 100644 --- a/chrome/browser/ui/media_router/media_cast_mode.cc +++ b/chrome/browser/ui/media_router/media_cast_mode.cc
@@ -22,8 +22,6 @@ case MediaCastMode::DESKTOP_MIRROR: return l10n_util::GetStringUTF8( IDS_MEDIA_ROUTER_DESKTOP_MIRROR_CAST_MODE); - case MediaCastMode::LOCAL_FILE: - return l10n_util::GetStringUTF8(IDS_MEDIA_ROUTER_LOCAL_FILE_CAST_MODE); default: NOTREACHED(); return ""; @@ -35,7 +33,6 @@ case MediaCastMode::PRESENTATION: case MediaCastMode::TAB_MIRROR: case MediaCastMode::DESKTOP_MIRROR: - case MediaCastMode::LOCAL_FILE: return true; default: return false;
diff --git a/chrome/browser/ui/media_router/media_cast_mode.h b/chrome/browser/ui/media_router/media_cast_mode.h index bd48724..41abc0d 100644 --- a/chrome/browser/ui/media_router/media_cast_mode.h +++ b/chrome/browser/ui/media_router/media_cast_mode.h
@@ -26,8 +26,6 @@ // Capture the entire desktop and stream it to a media sink. Available when // there is a compatible sink. DESKTOP_MIRROR = 0x4, - // Take a local media file to open in a tab and cast. - LOCAL_FILE = 0x8, }; using CastModeSet = std::set<MediaCastMode>;
diff --git a/chrome/browser/ui/media_router/media_router_file_dialog.cc b/chrome/browser/ui/media_router/media_router_file_dialog.cc deleted file mode 100644 index 9a7da21..0000000 --- a/chrome/browser/ui/media_router/media_router_file_dialog.cc +++ /dev/null
@@ -1,294 +0,0 @@ -// Copyright 2017 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/media_router/media_router_file_dialog.h" - -#include <memory> - -#include "base/bind.h" -#include "base/task/cancelable_task_tracker.h" -#include "base/task/post_task.h" -#include "base/task/thread_pool.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_window.h" -#include "chrome/browser/ui/tabs/tab_strip_model.h" -#include "chrome/grit/generated_resources.h" -#include "components/media_router/browser/media_router_metrics.h" -#include "components/media_router/common/issue.h" -#include "media/base/container_names.h" -#include "media/base/mime_util.h" -#include "net/base/filename_util.h" -#include "net/base/mime_util.h" -#include "ui/base/l10n/l10n_util.h" - -namespace media_router { - -namespace { - -std::u16string GetFileName(const ui::SelectedFileInfo& file_info) { - return file_info.file_path.BaseName().LossyDisplayName(); -} - -// Returns info about extensions for files we support as audio video files. -ui::SelectFileDialog::FileTypeInfo GetAudioVideoFileTypeInfo() { - ui::SelectFileDialog::FileTypeInfo file_type_info; - - file_type_info.allowed_paths = ui::SelectFileDialog::FileTypeInfo::ANY_PATH; - - std::vector<base::FilePath::StringType> extensions; - - // Add all extensions from the audio and video mime types. - net::GetExtensionsForMimeType("video/*", &extensions); - net::GetExtensionsForMimeType("audio/*", &extensions); - - // Filter based on what can be played on the media player - std::vector<base::FilePath::StringType> filtered_extensions; - std::copy_if(extensions.begin(), extensions.end(), - std::back_inserter(filtered_extensions), - [](const base::FilePath::StringType& extension) { - std::string mime_type; - net::GetWellKnownMimeTypeFromExtension(extension, &mime_type); - return media::IsSupportedMediaMimeType(mime_type); - }); - - // Add all audio and video extensions as a single type to the dialog. - file_type_info.extensions.push_back(filtered_extensions); - - // Set the description, otherwise it lists all the possible extensions which - // looks bad. - file_type_info.extension_description_overrides.push_back( - l10n_util::GetStringUTF16( - IDS_MEDIA_ROUTER_FILE_DIALOG_AUDIO_VIDEO_FILTER)); - - // Add an option for all files - file_type_info.include_all_files = true; - - return file_type_info; -} - -} // namespace - -MediaRouterFileDialog::FileSystemDelegate::FileSystemDelegate() = default; - -MediaRouterFileDialog::FileSystemDelegate::~FileSystemDelegate() { - if (select_file_dialog_) - select_file_dialog_->ListenerDestroyed(); -} - -bool MediaRouterFileDialog::FileSystemDelegate::FileExists( - const base::FilePath& file_path) const { - // We assume if the path exists, the file exists. - return base::PathExists(file_path); -} - -bool MediaRouterFileDialog::FileSystemDelegate::IsFileReadable( - const base::FilePath& file_path) const { - char buffer[1]; - return base::ReadFile(file_path, buffer, 1) != -1; -} - -bool MediaRouterFileDialog::FileSystemDelegate::IsFileTypeSupported( - const base::FilePath& file_path) const { - std::string mime_type; - net::GetMimeTypeFromFile(file_path, &mime_type); - return media::IsSupportedMediaMimeType(mime_type); -} - -int64_t MediaRouterFileDialog::FileSystemDelegate::GetFileSize( - const base::FilePath& file_path) const { - int64_t file_size; - return base::GetFileSize(file_path, &file_size) ? file_size : -1; -} - -base::FilePath -MediaRouterFileDialog::FileSystemDelegate::GetLastSelectedDirectory( - Browser* browser) const { - return browser->profile()->last_selected_directory(); -} - -void MediaRouterFileDialog::FileSystemDelegate::OpenFileDialog( - ui::SelectFileDialog::Listener* listener, - const Browser* browser, - const base::FilePath& default_directory, - const ui::SelectFileDialog::FileTypeInfo* file_type_info) { - select_file_dialog_ = ui::SelectFileDialog::Create( - listener, std::make_unique<ChromeSelectFilePolicy>( - browser->tab_strip_model()->GetActiveWebContents())); - - gfx::NativeWindow parent_window = browser->window()->GetNativeWindow(); - - select_file_dialog_->SelectFile( - ui::SelectFileDialog::SELECT_OPEN_FILE, std::u16string(), - default_directory, file_type_info, 0, base::FilePath::StringType(), - parent_window, nullptr /* |params| passed to the listener */); -} -// End of FileSystemDelegate default implementations - -MediaRouterFileDialog::MediaRouterFileDialog( - base::WeakPtr<MediaRouterFileDialogDelegate> delegate) - : MediaRouterFileDialog(std::move(delegate), - std::make_unique<FileSystemDelegate>()) {} - -// Used for tests -MediaRouterFileDialog::MediaRouterFileDialog( - base::WeakPtr<MediaRouterFileDialogDelegate> delegate, - std::unique_ptr<FileSystemDelegate> file_system_delegate) - : task_runner_(base::ThreadPool::CreateTaskRunner( - {base::MayBlock(), base::TaskPriority::USER_VISIBLE})), - file_system_delegate_(std::move(file_system_delegate)), - delegate_(std::move(delegate)) {} - -MediaRouterFileDialog::~MediaRouterFileDialog() = default; - -GURL MediaRouterFileDialog::GetLastSelectedFileUrl() { - return selected_file_.has_value() - ? net::FilePathToFileURL(selected_file_->local_path) - : GURL(); -} - -std::u16string MediaRouterFileDialog::GetLastSelectedFileName() { - return selected_file_.has_value() ? GetFileName(selected_file_.value()) - : std::u16string(); -} - -void MediaRouterFileDialog::MaybeReportLastSelectedFileInformation() { - if (selected_file_.has_value()) { - cancelable_task_tracker_.PostTask( - task_runner_.get(), FROM_HERE, - base::BindOnce(&MediaRouterFileDialog::ReportFileFormat, - base::Unretained(this), selected_file_->local_path)); - - cancelable_task_tracker_.PostTask( - task_runner_.get(), FROM_HERE, - base::BindOnce(&MediaRouterFileDialog::ReportFileSize, - base::Unretained(this), selected_file_->local_path)); - } else { - VLOG(1) << "MediaRouterFileDialog did not report file information; no file " - "to report."; - } -} - -void MediaRouterFileDialog::OpenFileDialog(Browser* browser) { - const base::FilePath directory = - file_system_delegate_->GetLastSelectedDirectory(browser); - - const ui::SelectFileDialog::FileTypeInfo file_type_info = - GetAudioVideoFileTypeInfo(); - - file_system_delegate_->OpenFileDialog(this, browser, directory, - &file_type_info); -} - -void MediaRouterFileDialog::ReportFileFormat(const base::FilePath& filename) { - // Windows implementation of ReadFile fails if file smaller than desired size, - // so use file length if file less than 8192 bytes (http://crbug.com/243885). - char buffer[8192]; - int read_size = sizeof(buffer); - int64_t actual_size; - if (base::GetFileSize(filename, &actual_size) && actual_size < read_size) - read_size = actual_size; - int read = base::ReadFile(filename, buffer, read_size); - - MediaRouterMetrics::RecordMediaRouterFileFormat( - media::container_names::DetermineContainer( - reinterpret_cast<const uint8_t*>(buffer), read)); -} - -void MediaRouterFileDialog::ReportFileSize(const base::FilePath& filename) { - int64_t size; - if (base::GetFileSize(filename, &size)) { - MediaRouterMetrics::RecordMediaRouterFileSize(size); - } else { - VLOG(1) << "Can't get file size for file: " << filename.LossyDisplayName() - << "."; - } -} - -void MediaRouterFileDialog::FileSelected(const base::FilePath& path, - int index, - void* params) { - FileSelectedWithExtraInfo(ui::SelectedFileInfo(path, path), index, params); -} - -void MediaRouterFileDialog::FileSelectedWithExtraInfo( - const ui::SelectedFileInfo& file_info, - int index, - void* params) { - cancelable_task_tracker_.PostTaskAndReplyWithResult( - task_runner_.get(), FROM_HERE, - base::BindOnce(&MediaRouterFileDialog::ValidateFile, - base::Unretained(this), file_info), - base::BindOnce(&MediaRouterFileDialog::OnValidationResults, - base::Unretained(this), file_info)); -} - -void MediaRouterFileDialog::OnValidationResults( - ui::SelectedFileInfo file_info, - MediaRouterFileDialog::ValidationResult validation_result) { - if (validation_result == MediaRouterFileDialog::FILE_OK) { - selected_file_ = file_info; - if (delegate_) - delegate_->FileDialogFileSelected(file_info); - } else if (delegate_) { - delegate_->FileDialogSelectionFailed( - CreateIssue(file_info, validation_result)); - } -} - -void MediaRouterFileDialog::FileSelectionCanceled(void* params) { - if (delegate_) - delegate_->FileDialogSelectionCanceled(); -} - -IssueInfo MediaRouterFileDialog::CreateIssue( - const ui::SelectedFileInfo& file_info, - MediaRouterFileDialog::ValidationResult validation_result) { - std::string issue_title; - switch (validation_result) { - case MediaRouterFileDialog::FILE_MISSING: - case MediaRouterFileDialog::FILE_EMPTY: - case MediaRouterFileDialog::FILE_TYPE_NOT_SUPPORTED: - case MediaRouterFileDialog::READ_FAILURE: - issue_title = l10n_util::GetStringFUTF8( - IDS_MEDIA_ROUTER_ISSUE_FILE_CAST_ERROR, GetFileName(file_info)); - break; - case MediaRouterFileDialog::FILE_OK: - // Create issue shouldn't be called with FILE_OK, but to ensure things - // compile, fall through sets |issue_title| to the generic error. - NOTREACHED(); - [[fallthrough]]; - case MediaRouterFileDialog::UNKNOWN_FAILURE: - issue_title = l10n_util::GetStringUTF8( - IDS_MEDIA_ROUTER_ISSUE_FILE_CAST_GENERIC_ERROR); - break; - } - return IssueInfo(issue_title, IssueInfo::Action::DISMISS, - IssueInfo::Severity::WARNING); -} - -MediaRouterFileDialog::ValidationResult MediaRouterFileDialog::ValidateFile( - const ui::SelectedFileInfo& file_info) { - // Attempt to determine if file exsists. - if (!file_system_delegate_->FileExists(file_info.local_path)) - return MediaRouterFileDialog::FILE_MISSING; - - // Attempt to read the file size and verify that the file has contents. - int file_size = file_system_delegate_->GetFileSize(file_info.local_path); - if (file_size < 0) - return MediaRouterFileDialog::READ_FAILURE; - - if (file_size == 0) - return MediaRouterFileDialog::FILE_EMPTY; - - if (!file_system_delegate_->IsFileReadable(file_info.local_path)) - return MediaRouterFileDialog::READ_FAILURE; - - if (!file_system_delegate_->IsFileTypeSupported(file_info.local_path)) - return MediaRouterFileDialog::FILE_TYPE_NOT_SUPPORTED; - - return MediaRouterFileDialog::FILE_OK; -} - -} // namespace media_router
diff --git a/chrome/browser/ui/media_router/media_router_file_dialog.h b/chrome/browser/ui/media_router/media_router_file_dialog.h deleted file mode 100644 index 14bee25..0000000 --- a/chrome/browser/ui/media_router/media_router_file_dialog.h +++ /dev/null
@@ -1,165 +0,0 @@ -// Copyright 2017 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_MEDIA_ROUTER_MEDIA_ROUTER_FILE_DIALOG_H_ -#define CHROME_BROWSER_UI_MEDIA_ROUTER_MEDIA_ROUTER_FILE_DIALOG_H_ - -#include "base/files/file_util.h" -#include "base/memory/weak_ptr.h" -#include "base/task/cancelable_task_tracker.h" -#include "chrome/browser/ui/chrome_select_file_policy.h" -#include "components/media_router/common/issue.h" -#include "ui/shell_dialogs/select_file_dialog.h" -#include "ui/shell_dialogs/selected_file_info.h" -#include "url/gurl.h" - -class Browser; - -namespace base { -class FilePath; -} - -namespace media_router { - -class MediaRouterFileDialog : public ui::SelectFileDialog::Listener { - public: - // The reasons that the file selection might have failed. Passed into the - // failure callback. - enum ValidationResult { - FILE_OK, - // File does not exist. - FILE_MISSING, - // The selected file is empty. - FILE_EMPTY, - // This file type is not supported by the chrome player. - FILE_TYPE_NOT_SUPPORTED, - // The selected file cannot be read. - READ_FAILURE, - // The reason for the failure is unknown. - UNKNOWN_FAILURE, - }; - - class MediaRouterFileDialogDelegate { - public: - virtual ~MediaRouterFileDialogDelegate() {} - - // Called when a file is selected by the user to store the files information - // and tell the message handler to pass along the information. - virtual void FileDialogFileSelected( - const ui::SelectedFileInfo& file_info) = 0; - - // Called when the file selection fails. - virtual void FileDialogSelectionFailed(const IssueInfo& issue) = 0; - - // Called when the file selection is canceled by the user. Optionally - // implementable. - virtual void FileDialogSelectionCanceled() {} - }; - - // A class which defines functions to interact with the file systems. - class FileSystemDelegate { - public: - FileSystemDelegate(); - virtual ~FileSystemDelegate(); - - // Checks if a file exists. - virtual bool FileExists(const base::FilePath& file_path) const; - - // Checks if a file can be read. - virtual bool IsFileReadable(const base::FilePath& file_path) const; - - // Checks if the file type is supported in this browser. - virtual bool IsFileTypeSupported(const base::FilePath& file_path) const; - - // Checks the size of a file, returns -1 if the file size cannot be read. - virtual int64_t GetFileSize(const base::FilePath& file_path) const; - - // Gets the last selected directory based on the browser. - virtual base::FilePath GetLastSelectedDirectory(Browser* browser) const; - - // Opens a dialog with |file_type_info| as the configuration, and shows - // |default_directory| as the starting place. - virtual void OpenFileDialog( - ui::SelectFileDialog::Listener* listener, - const Browser* browser, - const base::FilePath& default_directory, - const ui::SelectFileDialog::FileTypeInfo* file_type_info); - - private: - // The dialog object for the file dialog. Needs to be kept in scope while - // the dialog is open, but is not used for anything else. - scoped_refptr<ui::SelectFileDialog> select_file_dialog_; - }; - - explicit MediaRouterFileDialog( - base::WeakPtr<MediaRouterFileDialogDelegate> delegate); - - // Constuctor with injectable FileSystemDelegate, used for tests. - MediaRouterFileDialog( - base::WeakPtr<MediaRouterFileDialogDelegate> delegate, - std::unique_ptr<FileSystemDelegate> file_system_delegate); - - MediaRouterFileDialog(const MediaRouterFileDialog&) = delete; - MediaRouterFileDialog& operator=(const MediaRouterFileDialog&) = delete; - - ~MediaRouterFileDialog() override; - - virtual GURL GetLastSelectedFileUrl(); - virtual std::u16string GetLastSelectedFileName(); - - // Checks if a file has been recorded as being selected, then attempts to - // report interesting information about the file, such as format. - virtual void MaybeReportLastSelectedFileInformation(); - - // Opens the dialog configured to get a media file. - virtual void OpenFileDialog(Browser* browser); - - private: - // Reports the format of a file to the UMA stats. - void ReportFileFormat(const base::FilePath& filename); - - // Reports the size of a file to the UMA stats. - void ReportFileSize(const base::FilePath& filename); - - // Overridden from SelectFileDialog::Listener: - void FileSelected(const base::FilePath& path, - int index, - void* params) override; - void FileSelectedWithExtraInfo(const ui::SelectedFileInfo& file_info, - int index, - void* params) override; - void FileSelectionCanceled(void* params) override; - - // Returns a reason for failure if the file is not valid, or absl::nullopt if - // it passes validation. Has to be run on seperate thread. - ValidationResult ValidateFile(const ui::SelectedFileInfo& file_info); - - // Takes a file info and optionally a reason for validation failure, and calls - // the appropriate delegate function. - void OnValidationResults( - ui::SelectedFileInfo file_info, - MediaRouterFileDialog::ValidationResult validation_result); - - IssueInfo CreateIssue( - const ui::SelectedFileInfo& file_info, - MediaRouterFileDialog::ValidationResult validation_result); - - // Used to post file operations. Cleans up after itself and cancels unrun - // tasks when destructed. - base::CancelableTaskTracker cancelable_task_tracker_; - scoped_refptr<base::TaskRunner> task_runner_; - - // Pointer to the file last indicated by the system. - absl::optional<ui::SelectedFileInfo> selected_file_; - - // The object which all file system calls go through. - std::unique_ptr<FileSystemDelegate> file_system_delegate_; - - // Object which the media router file dialog callbacks get sent to. - base::WeakPtr<MediaRouterFileDialogDelegate> const delegate_; -}; - -} // namespace media_router - -#endif // CHROME_BROWSER_UI_MEDIA_ROUTER_MEDIA_ROUTER_FILE_DIALOG_H_
diff --git a/chrome/browser/ui/media_router/media_router_file_dialog_unittest.cc b/chrome/browser/ui/media_router/media_router_file_dialog_unittest.cc deleted file mode 100644 index d7111b38..0000000 --- a/chrome/browser/ui/media_router/media_router_file_dialog_unittest.cc +++ /dev/null
@@ -1,216 +0,0 @@ -// Copyright 2017 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/media_router/media_router_file_dialog.h" - -#include <memory> -#include <string> -#include <utility> - -#include "base/memory/raw_ptr.h" -#include "base/run_loop.h" -#include "base/strings/utf_string_conversions.h" -#include "base/task/thread_pool/thread_pool_instance.h" -#include "chrome/grit/generated_resources.h" -#include "components/media_router/common/issue.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" - -using testing::_; -using testing::ContainsRegex; -using testing::Field; -using testing::InvokeWithoutArgs; -using testing::NiceMock; -using testing::Return; -using testing::Test; - -namespace media_router { - -namespace { - -// Clears out async tasks. -void FlushTasks() { - base::ThreadPoolInstance::Get()->FlushForTesting(); - base::RunLoop().RunUntilIdle(); -} - -} // namespace - -class MockDelegate - : public MediaRouterFileDialog::MediaRouterFileDialogDelegate { - public: - MOCK_METHOD1(FileDialogFileSelected, - void(const ui::SelectedFileInfo& file_info)); - MOCK_METHOD1(FileDialogSelectionFailed, void(const IssueInfo& issue)); - MOCK_METHOD0(FileDialogSelectionCanceled, void()); - - base::WeakPtr<MockDelegate> GetWeakPtr() { - return weak_factory_.GetWeakPtr(); - } - - private: - base::WeakPtrFactory<MockDelegate> weak_factory_{this}; -}; - -class MockFileSystemDelegate - : public MediaRouterFileDialog::FileSystemDelegate { - public: - MockFileSystemDelegate() : MediaRouterFileDialog::FileSystemDelegate() {} - ~MockFileSystemDelegate() override {} - - MOCK_CONST_METHOD1(FileExists, bool(const base::FilePath& file_path)); - MOCK_CONST_METHOD1(IsFileReadable, bool(const base::FilePath& file_path)); - MOCK_CONST_METHOD1(IsFileTypeSupported, - bool(const base::FilePath& file_path)); - MOCK_CONST_METHOD1(GetFileSize, int64_t(const base::FilePath& file_path)); - MOCK_CONST_METHOD1(GetLastSelectedDirectory, - base::FilePath(Browser* browser)); - MOCK_METHOD4(OpenFileDialog, - void(ui::SelectFileDialog::Listener* listener, - const Browser* browser, - const base::FilePath& default_directory, - const ui::SelectFileDialog::FileTypeInfo* file_type_info)); -}; - -class MediaRouterFileDialogTest : public Test { - public: - MediaRouterFileDialogTest() - : fake_path_(base::FilePath(FILE_PATH_LITERAL("im/a/fake_path.mp3"))) {} - - void SetUp() override { - mock_delegate_ = std::make_unique<MockDelegate>(); - - auto temp_mock = std::make_unique<NiceMock<MockFileSystemDelegate>>(); - mock_file_system_delegate = temp_mock.get(); - - dialog_ = std::make_unique<MediaRouterFileDialog>( - mock_delegate_->GetWeakPtr(), std::move(temp_mock)); - dialog_as_listener_ = dialog_.get(); - - // Setup default file checks to all pass. - ON_CALL(*mock_file_system_delegate, FileExists(_)) - .WillByDefault(Return(true)); - ON_CALL(*mock_file_system_delegate, IsFileReadable(_)) - .WillByDefault(Return(true)); - ON_CALL(*mock_file_system_delegate, IsFileTypeSupported(_)) - .WillByDefault(Return(true)); - ON_CALL(*mock_file_system_delegate, GetFileSize(_)) - .WillByDefault(Return(1)); - } - - void SelectValidFile(const base::FilePath& path) { - EXPECT_CALL(*mock_file_system_delegate, FileExists(path)) - .WillOnce(Return(true)); - EXPECT_CALL(*mock_file_system_delegate, IsFileReadable(path)) - .WillOnce(Return(true)); - EXPECT_CALL(*mock_file_system_delegate, GetFileSize(path)) - .WillOnce(Return(1)); - - dialog_as_listener_->FileSelected(path, 0, nullptr); - } - - void SelectFileAndExpectFailure(const base::FilePath& path) { - std::u16string path_name = path.BaseName().LossyDisplayName(); - std::string error_title = l10n_util::GetStringFUTF8( - IDS_MEDIA_ROUTER_ISSUE_FILE_CAST_ERROR, path_name); - - EXPECT_CALL(*mock_delegate_, FileDialogSelectionFailed( - Field(&IssueInfo::title, error_title))); - - dialog_as_listener_->FileSelected(path, 0, nullptr); - - // Flush out the async file validation calls. - FlushTasks(); - } - - protected: - std::unique_ptr<MockDelegate> mock_delegate_; - raw_ptr<MockFileSystemDelegate> mock_file_system_delegate = nullptr; - std::unique_ptr<MediaRouterFileDialog> dialog_; - - // Used for simulating calls from a SelectFileDialog. - raw_ptr<ui::SelectFileDialog::Listener> dialog_as_listener_ = nullptr; - - const base::FilePath fake_path_; - - content::BrowserTaskEnvironment task_environment_; -}; - -// File selection succeeds, success callback called with the right file info. -// Selected file URL is set properly. -TEST_F(MediaRouterFileDialogTest, SelectFileSuccess) { - EXPECT_CALL(*mock_delegate_, - FileDialogFileSelected( - Field(&ui::SelectedFileInfo::local_path, fake_path_))); - SelectValidFile(fake_path_); - - FlushTasks(); - - ASSERT_THAT(dialog_->GetLastSelectedFileUrl().GetContent(), - ContainsRegex(base::UTF16ToUTF8(fake_path_.LossyDisplayName()))); -} - -// File selection gets cancelled, and the failure callback gets called. -TEST_F(MediaRouterFileDialogTest, SelectFileCanceled) { - EXPECT_CALL(*mock_delegate_, FileDialogSelectionCanceled()); - - dialog_as_listener_->FileSelectionCanceled(0); -} - -TEST_F(MediaRouterFileDialogTest, SelectFailureFileDoesNotExist) { - EXPECT_CALL(*mock_file_system_delegate, FileExists(fake_path_)) - .WillOnce(Return(false)); - - SelectFileAndExpectFailure(fake_path_); -} - -TEST_F(MediaRouterFileDialogTest, SelectFailureFileDoesNotContainContent) { - EXPECT_CALL(*mock_file_system_delegate, GetFileSize(fake_path_)) - .WillOnce(Return(0)); - - SelectFileAndExpectFailure(fake_path_); -} - -TEST_F(MediaRouterFileDialogTest, SelectFailureCannotReadGetFileSize) { - EXPECT_CALL(*mock_file_system_delegate, GetFileSize(fake_path_)) - .WillOnce(Return(-1)); - - SelectFileAndExpectFailure(fake_path_); -} - -TEST_F(MediaRouterFileDialogTest, SelectFailureCannotReadFile) { - EXPECT_CALL(*mock_file_system_delegate, IsFileReadable(fake_path_)) - .WillOnce(Return(false)); - - SelectFileAndExpectFailure(fake_path_); -} - -TEST_F(MediaRouterFileDialogTest, SelectFailureFileNotSupported) { - EXPECT_CALL(*mock_file_system_delegate, IsFileTypeSupported(fake_path_)) - .WillOnce(Return(false)); - - SelectFileAndExpectFailure(fake_path_); -} - -TEST_F(MediaRouterFileDialogTest, CancelFileSelectionAfterDelegateDeleted) { - mock_delegate_.reset(); - dialog_as_listener_->FileSelectionCanceled(nullptr); -} - -TEST_F(MediaRouterFileDialogTest, SelectValidFileAfterDelegateDeleted) { - mock_delegate_.reset(); - SelectValidFile(fake_path_); -} - -TEST_F(MediaRouterFileDialogTest, SelectInvalidFileAfterDelegateDeleted) { - mock_delegate_.reset(); - - EXPECT_CALL(*mock_file_system_delegate, GetFileSize(fake_path_)) - .WillOnce(Return(-1)); - dialog_as_listener_->FileSelected(fake_path_, 0, nullptr); -} - -} // namespace media_router
diff --git a/chrome/browser/ui/media_router/media_router_ui.cc b/chrome/browser/ui/media_router/media_router_ui.cc index acdc5c109..80bcd14 100644 --- a/chrome/browser/ui/media_router/media_router_ui.cc +++ b/chrome/browser/ui/media_router/media_router_ui.cc
@@ -109,149 +109,8 @@ } #endif -// Observes a WebContents following a call to MediaRouterUI::CreateRoute() -// and calls MediaRoute::CreateRoute() only after naviation is complete. -// Deletes itself when no longer needed. -// -// NOTE(jrw): This observer is needed to support casting a local file into an -// existing tab (i.e. a tab showing the "new tab" page) because of how the tab -// capture code identifed the WebContents to capture. -// -// The tab capture code finds the WebContents using its associated -// RenderFrameHost (via RenderFrameHost::FromID), and navigation causes the -// WebContents to become associated with a different RenderFrameHost from the -// one has when the naviation starts. As a result, trying to capture a tab -// before navigation is complete cases the WebContents not to be found. This -// could, in principle, by fixed by using FrameTreeNode::GloballyFindByID -// instead, because a WebContents is permanently associated with its root -// FrameFreeNode, but the implications of doing so are not clear. -class WebContentsCreateRouteObserver final - : public content::WebContentsObserver { - public: - WebContentsCreateRouteObserver(content::WebContents* tab_contents, - base::OnceClosure on_document_available) - : content::WebContentsObserver(tab_contents), - on_document_available_(std::move(on_document_available)) {} - - void DidFinishNavigation(content::NavigationHandle* handle) override { - std::move(on_document_available_).Run(); - delete this; - } - - void DidStopLoading() override { delete this; } - - void WebContentsDestroyed() override { delete this; } - - private: - base::OnceClosure on_document_available_; -}; - } // namespace -// Observes a WebContents and requests fullscreening of its first -// video element. The request is sent after the WebContents is loaded and tab -// capture has begun. Marked final to prevent inheritance so delete calls are -// contained to scenarios documented below. -class MediaRouterUI::WebContentsFullscreenOnLoadedObserver final - : public content::WebContentsObserver { - public: - WebContentsFullscreenOnLoadedObserver(const GURL& file_url, - content::WebContents* web_contents) - : file_url_(file_url) { - DCHECK(file_url_.SchemeIsFile()); - DCHECK(fullscreen_request_time_.is_null()); - - // If the WebContents is loading, start listening, otherwise just call the - // fullscreen function. - - // This class destroys itself in the following situations (at least one of - // which will occur): - // * after loading is complete and, - // ** capture has begun and fullscreen requested, - // ** 10 seconds have passed without capture, - // * another navigation is started, - // * the WebContents is destroyed. - if (web_contents->IsLoading()) { - Observe(web_contents); - } else { - FullScreenFirstVideoElement(web_contents); - } - } - ~WebContentsFullscreenOnLoadedObserver() override = default; - - // content::WebContentsObserver implementation. - void DidStopLoading() override { - FullScreenFirstVideoElement(web_contents()); - } - - void DidStartNavigation( - content::NavigationHandle* navigation_handle) override { - // If the user takes over and navigates away from the file, stop listening. - // (It is possible however for this listener to be created before the - // navigation to the requested file triggers, so provided we're still on the - // same URL, go ahead and keep listening). - if (file_url_ != navigation_handle->GetURL()) { - delete this; - } - } - - void WebContentsDestroyed() override { - // If the WebContents is destroyed we will never trigger and need to clean - // up. - delete this; - } - - private: - // Sends a request for full screen to the WebContents targeted at the first - // video element. The request is only sent after capture has begun. - void FullScreenFirstVideoElement(content::WebContents* web_contents) { - if (file_url_ != web_contents->GetLastCommittedURL()) { - // The user has navigated before the casting started. Do not attempt to - // fullscreen and cleanup. - return; - } - - fullscreen_request_time_ = base::TimeTicks::Now(); - FullscreenIfContentCaptured(web_contents); - } - - void FullscreenIfContentCaptured(content::WebContents* web_contents) { - if (web_contents->IsBeingCaptured()) { - mojo::AssociatedRemote<blink::mojom::FullscreenVideoElementHandler> - client; - web_contents->GetMainFrame() - ->GetRemoteAssociatedInterfaces() - ->GetInterface(&client); - client->RequestFullscreenVideoElement(); - delete this; - return; - } - if (base::TimeTicks::Now() - fullscreen_request_time_ > base::Seconds(10)) { - // If content capture hasn't started within the timeout skip fullscreen. - DLOG(WARNING) << "Capture of local content did not start within timeout"; - delete this; - return; - } - - capture_poll_timer_.Start( - FROM_HERE, base::Seconds(1), - base::BindOnce( - &WebContentsFullscreenOnLoadedObserver::FullscreenIfContentCaptured, - base::Unretained(this), web_contents)); - } - - const GURL file_url_; - - // The time at which fullscreen was requested. - base::TimeTicks fullscreen_request_time_; - - // Poll timer to monitor the capturer count when fullscreening local files. - // - // TODO(crbug.com/540965): Add a method to WebContentsObserver to report - // capturer count changes and get rid of this polling-based approach. - base::OneShotTimer capture_poll_timer_; -}; - MediaRouterUI::MediaRouterUI(content::WebContents* initiator) : presentation_manager_(WebContentsPresentationManager::Get(initiator)), initiator_(initiator), @@ -314,12 +173,6 @@ TerminateRoute(terminating_route_id_.value()); } -void MediaRouterUI::ChooseLocalFile( - base::OnceCallback<void(const ui::SelectedFileInfo*)> callback) { - file_selection_callback_ = std::move(callback); - OpenFileDialog(); -} - void MediaRouterUI::ClearIssue(const Issue::Id& issue_id) { RemoveIssue(issue_id); } @@ -387,38 +240,20 @@ // necessary. content::WebContents* tab_contents = initiator_; - absl::optional<RouteParameters> params; - if (cast_mode == MediaCastMode::LOCAL_FILE) { - GURL url = media_router_file_dialog_->GetLastSelectedFileUrl(); - tab_contents = OpenTabWithUrl(url); - params = GetLocalFileRouteParameters(sink_id, url, tab_contents); - } else { - params = GetRouteParameters(sink_id, cast_mode); - } - + absl::optional<RouteParameters> params = + GetRouteParameters(sink_id, cast_mode); if (!params) { SendIssueForUnableToCast(cast_mode, sink_id); return false; } - GetIssueManager()->ClearNonBlockingIssues(); - - auto on_document_available = base::BindOnce( - &MediaRouter::CreateRoute, base::Unretained(GetMediaRouter()), + GetMediaRouter()->CreateRoute( params->source_id, sink_id, params->origin, tab_contents, base::BindOnce(&RunRouteResponseCallbacks, std::move(params->presentation_callback), std::move(params->route_result_callbacks)), params->timeout, params->off_the_record); - if (cast_mode == MediaCastMode::LOCAL_FILE) { - // The assignment is just for testing; the creation of the observer is not! - web_contents_observer_for_test_ = new WebContentsCreateRouteObserver( - tab_contents, std::move(on_document_available)); - } else { - std::move(on_document_available).Run(); - } - // TODO(crbug.com/1015203): This call to UpdateSinks() was originally in // StartCasting(), but it causes Chrome to crash when the desktop picker // dialog is shown, so for now we just don't call it in that case. Move it @@ -501,15 +336,6 @@ GetIssueManager()->ClearIssue(issue_id); } -void MediaRouterUI::OpenFileDialog() { - if (!media_router_file_dialog_) { - media_router_file_dialog_ = - std::make_unique<MediaRouterFileDialog>(weak_factory_.GetWeakPtr()); - } - - media_router_file_dialog_->OpenFileDialog(GetBrowser()); -} - void MediaRouterUI::LogMediaSinkStatus() { std::vector<std::string> sink_ids; for (const auto& sink : GetEnabledSinks()) { @@ -613,10 +439,6 @@ MediaCastMode::DESKTOP_MIRROR, {MediaSource::ForUnchosenDesktop()}, origin); - // File mirroring is always available. - query_result_manager_->SetSourcesForCastMode( - MediaCastMode::LOCAL_FILE, {MediaSource::ForLocalFile()}, origin); - SessionID::id_type tab_id = sessions::SessionTabHelper::IdForTab(initiator_).id(); if (tab_id != -1) { @@ -783,10 +605,6 @@ issue_title = l10n_util::GetStringUTF8( IDS_MEDIA_ROUTER_ISSUE_CREATE_ROUTE_TIMEOUT_FOR_DESKTOP); break; - case LOCAL_FILE: - issue_title = l10n_util::GetStringUTF8( - IDS_MEDIA_ROUTER_ISSUE_FILE_CAST_GENERIC_ERROR); - break; } IssueInfo issue_info(issue_title, IssueInfo::Action::DISMISS, @@ -964,87 +782,6 @@ return ui_sink; } -void MediaRouterUI::FileDialogFileSelected( - const ui::SelectedFileInfo& file_info) { - std::move(file_selection_callback_).Run(&file_info); -} - -void MediaRouterUI::FileDialogSelectionFailed(const IssueInfo& issue) { - AddIssue(issue); - std::move(file_selection_callback_).Run(nullptr); -} - -void MediaRouterUI::FileDialogSelectionCanceled() { - std::move(file_selection_callback_).Run(nullptr); -} - -absl::optional<RouteParameters> MediaRouterUI::GetLocalFileRouteParameters( - const MediaSink::Id& sink_id, - const GURL& file_url, - content::WebContents* tab_contents) { - RouteParameters params; - SessionID::id_type tab_id = - sessions::SessionTabHelper::IdForTab(tab_contents).id(); - params.source_id = MediaSource::ForTab(tab_id).id(); - params.origin = url::Origin(); - - int request_id = current_route_request() ? current_route_request()->id : -1; - params.route_result_callbacks.push_back(base::BindOnce( - &MediaRouterUI::OnRouteResponseReceived, weak_factory_.GetWeakPtr(), - request_id, sink_id, MediaCastMode::LOCAL_FILE, - GetPresentationRequestSourceName())); - - params.route_result_callbacks.push_back( - base::BindOnce(&MaybeReportCastingSource, MediaCastMode::LOCAL_FILE)); - - params.route_result_callbacks.push_back(base::BindOnce( - &MediaRouterUI::MaybeReportFileInformation, weak_factory_.GetWeakPtr())); - - params.route_result_callbacks.push_back( - base::BindOnce(&MediaRouterUI::FullScreenFirstVideoElement, - weak_factory_.GetWeakPtr(), file_url, tab_contents)); - - params.timeout = GetRouteRequestTimeout(MediaCastMode::LOCAL_FILE); - CHECK(initiator_); - params.off_the_record = initiator_->GetBrowserContext()->IsOffTheRecord(); - - return absl::make_optional(std::move(params)); -} - -// TODO(crbug.com/792547): Refactor FullScreenFirstVideoElement() and -// MaybeReportFileInformation() into a local media casting specific location -// instead of here in the main ui. -void MediaRouterUI::FullScreenFirstVideoElement( - const GURL& file_url, - content::WebContents* web_contents, - const RouteRequestResult& result) { - if (result.result_code() == RouteRequestResult::OK) - new WebContentsFullscreenOnLoadedObserver(file_url, web_contents); -} - -void MediaRouterUI::MaybeReportFileInformation( - const RouteRequestResult& result) { - if (result.result_code() == RouteRequestResult::OK) - media_router_file_dialog_->MaybeReportLastSelectedFileInformation(); -} - -content::WebContents* MediaRouterUI::OpenTabWithUrl(const GURL& url) { - // Check if the current page is a new tab. If so open file in current page. - // If not then open a new page. - auto initiatorOrigin = initiator_->GetVisibleURL().DeprecatedGetOriginAsURL(); - if (initiatorOrigin == - GURL(chrome::kChromeUINewTabPageURL).DeprecatedGetOriginAsURL() || - initiatorOrigin == - GURL(chrome::kChromeUINewTabURL).DeprecatedGetOriginAsURL()) { - content::NavigationController::LoadURLParams load_params(url); - load_params.transition_type = ui::PAGE_TRANSITION_GENERATED; - initiator_->GetController().LoadURLWithParams(load_params); - return initiator_; - } - return chrome::AddSelectedTabWithURL(GetBrowser(), url, - ui::PAGE_TRANSITION_LINK); -} - MediaRouter* MediaRouterUI::GetMediaRouter() const { return MediaRouterFactory::GetApiForBrowserContext( initiator_->GetBrowserContext());
diff --git a/chrome/browser/ui/media_router/media_router_ui.h b/chrome/browser/ui/media_router/media_router_ui.h index b99ba48..e235a00 100644 --- a/chrome/browser/ui/media_router/media_router_ui.h +++ b/chrome/browser/ui/media_router/media_router_ui.h
@@ -19,7 +19,6 @@ #include "chrome/browser/ui/media_router/cast_dialog_controller.h" #include "chrome/browser/ui/media_router/cast_dialog_model.h" #include "chrome/browser/ui/media_router/media_cast_mode.h" -#include "chrome/browser/ui/media_router/media_router_file_dialog.h" #include "chrome/browser/ui/media_router/media_router_ui_helper.h" #include "chrome/browser/ui/media_router/media_sink_with_cast_modes.h" #include "chrome/browser/ui/media_router/query_result_manager.h" @@ -32,6 +31,7 @@ #include "components/media_router/common/media_source.h" #include "url/origin.h" +class Browser; class GURL; namespace content { @@ -52,11 +52,9 @@ class RouteRequestResult; // Functions as an intermediary between MediaRouter and Views Cast dialog. -class MediaRouterUI - : public CastDialogController, - public QueryResultManager::Observer, - public WebContentsPresentationManager::Observer, - public MediaRouterFileDialog::MediaRouterFileDialogDelegate { +class MediaRouterUI : public CastDialogController, + public QueryResultManager::Observer, + public WebContentsPresentationManager::Observer { public: explicit MediaRouterUI(content::WebContents* initiator); @@ -71,8 +69,6 @@ void StartCasting(const std::string& sink_id, MediaCastMode cast_mode) override; void StopCasting(const std::string& route_id) override; - void ChooseLocalFile( - base::OnceCallback<void(const ui::SelectedFileInfo*)> callback) override; void ClearIssue(const Issue::Id& issue_id) override; // Initializes internal state (e.g. starts listening for MediaSinks) for @@ -123,9 +119,6 @@ // Calls MediaRouter to remove the given issue. void RemoveIssue(const Issue::Id& issue_id); - // Opens a file picker for when the user selected local file casting. - void OpenFileDialog(); - // Uses LoggerImpl to log current available sinks. void LogMediaSinkStatus(); @@ -301,28 +294,6 @@ const MediaRoute* route, const absl::optional<Issue>& issue); - // MediaRouterFileDialogDelegate: - void FileDialogFileSelected(const ui::SelectedFileInfo& file_info) override; - void FileDialogSelectionFailed(const IssueInfo& issue) override; - void FileDialogSelectionCanceled() override; - - // Populates route-related parameters for CreateRoute() when doing file - // casting. - absl::optional<RouteParameters> GetLocalFileRouteParameters( - const MediaSink::Id& sink_id, - const GURL& file_url, - content::WebContents* tab_contents); - - // If the current URL for |web_contents| is |file_url|, requests the first - // video in it to be shown fullscreen. - void FullScreenFirstVideoElement(const GURL& file_url, - content::WebContents* web_contents, - const RouteRequestResult& result); - - // Sends a request to the file dialog to log UMA stats for the file that was - // cast if the result is successful. - void MaybeReportFileInformation(const RouteRequestResult& result); - // Opens the URL in a tab, returns the tab it was opened in. content::WebContents* OpenTabWithUrl(const GURL& url); @@ -344,11 +315,6 @@ return query_result_manager_.get(); } - void set_media_router_file_dialog_for_test( - std::unique_ptr<MediaRouterFileDialog> file_dialog) { - media_router_file_dialog_ = std::move(file_dialog); - } - void set_start_presentation_context_for_test( std::unique_ptr<StartPresentationContext> start_presentation_context) { start_presentation_context_ = std::move(start_presentation_context); @@ -363,10 +329,6 @@ // Contains up-to-date data to show in the dialog. CastDialogModel model_; - // This value is set when the user opens a file picker, and used when a file - // is selected and casting starts. - absl::optional<MediaSink::Id> local_file_sink_id_; - // This value is set when the UI requests a route to be terminated, and gets // reset when the route is removed. absl::optional<MediaRoute::Id> terminating_route_id_; @@ -375,9 +337,6 @@ // TODO(takumif): CastDialogModel should manage the observers. base::ObserverList<CastDialogController::Observer>::Unchecked observers_; - base::OnceCallback<void(const ui::SelectedFileInfo*)> - file_selection_callback_; - // This is non-null while this instance is registered to receive // updates from them. std::unique_ptr<MediaRoutesObserver> routes_observer_; @@ -410,10 +369,6 @@ // WebContents for the tab for which the Cast dialog is shown. const raw_ptr<content::WebContents> initiator_; - // The dialog that handles opening the file dialog and validating and - // returning the results. - std::unique_ptr<MediaRouterFileDialog> media_router_file_dialog_; - std::unique_ptr<IssuesObserver> issues_observer_; // Keeps track of which display the initiator WebContents is on. This is used
diff --git a/chrome/browser/ui/media_router/media_router_ui_helper.cc b/chrome/browser/ui/media_router/media_router_ui_helper.cc index 64c0e6a..ec401e6e 100644 --- a/chrome/browser/ui/media_router/media_router_ui_helper.cc +++ b/chrome/browser/ui/media_router/media_router_ui_helper.cc
@@ -15,7 +15,6 @@ // The amount of time to wait for a response when creating a new route. const int kCreateRouteTimeoutSeconds = 20; const int kCreateRouteTimeoutSecondsForTab = 60; -const int kCreateRouteTimeoutSecondsForLocalFile = 60; const int kCreateRouteTimeoutSecondsForDesktop = 120; } // namespace @@ -48,8 +47,6 @@ return base::Seconds(kCreateRouteTimeoutSecondsForTab); case DESKTOP_MIRROR: return base::Seconds(kCreateRouteTimeoutSecondsForDesktop); - case LOCAL_FILE: - return base::Seconds(kCreateRouteTimeoutSecondsForLocalFile); default: NOTREACHED(); return base::TimeDelta();
diff --git a/chrome/browser/ui/media_router/media_router_ui_unittest.cc b/chrome/browser/ui/media_router/media_router_ui_unittest.cc index 187b63ec..42b2047 100644 --- a/chrome/browser/ui/media_router/media_router_ui_unittest.cc +++ b/chrome/browser/ui/media_router/media_router_ui_unittest.cc
@@ -91,16 +91,6 @@ raw_ptr<CastDialogController> controller_ = nullptr; }; -class MockMediaRouterFileDialog : public MediaRouterFileDialog { - public: - MockMediaRouterFileDialog() : MediaRouterFileDialog(nullptr) {} - ~MockMediaRouterFileDialog() override {} - - MOCK_METHOD0(GetLastSelectedFileUrl, GURL()); - MOCK_METHOD0(GetLastSelectedFileName, std::u16string()); - MOCK_METHOD1(OpenFileDialog, void(Browser* browser)); -}; - class PresentationRequestCallbacks { public: PresentationRequestCallbacks() {} @@ -543,28 +533,6 @@ } #endif -// Tests that if a local file CreateRoute call is made from a new tab, the -// file will be opened in the new tab. -TEST_F(MediaRouterViewsUITest, RouteCreationLocalFileModeInTab) { - const GURL empty_tab = GURL(chrome::kChromeUINewTabURL); - const std::string file_url = "file:///some/url/for/a/file.mp3"; - CreateMediaRouterUIForURL(empty_tab); - auto file_dialog = std::make_unique<MockMediaRouterFileDialog>(); - auto* file_dialog_ptr = file_dialog.get(); - ui_->set_media_router_file_dialog_for_test(std::move(file_dialog)); - - EXPECT_CALL(*file_dialog_ptr, GetLastSelectedFileUrl()) - .WillOnce(Return(GURL(file_url))); - content::WebContents* location_file_opened = nullptr; - EXPECT_CALL(*mock_router_, CreateRouteInternal(_, _, _, _, _, _, _)) - .WillOnce(SaveArgWithMove<3>(&location_file_opened)); - ui_->CreateRoute(kSinkId, MediaCastMode::LOCAL_FILE); - ui_->SimulateDocumentAvailableForTest(); - - ASSERT_EQ(location_file_opened, web_contents()); - ASSERT_EQ(location_file_opened->GetVisibleURL(), file_url); -} - TEST_F(MediaRouterViewsUITest, SortedSinks) { NotifyUiOnResultsUpdated({{CreateCastSink("sink3", "B sink"), {}}, {CreateCastSink("sink2", "A sink"), {}},
diff --git a/chrome/browser/ui/task_manager/task_manager_table_model.cc b/chrome/browser/ui/task_manager/task_manager_table_model.cc index 4f7f7de..14d84f5 100644 --- a/chrome/browser/ui/task_manager/task_manager_table_model.cc +++ b/chrome/browser/ui/task_manager/task_manager_table_model.cc
@@ -863,8 +863,8 @@ if (!local_state) return; - DictionaryPrefUpdateDeprecated dict_update( - local_state, prefs::kTaskManagerColumnVisibility); + DictionaryPrefUpdate dict_update(local_state, + prefs::kTaskManagerColumnVisibility); base::DictionaryValue::Iterator it(*columns_settings_); while (!it.IsAtEnd()) { @@ -874,13 +874,13 @@ // Store the current sort status to be restored again at startup. if (!table_view_delegate_->IsTableSorted()) { - dict_update->SetString(kSortColumnIdKey, ""); + dict_update->SetStringKey(kSortColumnIdKey, ""); } else { const auto& sort_descriptor = table_view_delegate_->GetSortDescriptor(); - dict_update->SetString( + dict_update->SetStringKey( kSortColumnIdKey, GetColumnIdAsString(sort_descriptor.sorted_column_id)); - dict_update->SetBoolean(kSortIsAscendingKey, sort_descriptor.is_ascending); + dict_update->SetBoolKey(kSortIsAscendingKey, sort_descriptor.is_ascending); } }
diff --git a/chrome/browser/ui/ui_features.cc b/chrome/browser/ui/ui_features.cc index 29616fa..2f9abfe 100644 --- a/chrome/browser/ui/ui_features.cc +++ b/chrome/browser/ui/ui_features.cc
@@ -126,10 +126,6 @@ const base::Feature kTabGroupsAutoCreate{"TabGroupsAutoCreate", base::FEATURE_DISABLED_BY_DEFAULT}; -// Enables tabs to be frozen when collapsed. https://crbug.com/1110108 -const base::Feature kTabGroupsCollapseFreezing{ - "TabGroupsCollapseFreezing", base::FEATURE_ENABLED_BY_DEFAULT}; - // Directly controls the "new" badge (as opposed to old "master switch"; see // https://crbug.com/1169907 for master switch deprecation and // https://crbug.com/968587 for the feature itself)
diff --git a/chrome/browser/ui/ui_features.h b/chrome/browser/ui/ui_features.h index 29ad0b34..a0f59c6 100644 --- a/chrome/browser/ui/ui_features.h +++ b/chrome/browser/ui/ui_features.h
@@ -76,8 +76,6 @@ extern const base::Feature kTabGroupsAutoCreate; -extern const base::Feature kTabGroupsCollapseFreezing; - extern const base::Feature kTabGroupsNewBadgePromo; extern const base::Feature kTabGroupsSave;
diff --git a/chrome/browser/ui/user_education/feature_promo_snooze_service.cc b/chrome/browser/ui/user_education/feature_promo_snooze_service.cc index 57de208..0640ed2 100644 --- a/chrome/browser/ui/user_education/feature_promo_snooze_service.cc +++ b/chrome/browser/ui/user_education/feature_promo_snooze_service.cc
@@ -174,9 +174,8 @@ } void FeaturePromoSnoozeService::Reset(const base::Feature& iph_feature) { - DictionaryPrefUpdateDeprecated update(profile_->GetPrefs(), - kIPHSnoozeDataPath); - base::DictionaryValue* pref_data = update.Get(); + DictionaryPrefUpdate update(profile_->GetPrefs(), kIPHSnoozeDataPath); + base::Value* pref_data = update.Get(); pref_data->RemovePath(iph_feature.name); } @@ -239,9 +238,8 @@ const FeaturePromoSnoozeService::SnoozeData& snooze_data) { std::string path_prefix = std::string(iph_feature.name) + "."; - DictionaryPrefUpdateDeprecated update(profile_->GetPrefs(), - kIPHSnoozeDataPath); - base::DictionaryValue* pref_data = update.Get(); + DictionaryPrefUpdate update(profile_->GetPrefs(), kIPHSnoozeDataPath); + base::Value* pref_data = update.Get(); pref_data->SetBoolPath(path_prefix + kIPHIsDismissedPath, snooze_data.is_dismissed);
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view.h b/chrome/browser/ui/views/frame/browser_non_client_frame_view.h index 84b05d1..5470322 100644 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view.h +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view.h
@@ -46,7 +46,7 @@ // Called when BrowserView creates all it's child views. virtual void OnBrowserViewInitViewsComplete(); - // Called on Mac after the browser window is fullscreened or unfullscreened. + // Called after the browser window is fullscreened or unfullscreened. virtual void OnFullscreenStateChanged(); // Returns whether the caption buttons are drawn at the leading edge (i.e. the
diff --git a/chrome/browser/ui/views/global_media_controls/media_item_ui_device_selector_view_unittest.cc b/chrome/browser/ui/views/global_media_controls/media_item_ui_device_selector_view_unittest.cc index da85d25c..13ef135 100644 --- a/chrome/browser/ui/views/global_media_controls/media_item_ui_device_selector_view_unittest.cc +++ b/chrome/browser/ui/views/global_media_controls/media_item_ui_device_selector_view_unittest.cc
@@ -140,9 +140,6 @@ void(const std::string& sink_id, media_router::MediaCastMode cast_mode)); MOCK_METHOD1(StopCasting, void(const std::string& route_id)); - MOCK_METHOD1( - ChooseLocalFile, - void(base::OnceCallback<void(const ui::SelectedFileInfo*)> callback)); MOCK_METHOD1(ClearIssue, void(const media_router::Issue::Id& issue_id)); };
diff --git a/chrome/browser/ui/views/media_router/cast_dialog_metrics.cc b/chrome/browser/ui/views/media_router/cast_dialog_metrics.cc index 8836d93..98476b7 100644 --- a/chrome/browser/ui/views/media_router/cast_dialog_metrics.cc +++ b/chrome/browser/ui/views/media_router/cast_dialog_metrics.cc
@@ -34,8 +34,6 @@ case MediaCastMode::DESKTOP_MIRROR: return DialogActivationLocationAndCastMode:: kPinnedIconAndDesktopMirror; - case MediaCastMode::LOCAL_FILE: - return DialogActivationLocationAndCastMode::kPinnedIconAndLocalFile; } } else { switch (cast_mode) { @@ -48,9 +46,6 @@ case MediaCastMode::DESKTOP_MIRROR: return DialogActivationLocationAndCastMode:: kEphemeralIconAndDesktopMirror; - case MediaCastMode::LOCAL_FILE: - return DialogActivationLocationAndCastMode:: - kEphemeralIconAndLocalFile; } } break; @@ -64,8 +59,6 @@ case MediaCastMode::DESKTOP_MIRROR: return DialogActivationLocationAndCastMode:: kContextMenuAndDesktopMirror; - case MediaCastMode::LOCAL_FILE: - return DialogActivationLocationAndCastMode::kContextMenuAndLocalFile; } break; case MediaRouterDialogOpenOrigin::PAGE: @@ -76,8 +69,6 @@ return DialogActivationLocationAndCastMode::kPageAndTabMirror; case MediaCastMode::DESKTOP_MIRROR: return DialogActivationLocationAndCastMode::kPageAndDesktopMirror; - case MediaCastMode::LOCAL_FILE: - return DialogActivationLocationAndCastMode::kPageAndLocalFile; } break; case MediaRouterDialogOpenOrigin::APP_MENU: @@ -88,8 +79,6 @@ return DialogActivationLocationAndCastMode::kAppMenuAndTabMirror; case MediaCastMode::DESKTOP_MIRROR: return DialogActivationLocationAndCastMode::kAppMenuAndDesktopMirror; - case MediaCastMode::LOCAL_FILE: - return DialogActivationLocationAndCastMode::kAppMenuAndLocalFile; } break; // |OVERFLOW_MENU| refers to extension icons hidden in the app menu. That
diff --git a/chrome/browser/ui/views/media_router/cast_dialog_view_browsertest.cc b/chrome/browser/ui/views/media_router/cast_dialog_view_browsertest.cc index 6c2f1e3c..4e4062e9 100644 --- a/chrome/browser/ui/views/media_router/cast_dialog_view_browsertest.cc +++ b/chrome/browser/ui/views/media_router/cast_dialog_view_browsertest.cc
@@ -62,9 +62,6 @@ void StartCasting(const media_router::MediaSink::Id& sink_id, media_router::MediaCastMode cast_mode) override {} void StopCasting(const media_router::MediaRoute::Id& route_id) override {} - void ChooseLocalFile( - base::OnceCallback<void(const ui::SelectedFileInfo*)> callback) override { - } void ClearIssue(const media_router::Issue::Id& issue_id) override {} };
diff --git a/chrome/browser/ui/views/media_router/cast_dialog_view_unittest.cc b/chrome/browser/ui/views/media_router/cast_dialog_view_unittest.cc index 74b2bfb..c392e43 100644 --- a/chrome/browser/ui/views/media_router/cast_dialog_view_unittest.cc +++ b/chrome/browser/ui/views/media_router/cast_dialog_view_unittest.cc
@@ -85,9 +85,6 @@ MOCK_METHOD2(StartCasting, void(const std::string& sink_id, MediaCastMode cast_mode)); MOCK_METHOD1(StopCasting, void(const std::string& route_id)); - MOCK_METHOD1( - ChooseLocalFile, - void(base::OnceCallback<void(const ui::SelectedFileInfo*)> callback)); MOCK_METHOD1(ClearIssue, void(const Issue::Id& issue_id)); };
diff --git a/chrome/browser/ui/views/payments/payment_request_journey_logger_browsertest.cc b/chrome/browser/ui/views/payments/payment_request_journey_logger_browsertest.cc index abfb94d..991a1f4 100644 --- a/chrome/browser/ui/views/payments/payment_request_journey_logger_browsertest.cc +++ b/chrome/browser/ui/views/payments/payment_request_journey_logger_browsertest.cc
@@ -24,11 +24,96 @@ #include "services/metrics/public/cpp/ukm_source.h" namespace payments { +namespace { +class BasicCardEnabledTestBase : public PaymentRequestBrowserTestBase { + public: + BasicCardEnabledTestBase(const BasicCardEnabledTestBase&) = delete; + BasicCardEnabledTestBase& operator=(const BasicCardEnabledTestBase&) = delete; -using PaymentRequestJourneyLoggerTestBase = PaymentRequestBrowserTestBase; + protected: + BasicCardEnabledTestBase() { + feature_list_.InitAndEnableFeature(features::kPaymentRequestBasicCard); + } + + private: + base::test::ScopedFeatureList feature_list_; +}; + +class BasicCardDisabledTestBase : public PaymentRequestBrowserTestBase { + public: + BasicCardDisabledTestBase(const BasicCardDisabledTestBase&) = delete; + BasicCardDisabledTestBase& operator=(const BasicCardDisabledTestBase&) = + delete; + + protected: + BasicCardDisabledTestBase() { + feature_list_.InitAndDisableFeature(features::kPaymentRequestBasicCard); + } + + private: + base::test::ScopedFeatureList feature_list_; +}; +} // namespace + +using PaymentRequestJourneyLoggerSelectedPaymentAppBasicCardDisabledTest = + BasicCardDisabledTestBase; + +// Tests that the selected app metric is correctly logged when the +// Payment Request is completed with a payment handler. +IN_PROC_BROWSER_TEST_F( + PaymentRequestJourneyLoggerSelectedPaymentAppBasicCardDisabledTest, + TestSelectedPaymentMethod) { + std::string a_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", + &a_method_name); + std::string b_method_name; + InstallPaymentApp("b.com", "payment_request_success_responder.js", + &b_method_name); + + NavigateTo("/payment_request_no_shipping_test.html"); + base::HistogramTester histogram_tester; + + // Complete the Payment Request. + InvokePaymentRequestUIWithJs(content::JsReplace( + "buyWithMethods([{supportedMethods:$1}, {supportedMethods:$2}]);", + a_method_name, b_method_name)); + ResetEventWaiterForSequence( + {DialogEvent::PROCESSING_SPINNER_SHOWN, DialogEvent::DIALOG_CLOSED}); + ClickOnDialogViewAndWait(DialogViewID::PAY_BUTTON, dialog_view()); + + // Make sure the correct events were logged. + std::vector<base::Bucket> buckets = + histogram_tester.GetAllSamples("PaymentRequest.Events"); + ASSERT_EQ(1U, buckets.size()); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_SHOWN); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_PAY_CLICKED); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_RECEIVED_INSTRUMENT_DETAILS); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SKIPPED_SHOW); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_COMPLETED); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_USER_ABORTED); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_OTHER_ABORTED); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_HAD_INITIAL_FORM_OF_PAYMENT); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_HAD_NECESSARY_COMPLETE_SUGGESTIONS); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_SHIPPING); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_NAME); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_PHONE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_EMAIL); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_FALSE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_TRUE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_BASIC_CARD); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_GOOGLE); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_OTHER); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_CREDIT_CARD); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_GOOGLE); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_SELECTED_OTHER); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_COULD_NOT_SHOW); +} using PaymentRequestJourneyLoggerSelectedPaymentAppTest = - PaymentRequestJourneyLoggerTestBase; + BasicCardEnabledTestBase; // Tests that the selected app metric is correctly logged when the // Payment Request is completed with a credit card. @@ -81,7 +166,7 @@ } using PaymentRequestJourneyLoggerNoSupportedPaymentMethodTest = - PaymentRequestJourneyLoggerTestBase; + BasicCardEnabledTestBase; IN_PROC_BROWSER_TEST_F(PaymentRequestJourneyLoggerNoSupportedPaymentMethodTest, OnlyBobpaySupported) { @@ -132,8 +217,7 @@ EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_COULD_NOT_SHOW); } -using PaymentRequestJourneyLoggerMultipleShowTest = - PaymentRequestJourneyLoggerTestBase; +using PaymentRequestJourneyLoggerMultipleShowTest = BasicCardEnabledTestBase; IN_PROC_BROWSER_TEST_F(PaymentRequestJourneyLoggerMultipleShowTest, ShowSameRequest) { @@ -196,23 +280,8 @@ EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_COULD_NOT_SHOW); } -class PaymentRequestJourneyLoggerMultipleShowTestWithPaymentHandlersEnabled - : public PaymentRequestJourneyLoggerMultipleShowTest { - public: - PaymentRequestJourneyLoggerMultipleShowTestWithPaymentHandlersEnabled() { - // Enable payment handlers, also known as service worker payment apps. The - // rest of the test is identical to - // "StartNewRequestWithoutPaymentAppsFeature" testcase above. - feature_list_.InitAndEnableFeature(features::kServiceWorkerPaymentApps); - } - - private: - base::test::ScopedFeatureList feature_list_; -}; - -IN_PROC_BROWSER_TEST_F( - PaymentRequestJourneyLoggerMultipleShowTestWithPaymentHandlersEnabled, - StartNewRequest) { +IN_PROC_BROWSER_TEST_F(PaymentRequestJourneyLoggerMultipleShowTest, + StartNewRequest) { NavigateTo("/payment_request_multiple_show_test.html"); base::HistogramTester histogram_tester; @@ -320,6 +389,191 @@ EXPECT_TRUE(could_not_show & JourneyLogger::EVENT_COULD_NOT_SHOW); } +using PaymentRequestJourneyLoggerMultipleShowBasicCardDisabledTest = + BasicCardDisabledTestBase; + +IN_PROC_BROWSER_TEST_F( + PaymentRequestJourneyLoggerMultipleShowBasicCardDisabledTest, + ShowSameRequest) { + std::string a_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", + &a_method_name); + std::string b_method_name; + InstallPaymentApp("b.com", "payment_request_success_responder.js", + &b_method_name); + + NavigateTo("c.com", "/payment_request_multiple_show_test.html"); + + base::HistogramTester histogram_tester; + + // Start a Payment Request. + InvokePaymentRequestUIWithJs(content::JsReplace( + "buyWithMethods([{supportedMethods:$1}, {supportedMethods:$2}]);", + a_method_name, b_method_name)); + + // Try to show it again. + content::WebContents* web_contents = GetActiveWebContents(); + const std::string click_buy_button_js = + "(function() { document.getElementById('showAgain').click(); })();"; + ASSERT_TRUE(content::ExecuteScript(web_contents, click_buy_button_js)); + + // Complete the original Payment Request. + ResetEventWaiterForSequence( + {DialogEvent::PROCESSING_SPINNER_SHOWN, DialogEvent::DIALOG_CLOSED}); + ClickOnDialogViewAndWait(DialogViewID::PAY_BUTTON, dialog_view()); + + // Trying to show the same request twice is not considered a concurrent + // request. + EXPECT_TRUE( + histogram_tester.GetAllSamples("PaymentRequest.CheckoutFunnel.NoShow") + .empty()); + + // Make sure the correct events were logged. + std::vector<base::Bucket> buckets = + histogram_tester.GetAllSamples("PaymentRequest.Events"); + ASSERT_EQ(1U, buckets.size()); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_SHOWN); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_PAY_CLICKED); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_RECEIVED_INSTRUMENT_DETAILS); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SKIPPED_SHOW); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_COMPLETED); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_USER_ABORTED); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_OTHER_ABORTED); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_HAD_INITIAL_FORM_OF_PAYMENT); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_HAD_NECESSARY_COMPLETE_SUGGESTIONS); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_SHIPPING); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_NAME); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_PHONE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_EMAIL); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_FALSE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_TRUE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_BASIC_CARD); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_GOOGLE); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_OTHER); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_CREDIT_CARD); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_GOOGLE); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_SELECTED_OTHER); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_COULD_NOT_SHOW); +} + +IN_PROC_BROWSER_TEST_F( + PaymentRequestJourneyLoggerMultipleShowBasicCardDisabledTest, + StartNewRequest) { + std::string a_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", + &a_method_name); + std::string b_method_name; + InstallPaymentApp("b.com", "payment_request_success_responder.js", + &b_method_name); + + NavigateTo("/payment_request_multiple_show_test.html"); + + base::HistogramTester histogram_tester; + + // Start a Payment Request. + InvokePaymentRequestUIWithJs(content::JsReplace( + "buyWithMethods([{supportedMethods:$1}, {supportedMethods:$2}]);", + a_method_name, b_method_name)); + + // Get the dialog view of the first request, since the one cached for the + // tests will be replaced by the second Payment Request. + PaymentRequestDialogView* first_dialog_view = dialog_view(); + + // Try to show a second request. + ResetEventWaiter(DialogEvent::DIALOG_CLOSED); + content::WebContents* web_contents = GetActiveWebContents(); + ASSERT_TRUE(content::ExecuteScript( + web_contents, + content::JsReplace("showSecondRequestWithMethods([{supportedMethods:$1}, " + "{supportedMethods:$2}]);", + a_method_name, b_method_name))); + WaitForObservedEvent(); + + // Complete the original Payment Request. + ResetEventWaiterForSequence( + {DialogEvent::PROCESSING_SPINNER_SHOWN, DialogEvent::DIALOG_CLOSED}); + ClickOnDialogViewAndWait(DialogViewID::PAY_BUTTON, first_dialog_view); + + // There is one no show and one shown (verified below). + histogram_tester.ExpectBucketCount( + "PaymentRequest.CheckoutFunnel.NoShow", + JourneyLogger::NOT_SHOWN_REASON_CONCURRENT_REQUESTS, 1); + + // Make sure the correct events were logged. + std::vector<base::Bucket> buckets = + histogram_tester.GetAllSamples("PaymentRequest.Events"); + ASSERT_EQ(2U, buckets.size()); + base::HistogramBase::Sample shown; + base::HistogramBase::Sample could_not_show; + // Order of histogram recording is non-deterministic. So use EVENT_SHOWN bit + // to differentiate between the two histograms. + if (buckets[0].min & JourneyLogger::EVENT_SHOWN) { + shown = buckets[0].min; + could_not_show = buckets[1].min; + } else { + shown = buckets[1].min; + could_not_show = buckets[0].min; + } + // This is for the first (completed) request. + EXPECT_TRUE(shown & JourneyLogger::EVENT_SHOWN); + EXPECT_TRUE(shown & JourneyLogger::EVENT_PAY_CLICKED); + EXPECT_TRUE(shown & JourneyLogger::EVENT_RECEIVED_INSTRUMENT_DETAILS); + EXPECT_FALSE(shown & JourneyLogger::EVENT_SKIPPED_SHOW); + EXPECT_TRUE(shown & JourneyLogger::EVENT_COMPLETED); + EXPECT_FALSE(shown & JourneyLogger::EVENT_USER_ABORTED); + EXPECT_FALSE(shown & JourneyLogger::EVENT_OTHER_ABORTED); + EXPECT_TRUE(shown & JourneyLogger::EVENT_HAD_INITIAL_FORM_OF_PAYMENT); + EXPECT_TRUE(shown & JourneyLogger::EVENT_HAD_NECESSARY_COMPLETE_SUGGESTIONS); + EXPECT_FALSE(shown & JourneyLogger::EVENT_REQUEST_SHIPPING); + EXPECT_FALSE(shown & JourneyLogger::EVENT_REQUEST_PAYER_NAME); + EXPECT_FALSE(shown & JourneyLogger::EVENT_REQUEST_PAYER_PHONE); + EXPECT_FALSE(shown & JourneyLogger::EVENT_REQUEST_PAYER_EMAIL); + EXPECT_FALSE(shown & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_FALSE); + EXPECT_FALSE(shown & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_TRUE); + EXPECT_FALSE(shown & JourneyLogger::EVENT_REQUEST_METHOD_BASIC_CARD); + EXPECT_FALSE(shown & JourneyLogger::EVENT_REQUEST_METHOD_GOOGLE); + EXPECT_TRUE(shown & JourneyLogger::EVENT_REQUEST_METHOD_OTHER); + EXPECT_FALSE(shown & JourneyLogger::EVENT_SELECTED_CREDIT_CARD); + EXPECT_FALSE(shown & JourneyLogger::EVENT_SELECTED_GOOGLE); + EXPECT_TRUE(shown & JourneyLogger::EVENT_SELECTED_OTHER); + EXPECT_FALSE(shown & JourneyLogger::EVENT_COULD_NOT_SHOW); + + // The second set of events is for the second (never shown) request. + EXPECT_FALSE(could_not_show & JourneyLogger::EVENT_SHOWN); + EXPECT_FALSE(could_not_show & JourneyLogger::EVENT_PAY_CLICKED); + EXPECT_FALSE(could_not_show & + JourneyLogger::EVENT_RECEIVED_INSTRUMENT_DETAILS); + EXPECT_FALSE(could_not_show & JourneyLogger::EVENT_SKIPPED_SHOW); + EXPECT_FALSE(could_not_show & JourneyLogger::EVENT_COMPLETED); + EXPECT_FALSE(could_not_show & JourneyLogger::EVENT_USER_ABORTED); + EXPECT_FALSE(could_not_show & JourneyLogger::EVENT_OTHER_ABORTED); + + // The checkout funnel is aborted before checking for initial form of payment + // and the necessary complete suggestions, because querying for available + // payment apps is asynchronous. + EXPECT_FALSE(could_not_show & + JourneyLogger::EVENT_HAD_INITIAL_FORM_OF_PAYMENT); + EXPECT_FALSE(could_not_show & + JourneyLogger::EVENT_HAD_NECESSARY_COMPLETE_SUGGESTIONS); + + EXPECT_FALSE(could_not_show & JourneyLogger::EVENT_REQUEST_SHIPPING); + EXPECT_FALSE(could_not_show & JourneyLogger::EVENT_REQUEST_PAYER_NAME); + EXPECT_FALSE(could_not_show & JourneyLogger::EVENT_REQUEST_PAYER_PHONE); + EXPECT_FALSE(could_not_show & JourneyLogger::EVENT_REQUEST_PAYER_EMAIL); + EXPECT_FALSE(could_not_show & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_FALSE); + EXPECT_FALSE(could_not_show & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_TRUE); + EXPECT_FALSE(could_not_show & JourneyLogger::EVENT_REQUEST_METHOD_BASIC_CARD); + EXPECT_FALSE(could_not_show & JourneyLogger::EVENT_REQUEST_METHOD_GOOGLE); + EXPECT_TRUE(could_not_show & JourneyLogger::EVENT_REQUEST_METHOD_OTHER); + EXPECT_FALSE(could_not_show & JourneyLogger::EVENT_SELECTED_CREDIT_CARD); + EXPECT_FALSE(could_not_show & JourneyLogger::EVENT_SELECTED_GOOGLE); + EXPECT_FALSE(could_not_show & JourneyLogger::EVENT_SELECTED_OTHER); + EXPECT_TRUE(could_not_show & JourneyLogger::EVENT_COULD_NOT_SHOW); +} + class PaymentRequestJourneyLoggerMultipleShowTestWithPaymentHandlersDisabled : public PaymentRequestJourneyLoggerMultipleShowTest { public: @@ -435,8 +689,7 @@ EXPECT_TRUE(buckets[1].min & JourneyLogger::EVENT_COULD_NOT_SHOW); } -using PaymentRequestJourneyLoggerAllSectionStatsTest = - PaymentRequestJourneyLoggerTestBase; +using PaymentRequestJourneyLoggerAllSectionStatsTest = BasicCardEnabledTestBase; // Tests that the correct number of suggestions shown for each section is logged // when a Payment Request is completed. @@ -562,8 +815,152 @@ EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_COULD_NOT_SHOW); } +// The tests in this class correspond to the tests of the same name in +// PaymentRequestJourneyLoggerAllSectionStatsTest, with the basic-card being +// disabled. Parameterized tests are not used because the test setup for both +// tests are too different. +using PaymentRequestJourneyLoggerAllSectionStatsBasicCardDisabledTest = + BasicCardDisabledTestBase; + +// Tests that the correct number of suggestions shown for each section is logged +// when a Payment Request is completed. +IN_PROC_BROWSER_TEST_F( + PaymentRequestJourneyLoggerAllSectionStatsBasicCardDisabledTest, + NumberOfSuggestionsShown_Completed) { + std::string a_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", + &a_method_name); + + std::string b_method_name; + InstallPaymentApp("b.com", "payment_request_success_responder.js", + &b_method_name); + + NavigateTo("c.com", + "/payment_request_contact_details_and_free_shipping_test.html"); + base::HistogramTester histogram_tester; + + // Add two addresses. + AddAutofillProfile(autofill::test::GetFullProfile()); + AddAutofillProfile(autofill::test::GetFullProfile2()); + + // Complete the Payment Request. + InvokePaymentRequestUIWithJs(content::JsReplace( + "buyWithMethods([{supportedMethods:$1}, {supportedMethods:$2}]);", + a_method_name, b_method_name)); + ResetEventWaiterForSequence( + {DialogEvent::PROCESSING_SPINNER_SHOWN, DialogEvent::DIALOG_CLOSED}); + ClickOnDialogViewAndWait(DialogViewID::PAY_BUTTON, dialog_view()); + + // Expect the appropriate number of suggestions shown to be logged. + histogram_tester.ExpectUniqueSample( + "PaymentRequest.NumberOfSuggestionsShown.PaymentMethod.Completed", 2, 1); + histogram_tester.ExpectUniqueSample( + "PaymentRequest.NumberOfSuggestionsShown.ShippingAddress.Completed", 2, + 1); + histogram_tester.ExpectUniqueSample( + "PaymentRequest.NumberOfSuggestionsShown.ContactInfo.Completed", 2, 1); + + // Make sure the correct events were logged. + std::vector<base::Bucket> buckets = + histogram_tester.GetAllSamples("PaymentRequest.Events"); + ASSERT_EQ(1U, buckets.size()); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_SHOWN); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_PAY_CLICKED); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_RECEIVED_INSTRUMENT_DETAILS); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SKIPPED_SHOW); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_COMPLETED); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_USER_ABORTED); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_OTHER_ABORTED); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_HAD_INITIAL_FORM_OF_PAYMENT); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_HAD_NECESSARY_COMPLETE_SUGGESTIONS); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_SHIPPING); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_NAME); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_PHONE); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_EMAIL); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_FALSE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_TRUE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_BASIC_CARD); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_GOOGLE); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_OTHER); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_CREDIT_CARD); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_GOOGLE); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_SELECTED_OTHER); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_COULD_NOT_SHOW); +} + +// Tests that the correct number of suggestions shown for each section is logged +// when a Payment Request is aborted by the user. +IN_PROC_BROWSER_TEST_F( + PaymentRequestJourneyLoggerAllSectionStatsBasicCardDisabledTest, + NumberOfSuggestionsShown_UserAborted) { + std::string a_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", + &a_method_name); + + std::string b_method_name; + InstallPaymentApp("b.com", "payment_request_success_responder.js", + &b_method_name); + + NavigateTo("c.com", + "/payment_request_contact_details_and_free_shipping_test.html"); + base::HistogramTester histogram_tester; + + // Add two addresses and contact infos. + AddAutofillProfile(autofill::test::GetFullProfile()); + AddAutofillProfile(autofill::test::GetFullProfile2()); + + // The user aborts the Payment Request. + InvokePaymentRequestUIWithJs(content::JsReplace( + "buyWithMethods([{supportedMethods:$1}, {supportedMethods:$2}]);", + a_method_name, b_method_name)); + ClickOnCancel(); + + // Expect the appropriate number of suggestions shown to be logged. + histogram_tester.ExpectUniqueSample( + "PaymentRequest.NumberOfSuggestionsShown.PaymentMethod.UserAborted", 2, + 1); + histogram_tester.ExpectUniqueSample( + "PaymentRequest.NumberOfSuggestionsShown.ShippingAddress.UserAborted", 2, + 1); + histogram_tester.ExpectUniqueSample( + "PaymentRequest.NumberOfSuggestionsShown.ContactInfo.UserAborted", 2, 1); + + // Make sure the correct events were logged. + std::vector<base::Bucket> buckets = + histogram_tester.GetAllSamples("PaymentRequest.Events"); + ASSERT_EQ(1U, buckets.size()); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_SHOWN); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_PAY_CLICKED); + EXPECT_FALSE(buckets[0].min & + JourneyLogger::EVENT_RECEIVED_INSTRUMENT_DETAILS); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SKIPPED_SHOW); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_COMPLETED); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_USER_ABORTED); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_OTHER_ABORTED); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_HAD_INITIAL_FORM_OF_PAYMENT); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_HAD_NECESSARY_COMPLETE_SUGGESTIONS); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_SHIPPING); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_NAME); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_PHONE); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_EMAIL); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_FALSE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_TRUE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_BASIC_CARD); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_GOOGLE); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_OTHER); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_CREDIT_CARD); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_GOOGLE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_OTHER); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_COULD_NOT_SHOW); +} + using PaymentRequestJourneyLoggerNoShippingSectionStatsTest = - PaymentRequestJourneyLoggerTestBase; + BasicCardEnabledTestBase; // Tests that the correct number of suggestions shown for each section is logged // when a Payment Request is completed. @@ -691,8 +1088,146 @@ EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_COULD_NOT_SHOW); } +using PaymentRequestJourneyLoggerNoShippingSectionStatsBasicCardDisabledTest = + BasicCardDisabledTestBase; + +// Tests that the correct number of suggestions shown for each section is logged +// when a Payment Request is completed. +IN_PROC_BROWSER_TEST_F( + PaymentRequestJourneyLoggerNoShippingSectionStatsBasicCardDisabledTest, + NumberOfSuggestionsShown_Completed) { + std::string a_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", + &a_method_name); + std::string b_method_name; + InstallPaymentApp("b.com", "payment_request_success_responder.js", + &b_method_name); + + NavigateTo("c.com", "/payment_request_contact_details_test.html"); + base::HistogramTester histogram_tester; + + // Add two addresses and contact infos. + AddAutofillProfile(autofill::test::GetFullProfile()); + AddAutofillProfile(autofill::test::GetFullProfile2()); + + // Complete the Payment Request. + InvokePaymentRequestUIWithJs(content::JsReplace( + "buyWithMethods([{supportedMethods:$1}, {supportedMethods:$2}]);", + a_method_name, b_method_name)); + ResetEventWaiterForSequence( + {DialogEvent::PROCESSING_SPINNER_SHOWN, DialogEvent::DIALOG_CLOSED}); + ClickOnDialogViewAndWait(DialogViewID::PAY_BUTTON, dialog_view()); + + // Expect the appropriate number of suggestions shown to be logged. + histogram_tester.ExpectUniqueSample( + "PaymentRequest.NumberOfSuggestionsShown.PaymentMethod.Completed", 2, 1); + histogram_tester.ExpectUniqueSample( + "PaymentRequest.NumberOfSuggestionsShown.ContactInfo.Completed", 2, 1); + + // There should be no log for shipping address since it was not requested. + histogram_tester.ExpectTotalCount( + "PaymentRequest.NumberOfSuggestionsShown.ShippingAddress.Completed", 0); + + // Make sure the correct events were logged. + std::vector<base::Bucket> buckets = + histogram_tester.GetAllSamples("PaymentRequest.Events"); + ASSERT_EQ(1U, buckets.size()); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_SHOWN); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_PAY_CLICKED); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_RECEIVED_INSTRUMENT_DETAILS); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SKIPPED_SHOW); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_COMPLETED); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_USER_ABORTED); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_OTHER_ABORTED); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_HAD_INITIAL_FORM_OF_PAYMENT); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_HAD_NECESSARY_COMPLETE_SUGGESTIONS); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_SHIPPING); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_NAME); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_PHONE); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_EMAIL); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_FALSE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_TRUE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_BASIC_CARD); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_GOOGLE); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_OTHER); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_CREDIT_CARD); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_GOOGLE); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_SELECTED_OTHER); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_COULD_NOT_SHOW); +} + +// Tests that the correct number of suggestions shown for each section is logged +// when a Payment Request is aborted by the user. +IN_PROC_BROWSER_TEST_F( + PaymentRequestJourneyLoggerNoShippingSectionStatsBasicCardDisabledTest, + NumberOfSuggestionsShown_UserAborted) { + std::string a_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", + &a_method_name); + std::string b_method_name; + InstallPaymentApp("b.com", "payment_request_success_responder.js", + &b_method_name); + + NavigateTo("c.com", "/payment_request_contact_details_test.html"); + base::HistogramTester histogram_tester; + + // Add two confact info. + AddAutofillProfile(autofill::test::GetFullProfile()); + AddAutofillProfile(autofill::test::GetFullProfile2()); + + // The user aborts the Payment Request. + InvokePaymentRequestUIWithJs(content::JsReplace( + "buyWithMethods([{supportedMethods:$1}, {supportedMethods:$2}]);", + a_method_name, b_method_name)); + ClickOnCancel(); + + // Expect the appropriate number of suggestions shown to be logged. + histogram_tester.ExpectUniqueSample( + "PaymentRequest.NumberOfSuggestionsShown.PaymentMethod.UserAborted", 2, + 1); + histogram_tester.ExpectUniqueSample( + "PaymentRequest.NumberOfSuggestionsShown.ContactInfo.UserAborted", 2, 1); + + // There should be no log for shipping address since it was not requested. + histogram_tester.ExpectTotalCount( + "PaymentRequest.NumberOfSuggestionsShown.ShippingAddress.UserAborted", 0); + + // Make sure the correct events were logged. + std::vector<base::Bucket> buckets = + histogram_tester.GetAllSamples("PaymentRequest.Events"); + ASSERT_EQ(1U, buckets.size()); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_SHOWN); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_PAY_CLICKED); + EXPECT_FALSE(buckets[0].min & + JourneyLogger::EVENT_RECEIVED_INSTRUMENT_DETAILS); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SKIPPED_SHOW); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_COMPLETED); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_USER_ABORTED); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_OTHER_ABORTED); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_HAD_INITIAL_FORM_OF_PAYMENT); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_HAD_NECESSARY_COMPLETE_SUGGESTIONS); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_SHIPPING); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_NAME); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_PHONE); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_EMAIL); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_FALSE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_TRUE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_BASIC_CARD); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_GOOGLE); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_OTHER); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_CREDIT_CARD); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_GOOGLE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_OTHER); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_COULD_NOT_SHOW); +} + using PaymentRequestJourneyLoggerNoContactDetailSectionStatsTest = - PaymentRequestJourneyLoggerTestBase; + BasicCardEnabledTestBase; // Tests that the correct number of suggestions shown for each section is logged // when a Payment Request is completed. @@ -826,7 +1361,149 @@ EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_COULD_NOT_SHOW); } -using PaymentRequestNotShownTest = PaymentRequestJourneyLoggerTestBase; +using PaymentRequestJourneyLoggerNoContactDetailSectionStatsBasicCardDisabledTest = + BasicCardDisabledTestBase; + +// Tests that the correct number of suggestions shown for each section is logged +// when a Payment Request is completed. +IN_PROC_BROWSER_TEST_F( + PaymentRequestJourneyLoggerNoContactDetailSectionStatsBasicCardDisabledTest, + NumberOfSuggestionsShown_Completed) { + std::string a_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", + &a_method_name); + std::string b_method_name; + InstallPaymentApp("b.com", "payment_request_success_responder.js", + &b_method_name); + + NavigateTo("c.com", "/payment_request_free_shipping_test.html"); + base::HistogramTester histogram_tester; + + // Add two addresses. + AddAutofillProfile(autofill::test::GetFullProfile()); + AddAutofillProfile(autofill::test::GetFullProfile2()); + + // Complete the Payment Request. + InvokePaymentRequestUIWithJs(content::JsReplace( + "buyWithMethods([{supportedMethods:$1}, {supportedMethods:$2}]);", + a_method_name, b_method_name)); + ResetEventWaiterForSequence( + {DialogEvent::PROCESSING_SPINNER_SHOWN, DialogEvent::DIALOG_CLOSED}); + ClickOnDialogViewAndWait(DialogViewID::PAY_BUTTON, dialog_view()); + + // Expect the appropriate number of suggestions shown to be logged. + histogram_tester.ExpectUniqueSample( + "PaymentRequest.NumberOfSuggestionsShown.PaymentMethod.Completed", 2, 1); + histogram_tester.ExpectUniqueSample( + "PaymentRequest.NumberOfSuggestionsShown.ShippingAddress.Completed", 2, + 1); + + // There should be no log for contact info since it was not requested. + histogram_tester.ExpectTotalCount( + "PaymentRequest.NumberOfSuggestionsShown.ContactInfo.Completed", 0); + + // Make sure the correct events were logged. + std::vector<base::Bucket> buckets = + histogram_tester.GetAllSamples("PaymentRequest.Events"); + ASSERT_EQ(1U, buckets.size()); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_SHOWN); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_PAY_CLICKED); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_RECEIVED_INSTRUMENT_DETAILS); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SKIPPED_SHOW); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_COMPLETED); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_USER_ABORTED); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_OTHER_ABORTED); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_HAD_INITIAL_FORM_OF_PAYMENT); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_HAD_NECESSARY_COMPLETE_SUGGESTIONS); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_SHIPPING); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_NAME); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_PHONE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_EMAIL); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_FALSE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_TRUE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_BASIC_CARD); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_GOOGLE); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_OTHER); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_CREDIT_CARD); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_GOOGLE); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_SELECTED_OTHER); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_COULD_NOT_SHOW); +} + +// Tests that the correct number of suggestions shown for each section is logged +// when a Payment Request is aborted by the user. +IN_PROC_BROWSER_TEST_F( + PaymentRequestJourneyLoggerNoContactDetailSectionStatsBasicCardDisabledTest, + NumberOfSuggestionsShown_UserAborted) { + std::string a_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", + &a_method_name); + std::string b_method_name; + InstallPaymentApp("b.com", "payment_request_success_responder.js", + &b_method_name); + + NavigateTo("/payment_request_free_shipping_test.html"); + base::HistogramTester histogram_tester; + + // Add two addresses. + AddAutofillProfile(autofill::test::GetFullProfile()); + AddAutofillProfile(autofill::test::GetFullProfile2()); + + // The user aborts the Payment Request. + InvokePaymentRequestUIWithJs(content::JsReplace( + "buyWithMethods([{supportedMethods:$1}, {supportedMethods:$2}]);", + a_method_name, b_method_name)); + ClickOnCancel(); + + // Expect the appropriate number of suggestions shown to be logged. + histogram_tester.ExpectUniqueSample( + "PaymentRequest.NumberOfSuggestionsShown.PaymentMethod.UserAborted", 2, + 1); + histogram_tester.ExpectUniqueSample( + "PaymentRequest.NumberOfSuggestionsShown.ShippingAddress.UserAborted", 2, + 1); + + // There should be no log for contact info since it was not requested. + histogram_tester.ExpectTotalCount( + "PaymentRequest.NumberOfSuggestionsShown.ContactInfo.UserAborted", 0); + + // Make sure the correct events were logged. + std::vector<base::Bucket> buckets = + histogram_tester.GetAllSamples("PaymentRequest.Events"); + ASSERT_EQ(1U, buckets.size()); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_SHOWN); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_PAY_CLICKED); + EXPECT_FALSE(buckets[0].min & + JourneyLogger::EVENT_RECEIVED_INSTRUMENT_DETAILS); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SKIPPED_SHOW); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_COMPLETED); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_USER_ABORTED); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_OTHER_ABORTED); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_HAD_INITIAL_FORM_OF_PAYMENT); + EXPECT_TRUE(buckets[0].min & + JourneyLogger::EVENT_HAD_NECESSARY_COMPLETE_SUGGESTIONS); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_SHIPPING); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_NAME); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_PHONE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_EMAIL); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_FALSE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_TRUE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_FALSE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_TRUE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_BASIC_CARD); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_GOOGLE); + EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_OTHER); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_CREDIT_CARD); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_GOOGLE); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_OTHER); + EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_COULD_NOT_SHOW); +} + +using PaymentRequestNotShownTest = BasicCardEnabledTestBase; IN_PROC_BROWSER_TEST_F(PaymentRequestNotShownTest, OnlyNotShownMetricsLogged) { NavigateTo("/payment_request_can_make_payment_metrics_test.html"); @@ -869,7 +1546,7 @@ } using PaymentRequestCompleteSuggestionsForEverythingTest = - PaymentRequestJourneyLoggerTestBase; + BasicCardEnabledTestBase; IN_PROC_BROWSER_TEST_F(PaymentRequestCompleteSuggestionsForEverythingTest, UserHadCompleteSuggestionsForEverything) { @@ -1016,7 +1693,7 @@ EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_COULD_NOT_SHOW); } -class PaymentRequestIframeTest : public PaymentRequestJourneyLoggerTestBase { +class PaymentRequestIframeTest : public BasicCardEnabledTestBase { public: PaymentRequestIframeTest(const PaymentRequestIframeTest&) = delete; PaymentRequestIframeTest& operator=(const PaymentRequestIframeTest&) = delete; @@ -1296,101 +1973,4 @@ EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_OTHER); EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_COULD_NOT_SHOW); } - -// The tests in this class correspond to the tests of the same name in -// PaymentRequestJourneyLoggerAllSectionStatsTest, with the basic-card being -// disabled. Parameterized tests are not used because the test setup for both -// tests are too different. -class PaymentRequestJourneyLoggerWithoutBasicCardTestBase - : public PaymentRequestJourneyLoggerTestBase { - public: - PaymentRequestJourneyLoggerWithoutBasicCardTestBase( - const PaymentRequestJourneyLoggerWithoutBasicCardTestBase&) = delete; - PaymentRequestJourneyLoggerWithoutBasicCardTestBase& operator=( - const PaymentRequestJourneyLoggerWithoutBasicCardTestBase&) = delete; - - protected: - PaymentRequestJourneyLoggerWithoutBasicCardTestBase() { - feature_list_.InitWithFeatures({}, {::features::kPaymentRequestBasicCard}); - } - - private: - base::test::ScopedFeatureList feature_list_; -}; - -using PaymentRequestJourneyLoggerAllSectionStatsWithoutBasicCardTest = - PaymentRequestJourneyLoggerWithoutBasicCardTestBase; - -// Tests that the correct number of suggestions shown for each section is logged -// when a Payment Request is completed. -IN_PROC_BROWSER_TEST_F( - PaymentRequestJourneyLoggerAllSectionStatsWithoutBasicCardTest, - NumberOfSuggestionsShown_Completed) { - std::string a_method_name; - InstallPaymentApp("a.com", "payment_request_success_responder.js", - &a_method_name); - - std::string b_method_name; - InstallPaymentApp("b.com", "payment_request_success_responder.js", - &b_method_name); - - NavigateTo("c.com", - "/payment_request_contact_details_and_free_shipping_test.html"); - base::HistogramTester histogram_tester; - - // Setup a credit card with an associated billing address. - autofill::AutofillProfile billing_address = autofill::test::GetFullProfile(); - AddAutofillProfile(billing_address); - - // Add another address. - AddAutofillProfile(autofill::test::GetFullProfile2()); - - // Complete the Payment Request. - InvokePaymentRequestUIWithJs(content::JsReplace( - "buyWithMethods([{supportedMethods:$1}, {supportedMethods:$2}]);", - a_method_name, b_method_name)); - ResetEventWaiterForSequence( - {DialogEvent::PROCESSING_SPINNER_SHOWN, DialogEvent::DIALOG_CLOSED}); - ClickOnDialogViewAndWait(DialogViewID::PAY_BUTTON, dialog_view()); - - // Expect the appropriate number of suggestions shown to be logged. - histogram_tester.ExpectUniqueSample( - "PaymentRequest.NumberOfSuggestionsShown.PaymentMethod.Completed", 2, 1); - histogram_tester.ExpectUniqueSample( - "PaymentRequest.NumberOfSuggestionsShown.ShippingAddress.Completed", 2, - 1); - histogram_tester.ExpectUniqueSample( - "PaymentRequest.NumberOfSuggestionsShown.ContactInfo.Completed", 2, 1); - - // Make sure the correct events were logged. - std::vector<base::Bucket> buckets = - histogram_tester.GetAllSamples("PaymentRequest.Events"); - ASSERT_EQ(1U, buckets.size()); - EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_SHOWN); - EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_PAY_CLICKED); - EXPECT_TRUE(buckets[0].min & - JourneyLogger::EVENT_RECEIVED_INSTRUMENT_DETAILS); - EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SKIPPED_SHOW); - EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_COMPLETED); - EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_USER_ABORTED); - EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_OTHER_ABORTED); - EXPECT_TRUE(buckets[0].min & - JourneyLogger::EVENT_HAD_INITIAL_FORM_OF_PAYMENT); - EXPECT_TRUE(buckets[0].min & - JourneyLogger::EVENT_HAD_NECESSARY_COMPLETE_SUGGESTIONS); - EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_SHIPPING); - EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_NAME); - EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_PHONE); - EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_PAYER_EMAIL); - EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_FALSE); - EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_CAN_MAKE_PAYMENT_TRUE); - EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_BASIC_CARD); - EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_GOOGLE); - EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_REQUEST_METHOD_OTHER); - EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_CREDIT_CARD); - EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_SELECTED_GOOGLE); - EXPECT_TRUE(buckets[0].min & JourneyLogger::EVENT_SELECTED_OTHER); - EXPECT_FALSE(buckets[0].min & JourneyLogger::EVENT_COULD_NOT_SHOW); -} - } // namespace payments
diff --git a/chrome/browser/ui/views/payments/payment_request_no_update_with_browsertest.cc b/chrome/browser/ui/views/payments/payment_request_no_update_with_browsertest.cc index 71e2b91..eaee979b 100644 --- a/chrome/browser/ui/views/payments/payment_request_no_update_with_browsertest.cc +++ b/chrome/browser/ui/views/payments/payment_request_no_update_with_browsertest.cc
@@ -3,10 +3,12 @@ // found in the LICENSE file. #include "base/strings/utf_string_conversions.h" +#include "base/test/scoped_feature_list.h" #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" #include "components/autofill/core/browser/autofill_test_utils.h" #include "components/autofill/core/browser/data_model/autofill_profile.h" +#include "content/public/common/content_features.h" #include "content/public/test/browser_test.h" #include "content/public/test/browser_test_utils.h" #include "testing/gtest/include/gtest/gtest.h" @@ -21,7 +23,9 @@ const PaymentRequestNoUpdateWithTest&) = delete; protected: - PaymentRequestNoUpdateWithTest() {} + PaymentRequestNoUpdateWithTest() { + feature_list_.InitAndEnableFeature(::features::kPaymentRequestBasicCard); + } void RunJavaScriptFunctionToOpenPaymentRequestUI( const std::string& function_name) { @@ -32,6 +36,9 @@ WaitForObservedEvent(); } + + private: + base::test::ScopedFeatureList feature_list_; }; // A merchant that does not listen to shipping address update events will not @@ -144,4 +151,182 @@ ExpectBodyContains({"updatedShipping"}); } +// The tests in this class correspond to the tests of the same name in +// PaymentRequestShippingOptionViewControllerTest, with basic-card disabled. +// Parameterized tests are not used because the test setup for both tests are +// too different. +class PaymentRequestNoUpdateWithBasicCardDisabledTest + : public PaymentRequestBrowserTestBase { + public: + PaymentRequestNoUpdateWithBasicCardDisabledTest( + const PaymentRequestNoUpdateWithBasicCardDisabledTest&) = delete; + PaymentRequestNoUpdateWithBasicCardDisabledTest& operator=( + const PaymentRequestNoUpdateWithBasicCardDisabledTest&) = delete; + + protected: + PaymentRequestNoUpdateWithBasicCardDisabledTest() { + feature_list_.InitAndDisableFeature(::features::kPaymentRequestBasicCard); + } + + private: + base::test::ScopedFeatureList feature_list_; +}; + +// A merchant that does not listen to shipping address update events will not +// cause timeouts in UI. +IN_PROC_BROWSER_TEST_F(PaymentRequestNoUpdateWithBasicCardDisabledTest, + BuyWithoutListeners) { + // Installs two apps so that the Payment Request UI will be shown. + std::string a_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", + &a_method_name); + std::string b_method_name; + InstallPaymentApp("b.com", "payment_request_success_responder.js", + &b_method_name); + + NavigateTo("/payment_request_no_update_with_test.html"); + autofill::AutofillProfile billing_address = autofill::test::GetFullProfile(); + AddAutofillProfile(billing_address); + AddAutofillProfile(autofill::test::GetFullProfile2()); + autofill::CreditCard card = autofill::test::GetCreditCard(); + card.set_billing_address_id(billing_address.guid()); + AddCreditCard(card); + + InvokePaymentRequestUIWithJs( + content::JsReplace("buyWithoutListenersWithMethods([{supportedMethods:$1}" + ", {supportedMethods:$2}]);", + a_method_name, b_method_name)); + + OpenShippingAddressSectionScreen(); + ResetEventWaiterForSequence({DialogEvent::PROCESSING_SPINNER_SHOWN, + DialogEvent::PROCESSING_SPINNER_HIDDEN, + DialogEvent::SPEC_DONE_UPDATING, + DialogEvent::BACK_NAVIGATION}); + ClickOnChildInListViewAndWait( + /* child_index=*/1, /*total_num_children=*/2, + DialogViewID::SHIPPING_ADDRESS_SHEET_LIST_VIEW, + /*wait_for_animation=*/false); + // Wait for the animation here explicitly, otherwise + // ClickOnChildInListViewAndWait tries to install an AnimationDelegate before + // the animation is kicked off (since that's triggered off of the spec being + // updated) and this hits a DCHECK. + WaitForAnimation(); + + // Click on pay. + EXPECT_TRUE(IsPayButtonEnabled()); + ResetEventWaiterForSequence( + {DialogEvent::PROCESSING_SPINNER_SHOWN, DialogEvent::DIALOG_CLOSED}); + ClickOnDialogViewAndWait(DialogViewID::PAY_BUTTON, dialog_view()); + + ExpectBodyContains({"freeShipping"}); +} + +// A merchant that listens to shipping address update events, but does not call +// updateWith() on the event, will not cause timeouts in UI. +IN_PROC_BROWSER_TEST_F(PaymentRequestNoUpdateWithBasicCardDisabledTest, + BuyWithoutCallingUpdateWith) { + // Installs two apps so that the Payment Request UI will be shown. + std::string a_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", + &a_method_name); + std::string b_method_name; + InstallPaymentApp("b.com", "payment_request_success_responder.js", + &b_method_name); + + NavigateTo("/payment_request_no_update_with_test.html"); + autofill::AutofillProfile billing_address = autofill::test::GetFullProfile(); + AddAutofillProfile(billing_address); + AddAutofillProfile(autofill::test::GetFullProfile2()); + autofill::CreditCard card = autofill::test::GetCreditCard(); + card.set_billing_address_id(billing_address.guid()); + AddCreditCard(card); + + InvokePaymentRequestUIWithJs( + content::JsReplace("buyWithoutCallingUpdateWithWithMethods([{" + "supportedMethods:$1}, {supportedMethods:$2}]);", + a_method_name, b_method_name)); + + OpenShippingAddressSectionScreen(); + ResetEventWaiterForSequence({DialogEvent::PROCESSING_SPINNER_SHOWN, + DialogEvent::PROCESSING_SPINNER_HIDDEN, + DialogEvent::SPEC_DONE_UPDATING, + DialogEvent::BACK_NAVIGATION}); + ClickOnChildInListViewAndWait( + /* child_index=*/1, /*total_num_children=*/2, + DialogViewID::SHIPPING_ADDRESS_SHEET_LIST_VIEW, + /*wait_for_animation=*/false); + // Wait for the animation here explicitly, otherwise + // ClickOnChildInListViewAndWait tries to install an AnimationDelegate before + // the animation is kicked off (since that's triggered off of the spec being + // updated) and this hits a DCHECK. + WaitForAnimation(); + + // Click on pay. + EXPECT_TRUE(IsPayButtonEnabled()); + ResetEventWaiterForSequence( + {DialogEvent::PROCESSING_SPINNER_SHOWN, DialogEvent::DIALOG_CLOSED}); + ClickOnDialogViewAndWait(DialogViewID::PAY_BUTTON, dialog_view()); + + ExpectBodyContains({"freeShipping"}); +} + +// A merchant that invokes updateWith() directly without using a promise will +// not cause timeouts in UI. +IN_PROC_BROWSER_TEST_F(PaymentRequestNoUpdateWithBasicCardDisabledTest, + BuyWithoutPromises) { + // Installs two apps so that the Payment Request UI will be shown. + std::string a_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", + &a_method_name); + std::string b_method_name; + InstallPaymentApp("b.com", "payment_request_success_responder.js", + &b_method_name); + + NavigateTo("/payment_request_no_update_with_test.html"); + autofill::AutofillProfile billing_address = autofill::test::GetFullProfile(); + AddAutofillProfile(billing_address); + AddAutofillProfile(autofill::test::GetFullProfile2()); + autofill::CreditCard card = autofill::test::GetCreditCard(); + card.set_billing_address_id(billing_address.guid()); + AddCreditCard(card); + + InvokePaymentRequestUIWithJs( + content::JsReplace("buyWithoutPromisesWithMethods([{supportedMethods:$1}," + " {supportedMethods:$2}]);", + a_method_name, b_method_name)); + + OpenOrderSummaryScreen(); + EXPECT_EQ(u"$5.00", + GetLabelText(DialogViewID::ORDER_SUMMARY_TOTAL_AMOUNT_LABEL)); + ClickOnBackArrow(); + + OpenShippingAddressSectionScreen(); + ResetEventWaiterForSequence({DialogEvent::PROCESSING_SPINNER_SHOWN, + DialogEvent::PROCESSING_SPINNER_HIDDEN, + DialogEvent::SPEC_DONE_UPDATING, + DialogEvent::BACK_NAVIGATION}); + ClickOnChildInListViewAndWait( + /* child_index=*/1, /*total_num_children=*/2, + DialogViewID::SHIPPING_ADDRESS_SHEET_LIST_VIEW, + /*wait_for_animation=*/false); + // Wait for the animation here explicitly, otherwise + // ClickOnChildInListViewAndWait tries to install an AnimationDelegate before + // the animation is kicked off (since that's triggered off of the spec being + // updated) and this hits a DCHECK. + WaitForAnimation(); + + OpenOrderSummaryScreen(); + EXPECT_EQ(u"$10.00", + GetLabelText(DialogViewID::ORDER_SUMMARY_TOTAL_AMOUNT_LABEL)); + ClickOnBackArrow(); + + // Click on pay. + EXPECT_TRUE(IsPayButtonEnabled()); + ResetEventWaiterForSequence( + {DialogEvent::PROCESSING_SPINNER_SHOWN, DialogEvent::DIALOG_CLOSED}); + ClickOnDialogViewAndWait(DialogViewID::PAY_BUTTON, dialog_view()); + + ExpectBodyContains({"updatedShipping"}); +} + } // namespace payments
diff --git a/chrome/browser/ui/views/payments/payment_request_use_stats_browsertest.cc b/chrome/browser/ui/views/payments/payment_request_use_stats_browsertest.cc index d97d73f..f39d46c 100644 --- a/chrome/browser/ui/views/payments/payment_request_use_stats_browsertest.cc +++ b/chrome/browser/ui/views/payments/payment_request_use_stats_browsertest.cc
@@ -5,6 +5,7 @@ #include <vector> #include "base/strings/utf_string_conversions.h" +#include "base/test/scoped_feature_list.h" #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h" #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" @@ -15,6 +16,7 @@ #include "components/autofill/core/browser/personal_data_manager.h" #include "components/autofill/core/browser/test_autofill_clock.h" #include "components/web_modal/web_contents_modal_dialog_manager.h" +#include "content/public/common/content_features.h" #include "content/public/test/browser_test.h" #include "content/public/test/browser_test_utils.h" @@ -84,7 +86,12 @@ const PaymentRequestShippingAddressUseStatsTest&) = delete; protected: - PaymentRequestShippingAddressUseStatsTest() {} + PaymentRequestShippingAddressUseStatsTest() { + feature_list_.InitAndEnableFeature(::features::kPaymentRequestBasicCard); + } + + private: + base::test::ScopedFeatureList feature_list_; }; // Tests that use stats for the shipping address used in a Payment Request are @@ -128,6 +135,74 @@ EXPECT_EQ(kSomeLaterDate, updated_shipping->use_date()); } +// The tests in this class correspond to the tests of the same name in +// PaymentRequestShippingAddressUseStatsTest, but with basic-card disabled. +// Parameterized tests are not used because the test setup for both tests are +// too different. +class PaymentRequestShippingAddressUseStatsBasicCardDisabledTest + : public PaymentRequestBrowserTestBase { + public: + PaymentRequestShippingAddressUseStatsBasicCardDisabledTest( + const PaymentRequestShippingAddressUseStatsBasicCardDisabledTest&) = + delete; + PaymentRequestShippingAddressUseStatsBasicCardDisabledTest& operator=( + const PaymentRequestShippingAddressUseStatsBasicCardDisabledTest&) = + delete; + + protected: + PaymentRequestShippingAddressUseStatsBasicCardDisabledTest() { + feature_list_.InitAndDisableFeature(::features::kPaymentRequestBasicCard); + } + + private: + base::test::ScopedFeatureList feature_list_; +}; + +// Tests that use stats for the shipping address used in a Payment Request are +// properly updated upon completion. +IN_PROC_BROWSER_TEST_F( + PaymentRequestShippingAddressUseStatsBasicCardDisabledTest, + RecordUse) { + std::string payment_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", + &payment_method_name); + + NavigateTo("/payment_request_free_shipping_test.html"); + autofill::TestAutofillClock test_clock; + test_clock.SetNow(kSomeDate); + + // Create two addresses, one with a higher frequency score so that it is + // selected as the default shipping address. + autofill::AutofillProfile shipping_address1 = + autofill::test::GetFullProfile(); + AddAutofillProfile(shipping_address1); + autofill::AutofillProfile shipping_address2 = + autofill::test::GetFullProfile2(); + shipping_address2.set_use_count(3); + AddAutofillProfile(shipping_address2); + + // Check that the initial use stats were set correctly. + autofill::AutofillProfile* initial_shipping = + GetDataManager()->GetProfileByGUID(shipping_address2.guid()); + EXPECT_EQ(3U, initial_shipping->use_count()); + EXPECT_EQ(kSomeDate, initial_shipping->use_date()); + + // Complete the Payment Request. + test_clock.SetNow(kSomeLaterDate); + InvokePaymentRequestUIWithJs("buyWithMethods([{supportedMethods:'" + + payment_method_name + "'}]);"); + ResetEventWaiterForSequence( + {DialogEvent::PROCESSING_SPINNER_SHOWN, DialogEvent::DIALOG_CLOSED}); + ClickOnDialogViewAndWait(DialogViewID::PAY_BUTTON, dialog_view()); + WaitForOnPersonalDataChanged(); + + // Check that the usage of the profile was recorded. + autofill::AutofillProfile* updated_shipping = + GetDataManager()->GetProfileByGUID(shipping_address2.guid()); + EXPECT_EQ(4U, updated_shipping->use_count()); + EXPECT_EQ(kSomeLaterDate, updated_shipping->use_date()); +} + class PaymentRequestContactAddressUseStatsTest : public PaymentRequestBrowserTestBase { public: @@ -137,7 +212,12 @@ const PaymentRequestContactAddressUseStatsTest&) = delete; protected: - PaymentRequestContactAddressUseStatsTest() {} + PaymentRequestContactAddressUseStatsTest() { + feature_list_.InitAndEnableFeature(::features::kPaymentRequestBasicCard); + } + + private: + base::test::ScopedFeatureList feature_list_; }; // Tests that use stats for the contact address used in a Payment Request are @@ -180,6 +260,73 @@ EXPECT_EQ(kSomeLaterDate, updated_contact->use_date()); } +// The tests in this class correspond to the tests of the same name in +// PaymentRequestContactAddressUseStatsTest, but with basic-card disabled. +// Parameterized tests are not used because the test setup for both tests are +// too different. +class PaymentRequestContactAddressUseStatsBasicCardDisabledTest + : public PaymentRequestBrowserTestBase { + public: + PaymentRequestContactAddressUseStatsBasicCardDisabledTest( + const PaymentRequestContactAddressUseStatsBasicCardDisabledTest&) = + delete; + PaymentRequestContactAddressUseStatsBasicCardDisabledTest& operator=( + const PaymentRequestContactAddressUseStatsBasicCardDisabledTest&) = + delete; + + protected: + PaymentRequestContactAddressUseStatsBasicCardDisabledTest() { + feature_list_.InitAndDisableFeature(::features::kPaymentRequestBasicCard); + } + + private: + base::test::ScopedFeatureList feature_list_; +}; + +// Tests that use stats for the contact address used in a Payment Request are +// properly updated upon completion. +IN_PROC_BROWSER_TEST_F( + PaymentRequestContactAddressUseStatsBasicCardDisabledTest, + RecordUse) { + std::string payment_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", + &payment_method_name); + + NavigateTo("/payment_request_name_test.html"); + autofill::TestAutofillClock test_clock; + test_clock.SetNow(kSomeDate); + + // Create two addresses, one with a higher frequency score so that it is + // selected as the default contact address. + autofill::AutofillProfile contact_address1 = autofill::test::GetFullProfile(); + AddAutofillProfile(contact_address1); + autofill::AutofillProfile contact_address2 = + autofill::test::GetFullProfile2(); + contact_address2.set_use_count(3); + AddAutofillProfile(contact_address2); + + // Check that the initial use stats were set correctly. + autofill::AutofillProfile* initial_contact = + GetDataManager()->GetProfileByGUID(contact_address2.guid()); + EXPECT_EQ(3U, initial_contact->use_count()); + EXPECT_EQ(kSomeDate, initial_contact->use_date()); + + // Complete the Payment Request. + test_clock.SetNow(kSomeLaterDate); + InvokePaymentRequestUIWithJs("buyWithMethods([{supportedMethods:'" + + payment_method_name + "'}]);"); + ResetEventWaiterForSequence( + {DialogEvent::PROCESSING_SPINNER_SHOWN, DialogEvent::DIALOG_CLOSED}); + ClickOnDialogViewAndWait(DialogViewID::PAY_BUTTON, dialog_view()); + WaitForOnPersonalDataChanged(); + + // Check that the usage of the profile was recorded. + autofill::AutofillProfile* updated_contact = + GetDataManager()->GetProfileByGUID(contact_address2.guid()); + EXPECT_EQ(4U, updated_contact->use_count()); + EXPECT_EQ(kSomeLaterDate, updated_contact->use_date()); +} + class PaymentRequestSameShippingAndContactAddressUseStatsTest : public PaymentRequestBrowserTestBase { public: @@ -189,7 +336,12 @@ const PaymentRequestSameShippingAndContactAddressUseStatsTest&) = delete; protected: - PaymentRequestSameShippingAndContactAddressUseStatsTest() {} + PaymentRequestSameShippingAndContactAddressUseStatsTest() { + feature_list_.InitAndEnableFeature(::features::kPaymentRequestBasicCard); + } + + private: + base::test::ScopedFeatureList feature_list_; }; // Tests that use stats for an address that was used both as a shipping and @@ -233,4 +385,71 @@ EXPECT_EQ(kSomeLaterDate, updated_multi->use_date()); } +// The tests in this class correspond to the tests of the same name in +// PaymentRequestSameShippingAndContactAddressUseStatsTest, but with basic-card +// disabled. Parameterized tests are not used because the test setup for both +// tests are too different. +class PaymentRequestSameShippingAndContactAddressUseStatsBasicCardDisabledTest + : public PaymentRequestBrowserTestBase { + public: + PaymentRequestSameShippingAndContactAddressUseStatsBasicCardDisabledTest( + const PaymentRequestSameShippingAndContactAddressUseStatsBasicCardDisabledTest&) = + delete; + PaymentRequestSameShippingAndContactAddressUseStatsBasicCardDisabledTest& + operator=( + const PaymentRequestSameShippingAndContactAddressUseStatsBasicCardDisabledTest&) = + delete; + + protected: + PaymentRequestSameShippingAndContactAddressUseStatsBasicCardDisabledTest() { + feature_list_.InitAndDisableFeature(::features::kPaymentRequestBasicCard); + } + + private: + base::test::ScopedFeatureList feature_list_; +}; + +// Tests that use stats for an address that was used both as a shipping and +// contact address in a Payment Request are properly updated upon completion. +IN_PROC_BROWSER_TEST_F( + PaymentRequestSameShippingAndContactAddressUseStatsBasicCardDisabledTest, + RecordUse) { + std::string payment_method_name; + InstallPaymentApp("a.com", "payment_request_success_responder.js", + &payment_method_name); + + NavigateTo("/payment_request_contact_details_and_free_shipping_test.html"); + autofill::TestAutofillClock test_clock; + test_clock.SetNow(kSomeDate); + + // Create two addresses, one with a higher frequency score so that it is + // selected as the default shipping and contact address. + autofill::AutofillProfile multi_address1 = autofill::test::GetFullProfile(); + AddAutofillProfile(multi_address1); + autofill::AutofillProfile multi_address2 = autofill::test::GetFullProfile2(); + multi_address2.set_use_count(3); + AddAutofillProfile(multi_address2); + + // Check that the initial use stats were set correctly. + autofill::AutofillProfile* initial_multi = + GetDataManager()->GetProfileByGUID(multi_address2.guid()); + EXPECT_EQ(3U, initial_multi->use_count()); + EXPECT_EQ(kSomeDate, initial_multi->use_date()); + + // Complete the Payment Request. + test_clock.SetNow(kSomeLaterDate); + InvokePaymentRequestUIWithJs("buyWithMethods([{supportedMethods:'" + + payment_method_name + "'}]);"); + ResetEventWaiterForSequence( + {DialogEvent::PROCESSING_SPINNER_SHOWN, DialogEvent::DIALOG_CLOSED}); + ClickOnDialogViewAndWait(DialogViewID::PAY_BUTTON, dialog_view()); + WaitForOnPersonalDataChanged(); + + // Check that the usage of the profile was only recorded once. + autofill::AutofillProfile* updated_multi = + GetDataManager()->GetProfileByGUID(multi_address2.guid()); + EXPECT_EQ(4U, updated_multi->use_count()); + EXPECT_EQ(kSomeLaterDate, updated_multi->use_date()); +} + } // namespace payments
diff --git a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc index 504c0b7..b5706099 100644 --- a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc +++ b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc
@@ -699,18 +699,15 @@ gfx::Range tabs_in_group = ListTabsInGroup(change.group); for (auto i = tabs_in_group.start(); i < tabs_in_group.end(); ++i) { tabstrip_->tab_at(i)->SetVisible(!new_visuals->is_collapsed()); - if (base::FeatureList::IsEnabled( - features::kTabGroupsCollapseFreezing)) { - if (visuals_delta->new_visuals->is_collapsed()) { - tabstrip_->tab_at(i)->SetFreezingVoteToken( - performance_manager::freezing::EmitFreezingVoteForWebContents( - model_->GetWebContentsAt(i), - performance_manager::freezing::FreezingVoteValue:: - kCanFreeze, - "Collapsed Tab Group")); - } else { - tabstrip_->tab_at(i)->ReleaseFreezingVoteToken(); - } + if (visuals_delta->new_visuals->is_collapsed()) { + tabstrip_->tab_at(i)->SetFreezingVoteToken( + performance_manager::freezing::EmitFreezingVoteForWebContents( + model_->GetWebContentsAt(i), + performance_manager::freezing::FreezingVoteValue:: + kCanFreeze, + "Collapsed Tab Group")); + } else { + tabstrip_->tab_at(i)->ReleaseFreezingVoteToken(); } } }
diff --git a/chrome/browser/ui/views/tabs/tab_group_editor_bubble_view.cc b/chrome/browser/ui/views/tabs/tab_group_editor_bubble_view.cc index 89edc1e..a098c582 100644 --- a/chrome/browser/ui/views/tabs/tab_group_editor_bubble_view.cc +++ b/chrome/browser/ui/views/tabs/tab_group_editor_bubble_view.cc
@@ -182,18 +182,6 @@ dialog_model()->host()->Close(); } - void SendFeedbackPressed() { - base::RecordAction( - base::UserMetricsAction("TabGroups_TabGroupBubble_SendFeedback")); - chrome::ShowFeedbackPage( - browser_, chrome::FeedbackSource::kFeedbackSourceDesktopTabGroups, - /*description_template=*/std::string(), - /*description_placeholder_text=*/std::string(), - /*category_tag=*/std::string(), - /*extra_diagnostics=*/std::string()); - dialog_model()->host()->Close(); - } - private: const raw_ptr<const Browser> browser_; const tab_groups::TabGroupId group_; @@ -583,18 +571,6 @@ GetWidget()->CloseWithReason(views::Widget::ClosedReason::kUnspecified); } -void TabGroupEditorBubbleView::SendFeedbackPressed() { - base::RecordAction( - base::UserMetricsAction("TabGroups_TabGroupBubble_SendFeedback")); - chrome::ShowFeedbackPage( - browser_, chrome::FeedbackSource::kFeedbackSourceDesktopTabGroups, - /*description_template=*/std::string(), - /*description_placeholder_text=*/std::string(), - /*category_tag=*/std::string(), - /*extra_diagnostics=*/std::string()); - GetWidget()->CloseWithReason(views::Widget::ClosedReason::kUnspecified); -} - void TabGroupEditorBubbleView::OnBubbleClose() { if (title_at_opening_ != title_field_->GetText()) { base::RecordAction(
diff --git a/chrome/browser/ui/views/tabs/tab_group_editor_bubble_view.h b/chrome/browser/ui/views/tabs/tab_group_editor_bubble_view.h index 5b81363..96a6953 100644 --- a/chrome/browser/ui/views/tabs/tab_group_editor_bubble_view.h +++ b/chrome/browser/ui/views/tabs/tab_group_editor_bubble_view.h
@@ -43,7 +43,6 @@ static constexpr int TAB_GROUP_HEADER_CXMENU_UNGROUP = 15; static constexpr int TAB_GROUP_HEADER_CXMENU_CLOSE_GROUP = 16; static constexpr int TAB_GROUP_HEADER_CXMENU_MOVE_GROUP_TO_NEW_WINDOW = 17; - static constexpr int TAB_GROUP_HEADER_CXMENU_FEEDBACK = 18; using Colors = std::vector<std::pair<tab_groups::TabGroupColorId, std::u16string>>; @@ -82,7 +81,6 @@ void UngroupPressed(TabGroupHeader* header_view); void CloseGroupPressed(); void MoveGroupToNewWindowPressed(); - void SendFeedbackPressed(); void OnBubbleClose();
diff --git a/chrome/browser/ui/views/tabs/tab_group_editor_bubble_view_browsertest.cc b/chrome/browser/ui/views/tabs/tab_group_editor_bubble_view_browsertest.cc index 16a884d..7d2225b 100644 --- a/chrome/browser/ui/views/tabs/tab_group_editor_bubble_view_browsertest.cc +++ b/chrome/browser/ui/views/tabs/tab_group_editor_bubble_view_browsertest.cc
@@ -179,21 +179,8 @@ active_browser->tab_strip_model()->group_model()->ListTabGroups().size()); } -class TabGroupEditorBubbleViewDialogBrowserTestWithFreezingEnabled - : public TabGroupEditorBubbleViewDialogBrowserTest { - public: - TabGroupEditorBubbleViewDialogBrowserTestWithFreezingEnabled() { - scoped_feature_list_.InitWithFeatures( - {features::kTabGroupsCollapseFreezing}, {}); - } - - private: - base::test::ScopedFeatureList scoped_feature_list_; -}; - -IN_PROC_BROWSER_TEST_F( - TabGroupEditorBubbleViewDialogBrowserTestWithFreezingEnabled, - CollapsingGroupFreezesAllTabs) { +IN_PROC_BROWSER_TEST_F(TabGroupEditorBubbleViewDialogBrowserTest, + CollapsingGroupFreezesAllTabs) { BrowserView* browser_view = static_cast<BrowserView*>(browser()->window()); InProcessBrowserTest::AddBlankTabAndShow(browser()); InProcessBrowserTest::AddBlankTabAndShow(browser());
diff --git a/chrome/browser/ui/views/toolbar/chrome_labs_button.cc b/chrome/browser/ui/views/toolbar/chrome_labs_button.cc index ba2e311..af0d754a 100644 --- a/chrome/browser/ui/views/toolbar/chrome_labs_button.cc +++ b/chrome/browser/ui/views/toolbar/chrome_labs_button.cc
@@ -123,16 +123,15 @@ void ChromeLabsButton::UpdateDotIndicator() { #if BUILDFLAG(IS_CHROMEOS_ASH) - DictionaryPrefUpdateDeprecated update( + DictionaryPrefUpdate update( browser_view_->browser()->profile()->GetPrefs(), chrome_labs_prefs::kChromeLabsNewBadgeDictAshChrome); #else - DictionaryPrefUpdateDeprecated update( - g_browser_process->local_state(), - chrome_labs_prefs::kChromeLabsNewBadgeDict); + DictionaryPrefUpdate update(g_browser_process->local_state(), + chrome_labs_prefs::kChromeLabsNewBadgeDict); #endif - base::DictionaryValue* new_badge_prefs = update.Get(); + base::Value* new_badge_prefs = update.Get(); std::vector<std::string> lab_internal_names; const std::vector<LabInfo>& all_labs = model_->GetLabInfo();
diff --git a/chrome/browser/ui/views/toolbar/chrome_labs_utils.cc b/chrome/browser/ui/views/toolbar/chrome_labs_utils.cc index e5b619c..c03b885 100644 --- a/chrome/browser/ui/views/toolbar/chrome_labs_utils.cc +++ b/chrome/browser/ui/views/toolbar/chrome_labs_utils.cc
@@ -50,12 +50,11 @@ void UpdateChromeLabsNewBadgePrefs(Profile* profile, const ChromeLabsBubbleViewModel* model) { #if BUILDFLAG(IS_CHROMEOS_ASH) - DictionaryPrefUpdateDeprecated update( + DictionaryPrefUpdate update( profile->GetPrefs(), chrome_labs_prefs::kChromeLabsNewBadgeDictAshChrome); #else - DictionaryPrefUpdateDeprecated update( - g_browser_process->local_state(), - chrome_labs_prefs::kChromeLabsNewBadgeDict); + DictionaryPrefUpdate update(g_browser_process->local_state(), + chrome_labs_prefs::kChromeLabsNewBadgeDict); #endif base::Value* new_badge_prefs = update.Get();
diff --git a/chrome/browser/ui/views/toolbar/chrome_labs_view_controller.cc b/chrome/browser/ui/views/toolbar/chrome_labs_view_controller.cc index b70ff67..bb959083 100644 --- a/chrome/browser/ui/views/toolbar/chrome_labs_view_controller.cc +++ b/chrome/browser/ui/views/toolbar/chrome_labs_view_controller.cc
@@ -187,15 +187,14 @@ } #if BUILDFLAG(IS_CHROMEOS_ASH) - DictionaryPrefUpdateDeprecated update( + DictionaryPrefUpdate update( profile->GetPrefs(), chrome_labs_prefs::kChromeLabsNewBadgeDictAshChrome); #else - DictionaryPrefUpdateDeprecated update( - g_browser_process->local_state(), - chrome_labs_prefs::kChromeLabsNewBadgeDict); + DictionaryPrefUpdate update(g_browser_process->local_state(), + chrome_labs_prefs::kChromeLabsNewBadgeDict); #endif - base::DictionaryValue* new_badge_prefs = update.Get(); + base::Value* new_badge_prefs = update.Get(); DCHECK(new_badge_prefs->FindIntKey(lab.internal_name)); int start_day = *new_badge_prefs->FindIntKey(lab.internal_name); @@ -204,7 +203,7 @@ // epoch (1970-01-01). This value is the first day the user sees the new // experiment in Chrome Labs and will be used to determine whether or not to // show the new badge. - new_badge_prefs->SetInteger(lab.internal_name, GetCurrentDay()); + new_badge_prefs->SetIntKey(lab.internal_name, GetCurrentDay()); return true; } int days_elapsed = GetCurrentDay() - start_day;
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc index 715f390a..7061276 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_handler_unittest.cc
@@ -40,6 +40,7 @@ #include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui_controller.h" #include "content/public/test/browser_task_environment.h" +#include "content/public/test/navigation_simulator.h" #include "content/public/test/test_renderer_host.h" #include "content/public/test/test_web_ui.h" #include "printing/mojom/print.mojom.h" @@ -400,6 +401,10 @@ initiator_web_contents_ = content::WebContents::Create( content::WebContents::CreateParams(profile_)); content::WebContents* initiator = initiator_web_contents_.get(); + // Ensure the initiator has a RenderFrameHost with a live RenderFrame, as + // the print code will not bother to send IPCs to a non-live RenderFrame. + content::NavigationSimulator::NavigateAndCommitFromDocument( + GURL("about:blank"), initiator->GetMainFrame()); preview_web_contents_ = content::WebContents::Create( content::WebContents::CreateParams(profile_)); PrintViewManager::CreateForWebContents(initiator);
diff --git a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc index b57e10c0..cb3dc3a 100644 --- a/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +++ b/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc
@@ -1637,8 +1637,6 @@ IDS_SETTINGS_PRIVACY_REVIEW_WELCOME_CARD_SUB_HEADER}, {"privacyReviewWelcomeCardStartButton", IDS_SETTINGS_PRIVACY_REVIEW_WELCOME_CARD_START_BUTTON}, - {"privacyReviewWelcomeCardDontShowAgainCheckbox", - IDS_SETTINGS_PRIVACY_REVIEW_WELCOME_CARD_DONT_SHOW_AGAIN_CHECKBOX}, {"privacyReviewCompletionCardHeader", IDS_SETTINGS_PRIVACY_REVIEW_COMPLETION_CARD_HEADER}, {"privacyReviewCompletionCardSubHeader",
diff --git a/chrome/browser/ui/webui/tab_strip/tab_strip_page_handler.cc b/chrome/browser/ui/webui/tab_strip/tab_strip_page_handler.cc index e35e5a3..f8f6a349 100644 --- a/chrome/browser/ui/webui/tab_strip/tab_strip_page_handler.cc +++ b/chrome/browser/ui/webui/tab_strip/tab_strip_page_handler.cc
@@ -436,7 +436,10 @@ case blink::WebInputEvent::Type::kGestureLongTap: if (context_menu_after_tap_) page_->ShowContextMenu(); - [[fallthrough]]; + + should_drag_on_gesture_scroll_ = false; + long_press_timer_->Stop(); + return true; case blink::WebInputEvent::Type::kGestureTap: // Ensure that we reset `should_drag_on_gesture_scroll_` when we encounter // a gesture tap event (i.e. an event triggered after the user lifts their
diff --git a/chrome/browser/win/conflicts/incompatible_applications_updater.cc b/chrome/browser/win/conflicts/incompatible_applications_updater.cc index d94c9e4c..c760f93 100644 --- a/chrome/browser/win/conflicts/incompatible_applications_updater.cc +++ b/chrome/browser/win/conflicts/incompatible_applications_updater.cc
@@ -135,13 +135,13 @@ // |state_application_names|. void RemoveStaleApplications( const std::vector<std::string>& stale_application_names) { - // Early exit because DictionaryPrefUpdateDeprecated will write to the pref - // even if it doesn't contain a value. + // Early exit because DictionaryPrefUpdate will write to the pref even if it + // doesn't contain a value. if (stale_application_names.empty()) return; - DictionaryPrefUpdateDeprecated update(g_browser_process->local_state(), - prefs::kIncompatibleApplications); + DictionaryPrefUpdate update(g_browser_process->local_state(), + prefs::kIncompatibleApplications); base::Value* existing_applications = update.Get(); for (const auto& application_name : stale_application_names) { @@ -209,8 +209,8 @@ base::Value new_applications = ConvertToDictionary(incompatible_applications); // Update the existing dictionary. - DictionaryPrefUpdateDeprecated update(g_browser_process->local_state(), - prefs::kIncompatibleApplications); + DictionaryPrefUpdate update(g_browser_process->local_state(), + prefs::kIncompatibleApplications); base::Value* existing_applications = update.Get(); for (auto&& element : new_applications.DictItems()) { existing_applications->SetKey(std::move(element.first),
diff --git a/chrome/build/linux.pgo.txt b/chrome/build/linux.pgo.txt index 9b34de2c..db2d3168 100644 --- a/chrome/build/linux.pgo.txt +++ b/chrome/build/linux.pgo.txt
@@ -1 +1 @@ -chrome-linux-main-1642075045-895de87bc21918c0a8f91690568c382c98469702.profdata +chrome-linux-main-1642096811-5d92c1533888b176e8442796f7c7242e81c1a405.profdata
diff --git a/chrome/build/mac.pgo.txt b/chrome/build/mac.pgo.txt index e2deac6..33c2474 100644 --- a/chrome/build/mac.pgo.txt +++ b/chrome/build/mac.pgo.txt
@@ -1 +1 @@ -chrome-mac-main-1642075045-0b98c50079ee2ee11ac79ced7015c8b4a4d47b6b.profdata +chrome-mac-main-1642096811-9d1c8f6f3725022e441d0e0f2dec05bc0d0bd2ab.profdata
diff --git a/chrome/build/win32.pgo.txt b/chrome/build/win32.pgo.txt index 3c89623..41fbdeb 100644 --- a/chrome/build/win32.pgo.txt +++ b/chrome/build/win32.pgo.txt
@@ -1 +1 @@ -chrome-win32-main-1642085871-c3e866238b172d86b0c5e5d535f17b73a3919498.profdata +chrome-win32-main-1642096745-b4ad3240b877e18877bb43db801cc9d59e5947c7.profdata
diff --git a/chrome/build/win64.pgo.txt b/chrome/build/win64.pgo.txt index c4211937..9214b32 100644 --- a/chrome/build/win64.pgo.txt +++ b/chrome/build/win64.pgo.txt
@@ -1 +1 @@ -chrome-win64-main-1642085871-c337179c7d831da87b8fc2d291420fc0448582e3.profdata +chrome-win64-main-1642096745-7d33997bfe6967d0e9fcfd448e80a21a6f68cd50.profdata
diff --git a/chrome/common/chrome_features.cc b/chrome/common/chrome_features.cc index f5260af..2fb2bef 100644 --- a/chrome/common/chrome_features.cc +++ b/chrome/common/chrome_features.cc
@@ -941,7 +941,7 @@ #if BUILDFLAG(IS_CHROMEOS_ASH) const base::Feature kChromeOSSharingHub{"ChromeOSSharingHub", - base::FEATURE_DISABLED_BY_DEFAULT}; + base::FEATURE_ENABLED_BY_DEFAULT}; #endif #if BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index c9506949..cb60e86 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn
@@ -6401,7 +6401,6 @@ "../browser/ui/autofill/save_update_address_profile_bubble_controller_impl_unittest.cc", "../browser/ui/media_router/cast_modes_with_media_sources_unittest.cc", "../browser/ui/media_router/media_cast_mode_unittest.cc", - "../browser/ui/media_router/media_router_file_dialog_unittest.cc", "../browser/ui/media_router/media_router_ui_helper_unittest.cc", "../browser/ui/media_router/media_router_ui_service_factory_unittest.cc", "../browser/ui/media_router/query_result_manager_unittest.cc",
diff --git a/chrome/test/data/extensions/api_test/declarative_net_request/fenced_frames/background.js b/chrome/test/data/extensions/api_test/declarative_net_request/fenced_frames/background.js index 1ea5beb..a0ff46ec 100644 --- a/chrome/test/data/extensions/api_test/declarative_net_request/fenced_frames/background.js +++ b/chrome/test/data/extensions/api_test/declarative_net_request/fenced_frames/background.js
@@ -62,7 +62,7 @@ request: { initiator: getServerURL('a.com'), method: 'GET', - frameId: 4, + frameId: mparchEnabled ? 5 : 4, parentFrameId: 0, type: 'sub_frame', tabId: tab.id, @@ -89,7 +89,7 @@ request: { initiator: getServerURL('a.com'), method: 'GET', - frameId: mparchEnabled ? 6 : 5, + frameId: mparchEnabled ? 7 : 5, parentFrameId: 0, type: 'sub_frame', tabId: tab.id,
diff --git a/chrome/test/data/extensions/api_test/webnavigation/fencedFrames/test_fencedFrame.js b/chrome/test/data/extensions/api_test/webnavigation/fencedFrames/test_fencedFrame.js index d42e6235..b2316f3 100644 --- a/chrome/test/data/extensions/api_test/webnavigation/fencedFrames/test_fencedFrame.js +++ b/chrome/test/data/extensions/api_test/webnavigation/fencedFrames/test_fencedFrame.js
@@ -14,6 +14,8 @@ let URL_INTERMEDIATE_IFRAME = getURL('iframe.html'); let URL_FENCED_FRAME = 'http://a.com:' + port + '/extensions/api_test/webnavigation/fencedFrames/frame.html'; + var mparchEnabled = config.customArg == 'MPArch'; + chrome.test.runTests([ // Navigates from an extension page to a HTTP page to contain // an iframe which contains a fenced frame. @@ -146,7 +148,7 @@ parentFrameId: 0, url: URL_INTERMEDIATE_IFRAME}, {errorOccurred: false, - frameId: 5, + frameId: mparchEnabled ? 6 : 5, parentFrameId: 4, url: URL_FENCED_FRAME}], details);
diff --git a/chrome/test/data/extensions/api_test/webrequest/framework.js b/chrome/test/data/extensions/api_test/webrequest/framework.js index 2cf2f6c0..42971ccb 100644 --- a/chrome/test/data/extensions/api_test/webrequest/framework.js +++ b/chrome/test/data/extensions/api_test/webrequest/framework.js
@@ -8,6 +8,7 @@ var capturedEventData; var capturedUnexpectedData; var expectedEventOrder; +var mparchEnabled; var tabId; var tabIdMap; var frameIdMap; @@ -62,8 +63,11 @@ // Creates an "about:blank" tab and runs |tests| with this tab as default. function runTests(tests) { chrome.test.getConfig(function(config) { - if (config.customArg == 'debug') - debug = true; + if (config.customArg) { + let args = JSON.parse(config.customArg); + debug = args.debug; + mparchEnabled = args.mparch; + } var waitForAboutBlank = function(_, info, tab) { if (debug) {
diff --git a/chrome/test/data/extensions/api_test/webrequest/test_fenced_frames_send_message.js b/chrome/test/data/extensions/api_test/webrequest/test_fenced_frames_send_message.js index 47f57aa..6798283 100644 --- a/chrome/test/data/extensions/api_test/webrequest/test_fenced_frames_send_message.js +++ b/chrome/test/data/extensions/api_test/webrequest/test_fenced_frames_send_message.js
@@ -26,7 +26,7 @@ if (EVENT_MESSAGE_EXTENSION_STRING != details.message) { chrome.test.fail('Invalid message: ' + details.message); } - chrome.test.assertEq(5, details.frameId); + chrome.test.assertEq(mparchEnabled ? 6 : 5, details.frameId); chrome.test.assertEq(4, details.parentFrameId); chrome.test.assertEq('sub_frame', details.type); chrome.test.assertEq(getURLFencedFrame(), details.url);
diff --git a/chrome/test/data/extensions/api_test/webrequest/test_redirects.js b/chrome/test/data/extensions/api_test/webrequest/test_redirects.js index 654bf97..d20299e 100644 --- a/chrome/test/data/extensions/api_test/webrequest/test_redirects.js +++ b/chrome/test/data/extensions/api_test/webrequest/test_redirects.js
@@ -29,8 +29,11 @@ chrome.test.getConfig(function(config) { var onHeadersReceivedExtraInfoSpec = ['blocking']; - if (config.customArg === 'useExtraHeaders') - onHeadersReceivedExtraInfoSpec.push('extraHeaders'); + if (config.customArg) { + let args = JSON.parse(config.customArg); + if (args.useExtraHeaders) + onHeadersReceivedExtraInfoSpec.push('extraHeaders'); + } runTests([ function redirectToDataUrlOnHeadersReceived() {
diff --git a/chrome/test/data/extensions/api_test/webrequest/test_subresource_redirects.js b/chrome/test/data/extensions/api_test/webrequest/test_subresource_redirects.js index 0b60fdc..7b1428f 100644 --- a/chrome/test/data/extensions/api_test/webrequest/test_subresource_redirects.js +++ b/chrome/test/data/extensions/api_test/webrequest/test_subresource_redirects.js
@@ -48,8 +48,11 @@ chrome.test.getConfig(function(config) { var onHeadersReceivedExtraInfoSpec = ['blocking']; - if (config.customArg === 'useExtraHeaders') - onHeadersReceivedExtraInfoSpec.push('extraHeaders'); + if (config.customArg) { + let args = JSON.parse(config.customArg); + if (args.useExtraHeaders) + onHeadersReceivedExtraInfoSpec.push('extraHeaders'); + } runTests([ function subresourceRedirectToDataUrlOnHeadersReceived() {
diff --git a/chrome/test/data/webui/chromeos/firmware_update/firmware_update_test.js b/chrome/test/data/webui/chromeos/firmware_update/firmware_update_test.js index d316713..fbb7049 100644 --- a/chrome/test/data/webui/chromeos/firmware_update/firmware_update_test.js +++ b/chrome/test/data/webui/chromeos/firmware_update/firmware_update_test.js
@@ -132,4 +132,28 @@ mojoString16ToString(fakeFirmwareUpdate.deviceName)} is up to date`, getUpdateDialogTitle().innerText.trim()); }); + + test('UpdateFailed', async () => { + await flushTasks(); + // Open dialog for firmware update. The third fake update in the list + // will fail. + getUpdateCards()[2].shadowRoot.querySelector(`#updateButton`).click(); + // Process |OnStateChanged| and |OnProgressChanged| calls. + await flushTasks(); + await flushTasks(); + assertEquals(UpdateState.kUpdating, getUpdateState()); + const fakeFirmwareUpdate = getFirmwareUpdateFromDialog(); + assertEquals( + `Updating ${mojoString16ToString(fakeFirmwareUpdate.deviceName)}`, + getUpdateDialogTitle().innerText.trim()); + // Allow firmware update to complete. + await controller.getUpdateCompletedPromiseForTesting(); + await flushTasks(); + assertEquals(UpdateState.kFailed, getUpdateState()); + assertTrue(getUpdateDialog().open); + assertEquals( + `Failed to update ${ + mojoString16ToString(fakeFirmwareUpdate.deviceName)}`, + getUpdateDialogTitle().innerText.trim()); + }); }
diff --git a/chrome/test/data/webui/settings/privacy_page_test.ts b/chrome/test/data/webui/settings/privacy_page_test.ts index f4a3b6138..a95a5741 100644 --- a/chrome/test/data/webui/settings/privacy_page_test.ts +++ b/chrome/test/data/webui/settings/privacy_page_test.ts
@@ -214,10 +214,6 @@ privacy_sandbox: { apis_enabled: {value: true}, }, - privacy_review: { - show_welcome_card: - {type: chrome.settingsPrivate.PrefType.BOOLEAN, value: true}, - }, privacy_guide: { viewed: { type: chrome.settingsPrivate.PrefType.BOOLEAN,
diff --git a/chrome/test/data/webui/settings/privacy_review_page_test.ts b/chrome/test/data/webui/settings/privacy_review_page_test.ts index c4f5dcaf..032c74f 100644 --- a/chrome/test/data/webui/settings/privacy_review_page_test.ts +++ b/chrome/test/data/webui/settings/privacy_review_page_test.ts
@@ -5,7 +5,7 @@ // clang-format off import {webUIListenerCallback} from 'chrome://resources/js/cr.m.js'; import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -import {CookiePrimarySetting, PrivacyReviewHistorySyncFragmentElement, PrivacyReviewStep, PrivacyReviewWelcomeFragmentElement, SafeBrowsingSetting, SettingsCheckboxElement, SettingsPrivacyReviewPageElement, SettingsRadioGroupElement} from 'chrome://settings/lazy_load.js'; +import {CookiePrimarySetting, PrivacyReviewHistorySyncFragmentElement, PrivacyReviewStep, PrivacyReviewWelcomeFragmentElement, SafeBrowsingSetting, SettingsPrivacyReviewPageElement, SettingsRadioGroupElement} from 'chrome://settings/lazy_load.js'; import {Router, routes, StatusAction, SyncBrowserProxyImpl, SyncPrefs, syncPrefsIndividualDataTypes} from 'chrome://settings/settings.js'; import {assertEquals, assertFalse, assertTrue} from 'chrome://webui-test/chai_assert.js'; import {eventToPromise, flushTasks, isChildVisible} from 'chrome://webui-test/test_util.js'; @@ -34,12 +34,6 @@ page = document.createElement('settings-privacy-review-page'); page.disableAnimationsForTesting(); page.prefs = { - privacy_review: { - show_welcome_card: { - type: chrome.settingsPrivate.PrefType.BOOLEAN, - value: true, - }, - }, privacy_guide: { viewed: { type: chrome.settingsPrivate.PrefType.BOOLEAN, @@ -304,9 +298,6 @@ } test('startPrivacyReview', function() { - // Make sure the pref to show the welcome card is on. - page.setPrefValue('privacy_review.show_welcome_card', true); - // Navigating to the privacy review without a step parameter navigates to // the welcome card. Router.getInstance().navigateTo(routes.PRIVACY_REVIEW); @@ -314,28 +305,9 @@ assertWelcomeCardVisible(); assertTrue(page.getPref('privacy_guide.viewed').value); - - const welcomeFragment = - page.shadowRoot!.querySelector<PrivacyReviewWelcomeFragmentElement>( - '#' + PrivacyReviewStep.WELCOME)!; - const dontShowAgainCheckbox = - welcomeFragment.shadowRoot!.querySelector<SettingsCheckboxElement>( - '#dontShowAgainCheckbox')!; - assertFalse(dontShowAgainCheckbox.checked); - dontShowAgainCheckbox.$.checkbox.click(); - welcomeFragment.$.startButton.click(); - flush(); - assertMsbbCardVisible(); - - // Navigating this time should skip the welcome card. - assertFalse(page.getPref('privacy_review.show_welcome_card').value); - Router.getInstance().navigateTo(routes.PRIVACY_REVIEW); - assertMsbbCardVisible(); }); test('welcomeForwardNavigation', function() { - page.setPrefValue('privacy_review.show_welcome_card', true); - // Navigating to the privacy review without a step parameter navigates to // the welcome card. Router.getInstance().navigateTo(routes.PRIVACY_REVIEW);
diff --git a/chrome/updater/BUILD.gn b/chrome/updater/BUILD.gn index a41fbe4..524ba00 100644 --- a/chrome/updater/BUILD.gn +++ b/chrome/updater/BUILD.gn
@@ -641,6 +641,7 @@ deps += [ "//chrome/common/mac:launchd", + "//chrome/updater/mac:ksadmin_lib", "//third_party/ocmock", ]
diff --git a/chrome/updater/mac/BUILD.gn b/chrome/updater/mac/BUILD.gn index 8d298bf..f6395606 100644 --- a/chrome/updater/mac/BUILD.gn +++ b/chrome/updater/mac/BUILD.gn
@@ -137,21 +137,35 @@ ] } -executable("ksadmin") { - output_name = "ksadmin" +source_set("ksadmin_lib") { sources = [ "keystone/ksadmin.h", "keystone/ksadmin.mm", - "keystone/ksadmin_main.cc", ] deps = [ "//base", "//chrome/updater:base", - "//chrome/updater:constants_prod", "//chrome/updater:version_header", ] + visibility = [ + ":ksadmin", + "//chrome/updater:updater_test_sources", + ] +} + +executable("ksadmin") { + output_name = "ksadmin" + sources = [ "keystone/ksadmin_main.cc" ] + + public_deps = [ ":ksadmin_lib" ] + + deps = [ + "//base", + "//chrome/updater:constants_prod", + ] + frameworks = [ "CoreFoundation.framework" ] if (is_asan) {
diff --git a/chrome/updater/mac/keystone/ksadmin.h b/chrome/updater/mac/keystone/ksadmin.h index 989aaf0..cf2431a 100644 --- a/chrome/updater/mac/keystone/ksadmin.h +++ b/chrome/updater/mac/keystone/ksadmin.h
@@ -5,9 +5,16 @@ #ifndef CHROME_UPDATER_MAC_KEYSTONE_KSADMIN_H_ #define CHROME_UPDATER_MAC_KEYSTONE_KSADMIN_H_ +#include <map> +#include <string> + namespace updater { -int KSAdminAppMain(int argc, char* argv[]); +// Exports the function for testing purpose. +std::map<std::string, std::string> ParseCommandLine(int argc, + const char* argv[]); + +int KSAdminAppMain(int argc, const char* argv[]); } // namespace updater
diff --git a/chrome/updater/mac/keystone/ksadmin.mm b/chrome/updater/mac/keystone/ksadmin.mm index 6b2ec453..e4d65a8 100644 --- a/chrome/updater/mac/keystone/ksadmin.mm +++ b/chrome/updater/mac/keystone/ksadmin.mm
@@ -7,6 +7,7 @@ #include <stdio.h> #include <algorithm> +#include <map> #include <string> #include <utility> #include <vector> @@ -41,37 +42,15 @@ #include "chrome/updater/util.h" namespace updater { -namespace { - -constexpr char kCommandDelete[] = "delete"; -constexpr char kCommandInstall[] = "install"; -constexpr char kCommandList[] = "list"; -constexpr char kCommandKsadminVersion[] = "ksadmin-version"; -constexpr char kCommandPrintTag[] = "print-tag"; -constexpr char kCommandPrintTickets[] = "print-tickets"; -constexpr char kCommandRegister[] = "register"; -constexpr char kCommandSystemStore[] = "system-store"; -constexpr char kCommandUserInitiated[] = "user-initiated"; -constexpr char kCommandUserStore[] = "user-store"; -constexpr char kCommandBrandKey[] = "brand-key"; -constexpr char kCommandBrandPath[] = "brand-path"; -constexpr char kCommandProductId[] = "productid"; -constexpr char kCommandTag[] = "tag"; -constexpr char kCommandTagKey[] = "tag-key"; -constexpr char kCommandTagPath[] = "tag-path"; -constexpr char kCommandVersion[] = "version"; -constexpr char kCommandVersionKey[] = "version-key"; -constexpr char kCommandVersionPath[] = "version-path"; -constexpr char kCommandXCPath[] = "xcpath"; // base::CommandLine can't be used because it enforces that all switches are // lowercase, but ksadmin has case-sensitive switches. This argument parser // converts an argv set into a map of switch name to switch value; for example // `ksadmin --register --productid com.goog.chrome -v 1.2.3.4 e` to // `{"register": "", "productid": "com.goog.chrome", "v": "1.2.3.4", "e": ""}`. -base::flat_map<std::string, std::string> ParseCommandLine(int argc, - char* argv[]) { - base::flat_map<std::string, std::string> result; +std::map<std::string, std::string> ParseCommandLine(int argc, + const char* argv[]) { + std::map<std::string, std::string> result; std::string last_arg; for (int i = 1; i < argc; ++i) { std::string arg(argv[i]); @@ -102,11 +81,34 @@ return result; } +namespace { + +constexpr char kCommandDelete[] = "delete"; +constexpr char kCommandInstall[] = "install"; +constexpr char kCommandList[] = "list"; +constexpr char kCommandKsadminVersion[] = "ksadmin-version"; +constexpr char kCommandPrintTag[] = "print-tag"; +constexpr char kCommandPrintTickets[] = "print-tickets"; +constexpr char kCommandRegister[] = "register"; +constexpr char kCommandSystemStore[] = "system-store"; +constexpr char kCommandUserInitiated[] = "user-initiated"; +constexpr char kCommandUserStore[] = "user-store"; +constexpr char kCommandBrandKey[] = "brand-key"; +constexpr char kCommandBrandPath[] = "brand-path"; +constexpr char kCommandProductId[] = "productid"; +constexpr char kCommandTag[] = "tag"; +constexpr char kCommandTagKey[] = "tag-key"; +constexpr char kCommandTagPath[] = "tag-path"; +constexpr char kCommandVersion[] = "version"; +constexpr char kCommandVersionKey[] = "version-key"; +constexpr char kCommandVersionPath[] = "version-path"; +constexpr char kCommandXCPath[] = "xcpath"; + bool HasSwitch(const std::string& arg, - const base::flat_map<std::string, std::string>& switches) { + const std::map<std::string, std::string>& switches) { if (base::Contains(switches, arg)) return true; - const static base::flat_map<std::string, std::vector<std::string>> aliases = { + const static std::map<std::string, std::vector<std::string>> aliases = { {kCommandDelete, {"d"}}, {kCommandInstall, {"i"}}, {kCommandList, {"l"}}, {kCommandKsadminVersion, {"k"}}, {kCommandPrintTag, {"G"}}, {kCommandPrintTickets, {"print", "p"}}, @@ -122,12 +124,11 @@ return false; } -std::string SwitchValue( - const std::string& arg, - const base::flat_map<std::string, std::string>& switches) { +std::string SwitchValue(const std::string& arg, + const std::map<std::string, std::string>& switches) { if (base::Contains(switches, arg)) return switches.at(arg); - const static base::flat_map<std::string, std::string> aliases = { + const static std::map<std::string, std::string> aliases = { {kCommandBrandKey, "b"}, {kCommandBrandPath, "B"}, {kCommandProductId, "P"}, {kCommandTag, "g"}, {kCommandTagKey, "K"}, {kCommandTagPath, "H"}, @@ -147,7 +148,7 @@ .value(); } -UpdaterScope Scope(const base::flat_map<std::string, std::string>& switches) { +UpdaterScope Scope(const std::map<std::string, std::string>& switches) { if (HasSwitch(kCommandSystemStore, switches)) return UpdaterScope::kSystem; if (HasSwitch(kCommandUserStore, switches)) @@ -165,7 +166,7 @@ class KSAdminApp : public App { public: - explicit KSAdminApp(const base::flat_map<std::string, std::string>& switches) + explicit KSAdminApp(const std::map<std::string, std::string>& switches) : switches_(switches), service_proxy_(base::MakeRefCounted<UpdateServiceProxy>(Scope())) {} @@ -190,7 +191,7 @@ NSDictionary<NSString*, KSTicket*>* LoadTicketStore(); - const base::flat_map<std::string, std::string> switches_; + const std::map<std::string, std::string> switches_; scoped_refptr<UpdateServiceProxy> service_proxy_; }; @@ -435,7 +436,7 @@ Shutdown(1); } } - const base::flat_map<std::string, void (KSAdminApp::*)()> commands = { + const std::map<std::string, void (KSAdminApp::*)()> commands = { {kCommandDelete, &KSAdminApp::Delete}, {kCommandInstall, &KSAdminApp::CheckForUpdates}, {kCommandList, &KSAdminApp::CheckForUpdates}, @@ -455,10 +456,10 @@ } // namespace -int KSAdminAppMain(int argc, char* argv[]) { +int KSAdminAppMain(int argc, const char* argv[]) { base::AtExitManager exit_manager; base::CommandLine::Init(argc, argv); - base::flat_map<std::string, std::string> command_line = + std::map<std::string, std::string> command_line = ParseCommandLine(argc, argv); updater::InitLogging(Scope(command_line), FILE_PATH_LITERAL("updater.log")); base::SingleThreadTaskExecutor main_task_executor(base::MessagePumpType::UI);
diff --git a/chrome/updater/mac/keystone/ksadmin_main.cc b/chrome/updater/mac/keystone/ksadmin_main.cc index f96128c..7e61660f 100644 --- a/chrome/updater/mac/keystone/ksadmin_main.cc +++ b/chrome/updater/mac/keystone/ksadmin_main.cc
@@ -4,6 +4,6 @@ #include "chrome/updater/mac/keystone/ksadmin.h" -int main(int argc, char* argv[]) { +int main(int argc, const char* argv[]) { return updater::KSAdminAppMain(argc, argv); }
diff --git a/chrome/updater/mac/keystone/ksadmin_unittest.cc b/chrome/updater/mac/keystone/ksadmin_unittest.cc index bb38885..1871050 100644 --- a/chrome/updater/mac/keystone/ksadmin_unittest.cc +++ b/chrome/updater/mac/keystone/ksadmin_unittest.cc
@@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/updater/mac/keystone/ksadmin.h" + +#include <map> #include <string> #include <vector> @@ -50,4 +53,41 @@ ASSERT_EQ(out, base::StrCat({kUpdaterVersion, "\n"})); } +TEST(KSAdminTest, ParseCommandLine) { + const char* argv[] = {"ksadmin", "--register", + "-P", "com.google.kipple", + "-v", "1.2.3.4", + "--xcpath", "/Applications/GoogleKipple.app", + "-u", "https://tools.google.com/service/update2"}; + + std::map<std::string, std::string> arg_map = + ParseCommandLine(std::size(argv), argv); + EXPECT_EQ(arg_map.size(), size_t{5}); + EXPECT_EQ(arg_map["register"], ""); + EXPECT_EQ(arg_map["P"], "com.google.kipple"); + EXPECT_EQ(arg_map["v"], "1.2.3.4"); + EXPECT_EQ(arg_map["xcpath"], "/Applications/GoogleKipple.app"); + EXPECT_EQ(arg_map["u"], "https://tools.google.com/service/update2"); +} + +TEST(KSAdminTest, ParseCommandLine_DiffByCase) { + const char* argv[] = {"ksadmin", "-k", "-K", "Tag"}; + + std::map<std::string, std::string> arg_map = + ParseCommandLine(std::size(argv), argv); + EXPECT_EQ(arg_map.size(), size_t{2}); + EXPECT_EQ(arg_map["k"], ""); + EXPECT_EQ(arg_map["K"], "Tag"); +} + +TEST(KSAdminTest, ParseCommandLine_CombinedShortOptions) { + const char* argv[] = {"ksadmin", "-pP", "com.google.Chrome"}; + + std::map<std::string, std::string> arg_map = + ParseCommandLine(std::size(argv), argv); + EXPECT_EQ(arg_map.size(), size_t{2}); + EXPECT_EQ(arg_map["p"], ""); + EXPECT_EQ(arg_map["P"], "com.google.Chrome"); +} + } // namespace updater
diff --git a/chrome/updater/mac/signing/parts.py b/chrome/updater/mac/signing/parts.py index dc6a0f1..b0727a0 100644 --- a/chrome/updater/mac/signing/parts.py +++ b/chrome/updater/mac/signing/parts.py
@@ -32,12 +32,6 @@ # Innermost parts come first. return [ - CodeSignedProduct( # Keystone Agent app bundle plist - ks_agent_app + '/Contents/MacOS/Info.plist', - config.keystone_app_name + 'Agent', - identifier_requirement=False, - options=CodeSignOptions.FULL_HARDENED_RUNTIME_OPTIONS, - verify_options=VerifyOptions.DEEP + VerifyOptions.STRICT), CodeSignedProduct( # Keystone Agent app bundle ks_agent_app, config.keystone_app_name + 'Agent',
diff --git a/chrome/updater/persisted_data.cc b/chrome/updater/persisted_data.cc index a9eb029..0c61a2f3 100644 --- a/chrome/updater/persisted_data.cc +++ b/chrome/updater/persisted_data.cc
@@ -123,8 +123,7 @@ if (!pref_service_) return false; - DictionaryPrefUpdateDeprecated update(pref_service_, - kPersistedDataPreference); + DictionaryPrefUpdate update(pref_service_, kPersistedDataPreference); base::Value* apps = update->FindDictKey("apps"); return apps ? apps->RemoveKey(id) : false; @@ -196,8 +195,7 @@ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (!pref_service_) return; - DictionaryPrefUpdateDeprecated update(pref_service_, - kPersistedDataPreference); + DictionaryPrefUpdate update(pref_service_, kPersistedDataPreference); GetOrCreateAppKey(id, update.Get())->SetStringKey(key, value); }
diff --git a/chrome/updater/test/integration_tests.cc b/chrome/updater/test/integration_tests.cc index 468fac1..0617d52 100644 --- a/chrome/updater/test/integration_tests.cc +++ b/chrome/updater/test/integration_tests.cc
@@ -538,7 +538,15 @@ ExpectClean(); } -TEST_F(IntegrationTest, UninstallUpdaterWhenAllAppsUninstalled) { +#if defined(OS_MAC) +// TODO(https://crbug.com/1287235): Failing consistently on Mac. +#define MAYBE_UninstallUpdaterWhenAllAppsUninstalled \ + DISABLED_UninstallUpdaterWhenAllAppsUninstalled +#else +#define MAYBE_UninstallUpdaterWhenAllAppsUninstalled \ + UninstallUpdaterWhenAllAppsUninstalled +#endif +TEST_F(IntegrationTest, MAYBE_UninstallUpdaterWhenAllAppsUninstalled) { Install(); RegisterApp("test1"); ExpectInstalled();
diff --git a/chromecast/browser/cast_browser_main_parts.cc b/chromecast/browser/cast_browser_main_parts.cc index 507872f0..6907e66 100644 --- a/chromecast/browser/cast_browser_main_parts.cc +++ b/chromecast/browser/cast_browser_main_parts.cc
@@ -17,6 +17,7 @@ #include "base/cxx17_backports.h" #include "base/files/file_util.h" #include "base/logging.h" +#include "base/memory/memory_pressure_monitor.h" #include "base/memory/ptr_util.h" #include "base/path_service.h" #include "base/run_loop.h" @@ -71,6 +72,7 @@ #include "chromecast/ui/display_settings_manager_impl.h" #include "components/heap_profiling/multi_process/client_connection_manager.h" #include "components/heap_profiling/multi_process/supervisor.h" +#include "components/memory_pressure/multi_source_memory_pressure_monitor.h" #include "components/prefs/pref_service.h" #include "components/viz/common/switches.h" #include "content/public/browser/browser_task_traits.h" @@ -411,8 +413,7 @@ parameters_(std::move(parameters)), cast_content_browser_client_(cast_content_browser_client), media_caps_(std::make_unique<media::MediaCapsImpl>()), - metrics_helper_(std::make_unique<metrics::MetricsHelperImpl>()), - cast_system_memory_pressure_evaluator_adjuster_(nullptr) { + metrics_helper_(std::make_unique<metrics::MetricsHelperImpl>()) { DCHECK(cast_content_browser_client); base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); AddDefaultCommandLineSwitches(command_line); @@ -576,15 +577,17 @@ int CastBrowserMainParts::PreMainMessageLoopRun() { #if !defined(OS_ANDROID) && !defined(OS_FUCHSIA) - memory_pressure_monitor_.reset( - new memory_pressure::MultiSourceMemoryPressureMonitor()); - auto cast_system_memory_pressure_evaluator = - std::make_unique<CastSystemMemoryPressureEvaluator>( - memory_pressure_monitor_->CreateVoter()); - cast_system_memory_pressure_evaluator_adjuster_ = - cast_system_memory_pressure_evaluator.get(); - memory_pressure_monitor_->SetSystemEvaluator( - std::move(cast_system_memory_pressure_evaluator)); + // static_cast is safe because this is the only implementation of + // MemoryPressureMonitor. + auto* monitor = + static_cast<memory_pressure::MultiSourceMemoryPressureMonitor*>( + base::MemoryPressureMonitor::Get()); + // |monitor| may be nullptr in browser tests. + if (monitor) { + monitor->SetSystemEvaluator( + std::make_unique<CastSystemMemoryPressureEvaluator>( + monitor->CreateVoter())); + } // base::Unretained() is safe because the browser client will outlive any // component in the browser; this factory method will not be called after @@ -710,8 +713,7 @@ cast_browser_process_->SetCastService( cast_browser_process_->browser_client()->CreateCastService( - cast_browser_process_->browser_context(), - cast_system_memory_pressure_evaluator_adjuster_, + cast_browser_process_->browser_context(), nullptr, cast_browser_process_->pref_service(), video_plane_controller_.get(), window_manager_.get(), web_service_.get(), display_settings_manager_.get(),
diff --git a/chromecast/browser/cast_browser_main_parts.h b/chromecast/browser/cast_browser_main_parts.h index d3b2f95..94bb3baa 100644 --- a/chromecast/browser/cast_browser_main_parts.h +++ b/chromecast/browser/cast_browser_main_parts.h
@@ -12,7 +12,6 @@ #include "build/buildflag.h" #include "chromecast/browser/display_configurator_observer.h" #include "chromecast/chromecast_buildflags.h" -#include "components/memory_pressure/multi_source_memory_pressure_monitor.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_main_parts.h" #include "content/public/common/main_function_params.h" @@ -36,7 +35,6 @@ namespace chromecast { class CastFeatureUpdateObserver; -class CastSystemMemoryPressureEvaluatorAdjuster; class CastWebService; class DisplaySettingsManager; class ServiceConnector; @@ -159,12 +157,6 @@ // Tracks all media pipeline backends. std::unique_ptr<media::MediaPipelineBackendManager> media_pipeline_backend_manager_; -#if !defined(OS_ANDROID) && !defined(OS_FUCHSIA) - std::unique_ptr<memory_pressure::MultiSourceMemoryPressureMonitor> - memory_pressure_monitor_; -#endif // !defined(OS_ANDROID) && !defined(OS_FUCHSIA) - CastSystemMemoryPressureEvaluatorAdjuster* - cast_system_memory_pressure_evaluator_adjuster_; #if BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS) std::unique_ptr<extensions::ExtensionsClient> extensions_client_;
diff --git a/chromeos/chromeos_strings.grd b/chromeos/chromeos_strings.grd index 95825eb..84c570a9 100644 --- a/chromeos/chromeos_strings.grd +++ b/chromeos/chromeos_strings.grd
@@ -2561,6 +2561,12 @@ <message translateable="false" name="IDS_FIRMWARE_RESTARTING_FOOTER_TEXT" desc="Label shown when a device is being restarted."> Restarting ... </message> + <message translateable="false" name="IDS_FIRMWARE_UPDATE_FAILED_TITLE_TEXT" desc="Label shown when an update fails."> + Failed to update <ph name="DEVICE_NAME">$1<ex>Logitech keyboard</ex></ph> + </message> + <message translateable="false" name="IDS_FIRMWARE_UPDATE_FAILED_BODY_TEXT" desc="Label for communicating information about why an update failed."> + Update failed + </message> <!-- Quick Answers --> <message name="IDS_ASH_QUICK_ANSWERS_SETTINGS_BUTTON_TOOLTIP_TEXT" desc="Tootip text for the settings-button in Quick-Answers related views.">
diff --git a/chromeos/components/sync_wifi/fake_pending_network_configuration_tracker.cc b/chromeos/components/sync_wifi/fake_pending_network_configuration_tracker.cc index fca8d6c..f2fe01c 100644 --- a/chromeos/components/sync_wifi/fake_pending_network_configuration_tracker.cc +++ b/chromeos/components/sync_wifi/fake_pending_network_configuration_tracker.cc
@@ -53,8 +53,8 @@ std::vector<PendingNetworkConfigurationUpdate> FakePendingNetworkConfigurationTracker::GetPendingUpdates() { std::vector<PendingNetworkConfigurationUpdate> list; - for (const auto& it : id_to_pending_update_map_) - list.emplace_back(it.second); + for (const auto& [id, pending_update] : id_to_pending_update_map_) + list.emplace_back(pending_update); return list; }
diff --git a/chromeos/components/sync_wifi/fake_timer_factory.cc b/chromeos/components/sync_wifi/fake_timer_factory.cc index 64ae1320..98911be 100644 --- a/chromeos/components/sync_wifi/fake_timer_factory.cc +++ b/chromeos/components/sync_wifi/fake_timer_factory.cc
@@ -27,8 +27,8 @@ // Make a copy because firing a timer will usually destroy it. This calls // OnOneShotTimerDeleted and removes it from |id_to_timer_map_|. auto id_to_timer_map_copy = id_to_timer_map_; - for (auto it : id_to_timer_map_copy) - it.second->Fire(); + for (auto [id, timer] : id_to_timer_map_copy) + timer->Fire(); } void FakeTimerFactory::OnOneShotTimerDeleted(
diff --git a/chromeos/components/sync_wifi/pending_network_configuration_tracker_impl.cc b/chromeos/components/sync_wifi/pending_network_configuration_tracker_impl.cc index 93f2879..dc2f893d 100644 --- a/chromeos/components/sync_wifi/pending_network_configuration_tracker_impl.cc +++ b/chromeos/components/sync_wifi/pending_network_configuration_tracker_impl.cc
@@ -119,10 +119,9 @@ std::vector<PendingNetworkConfigurationUpdate> PendingNetworkConfigurationTrackerImpl::GetPendingUpdates() { std::vector<PendingNetworkConfigurationUpdate> list; - for (const auto entry : dict_.DictItems()) { + for (const auto [key, value] : dict_.DictItems()) { list.push_back(ConvertToPendingUpdate( - /*dict=*/&entry.second, - NetworkIdentifier::DeserializeFromString(entry.first))); + /*dict=*/&value, NetworkIdentifier::DeserializeFromString(key))); } return list; }
diff --git a/chromeos/components/sync_wifi/wifi_configuration_bridge.cc b/chromeos/components/sync_wifi/wifi_configuration_bridge.cc index 14e24ca..248cd82 100644 --- a/chromeos/components/sync_wifi/wifi_configuration_bridge.cc +++ b/chromeos/components/sync_wifi/wifi_configuration_bridge.cc
@@ -184,10 +184,7 @@ std::unique_ptr<syncer::ModelTypeStore::WriteBatch> batch = store_->CreateWriteBatch(); // Iterate through synced networks and update local stack where appropriate. - for (auto& kv : sync_networks) { - NetworkIdentifier& id = kv.first; - sync_pb::WifiConfigurationSpecifics& proto = kv.second; - + for (const auto& [id, proto] : sync_networks) { if (local_networks.contains(id) && local_networks[id].last_connected_timestamp() > proto.last_connected_timestamp()) { @@ -279,8 +276,8 @@ void WifiConfigurationBridge::GetAllDataForDebugging(DataCallback callback) { auto batch = std::make_unique<syncer::MutableDataBatch>(); - for (const auto& entry : entries_) { - batch->Put(entry.first, GenerateWifiEntityData(entry.second)); + for (const auto& [storage_key, specifics] : entries_) { + batch->Put(storage_key, GenerateWifiEntityData(specifics)); } std::move(callback).Run(std::move(batch)); } @@ -360,8 +357,8 @@ // Temporary fix for networks which accidentally had autoconnect disabled. if (!pref_service_->GetBoolean(kHasFixedAutoconnect)) { std::vector<sync_pb::WifiConfigurationSpecifics> protos; - for (const auto& entry : entries_) { - protos.push_back(entry.second); + for (const auto& [storage_key, specifics] : entries_) { + protos.push_back(specifics); } local_network_collector_->FixAutoconnect( protos, @@ -388,12 +385,12 @@ base::flat_map<std::string, absl::optional<sync_pb::WifiConfigurationSpecifics>> updates = networks_to_sync_when_ready_; - for (auto const& it : updates) { - if (it.second) { - SaveNetworkToSync(it.second); + for (auto const& [storage_key, specifics] : updates) { + if (specifics) { + SaveNetworkToSync(specifics); continue; } - RemoveNetworkFromSync(it.first); + RemoveNetworkFromSync(storage_key); } networks_to_sync_when_ready_.clear(); } @@ -413,8 +410,8 @@ std::vector<NetworkIdentifier> WifiConfigurationBridge::GetAllIdsForTesting() { std::vector<NetworkIdentifier> ids; - for (const auto& entry : entries_) - ids.push_back(NetworkIdentifier::FromProto(entry.second)); + for (const auto& [storage_key, specifics] : entries_) + ids.push_back(NetworkIdentifier::FromProto(specifics)); return ids; }
diff --git a/chromeos/components/sync_wifi/wifi_configuration_bridge_unittest.cc b/chromeos/components/sync_wifi/wifi_configuration_bridge_unittest.cc index 805c32f..da95a49 100644 --- a/chromeos/components/sync_wifi/wifi_configuration_bridge_unittest.cc +++ b/chromeos/components/sync_wifi/wifi_configuration_bridge_unittest.cc
@@ -93,8 +93,8 @@ std::unique_ptr<syncer::DataBatch> batch, std::vector<sync_pb::WifiConfigurationSpecifics>* output) { while (batch->HasNext()) { - const syncer::KeyAndData& data_pair = batch->Next(); - output->push_back(data_pair.second->specifics.wifi_configuration()); + const auto& [key, data] = batch->Next(); + output->push_back(data->specifics.wifi_configuration()); } }
diff --git a/chromeos/profiles/orderfile.newest.txt b/chromeos/profiles/orderfile.newest.txt index bab9823..bd63549e 100644 --- a/chromeos/profiles/orderfile.newest.txt +++ b/chromeos/profiles/orderfile.newest.txt
@@ -1 +1 @@ -chromeos-chrome-orderfile-field-99-4758.14-1640601734-benchmark-99.0.4799.0-r1.orderfile.xz +chromeos-chrome-orderfile-field-99-4758.14-1641211952-benchmark-99.0.4803.0-r1.orderfile.xz
diff --git a/chromeos/services/bluetooth_config/device_name_manager_impl.cc b/chromeos/services/bluetooth_config/device_name_manager_impl.cc index 5f602e5d..f5579fa 100644 --- a/chromeos/services/bluetooth_config/device_name_manager_impl.cc +++ b/chromeos/services/bluetooth_config/device_name_manager_impl.cc
@@ -82,10 +82,8 @@ return; } - base::DictionaryValue* device_id_to_nickname_map = - DictionaryPrefUpdateDeprecated(local_state_, - kDeviceIdToNicknameMapPrefName) - .Get(); + base::Value* device_id_to_nickname_map = + DictionaryPrefUpdate(local_state_, kDeviceIdToNicknameMapPrefName).Get(); DCHECK(device_id_to_nickname_map) << "Device ID to nickname map pref is unregistered."; device_id_to_nickname_map->SetStringKey(device_id, nickname); @@ -101,10 +99,8 @@ return; } - base::DictionaryValue* device_id_to_nickname_map = - DictionaryPrefUpdateDeprecated(local_state_, - kDeviceIdToNicknameMapPrefName) - .Get(); + base::Value* device_id_to_nickname_map = + DictionaryPrefUpdate(local_state_, kDeviceIdToNicknameMapPrefName).Get(); DCHECK(device_id_to_nickname_map) << "Device ID to nickname map pref is unregistered.";
diff --git a/components/arc/BUILD.gn b/components/arc/BUILD.gn index ae01a8e..4baddb00 100644 --- a/components/arc/BUILD.gn +++ b/components/arc/BUILD.gn
@@ -38,11 +38,16 @@ static_library("arc_test_support") { testonly = true sources = [ + "test/fake_intent_helper_host.cc", + "test/fake_intent_helper_host.h", "test/fake_intent_helper_instance.cc", "test/fake_intent_helper_instance.h", ] - deps = [ "//ash/components/arc/mojom" ] + deps = [ + "//ash/components/arc/mojom", + "//ash/components/arc/session:connection_holder", + ] } source_set("unit_tests") {
diff --git a/components/arc/test/fake_intent_helper_host.cc b/components/arc/test/fake_intent_helper_host.cc new file mode 100644 index 0000000..090e65ce --- /dev/null +++ b/components/arc/test/fake_intent_helper_host.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 "components/arc/test/fake_intent_helper_host.h" + +namespace arc { + +FakeIntentHelperHost::FakeIntentHelperHost( + ConnectionHolder<arc::mojom::IntentHelperInstance, + arc::mojom::IntentHelperHost>* + intent_helper_connection_holder) + : intent_helper_connection_holder_(intent_helper_connection_holder) { + intent_helper_connection_holder_->SetHost(this); +} + +FakeIntentHelperHost::~FakeIntentHelperHost() { + intent_helper_connection_holder_->SetHost(nullptr); +} + +void FakeIntentHelperHost::OnIconInvalidated(const std::string& package_name) {} +void FakeIntentHelperHost::OnIntentFiltersUpdated( + std::vector<IntentFilter> intent_filters) {} +void FakeIntentHelperHost::OnOpenDownloads() {} +void FakeIntentHelperHost::OnOpenUrl(const std::string& url) {} +void FakeIntentHelperHost::OnOpenCustomTab(const std::string& url, + int32_t task_id, + OnOpenCustomTabCallback callback) {} +void FakeIntentHelperHost::OnOpenChromePage(mojom::ChromePage page) {} +void FakeIntentHelperHost::FactoryResetArc() {} +void FakeIntentHelperHost::OpenWallpaperPicker() {} +void FakeIntentHelperHost::OpenVolumeControl() {} +void FakeIntentHelperHost::OnOpenWebApp(const std::string& url) {} +void FakeIntentHelperHost::RecordShareFilesMetricsDeprecated( + mojom::ShareFiles flag) {} +void FakeIntentHelperHost::LaunchCameraApp(uint32_t intent_id, + arc::mojom::CameraIntentMode mode, + bool should_handle_result, + bool should_down_scale, + bool is_secure, + int32_t task_id) {} +void FakeIntentHelperHost::OnIntentFiltersUpdatedForPackage( + const std::string& package_name, + std::vector<IntentFilter> intent_filters) {} +void FakeIntentHelperHost::CloseCameraApp() {} +void FakeIntentHelperHost::IsChromeAppEnabled( + arc::mojom::ChromeApp app, + IsChromeAppEnabledCallback callback) {} +void FakeIntentHelperHost::OnSupportedLinksChanged( + std::vector<arc::mojom::SupportedLinksPtr> added_packages, + std::vector<arc::mojom::SupportedLinksPtr> removed_packages, + arc::mojom::SupportedLinkChangeSource source) {} +void FakeIntentHelperHost::OnDownloadAdded( + const std::string& relative_path, + const std::string& owner_package_name) {} +void FakeIntentHelperHost::OnOpenAppWithIntent( + const GURL& start_url, + arc::mojom::LaunchIntentPtr intent) {} + +} // namespace arc
diff --git a/components/arc/test/fake_intent_helper_host.h b/components/arc/test/fake_intent_helper_host.h new file mode 100644 index 0000000..cc25808 --- /dev/null +++ b/components/arc/test/fake_intent_helper_host.h
@@ -0,0 +1,69 @@ +// 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 COMPONENTS_ARC_TEST_FAKE_INTENT_HELPER_HOST_H_ +#define COMPONENTS_ARC_TEST_FAKE_INTENT_HELPER_HOST_H_ + +#include "ash/components/arc/mojom/intent_helper.mojom.h" +#include "ash/components/arc/session/connection_holder.h" + +namespace arc { + +// For tests in arc/ that cannot use the real IntentHelperHost implementation +// in //components/arc. +class FakeIntentHelperHost : public mojom::IntentHelperHost { + public: + explicit FakeIntentHelperHost( + ConnectionHolder<arc::mojom::IntentHelperInstance, + arc::mojom::IntentHelperHost>* app_connection_holder); + FakeIntentHelperHost(const FakeIntentHelperHost&) = delete; + FakeIntentHelperHost& operator=(const FakeIntentHelperHost&) = delete; + ~FakeIntentHelperHost() override; + + // mojom::IntentHelperHost overrides. + void OnIconInvalidated(const std::string& package_name) override; + void OnIntentFiltersUpdated( + std::vector<IntentFilter> intent_filters) override; + void OnOpenDownloads() override; + void OnOpenUrl(const std::string& url) override; + void OnOpenCustomTab(const std::string& url, + int32_t task_id, + OnOpenCustomTabCallback callback) override; + void OnOpenChromePage(mojom::ChromePage page) override; + void FactoryResetArc() override; + void OpenWallpaperPicker() override; + void OpenVolumeControl() override; + void OnOpenWebApp(const std::string& url) override; + void RecordShareFilesMetricsDeprecated(mojom::ShareFiles flag) override; + void LaunchCameraApp(uint32_t intent_id, + arc::mojom::CameraIntentMode mode, + bool should_handle_result, + bool should_down_scale, + bool is_secure, + int32_t task_id) override; + void OnIntentFiltersUpdatedForPackage( + const std::string& package_name, + std::vector<IntentFilter> intent_filters) override; + void CloseCameraApp() override; + void IsChromeAppEnabled(arc::mojom::ChromeApp app, + IsChromeAppEnabledCallback callback) override; + void OnSupportedLinksChanged( + std::vector<arc::mojom::SupportedLinksPtr> added_packages, + std::vector<arc::mojom::SupportedLinksPtr> removed_packages, + arc::mojom::SupportedLinkChangeSource source) override; + void OnDownloadAdded(const std::string& relative_path, + const std::string& owner_package_name) override; + void OnOpenAppWithIntent(const GURL& start_url, + arc::mojom::LaunchIntentPtr intent) override; + + private: + // The connection holder must outlive |this| object. + ConnectionHolder<arc::mojom::IntentHelperInstance, + arc::mojom::IntentHelperHost>* const + intent_helper_connection_holder_; +}; + +} // namespace arc + +#endif // COMPONENTS_ARC_TEST_FAKE_INTENT_HELPER_HOST_H_
diff --git a/components/cdm/browser/media_drm_storage_impl.cc b/components/cdm/browser/media_drm_storage_impl.cc index f59e2b55..c7df597 100644 --- a/components/cdm/browser/media_drm_storage_impl.cc +++ b/components/cdm/browser/media_drm_storage_impl.cc
@@ -354,7 +354,7 @@ // 2. Removes the origin data if all of the sessions are removed. // 3. Returns a list of origin IDs to unprovision. std::vector<base::UnguessableToken> ClearMatchingLicenseData( - base::DictionaryValue* storage_dict, + base::Value* storage_dict, base::Time start, base::Time end, const base::RepeatingCallback<bool(const GURL&)>& filter) { @@ -573,8 +573,7 @@ // Save the origin ID in the preference as long as it is not null. if (origin_id) { - DictionaryPrefUpdateDeprecated update(pref_service, - prefs::kMediaDrmStorage); + DictionaryPrefUpdate update(pref_service, prefs::kMediaDrmStorage); CreateOriginDictAndReturnSessionsDict(update.Get(), origin, origin_id.value()); } @@ -693,7 +692,7 @@ base::OnceClosure complete_cb) { DVLOG(1) << __func__ << ": Clear licenses [" << start << ", " << end << "]"; - DictionaryPrefUpdateDeprecated update(pref_service, prefs::kMediaDrmStorage); + DictionaryPrefUpdate update(pref_service, prefs::kMediaDrmStorage); std::vector<base::UnguessableToken> no_license_origin_ids = ClearMatchingLicenseData(update.Get(), start, end, filter); @@ -815,8 +814,8 @@ return; } - DictionaryPrefUpdateDeprecated update(pref_service_, prefs::kMediaDrmStorage); - base::DictionaryValue* storage_dict = update.Get(); + DictionaryPrefUpdate update(pref_service_, prefs::kMediaDrmStorage); + base::Value* storage_dict = update.Get(); DCHECK(storage_dict); // Update origin dict once origin provisioning completes. There may be @@ -847,8 +846,8 @@ return; } - DictionaryPrefUpdateDeprecated update(pref_service_, prefs::kMediaDrmStorage); - base::DictionaryValue* storage_dict = update.Get(); + DictionaryPrefUpdate update(pref_service_, prefs::kMediaDrmStorage); + base::Value* storage_dict = update.Get(); DCHECK(storage_dict); base::Value* sessions_dict = GetSessionsDictFromStorageDict<base::Value>( @@ -948,7 +947,7 @@ return; } - DictionaryPrefUpdateDeprecated update(pref_service_, prefs::kMediaDrmStorage); + DictionaryPrefUpdate update(pref_service_, prefs::kMediaDrmStorage); base::Value* sessions_dict = GetSessionsDictFromStorageDict<base::Value>( update.Get(), origin().Serialize());
diff --git a/components/external_intents/android/java/src/org/chromium/components/external_intents/ExternalNavigationHandler.java b/components/external_intents/android/java/src/org/chromium/components/external_intents/ExternalNavigationHandler.java index 645ea85..210f489 100644 --- a/components/external_intents/android/java/src/org/chromium/components/external_intents/ExternalNavigationHandler.java +++ b/components/external_intents/android/java/src/org/chromium/components/external_intents/ExternalNavigationHandler.java
@@ -629,6 +629,7 @@ boolean shouldStayInApp = handler.shouldStayInApp( isExternalProtocol, mDelegate.isIntentForTrustedCallingApp(targetIntent)); if (shouldStayInApp || handler.shouldNotOverrideUrlLoading()) { + if (isExternalProtocol) handler.maybeLogExternalRedirectBlockedWithMissingGesture(); if (DEBUG) Log.i(TAG, "RedirectHandler decision"); return true; }
diff --git a/components/external_intents/android/java/src/org/chromium/components/external_intents/InterceptNavigationDelegateImpl.java b/components/external_intents/android/java/src/org/chromium/components/external_intents/InterceptNavigationDelegateImpl.java index 025e4ca..aa26467e 100644 --- a/components/external_intents/android/java/src/org/chromium/components/external_intents/InterceptNavigationDelegateImpl.java +++ b/components/external_intents/android/java/src/org/chromium/components/external_intents/InterceptNavigationDelegateImpl.java
@@ -128,8 +128,7 @@ return false; } redirectHandler.updateNewUrlLoading(navigationParams.pageTransitionType, - navigationParams.isRedirect, - navigationParams.hasUserGesture || navigationParams.hasUserGestureCarryover, + navigationParams.isRedirect, navigationParams.hasUserGesture, lastUserInteractionTime, getLastCommittedEntryIndex(), isInitialNavigation()); boolean shouldCloseTab = shouldCloseContentsOnOverrideUrlLoadingAndLaunchIntent();
diff --git a/components/external_intents/android/java/src/org/chromium/components/external_intents/RedirectHandler.java b/components/external_intents/android/java/src/org/chromium/components/external_intents/RedirectHandler.java index 8e6f619..fb6a277 100644 --- a/components/external_intents/android/java/src/org/chromium/components/external_intents/RedirectHandler.java +++ b/components/external_intents/android/java/src/org/chromium/components/external_intents/RedirectHandler.java
@@ -14,6 +14,8 @@ import org.chromium.base.ContextUtils; import org.chromium.base.Function; import org.chromium.base.IntentUtils; +import org.chromium.base.Log; +import org.chromium.base.metrics.RecordHistogram; import org.chromium.ui.base.PageTransition; import java.util.HashSet; @@ -23,6 +25,8 @@ * This class contains the logic to determine effective navigation/redirect. */ public class RedirectHandler { + private static final String TAG = "RedirectHandler"; + /** * An invalid entry index. */ @@ -52,6 +56,8 @@ private boolean mShouldNotBlockOverrideUrlLoadingOnCurrentRedirectionChain; private boolean mExternalIntentStartedTask; + private long mLastUserInteractionTimeMillis; + public static RedirectHandler create() { return new RedirectHandler(); } @@ -168,6 +174,7 @@ boolean isInitialNavigation) { long prevNewUrlLoadingTime = mLastNewUrlLoadingTime; mLastNewUrlLoadingTime = SystemClock.elapsedRealtime(); + mLastUserInteractionTimeMillis = lastUserInteractionTime; int pageTransitionCore = pageTransType & PageTransition.CORE_MASK; @@ -346,4 +353,16 @@ public Intent getInitialIntent() { return mInitialIntent; } + + public void maybeLogExternalRedirectBlockedWithMissingGesture() { + if (mInitialNavigationType == NAVIGATION_TYPE_FROM_LINK_WITHOUT_USER_GESTURE) { + long millisSinceLastGesture = + SystemClock.elapsedRealtime() - mLastUserInteractionTimeMillis; + Log.w(TAG, + "External navigation blocked due to missing gesture. Last input was " + + millisSinceLastGesture + "ms ago."); + RecordHistogram.recordTimesHistogram( + "Android.Intent.BlockedExternalNavLastGestureTime", millisSinceLastGesture); + } + } }
diff --git a/components/history/core/browser/top_sites_impl.cc b/components/history/core/browser/top_sites_impl.cc index 1bad31c8..d921aa5f 100644 --- a/components/history/core/browser/top_sites_impl.cc +++ b/components/history/core/browser/top_sites_impl.cc
@@ -151,7 +151,7 @@ DCHECK(thread_checker_.CalledOnValidThread()); { - DictionaryPrefUpdateDeprecated update(pref_service_, kBlockedUrlsPrefsKey); + DictionaryPrefUpdate update(pref_service_, kBlockedUrlsPrefsKey); base::Value* blocked_urls = update.Get(); blocked_urls->SetKey(GetURLHash(url), base::Value()); } @@ -163,7 +163,7 @@ void TopSitesImpl::RemoveBlockedUrl(const GURL& url) { DCHECK(thread_checker_.CalledOnValidThread()); { - DictionaryPrefUpdateDeprecated update(pref_service_, kBlockedUrlsPrefsKey); + DictionaryPrefUpdate update(pref_service_, kBlockedUrlsPrefsKey); base::Value* blocked_urls = update.Get(); blocked_urls->RemoveKey(GetURLHash(url)); } @@ -181,7 +181,7 @@ void TopSitesImpl::ClearBlockedUrls() { DCHECK(thread_checker_.CalledOnValidThread()); { - DictionaryPrefUpdateDeprecated update(pref_service_, kBlockedUrlsPrefsKey); + DictionaryPrefUpdate update(pref_service_, kBlockedUrlsPrefsKey); base::Value* blocked_urls = update.Get(); blocked_urls->DictClear(); }
diff --git a/components/js_injection/browser/js_communication_host.cc b/components/js_injection/browser/js_communication_host.cc index a66611e..c271065 100644 --- a/components/js_injection/browser/js_communication_host.cc +++ b/components/js_injection/browser/js_communication_host.cc
@@ -201,6 +201,13 @@ void JsCommunicationHost::NotifyFrameForWebMessageListener( content::RenderFrameHost* render_frame_host) { + // AddWebMessageHostFactory() uses this method with ForEachFrame() from JNI. + // Old entries are deleted from `js_to_browser_messagings_` by + // RenderFrameDeleted(); however, RenderFrameDeleted() will not be called if + // there is no live RenderFrame. + if (!render_frame_host->IsRenderFrameLive()) + return; + mojo::AssociatedRemote<mojom::JsCommunication> configurator_remote; render_frame_host->GetRemoteAssociatedInterfaces()->GetInterface( &configurator_remote);
diff --git a/components/media_router/browser/media_router_metrics.h b/components/media_router/browser/media_router_metrics.h index a48c120..eff00f5 100644 --- a/components/media_router/browser/media_router_metrics.h +++ b/components/media_router/browser/media_router_metrics.h
@@ -34,25 +34,25 @@ kPinnedIconAndPresentation, kPinnedIconAndTabMirror, kPinnedIconAndDesktopMirror, - kPinnedIconAndLocalFile, + kPinnedIconAndLocalFile, // Obsolete. // One can start casting from an ephemeral icon by stopping a session, then // starting another from the same dialog. kEphemeralIconAndPresentation, kEphemeralIconAndTabMirror, kEphemeralIconAndDesktopMirror, - kEphemeralIconAndLocalFile, + kEphemeralIconAndLocalFile, // Obsolete. kContextMenuAndPresentation, kContextMenuAndTabMirror, kContextMenuAndDesktopMirror, - kContextMenuAndLocalFile, + kContextMenuAndLocalFile, // Obsolete. kPageAndPresentation, kPageAndTabMirror, kPageAndDesktopMirror, - kPageAndLocalFile, + kPageAndLocalFile, // Obsolete. kAppMenuAndPresentation, kAppMenuAndTabMirror, kAppMenuAndDesktopMirror, - kAppMenuAndLocalFile, + kAppMenuAndLocalFile, // Obsolete. // NOTE: Do not reorder existing entries, and add entries only immediately // above this line.
diff --git a/components/metrics/generate_expired_histograms_array.gni b/components/metrics/generate_expired_histograms_array.gni index 7be1c08..01882ef5 100644 --- a/components/metrics/generate_expired_histograms_array.gni +++ b/components/metrics/generate_expired_histograms_array.gni
@@ -50,6 +50,7 @@ "//tools/metrics/histograms/metadata/chrome/histograms.xml", "//tools/metrics/histograms/metadata/chromeos/histograms.xml", "//tools/metrics/histograms/metadata/chromeos_hps/histograms.xml", + "//tools/metrics/histograms/metadata/chromeos_settings/histograms.xml", "//tools/metrics/histograms/metadata/cloud/histograms.xml", "//tools/metrics/histograms/metadata/commerce/histograms.xml", "//tools/metrics/histograms/metadata/compositing/histograms.xml",
diff --git a/components/navigation_interception/android/java/src/org/chromium/components/navigation_interception/NavigationParams.java b/components/navigation_interception/android/java/src/org/chromium/components/navigation_interception/NavigationParams.java index 0379af2..39ff47d 100644 --- a/components/navigation_interception/android/java/src/org/chromium/components/navigation_interception/NavigationParams.java +++ b/components/navigation_interception/android/java/src/org/chromium/components/navigation_interception/NavigationParams.java
@@ -44,12 +44,6 @@ /** True if the target URL can't be handled by Chrome's internal protocol handlers. */ public final boolean isExternalProtocol; - /** - * True if the navigation was originated from a navigation which had been - * initiated by the user. - */ - public final boolean hasUserGestureCarryover; - /** True if the navigation was originated from the main frame. */ public final boolean isMainFrame; @@ -62,7 +56,7 @@ public NavigationParams(GURL url, GURL referrer, long navigationId, boolean isPost, boolean hasUserGesture, int pageTransitionType, boolean isRedirect, boolean isExternalProtocol, boolean isMainFrame, boolean isRendererInitiated, - boolean hasUserGestureCarryover, @Nullable Origin initiatorOrigin) { + @Nullable Origin initiatorOrigin) { this.url = url; this.referrer = referrer; this.navigationId = navigationId; @@ -73,7 +67,6 @@ this.isExternalProtocol = isExternalProtocol; this.isMainFrame = isMainFrame; this.isRendererInitiated = isRendererInitiated; - this.hasUserGestureCarryover = hasUserGestureCarryover; this.initiatorOrigin = initiatorOrigin; } @@ -81,9 +74,9 @@ public static NavigationParams create(GURL url, GURL referrer, long navigationId, boolean isPost, boolean hasUserGesture, int pageTransitionType, boolean isRedirect, boolean isExternalProtocol, boolean isMainFrame, boolean isRendererInitiated, - boolean hasUserGestureCarryover, @Nullable Origin initiatorOrigin) { + @Nullable Origin initiatorOrigin) { return new NavigationParams(url, referrer, navigationId, isPost, hasUserGesture, pageTransitionType, isRedirect, isExternalProtocol, isMainFrame, - isRendererInitiated, hasUserGestureCarryover, initiatorOrigin); + isRendererInitiated, initiatorOrigin); } }
diff --git a/components/navigation_interception/intercept_navigation_delegate.cc b/components/navigation_interception/intercept_navigation_delegate.cc index 897acfd..337e9c0 100644 --- a/components/navigation_interception/intercept_navigation_delegate.cc +++ b/components/navigation_interception/intercept_navigation_delegate.cc
@@ -32,8 +32,6 @@ namespace { -const int kMaxValidityOfUserGestureCarryoverInSeconds = 10; - const void* const kInterceptNavigationDelegateUserDataKey = &kInterceptNavigationDelegateUserDataKey; @@ -119,20 +117,11 @@ if (jdelegate.is_null()) return false; - bool has_user_gesture_carryover = - !navigation_params_to_use.has_user_gesture() && - base::TimeTicks::Now() - last_user_gesture_carryover_timestamp_ <= - base::Seconds(kMaxValidityOfUserGestureCarryoverInSeconds); - - ScopedJavaLocalRef<jobject> jobject_params = CreateJavaNavigationParams( - env, navigation_params_to_use, has_user_gesture_carryover); + ScopedJavaLocalRef<jobject> jobject_params = + CreateJavaNavigationParams(env, navigation_params_to_use); return Java_InterceptNavigationDelegate_shouldIgnoreNavigation( env, jdelegate, jobject_params); } -void InterceptNavigationDelegate::UpdateLastUserGestureCarryoverTimestamp() { - last_user_gesture_carryover_timestamp_ = base::TimeTicks::Now(); -} - } // namespace navigation_interception
diff --git a/components/navigation_interception/intercept_navigation_delegate.h b/components/navigation_interception/intercept_navigation_delegate.h index 4452c33..a6da027 100644 --- a/components/navigation_interception/intercept_navigation_delegate.h +++ b/components/navigation_interception/intercept_navigation_delegate.h
@@ -66,13 +66,8 @@ virtual bool ShouldIgnoreNavigation( const NavigationParams& navigation_params); - // Updates |last_user_gesture_carryover_timestamp_| when user gesture is - // carried over. - void UpdateLastUserGestureCarryoverTimestamp(); - private: JavaObjectWeakGlobalRef weak_jdelegate_; - base::TimeTicks last_user_gesture_carryover_timestamp_; bool escape_external_handler_value_ = false; };
diff --git a/components/navigation_interception/navigation_params_android.cc b/components/navigation_interception/navigation_params_android.cc index 8e593a7..99639178 100644 --- a/components/navigation_interception/navigation_params_android.cc +++ b/components/navigation_interception/navigation_params_android.cc
@@ -11,8 +11,7 @@ base::android::ScopedJavaLocalRef<jobject> CreateJavaNavigationParams( JNIEnv* env, - const NavigationParams& params, - bool has_user_gesture_carryover) { + const NavigationParams& params) { const GURL& url = params.base_url_for_data_url().is_empty() ? params.url() : params.base_url_for_data_url(); @@ -23,7 +22,7 @@ params.navigation_id(), params.is_post(), params.has_user_gesture(), params.transition_type(), params.is_redirect(), params.is_external_protocol(), params.is_main_frame(), - params.is_renderer_initiated(), has_user_gesture_carryover, + params.is_renderer_initiated(), params.initiator_origin() ? params.initiator_origin()->CreateJavaObject() : nullptr); }
diff --git a/components/navigation_interception/navigation_params_android.h b/components/navigation_interception/navigation_params_android.h index 7bb164dd..4c68f8c 100644 --- a/components/navigation_interception/navigation_params_android.h +++ b/components/navigation_interception/navigation_params_android.h
@@ -13,8 +13,7 @@ base::android::ScopedJavaLocalRef<jobject> CreateJavaNavigationParams( JNIEnv* env, - const NavigationParams& params, - bool has_user_gesture_carryover); + const NavigationParams& params); } // namespace navigation_interception
diff --git a/components/optimization_guide/DEPS b/components/optimization_guide/DEPS index c22edf8e..ba9c0890 100644 --- a/components/optimization_guide/DEPS +++ b/components/optimization_guide/DEPS
@@ -1,6 +1,4 @@ include_rules = [ - "+components/data_reduction_proxy/core/browser", - "+components/data_reduction_proxy/core/common", "+components/leveldb_proto", "+components/prefs", "+components/sync_preferences",
diff --git a/components/optimization_guide/core/BUILD.gn b/components/optimization_guide/core/BUILD.gn index 02ab759..e2ac18d 100644 --- a/components/optimization_guide/core/BUILD.gn +++ b/components/optimization_guide/core/BUILD.gn
@@ -195,7 +195,6 @@ deps = [ ":bloomfilter", "//base", - "//components/data_reduction_proxy/core/browser", "//components/leveldb_proto", "//components/optimization_guide/proto:optimization_guide_proto", "//components/prefs", @@ -323,8 +322,6 @@ ":test_support", "//base", "//base/test:test_support", - "//components/data_reduction_proxy/core/browser", - "//components/data_reduction_proxy/core/common", "//components/leveldb_proto:test_support", "//components/optimization_guide/proto:optimization_guide_proto", "//components/prefs:test_support",
diff --git a/components/optimization_guide/core/hints_fetcher.cc b/components/optimization_guide/core/hints_fetcher.cc index 108aa97e..273e1ebf 100644 --- a/components/optimization_guide/core/hints_fetcher.cc +++ b/components/optimization_guide/core/hints_fetcher.cc
@@ -109,7 +109,7 @@ // static void HintsFetcher::ClearHostsSuccessfullyFetched(PrefService* pref_service) { - DictionaryPrefUpdateDeprecated hosts_fetched_list( + DictionaryPrefUpdate hosts_fetched_list( pref_service, prefs::kHintsFetcherHostsSuccessfullyFetched); hosts_fetched_list->DictClear(); } @@ -134,7 +134,7 @@ return false; } - DictionaryPrefUpdateDeprecated hosts_fetched( + DictionaryPrefUpdate hosts_fetched( pref_service, prefs::kHintsFetcherHostsSuccessfullyFetched); absl::optional<double> value = hosts_fetched->FindDoubleKey(HashHostForDictionary(host)); @@ -149,7 +149,7 @@ // static void HintsFetcher::ClearSingleFetchedHost(PrefService* pref_service, const std::string& host) { - DictionaryPrefUpdateDeprecated hosts_fetched_list( + DictionaryPrefUpdate hosts_fetched_list( pref_service, prefs::kHintsFetcherHostsSuccessfullyFetched); hosts_fetched_list->RemovePath(HashHostForDictionary(host)); } @@ -158,7 +158,7 @@ void HintsFetcher::AddFetchedHostForTesting(PrefService* pref_service, const std::string& host, base::Time time) { - DictionaryPrefUpdateDeprecated hosts_fetched_list( + DictionaryPrefUpdate hosts_fetched_list( pref_service, prefs::kHintsFetcherHostsSuccessfullyFetched); hosts_fetched_list->SetDoubleKey( HashHostForDictionary(host), @@ -363,7 +363,7 @@ return; } - DictionaryPrefUpdateDeprecated hosts_fetched_list( + DictionaryPrefUpdate hosts_fetched_list( pref_service_, prefs::kHintsFetcherHostsSuccessfullyFetched); // Remove any expired hosts. @@ -454,7 +454,7 @@ const std::vector<std::string>& hosts) const { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - DictionaryPrefUpdateDeprecated hosts_fetched( + DictionaryPrefUpdate hosts_fetched( pref_service_, prefs::kHintsFetcherHostsSuccessfullyFetched); std::vector<std::string> target_hosts;
diff --git a/components/optimization_guide/core/hints_fetcher_unittest.cc b/components/optimization_guide/core/hints_fetcher_unittest.cc index 42da1d70..7605284 100644 --- a/components/optimization_guide/core/hints_fetcher_unittest.cc +++ b/components/optimization_guide/core/hints_fetcher_unittest.cc
@@ -90,7 +90,7 @@ // expire at |host_invalid_time|. void SeedCoveredHosts(const std::vector<std::string>& hosts, base::Time host_invalid_time) { - DictionaryPrefUpdateDeprecated hosts_fetched( + DictionaryPrefUpdate hosts_fetched( pref_service(), prefs::kHintsFetcherHostsSuccessfullyFetched); for (const std::string& host : hosts) { @@ -520,7 +520,7 @@ // The first pair of hosts should be removed from the dictionary // pref as they have expired. - DictionaryPrefUpdateDeprecated hosts_fetched( + DictionaryPrefUpdate hosts_fetched( pref_service(), prefs::kHintsFetcherHostsSuccessfullyFetched); EXPECT_EQ(2u, hosts_fetched->DictSize()); @@ -535,7 +535,7 @@ base::Time host_invalid_time = base::Time::Now() + base::Hours(1); SeedCoveredHosts(hosts, host_invalid_time); - DictionaryPrefUpdateDeprecated hosts_fetched( + DictionaryPrefUpdate hosts_fetched( pref_service(), prefs::kHintsFetcherHostsSuccessfullyFetched); EXPECT_EQ(2u, hosts_fetched->DictSize()); @@ -563,7 +563,7 @@ // The two expired hosts should be removed from the dictionary pref as they // have expired. - DictionaryPrefUpdateDeprecated hosts_fetched( + DictionaryPrefUpdate hosts_fetched( pref_service(), prefs::kHintsFetcherHostsSuccessfullyFetched); EXPECT_EQ(2u, hosts_fetched->DictSize()); @@ -597,7 +597,7 @@ EXPECT_TRUE(hints_fetched()); // Navigations to both the extra hosts should be recorded. - DictionaryPrefUpdateDeprecated hosts_fetched( + DictionaryPrefUpdate hosts_fetched( pref_service(), prefs::kHintsFetcherHostsSuccessfullyFetched); EXPECT_EQ(200u, hosts_fetched->DictSize()); @@ -633,7 +633,7 @@ if (!ShouldPersistHintsToDisk()) return; - DictionaryPrefUpdateDeprecated hosts_fetched( + DictionaryPrefUpdate hosts_fetched( pref_service(), prefs::kHintsFetcherHostsSuccessfullyFetched); EXPECT_EQ(max_hosts_in_fetch_request, hosts_fetched->DictSize()); EXPECT_EQ(all_hosts.size(), max_hosts_in_fetch_request + 5);
diff --git a/components/optimization_guide/core/hints_manager.cc b/components/optimization_guide/core/hints_manager.cc index 786a5c4..7ae4f3a 100644 --- a/components/optimization_guide/core/hints_manager.cc +++ b/components/optimization_guide/core/hints_manager.cc
@@ -885,7 +885,7 @@ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); bool should_load_new_optimization_filter = false; - DictionaryPrefUpdateDeprecated previously_registered_opt_types( + DictionaryPrefUpdate previously_registered_opt_types( pref_service_, prefs::kPreviouslyRegisteredOptimizationTypes); for (const auto optimization_type : optimization_types) { if (optimization_type == proto::TYPE_UNSPECIFIED)
diff --git a/components/optimization_guide/core/hints_manager_unittest.cc b/components/optimization_guide/core/hints_manager_unittest.cc index 5f4fd3b83..3b9c918 100644 --- a/components/optimization_guide/core/hints_manager_unittest.cc +++ b/components/optimization_guide/core/hints_manager_unittest.cc
@@ -15,7 +15,6 @@ #include "base/test/metrics/histogram_tester.h" #include "base/test/scoped_feature_list.h" #include "base/test/task_environment.h" -#include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h" #include "components/optimization_guide/core/bloom_filter.h" #include "components/optimization_guide/core/hint_cache.h" #include "components/optimization_guide/core/hints_component_util.h" @@ -313,8 +312,6 @@ pref_service_ = std::make_unique<sync_preferences::TestingPrefServiceSyncable>(); prefs::RegisterProfilePrefs(pref_service_->registry()); - pref_service_->registry()->RegisterBooleanPref( - data_reduction_proxy::prefs::kDataSaverEnabled, false); unified_consent::UnifiedConsentService::RegisterPrefs( pref_service_->registry());
diff --git a/components/optimization_guide/core/optimization_guide_permissions_util.cc b/components/optimization_guide/core/optimization_guide_permissions_util.cc index d7a71e2..fec0880 100644 --- a/components/optimization_guide/core/optimization_guide_permissions_util.cc +++ b/components/optimization_guide/core/optimization_guide_permissions_util.cc
@@ -7,21 +7,12 @@ #include <memory> #include "base/feature_list.h" -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h" #include "components/optimization_guide/core/optimization_guide_features.h" #include "components/optimization_guide/core/optimization_guide_switches.h" #include "components/unified_consent/url_keyed_data_collection_consent_helper.h" namespace { -bool IsUserDataSaverEnabledAndAllowedToFetchFromRemoteService( - bool is_off_the_record, - PrefService* pref_service) { - // Check if they are a data saver user. - return data_reduction_proxy::DataReductionProxySettings:: - IsDataSaverEnabledByUser(is_off_the_record, pref_service); -} - bool IsUserConsentedToAnonymousDataCollectionAndAllowedToFetchFromRemoteService( PrefService* pref_service) { if (!optimization_guide::features:: @@ -55,10 +46,6 @@ if (features::IsRemoteFetchingExplicitlyAllowedForPerformanceInfo()) return true; - if (IsUserDataSaverEnabledAndAllowedToFetchFromRemoteService( - is_off_the_record, pref_service)) - return true; - return IsUserConsentedToAnonymousDataCollectionAndAllowedToFetchFromRemoteService( pref_service); }
diff --git a/components/optimization_guide/core/optimization_guide_permissions_util_unittest.cc b/components/optimization_guide/core/optimization_guide_permissions_util_unittest.cc index 9e879748..015955c 100644 --- a/components/optimization_guide/core/optimization_guide_permissions_util_unittest.cc +++ b/components/optimization_guide/core/optimization_guide_permissions_util_unittest.cc
@@ -7,8 +7,6 @@ #include "base/command_line.h" #include "base/test/scoped_feature_list.h" #include "base/test/task_environment.h" -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h" -#include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h" #include "components/optimization_guide/core/optimization_guide_features.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "components/unified_consent/pref_names.h" @@ -22,13 +20,6 @@ void SetUp() override { unified_consent::UnifiedConsentService::RegisterPrefs( pref_service_.registry()); - pref_service_.registry()->RegisterBooleanPref( - data_reduction_proxy::prefs::kDataSaverEnabled, false); - } - - void SetDataSaverEnabled(bool enabled) { - data_reduction_proxy::DataReductionProxySettings:: - SetDataSaverEnabledForTesting(&pref_service_, enabled); } void SetUrlKeyedAnonymizedDataCollectionEnabled(bool enabled) { @@ -45,53 +36,38 @@ }; TEST_F(OptimizationGuidePermissionsUtilTest, - IsUserPermittedToFetchHintsNonDataSaverUser) { + IsUserPermittedToFetchHintsDefaultUser) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitAndEnableFeature( {optimization_guide::features::kRemoteOptimizationGuideFetching}); - SetDataSaverEnabled(false); EXPECT_FALSE(IsUserPermittedToFetchFromRemoteOptimizationGuide( /*is_off_the_record=*/false, pref_service())); } -TEST_F(OptimizationGuidePermissionsUtilTest, - IsUserPermittedToFetchHintsDataSaverUser) { - base::test::ScopedFeatureList scoped_feature_list; - scoped_feature_list.InitAndEnableFeature( - {optimization_guide::features::kRemoteOptimizationGuideFetching}); - SetDataSaverEnabled(true); - - EXPECT_TRUE(IsUserPermittedToFetchFromRemoteOptimizationGuide( - /*is_off_the_record=*/false, pref_service())); -} - TEST_F( OptimizationGuidePermissionsUtilTest, - IsUserPermittedToFetchHintsNonDataSaverUserAnonymousDataCollectionEnabledFeatureEnabled) { + IsUserPermittedToFetchHintsDefaultUserAnonymousDataCollectionEnabledFeatureEnabled) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitWithFeatures( {optimization_guide::features::kRemoteOptimizationGuideFetching, optimization_guide::features:: kRemoteOptimizationGuideFetchingAnonymousDataConsent}, {}); - SetDataSaverEnabled(false); SetUrlKeyedAnonymizedDataCollectionEnabled(true); EXPECT_TRUE(IsUserPermittedToFetchFromRemoteOptimizationGuide( /*is_off_the_record=*/false, pref_service())); } -TEST_F( - OptimizationGuidePermissionsUtilTest, - IsUserPermittedToFetchHintsNonDataSaverUserAnonymousDataCollectionDisabled) { +TEST_F(OptimizationGuidePermissionsUtilTest, + IsUserPermittedToFetchHintsDefaultUserAnonymousDataCollectionDisabled) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitWithFeatures( {optimization_guide::features::kRemoteOptimizationGuideFetching, optimization_guide::features:: kRemoteOptimizationGuideFetchingAnonymousDataConsent}, {}); - SetDataSaverEnabled(false); SetUrlKeyedAnonymizedDataCollectionEnabled(false); EXPECT_FALSE(IsUserPermittedToFetchFromRemoteOptimizationGuide( @@ -100,13 +76,12 @@ TEST_F( OptimizationGuidePermissionsUtilTest, - IsUserPermittedToFetchHintsNonDataSaverUserAnonymousDataCollectionEnabledFeatureNotEnabled) { + IsUserPermittedToFetchHintsDefaultUserAnonymousDataCollectionEnabledFeatureNotEnabled) { base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitWithFeatures( {optimization_guide::features::kRemoteOptimizationGuideFetching}, {optimization_guide::features:: kRemoteOptimizationGuideFetchingAnonymousDataConsent}); - SetDataSaverEnabled(false); SetUrlKeyedAnonymizedDataCollectionEnabled(true); EXPECT_FALSE(IsUserPermittedToFetchFromRemoteOptimizationGuide( @@ -118,7 +93,6 @@ base::test::ScopedFeatureList scoped_feature_list; scoped_feature_list.InitWithFeatures( {}, {optimization_guide::features::kRemoteOptimizationGuideFetching}); - SetDataSaverEnabled(true); SetUrlKeyedAnonymizedDataCollectionEnabled(true); EXPECT_FALSE(IsUserPermittedToFetchFromRemoteOptimizationGuide( @@ -133,7 +107,6 @@ optimization_guide::features:: kContextMenuPerformanceInfoAndRemoteHintFetching}, {}); - SetDataSaverEnabled(false); SetUrlKeyedAnonymizedDataCollectionEnabled(false); EXPECT_TRUE(IsUserPermittedToFetchFromRemoteOptimizationGuide( @@ -150,7 +123,6 @@ optimization_guide::features:: kContextMenuPerformanceInfoAndRemoteHintFetching}, {}); - SetDataSaverEnabled(true); SetUrlKeyedAnonymizedDataCollectionEnabled(true); EXPECT_FALSE(IsUserPermittedToFetchFromRemoteOptimizationGuide(
diff --git a/components/payments/content/android/payment_app_service_bridge.cc b/components/payments/content/android/payment_app_service_bridge.cc index 7b5a3e53..a2df0a2d 100644 --- a/components/payments/content/android/payment_app_service_bridge.cc +++ b/components/payments/content/android/payment_app_service_bridge.cc
@@ -274,7 +274,12 @@ // displays the top-level origin in its UI before the user can click on the // [Verify] button to invoke this authenticator. auto* rfh = content::RenderFrameHost::FromID(frame_routing_id_); - return rfh && rfh->IsActive() + // Lifetime of the created authenticator is externally managed by the + // authenticator factory, but is generally tied to the RenderFrame by + // listening for `RenderFrameDeleted()`. Check `IsRenderFrameLive()` as a + // safety precaution to ensure that `RenderFrameDeleted()` will be called at + // some point. + return rfh && rfh->IsActive() && rfh->IsRenderFrameLive() ? std::make_unique<InternalAuthenticatorAndroid>(rfh) : nullptr; }
diff --git a/components/policy/test_support/BUILD.gn b/components/policy/test_support/BUILD.gn index 9ce06fb..c353f460 100644 --- a/components/policy/test_support/BUILD.gn +++ b/components/policy/test_support/BUILD.gn
@@ -80,6 +80,7 @@ "embedded_policy_test_server_test_base.h", "embedded_policy_test_server_unittest.cc", "failing_request_handler_unittest.cc", + "policy_storage_unittest.cc", "request_handler_for_api_authorization_unittest.cc", "request_handler_for_auto_enrollment_unittest.cc", "request_handler_for_chrome_desktop_report_unittest.cc",
diff --git a/components/policy/test_support/embedded_policy_test_server.cc b/components/policy/test_support/embedded_policy_test_server.cc index 6245380..51f39bc 100644 --- a/components/policy/test_support/embedded_policy_test_server.cc +++ b/components/policy/test_support/embedded_policy_test_server.cc
@@ -28,6 +28,7 @@ #include "components/policy/test_support/request_handler_for_remote_commands.h" #include "components/policy/test_support/request_handler_for_status_upload.h" #include "components/policy/test_support/test_server_helpers.h" +#include "net/base/url_util.h" #include "net/http/http_status_code.h" #include "net/test/embedded_test_server/http_request.h" #include "net/test/embedded_test_server/http_response.h" @@ -40,6 +41,10 @@ namespace { +const char kExternalPolicyDataPath[] = "/externalpolicydata"; +const char kExternalPolicyTypeParam[] = "policy_type"; +const char kExternalEntityIdParam[] = "entity_id"; + std::unique_ptr<HttpResponse> LogStatusAndReturn( GURL url, std::unique_ptr<HttpResponse> response) { @@ -131,11 +136,25 @@ client_storage_.get(), policy_storage_.get(), request_type, error_code)); } +GURL EmbeddedPolicyTestServer::GetExternalPolicyDataURL( + const std::string& policy_type, + const std::string& entity_id) const { + GURL url = http_server_.GetURL(kExternalPolicyDataPath); + url = net::AppendOrReplaceQueryParameter(url, kExternalPolicyTypeParam, + policy_type); + url = net::AppendOrReplaceQueryParameter(url, kExternalEntityIdParam, + entity_id); + return url; +} + std::unique_ptr<HttpResponse> EmbeddedPolicyTestServer::HandleRequest( const HttpRequest& request) { GURL url = request.GetURL(); DLOG(INFO) << "Request URL: " << url; + if (url.path() == kExternalPolicyDataPath) + return HandleExternalPolicyDataRequest(url); + std::string request_type = KeyValueFromUrl(url, dm_protocol::kParamRequest); auto it = request_handlers_.find(request_type); if (it == request_handlers_.end()) { @@ -153,4 +172,22 @@ return LogStatusAndReturn(url, it->second->HandleRequest(request)); } +std::unique_ptr<HttpResponse> +EmbeddedPolicyTestServer::HandleExternalPolicyDataRequest(const GURL& url) { + DCHECK_EQ(url.path(), kExternalPolicyDataPath); + std::string policy_type = KeyValueFromUrl(url, kExternalPolicyTypeParam); + std::string entity_id = KeyValueFromUrl(url, kExternalEntityIdParam); + std::string policy_payload = + policy_storage_->GetExternalPolicyPayload(policy_type, entity_id); + std::unique_ptr<HttpResponse> response; + if (policy_payload.empty()) { + response = CreateHttpResponse( + net::HTTP_NOT_FOUND, + "No external policy payload for specified policy type and entity ID"); + } else { + response = CreateHttpResponse(net::HTTP_OK, policy_payload); + } + return LogStatusAndReturn(url, std::move(response)); +} + } // namespace policy
diff --git a/components/policy/test_support/embedded_policy_test_server.h b/components/policy/test_support/embedded_policy_test_server.h index 4b05eb01..a19ef43 100644 --- a/components/policy/test_support/embedded_policy_test_server.h +++ b/components/policy/test_support/embedded_policy_test_server.h
@@ -84,11 +84,18 @@ void ConfigureRequestError(const std::string& request_type, net::HttpStatusCode error_code); + GURL GetExternalPolicyDataURL(const std::string& policy_type, + const std::string& entity_id) const; + private: // Default request handler. std::unique_ptr<net::test_server::HttpResponse> HandleRequest( const net::test_server::HttpRequest& request); + // Request handler for external policy data. + std::unique_ptr<net::test_server::HttpResponse> + HandleExternalPolicyDataRequest(const GURL& request); + net::test_server::EmbeddedTestServer http_server_; std::map<std::string, std::unique_ptr<RequestHandler>> request_handlers_; std::unique_ptr<ClientStorage> client_storage_;
diff --git a/components/policy/test_support/embedded_policy_test_server_test_base.cc b/components/policy/test_support/embedded_policy_test_server_test_base.cc index a78a1a2..1a4c28dd 100644 --- a/components/policy/test_support/embedded_policy_test_server_test_base.cc +++ b/components/policy/test_support/embedded_policy_test_server_test_base.cc
@@ -12,6 +12,7 @@ #include "base/run_loop.h" #include "components/policy/core/common/cloud/cloud_policy_constants.h" #include "net/base/url_util.h" +#include "net/http/http_request_headers.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "services/network/public/cpp/resource_request.h" #include "services/network/public/cpp/shared_url_loader_factory.h" @@ -34,7 +35,7 @@ test_server_.Start(); resource_request_ = std::make_unique<network::ResourceRequest>(); - resource_request_->method = "POST"; + resource_request_->method = net::HttpRequestHeaders::kPostMethod; resource_request_->url = test_server_.GetServiceURL(); } @@ -48,6 +49,14 @@ net::AppendQueryParameter(resource_request_->url, key, value); } +void EmbeddedPolicyTestServerTestBase::SetURL(const GURL& url) { + resource_request_->url = url; +} + +void EmbeddedPolicyTestServerTestBase::SetMethod(const std::string& method) { + resource_request_->method = method; +} + void EmbeddedPolicyTestServerTestBase::SetAppType(const std::string& app_type) { AddQueryParam(dm_protocol::kParamAppType, app_type); }
diff --git a/components/policy/test_support/embedded_policy_test_server_test_base.h b/components/policy/test_support/embedded_policy_test_server_test_base.h index 43aff03..87ba0af 100644 --- a/components/policy/test_support/embedded_policy_test_server_test_base.h +++ b/components/policy/test_support/embedded_policy_test_server_test_base.h
@@ -38,6 +38,8 @@ void SetUp() override; // Helper functions to set request components. + void SetURL(const GURL& url); + void SetMethod(const std::string& method); void SetAppType(const std::string& app_type); void SetDeviceIdParam(const std::string& device_id); void SetDeviceType(const std::string& device_type);
diff --git a/components/policy/test_support/embedded_policy_test_server_unittest.cc b/components/policy/test_support/embedded_policy_test_server_unittest.cc index d8805b03..ebc97d6 100644 --- a/components/policy/test_support/embedded_policy_test_server_unittest.cc +++ b/components/policy/test_support/embedded_policy_test_server_unittest.cc
@@ -7,7 +7,9 @@ #include "components/policy/core/common/cloud/cloud_policy_constants.h" #include "components/policy/test_support/embedded_policy_test_server.h" #include "components/policy/test_support/embedded_policy_test_server_test_base.h" +#include "components/policy/test_support/policy_storage.h" #include "components/policy/test_support/test_server_helpers.h" +#include "net/http/http_request_headers.h" #include "net/http/http_status_code.h" #include "net/test/embedded_test_server/http_request.h" #include "net/test/embedded_test_server/http_response.h" @@ -19,9 +21,11 @@ namespace { constexpr char kFakeDeviceId[] = "fake_device_id"; +constexpr char kFakeExtensionId[] = "fake_extension_id"; constexpr char kFakeRequestType[] = "fake_request_type"; constexpr char kInvalidRequestType[] = "invalid_request_type"; constexpr char kResponseBodyYay[] = "Yay!!!"; +constexpr char kRawPolicyPayload[] = R"({"foo": "bar"})"; class FakeRequestHandler : public EmbeddedPolicyTestServer::RequestHandler { public: @@ -101,4 +105,30 @@ EXPECT_EQ(GetResponseCode(), net::HTTP_BAD_REQUEST); } +TEST_F(EmbeddedPolicyTestServerTest, HandleRequest_ExternalPolicyData_Success) { + test_server()->policy_storage()->SetExternalPolicyPayload( + dm_protocol::kChromeExtensionPolicyType, kFakeExtensionId, + kRawPolicyPayload); + SetMethod(net::HttpRequestHeaders::kGetMethod); + SetURL(test_server()->GetExternalPolicyDataURL( + dm_protocol::kChromeExtensionPolicyType, kFakeExtensionId)); + + StartRequestAndWait(); + + EXPECT_EQ(GetResponseCode(), net::HTTP_OK); + ASSERT_TRUE(HasResponseBody()); + EXPECT_EQ(GetResponseBody(), kRawPolicyPayload); +} + +TEST_F(EmbeddedPolicyTestServerTest, + HandleRequest_ExternalPolicyData_NoPayload) { + SetMethod(net::HttpRequestHeaders::kGetMethod); + SetURL(test_server()->GetExternalPolicyDataURL( + dm_protocol::kChromeExtensionPolicyType, kFakeExtensionId)); + + StartRequestAndWait(); + + EXPECT_EQ(GetResponseCode(), net::HTTP_NOT_FOUND); +} + } // namespace policy
diff --git a/components/policy/test_support/policy_storage.cc b/components/policy/test_support/policy_storage.cc index 5fd2615..bb6643c1 100644 --- a/components/policy/test_support/policy_storage.cc +++ b/components/policy/test_support/policy_storage.cc
@@ -63,6 +63,23 @@ policy_payloads_[GetPolicyKey(policy_type, entity_id)] = policy_payload; } +std::string PolicyStorage::GetExternalPolicyPayload( + const std::string& policy_type, + const std::string& entity_id) { + std::string policy_key = GetPolicyKey(policy_type, entity_id); + return external_policy_payloads_.contains(policy_key) + ? external_policy_payloads_.at(policy_key) + : std::string(); +} + +void PolicyStorage::SetExternalPolicyPayload( + const std::string& policy_type, + const std::string& entity_id, + const std::string& policy_payload) { + external_policy_payloads_[GetPolicyKey(policy_type, entity_id)] = + policy_payload; +} + void PolicyStorage::SetPsmEntry(const std::string& brand_serial_id, const PolicyStorage::PsmEntry& psm_entry) { psm_entries_[brand_serial_id] = psm_entry;
diff --git a/components/policy/test_support/policy_storage.h b/components/policy/test_support/policy_storage.h index 952363d..23f1480 100644 --- a/components/policy/test_support/policy_storage.h +++ b/components/policy/test_support/policy_storage.h
@@ -44,6 +44,18 @@ const std::string& entity_id, const std::string& policy_payload); + // Returns the raw payload to be served by an external endpoint and associated + // with |policy_type| and optional |entity_id|. Returns empty string if there + // is no such association. + std::string GetExternalPolicyPayload(const std::string& policy_type, + const std::string& entity_id); + + // Associates the |raw_payload| to be served via an external endpoint with + // |policy_type| and optional |entity_id|. + void SetExternalPolicyPayload(const std::string& policy_type, + const std::string& entity_id, + const std::string& raw_payload); + SignatureProvider* signature_provider() const { return signature_provider_.get(); } @@ -136,11 +148,13 @@ uint64_t remainder) const; private: - // Maps policy types to a serialized proto representing the policies to be - // applied for the type (e.g. CloudPolicySettings, - // ChromeDeviceSettingsProto). + // Maps policy keys to a serialized proto representing the policies to be + // applied for the type (e.g. CloudPolicySettings, ChromeDeviceSettingsProto). base::flat_map<std::string, std::string> policy_payloads_; + // Maps policy keys to a raw policy data served via an external endpoint. + base::flat_map<std::string, std::string> external_policy_payloads_; + std::unique_ptr<SignatureProvider> signature_provider_; std::string robot_api_auth_code_;
diff --git a/components/policy/test_support/policy_storage_unittest.cc b/components/policy/test_support/policy_storage_unittest.cc new file mode 100644 index 0000000..d735a4b --- /dev/null +++ b/components/policy/test_support/policy_storage_unittest.cc
@@ -0,0 +1,34 @@ +// 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 "components/policy/test_support/policy_storage.h" + +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace policy { + +namespace { + +constexpr const char kFakePolicyType[] = "fake_policy_type"; +constexpr const char kFakeEntityId[] = "fake_entity_id"; +constexpr const char kRawPolicyPayload[] = R"({"foo": "bar"})"; + +} // namespace + +TEST(PolicyStorageTest, StoresExternalPolicyData) { + PolicyStorage policy_storage; + policy_storage.SetExternalPolicyPayload(kFakePolicyType, kFakeEntityId, + kRawPolicyPayload); + + EXPECT_EQ( + policy_storage.GetExternalPolicyPayload(kFakePolicyType, kFakeEntityId), + kRawPolicyPayload); + // Check that external policy payloads are stored separately from regular + // policy payloads. + EXPECT_THAT(policy_storage.GetPolicyPayload(kFakePolicyType, kFakeEntityId), + testing::IsEmpty()); +} + +} // namespace policy
diff --git a/components/printing/browser/print_manager.cc b/components/printing/browser/print_manager.cc index 8635852..0bc4c12 100644 --- a/components/printing/browser/print_manager.cc +++ b/components/printing/browser/print_manager.cc
@@ -64,6 +64,15 @@ const mojo::AssociatedRemote<printing::mojom::PrintRenderFrame>& PrintManager::GetPrintRenderFrame(content::RenderFrameHost* rfh) { + // This is a safety CHECK() to protect against future regressions where a + // caller forgets to check `IsRenderFrameLive()`. Entries are removed from + // `print_render_frames_` by RenderFrameDeleted(), which may never be called + // if the RenderFrameHost does not currently have a live RenderFrame. + // + // While this CHECK() could be moved into the two conditional branches below + // that actually bind the remote, it does not really make sense to send an IPC + // to a non-live RenderFrame. + CHECK(rfh->IsRenderFrameLive()); auto it = print_render_frames_.find(rfh); if (it == print_render_frames_.end()) { mojo::AssociatedRemote<printing::mojom::PrintRenderFrame> remote;
diff --git a/components/printing/browser/print_to_pdf/pdf_print_manager.cc b/components/printing/browser/print_to_pdf/pdf_print_manager.cc index b814685..44421c6 100644 --- a/components/printing/browser/print_to_pdf/pdf_print_manager.cc +++ b/components/printing/browser/print_to_pdf/pdf_print_manager.cc
@@ -102,6 +102,12 @@ return; } + if (!rfh->IsRenderFrameLive()) { + std::move(callback).Run(PRINTING_FAILED, + base::MakeRefCounted<base::RefCountedString>()); + return; + } + printing_rfh_ = rfh; page_ranges_ = page_ranges; ignore_invalid_page_ranges_ = ignore_invalid_page_ranges; @@ -227,6 +233,22 @@ void PdfPrintManager::PdfWritingDone(int page_count) {} #endif +void PdfPrintManager::RenderFrameDeleted( + content::RenderFrameHost* render_frame_host) { + PrintManager::RenderFrameDeleted(render_frame_host); + + if (printing_rfh_ != render_frame_host) { + return; + } + + if (callback_) { + std::move(callback_).Run(PRINTING_FAILED, + base::MakeRefCounted<base::RefCountedString>()); + } + + Reset(); +} + void PdfPrintManager::DidPrintDocument( printing::mojom::DidPrintDocumentParamsPtr params, DidPrintDocumentCallback callback) { @@ -263,7 +285,15 @@ DCHECK(result == PRINT_SUCCESS || data_.empty()); std::move(callback_).Run(result, base::RefCountedString::TakeString(&data_)); - GetPrintRenderFrame(printing_rfh_)->PrintingDone(result == PRINT_SUCCESS); + // TODO(https://crbug.com/1286556): In theory, this should not be needed. In + // practice, nothing seems to restrict receiving incoming Mojo method calls + // for reporting the printing state to `printing_rfh_`. + // + // This should probably be changed so that the browser pushes endpoints to the + // renderer rather than the renderer connecting on-demand to the browser... + if (printing_rfh_ && printing_rfh_->IsRenderFrameLive()) { + GetPrintRenderFrame(printing_rfh_)->PrintingDone(result == PRINT_SUCCESS); + } Reset(); }
diff --git a/components/printing/browser/print_to_pdf/pdf_print_manager.h b/components/printing/browser/print_to_pdf/pdf_print_manager.h index c842027..193a1cc 100644 --- a/components/printing/browser/print_to_pdf/pdf_print_manager.h +++ b/components/printing/browser/print_to_pdf/pdf_print_manager.h
@@ -15,6 +15,7 @@ #include "components/printing/browser/print_manager.h" #include "components/printing/common/print.mojom.h" #include "content/public/browser/render_frame_host.h" +#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_user_data.h" #include "printing/print_settings.h" @@ -62,6 +63,9 @@ explicit PdfPrintManager(content::WebContents* web_contents); friend class content::WebContentsUserData<PdfPrintManager>; + // WebContentsObserver overrides (via PrintManager): + void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; + // printing::mojom::PrintManagerHost: void DidPrintDocument(printing::mojom::DidPrintDocumentParamsPtr params, DidPrintDocumentCallback callback) override;
diff --git a/components/reporting/encryption/encryption_module.cc b/components/reporting/encryption/encryption_module.cc index 49a43af..6cba25b 100644 --- a/components/reporting/encryption/encryption_module.cc +++ b/components/reporting/encryption/encryption_module.cc
@@ -4,7 +4,6 @@ #include "components/reporting/encryption/encryption_module.h" -#include <atomic> #include <string> #include <utility>
diff --git a/components/reporting/encryption/encryption_module.h b/components/reporting/encryption/encryption_module.h index 46894b122..653f04d 100644 --- a/components/reporting/encryption/encryption_module.h +++ b/components/reporting/encryption/encryption_module.h
@@ -5,8 +5,6 @@ #ifndef COMPONENTS_REPORTING_ENCRYPTION_ENCRYPTION_MODULE_H_ #define COMPONENTS_REPORTING_ENCRYPTION_ENCRYPTION_MODULE_H_ -#include <atomic> - #include "base/callback.h" #include "base/memory/ref_counted.h" #include "base/strings/string_piece.h"
diff --git a/components/reporting/encryption/encryption_module_interface.cc b/components/reporting/encryption/encryption_module_interface.cc index 1ca9997..49b5585 100644 --- a/components/reporting/encryption/encryption_module_interface.cc +++ b/components/reporting/encryption/encryption_module_interface.cc
@@ -4,8 +4,6 @@ #include "components/reporting/encryption/encryption_module_interface.h" -#include <atomic> - #include "base/callback.h" #include "base/feature_list.h" #include "base/strings/string_piece.h"
diff --git a/components/security_interstitials/content/stateful_ssl_host_state_delegate.cc b/components/security_interstitials/content/stateful_ssl_host_state_delegate.cc index 5a9cbe3c..e798723e 100644 --- a/components/security_interstitials/content/stateful_ssl_host_state_delegate.cc +++ b/components/security_interstitials/content/stateful_ssl_host_state_delegate.cc
@@ -99,8 +99,8 @@ int threshold) { double now = clock->Now().ToJsTime(); - DictionaryPrefUpdateDeprecated pref_update(pref_service, - prefs::kRecurrentSSLInterstitial); + DictionaryPrefUpdate pref_update(pref_service, + prefs::kRecurrentSSLInterstitial); base::Value* list_value = pref_update->FindListKey(net::ErrorToShortString(error)); if (list_value) { @@ -524,8 +524,8 @@ void StatefulSSLHostStateDelegate::ResetRecurrentErrorCountForTesting() { recurrent_errors_.clear(); - DictionaryPrefUpdateDeprecated pref_update(pref_service_, - prefs::kRecurrentSSLInterstitial); + DictionaryPrefUpdate pref_update(pref_service_, + prefs::kRecurrentSSLInterstitial); pref_update->DictClear(); }
diff --git a/components/sync/base/extensions_activity.cc b/components/sync/base/extensions_activity.cc index e2f88c4..71b06f2 100644 --- a/components/sync/base/extensions_activity.cc +++ b/components/sync/base/extensions_activity.cc
@@ -22,9 +22,7 @@ void ExtensionsActivity::PutRecords(const Records& records) { base::AutoLock lock(records_lock_); - for (const auto& id_and_record : records) { - const std::string& id = id_and_record.first; - const Record& record = id_and_record.second; + for (const auto& [id, record] : records) { records_[id].extension_id = record.extension_id; records_[id].bookmark_write_count += record.bookmark_write_count; }
diff --git a/components/sync/base/progress_marker_map.cc b/components/sync/base/progress_marker_map.cc index e2d9c58b..78787b5 100644 --- a/components/sync/base/progress_marker_map.cc +++ b/components/sync/base/progress_marker_map.cc
@@ -14,13 +14,12 @@ std::unique_ptr<base::DictionaryValue> ProgressMarkerMapToValue( const ProgressMarkerMap& marker_map) { std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); - for (const auto& model_type_and_progress_marker : marker_map) { + for (const auto& [model_type, progress_marker] : marker_map) { std::string printable_payload; - base::EscapeJSONString(model_type_and_progress_marker.second, - false /* put_in_quotes */, &printable_payload); + base::EscapeJSONString(progress_marker, false /* put_in_quotes */, + &printable_payload); base::Base64Encode(printable_payload, &printable_payload); - value->SetString(ModelTypeToString(model_type_and_progress_marker.first), - printable_payload); + value->SetString(ModelTypeToString(model_type), printable_payload); } return value; }
diff --git a/components/sync/driver/data_type_manager_impl.cc b/components/sync/driver/data_type_manager_impl.cc index 348c3d5..bfc4ea2 100644 --- a/components/sync/driver/data_type_manager_impl.cc +++ b/components/sync/driver/data_type_manager_impl.cc
@@ -76,9 +76,7 @@ // Check if any of the controllers are already in a FAILED state, and if so, // mark them accordingly in the status table. DataTypeStatusTable::TypeErrorMap existing_errors; - for (const auto& kv : *controllers_) { - ModelType type = kv.first; - const DataTypeController* controller = kv.second.get(); + for (const auto& [type, controller] : *controllers_) { DataTypeController::State state = controller->state(); DCHECK(state == DataTypeController::NOT_RUNNING || state == DataTypeController::STOPPING || @@ -238,9 +236,9 @@ DataTypeConfigState state, const DataTypeConfigStateMap& state_map) { ModelTypeSet types; - for (const auto& kv : state_map) { - if (kv.second == state) - types.Put(kv.first); + for (const auto& [type, config_state] : state_map) { + if (config_state == state) + types.Put(type); } return types; } @@ -743,10 +741,10 @@ if (debug_info_listener_.IsInitialized() && !configuration_stats_.empty()) { std::vector<DataTypeConfigurationStats> stats; - for (auto& type_and_stat : configuration_stats_) { + for (auto& [type, stat] : configuration_stats_) { // Note: |configuration_stats_| gets cleared below, so it's okay to // destroy its contents here. - stats.push_back(std::move(type_and_stat.second)); + stats.push_back(std::move(stat)); } debug_info_listener_.Call( FROM_HERE, &DataTypeDebugInfoListener::OnDataTypeConfigureComplete, @@ -774,9 +772,7 @@ ModelTypeSet DataTypeManagerImpl::GetPurgedDataTypes() const { ModelTypeSet purged_types; - for (const auto& kv : *controllers_) { - ModelType type = kv.first; - const DataTypeController* controller = kv.second.get(); + for (const auto& [type, controller] : *controllers_) { // TODO(crbug.com/897628): NOT_RUNNING doesn't necessarily mean the sync // metadata was cleared, if KEEP_METADATA was used when stopping. if (controller->state() == DataTypeController::NOT_RUNNING) {
diff --git a/components/sync/driver/data_type_manager_impl_unittest.cc b/components/sync/driver/data_type_manager_impl_unittest.cc index ba65395..880c795f 100644 --- a/components/sync/driver/data_type_manager_impl_unittest.cc +++ b/components/sync/driver/data_type_manager_impl_unittest.cc
@@ -136,12 +136,9 @@ DataTypeStatusTable::TypeErrorMap expected_errors = done_expectation_.data_type_status_table.GetAllErrors(); ASSERT_EQ(expected_errors.size(), errors.size()); - for (DataTypeStatusTable::TypeErrorMap::const_iterator iter = - expected_errors.begin(); - iter != expected_errors.end(); ++iter) { - ASSERT_TRUE(errors.find(iter->first) != errors.end()); - ASSERT_EQ(iter->second.error_type(), - errors.find(iter->first)->second.error_type()); + for (const auto& [type, error] : expected_errors) { + ASSERT_TRUE(errors.find(type) != errors.end()); + ASSERT_EQ(error.error_type(), errors.find(type)->second.error_type()); } done_expectation_ = DataTypeManager::ConfigureResult(); }
diff --git a/components/sync/driver/data_type_status_table.cc b/components/sync/driver/data_type_status_table.cc index b1d5d2e..652a355 100644 --- a/components/sync/driver/data_type_status_table.cc +++ b/components/sync/driver/data_type_status_table.cc
@@ -33,9 +33,8 @@ void DataTypeStatusTable::UpdateFailedDataTypes(const TypeErrorMap& errors) { DVLOG(1) << "Setting " << errors.size() << " new failed types."; - for (const auto& model_type_and_error : errors) { - UpdateFailedDataType(model_type_and_error.first, - model_type_and_error.second); + for (const auto& [model_type, error] : errors) { + UpdateFailedDataType(model_type, error); } }
diff --git a/components/sync/driver/glue/sync_transport_data_prefs.cc b/components/sync/driver/glue/sync_transport_data_prefs.cc index 18653e17..4baca33 100644 --- a/components/sync/driver/glue/sync_transport_data_prefs.cc +++ b/components/sync/driver/glue/sync_transport_data_prefs.cc
@@ -50,12 +50,10 @@ const std::map<ModelType, int64_t>& invalidation_versions, PrefService* pref_service) { auto invalidation_dictionary = std::make_unique<base::DictionaryValue>(); - for (const auto& map_iter : invalidation_versions) { - std::string version_str = base::NumberToString(map_iter.second); + for (const auto& [type, version] : invalidation_versions) { invalidation_dictionary->SetString( - base::NumberToString( - GetSpecificsFieldNumberFromModelType(map_iter.first)), - version_str); + base::NumberToString(GetSpecificsFieldNumberFromModelType(type)), + base::NumberToString(version)); } pref_service->Set(kSyncInvalidationVersions2, *invalidation_dictionary); }
diff --git a/components/sync/driver/glue/sync_transport_data_prefs_unittest.cc b/components/sync/driver/glue/sync_transport_data_prefs_unittest.cc index 7f12af3..aa38ad2 100644 --- a/components/sync/driver/glue/sync_transport_data_prefs_unittest.cc +++ b/components/sync/driver/glue/sync_transport_data_prefs_unittest.cc
@@ -39,8 +39,8 @@ sync_prefs_->GetInvalidationVersions(); EXPECT_EQ(versions.size(), versions2.size()); - for (auto map_iter : versions2) { - EXPECT_EQ(versions[map_iter.first], map_iter.second); + for (auto [type, version] : versions2) { + EXPECT_EQ(versions[type], version); } }
diff --git a/components/sync/driver/model_load_manager.cc b/components/sync/driver/model_load_manager.cc index 72ebb5f..ba06ab4 100644 --- a/components/sync/driver/model_load_manager.cc +++ b/components/sync/driver/model_load_manager.cc
@@ -55,8 +55,7 @@ DVLOG(1) << "ModelLoadManager: Stopping disabled types."; std::map<DataTypeController*, ShutdownReason> types_to_stop; - for (const auto& type_and_dtc : *controllers_) { - DataTypeController* dtc = type_and_dtc.second.get(); + for (const auto& [type, dtc] : *controllers_) { // We generally stop all data types which are not desired. When the storage // option changes, we need to restart all data types so that they can // re-wire to the correct storage. @@ -78,7 +77,7 @@ configure_context_.sync_mode == SyncMode::kTransportOnly) { reason = ShutdownReason::STOP_SYNC_AND_KEEP_DATA; } - types_to_stop[dtc] = reason; + types_to_stop[dtc.get()] = reason; } } @@ -89,9 +88,7 @@ types_to_stop.size(), base::BindOnce(&ModelLoadManager::LoadDesiredTypes, weak_ptr_factory_.GetWeakPtr())); - for (const auto& dtc_and_reason : types_to_stop) { - DataTypeController* dtc = dtc_and_reason.first; - const ShutdownReason reason = dtc_and_reason.second; + for (const auto& [dtc, reason] : types_to_stop) { DVLOG(1) << "ModelLoadManager: stop " << dtc->name() << " due to " << ShutdownReasonToString(reason); StopDatatypeImpl(SyncError(), reason, dtc, barrier_closure); @@ -155,13 +152,13 @@ weak_ptr_factory_.InvalidateWeakPtrs(); // Stop started data types. - for (const auto& type_and_dtc : *controllers_) { - DataTypeController* dtc = type_and_dtc.second.get(); + for (const auto& [type, dtc] : *controllers_) { if (dtc->state() != DataTypeController::NOT_RUNNING && dtc->state() != DataTypeController::STOPPING) { // We don't really wait until all datatypes have been fully stopped, which // is only required (and in fact waited for) when Initialize() is called. - StopDatatypeImpl(SyncError(), shutdown_reason, dtc, base::DoNothing()); + StopDatatypeImpl(SyncError(), shutdown_reason, dtc.get(), + base::DoNothing()); DVLOG(1) << "ModelLoadManager: Stopped " << dtc->name(); } }
diff --git a/components/sync/driver/sync_service_impl.cc b/components/sync/driver/sync_service_impl.cc index a2d99d2b..1c811731 100644 --- a/components/sync/driver/sync_service_impl.cc +++ b/components/sync/driver/sync_service_impl.cc
@@ -1215,9 +1215,8 @@ ModelTypeSet registered_types; // The |data_type_controllers_| are determined by command-line flags; // that's effectively what controls the values returned here. - for (const std::pair<const ModelType, std::unique_ptr<DataTypeController>>& - type_and_controller : data_type_controllers_) { - registered_types.Put(type_and_controller.first); + for (const auto& [type, controller] : data_type_controllers_) { + registered_types.Put(type); } return registered_types; } @@ -1225,9 +1224,7 @@ ModelTypeSet SyncServiceImpl::GetModelTypesForTransportOnlyMode() const { // Collect the types from all controllers that support transport-only mode. ModelTypeSet allowed_types; - for (const auto& type_and_controller : data_type_controllers_) { - ModelType type = type_and_controller.first; - const DataTypeController* controller = type_and_controller.second.get(); + for (const auto& [type, controller] : data_type_controllers_) { if (controller->ShouldRunInTransportOnlyMode()) { allowed_types.Put(type); } @@ -1306,12 +1303,7 @@ type_status_header->SetString("state", "State"); result->Append(std::move(type_status_header)); - for (const std::pair<const ModelType, std::unique_ptr<DataTypeController>>& - type_and_controller : data_type_controllers_) { - const ModelType type = type_and_controller.first; - const DataTypeController* const controller = - type_and_controller.second.get(); - + for (const auto& [type, controller] : data_type_controllers_) { auto type_status = std::make_unique<base::DictionaryValue>(); type_status->SetString("name", ModelTypeToString(type)); @@ -1397,8 +1389,8 @@ // Callbacks passed to the controllers get a non-owning reference to the // counts vector, which they use to push the count for their individual type. - for (const auto& type_and_controller : data_type_controllers_) { - type_and_controller.second->GetTypeEntitiesCount(base::BindOnce( + for (const auto& [type, controller] : data_type_controllers_) { + controller->GetTypeEntitiesCount(base::BindOnce( [](const base::RepeatingClosure& all_types_done_barrier, EntityCountsVector* all_types_counts_ptr, const TypeEntitiesCount& count) { @@ -1615,24 +1607,25 @@ for (ModelType type : all_types) { const auto dtc_iter = data_type_controllers_.find(type); - if (dtc_iter != data_type_controllers_.end()) { - if (dtc_iter->second->state() == DataTypeController::NOT_RUNNING) { - // In the NOT_RUNNING state it's not allowed to call GetAllNodes on the - // DataTypeController, so just return an empty result. - // This can happen e.g. if we're waiting for a custom passphrase to be - // entered - the data types are already considered active in this case, - // but their DataTypeControllers are still NOT_RUNNING. - helper->OnReceivedNodesForType(type, - std::make_unique<base::ListValue>()); - } else { - dtc_iter->second->GetAllNodes(base::BindRepeating( - &GetAllNodesRequestHelper::OnReceivedNodesForType, helper)); - } - } else { + if (dtc_iter == data_type_controllers_.end()) { // We should have no data type controller only for Nigori. DCHECK_EQ(type, NIGORI); engine_->GetNigoriNodeForDebugging(base::BindOnce( &GetAllNodesRequestHelper::OnReceivedNodesForType, helper)); + continue; + } + + DataTypeController* controller = dtc_iter->second.get(); + if (controller->state() == DataTypeController::NOT_RUNNING) { + // In the NOT_RUNNING state it's not allowed to call GetAllNodes on the + // DataTypeController, so just return an empty result. + // This can happen e.g. if we're waiting for a custom passphrase to be + // entered - the data types are already considered active in this case, + // but their DataTypeControllers are still NOT_RUNNING. + helper->OnReceivedNodesForType(type, std::make_unique<base::ListValue>()); + } else { + controller->GetAllNodes(base::BindRepeating( + &GetAllNodesRequestHelper::OnReceivedNodesForType, helper)); } } }
diff --git a/components/sync/driver/sync_service_impl_unittest.cc b/components/sync/driver/sync_service_impl_unittest.cc index 2416fac..40cfe7e 100644 --- a/components/sync/driver/sync_service_impl_unittest.cc +++ b/components/sync/driver/sync_service_impl_unittest.cc
@@ -115,10 +115,8 @@ // Default includes a regular controller and a transport-mode controller. DataTypeController::TypeVector controllers; - for (const auto& type_and_transport_mode_support : + for (const auto& [type, transport_mode_support] : registered_types_and_transport_mode_support) { - ModelType type = type_and_transport_mode_support.first; - bool transport_mode_support = type_and_transport_mode_support.second; auto controller = std::make_unique<FakeDataTypeController>( type, transport_mode_support); // Hold a raw pointer to directly interact with the controller.
diff --git a/components/sync/engine/commit.cc b/components/sync/engine/commit.cc index ea0487a..9d72c25f 100644 --- a/components/sync/engine/commit.cc +++ b/components/sync/engine/commit.cc
@@ -126,8 +126,8 @@ } ModelTypeSet contributed_data_types; - for (const auto& contribution : contributions) { - contributed_data_types.Put(contribution.first); + for (const auto& [type, contribution] : contributions) { + contributed_data_types.Put(type); } // Set the client config params. @@ -219,14 +219,13 @@ // Let the contributors process the responses to each of their requests. SyncerError processing_result = SyncerError(SyncerError::SYNCER_OK); - for (ContributionMap::const_iterator it = contributions_.begin(); - it != contributions_.end(); ++it) { - TRACE_EVENT1("sync", "ProcessCommitResponse", "type", - ModelTypeToString(it->first)); + for (const auto& [type, contributions] : contributions_) { + const char* model_type_str = ModelTypeToString(type); + TRACE_EVENT1("sync", "ProcessCommitResponse", "type", model_type_str); SyncerError type_result = - it->second->ProcessCommitResponse(response, status); + contributions->ProcessCommitResponse(response, status); if (type_result.value() == SyncerError::SERVER_RETURN_CONFLICT) { - nudge_tracker->RecordCommitConflict(it->first); + nudge_tracker->RecordCommitConflict(type); } if (processing_result.value() == SyncerError::SYNCER_OK && type_result.value() != SyncerError::SYNCER_OK) {
diff --git a/components/sync/engine/commit_util.cc b/components/sync/engine/commit_util.cc index 394000a..6e96984 100644 --- a/components/sync/engine/commit_util.cc +++ b/components/sync/engine/commit_util.cc
@@ -25,12 +25,12 @@ activity->GetAndClearRecords(extensions_activity_buffer); const ExtensionsActivity::Records& records = *extensions_activity_buffer; - for (const auto& id_and_record : records) { + for (const auto& [id, record] : records) { sync_pb::ChromiumExtensionsActivity* activity_message = message->add_extensions_activity(); - activity_message->set_extension_id(id_and_record.second.extension_id); + activity_message->set_extension_id(record.extension_id); activity_message->set_bookmark_writes_since_last_commit( - id_and_record.second.bookmark_write_count); + record.bookmark_write_count); } }
diff --git a/components/sync/engine/cycle/nudge_tracker.cc b/components/sync/engine/cycle/nudge_tracker.cc index 04c479d..009c935 100644 --- a/components/sync/engine/cycle/nudge_tracker.cc +++ b/components/sync/engine/cycle/nudge_tracker.cc
@@ -172,14 +172,14 @@ } void NudgeTracker::UpdateTypeThrottlingAndBackoffState() { - for (const auto& type_and_tracker : type_trackers_) { - type_and_tracker.second->UpdateThrottleOrBackoffState(); + for (const auto& [type, tracker] : type_trackers_) { + tracker->UpdateThrottleOrBackoffState(); } } bool NudgeTracker::IsAnyTypeBlocked() const { - for (const auto& type_and_tracker : type_trackers_) { - if (type_and_tracker.second->IsBlocked()) { + for (const auto& [type, tracker] : type_trackers_) { + if (tracker->IsBlocked()) { return true; } } @@ -203,11 +203,10 @@ // Return min of GetTimeUntilUnblock() values for all IsBlocked() types. base::TimeDelta time_until_next_unblock = base::TimeDelta::Max(); - for (const auto& type_and_tracker : type_trackers_) { - if (type_and_tracker.second->IsBlocked()) { + for (const auto& [type, tracker] : type_trackers_) { + if (tracker->IsBlocked()) { time_until_next_unblock = - std::min(time_until_next_unblock, - type_and_tracker.second->GetTimeUntilUnblock()); + std::min(time_until_next_unblock, tracker->GetTimeUntilUnblock()); } } DCHECK(!time_until_next_unblock.is_max()); @@ -224,9 +223,9 @@ ModelTypeSet NudgeTracker::GetBlockedTypes() const { ModelTypeSet result; - for (const auto& type_and_tracker : type_trackers_) { - if (type_and_tracker.second->IsBlocked()) { - result.Put(type_and_tracker.first); + for (const auto& [type, tracker] : type_trackers_) { + if (tracker->IsBlocked()) { + result.Put(type); } } return result; @@ -234,9 +233,9 @@ ModelTypeSet NudgeTracker::GetNudgedTypes() const { ModelTypeSet result; - for (const auto& type_and_tracker : type_trackers_) { - if (type_and_tracker.second->HasLocalChangePending()) { - result.Put(type_and_tracker.first); + for (const auto& [type, tracker] : type_trackers_) { + if (tracker->HasLocalChangePending()) { + result.Put(type); } } return result; @@ -244,9 +243,9 @@ ModelTypeSet NudgeTracker::GetNotifiedTypes() const { ModelTypeSet result; - for (const auto& type_and_tracker : type_trackers_) { - if (type_and_tracker.second->HasPendingInvalidation()) { - result.Put(type_and_tracker.first); + for (const auto& [type, tracker] : type_trackers_) { + if (tracker->HasPendingInvalidation()) { + result.Put(type); } } return result; @@ -254,9 +253,9 @@ ModelTypeSet NudgeTracker::GetRefreshRequestedTypes() const { ModelTypeSet result; - for (const auto& type_and_tracker : type_trackers_) { - if (type_and_tracker.second->HasRefreshRequestPending()) { - result.Put(type_and_tracker.first); + for (const auto& [type, tracker] : type_trackers_) { + if (tracker->HasRefreshRequestPending()) { + result.Put(type); } } return result; @@ -270,12 +269,11 @@ } sync_pb::SyncEnums::GetUpdatesOrigin NudgeTracker::GetOrigin() const { - for (const auto& type_and_tracker : type_trackers_) { - const DataTypeTracker& tracker = *type_and_tracker.second; - if (!tracker.IsBlocked() && - (tracker.HasPendingInvalidation() || - tracker.HasRefreshRequestPending() || - tracker.HasLocalChangePending() || tracker.IsInitialSyncRequired())) { + for (const auto& [type, tracker] : type_trackers_) { + if (!tracker->IsBlocked() && (tracker->HasPendingInvalidation() || + tracker->HasRefreshRequestPending() || + tracker->HasLocalChangePending() || + tracker->IsInitialSyncRequired())) { return sync_pb::SyncEnums::GU_TRIGGER; } } @@ -322,8 +320,8 @@ } void NudgeTracker::SetHintBufferSize(size_t size) { - for (const auto& type_and_tracker : type_trackers_) { - type_and_tracker.second->UpdatePayloadBufferSize(size); + for (const auto& [type, tracker] : type_trackers_) { + tracker->UpdatePayloadBufferSize(size); } }
diff --git a/components/sync/engine/get_updates_processor.cc b/components/sync/engine/get_updates_processor.cc index f0c57c23..907c449 100644 --- a/components/sync/engine/get_updates_processor.cc +++ b/components/sync/engine/get_updates_processor.cc
@@ -357,9 +357,9 @@ void GetUpdatesProcessor::ApplyUpdates(const ModelTypeSet& gu_types, StatusController* status_controller) { status_controller->set_get_updates_request_types(gu_types); - for (const auto& kv : *update_handler_map_) { - if (gu_types.Has(kv.first)) { - kv.second->ApplyUpdates(status_controller); + for (const auto& [type, update_handler] : *update_handler_map_) { + if (gu_types.Has(type)) { + update_handler->ApplyUpdates(status_controller); } } }
diff --git a/components/sync/engine/loopback_server/loopback_server.cc b/components/sync/engine/loopback_server/loopback_server.cc index c580e402..c02c7c51 100644 --- a/components/sync/engine/loopback_server/loopback_server.cc +++ b/components/sync/engine/loopback_server/loopback_server.cc
@@ -136,10 +136,8 @@ DCHECK(datatypes_to_migrate); datatypes_to_migrate->clear(); - for (const auto& request_version : request_version_map_) { - const ModelType type = request_version.first; - const int client_migration_version = - request_version.second.migration_version(); + for (const auto& [type, request_version] : request_version_map_) { + const int client_migration_version = request_version.migration_version(); const int server_migration_version = GetServerMigrationVersion(server_migration_versions, type); @@ -156,12 +154,11 @@ // version between request progress markers and response entities. void SetProgressMarkers( sync_pb::GetUpdatesResponse* get_updates_response) const { - for (const auto& kv : response_version_map_) { + for (const auto& [type, response_version] : response_version_map_) { sync_pb::DataTypeProgressMarker* new_marker = get_updates_response->add_new_progress_marker(); - new_marker->set_data_type_id( - GetSpecificsFieldNumberFromModelType(kv.first)); - new_marker->set_token(kv.second.ToString()); + new_marker->set_data_type_id(GetSpecificsFieldNumberFromModelType(type)); + new_marker->set_token(response_version.ToString()); } } @@ -463,9 +460,9 @@ } std::vector<const LoopbackServerEntity*> wanted_entities; - for (const auto& id_and_entity : entities_) { - if (sieve->ClientWantsItem(*id_and_entity.second)) { - wanted_entities.push_back(id_and_entity.second.get()); + for (const auto& [id, entity] : entities_) { + if (sieve->ClientWantsItem(*entity)) { + wanted_entities.push_back(entity.get()); } } @@ -615,10 +612,10 @@ void LoopbackServer::DeleteChildren(const string& parent_id) { std::vector<sync_pb::SyncEntity> tombstones; // Find all the children of |parent_id|. - for (auto& entity : entities_) { - if (IsChild(entity.first, parent_id)) { + for (auto& [id, entity] : entities_) { + if (IsChild(id, parent_id)) { sync_pb::SyncEntity proto; - entity.second->SerializeAsProto(&proto); + entity->SerializeAsProto(&proto); tombstones.emplace_back(proto); } } @@ -714,12 +711,11 @@ ModelType model_type) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); std::vector<sync_pb::SyncEntity> sync_entities; - for (const auto& kv : entities_) { - const LoopbackServerEntity& entity = *kv.second; - if (!(entity.IsDeleted() || entity.IsPermanent()) && - entity.GetModelType() == model_type) { + for (const auto& [id, entity] : entities_) { + if (!(entity->IsDeleted() || entity->IsPermanent()) && + entity->GetModelType() == model_type) { sync_pb::SyncEntity sync_entity; - entity.SerializeAsProto(&sync_entity); + entity->SerializeAsProto(&sync_entity); sync_entities.push_back(sync_entity); } } @@ -730,12 +726,11 @@ LoopbackServer::GetPermanentSyncEntitiesByModelType(ModelType model_type) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); std::vector<sync_pb::SyncEntity> sync_entities; - for (const auto& kv : entities_) { - const LoopbackServerEntity& entity = *kv.second; - if (!entity.IsDeleted() && entity.IsPermanent() && - entity.GetModelType() == model_type) { + for (const auto& [id, entity] : entities_) { + if (!entity->IsDeleted() && entity->IsPermanent() && + entity->GetModelType() == model_type) { sync_pb::SyncEntity sync_entity; - entity.SerializeAsProto(&sync_entity); + entity->SerializeAsProto(&sync_entity); sync_entities.push_back(sync_entity); } } @@ -754,23 +749,22 @@ dictionary->SetKey(ModelTypeToString(type), base::ListValue()); } - for (const auto& kv : entities_) { - const LoopbackServerEntity& entity = *kv.second; - if (entity.IsDeleted() || entity.IsPermanent()) { + for (const auto& [id, entity] : entities_) { + if (entity->IsDeleted() || entity->IsPermanent()) { // Tombstones are ignored as they don't represent current data. Folders // are also ignored as current verification infrastructure does not // consider them. continue; } base::ListValue* list_value; - if (!dictionary->GetList(ModelTypeToString(entity.GetModelType()), + if (!dictionary->GetList(ModelTypeToString(entity->GetModelType()), &list_value)) { return nullptr; } // TODO(pvalenzuela): Store more data for each entity so additional // verification can be performed. One example of additional verification // is checking the correctness of the bookmark hierarchy. - list_value->Append(entity.GetName()); + list_value->Append(entity->GetName()); } return dictionary; @@ -823,9 +817,9 @@ proto->set_last_version_assigned(version_); for (const auto& key : keystore_keys_) proto->add_keystore_keys(key.data(), key.size()); - for (const auto& entity : entities_) { + for (const auto& [id, entity] : entities_) { auto* new_entity = proto->mutable_entities()->Add(); - entity.second->SerializeAsLoopbackServerEntity(new_entity); + entity->SerializeAsLoopbackServerEntity(new_entity); } }
diff --git a/components/sync/engine/model_type_registry.cc b/components/sync/engine/model_type_registry.cc index edfbf13..830ca78 100644 --- a/components/sync/engine/model_type_registry.cc +++ b/components/sync/engine/model_type_registry.cc
@@ -108,9 +108,9 @@ ModelTypeSet ModelTypeRegistry::GetInitialSyncEndedTypes() const { ModelTypeSet result; - for (const auto& kv : update_handler_map_) { - if (kv.second->IsInitialSyncEnded()) - result.Put(kv.first); + for (const auto& [type, update_handler] : update_handler_map_) { + if (update_handler->IsInitialSyncEnded()) + result.Put(type); } return result; }
diff --git a/components/sync/engine/model_type_worker.cc b/components/sync/engine/model_type_worker.cc index d70dfa3..2d34c62 100644 --- a/components/sync/engine/model_type_worker.cc +++ b/components/sync/engine/model_type_worker.cc
@@ -473,11 +473,11 @@ if (!entries_pending_decryption_.empty() && (!encryption_enabled_ || cryptographer_->CanEncrypt())) { DCHECK(BlockForEncryption()); - for (auto& key_and_info : unknown_encryption_keys_by_name_) { - key_and_info.second.get_updates_while_should_have_been_known++; + for (auto& [key, info] : unknown_encryption_keys_by_name_) { + info.get_updates_while_should_have_been_known++; // If the key is now missing for too long, drop pending updates encrypted // with it. This eventually unblocks a worker having undecryptable data. - MaybeDropPendingUpdatesEncryptedWith(key_and_info.first); + MaybeDropPendingUpdatesEncryptedWith(key); } } @@ -738,9 +738,9 @@ } // Try to insert. If we already saw an item with the same server id, // this will fail but give us its iterator. - auto it_and_success = + auto [it, success] = id_to_index.emplace(candidate.entity.id, pending_updates_.size()); - if (it_and_success.second) { + if (success) { // New server id, append at the end. Note that we already inserted // the correct index (|pending_updates_.size()|) above. pending_updates_.push_back(std::move(candidate)); @@ -749,7 +749,7 @@ // Duplicate! Overwrite the existing update if |candidate| has a more recent // version. - const size_t existing_index = it_and_success.first->second; + const size_t existing_index = it->second; UpdateResponseData& existing_update = pending_updates_[existing_index]; if (candidate.response_version >= existing_update.response_version) { existing_update = std::move(candidate);
diff --git a/components/sync/engine/sync_scheduler_impl.cc b/components/sync/engine/sync_scheduler_impl.cc index 41a2125..eed7977 100644 --- a/components/sync/engine/sync_scheduler_impl.cc +++ b/components/sync/engine/sync_scheduler_impl.cc
@@ -840,9 +840,8 @@ if (force_short_nudge_delay_for_test_) return; - for (const auto& type_and_delay : nudge_delays) { - nudge_tracker_.UpdateLocalChangeDelay(type_and_delay.first, - type_and_delay.second); + for (const auto& [type, delay] : nudge_delays) { + nudge_tracker_.UpdateLocalChangeDelay(type, delay); } }
diff --git a/components/sync/model/client_tag_based_model_type_processor.cc b/components/sync/model/client_tag_based_model_type_processor.cc index 30ccd65..22b6804 100644 --- a/components/sync/model/client_tag_based_model_type_processor.cc +++ b/components/sync/model/client_tag_based_model_type_processor.cc
@@ -40,8 +40,8 @@ size_t CountDuplicateClientTags(const EntityMetadataMap& metadata_map) { size_t count = 0u; std::set<std::string> client_tag_hashes; - for (const auto& kv : metadata_map) { - const std::string& client_tag_hash = kv.second->client_tag_hash(); + for (const auto& [storage_key, metadata] : metadata_map) { + const std::string& client_tag_hash = metadata->client_tag_hash(); if (client_tag_hashes.find(client_tag_hash) != client_tag_hashes.end()) { count++; } @@ -940,8 +940,7 @@ std::unique_ptr<DataBatch> data_batch) { DCHECK(entity_tracker_); while (data_batch->HasNext()) { - KeyAndData data = data_batch->Next(); - const std::string& storage_key = data.first; + auto [storage_key, data] = data_batch->Next(); storage_keys_to_load.erase(storage_key); ProcessorEntity* entity = @@ -950,7 +949,7 @@ if (entity != nullptr && entity->RequiresCommitData()) { // SetCommitData will update EntityData's fields with values from // metadata. - entity->SetCommitData(std::move(data.second)); + entity->SetCommitData(std::move(data)); } } @@ -1113,14 +1112,13 @@ std::string type_string = ModelTypeToString(type_); while (batch->HasNext()) { - KeyAndData key_and_data = batch->Next(); - std::unique_ptr<EntityData> data = std::move(key_and_data.second); + const auto& [storage_key, data] = batch->Next(); // There is an overlap between EntityData fields from the bridge and // EntityMetadata fields from the processor's entity, metadata is // the authoritative source of truth. const ProcessorEntity* entity = - entity_tracker_->GetEntityForStorageKey(key_and_data.first); + entity_tracker_->GetEntityForStorageKey(storage_key); // |entity| could be null if there are some unapplied changes. if (entity != nullptr) { const sync_pb::EntityMetadata& metadata = entity->metadata();
diff --git a/components/sync/model/in_memory_metadata_change_list.cc b/components/sync/model/in_memory_metadata_change_list.cc index c539998..41c12a0 100644 --- a/components/sync/model/in_memory_metadata_change_list.cc +++ b/components/sync/model/in_memory_metadata_change_list.cc
@@ -13,9 +13,7 @@ void InMemoryMetadataChangeList::TransferChangesTo(MetadataChangeList* other) { DCHECK(other); - for (const auto& pair : metadata_changes_) { - const std::string& storage_key = pair.first; - const MetadataChange& change = pair.second; + for (const auto& [storage_key, change] : metadata_changes_) { switch (change.type) { case UPDATE: other->UpdateMetadata(storage_key, change.metadata);
diff --git a/components/sync/model/model_type_store_impl_unittest.cc b/components/sync/model/model_type_store_impl_unittest.cc index 1d82041..da35bb3 100644 --- a/components/sync/model/model_type_store_impl_unittest.cc +++ b/components/sync/model/model_type_store_impl_unittest.cc
@@ -139,10 +139,10 @@ EXPECT_EQ(state.SerializeAsString(), batch->GetModelTypeState().SerializeAsString()); EntityMetadataMap actual_metadata = batch->TakeAllMetadata(); - for (const auto& kv : expected_metadata) { - auto it = actual_metadata.find(kv.first); + for (const auto& [storage_key, metadata] : expected_metadata) { + auto it = actual_metadata.find(storage_key); ASSERT_TRUE(it != actual_metadata.end()); - EXPECT_EQ(kv.second.SerializeAsString(), it->second->SerializeAsString()); + EXPECT_EQ(metadata.SerializeAsString(), it->second->SerializeAsString()); actual_metadata.erase(it); } EXPECT_EQ(0U, actual_metadata.size());
diff --git a/components/sync/model/mutable_data_batch_unittest.cc b/components/sync/model/mutable_data_batch_unittest.cc index 6c1d7bc..31935b6e 100644 --- a/components/sync/model/mutable_data_batch_unittest.cc +++ b/components/sync/model/mutable_data_batch_unittest.cc
@@ -20,18 +20,18 @@ batch.Put("one", base::WrapUnique(entity1)); EXPECT_TRUE(batch.HasNext()); - const KeyAndData& pair1 = batch.Next(); + const auto& [key1, data1] = batch.Next(); EXPECT_FALSE(batch.HasNext()); - EXPECT_EQ("one", pair1.first); - EXPECT_EQ(entity1, pair1.second.get()); + EXPECT_EQ("one", key1); + EXPECT_EQ(entity1, data1.get()); batch.Put("two", base::WrapUnique(entity2)); EXPECT_TRUE(batch.HasNext()); - const KeyAndData& pair2 = batch.Next(); + const auto& [key2, data2] = batch.Next(); EXPECT_FALSE(batch.HasNext()); - EXPECT_EQ("two", pair2.first); - EXPECT_EQ(entity2, pair2.second.get()); + EXPECT_EQ("two", key2); + EXPECT_EQ(entity2, data2.get()); } TEST(MutableDataBatchTest, PutAndNextInterleaved) { @@ -47,23 +47,23 @@ batch.Put("two", base::WrapUnique(entity2)); EXPECT_TRUE(batch.HasNext()); - const KeyAndData& pair1 = batch.Next(); + const auto& [key1, data1] = batch.Next(); EXPECT_TRUE(batch.HasNext()); - EXPECT_EQ("one", pair1.first); - EXPECT_EQ(entity1, pair1.second.get()); + EXPECT_EQ("one", key1); + EXPECT_EQ(entity1, data1.get()); batch.Put("three", base::WrapUnique(entity3)); EXPECT_TRUE(batch.HasNext()); - const KeyAndData& pair2 = batch.Next(); + const auto& [key2, data2] = batch.Next(); EXPECT_TRUE(batch.HasNext()); - EXPECT_EQ("two", pair2.first); - EXPECT_EQ(entity2, pair2.second.get()); + EXPECT_EQ("two", key2); + EXPECT_EQ(entity2, data2.get()); - const KeyAndData& pair3 = batch.Next(); + const auto& [key3, data3] = batch.Next(); EXPECT_FALSE(batch.HasNext()); - EXPECT_EQ("three", pair3.first); - EXPECT_EQ(entity3, pair3.second.get()); + EXPECT_EQ("three", key3); + EXPECT_EQ(entity3, data3.get()); } TEST(MutableDataBatchTest, PutAndNextSharedKey) { @@ -78,15 +78,15 @@ batch.Put("same", base::WrapUnique(entity2)); EXPECT_TRUE(batch.HasNext()); - const KeyAndData& pair1 = batch.Next(); + const auto& [key1, data1] = batch.Next(); EXPECT_TRUE(batch.HasNext()); - EXPECT_EQ("same", pair1.first); - EXPECT_EQ(entity1, pair1.second.get()); + EXPECT_EQ("same", key1); + EXPECT_EQ(entity1, data1.get()); - const KeyAndData& pair2 = batch.Next(); + const auto& [key2, data2] = batch.Next(); EXPECT_FALSE(batch.HasNext()); - EXPECT_EQ("same", pair2.first); - EXPECT_EQ(entity2, pair2.second.get()); + EXPECT_EQ("same", key2); + EXPECT_EQ(entity2, data2.get()); } } // namespace syncer
diff --git a/components/sync/model/processor_entity_tracker.cc b/components/sync/model/processor_entity_tracker.cc index cded44b..1eec680d 100644 --- a/components/sync/model/processor_entity_tracker.cc +++ b/components/sync/model/processor_entity_tracker.cc
@@ -18,9 +18,9 @@ metadata_map) : model_type_state_(model_type_state) { DCHECK(model_type_state.initial_sync_done()); - for (auto& kv : metadata_map) { + for (auto& [storage_key, metadata] : metadata_map) { std::unique_ptr<ProcessorEntity> entity = - ProcessorEntity::CreateFromMetadata(kv.first, std::move(*kv.second)); + ProcessorEntity::CreateFromMetadata(storage_key, std::move(*metadata)); const ClientTagHash client_tag_hash = ClientTagHash::FromHashed(entity->metadata().client_tag_hash()); @@ -35,8 +35,7 @@ ProcessorEntityTracker::~ProcessorEntityTracker() = default; bool ProcessorEntityTracker::AllStorageKeysPopulated() const { - for (const auto& kv : entities_) { - const ProcessorEntity* entity = kv.second.get(); + for (const auto& [client_tag_hash, entity] : entities_) { if (entity->storage_key().empty()) return false; } @@ -47,15 +46,15 @@ } void ProcessorEntityTracker::ClearTransientSyncState() { - for (const auto& kv : entities_) { - kv.second->ClearTransientSyncState(); + for (const auto& [client_tag_hash, entity] : entities_) { + entity->ClearTransientSyncState(); } } size_t ProcessorEntityTracker::CountNonTombstoneEntries() const { size_t count = 0; - for (const auto& kv : entities_) { - if (!kv.second->metadata().is_deleted()) { + for (const auto& [client_tag_hash, entity] : entities_) { + if (!entity->metadata().is_deleted()) { ++count; } } @@ -158,8 +157,8 @@ ProcessorEntityTracker::GetAllEntitiesIncludingTombstones() const { std::vector<const ProcessorEntity*> entities; entities.reserve(entities_.size()); - for (const auto& entity : entities_) { - entities.push_back(entity.second.get()); + for (const auto& [client_tag_hash, entity] : entities_) { + entities.push_back(entity.get()); } return entities; } @@ -167,10 +166,9 @@ std::vector<ProcessorEntity*> ProcessorEntityTracker::GetEntitiesWithLocalChanges(size_t max_entries) { std::vector<ProcessorEntity*> entities; - for (const auto& kv : entities_) { - ProcessorEntity* entity = kv.second.get(); + for (const auto& [client_tag_hash, entity] : entities_) { if (entity->RequiresCommitRequest() && !entity->RequiresCommitData()) { - entities.push_back(entity); + entities.push_back(entity.get()); if (entities.size() >= max_entries) break; } @@ -179,8 +177,7 @@ } bool ProcessorEntityTracker::HasLocalChanges() const { - for (const auto& kv : entities_) { - ProcessorEntity* entity = kv.second.get(); + for (const auto& [client_tag_hash, entity] : entities_) { if (entity->RequiresCommitRequest()) { return true; } @@ -196,8 +193,7 @@ ProcessorEntityTracker::IncrementSequenceNumberForAllExcept( const std::unordered_set<std::string>& already_updated_storage_keys) { std::vector<const ProcessorEntity*> affected_entities; - for (const auto& kv : entities_) { - ProcessorEntity* entity = kv.second.get(); + for (const auto& [client_tag_hash, entity] : entities_) { if (entity->storage_key().empty() || (already_updated_storage_keys.find(entity->storage_key()) != already_updated_storage_keys.end())) { @@ -207,7 +203,7 @@ continue; } entity->IncrementSequenceNumber(base::Time::Now()); - affected_entities.push_back(entity); + affected_entities.push_back(entity.get()); } return affected_entities; }
diff --git a/components/sync/model/syncable_service_based_bridge.cc b/components/sync/model/syncable_service_based_bridge.cc index 89e9b8c..da5892e8 100644 --- a/components/sync/model/syncable_service_based_bridge.cc +++ b/components/sync/model/syncable_service_based_bridge.cc
@@ -487,11 +487,10 @@ // this function is reached only if sync is starting already. SyncDataList initial_sync_data; initial_sync_data.reserve(in_memory_store_.size()); - for (const std::pair<const std::string, sync_pb::EntitySpecifics>& record : - in_memory_store_) { + for (const auto& [storage_key, specifics] : in_memory_store_) { // Note that client tag hash is used as storage key too. initial_sync_data.push_back(SyncData::CreateRemoteData( - std::move(record.second), ClientTagHash::FromHashed(record.first))); + std::move(specifics), ClientTagHash::FromHashed(storage_key))); } auto error_callback =
diff --git a/components/sync/nigori/nigori_key_bag.cc b/components/sync/nigori/nigori_key_bag.cc index 4abcac7..cd2b3e2 100644 --- a/components/sync/nigori/nigori_key_bag.cc +++ b/components/sync/nigori/nigori_key_bag.cc
@@ -76,9 +76,8 @@ sync_pb::NigoriKeyBag NigoriKeyBag::ToProto() const { sync_pb::NigoriKeyBag output; - for (const auto& key_name_and_nigori : nigori_map_) { - *output.add_key() = - NigoriToProto(*key_name_and_nigori.second, key_name_and_nigori.first); + for (const auto& [key_name, nigori] : nigori_map_) { + *output.add_key() = NigoriToProto(*nigori, key_name); } return output; } @@ -135,10 +134,9 @@ } void NigoriKeyBag::AddAllUnknownKeysFrom(const NigoriKeyBag& other) { - for (const auto& key_name_and_nigori : other.nigori_map_) { + for (const auto& [key_name, nigori] : other.nigori_map_) { // Only use this key if we don't already know about it. - nigori_map_.emplace(key_name_and_nigori.first, - CloneNigori(*key_name_and_nigori.second)); + nigori_map_.emplace(key_name, CloneNigori(*nigori)); } }
diff --git a/components/sync/test/engine/fake_sync_manager.cc b/components/sync/test/engine/fake_sync_manager.cc index c6abeae..7ae0746 100644 --- a/components/sync/test/engine/fake_sync_manager.cc +++ b/components/sync/test/engine/fake_sync_manager.cc
@@ -49,9 +49,8 @@ auto it = num_invalidations_received_.find(type); if (it == num_invalidations_received_.end()) { return 0; - } else { - return it->second; } + return it->second; } void FakeSyncManager::WaitForSyncThread() {
diff --git a/components/sync/test/engine/mock_model_type_processor.cc b/components/sync/test/engine/mock_model_type_processor.cc index 569aef9a..3cf14bd 100644 --- a/components/sync/test/engine/mock_model_type_processor.cc +++ b/components/sync/test/engine/mock_model_type_processor.cc
@@ -293,9 +293,8 @@ auto it = sequence_numbers_.find(tag_hash); if (it == sequence_numbers_.end()) { return 0; - } else { - return it->second; } + return it->second; } // The model thread should be sending us items with strictly increasing @@ -313,9 +312,8 @@ auto it = base_versions_.find(tag_hash); if (it == base_versions_.end()) { return kUncommittedVersion; - } else { - return it->second; } + return it->second; } void MockModelTypeProcessor::SetBaseVersion(const ClientTagHash& tag_hash,
diff --git a/components/sync/test/engine/mock_model_type_worker.cc b/components/sync/test/engine/mock_model_type_worker.cc index 3cb32a1..d802ab5 100644 --- a/components/sync/test/engine/mock_model_type_worker.cc +++ b/components/sync/test/engine/mock_model_type_worker.cc
@@ -351,9 +351,8 @@ auto it = server_versions_.find(tag_hash); if (it == server_versions_.end()) { return 0; - } else { - return it->second; } + return it->second; } void MockModelTypeWorker::SetServerVersion(const ClientTagHash& tag_hash,
diff --git a/components/sync/test/engine/single_type_mock_server.cc b/components/sync/test/engine/single_type_mock_server.cc index e41cc72..7138f24 100644 --- a/components/sync/test/engine/single_type_mock_server.cc +++ b/components/sync/test/engine/single_type_mock_server.cc
@@ -170,9 +170,8 @@ // Server versions do not necessarily start at 1 or 0. if (it == server_versions_.end()) { return 2048; - } else { - return it->second; } + return it->second; } void SingleTypeMockServer::SetServerVersion(const ClientTagHash& tag_hash,
diff --git a/components/sync/test/model/fake_model_type_sync_bridge.cc b/components/sync/test/model/fake_model_type_sync_bridge.cc index 3481779e..d04cd00 100644 --- a/components/sync/test/model/fake_model_type_sync_bridge.cc +++ b/components/sync/test/model/fake_model_type_sync_bridge.cc
@@ -156,9 +156,9 @@ FakeModelTypeSyncBridge::Store::CreateMetadataBatch() const { auto metadata_batch = std::make_unique<MetadataBatch>(); metadata_batch->SetModelTypeState(model_type_state_); - for (const auto& kv : metadata_store_) { + for (const auto& [storage_key, metadata] : metadata_store_) { metadata_batch->AddMetadata( - kv.first, std::make_unique<sync_pb::EntityMetadata>(kv.second)); + storage_key, std::make_unique<sync_pb::EntityMetadata>(metadata)); } return metadata_batch; } @@ -253,9 +253,9 @@ } // Commit any local entities that aren't being overwritten by the server. - for (const auto& kv : db_->all_data()) { - if (remote_storage_keys.find(kv.first) == remote_storage_keys.end()) { - change_processor()->Put(kv.first, CopyEntityData(*kv.second), + for (const auto& [storage_key, entity_data] : db_->all_data()) { + if (remote_storage_keys.find(storage_key) == remote_storage_keys.end()) { + change_processor()->Put(storage_key, CopyEntityData(*entity_data), metadata_change_list.get()); } } @@ -338,8 +338,8 @@ } auto batch = std::make_unique<MutableDataBatch>(); - for (const auto& kv : db_->all_data()) { - batch->Put(kv.first, CopyEntityData(*kv.second)); + for (const auto& [storage_key, entity_data] : db_->all_data()) { + batch->Put(storage_key, CopyEntityData(*entity_data)); } std::move(callback).Run(std::move(batch)); }
diff --git a/components/sync/test/model/test_matchers.h b/components/sync/test/model/test_matchers.h index 81fc5988..8abe0c1 100644 --- a/components/sync/test/model/test_matchers.h +++ b/components/sync/test/model/test_matchers.h
@@ -48,12 +48,11 @@ // We need to convert the map values to non-pointers in order to make them // copyable and use gmock. - std::map<std::string, std::unique_ptr<sync_pb::EntityMetadata>> metadata = - arg->TakeAllMetadata(); + std::map<std::string, std::unique_ptr<sync_pb::EntityMetadata>> + metadata_by_storage_key = arg->TakeAllMetadata(); std::map<std::string, sync_pb::EntityMetadata> copyable_metadata; - for (std::pair<const std::string, std::unique_ptr<sync_pb::EntityMetadata>>& - kv : metadata) { - copyable_metadata[kv.first] = std::move(*(kv.second)); + for (auto& [storage_key, metadata] : metadata_by_storage_key) { + copyable_metadata[storage_key] = std::move(*metadata); } return ExplainMatchResult(
diff --git a/components/sync/trusted_vault/download_keys_response_handler.cc b/components/sync/trusted_vault/download_keys_response_handler.cc index 27e9a81..255e014 100644 --- a/components/sync/trusted_vault/download_keys_response_handler.cc +++ b/components/sync/trusted_vault/download_keys_response_handler.cc
@@ -63,8 +63,8 @@ } std::vector<ExtractedSharedKey> result; - for (const auto& epoch_and_extracted_key : epoch_to_extracted_key) { - result.push_back(epoch_and_extracted_key.second); + for (const auto& [epoch, extracted_key] : epoch_to_extracted_key) { + result.push_back(extracted_key); } return result; }
diff --git a/components/sync/trusted_vault/fake_security_domains_server.cc b/components/sync/trusted_vault/fake_security_domains_server.cc index 4e63760..ce92a8f 100644 --- a/components/sync/trusted_vault/fake_security_domains_server.cc +++ b/components/sync/trusted_vault/fake_security_domains_server.cc
@@ -220,10 +220,9 @@ state_.current_epoch++; state_.trusted_vault_keys.push_back(new_trusted_vault_key); state_.constant_key_allowed = false; - for (auto& member_and_shared_key : state_.public_key_to_shared_keys) { + for (auto& [member, shared_key] : state_.public_key_to_shared_keys) { std::unique_ptr<SecureBoxPublicKey> member_public_key = - SecureBoxPublicKey::CreateByImport( - ProtoStringToBytes(member_and_shared_key.first)); + SecureBoxPublicKey::CreateByImport(ProtoStringToBytes(member)); DCHECK(member_public_key); sync_pb::SharedMemberKey new_shared_key; @@ -234,7 +233,7 @@ AssignBytesToProtoString( ComputeMemberProof(*member_public_key, new_trusted_vault_key), new_shared_key.mutable_member_proof()); - member_and_shared_key.second.push_back(new_shared_key); + shared_key.push_back(new_shared_key); sync_pb::RotationProof rotation_proof; rotation_proof.set_new_epoch(state_.current_epoch); @@ -243,8 +242,7 @@ /*trusted_vault_key=*/new_trusted_vault_key, /*prev_trusted_vault_key=*/last_trusted_vault_key), rotation_proof.mutable_rotation_proof()); - state_.public_key_to_rotation_proofs[member_and_shared_key.first].push_back( - rotation_proof); + state_.public_key_to_rotation_proofs[member].push_back(rotation_proof); } return new_trusted_vault_key; @@ -278,16 +276,15 @@ bool FakeSecurityDomainsServer::AllMembersHaveKey( const std::vector<uint8_t>& trusted_vault_key) const { base::AutoLock autolock(lock_); - for (const auto& public_key_and_shared_keys : + for (const auto& [public_key, shared_keys] : state_.public_key_to_shared_keys) { bool member_has_key = false; std::unique_ptr<SecureBoxPublicKey> member_public_key = - SecureBoxPublicKey::CreateByImport( - ProtoStringToBytes(public_key_and_shared_keys.first)); + SecureBoxPublicKey::CreateByImport(ProtoStringToBytes(public_key)); DCHECK(member_public_key); - for (const auto& shared_key : public_key_and_shared_keys.second) { + for (const auto& shared_key : shared_keys) { // Member has |trusted_vault_key| if there is a member proof signed by // |trusted_vault_key|. if (VerifyMemberProof(*member_public_key, trusted_vault_key,
diff --git a/components/sync_bookmarks/bookmark_model_merger.cc b/components/sync_bookmarks/bookmark_model_merger.cc index 1f505865..70f6d38 100644 --- a/components/sync_bookmarks/bookmark_model_merger.cc +++ b/components/sync_bookmarks/bookmark_model_merger.cc
@@ -275,11 +275,9 @@ base::GUIDHash> guid_to_update; - for (auto& parent_guid_and_updates : *updates_per_parent_guid) { - std::list<UpdateResponseData>* updates = &parent_guid_and_updates.second; - - auto updates_iter = updates->begin(); - while (updates_iter != updates->end()) { + for (auto& [parent_guid, updates] : *updates_per_parent_guid) { + auto updates_iter = updates.begin(); + while (updates_iter != updates.end()) { const UpdateResponseData& update = *updates_iter; DCHECK(!update.entity.is_deleted()); DCHECK(update.entity.server_defined_unique_tag.empty()); @@ -308,11 +306,11 @@ if (CompareDuplicateUpdates(/*next_update=*/update, /*previous_update=*/duplicate_update)) { - updates->erase(it_and_success.first->second); + updates.erase(it_and_success.first->second); guid_to_update[guid_in_specifics] = updates_iter; ++updates_iter; } else { - updates_iter = updates->erase(updates_iter); + updates_iter = updates.erase(updates_iter); } } } @@ -544,9 +542,8 @@ DCHECK(favicon_service); int num_updates_in_forest = 0; - for (const auto& tree_tag_and_root : remote_forest_) { - num_updates_in_forest += - 1 + CountRemoteTreeNodeDescendantsForUma(tree_tag_and_root.second); + for (const auto& [server_defined_unique_tag, root] : remote_forest_) { + num_updates_in_forest += 1 + CountRemoteTreeNodeDescendantsForUma(root); } base::UmaHistogramCounts100000( "Sync.BookmarkModelMerger.ReachableInputUpdates", num_updates_in_forest); @@ -576,9 +573,7 @@ // to perform the primary match. If there are multiple match candidates it // selects the first one. // Associate permanent folders. - for (const auto& tree_tag_and_root : remote_forest_) { - const std::string& server_defined_unique_tag = tree_tag_and_root.first; - + for (const auto& [server_defined_unique_tag, root] : remote_forest_) { DCHECK(!server_defined_unique_tag.empty()); const bookmarks::BookmarkNode* permanent_folder = @@ -599,7 +594,7 @@ GetPermanentFolderGUIDForServerDefinedUniqueTag( server_defined_unique_tag)); MergeSubtree(/*local_subtree_root=*/permanent_folder, - /*remote_node=*/tree_tag_and_root.second); + /*remote_node=*/root); } if (base::FeatureList::IsEnabled(switches::kSyncReuploadBookmarks)) { @@ -646,9 +641,9 @@ // All remaining entries in |updates_per_parent_guid| must be unreachable from // permanent entities, since otherwise they would have been moved away. - for (const auto& parent_guid_and_updates : + for (const auto& [parent_guid, updates] : grouped_updates.updates_per_parent_guid) { - for (const UpdateResponseData& update : parent_guid_and_updates.second) { + for (const UpdateResponseData& update : updates) { if (update.entity.specifics.has_bookmark()) { LogProblematicBookmark(RemoteBookmarkUpdateError::kMissingParentEntity); tracker_for_recording_ignored_updates @@ -683,9 +678,8 @@ // Build a temporary lookup table for remote GUIDs. std::unordered_map<base::GUID, const RemoteTreeNode*, base::GUIDHash> guid_to_remote_node_map; - for (const auto& tree_tag_and_root : remote_forest) { - tree_tag_and_root.second.EmplaceSelfAndDescendantsByGUID( - &guid_to_remote_node_map); + for (const auto& [server_defined_unique_tag, root] : remote_forest) { + root.EmplaceSelfAndDescendantsByGUID(&guid_to_remote_node_map); } // Iterate through all local bookmarks to find matches by GUID.
diff --git a/components/sync_bookmarks/bookmark_remote_updates_handler.cc b/components/sync_bookmarks/bookmark_remote_updates_handler.cc index 88c86da3..2a0ab02 100644 --- a/components/sync_bookmarks/bookmark_remote_updates_handler.cc +++ b/components/sync_bookmarks/bookmark_remote_updates_handler.cc
@@ -465,11 +465,10 @@ std::set<base::GUID> roots; std::unordered_map<base::GUID, std::vector<base::GUID>, base::GUIDHash> parent_to_children; - for (const auto& pair : guid_to_updates) { - const syncer::EntityData& update_entity = pair.second->entity; - base::GUID parent_guid = GetParentGUIDInUpdate(update_entity); + for (const auto& [guid, update] : guid_to_updates) { + base::GUID parent_guid = GetParentGUIDInUpdate(update->entity); base::GUID child_guid = - base::GUID::ParseLowercase(update_entity.specifics.bookmark().guid()); + base::GUID::ParseLowercase(update->entity.specifics.bookmark().guid()); DCHECK(child_guid.is_valid()); parent_to_children[parent_guid].emplace_back(std::move(child_guid));
diff --git a/components/sync_bookmarks/bookmark_specifics_conversions.cc b/components/sync_bookmarks/bookmark_specifics_conversions.cc index bde8ce2..1250a1d 100644 --- a/components/sync_bookmarks/bookmark_specifics_conversions.cc +++ b/components/sync_bookmarks/bookmark_specifics_conversions.cc
@@ -70,10 +70,10 @@ void UpdateBookmarkSpecificsMetaInfo( const bookmarks::BookmarkNode::MetaInfoMap* metainfo_map, sync_pb::BookmarkSpecifics* bm_specifics) { - for (const std::pair<const std::string, std::string>& pair : *metainfo_map) { + for (const auto& [key, value] : *metainfo_map) { sync_pb::MetaInfo* meta_info = bm_specifics->add_meta_info(); - meta_info->set_key(pair.first); - meta_info->set_value(pair.second); + meta_info->set_key(key); + meta_info->set_value(value); } }
diff --git a/components/sync_bookmarks/synced_bookmark_tracker.cc b/components/sync_bookmarks/synced_bookmark_tracker.cc index 10fa10a..e7cbbea0 100644 --- a/components/sync_bookmarks/synced_bookmark_tracker.cc +++ b/components/sync_bookmarks/synced_bookmark_tracker.cc
@@ -398,20 +398,19 @@ *max_version_among_ignored_updates_due_to_missing_parent_); } - for (const std::pair<const std::string, std::unique_ptr<Entity>>& pair : - sync_id_to_entities_map_) { - DCHECK(pair.second) << " for ID " << pair.first; - DCHECK(pair.second->metadata()) << " for ID " << pair.first; - if (pair.second->metadata()->is_deleted()) { + for (const auto& [sync_id, entity] : sync_id_to_entities_map_) { + DCHECK(entity) << " for ID " << sync_id; + DCHECK(entity->metadata()) << " for ID " << sync_id; + if (entity->metadata()->is_deleted()) { // Deletions will be added later because they need to maintain the same // order as in |ordered_local_tombstones_|. continue; } - DCHECK(pair.second->bookmark_node()); + DCHECK(entity->bookmark_node()); sync_pb::BookmarkMetadata* bookmark_metadata = model_metadata.add_bookmarks_metadata(); - bookmark_metadata->set_id(pair.second->bookmark_node()->id()); - *bookmark_metadata->mutable_metadata() = *pair.second->metadata(); + bookmark_metadata->set_id(entity->bookmark_node()->id()); + *bookmark_metadata->mutable_metadata() = *entity->metadata(); } // Add pending deletions. for (const Entity* tombstone_entity : ordered_local_tombstones_) { @@ -427,9 +426,7 @@ } bool SyncedBookmarkTracker::HasLocalChanges() const { - for (const std::pair<const std::string, std::unique_ptr<Entity>>& pair : - sync_id_to_entities_map_) { - Entity* entity = pair.second.get(); + for (const auto& [sync_id, entity] : sync_id_to_entities_map_) { if (entity->IsUnsynced()) { return true; } @@ -440,9 +437,8 @@ std::vector<const SyncedBookmarkTracker::Entity*> SyncedBookmarkTracker::GetAllEntities() const { std::vector<const SyncedBookmarkTracker::Entity*> entities; - for (const std::pair<const std::string, std::unique_ptr<Entity>>& pair : - sync_id_to_entities_map_) { - entities.push_back(pair.second.get()); + for (const auto& [sync_id, entity] : sync_id_to_entities_map_) { + entities.push_back(entity.get()); } return entities; } @@ -452,16 +448,14 @@ std::vector<const SyncedBookmarkTracker::Entity*> entities_with_local_changes; // Entities with local non deletions should be sorted such that parent // creation/update comes before child creation/update. - for (const std::pair<const std::string, std::unique_ptr<Entity>>& pair : - sync_id_to_entities_map_) { - Entity* entity = pair.second.get(); + for (const auto& [sync_id, entity] : sync_id_to_entities_map_) { if (entity->metadata()->is_deleted()) { // Deletions are stored sorted in |ordered_local_tombstones_| and will be // added later. continue; } if (entity->IsUnsynced()) { - entities_with_local_changes.push_back(entity); + entities_with_local_changes.push_back(entity.get()); } } std::vector<const SyncedBookmarkTracker::Entity*> ordered_local_changes = @@ -689,16 +683,14 @@ !base::FeatureList::IsEnabled(switches::kSyncReuploadBookmarks)) { return false; } - for (const auto& sync_id_and_entity : sync_id_to_entities_map_) { - const SyncedBookmarkTracker::Entity* entity = - sync_id_and_entity.second.get(); + for (const auto& [sync_id, entity] : sync_id_to_entities_map_) { if (entity->IsUnsynced() || entity->metadata()->is_deleted()) { continue; } if (entity->bookmark_node()->is_permanent_node()) { continue; } - IncrementSequenceNumber(entity); + IncrementSequenceNumber(entity.get()); } SetBookmarksReuploaded(); return true;
diff --git a/components/sync_device_info/device_count_metrics_provider.cc b/components/sync_device_info/device_count_metrics_provider.cc index ae83874..64b8246 100644 --- a/components/sync_device_info/device_count_metrics_provider.cc +++ b/components/sync_device_info/device_count_metrics_provider.cc
@@ -37,20 +37,20 @@ int desktop_count = 0; int phone_count = 0; int tablet_count = 0; - for (const auto& device_type_and_count : count_by_type) { - total_devices += device_type_and_count.second; - switch (device_type_and_count.first) { + for (const auto& [device_type, count] : count_by_type) { + total_devices += count; + switch (device_type) { case sync_pb::SyncEnums_DeviceType_TYPE_CROS: case sync_pb::SyncEnums_DeviceType_TYPE_LINUX: case sync_pb::SyncEnums_DeviceType_TYPE_MAC: case sync_pb::SyncEnums_DeviceType_TYPE_WIN: - desktop_count += device_type_and_count.second; + desktop_count += count; break; case sync_pb::SyncEnums_DeviceType_TYPE_PHONE: - phone_count += device_type_and_count.second; + phone_count += count; break; case sync_pb::SyncEnums_DeviceType_TYPE_TABLET: - tablet_count += device_type_and_count.second; + tablet_count += count; break; case sync_pb::SyncEnums_DeviceType_TYPE_OTHER: case sync_pb::SyncEnums_DeviceType_TYPE_UNSET:
diff --git a/components/sync_device_info/device_info_sync_bridge.cc b/components/sync_device_info/device_info_sync_bridge.cc index 8472cd2..ca76553 100644 --- a/components/sync_device_info/device_info_sync_bridge.cc +++ b/components/sync_device_info/device_info_sync_bridge.cc
@@ -493,8 +493,8 @@ void DeviceInfoSyncBridge::GetAllDataForDebugging(DataCallback callback) { auto batch = std::make_unique<MutableDataBatch>(); - for (const auto& kv : all_data_) { - batch->Put(kv.first, CopyToEntityData(*kv.second)); + for (const auto& [cache_guid, specifics] : all_data_) { + batch->Put(cache_guid, CopyToEntityData(*specifics)); } std::move(callback).Run(std::move(batch)); } @@ -556,9 +556,9 @@ std::vector<std::unique_ptr<DeviceInfo>> DeviceInfoSyncBridge::GetAllDeviceInfo() const { std::vector<std::unique_ptr<DeviceInfo>> list; - for (const auto& id_and_specifics : all_data_) { - if (IsChromeClient(*id_and_specifics.second)) { - list.push_back(SpecificsToModel(*id_and_specifics.second)); + for (const auto& [cache_guid, specifics] : all_data_) { + if (IsChromeClient(*specifics)) { + list.push_back(SpecificsToModel(*specifics)); } } return list; @@ -856,36 +856,36 @@ std::map<sync_pb::SyncEnums_DeviceType, std::multimap<base::Time, int>> relevant_events; - for (const auto& pair : all_data_) { - if (!IsChromeClient(*pair.second)) { + for (const auto& [cache_guid, specifics] : all_data_) { + if (!IsChromeClient(*specifics)) { continue; } - if (DeviceInfoUtil::IsActive(GetLastUpdateTime(*pair.second), now)) { - base::Time begin = change_processor()->GetEntityCreationTime(pair.first); + if (DeviceInfoUtil::IsActive(GetLastUpdateTime(*specifics), now)) { + base::Time begin = change_processor()->GetEntityCreationTime(cache_guid); base::Time end = - change_processor()->GetEntityModificationTime(pair.first); + change_processor()->GetEntityModificationTime(cache_guid); // Begin/end timestamps are received from other devices without local // sanitizing, so potentially the timestamps could be malformed, and the // modification time may predate the creation time. if (begin > end) { continue; } - relevant_events[pair.second->device_type()].emplace(begin, 1); - relevant_events[pair.second->device_type()].emplace(end, -1); + relevant_events[specifics->device_type()].emplace(begin, 1); + relevant_events[specifics->device_type()].emplace(end, -1); } } std::map<sync_pb::SyncEnums_DeviceType, int> device_count_by_type; - for (const auto& type_and_events : relevant_events) { + for (const auto& [type, events] : relevant_events) { int max_overlapping = 0; int overlapping = 0; - for (const auto& event : type_and_events.second) { - overlapping += event.second; + for (const auto& [time, value] : events) { + overlapping += value; DCHECK_LE(0, overlapping); max_overlapping = std::max(max_overlapping, overlapping); } - device_count_by_type[type_and_events.first] = max_overlapping; + device_count_by_type[type] = max_overlapping; DCHECK_EQ(overlapping, 0); } @@ -898,10 +898,9 @@ std::unordered_set<std::string> cache_guids_to_expire; // Just collecting cache guids to expire to avoid modifying |all_data_| via // DeleteSpecifics() while iterating over it. - for (const auto& pair : all_data_) { - const std::string& cache_guid = pair.first; + for (const auto& [cache_guid, specifics] : all_data_) { if (cache_guid != local_cache_guid_ && - GetLastUpdateTime(*pair.second) < expiration_threshold) { + GetLastUpdateTime(*specifics) < expiration_threshold) { cache_guids_to_expire.insert(cache_guid); } }
diff --git a/components/sync_device_info/device_info_sync_bridge_unittest.cc b/components/sync_device_info/device_info_sync_bridge_unittest.cc index 38e1f3ec..627fe41 100644 --- a/components/sync_device_info/device_info_sync_bridge_unittest.cc +++ b/components/sync_device_info/device_info_sync_bridge_unittest.cc
@@ -343,8 +343,8 @@ std::unique_ptr<DataBatch> batch) { std::map<std::string, sync_pb::EntitySpecifics> storage_key_to_specifics; while (batch && batch->HasNext()) { - const syncer::KeyAndData& pair = batch->Next(); - storage_key_to_specifics[pair.first] = pair.second->specifics; + const auto& [key, data] = batch->Next(); + storage_key_to_specifics[key] = data->specifics; } return storage_key_to_specifics; }
diff --git a/components/sync_preferences/pref_model_associator.cc b/components/sync_preferences/pref_model_associator.cc index 29fbb22..3a25ed1 100644 --- a/components/sync_preferences/pref_model_associator.cc +++ b/components/sync_preferences/pref_model_associator.cc
@@ -342,6 +342,8 @@ base::Value result = to_value.Clone(); for (auto it : from_value.DictItems()) { + // It's not clear whether using a C++17 structured binding here would cause + // a copy of the value or not, so in doubt unpack the old way. const base::Value* from_key_value = &it.second; base::Value* to_key_value = result.FindKey(it.first); if (to_key_value) {
diff --git a/components/sync_sessions/local_session_event_handler_impl.cc b/components/sync_sessions/local_session_event_handler_impl.cc index 44f17cab..9b75a59 100644 --- a/components/sync_sessions/local_session_event_handler_impl.cc +++ b/components/sync_sessions/local_session_event_handler_impl.cc
@@ -32,10 +32,10 @@ DCHECK(sessions_client); SyncedWindowDelegatesGetter* synced_window_getter = sessions_client->GetSyncedWindowDelegatesGetter(); - SyncedWindowDelegatesGetter::SyncedWindowDelegateMap windows = + SyncedWindowDelegatesGetter::SyncedWindowDelegateMap window_delegates = synced_window_getter->GetSyncedWindowDelegates(); - for (const auto& window_iter_pair : windows) { - if (window_iter_pair.second->IsSessionRestoreInProgress()) { + for (const auto& [window_id, window_delegate] : window_delegates) { + if (window_delegate->IsSessionRestoreInProgress()) { return true; } } @@ -55,9 +55,8 @@ // tabs are currently open. This means that there is tab data that will be // restored later, but we cannot access it. bool ScanForTabbedWindow(SyncedWindowDelegatesGetter* delegates_getter) { - for (const auto& window_iter_pair : + for (const auto& [window_id, window_delegate] : delegates_getter->GetSyncedWindowDelegates()) { - const SyncedWindowDelegate* window_delegate = window_iter_pair.second; if (window_delegate->IsTypeNormal() && IsWindowSyncable(*window_delegate)) { return true; } @@ -150,7 +149,7 @@ SyncedSession* current_session = session_tracker_->GetSession(current_session_tag_); - SyncedWindowDelegatesGetter::SyncedWindowDelegateMap windows = + SyncedWindowDelegatesGetter::SyncedWindowDelegateMap window_delegates = sessions_client_->GetSyncedWindowDelegatesGetter() ->GetSyncedWindowDelegates(); @@ -168,8 +167,7 @@ << " windows from previous session."; } - for (auto& window_iter_pair : windows) { - const SyncedWindowDelegate* window_delegate = window_iter_pair.second; + for (auto& [unused, window_delegate] : window_delegates) { // Make sure the window is viewable and is not about to be closed. The // viewable window check is necessary because, for example, when a browser // is closed the destructor is not necessarily run immediately. This means @@ -184,6 +182,7 @@ continue; } + // TODO(crbug.com/1286934): Can we use the `unused` variable above instead? SessionID window_id = window_delegate->GetSessionId(); DVLOG(1) << "Associating window " << window_id.id() << " with " << window_delegate->GetTabCount() << " tabs.";
diff --git a/components/sync_sessions/local_session_event_handler_impl_unittest.cc b/components/sync_sessions/local_session_event_handler_impl_unittest.cc index 3b54002..b105c092 100644 --- a/components/sync_sessions/local_session_event_handler_impl_unittest.cc +++ b/components/sync_sessions/local_session_event_handler_impl_unittest.cc
@@ -73,11 +73,11 @@ const std::map<int, std::vector<int>>& window_id_to_tabs) { sync_pb::SessionSpecifics session_header; session_header.set_session_tag(kSessionTag); - for (const auto& window_and_tabs : window_id_to_tabs) { + for (const auto& [window_id, tabs] : window_id_to_tabs) { sync_pb::SessionWindow* mutable_window = session_header.mutable_header()->add_window(); - mutable_window->set_window_id(window_and_tabs.first); - for (int tab_id : window_and_tabs.second) { + mutable_window->set_window_id(window_id); + for (int tab_id : tabs) { mutable_window->add_tab(tab_id); } }
diff --git a/components/sync_sessions/session_store.cc b/components/sync_sessions/session_store.cc index 8b9e86c..6534a2d 100644 --- a/components/sync_sessions/session_store.cc +++ b/components/sync_sessions/session_store.cc
@@ -421,10 +421,7 @@ bool found_local_header = false; - for (auto& storage_key_and_specifics : initial_data) { - const std::string& storage_key = storage_key_and_specifics.first; - SessionSpecifics& specifics = storage_key_and_specifics.second; - + for (auto& [storage_key, specifics] : initial_data) { // The store should not contain invalid data, but as a precaution we filter // out anyway in case the persisted data is corrupted. if (!AreValidSpecifics(specifics)) {
diff --git a/components/sync_sessions/session_store_unittest.cc b/components/sync_sessions/session_store_unittest.cc index 65b9bc7..2a1982f7 100644 --- a/components/sync_sessions/session_store_unittest.cc +++ b/components/sync_sessions/session_store_unittest.cc
@@ -101,9 +101,7 @@ std::unique_ptr<DataBatch> batch) { std::map<std::string, EntityData> storage_key_to_data; while (batch && batch->HasNext()) { - auto batch_entry = batch->Next(); - const std::string& storage_key = batch_entry.first; - std::unique_ptr<EntityData> entity_data = std::move(batch_entry.second); + auto [storage_key, entity_data] = batch->Next(); EXPECT_THAT(entity_data, NotNull()); if (entity_data) { storage_key_to_data.emplace(storage_key, std::move(*entity_data));
diff --git a/components/sync_sessions/session_sync_bridge.cc b/components/sync_sessions/session_sync_bridge.cc index 17010234..6484e51 100644 --- a/components/sync_sessions/session_sync_bridge.cc +++ b/components/sync_sessions/session_sync_bridge.cc
@@ -440,10 +440,9 @@ CreateSessionStoreWriteBatch(); std::unique_ptr<syncer::DataBatch> read_batch = store_->GetAllSessionData(); while (read_batch->HasNext()) { - syncer::KeyAndData key_and_data = read_batch->Next(); - if (store_->StorageKeyMatchesLocalSession(key_and_data.first)) { - change_processor()->Put(key_and_data.first, - std::move(key_and_data.second), + auto [key, data] = read_batch->Next(); + if (store_->StorageKeyMatchesLocalSession(key)) { + change_processor()->Put(key, std::move(data), write_batch->GetMetadataChangeList()); } }
diff --git a/components/sync_sessions/synced_session.cc b/components/sync_sessions/synced_session.cc index f9f0ecc..98e1f61 100644 --- a/components/sync_sessions/synced_session.cc +++ b/components/sync_sessions/synced_session.cc
@@ -353,9 +353,9 @@ sync_pb::SessionHeader SyncedSession::ToSessionHeaderProto() const { sync_pb::SessionHeader header; - for (const auto& window_pair : windows) { + for (const auto& [window_id, window] : windows) { sync_pb::SessionWindow* w = header.add_window(); - w->CopyFrom(window_pair.second->ToSessionWindowProto()); + w->CopyFrom(window->ToSessionWindowProto()); } header.set_client_name(session_name); header.set_device_type(device_type);
diff --git a/components/sync_sessions/synced_session_tracker.cc b/components/sync_sessions/synced_session_tracker.cc index 42a0de0..6923c4c3 100644 --- a/components/sync_sessions/synced_session_tracker.cc +++ b/components/sync_sessions/synced_session_tracker.cc
@@ -50,9 +50,8 @@ // Presentable means |foreign_session| must have syncable content. bool IsPresentable(SyncSessionsClient* sessions_client, const SyncedSession& foreign_session) { - for (const auto& id_and_window : foreign_session.windows) { - if (ShouldSyncSessionWindow(sessions_client, - id_and_window.second->wrapped_window)) { + for (const auto& [window_id, window] : foreign_session.windows) { + if (ShouldSyncSessionWindow(sessions_client, window->wrapped_window)) { return true; } } @@ -201,8 +200,9 @@ if (!session) return false; // We have no record of this session. - for (const auto& window_pair : session->synced_session.windows) - windows->push_back(&window_pair.second->wrapped_window); + for (const auto& [window_id, window] : session->synced_session.windows) { + windows->push_back(&window->wrapped_window); + } return true; } @@ -286,17 +286,16 @@ const std::string& session_tag) { TrackedSession* session = GetTrackedSession(session_tag); - for (auto& window_pair : session->synced_session.windows) { + for (auto& [window_id, window] : session->synced_session.windows) { // First unmap the tabs in the window. - for (auto& tab : window_pair.second->wrapped_window.tabs) { + for (auto& tab : window->wrapped_window.tabs) { SessionID tab_id = tab->tab_id; session->unmapped_tabs[tab_id] = std::move(tab); } - window_pair.second->wrapped_window.tabs.clear(); + window->wrapped_window.tabs.clear(); // Then unmap the window itself. - session->unmapped_windows[window_pair.first] = - std::move(window_pair.second); + session->unmapped_windows[window_id] = std::move(window); } session->synced_session.windows.clear(); } @@ -339,8 +338,8 @@ SessionLookup lookup, bool exclude_local_session) const { std::vector<const SyncedSession*> sessions; - for (const auto& session_pair : session_map_) { - const SyncedSession& session = session_pair.second.synced_session; + for (const auto& [session_tag, tracked_session] : session_map_) { + const SyncedSession& session = tracked_session.synced_session; if (lookup == PRESENTABLE && !IsPresentable(sessions_client_, session)) { continue; } @@ -349,8 +348,8 @@ // IsRecentLocalCacheGuid() is used to filter out older values of the // local cache GUID. if (exclude_local_session && - (session_pair.first == local_session_tag_ || - sessions_client_->IsRecentLocalCacheGuid(session_pair.first))) { + (session_tag == local_session_tag_ || + sessions_client_->IsRecentLocalCacheGuid(session_tag))) { continue; } sessions.push_back(&session); @@ -366,8 +365,9 @@ if (!session) return; - for (const auto& window_pair : session->unmapped_windows) - session->synced_window_map.erase(window_pair.first); + for (const auto& [window_id, window] : session->unmapped_windows) { + session->synced_window_map.erase(window_id); + } session->unmapped_windows.clear(); int num_unmapped_and_unsynced = 0; @@ -475,19 +475,20 @@ // The tab has already been mapped, possibly because of the tab node id // being reused across tabs. Find the existing tab and move it to the right // window. - for (auto& window_iter_pair : GetSession(session_tag)->windows) { - auto tab_iter = std::find_if( - window_iter_pair.second->wrapped_window.tabs.begin(), - window_iter_pair.second->wrapped_window.tabs.end(), + for (auto& [existing_window_id, existing_window] : + GetSession(session_tag)->windows) { + auto existing_tab_iter = std::find_if( + existing_window->wrapped_window.tabs.begin(), + existing_window->wrapped_window.tabs.end(), [&tab_ptr](const std::unique_ptr<sessions::SessionTab>& tab) { return tab.get() == tab_ptr; }); - if (tab_iter != window_iter_pair.second->wrapped_window.tabs.end()) { - tab = std::move(*tab_iter); - window_iter_pair.second->wrapped_window.tabs.erase(tab_iter); + if (existing_tab_iter != existing_window->wrapped_window.tabs.end()) { + tab = std::move(*existing_tab_iter); + existing_window->wrapped_window.tabs.erase(existing_tab_iter); DVLOG(1) << "Moving tab " << tab_id << " from window " - << window_iter_pair.first << " to " << window_id; + << existing_window_id << " to " << window_id; break; } } @@ -643,15 +644,16 @@ session->unmapped_tabs.erase(unmapped_tabs_iter); } else { sessions::SessionTab* new_tab_ptr = new_tab_iter->second; - for (auto& window_iter_pair : session->synced_session.windows) { - auto& window_tabs = window_iter_pair.second->wrapped_window.tabs; + for (auto& [existing_window_id, existing_window] : + session->synced_session.windows) { + auto& existing_window_tabs = existing_window->wrapped_window.tabs; auto tab_iter = std::find_if( - window_tabs.begin(), window_tabs.end(), + existing_window_tabs.begin(), existing_window_tabs.end(), [&new_tab_ptr](const std::unique_ptr<sessions::SessionTab>& tab) { return tab.get() == new_tab_ptr; }); - if (tab_iter != window_tabs.end()) { - window_tabs.erase(tab_iter); + if (tab_iter != existing_window_tabs.end()) { + existing_window_tabs.erase(tab_iter); break; } } @@ -813,8 +815,7 @@ const base::RepeatingCallback<void(const std::string& session_name, sync_pb::SessionSpecifics* specifics)>& output_cb) { - for (const auto& session_entry : session_tag_to_node_ids) { - const std::string& session_tag = session_entry.first; + for (const auto& [session_tag, node_ids] : session_tag_to_node_ids) { const SyncedSession* session = tracker.LookupSession(session_tag); if (!session) { // Unknown session. @@ -824,7 +825,7 @@ const std::set<int> known_tab_node_ids = tracker.LookupTabNodeIds(session_tag); - for (int tab_node_id : session_entry.second) { + for (int tab_node_id : node_ids) { // Header entity. if (tab_node_id == TabNodePool::kInvalidTabNodeID) { sync_pb::SessionSpecifics header_pb;
diff --git a/components/sync_sessions/synced_session_tracker_unittest.cc b/components/sync_sessions/synced_session_tracker_unittest.cc index f6065cbf..461c268d 100644 --- a/components/sync_sessions/synced_session_tracker_unittest.cc +++ b/components/sync_sessions/synced_session_tracker_unittest.cc
@@ -95,9 +95,9 @@ // Now traverse the SyncedSession tree to verify the mapped tabs all match // up. int mapped_tab_count = 0; - for (auto& window_pair : session->synced_session.windows) { - mapped_tab_count += window_pair.second->wrapped_window.tabs.size(); - for (auto& tab : window_pair.second->wrapped_window.tabs) { + for (auto& [window_id, window] : session->synced_session.windows) { + mapped_tab_count += window->wrapped_window.tabs.size(); + for (auto& tab : window->wrapped_window.tabs) { const auto tab_map_it = session->synced_tab_map.find(tab->tab_id); if (tab_map_it == session->synced_tab_map.end()) { return AssertionFailure() << "Tab ID " << tab->tab_id.id() @@ -113,21 +113,19 @@ // Wrap up by verifying all unmapped tabs are tracked. int unmapped_tab_count = session->unmapped_tabs.size(); - for (const auto& tab_pair : session->unmapped_tabs) { - if (tab_pair.first != tab_pair.second->tab_id) { - return AssertionFailure() - << "Unmapped tab " << tab_pair.second->tab_id.id() - << " associated with wrong tab " << tab_pair.first; + for (const auto& [id, tab] : session->unmapped_tabs) { + if (id != tab->tab_id) { + return AssertionFailure() << "Unmapped tab " << tab->tab_id.id() + << " associated with wrong tab " << id; } - const auto tab_map_it = - session->synced_tab_map.find(tab_pair.second->tab_id); + const auto tab_map_it = session->synced_tab_map.find(tab->tab_id); if (tab_map_it == session->synced_tab_map.end()) { - return AssertionFailure() << "Unmapped tab " << tab_pair.second->tab_id + return AssertionFailure() << "Unmapped tab " << tab->tab_id << " has no corresponding synced tab entry"; } - if (tab_map_it->second != tab_pair.second.get()) { + if (tab_map_it->second != tab.get()) { return AssertionFailure() - << "Unmapped tab " << tab_pair.second->tab_id.id() + << "Unmapped tab " << tab->tab_id.id() << " does not match synced tab map " << tab_map_it->second; } }
diff --git a/components/sync_sessions/test_matchers.cc b/components/sync_sessions/test_matchers.cc index cfcdcbc..0fba3eb 100644 --- a/components/sync_sessions/test_matchers.cc +++ b/components/sync_sessions/test_matchers.cc
@@ -164,15 +164,14 @@ } std::map<int, std::vector<int>> actual_window_id_to_tabs; - for (const auto& id_and_window : actual->windows) { - const SessionID actual_window_id = id_and_window.first; - if (actual_window_id != id_and_window.second->wrapped_window.window_id) { + for (const auto& [actual_window_id, actual_window] : actual->windows) { + if (actual_window_id != actual_window->wrapped_window.window_id) { *listener << " which has an inconsistent window representation"; return false; } actual_window_id_to_tabs.emplace(actual_window_id.id(), std::vector<int>()); - for (const auto& tab : id_and_window.second->wrapped_window.tabs) { + for (const auto& tab : actual_window->wrapped_window.tabs) { actual_window_id_to_tabs[actual_window_id.id()].push_back( tab->tab_id.id()); }
diff --git a/components/sync_sessions/test_synced_window_delegates_getter.cc b/components/sync_sessions/test_synced_window_delegates_getter.cc index 7999045..dc7d3dd 100644 --- a/components/sync_sessions/test_synced_window_delegates_getter.cc +++ b/components/sync_sessions/test_synced_window_delegates_getter.cc
@@ -427,10 +427,10 @@ } const SyncedWindowDelegate* TestSyncedWindowDelegatesGetter::FindById( - SessionID id) { - for (auto window_iter_pair : delegates_) { - if (window_iter_pair.second->GetSessionId() == id) - return window_iter_pair.second; + SessionID session_id) { + for (const auto& [window_id, delegate] : delegates_) { + if (delegate->GetSessionId() == session_id) + return delegate; } return nullptr; }
diff --git a/components/sync_sessions/test_synced_window_delegates_getter.h b/components/sync_sessions/test_synced_window_delegates_getter.h index 62dddb3..269693f 100644 --- a/components/sync_sessions/test_synced_window_delegates_getter.h +++ b/components/sync_sessions/test_synced_window_delegates_getter.h
@@ -191,7 +191,7 @@ // SyncedWindowDelegatesGetter overrides. SyncedWindowDelegateMap GetSyncedWindowDelegates() override; - const SyncedWindowDelegate* FindById(SessionID id) override; + const SyncedWindowDelegate* FindById(SessionID session_id) override; private: class DummyRouter : public LocalSessionEventRouter {
diff --git a/components/sync_user_events/user_event_sync_bridge_unittest.cc b/components/sync_user_events/user_event_sync_bridge_unittest.cc index 526e0bf..80db5342 100644 --- a/components/sync_user_events/user_event_sync_bridge_unittest.cc +++ b/components/sync_user_events/user_event_sync_bridge_unittest.cc
@@ -152,8 +152,8 @@ std::map<std::string, sync_pb::EntitySpecifics> storage_key_to_specifics; if (batch != nullptr) { while (batch->HasNext()) { - const syncer::KeyAndData& pair = batch->Next(); - storage_key_to_specifics[pair.first] = pair.second->specifics; + const auto& [key, data] = batch->Next(); + storage_key_to_specifics[key] = data->specifics; } } return storage_key_to_specifics; @@ -177,9 +177,8 @@ std::unique_ptr<sync_pb::EntitySpecifics> specifics; if (batch != nullptr && batch->HasNext()) { - const syncer::KeyAndData& pair = batch->Next(); - specifics = - std::make_unique<sync_pb::EntitySpecifics>(pair.second->specifics); + const auto& [key, data] = batch->Next(); + specifics = std::make_unique<sync_pb::EntitySpecifics>(data->specifics); EXPECT_FALSE(batch->HasNext()); } return specifics;
diff --git a/components/test/data/payments/contact_details.js b/components/test/data/payments/contact_details.js index 089efb59..107d3c4 100644 --- a/components/test/data/payments/contact_details.js +++ b/components/test/data/payments/contact_details.js
@@ -10,15 +10,24 @@ * Launches the PaymentRequest UI that requests contact details. */ function buy() { // eslint-disable-line no-unused-vars + buyWithMethods([ + {supportedMethods: 'https://bobpay.com'}, + { + supportedMethods: 'basic-card', + data: {supportedNetworks: ['amex', 'visa']}, + }, + ]); +} + +/** + * Launches the PaymentRequest UI that requests contact details. + * @param {sequence<PaymentMethodData>} methodData An array of payment method + * objects. + */ +function buyWithMethods(methodData) { try { new PaymentRequest( - [ - {supportedMethods: 'https://bobpay.com'}, - { - supportedMethods: 'basic-card', - data: {supportedNetworks: ['amex', 'visa']}, - }, - ], + methodData, {total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}}, { requestPayerName: true, requestPayerEmail: true,
diff --git a/components/test/data/payments/free_shipping.js b/components/test/data/payments/free_shipping.js index d604f99..ac43f5e 100644 --- a/components/test/data/payments/free_shipping.js +++ b/components/test/data/payments/free_shipping.js
@@ -9,8 +9,33 @@ /** * Launches the PaymentRequest UI that offers free shipping worldwide. + * + * Legacy entry function until basic-card is removed. */ function buy() { // eslint-disable-line no-unused-vars + buyWithMethods([{ + supportedMethods: 'basic-card', + data: { + supportedNetworks: [ + 'visa', + 'unionpay', + 'mir', + 'mastercard', + 'jcb', + 'discover', + 'diners', + 'amex', + ], + }, + }]); +} + +/** + * Launches the PaymentRequest UI that offers free shipping worldwide. + * @param {sequence<PaymentMethodData>} methodData An array of payment method + * objects. + */ +function buyWithMethods(methodData) { try { var details = { total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}, @@ -22,21 +47,7 @@ }], }; var request = new PaymentRequest( - [{ - supportedMethods: 'basic-card', - data: { - supportedNetworks: [ - 'visa', - 'unionpay', - 'mir', - 'mastercard', - 'jcb', - 'discover', - 'diners', - 'amex', - ], - }, - }], + methodData, details, {requestShipping: true}); request.addEventListener('shippingaddresschange', function(e) { e.updateWith(new Promise(function(resolve) {
diff --git a/components/test/data/payments/multiple_show.js b/components/test/data/payments/multiple_show.js index 030a9f4f..9c36b23 100644 --- a/components/test/data/payments/multiple_show.js +++ b/components/test/data/payments/multiple_show.js
@@ -13,15 +13,24 @@ * Show a Payment Request. */ function buy() { // eslint-disable-line no-unused-vars + buyWithMethods([ + {supportedMethods: 'https://bobpay.com'}, + { + supportedMethods: 'basic-card', + data: {supportedNetworks: ['visa']}, + }, + ]); +} + +/** + * Show a Payment Request with given methods. + * @param {sequence<PaymentMethodData>} methodData An array of payment method + * objects. + */ +function buyWithMethods(methodData) { try { request = new PaymentRequest( - [ - {supportedMethods: 'https://bobpay.com'}, - { - supportedMethods: 'basic-card', - data: {supportedNetworks: ['visa']}, - }, - ], + methodData, {total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}}); request.show() .then(function(resp) { @@ -68,15 +77,24 @@ * Show a second Payment Request. */ function showSecondRequest() { // eslint-disable-line no-unused-vars + showSecondRequestWithMethods([ + {supportedMethods: 'https://bobpay.com'}, + { + supportedMethods: 'basic-card', + data: {supportedNetworks: ['visa']}, + }, + ]); +} + +/** + * Show a second Payment Request with given methods. + * @param {sequence<PaymentMethodData>} methodData An array of payment method + * objects. + */ +function showSecondRequestWithMethods(methodData) { try { request2 = new PaymentRequest( - [ - {supportedMethods: 'https://bobpay.com'}, - { - supportedMethods: 'basic-card', - data: {supportedNetworks: ['visa']}, - }, - ], + methodData, {total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}}); request2.show() .then(function(resp) {
diff --git a/components/test/data/payments/name.js b/components/test/data/payments/name.js index ae5b21c..5419b9e 100644 --- a/components/test/data/payments/name.js +++ b/components/test/data/payments/name.js
@@ -8,11 +8,24 @@ /** * Launches the PaymentRequest UI that requests payer name. + * + * Legacy entry function until basic-card is removed. */ function buy() { // eslint-disable-line no-unused-vars + buyWithMethods( + [{supportedMethods: 'basic-card', data: {supportedNetworks: ['visa']}}]); +} + +/** + * Launches the PaymentRequest UI that offers free shipping worldwide. + * + * @param {sequence<PaymentMethodData>} methodData - An array of payment method + * objects. + */ +function buyWithMethods(methodData) { try { new PaymentRequest( - [{supportedMethods: 'basic-card', data: {supportedNetworks: ['visa']}}], + methodData, {total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}}, {requestPayerName: true}) .show()
diff --git a/components/test/data/payments/no_update_with.js b/components/test/data/payments/no_update_with.js index f2c3539..617752f 100644 --- a/components/test/data/payments/no_update_with.js +++ b/components/test/data/payments/no_update_with.js
@@ -6,12 +6,14 @@ /** * Builds a PaymentRequest that requests a shipping address. + * @param {sequence<PaymentMethodData>} methodData An array of payment method + * objects. * @return {PaymentRequest} - A new PaymentRequest object. */ -function buildPaymentRequest() { +function buildPaymentRequest(methodData) { try { return new PaymentRequest( - [{supportedMethods: 'basic-card'}], { + methodData, { total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}, shippingOptions: [{ selected: true, @@ -47,18 +49,39 @@ } /** - * Show a PaymentRequest that requests a shipping address, but has no listeners. + * Show a basic-card PaymentRequest that requests a shipping address, but has no + * listeners. */ function buyWithoutListeners() { // eslint-disable-line no-unused-vars - showPaymentRequest(buildPaymentRequest()); + buyWithoutListenersWithMethods([{supportedMethods: 'basic-card'}]); } /** - * Show a PaymentRequest that requests a shipping address, but listeners don't - * call updateWith(). + * Show a PaymentRequest using methodData that requests a shipping address, but + * has no listeners. + * @param {sequence<PaymentMethodData>} methodData An array of payment method + * objects. + */ + function buyWithoutListenersWithMethods(methodData) { + showPaymentRequest(buildPaymentRequest(methodData)); +} + +/** + * Show a basic-card PaymentRequest that requests a shipping address, but + * listeners don't call updateWith(). */ function buyWithoutCallingUpdateWith() { // eslint-disable-line no-unused-vars - const pr = buildPaymentRequest(); + buyWithoutCallingUpdateWithWithMethods([{supportedMethods: 'basic-card'}]); +} + +/** + * Show a PaymentRequest using methodData that requests a shipping address, but + * listeners don't call updateWith(). + * @param {sequence<PaymentMethodData>} methodData An array of payment method + * objects. + */ + function buyWithoutCallingUpdateWithWithMethods(methodData) { + const pr = buildPaymentRequest(methodData); pr.addEventListener('shippingaddresschange', function(evt) { print('shippingaddresschange'); }); @@ -69,11 +92,21 @@ } /** - * Show a PaymentRequest that requests a shipping address, but listeners don't - * use promises to update the UI. + * Show a basic-card PaymentRequest that requests a shipping address, but + * listeners don't use promises to update the UI. */ function buyWithoutPromises() { // eslint-disable-line no-unused-vars - const pr = buildPaymentRequest(); + buyWithoutPromisesWithMethods([{supportedMethods: 'basic-card'}]); +} + +/** + * Show a PaymentRequest using methodData that requests a shipping address, but + * listeners don't use promises to update the UI. + * @param {sequence<PaymentMethodData>} methodData An array of payment method + * objects. + */ + function buyWithoutPromisesWithMethods(methodData) { + const pr = buildPaymentRequest(methodData); const updatedDetails = { total: {label: 'Updated total', amount: {currency: 'USD', value: '10.00'}}, shippingOptions: [{
diff --git a/components/translate/core/browser/translate_infobar_delegate_unittest.cc b/components/translate/core/browser/translate_infobar_delegate_unittest.cc index cdfe2be7..fe5f33e 100644 --- a/components/translate/core/browser/translate_infobar_delegate_unittest.cc +++ b/components/translate/core/browser/translate_infobar_delegate_unittest.cc
@@ -197,8 +197,8 @@ testing::accept_languages_prefs); ON_CALL(*(client_.get()), GetTranslateAcceptLanguages()) .WillByDefault(Return(&accept_languages)); - ListPrefUpdateDeprecated update(pref_service_.get(), - translate::prefs::kBlockedLanguages); + ListPrefUpdate update(pref_service_.get(), + translate::prefs::kBlockedLanguages); update->Append(kSourceLanguage); pref_service_->SetString(language::prefs::kAcceptLanguages, kSourceLanguage); #if BUILDFLAG(IS_CHROMEOS_ASH) @@ -214,7 +214,7 @@ } TEST_F(TranslateInfoBarDelegateTest, ShouldAutoAlwaysTranslate) { - DictionaryPrefUpdateDeprecated update_translate_accepted_count( + DictionaryPrefUpdate update_translate_accepted_count( pref_service_.get(), TranslatePrefs::kPrefTranslateAcceptedCount); base::Value* update_translate_accepted_dict = update_translate_accepted_count.Get(); @@ -248,7 +248,7 @@ } TEST_F(TranslateInfoBarDelegateTest, ShouldNotAutoAlwaysTranslateUnknown) { - DictionaryPrefUpdateDeprecated update_translate_accepted_count( + DictionaryPrefUpdate update_translate_accepted_count( pref_service_.get(), TranslatePrefs::kPrefTranslateAcceptedCount); base::Value* update_translate_accepted_dict = update_translate_accepted_count.Get(); @@ -304,7 +304,7 @@ ON_CALL(*(client_.get()), GetTranslateAcceptLanguages()) .WillByDefault(Return(&accept_languages)); - DictionaryPrefUpdateDeprecated update_translate_denied_count( + DictionaryPrefUpdate update_translate_denied_count( pref_service_.get(), TranslatePrefs::kPrefTranslateDeniedCount); base::Value* update_translate_denied_dict = update_translate_denied_count.Get();
diff --git a/components/translate/core/browser/translate_prefs.cc b/components/translate/core/browser/translate_prefs.cc index 251f0d2..6fd454e 100644 --- a/components/translate/core/browser/translate_prefs.cc +++ b/components/translate/core/browser/translate_prefs.cc
@@ -244,8 +244,7 @@ if (!IsBlockedLanguage(input_language)) { std::string canonical_lang(input_language); language::ToTranslateLanguageSynonym(&canonical_lang); - ListPrefUpdateDeprecated update(prefs_, - translate::prefs::kBlockedLanguages); + ListPrefUpdate update(prefs_, translate::prefs::kBlockedLanguages); update->Append(std::move(canonical_lang)); } // Remove the blocked language from the always translate list if present. @@ -260,7 +259,7 @@ } std::string canonical_lang(input_language); language::ToTranslateLanguageSynonym(&canonical_lang); - ListPrefUpdateDeprecated update(prefs_, translate::prefs::kBlockedLanguages); + ListPrefUpdate update(prefs_, translate::prefs::kBlockedLanguages); update->EraseListValue(base::Value(std::move(canonical_lang))); } @@ -558,14 +557,14 @@ void TranslatePrefs::AddSiteToNeverPromptList(base::StringPiece site) { DCHECK(!site.empty()); AddValueToNeverPromptList(kPrefNeverPromptSitesDeprecated, site); - DictionaryPrefUpdateDeprecated update(prefs_, kPrefNeverPromptSitesWithTime); + DictionaryPrefUpdate update(prefs_, kPrefNeverPromptSitesWithTime); update.Get()->SetKey(site, base::TimeToValue(base::Time::Now())); } void TranslatePrefs::RemoveSiteFromNeverPromptList(base::StringPiece site) { DCHECK(!site.empty()); RemoveValueFromNeverPromptList(kPrefNeverPromptSitesDeprecated, site); - DictionaryPrefUpdateDeprecated update(prefs_, kPrefNeverPromptSitesWithTime); + DictionaryPrefUpdate update(prefs_, kPrefNeverPromptSitesWithTime); update.Get()->RemoveKey(site); } @@ -608,8 +607,7 @@ void TranslatePrefs::AddLanguagePairToAlwaysTranslateList( base::StringPiece source_language, base::StringPiece target_language) { - DictionaryPrefUpdateDeprecated update(prefs_, - prefs::kPrefAlwaysTranslateList); + DictionaryPrefUpdate update(prefs_, prefs::kPrefAlwaysTranslateList); DCHECK(update.Get()) << "Always translated pref is unregistered"; // Get translate version of language codes. @@ -627,8 +625,7 @@ void TranslatePrefs::RemoveLanguagePairFromAlwaysTranslateList( base::StringPiece source_language, base::StringPiece target_language) { - DictionaryPrefUpdateDeprecated update(prefs_, - prefs::kPrefAlwaysTranslateList); + DictionaryPrefUpdate update(prefs_, prefs::kPrefAlwaysTranslateList); DCHECK(update.Get()) << "Always translate pref is unregistered"; // Get translate version of language codes. @@ -684,7 +681,7 @@ void TranslatePrefs::IncrementTranslationDeniedCount( base::StringPiece language) { - DictionaryPrefUpdateDeprecated update(prefs_, kPrefTranslateDeniedCount); + DictionaryPrefUpdate update(prefs_, kPrefTranslateDeniedCount); base::Value* dict = update.Get(); int count = dict->FindIntKey(language).value_or(0); @@ -693,7 +690,7 @@ } void TranslatePrefs::ResetTranslationDeniedCount(base::StringPiece language) { - DictionaryPrefUpdateDeprecated update(prefs_, kPrefTranslateDeniedCount); + DictionaryPrefUpdate update(prefs_, kPrefTranslateDeniedCount); update.Get()->SetIntKey(language, 0); } @@ -705,7 +702,7 @@ void TranslatePrefs::IncrementTranslationIgnoredCount( base::StringPiece language) { - DictionaryPrefUpdateDeprecated update(prefs_, kPrefTranslateIgnoredCount); + DictionaryPrefUpdate update(prefs_, kPrefTranslateIgnoredCount); base::Value* dict = update.Get(); int count = dict->FindIntKey(language).value_or(0); @@ -714,7 +711,7 @@ } void TranslatePrefs::ResetTranslationIgnoredCount(base::StringPiece language) { - DictionaryPrefUpdateDeprecated update(prefs_, kPrefTranslateIgnoredCount); + DictionaryPrefUpdate update(prefs_, kPrefTranslateIgnoredCount); update.Get()->SetIntKey(language, 0); } @@ -726,7 +723,7 @@ void TranslatePrefs::IncrementTranslationAcceptedCount( base::StringPiece language) { - DictionaryPrefUpdateDeprecated update(prefs_, kPrefTranslateAcceptedCount); + DictionaryPrefUpdate update(prefs_, kPrefTranslateAcceptedCount); base::Value* dict = update.Get(); int count = dict->FindIntKey(language).value_or(0); @@ -735,7 +732,7 @@ } void TranslatePrefs::ResetTranslationAcceptedCount(base::StringPiece language) { - DictionaryPrefUpdateDeprecated update(prefs_, kPrefTranslateAcceptedCount); + DictionaryPrefUpdate update(prefs_, kPrefTranslateAcceptedCount); update.Get()->SetIntKey(language, 0); } @@ -749,7 +746,7 @@ void TranslatePrefs::IncrementTranslationAutoAlwaysCount( base::StringPiece language) { - DictionaryPrefUpdateDeprecated update(prefs_, kPrefTranslateAutoAlwaysCount); + DictionaryPrefUpdate update(prefs_, kPrefTranslateAutoAlwaysCount); base::Value* dict = update.Get(); int count = dict->FindIntKey(language).value_or(0); @@ -759,7 +756,7 @@ void TranslatePrefs::ResetTranslationAutoAlwaysCount( base::StringPiece language) { - DictionaryPrefUpdateDeprecated update(prefs_, kPrefTranslateAutoAlwaysCount); + DictionaryPrefUpdate update(prefs_, kPrefTranslateAutoAlwaysCount); update.Get()->SetIntKey(language, 0); } @@ -771,7 +768,7 @@ void TranslatePrefs::IncrementTranslationAutoNeverCount( base::StringPiece language) { - DictionaryPrefUpdateDeprecated update(prefs_, kPrefTranslateAutoNeverCount); + DictionaryPrefUpdate update(prefs_, kPrefTranslateAutoNeverCount); base::Value* dict = update.Get(); int count = dict->FindIntKey(language).value_or(0); @@ -781,7 +778,7 @@ void TranslatePrefs::ResetTranslationAutoNeverCount( base::StringPiece language) { - DictionaryPrefUpdateDeprecated update(prefs_, kPrefTranslateAutoNeverCount); + DictionaryPrefUpdate update(prefs_, kPrefTranslateAutoNeverCount); update.Get()->SetIntKey(language, 0); } #endif // defined(OS_ANDROID) || defined(OS_IOS) @@ -958,11 +955,11 @@ // Migration copies any sites on the deprecated never prompt pref to // the new version and clears all references to the old one. This will // make subsequent calls to migrate no-ops. - DictionaryPrefUpdateDeprecated never_prompt_list_update( - prefs_, kPrefNeverPromptSitesWithTime); + DictionaryPrefUpdate never_prompt_list_update(prefs_, + kPrefNeverPromptSitesWithTime); base::Value* never_prompt_list = never_prompt_list_update.Get(); if (never_prompt_list) { - ListPrefUpdateDeprecated deprecated_prompt_list_update( + ListPrefUpdate deprecated_prompt_list_update( prefs_, kPrefNeverPromptSitesDeprecated); base::Value* deprecated_list = deprecated_prompt_list_update.Get(); for (auto& site : deprecated_list->GetList()) { @@ -1006,7 +1003,7 @@ void TranslatePrefs::AddValueToNeverPromptList(const char* pref_id, base::StringPiece value) { - ListPrefUpdateDeprecated update(prefs_, pref_id); + ListPrefUpdate update(prefs_, pref_id); base::Value* never_prompt_list = update.Get(); if (!never_prompt_list) { NOTREACHED() << "Unregistered never-translate pref"; @@ -1021,7 +1018,7 @@ void TranslatePrefs::RemoveValueFromNeverPromptList(const char* pref_id, base::StringPiece value) { - ListPrefUpdateDeprecated update(prefs_, pref_id); + ListPrefUpdate update(prefs_, pref_id); base::Value* never_prompt_list = update.Get(); if (!never_prompt_list) { NOTREACHED() << "Unregistered never-translate pref";
diff --git a/components/translate/core/browser/translate_prefs_unittest.cc b/components/translate/core/browser/translate_prefs_unittest.cc index 12df712..8600c7b 100644 --- a/components/translate/core/browser/translate_prefs_unittest.cc +++ b/components/translate/core/browser/translate_prefs_unittest.cc
@@ -944,7 +944,7 @@ .size(), 2u); // Also put one of those sites on the new pref but migrated incorrectly. - DictionaryPrefUpdateDeprecated never_prompt_list_update( + DictionaryPrefUpdate never_prompt_list_update( &prefs_, TranslatePrefs::kPrefNeverPromptSitesWithTime); base::Value* never_prompt_list = never_prompt_list_update.Get(); never_prompt_list->SetKey("migratedWrong.com", base::Value(0));
diff --git a/components/url_formatter/url_formatter.cc b/components/url_formatter/url_formatter.cc index efc24b7..07aeee3 100644 --- a/components/url_formatter/url_formatter.cc +++ b/components/url_formatter/url_formatter.cc
@@ -24,6 +24,8 @@ #include "third_party/icu/source/common/unicode/utypes.h" #include "url/gurl.h" #include "url/third_party/mozilla/url_parse.h" +#include "url/url_constants.h" +#include "url/url_util.h" namespace url_formatter { @@ -464,6 +466,29 @@ return result; } +// Returns true iff URL-parsing `spec` would reveal that it has the +// "view-source" scheme, and that parsing the spec minus that scheme also has +// the "view-source" scheme. +bool HasTwoViewSourceSchemes(base::StringPiece spec) { + static constexpr char kViewSource[] = "view-source"; + url::Component scheme; + if (!url::FindAndCompareScheme(spec.data(), + base::checked_cast<int>(spec.size()), + kViewSource, &scheme)) { + return false; + } + // Consume the scheme. + spec.remove_prefix(scheme.begin + scheme.len); + // Consume the trailing colon. If it's not there, then `spec` didn't really + // have the first view-source scheme. + if (spec.empty() || spec[0] != ':') + return false; + spec.remove_prefix(1); + + return url::FindAndCompareScheme( + spec.data(), base::checked_cast<int>(spec.size()), kViewSource, &scheme); +} + } // namespace const FormatUrlType kFormatUrlOmitNothing = 0; @@ -526,16 +551,14 @@ else *new_parsed = url::Parsed(); - // Special handling for view-source:. Don't use content::kViewSourceScheme - // because this library shouldn't depend on chrome. - const char kViewSource[] = "view-source"; - // Reject "view-source:view-source:..." to avoid deep recursion. - const char kViewSourceTwice[] = "view-source:view-source:"; + // Special handling for view-source:. Don't use content::kViewSourceScheme + // because this library shouldn't depend on chrome. Reject repeated + // view-source schemes to avoid recursion. + static constexpr base::StringPiece kViewSource = "view-source"; if (url.SchemeIs(kViewSource) && - !base::StartsWith(url.possibly_invalid_spec(), kViewSourceTwice, - base::CompareCase::INSENSITIVE_ASCII)) { - return FormatViewSourceUrl(url, format_types, unescape_rules, - new_parsed, prefix_end, adjustments); + !HasTwoViewSourceSchemes(url.possibly_invalid_spec())) { + return FormatViewSourceUrl(url, format_types, unescape_rules, new_parsed, + prefix_end, adjustments); } // We handle both valid and invalid URLs (this will give us the spec
diff --git a/components/url_formatter/url_formatter_unittest.cc b/components/url_formatter/url_formatter_unittest.cc index f4ce967d..57b0263 100644 --- a/components/url_formatter/url_formatter_unittest.cc +++ b/components/url_formatter/url_formatter_unittest.cc
@@ -476,6 +476,26 @@ EXPECT_EQ(u"query", formatted.substr(parsed.query.begin, parsed.query.len)); EXPECT_EQ(u"ref", formatted.substr(parsed.ref.begin, parsed.ref.len)); + // Repeated view-source separated by a space. + formatted = FormatUrl( + GURL( + "view-source: view-source:http://user:passwd@host:81/path?query#ref"), + kFormatUrlOmitUsernamePassword, net::UnescapeRule::NORMAL, &parsed, + nullptr, nullptr); + EXPECT_EQ( + u"view-source: view-source:http://user:passwd@host:81/path?query#ref", + formatted); + EXPECT_EQ(u"view-source", + formatted.substr(parsed.scheme.begin, parsed.scheme.len)); + EXPECT_FALSE(parsed.username.is_valid()); + EXPECT_FALSE(parsed.password.is_valid()); + EXPECT_FALSE(parsed.host.is_valid()); + EXPECT_FALSE(parsed.port.is_valid()); + EXPECT_EQ(u" view-source:http://user:passwd@host:81/path", + formatted.substr(parsed.path.begin, parsed.path.len)); + EXPECT_EQ(u"query", formatted.substr(parsed.query.begin, parsed.query.len)); + EXPECT_EQ(u"ref", formatted.substr(parsed.ref.begin, parsed.ref.len)); + // omit http case. formatted = FormatUrl(GURL("http://host:8000/a?b=c#d"), kFormatUrlOmitHTTP, net::UnescapeRule::NORMAL, &parsed, nullptr, nullptr);
diff --git a/components/viz/service/gl/gpu_service_impl.cc b/components/viz/service/gl/gpu_service_impl.cc index a31ab007..02f3331f 100644 --- a/components/viz/service/gl/gpu_service_impl.cc +++ b/components/viz/service/gl/gpu_service_impl.cc
@@ -392,7 +392,6 @@ (is_native_vulkan && is_native_gl) ? &gpu_info : nullptr); if (vulkan_context_provider_) { // If Vulkan is supported, then OOP-R is supported. - gpu_info_.oop_rasterization_supported = true; gpu_feature_info_.status_values[gpu::GPU_FEATURE_TYPE_OOP_RASTERIZATION] = gpu::kGpuFeatureStatusEnabled; } else { @@ -405,7 +404,6 @@ if (gpu_preferences_.gr_context_type == gpu::GrContextType::kDawn) { dawn_context_provider_ = DawnContextProvider::Create(); if (dawn_context_provider_) { - gpu_info_.oop_rasterization_supported = true; gpu_feature_info_.status_values[gpu::GPU_FEATURE_TYPE_OOP_RASTERIZATION] = gpu::kGpuFeatureStatusEnabled; } else {
diff --git a/content/browser/accessibility/browser_accessibility.cc b/content/browser/accessibility/browser_accessibility.cc index f0896a77..65959ce 100644 --- a/content/browser/accessibility/browser_accessibility.cc +++ b/content/browser/accessibility/browser_accessibility.cc
@@ -1307,6 +1307,10 @@ return node_->GetStringListAttribute(attribute, value); } +bool BrowserAccessibility::HasHtmlAttribute(const char* attribute) const { + return node_->HasHtmlAttribute(attribute); +} + const BrowserAccessibility::HtmlAttributes& BrowserAccessibility::GetHtmlAttributes() const { return node()->GetHtmlAttributes();
diff --git a/content/browser/accessibility/browser_accessibility.h b/content/browser/accessibility/browser_accessibility.h index 2974b1f..d4c7c37 100644 --- a/content/browser/accessibility/browser_accessibility.h +++ b/content/browser/accessibility/browser_accessibility.h
@@ -430,6 +430,7 @@ bool GetStringListAttribute(ax::mojom::StringListAttribute attribute, std::vector<std::string>* value) const override; typedef base::StringPairs HtmlAttributes; + bool HasHtmlAttribute(const char* attribute) const override; const HtmlAttributes& GetHtmlAttributes() const override; bool GetHtmlAttribute(const char* attribute, std::string* value) const override;
diff --git a/content/browser/accessibility/browser_accessibility_cocoa.h b/content/browser/accessibility/browser_accessibility_cocoa.h index 8a28477..e0d7e51 100644 --- a/content/browser/accessibility/browser_accessibility_cocoa.h +++ b/content/browser/accessibility/browser_accessibility_cocoa.h
@@ -128,7 +128,6 @@ @property(nonatomic, readonly) id disclosedByRow; @property(nonatomic, readonly) NSNumber* disclosureLevel; @property(nonatomic, readonly) id disclosedRows; -@property(nonatomic, readonly) NSString* dropEffects; // Returns the object at the root of the current edit field, if any. @property(nonatomic, readonly) id editableAncestor; @property(nonatomic, readonly) NSNumber* enabled;
diff --git a/content/browser/accessibility/browser_accessibility_cocoa.mm b/content/browser/accessibility/browser_accessibility_cocoa.mm index 8e61e3d..bd21305 100644 --- a/content/browser/accessibility/browser_accessibility_cocoa.mm +++ b/content/browser/accessibility/browser_accessibility_cocoa.mm
@@ -66,7 +66,6 @@ namespace { // Private WebKit accessibility attributes. -NSString* const NSAccessibilityDropEffectsAttribute = @"AXDropEffects"; NSString* const NSAccessibilityEditableAncestorAttribute = @"AXEditableAncestor"; NSString* const NSAccessibilityElementBusyAttribute = @"AXElementBusy"; @@ -698,7 +697,6 @@ {NSAccessibilityDisclosedByRowAttribute, @"disclosedByRow"}, {NSAccessibilityDisclosureLevelAttribute, @"disclosureLevel"}, {NSAccessibilityDisclosedRowsAttribute, @"disclosedRows"}, - {NSAccessibilityDropEffectsAttribute, @"dropEffects"}, {NSAccessibilityEditableAncestorAttribute, @"editableAncestor"}, {NSAccessibilityElementBusyAttribute, @"elementBusy"}, {NSAccessibilityEnabledAttribute, @"enabled"}, @@ -1009,17 +1007,6 @@ return nil; } -- (NSString*)dropEffects { - if (![self instanceActive]) - return nil; - - std::string dropEffects; - if (_owner->GetHtmlAttribute("aria-dropeffect", &dropEffects)) - return base::SysUTF8ToNSString(dropEffects); - - return nil; -} - - (id)editableAncestor { if (![self instanceActive]) return nil; @@ -3036,10 +3023,6 @@ ]]; } - std::string dropEffect; - if (_owner->GetHtmlAttribute("aria-dropeffect", &dropEffect)) - [ret addObject:NSAccessibilityDropEffectsAttribute]; - std::string grabbed; if (_owner->GetHtmlAttribute("aria-grabbed", &grabbed)) [ret addObject:NSAccessibilityGrabbedAttribute];
diff --git a/content/browser/accessibility/dump_accessibility_scripts_browsertest.cc b/content/browser/accessibility/dump_accessibility_scripts_browsertest.cc index ee71b15..33ea82d3 100644 --- a/content/browser/accessibility/dump_accessibility_scripts_browsertest.cc +++ b/content/browser/accessibility/dump_accessibility_scripts_browsertest.cc
@@ -217,6 +217,10 @@ RunTypedTest<kMacAttributes>("ax-has-popup.html"); } +IN_PROC_BROWSER_TEST_P(DumpAccessibilityScriptTest, AXDropEffects) { + RunTypedTest<kMacAttributes>("ax-drop-effects.html"); +} + IN_PROC_BROWSER_TEST_P(DumpAccessibilityScriptTest, AXInvalid) { RunTypedTest<kMacAttributes>("ax-invalid.html"); }
diff --git a/content/browser/android/dialog_overlay_impl.cc b/content/browser/android/dialog_overlay_impl.cc index ebcf00c..cc95bd5 100644 --- a/content/browser/android/dialog_overlay_impl.cc +++ b/content/browser/android/dialog_overlay_impl.cc
@@ -39,6 +39,12 @@ if (!rfhi) return 0; + // If the RenderFrameHost does not have a live RenderFrame, immediately bail + // out: not only is there nothing to do, the `RenderFrameDeleted()` + // notification to clean up the overlay would never be called. + if (!rfhi->IsRenderFrameLive()) + return 0; + // TODO(http://crbug.com/673886): Support overlay surfaces in VR using GVR // reprojection video surface. RenderWidgetHostViewBase* rwhvb = @@ -93,7 +99,7 @@ // Make sure RenderFrameDeleted will be called on RFH and thus we will clean // up. - DCHECK(rfhi_->IsRenderFrameCreated()); + CHECK(rfhi_->IsRenderFrameCreated()); web_contents->GetNativeView()->AddObserver(this); // Note that we're not allowed to call back into |obj| before it calls
diff --git a/content/browser/back_forward_cache_internal_browsertest.cc b/content/browser/back_forward_cache_internal_browsertest.cc index 7c4ed1d..060b865b 100644 --- a/content/browser/back_forward_cache_internal_browsertest.cc +++ b/content/browser/back_forward_cache_internal_browsertest.cc
@@ -248,7 +248,7 @@ } IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, - NavigationsAreFullyCommitted) { + DISABLED_NavigationsAreFullyCommitted) { ASSERT_TRUE(embedded_test_server()->Start()); // During a navigation, the document being navigated *away from* can either be
diff --git a/content/browser/fenced_frame/fenced_frame.cc b/content/browser/fenced_frame/fenced_frame.cc index ce120e01..92a3b7ed 100644 --- a/content/browser/fenced_frame/fenced_frame.cc +++ b/content/browser/fenced_frame/fenced_frame.cc
@@ -14,11 +14,32 @@ namespace content { +namespace { + +FrameTreeNode* CreateDelegateFrameTreeNode( + RenderFrameHostImpl* owner_render_frame_host) { + return owner_render_frame_host->frame_tree()->AddFrame( + &*owner_render_frame_host, owner_render_frame_host->GetProcess()->GetID(), + owner_render_frame_host->GetProcess()->GetNextRoutingID(), + /*frame_remote=*/mojo::NullAssociatedRemote(), + /*browser_interface_broker_receiver=*/mojo::NullReceiver(), + /*policy_container_bind_params=*/nullptr, + blink::mojom::TreeScopeType::kDocument, "", "", true, + blink::LocalFrameToken(), base::UnguessableToken::Create(), + blink::FramePolicy(), blink::mojom::FrameOwnerProperties(), false, + blink::FrameOwnerElementType::kFencedframe, + /*is_dummy_frame_for_inner_tree=*/true); +} + +} // namespace + FencedFrame::FencedFrame( base::SafeRef<RenderFrameHostImpl> owner_render_frame_host) : web_contents_(static_cast<WebContentsImpl*>( WebContents::FromRenderFrameHost(&*owner_render_frame_host))), owner_render_frame_host_(owner_render_frame_host), + outer_delegate_frame_tree_node_( + CreateDelegateFrameTreeNode(&*owner_render_frame_host)), frame_tree_( std::make_unique<FrameTree>(web_contents_->GetBrowserContext(), /*delegate=*/this, @@ -112,23 +133,7 @@ } void FencedFrame::CreateProxyAndAttachToOuterFrameTree() { - // The fenced frame should not already be attached. - DCHECK(!outer_delegate_frame_tree_node_); - - outer_delegate_frame_tree_node_ = - owner_render_frame_host_->frame_tree()->AddFrame( - &*owner_render_frame_host_, - owner_render_frame_host_->GetProcess()->GetID(), - owner_render_frame_host_->GetProcess()->GetNextRoutingID(), - /*frame_remote=*/mojo::NullAssociatedRemote(), - /*browser_interface_broker_receiver=*/mojo::NullReceiver(), - /*policy_container_bind_params=*/nullptr, - blink::mojom::TreeScopeType::kDocument, "", "", true, - blink::LocalFrameToken(), base::UnguessableToken::Create(), - blink::FramePolicy(), blink::mojom::FrameOwnerProperties(), false, - blink::FrameOwnerElementType::kFencedframe, - /*is_dummy_frame_for_inner_tree=*/true); - + DCHECK(outer_delegate_frame_tree_node_); // Connect the outer delegate RenderFrameHost with the inner main // FrameTreeNode. This allows us to traverse from the outer delegate RFH // inward, to the inner fenced frame FrameTree.
diff --git a/content/browser/media/capture/desktop_capture_device.cc b/content/browser/media/capture/desktop_capture_device.cc index db52f1f..8dafb1b 100644 --- a/content/browser/media/capture/desktop_capture_device.cc +++ b/content/browser/media/capture/desktop_capture_device.cc
@@ -130,6 +130,8 @@ scoped_refptr<base::SingleThreadTaskRunner> task_runner, const base::TickClock* tick_clock); + base::WeakPtr<Core> GetWeakPtr() { return weak_factory_.GetWeakPtr(); } + private: // webrtc::DesktopCapturer::Callback interface. // A side-effect of this method is to schedule the next frame. @@ -589,9 +591,8 @@ const media::VideoCaptureParams& params, std::unique_ptr<Client> client) { thread_.task_runner()->PostTask( - FROM_HERE, - base::BindOnce(&Core::AllocateAndStart, base::Unretained(core_.get()), - params, std::move(client))); + FROM_HERE, base::BindOnce(&Core::AllocateAndStart, core_->GetWeakPtr(), + params, std::move(client))); } void DesktopCaptureDevice::StopAndDeAllocate() { @@ -611,7 +612,7 @@ return; thread_.task_runner()->PostTask( FROM_HERE, base::BindOnce(&Core::SetNotificationWindowId, - base::Unretained(core_.get()), window_id)); + core_->GetWeakPtr(), window_id)); } DesktopCaptureDevice::DesktopCaptureDevice(
diff --git a/content/browser/media/capture/desktop_capture_device.h b/content/browser/media/capture/desktop_capture_device.h index aa99181..98fafae 100644 --- a/content/browser/media/capture/desktop_capture_device.h +++ b/content/browser/media/capture/desktop_capture_device.h
@@ -68,8 +68,15 @@ scoped_refptr<base::SingleThreadTaskRunner> task_runner, const base::TickClock* tick_clock); - base::Thread thread_; std::unique_ptr<Core> core_; + + // Ensure that the thread is the first object destroyed, as that will ensure + // it is stopped. This helps to guarantee that the thread is stopped before + // any of our objects (which it may be depending on), are destroyed. While the + // thread *should* be stopped by consumers with StopAndDeAllocate, some edge + // cases may mean that there is either not a chance for it to be called, or it + // may have been called but not yet scheduled to run. + base::Thread thread_; }; } // namespace content
diff --git a/content/browser/media/media_web_contents_observer.cc b/content/browser/media/media_web_contents_observer.cc index fa9ca56..f14662a 100644 --- a/content/browser/media/media_web_contents_observer.cc +++ b/content/browser/media/media_web_contents_observer.cc
@@ -38,19 +38,6 @@ return metrics; } -static void OnAudioOutputDeviceIdTranslated( - base::WeakPtr<MediaWebContentsObserver> observer, - const MediaPlayerId& player_id, - const absl::optional<std::string>& raw_device_id) { - if (!raw_device_id) - return; - - content::GetUIThreadTaskRunner({})->PostTask( - FROM_HERE, - base::BindOnce(&MediaWebContentsObserver::OnReceivedTranslatedDeviceId, - std::move(observer), player_id, raw_device_id.value())); -} - } // anonymous namespace // Maintains state for a single player. Issues WebContents and power-related @@ -398,8 +385,41 @@ void MediaWebContentsObserver::MediaPlayerObserverHostImpl:: OnAudioOutputSinkChanged(const std::string& hashed_device_id) { - media_web_contents_observer_->OnAudioOutputSinkChanged(media_player_id_, - hashed_device_id); + auto* render_frame_host = + RenderFrameHost::FromID(media_player_id_.frame_routing_id); + DCHECK(render_frame_host); + + auto salt_and_origin = content::GetMediaDeviceSaltAndOrigin( + render_frame_host->GetProcess()->GetID(), + render_frame_host->GetRoutingID()); + + content::GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, + base::BindOnce( + // TODO(dcheng): GetMediaDeviceIDForHMAC should not be overloaded, + // which would avoid the need for static_casts / wrapper lambdas + // (which are not zero cost). + static_cast<void (*)( + blink::mojom::MediaDeviceType, std::string, url::Origin, + std::string, scoped_refptr<base::SequencedTaskRunner>, + base::OnceCallback<void(const absl::optional<std::string>&)>)>( + &MediaStreamManager::GetMediaDeviceIDForHMAC), + blink::mojom::MediaDeviceType::MEDIA_AUDIO_OUTPUT, + salt_and_origin.device_id_salt, std::move(salt_and_origin.origin), + hashed_device_id, content::GetUIThreadTaskRunner({}), + base::BindOnce( + &MediaPlayerObserverHostImpl::OnReceivedTranslatedDeviceId, + weak_factory_.GetWeakPtr()))); +} + +void MediaWebContentsObserver::MediaPlayerObserverHostImpl:: + OnReceivedTranslatedDeviceId( + const absl::optional<std::string>& translated_id) { + if (!translated_id) + return; + + media_web_contents_observer_->OnAudioOutputSinkChangedWithRawDeviceId( + media_player_id_, *translated_id); } void MediaWebContentsObserver::MediaPlayerObserverHostImpl:: @@ -530,36 +550,7 @@ has_played_before_ = true; } -void MediaWebContentsObserver::OnAudioOutputSinkChanged( - const MediaPlayerId& player_id, - std::string hashed_device_id) { - auto* render_frame_host = RenderFrameHost::FromID(player_id.frame_routing_id); - DCHECK(render_frame_host); - - auto salt_and_origin = content::GetMediaDeviceSaltAndOrigin( - render_frame_host->GetProcess()->GetID(), - render_frame_host->GetRoutingID()); - - auto callback_on_io_thread = base::BindOnce( - [](const std::string& salt, const url::Origin& origin, - const std::string& hashed_device_id, - base::OnceCallback<void(const absl::optional<std::string>&)> - callback) { - MediaStreamManager::GetMediaDeviceIDForHMAC( - blink::mojom::MediaDeviceType::MEDIA_AUDIO_OUTPUT, salt, - std::move(origin), hashed_device_id, - base::SequencedTaskRunnerHandle::Get(), std::move(callback)); - }, - salt_and_origin.device_id_salt, std::move(salt_and_origin.origin), - hashed_device_id, - base::BindOnce(&OnAudioOutputDeviceIdTranslated, - weak_ptr_factory_.GetWeakPtr(), player_id)); - - content::GetIOThreadTaskRunner({})->PostTask( - FROM_HERE, std::move(callback_on_io_thread)); -} - -void MediaWebContentsObserver::OnReceivedTranslatedDeviceId( +void MediaWebContentsObserver::OnAudioOutputSinkChangedWithRawDeviceId( const MediaPlayerId& player_id, const std::string& raw_device_id) { session_controllers_manager_->OnAudioOutputSinkChanged(player_id,
diff --git a/content/browser/media/media_web_contents_observer.h b/content/browser/media/media_web_contents_observer.h index 3266e4d..73b9b957 100644 --- a/content/browser/media/media_web_contents_observer.h +++ b/content/browser/media/media_web_contents_observer.h
@@ -120,9 +120,6 @@ audible_metrics_ = audible_metrics; } - void OnReceivedTranslatedDeviceId(const MediaPlayerId& player_id, - const std::string& raw_device_id); - // Returns whether or not to be able to use the MediaPlayer mojo interface. bool IsMediaPlayerRemoteAvailable(const MediaPlayerId& player_id); @@ -219,6 +216,9 @@ PlayerInfo* GetPlayerInfo(); void NotifyAudioStreamMonitorIfNeeded(); + void OnReceivedTranslatedDeviceId( + const absl::optional<std::string>& translated_id); + const MediaPlayerId media_player_id_; const raw_ptr<MediaWebContentsObserver> media_web_contents_observer_; @@ -229,6 +229,8 @@ bool uses_audio_service_ = true; std::unique_ptr<AudioStreamMonitor::AudibleClientRegistration> audio_client_registration_; + + base::WeakPtrFactory<MediaPlayerObserverHostImpl> weak_factory_{this}; }; using MediaPlayerHostImplMap = @@ -263,8 +265,9 @@ const MediaPlayerId& player_id, blink::WebFullscreenVideoStatus fullscreen_status); void OnMediaPlaying(); - void OnAudioOutputSinkChanged(const MediaPlayerId& player_id, - std::string hashed_device_id); + void OnAudioOutputSinkChangedWithRawDeviceId( + const MediaPlayerId& player_id, + const std::string& raw_device_id); // Used to notify when the renderer -> browser mojo connection via the // interface media::mojom::MediaPlayerObserver gets disconnected. @@ -320,8 +323,6 @@ // Map of remote endpoints for the media::mojom::MediaPlayer mojo interface, // indexed by MediaPlayerId. MediaPlayerRemotesMap media_player_remotes_; - - base::WeakPtrFactory<MediaWebContentsObserver> weak_ptr_factory_{this}; }; } // namespace content
diff --git a/content/browser/network_service_instance_impl.cc b/content/browser/network_service_instance_impl.cc index 4017bdf..a9874632 100644 --- a/content/browser/network_service_instance_impl.cc +++ b/content/browser/network_service_instance_impl.cc
@@ -177,7 +177,6 @@ base::Thread& GetNetworkServiceDedicatedThread() { static base::NoDestructor<base::Thread> thread{"NetworkService"}; - DCHECK(base::FeatureList::IsEnabled(kNetworkServiceDedicatedThread)); return *thread; } @@ -547,7 +546,11 @@ void CreateInProcessNetworkService( mojo::PendingReceiver<network::mojom::NetworkService> receiver) { scoped_refptr<base::SingleThreadTaskRunner> task_runner; - if (base::FeatureList::IsEnabled(kNetworkServiceDedicatedThread)) { + // If it's specified to run a separate thread for the in-process network + // service, or if the IO thread isn't initialized because we're in Android's + // minimal browser mode, then use a dedicated thread. + if (base::FeatureList::IsEnabled(kNetworkServiceDedicatedThread) || + !BrowserThread::IsThreadInitialized(BrowserThread::IO)) { base::Thread::Options options(base::MessagePumpType::IO, 0); GetNetworkServiceDedicatedThread().StartWithOptions(std::move(options)); task_runner = GetNetworkServiceDedicatedThread().task_runner();
diff --git a/content/browser/renderer_host/navigator.cc b/content/browser/renderer_host/navigator.cc index 1462a224..f96ea50 100644 --- a/content/browser/renderer_host/navigator.cc +++ b/content/browser/renderer_host/navigator.cc
@@ -428,15 +428,6 @@ base::WeakPtr<RenderFrameHostImpl> old_frame_host = frame_tree_node->render_manager()->current_frame_host()->GetWeakPtr(); - // If a frame claims the navigation was same-document, it must be the current - // frame, not a pending one. - // TODO(creis): This check should be moved to RenderFrameHostImpl, allowing an - // early return. See https://crbug.com/1209097. - if (was_within_same_document && render_frame_host != old_frame_host.get()) { - bad_message::ReceivedBadMessage(render_frame_host->GetProcess(), - bad_message::NI_IN_PAGE_NAVIGATION); - was_within_same_document = false; - } // At this point we have already chosen a SiteInstance for this navigation, so // set OriginIsolationRequest to kNone in the conversion to UrlInfo below: // this is done implicitly in the UrlInfoInit constructor. @@ -453,6 +444,12 @@ std::move(old_page_info->new_lifecycle_state_for_old_page)); } + // If a frame claims the navigation was same-document, it must be the current + // frame, not a pending one. + if (was_within_same_document && render_frame_host != old_frame_host.get()) { + was_within_same_document = false; + } + if (ui::PageTransitionIsMainFrame(params.transition)) { // Run tasks that must execute just before the commit. delegate_->DidNavigateMainFramePreCommit(frame_tree_node,
diff --git a/content/browser/renderer_host/render_frame_host_delegate.h b/content/browser/renderer_host/render_frame_host_delegate.h index f0cf415de..166a94c9 100644 --- a/content/browser/renderer_host/render_frame_host_delegate.h +++ b/content/browser/renderer_host/render_frame_host_delegate.h
@@ -322,14 +322,6 @@ bool is_fullscreen, blink::mojom::FullscreenOptionsPtr options); -#if defined(OS_ANDROID) - // Updates information to determine whether a user gesture should carryover to - // future navigations. This is needed so navigations within a certain - // timeframe of a request initiated by a gesture will be treated as if they - // were initiated by a gesture too, otherwise the navigation may be blocked. - virtual void UpdateUserGestureCarryoverInfo() {} -#endif - // Let the delegate decide whether postMessage should be delivered to // |target_rfh| from a source frame in the given SiteInstance. This defaults // to false and overrides the RenderFrameHost's decision if true.
diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc index 6cb871e..f1d6b8a 100644 --- a/content/browser/renderer_host/render_frame_host_impl.cc +++ b/content/browser/renderer_host/render_frame_host_impl.cc
@@ -3128,6 +3128,7 @@ CHECK_NE(render_frame_state_, RenderFrameState::kDeleting); bool was_created = is_render_frame_created(); render_frame_state_ = RenderFrameState::kDeleting; + render_frame_scoped_weak_ptr_factory_.InvalidateWeakPtrs(); // If the current status is different than the new status, the delegate // needs to be notified. @@ -5499,16 +5500,6 @@ return GetMainFrame()->GetRenderWidgetHost()->GetKeyboardLayoutMap(); } -#if defined(OS_ANDROID) -void RenderFrameHostImpl::UpdateUserGestureCarryoverInfo() { - // This should not occur for prerenders but may occur for pages in - // the BackForwardCache depending on timing. - if (!IsActive()) - return; - delegate_->UpdateUserGestureCarryoverInfo(); -} -#endif - void RenderFrameHostImpl::VisibilityChanged( blink::mojom::FrameVisibility visibility) { visibility_ = visibility; @@ -8533,6 +8524,15 @@ pepper_instance_map_.clear(); pepper_hung_detectors_.Clear(); #endif // BUILDFLAG(ENABLE_PLUGINS) + + // Audio stream factories are tied to a live RenderFrame: see + // //content/browser/media/forwarding_audio_stream_factory.h. + // Eagerly reset now to ensure that it is impossible to create streams + // associated with a RenderFrameHost without a live RenderFrame; + // otherwise, the `RenderFrameDeleted()` signal used to clean up streams + // will never fire. + audio_service_audio_output_stream_factory_.reset(); + audio_service_audio_input_stream_factory_.reset(); } bool RenderFrameHostImpl::IsFocused() { @@ -8881,10 +8881,10 @@ continue; } - if (i + relative_offset < 0 || - i + relative_offset >= parent_->child_count()) { + if (relative_offset < 0 && base::checked_cast<size_t>(-relative_offset) > i) return nullptr; - } + if (i + relative_offset >= parent_->child_count()) + return nullptr; return parent_->child_at(i + relative_offset); } @@ -9371,12 +9371,19 @@ // the commit which in turns updates the browser's token before this method // could be called. DCHECK(GetAXTreeID().token()); + // `render_accessibility_host_` is reset in `TearDownMojoConnection()`, but + // this Mojo endpoint lives on another sequence and posts tasks back to this + // `RenderFrameHostImpl` on the UI thread. After the reset, there may still be + // tasks in flight: use `render_frame_scoped_weak_ptr_factory_` to ensure + // those tasks are dropped if they arrive after the reset of their + // corresponding RenderAccessibilityHost. render_accessibility_host_ = base::SequenceBound<RenderAccessibilityHost>( base::FeatureList::IsEnabled( features::kRenderAccessibilityHostDeserializationOffMainThread) ? base::ThreadPool::CreateSequencedTaskRunner({}) : base::SequencedTaskRunnerHandle::Get(), - weak_ptr_factory_.GetWeakPtr(), std::move(receiver), GetAXTreeID()); + render_frame_scoped_weak_ptr_factory_.GetWeakPtr(), std::move(receiver), + GetAXTreeID()); } void RenderFrameHostImpl::CancelPrerendering( @@ -10238,6 +10245,16 @@ return false; } + // If a frame claims the navigation was same-document, it must be the current + // frame, not a pending one. + base::WeakPtr<RenderFrameHostImpl> old_frame_host = + frame_tree_node_->render_manager()->current_frame_host()->GetWeakPtr(); + if (is_same_document_navigation && this != old_frame_host.get()) { + bad_message::ReceivedBadMessage(this->GetProcess(), + bad_message::NI_IN_PAGE_NAVIGATION); + return false; + } + return true; }
diff --git a/content/browser/renderer_host/render_frame_host_impl.h b/content/browser/renderer_host/render_frame_host_impl.h index 97926be..0e9b4be 100644 --- a/content/browser/renderer_host/render_frame_host_impl.h +++ b/content/browser/renderer_host/render_frame_host_impl.h
@@ -2696,10 +2696,6 @@ void OpenURL(blink::mojom::OpenURLParamsPtr params) override; void DidStopLoading() override; -#if defined(OS_ANDROID) - void UpdateUserGestureCarryoverInfo() override; -#endif - friend class RenderAccessibilityHost; void HandleAXEvents(const ui::AXTreeID& tree_id, mojom::AXUpdatesAndEventsPtr updates_and_events, @@ -4128,8 +4124,15 @@ raw_ptr<WebBluetoothServiceImpl> last_web_bluetooth_service_for_testing_ = nullptr; - // NOTE: This must be the last member. + // WeakPtrFactories are the last members, to ensure they are destroyed before + // all other fields of `this`. base::WeakPtrFactory<RenderFrameHostImpl> weak_ptr_factory_{this}; + + // Unlike `weak_ptr_factory` which only invalidates when `this` is about to be + // deleted, `render_frame_scoped_weak_ptr_factory_` is invalidated every time + // the RenderFrame is deleted (for example, if the renderer crashes). + base::WeakPtrFactory<RenderFrameHostImpl> + render_frame_scoped_weak_ptr_factory_{this}; }; // Used when DCHECK_STATE_TRANSITION triggers.
diff --git a/content/browser/service_worker/embedded_worker_instance.cc b/content/browser/service_worker/embedded_worker_instance.cc index 80250a4..5f2762f 100644 --- a/content/browser/service_worker/embedded_worker_instance.cc +++ b/content/browser/service_worker/embedded_worker_instance.cc
@@ -333,13 +333,7 @@ coep_reporter_for_subresources.InitWithNewPipeAndPassReceiver()); } - // Initialize the global scope now if the worker won't be paused. Otherwise, - // delay initialization until the main script is loaded. - if (!owner_version_->initialize_global_scope_after_main_script_loaded()) { - owner_version_->InitializeGlobalScope( - /*script_loader_factories=*/nullptr, - /*subresource_loader_factories=*/nullptr); - } + owner_version_->InitializeGlobalScope(); // Register to DevTools and update params accordingly. const int routing_id = rph->GetNextRoutingID(); @@ -611,7 +605,6 @@ // Renderer side has started to launch the worker thread. starting_phase_ = SCRIPT_LOADED; - owner_version_->OnMainScriptLoaded(); } void EmbeddedWorkerInstance::OnWorkerVersionInstalled() { @@ -835,89 +828,6 @@ return factory_bundle; } -EmbeddedWorkerInstance::CreateFactoryBundlesResult:: - CreateFactoryBundlesResult() = default; -EmbeddedWorkerInstance::CreateFactoryBundlesResult:: - ~CreateFactoryBundlesResult() = default; -EmbeddedWorkerInstance::CreateFactoryBundlesResult::CreateFactoryBundlesResult( - CreateFactoryBundlesResult&& other) = default; - -EmbeddedWorkerInstance::CreateFactoryBundlesResult -EmbeddedWorkerInstance::CreateFactoryBundles() { - DCHECK_CURRENTLY_ON(BrowserThread::UI); - - CreateFactoryBundlesResult result; - - auto* rph = RenderProcessHost::FromID(process_id()); - if (!rph) { - // Return nullptr because we can't create a factory bundle because of - // missing renderer. - return result; - } - - // Create mojo::Remote which is connected to and owns a COEP reporter. - mojo::PendingRemote<network::mojom::CrossOriginEmbedderPolicyReporter> - coep_reporter_for_devtools; - mojo::PendingRemote<network::mojom::CrossOriginEmbedderPolicyReporter> - coep_reporter_for_scripts; - mojo::PendingRemote<network::mojom::CrossOriginEmbedderPolicyReporter> - coep_reporter_for_subresources; - - // |cross_origin_embedder_policy| is nullopt in some unittests. - // TODO(shimazu): Set COEP in those tests. - if (owner_version_->cross_origin_embedder_policy()) { - mojo::PendingRemote<blink::mojom::ReportingObserver> - reporting_observer_remote; - owner_version_->set_reporting_observer_receiver( - reporting_observer_remote.InitWithNewPipeAndPassReceiver()); - - auto* storage_partition = - static_cast<StoragePartitionImpl*>(rph->GetStoragePartition()); - coep_reporter_ = std::make_unique<CrossOriginEmbedderPolicyReporter>( - storage_partition->GetWeakPtr(), owner_version_->script_url(), - owner_version_->cross_origin_embedder_policy()->reporting_endpoint, - owner_version_->cross_origin_embedder_policy() - ->report_only_reporting_endpoint, - owner_version_->reporting_source(), - // TODO(https://crbug.com/1147281): This is the NetworkIsolationKey of a - // top-level browsing context, which shouldn't be use for ServiceWorkers - // used in iframes. - net::NetworkIsolationKey::ToDoUseTopFrameOriginAsWell( - url::Origin::Create(owner_version_->script_url()))); - coep_reporter_->BindObserver(std::move(reporting_observer_remote)); - coep_reporter_->Clone( - coep_reporter_for_devtools.InitWithNewPipeAndPassReceiver()); - coep_reporter_->Clone( - coep_reporter_for_scripts.InitWithNewPipeAndPassReceiver()); - coep_reporter_->Clone( - coep_reporter_for_subresources.InitWithNewPipeAndPassReceiver()); - - ServiceWorkerDevToolsManager::GetInstance() - ->UpdateCrossOriginEmbedderPolicy( - process_id(), worker_devtools_agent_route_id(), - owner_version_->cross_origin_embedder_policy().value(), - std::move(coep_reporter_for_devtools)); - } - - const url::Origin origin = url::Origin::Create(owner_version_->script_url()); - result.script_bundle = EmbeddedWorkerInstance::CreateFactoryBundle( - rph, worker_devtools_agent_route_id(), origin, - owner_version_->cross_origin_embedder_policy(), - std::move(coep_reporter_for_scripts), - ContentBrowserClient::URLLoaderFactoryType::kServiceWorkerScript, - WorkerDevtoolsId().ToString()); - result.subresource_bundle = EmbeddedWorkerInstance::CreateFactoryBundle( - rph, worker_devtools_agent_route_id(), origin, - owner_version_->cross_origin_embedder_policy(), - std::move(coep_reporter_for_subresources), - ContentBrowserClient::URLLoaderFactoryType::kServiceWorkerSubResource, - WorkerDevtoolsId().ToString()); - - BindCacheStorageInternal(); - - return result; -} - void EmbeddedWorkerInstance::OnReportException( const std::u16string& error_message, int line_number,
diff --git a/content/browser/service_worker/embedded_worker_instance.h b/content/browser/service_worker/embedded_worker_instance.h index 9ade464..965256c9 100644 --- a/content/browser/service_worker/embedded_worker_instance.h +++ b/content/browser/service_worker/embedded_worker_instance.h
@@ -240,18 +240,6 @@ ContentBrowserClient::URLLoaderFactoryType factory_type, const std::string& devtools_worker_token); - // Creates a set of factory bundles for scripts and subresources. This must be - // called after the COEP value for the worker script is known. - struct CreateFactoryBundlesResult { - CreateFactoryBundlesResult(); - ~CreateFactoryBundlesResult(); - CreateFactoryBundlesResult(CreateFactoryBundlesResult&& other); - - std::unique_ptr<blink::PendingURLLoaderFactoryBundle> script_bundle; - std::unique_ptr<blink::PendingURLLoaderFactoryBundle> subresource_bundle; - }; - CreateFactoryBundlesResult CreateFactoryBundles(); - // Returns the unique token that has been generated to identify this worker // instance, and its corresponding GlobalScope in the renderer process. If the // service worker is not currently running, this is absl::nullopt.
diff --git a/content/browser/service_worker/fake_service_worker.cc b/content/browser/service_worker/fake_service_worker.cc index 06dc1e3..f041e4ec 100644 --- a/content/browser/service_worker/fake_service_worker.cc +++ b/content/browser/service_worker/fake_service_worker.cc
@@ -50,8 +50,6 @@ blink::mojom::ServiceWorkerRegistrationObjectInfoPtr registration_info, blink::mojom::ServiceWorkerObjectInfoPtr service_worker_info, blink::mojom::FetchHandlerExistence fetch_handler_existence, - std::unique_ptr<blink::PendingURLLoaderFactoryBundle> - subresource_loader_factories, mojo::PendingReceiver<blink::mojom::ReportingObserver> reporting_observer_receiver) { host_.Bind(std::move(service_worker_host));
diff --git a/content/browser/service_worker/fake_service_worker.h b/content/browser/service_worker/fake_service_worker.h index 8c5c3c8..849c3dd 100644 --- a/content/browser/service_worker/fake_service_worker.h +++ b/content/browser/service_worker/fake_service_worker.h
@@ -60,8 +60,6 @@ blink::mojom::ServiceWorkerRegistrationObjectInfoPtr registration_info, blink::mojom::ServiceWorkerObjectInfoPtr service_worker_info, FetchHandlerExistence fetch_handler_existence, - std::unique_ptr<blink::PendingURLLoaderFactoryBundle> - subresource_loader_factories, mojo::PendingReceiver<blink::mojom::ReportingObserver> reporting_observer_receiver) override; void DispatchInstallEvent(DispatchInstallEventCallback callback) override;
diff --git a/content/browser/service_worker/service_worker_job_unittest.cc b/content/browser/service_worker/service_worker_job_unittest.cc index 3a5c803..5094369 100644 --- a/content/browser/service_worker/service_worker_job_unittest.cc +++ b/content/browser/service_worker/service_worker_job_unittest.cc
@@ -1358,7 +1358,6 @@ blink::mojom::ServiceWorkerRegistrationObjectInfoPtr, blink::mojom::ServiceWorkerObjectInfoPtr, blink::mojom::FetchHandlerExistence, - std::unique_ptr<blink::PendingURLLoaderFactoryBundle>, mojo::PendingReceiver<blink::mojom::ReportingObserver>) override { client_->SimulateFailureOfScriptEvaluation(); }
diff --git a/content/browser/service_worker/service_worker_version.cc b/content/browser/service_worker/service_worker_version.cc index 133bf5f..be5b938 100644 --- a/content/browser/service_worker/service_worker_version.cc +++ b/content/browser/service_worker/service_worker_version.cc
@@ -1011,32 +1011,7 @@ } } -void ServiceWorkerVersion::OnMainScriptLoaded() { - if (!initialize_global_scope_after_main_script_loaded_) - return; - initialize_global_scope_after_main_script_loaded_ = false; - - int net_error = script_cache_map()->main_script_net_error(); - if (net_error != net::OK) - return; - - // The subresource loaders need to be updated. Get the factories with the - // correct COEP value and pass it to the service worker. - // - // TODO(https://crbug.com/1039613): Update the loader factories passed to the - // script loader factory too. - DCHECK_EQ(NEW, status()); - EmbeddedWorkerInstance::CreateFactoryBundlesResult result = - embedded_worker_->CreateFactoryBundles(); - InitializeGlobalScope(std::move(result.script_bundle), - std::move(result.subresource_bundle)); -} - -void ServiceWorkerVersion::InitializeGlobalScope( - std::unique_ptr<blink::PendingURLLoaderFactoryBundle> - script_loader_factories, - std::unique_ptr<blink::PendingURLLoaderFactoryBundle> - subresource_loader_factories) { +void ServiceWorkerVersion::InitializeGlobalScope() { receiver_.reset(); receiver_.Bind(service_worker_host_.InitWithNewEndpointAndPassReceiver()); @@ -1045,19 +1020,6 @@ // The registration must exist since we keep a reference to it during // service worker startup. DCHECK(registration); - - if (subresource_loader_factories) { - // |subresource_loader_factories| is valid only when the service worker is - // a new worker. - DCHECK_EQ(NEW, status()); - - // |script_loader_factories| should be updated too. - DCHECK(script_loader_factories); - embedded_worker_->UpdateLoaderFactories( - std::move(script_loader_factories), - /*subresource_loader_factories=*/nullptr); - } - DCHECK(worker_host_); DCHECK(service_worker_remote_); service_worker_remote_->InitializeGlobalScope( @@ -1065,8 +1027,7 @@ worker_host_->container_host()->CreateServiceWorkerRegistrationObjectInfo( std::move(registration)), worker_host_->container_host()->CreateServiceWorkerObjectInfoToSend(this), - fetch_handler_existence_, std::move(subresource_loader_factories), - std::move(reporting_observer_receiver_)); + fetch_handler_existence_, std::move(reporting_observer_receiver_)); is_endpoint_ready_ = true; }
diff --git a/content/browser/service_worker/service_worker_version.h b/content/browser/service_worker/service_worker_version.h index 1b99ee9..e4ffe57d 100644 --- a/content/browser/service_worker/service_worker_version.h +++ b/content/browser/service_worker/service_worker_version.h
@@ -62,10 +62,6 @@ #include "url/gurl.h" #include "url/origin.h" -namespace blink { -class PendingURLLoaderFactoryBundle; -} - namespace content { class ServiceWorkerContainerHost; @@ -468,15 +464,6 @@ force_bypass_cache_for_scripts_ = force_bypass_cache_for_scripts; } - bool initialize_global_scope_after_main_script_loaded() const { - return initialize_global_scope_after_main_script_loaded_; - } - - void set_initialize_global_scope_after_main_script_loaded() { - DCHECK(!initialize_global_scope_after_main_script_loaded_); - initialize_global_scope_after_main_script_loaded_ = true; - } - void set_main_script_load_params( blink::mojom::WorkerMainScriptLoadParamsPtr main_script_load_params) { main_script_load_params_ = std::move(main_script_load_params); @@ -490,12 +477,6 @@ std::move(outside_fetch_client_settings_object); } - // For use by EmbeddedWorkerInstance. Called when the main script loaded. - // This is only used for new (non-installed) workers, so that script - // evaluation doesn't happen in the renderer until the browser calls - // InitializeGlobalScope() to tell it's ready to proceed. - void OnMainScriptLoaded(); - // Returns the reason the embedded worker failed to start, using internal // information that may not be available to the caller. Returns // |default_code| if it can't deduce a reason. @@ -632,13 +613,7 @@ } // Initializes the global scope of the ServiceWorker on the renderer side. - // This is dependant on a number of internal members and should only be called - // at a few select points where those members are valid. - void InitializeGlobalScope( - std::unique_ptr<blink::PendingURLLoaderFactoryBundle> - script_loader_factories, - std::unique_ptr<blink::PendingURLLoaderFactoryBundle> - subresource_loader_factories); + void InitializeGlobalScope(); // Returns true if |process_id| is a controllee process ID of this version. bool IsControlleeProcessID(int process_id) const; @@ -1075,10 +1050,7 @@ // called. This allows the browser process to prevent the renderer from // evaluating the script immediately after the script has been loaded, until // the subresource loader factories are updated. - // TODO(crbug.com/1270772): This can probably be removed since - // PlzServiceWorker has landed, as it looks only used in tests. Verify and - // remove if that's accurate. - bool initialize_global_scope_after_main_script_loaded_ = false; + bool initialize_global_scope_after_main_script_loaded_for_testing = false; // Populated via network::mojom::URLResponseHead of the main script. std::unique_ptr<MainScriptResponse> main_script_response_;
diff --git a/content/browser/service_worker/service_worker_version_browsertest.cc b/content/browser/service_worker/service_worker_version_browsertest.cc index 98b4ebab..ebc8920 100644 --- a/content/browser/service_worker/service_worker_version_browsertest.cc +++ b/content/browser/service_worker/service_worker_version_browsertest.cc
@@ -441,7 +441,6 @@ version_ = CreateNewServiceWorkerVersion( wrapper()->context()->registry(), registration_.get(), embedded_test_server()->GetURL(worker_url), script_type); - version_->set_initialize_global_scope_after_main_script_loaded(); // Make the registration findable via storage functions. wrapper()->context()->registry()->NotifyInstallingRegistration( registration_.get());
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 6bbbd826..4171952 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc
@@ -3606,15 +3606,6 @@ SetVisibilityAndNotifyObservers(new_visibility); } -#if defined(OS_ANDROID) -void WebContentsImpl::UpdateUserGestureCarryoverInfo() { - OPTIONAL_TRACE_EVENT0("content", - "WebContentsImpl::UpdateUserGestureCarryoverInfo"); - if (delegate_) - delegate_->UpdateUserGestureCarryoverInfo(this); -} -#endif - bool WebContentsImpl::IsFullscreen() { return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false; }
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index eea51b44..3eb6c00 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h
@@ -660,9 +660,6 @@ RenderFrameHostImpl* rfh, bool is_fullscreen, blink::mojom::FullscreenOptionsPtr options) override; -#if defined(OS_ANDROID) - void UpdateUserGestureCarryoverInfo() override; -#endif bool ShouldRouteMessageEvent( RenderFrameHostImpl* target_rfh, SiteInstance* source_site_instance) const override;
diff --git a/content/browser/webauth/virtual_discovery.cc b/content/browser/webauth/virtual_discovery.cc index 493f2aab..8cef247 100644 --- a/content/browser/webauth/virtual_discovery.cc +++ b/content/browser/webauth/virtual_discovery.cc
@@ -4,15 +4,18 @@ #include "content/browser/webauth/virtual_discovery.h" +#include <memory> #include <utility> #include "base/bind.h" -#include "base/callback_helpers.h" #include "base/check.h" #include "base/location.h" +#include "base/memory/weak_ptr.h" +#include "base/strings/string_piece.h" #include "base/threading/thread_task_runner_handle.h" -#include "content/browser/webauth/authenticator_environment_impl.h" #include "device/fido/fido_device.h" +#include "device/fido/fido_device_discovery.h" +#include "device/fido/fido_transport_protocol.h" namespace content {
diff --git a/content/browser/webauth/virtual_discovery.h b/content/browser/webauth/virtual_discovery.h index 201ecda..ed5bb98 100644 --- a/content/browser/webauth/virtual_discovery.h +++ b/content/browser/webauth/virtual_discovery.h
@@ -11,6 +11,7 @@ #include "base/memory/weak_ptr.h" #include "base/strings/string_piece.h" #include "device/fido/fido_device_discovery.h" +#include "device/fido/fido_transport_protocol.h" namespace device { class FidoDevice;
diff --git a/content/common/frame.mojom b/content/common/frame.mojom index afd57b6..ace032d 100644 --- a/content/common/frame.mojom +++ b/content/common/frame.mojom
@@ -777,13 +777,6 @@ // proper encoding name. Sent for top-level frames. UpdateEncoding(string encoding_name); - // Updates information to determine whether a user gesture should carryover to - // future navigations. This is needed so navigations within a certain - // timeframe of a request initiated by a gesture will be treated as if they - // were initiated by a gesture too, otherwise the navigation may be blocked. - [EnableIf=is_android] - UpdateUserGestureCarryoverInfo(); - // Notifies the browser that this frame has new session history information. // // NOTE: PageState can be quite large when serialized, and its message
diff --git a/content/public/browser/render_frame_host_receiver_set.h b/content/public/browser/render_frame_host_receiver_set.h index aa7af36..6b5ce9b8 100644 --- a/content/public/browser/render_frame_host_receiver_set.h +++ b/content/public/browser/render_frame_host_receiver_set.h
@@ -10,13 +10,13 @@ #include "base/memory/raw_ptr.h" #include "content/common/content_export.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents_observer.h" #include "mojo/public/cpp/bindings/associated_receiver_set.h" #include "mojo/public/cpp/bindings/pending_associated_receiver.h" namespace content { -class RenderFrameHost; class WebContents; // Owns a set of Channel-associated interface receivers with frame context on @@ -51,6 +51,17 @@ void Bind(RenderFrameHost* render_frame_host, mojo::PendingAssociatedReceiver<Interface> pending_receiver) { + // If the RenderFrameHost does not have a live RenderFrame: + // 1. There is no point in binding receivers, as the renderer should not be + // doing anything with this RenderFrameHost. + // 2. More problematic, `RenderFrameDeleted()` might not be called again + // for `render_frame_host`, potentially leaving dangling pointers to the + // RenderFrameHost (or other related objects) after the RenderFrameHost + // itself is later deleted. + if (!render_frame_host->IsRenderFrameLive()) { + return; + } + mojo::ReceiverId id = receivers_.Add(impl_, std::move(pending_receiver), render_frame_host); frame_to_receivers_map_[render_frame_host].push_back(id);
diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h index 9024cf96..b554b15 100644 --- a/content/public/browser/web_contents_delegate.h +++ b/content/public/browser/web_contents_delegate.h
@@ -686,14 +686,6 @@ // Picture-in-Picture mode has ended. virtual void ExitPictureInPicture() {} -#if defined(OS_ANDROID) - // Updates information to determine whether a user gesture should carryover to - // future navigations. This is needed so navigations within a certain - // timeframe of a request initiated by a gesture will be treated as if they - // were initiated by a gesture too, otherwise the navigation may be blocked. - virtual void UpdateUserGestureCarryoverInfo(WebContents* web_contents) {} -#endif - // Returns true if lazy loading of images and frames should be enabled. virtual bool ShouldAllowLazyLoad();
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index 487cba7..dcaa93d 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc
@@ -2524,12 +2524,6 @@ // blink::mojom::ResourceLoadInfoNotifier implementation // -------------------------- -#if defined(OS_ANDROID) -void RenderFrameImpl::NotifyUpdateUserGestureCarryoverInfo() { - GetFrameHost()->UpdateUserGestureCarryoverInfo(); -} -#endif - void RenderFrameImpl::NotifyResourceRedirectReceived( const net::RedirectInfo& redirect_info, network::mojom::URLResponseHeadPtr redirect_response) {}
diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h index 1b582c1..5b25f2b 100644 --- a/content/renderer/render_frame_impl.h +++ b/content/renderer/render_frame_impl.h
@@ -401,9 +401,6 @@ const int32_t flags) override; // blink::mojom::ResourceLoadInfoNotifier implementation: -#if defined(OS_ANDROID) - void NotifyUpdateUserGestureCarryoverInfo() override; -#endif void NotifyResourceRedirectReceived( const net::RedirectInfo& redirect_info, network::mojom::URLResponseHeadPtr redirect_response) override;
diff --git a/content/test/data/accessibility/mac/attributes/ax-drop-effects-expected.txt b/content/test/data/accessibility/mac/attributes/ax-drop-effects-expected.txt new file mode 100644 index 0000000..0ba40f2e --- /dev/null +++ b/content/test/data/accessibility/mac/attributes/ax-drop-effects-expected.txt
@@ -0,0 +1,2 @@ +drop_effect.AXDropEffects='copy' +not_applicable.AXDropEffects=n/a
diff --git a/content/test/data/accessibility/mac/attributes/ax-drop-effects.html b/content/test/data/accessibility/mac/attributes/ax-drop-effects.html new file mode 100644 index 0000000..619dcc5c --- /dev/null +++ b/content/test/data/accessibility/mac/attributes/ax-drop-effects.html
@@ -0,0 +1,8 @@ +<!-- +@SCRIPT: + drop_effect.AXDropEffects + not_applicable.AXDropEffects +--> +<!DOCTYPE html> +<div id="drop_effect" aria-dropeffect="copy"> +<div id="not_applicable"></div>
diff --git a/content/test/gpu/gpu_tests/webcodecs_integration_test.py b/content/test/gpu/gpu_tests/webcodecs_integration_test.py index b1de54a..9854c22 100644 --- a/content/test/gpu/gpu_tests/webcodecs_integration_test.py +++ b/content/test/gpu/gpu_tests/webcodecs_integration_test.py
@@ -17,7 +17,7 @@ four_colors_img_path = os.path.join(data_path, 'four-colors.y4m') frame_sources = ["camera", "capture", "offscreen", "hw_decoder", "sw_decoder"] -codecs = ["avc1.42001E", "vp8", "vp09.00.10.08"] +codecs = ["avc1.42001E", "vp8", "vp09.00.10.08", "av01.0.04M.08"] accelerations = ["prefer-hardware", "prefer-software"]
diff --git a/content/test/test_render_frame.cc b/content/test/test_render_frame.cc index dd6fac0..b4ea4aea 100644 --- a/content/test/test_render_frame.cc +++ b/content/test/test_render_frame.cc
@@ -212,10 +212,6 @@ void DidStopLoading() override {} -#if defined(OS_ANDROID) - void UpdateUserGestureCarryoverInfo() override {} -#endif - private: mojom::DidCommitProvisionalLoadParamsPtr last_commit_params_; mojo::PendingReceiver<blink::mojom::BrowserInterfaceBroker>
diff --git a/docs/README.md b/docs/README.md index e115063..16bf8f2d 100644 --- a/docs/README.md +++ b/docs/README.md
@@ -336,19 +336,19 @@ ### Accessibility * [Accessibility Overview](accessibility/overview.md) - Overview of accessibility concerns and approaches in Chromium. -* [Accessibility Tests](accessibility/tests.md) - Where to find +* [Accessibility Tests](accessibility/browser/tests.md) - Where to find accessibility-related tests in the codebase. -* [ChromeVox on Chrome OS](accessibility/chromevox.md) - Enabling spoken +* [ChromeVox on Chrome OS](accessibility/os/chromevox.md) - Enabling spoken feedback (ChromeVox) on Chrome OS. -* [ChromeVox on Desktop Linux](accessibility/chromevox_on_desktop_linux.md) - +* [ChromeVox on Desktop Linux](accessibility/os/chromevox_on_desktop_linux.md) - Enabling spoken feedback (ChromeVox) on desktop Linux. -* [Offscreen, Invisible and Size](accessibility/offscreen.md) - How Chrome +* [Offscreen, Invisible and Size](accessibility/browser/offscreen.md) - How Chrome defines offscreen, invisible and size in the accessibility tree. -* [Text to Speech](accessibility/tts.md) - Overview of text to speech in +* [Text to Speech](accessibility/browser/tts.md) - Overview of text to speech in Chrome and Chrome OS. -* [BRLTTY in Chrome OS](accessibility/brltty.md) - Chrome OS integration with +* [BRLTTY in Chrome OS](accessibility/os/brltty.md) - Chrome OS integration with BRLTTY to support refreshable braille displays -* [PATTS on Chrome OS](accessibility/patts.md) - Notes on the PATTS speech +* [PATTS on Chrome OS](accessibility/os/patts.md) - Notes on the PATTS speech synthesis engine used on Chrome OS * [VoiceOver](ios/voiceover.md) - Using Apple's VoiceOver feature with Chromium on iOS.
diff --git a/extensions/browser/api/audio/audio_device_id_calculator.cc b/extensions/browser/api/audio/audio_device_id_calculator.cc index a831c27..052f42e 100644 --- a/extensions/browser/api/audio/audio_device_id_calculator.cc +++ b/extensions/browser/api/audio/audio_device_id_calculator.cc
@@ -54,7 +54,7 @@ DCHECK(stable_id_map_loaded_); DCHECK_EQ(0u, stable_id_map_.count(audio_service_stable_id)); - ListPrefUpdateDeprecated update( + ListPrefUpdate update( ExtensionsBrowserClient::Get()->GetPrefServiceForContext(context_), kAudioApiStableDeviceIds);
diff --git a/extensions/browser/api/lock_screen_data/lock_screen_item_storage.cc b/extensions/browser/api/lock_screen_data/lock_screen_item_storage.cc index cca8a49..16d6707 100644 --- a/extensions/browser/api/lock_screen_data/lock_screen_item_storage.cc +++ b/extensions/browser/api/lock_screen_data/lock_screen_item_storage.cc
@@ -408,7 +408,7 @@ std::move(item)); { - DictionaryPrefUpdateDeprecated update(local_state_, kLockScreenDataPrefKey); + DictionaryPrefUpdate update(local_state_, kLockScreenDataPrefKey); update->SetPath({user_id_, extension_id, kExtensionItemCountPrefKey}, base::Value(static_cast<int>( data_item_cache_[extension_id].data_items.size()))); @@ -468,7 +468,7 @@ data_item_cache_[extension_id].data_items.erase(item_id); { - DictionaryPrefUpdateDeprecated update(local_state_, kLockScreenDataPrefKey); + DictionaryPrefUpdate update(local_state_, kLockScreenDataPrefKey); update->SetPath({user_id_, extension_id, kExtensionItemCountPrefKey}, base::Value(static_cast<int>( data_item_cache_[extension_id].data_items.size()))); @@ -562,7 +562,7 @@ } { - DictionaryPrefUpdateDeprecated update(local_state_, kLockScreenDataPrefKey); + DictionaryPrefUpdate update(local_state_, kLockScreenDataPrefKey); base::Value info(base::Value::Type::DICTIONARY); info.SetKey(kExtensionItemCountPrefKey, base::Value(static_cast<int>(data->second.data_items.size()))); @@ -670,7 +670,7 @@ void LockScreenItemStorage::RemoveExtensionFromLocalState( const std::string& id) { { - DictionaryPrefUpdateDeprecated update(local_state_, kLockScreenDataPrefKey); + DictionaryPrefUpdate update(local_state_, kLockScreenDataPrefKey); update->RemovePath(base::StrCat({user_id_, ".", id})); }
diff --git a/extensions/browser/api/lock_screen_data/lock_screen_item_storage_unittest.cc b/extensions/browser/api/lock_screen_data/lock_screen_item_storage_unittest.cc index 25b20d6..68d7f5d 100644 --- a/extensions/browser/api/lock_screen_data/lock_screen_item_storage_unittest.cc +++ b/extensions/browser/api/lock_screen_data/lock_screen_item_storage_unittest.cc
@@ -606,8 +606,7 @@ ASSERT_TRUE(state.storage_version == 1 || state.storage_version == 2) << "Failed to init local state " << state.extension_id; - DictionaryPrefUpdateDeprecated update(&local_state_, - "lockScreenDataItems"); + DictionaryPrefUpdate update(&local_state_, "lockScreenDataItems"); if (state.storage_version == 1) { update->SetPath({kTestUserIdHash, state.extension_id}, base::Value(state.item_count));
diff --git a/extensions/browser/extension_prefs.cc b/extensions/browser/extension_prefs.cc index efdde56..bf0a8859 100644 --- a/extensions/browser/extension_prefs.cc +++ b/extensions/browser/extension_prefs.cc
@@ -1400,7 +1400,7 @@ // true, which signifies that the registry key was deleted or the pref file // no longer lists the extension). if (!external_uninstall && Manifest::IsExternalLocation(location)) { - ListPrefUpdateDeprecated update(prefs_, kExternalUninstalls); + ListPrefUpdate update(prefs_, kExternalUninstalls); update->Append(extension_id); } @@ -2303,7 +2303,7 @@ void ExtensionPrefs::SetExtensionPrefFromContainer( const char* pref, const ExtensionIdContainer& strings) { - ListPrefUpdateDeprecated update(prefs_, pref); + ListPrefUpdate update(prefs_, pref); base::Value* list_of_values = update.Get(); list_of_values->ClearList(); for (auto iter = strings.cbegin(); iter != strings.cend(); ++iter) { @@ -2650,7 +2650,7 @@ if (uninstalled_ids.empty()) return; - ListPrefUpdateDeprecated update(prefs_, kExternalUninstalls); + ListPrefUpdate update(prefs_, kExternalUninstalls); base::Value* current_ids = update.Get(); for (const auto& id : uninstalled_ids) { base::Value::ListView list = current_ids->GetList(); @@ -2723,8 +2723,7 @@ bool ExtensionPrefs::ShouldInstallObsoleteComponentExtension( const std::string& extension_id) { - ListPrefUpdateDeprecated update(prefs_, - pref_names::kDeletedComponentExtensions); + ListPrefUpdate update(prefs_, pref_names::kDeletedComponentExtensions); base::Value* current_ids = update.Get(); base::Value::ListView list = current_ids->GetList(); auto existing_entry = std::find_if( @@ -2737,8 +2736,7 @@ void ExtensionPrefs::MarkObsoleteComponentExtensionAsRemoved( const std::string& extension_id, const ManifestLocation location) { - ListPrefUpdateDeprecated update(prefs_, - pref_names::kDeletedComponentExtensions); + ListPrefUpdate update(prefs_, pref_names::kDeletedComponentExtensions); base::Value* current_ids = update.Get(); base::Value::ListView list = current_ids->GetList(); auto existing_entry = std::find_if( @@ -2752,7 +2750,7 @@ } void ExtensionPrefs::ClearExternalUninstallBit(const ExtensionId& id) { - ListPrefUpdateDeprecated update(prefs_, kExternalUninstalls); + ListPrefUpdate update(prefs_, kExternalUninstalls); base::Value* current_ids = update.Get(); current_ids->EraseListValueIf([&id](const base::Value& value) { return value.is_string() && value.GetString() == id;
diff --git a/gpu/config/gpu_info.cc b/gpu/config/gpu_info.cc index 441fe09..60ae516 100644 --- a/gpu/config/gpu_info.cc +++ b/gpu/config/gpu_info.cc
@@ -224,7 +224,6 @@ macos_specific_texture_target(gpu::GetPlatformSpecificTextureTarget()), #endif // OS_MAC jpeg_decode_accelerator_supported(false), - oop_rasterization_supported(false), subpixel_font_rendering(true) { } @@ -316,7 +315,6 @@ ImageDecodeAcceleratorSupportedProfiles image_decode_accelerator_supported_profiles; - bool oop_rasterization_supported; bool subpixel_font_rendering; uint32_t visibility_callback_call_count; @@ -394,7 +392,6 @@ jpeg_decode_accelerator_supported); for (const auto& profile : image_decode_accelerator_supported_profiles) EnumerateImageDecodeAcceleratorSupportedProfile(profile, enumerator); - enumerator->AddBool("oopRasterizationSupported", oop_rasterization_supported); enumerator->AddBool("subpixelFontRendering", subpixel_font_rendering); enumerator->AddInt("visibilityCallbackCallCount", visibility_callback_call_count);
diff --git a/gpu/config/gpu_info.h b/gpu/config/gpu_info.h index 2cfd8dfb..704434b 100644 --- a/gpu/config/gpu_info.h +++ b/gpu/config/gpu_info.h
@@ -413,8 +413,6 @@ ImageDecodeAcceleratorSupportedProfiles image_decode_accelerator_supported_profiles; - bool oop_rasterization_supported; - bool subpixel_font_rendering; uint32_t visibility_callback_call_count = 0;
diff --git a/gpu/config/gpu_info_collector.cc b/gpu/config/gpu_info_collector.cc index 8ac31a3..dc6bec2 100644 --- a/gpu/config/gpu_info_collector.cc +++ b/gpu/config/gpu_info_collector.cc
@@ -24,7 +24,6 @@ #include "skia/buildflags.h" #include "third_party/angle/src/gpu_info_util/SystemInfo.h" // nogncheck #include "third_party/skia/include/core/SkGraphics.h" -#include "third_party/skia/include/gpu/GrDirectContext.h" #include "ui/gl/buildflags.h" #include "ui/gl/gl_bindings.h" #include "ui/gl/gl_context.h" @@ -145,24 +144,6 @@ return -1; } -bool SupportsOOPRaster(const gl::GLVersionInfo& gl_info) { - const bool use_version_es2 = false; - sk_sp<const GrGLInterface> gl_interface( - gl::init::CreateGrGLInterface(gl_info, use_version_es2)); - if (!gl_interface) { - return false; - } - - sk_sp<GrDirectContext> gr_context = - GrDirectContext::MakeGL(std::move(gl_interface)); - if (gr_context) { - // TODO(backer): Stash this GrContext for future use. For now, destroy. - return true; - } - - return false; -} - #if BUILDFLAG(USE_DAWN) || BUILDFLAG(SKIA_USE_DAWN) std::string GetDawnAdapterTypeString(wgpu::AdapterType type) { switch (type) { @@ -436,10 +417,6 @@ reinterpret_cast<GLint*>(&gpu_info->gl_reset_notification_strategy)); } - // Unconditionally check oop raster status regardless of preferences - // so that finch trials can turn it on. - gpu_info->oop_rasterization_supported = SupportsOOPRaster(gl_info); - // TODO(kbr): remove once the destruction of a current context automatically // clears the current context. context->ReleaseCurrent(surface.get());
diff --git a/gpu/config/gpu_util.cc b/gpu/config/gpu_util.cc index bbab0ee..e06b07a 100644 --- a/gpu/config/gpu_util.cc +++ b/gpu/config/gpu_util.cc
@@ -203,11 +203,6 @@ if (status != kGpuFeatureStatusEnabled) return status; - // If we can't create a GrContext for whatever reason, don't enable oop - // rasterization. - if (!gpu_info.oop_rasterization_supported) - return kGpuFeatureStatusDisabled; - if (gpu_preferences.disable_oop_rasterization) return kGpuFeatureStatusDisabled;
diff --git a/gpu/config/software_rendering_list.json b/gpu/config/software_rendering_list.json index a4a3bba3..4494eba 100644 --- a/gpu/config/software_rendering_list.json +++ b/gpu/config/software_rendering_list.json
@@ -1679,6 +1679,23 @@ "features": [ "accelerated_2d_canvas" ] + }, + { + "id": 175, + "description": "Disable video encoding on NVidia drivers older than summer 2018", + "cr_bugs": [1263058], + "os": { + "type": "win" + }, + "vendor_id": "0x10de", + "multi_gpu_category": "any", + "driver_version": { + "op": "<=", + "value": "24.21.13.9826" + }, + "features": [ + "accelerated_video_encode" + ] } ] }
diff --git a/gpu/ipc/common/gpu_info.mojom b/gpu/ipc/common/gpu_info.mojom index abce48f..d82b5bb 100644 --- a/gpu/ipc/common/gpu_info.mojom +++ b/gpu/ipc/common/gpu_info.mojom
@@ -179,7 +179,6 @@ array<ImageDecodeAcceleratorSupportedProfile> image_decode_accelerator_supported_profiles; - bool oop_rasterization_supported; bool subpixel_font_rendering; uint32 visibility_callback_call_count;
diff --git a/gpu/ipc/common/gpu_info_mojom_traits.cc b/gpu/ipc/common/gpu_info_mojom_traits.cc index c00fa81..842b383 100644 --- a/gpu/ipc/common/gpu_info_mojom_traits.cc +++ b/gpu/ipc/common/gpu_info_mojom_traits.cc
@@ -394,7 +394,6 @@ out->jpeg_decode_accelerator_supported = data.jpeg_decode_accelerator_supported(); - out->oop_rasterization_supported = data.oop_rasterization_supported(); out->subpixel_font_rendering = data.subpixel_font_rendering(); out->visibility_callback_call_count = data.visibility_callback_call_count();
diff --git a/gpu/ipc/common/gpu_info_mojom_traits.h b/gpu/ipc/common/gpu_info_mojom_traits.h index 03627b3..5cdbf02 100644 --- a/gpu/ipc/common/gpu_info_mojom_traits.h +++ b/gpu/ipc/common/gpu_info_mojom_traits.h
@@ -406,10 +406,6 @@ return input.image_decode_accelerator_supported_profiles; } - static bool oop_rasterization_supported(const gpu::GPUInfo& input) { - return input.oop_rasterization_supported; - } - static bool subpixel_font_rendering(const gpu::GPUInfo& input) { return input.subpixel_font_rendering; }
diff --git a/infra/config/generated/luci/cr-buildbucket.cfg b/infra/config/generated/luci/cr-buildbucket.cfg index 56b2139..e4d7004b 100644 --- a/infra/config/generated/luci/cr-buildbucket.cfg +++ b/infra/config/generated/luci/cr-buildbucket.cfg
@@ -44561,6 +44561,10 @@ build_numbers: YES service_account: "chromium-try-builder@chops-service-accounts.iam.gserviceaccount.com" experiments { + key: "luci.recipes.use_python3" + value: 100 + } + experiments { key: "luci.use_realms" value: 100 } @@ -44638,6 +44642,10 @@ build_numbers: YES service_account: "chromium-try-builder@chops-service-accounts.iam.gserviceaccount.com" experiments { + key: "luci.recipes.use_python3" + value: 100 + } + experiments { key: "luci.use_realms" value: 100 } @@ -44715,6 +44723,10 @@ build_numbers: YES service_account: "chromium-try-builder@chops-service-accounts.iam.gserviceaccount.com" experiments { + key: "luci.recipes.use_python3" + value: 100 + } + experiments { key: "luci.use_realms" value: 100 } @@ -44792,6 +44804,10 @@ build_numbers: YES service_account: "chromium-try-builder@chops-service-accounts.iam.gserviceaccount.com" experiments { + key: "luci.recipes.use_python3" + value: 100 + } + experiments { key: "luci.use_realms" value: 100 } @@ -44869,6 +44885,10 @@ build_numbers: YES service_account: "chromium-try-builder@chops-service-accounts.iam.gserviceaccount.com" experiments { + key: "luci.recipes.use_python3" + value: 100 + } + experiments { key: "luci.use_realms" value: 100 } @@ -44946,6 +44966,10 @@ build_numbers: YES service_account: "chromium-try-builder@chops-service-accounts.iam.gserviceaccount.com" experiments { + key: "luci.recipes.use_python3" + value: 100 + } + experiments { key: "luci.use_realms" value: 100 } @@ -45106,6 +45130,10 @@ build_numbers: YES service_account: "chromium-ci-builder@chops-service-accounts.iam.gserviceaccount.com" experiments { + key: "luci.recipes.use_python3" + value: 100 + } + experiments { key: "luci.use_realms" value: 100 } @@ -80991,26 +81019,33 @@ dimensions: "os:Ubuntu-16.04|Ubuntu-18.04" dimensions: "pool:luci.chromium.webrtc.fyi" exe { - cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" - cipd_version: "refs/heads/main" - cmd: "luciexe" + cipd_package: "infra/chromium/bootstrapper/${platform}" + cipd_version: "latest" + cmd: "bootstrapper" } properties: '{' - ' "$build/goma": {' - ' "enable_ats": true,' - ' "rpc_extra_params": "?prod",' - ' "server_host": "goma.chromium.org",' - ' "use_luci_auth": true' + ' "$bootstrap/exe": {' + ' "exe": {' + ' "cipd_package": "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",' + ' "cipd_version": "refs/heads/main",' + ' "cmd": [' + ' "luciexe"' + ' ]' + ' }' ' },' - ' "$recipe_engine/resultdb/test_presentation": {' - ' "column_keys": [],' - ' "grouping_keys": [' - ' "status",' - ' "v.test_suite"' - ' ]' + ' "$bootstrap/properties": {' + ' "properties_file": "infra/config/generated/builders/webrtc.fyi/WebRTC Chromium FYI Android Builder/properties.textpb",' + ' "top_level_project": {' + ' "ref": "refs/heads/main",' + ' "repo": {' + ' "host": "chromium.googlesource.com",' + ' "project": "chromium/src"' + ' }' + ' }' ' },' ' "builder_group": "chromium.webrtc.fyi",' + ' "led_builder_is_bootstrapped": true,' ' "recipe": "chromium"' '}' execution_timeout_secs: 7200 @@ -81035,26 +81070,33 @@ dimensions: "os:Ubuntu-16.04|Ubuntu-18.04" dimensions: "pool:luci.chromium.webrtc.fyi" exe { - cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" - cipd_version: "refs/heads/main" - cmd: "luciexe" + cipd_package: "infra/chromium/bootstrapper/${platform}" + cipd_version: "latest" + cmd: "bootstrapper" } properties: '{' - ' "$build/goma": {' - ' "enable_ats": true,' - ' "rpc_extra_params": "?prod",' - ' "server_host": "goma.chromium.org",' - ' "use_luci_auth": true' + ' "$bootstrap/exe": {' + ' "exe": {' + ' "cipd_package": "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",' + ' "cipd_version": "refs/heads/main",' + ' "cmd": [' + ' "luciexe"' + ' ]' + ' }' ' },' - ' "$recipe_engine/resultdb/test_presentation": {' - ' "column_keys": [],' - ' "grouping_keys": [' - ' "status",' - ' "v.test_suite"' - ' ]' + ' "$bootstrap/properties": {' + ' "properties_file": "infra/config/generated/builders/webrtc.fyi/WebRTC Chromium FYI Android Builder (dbg)/properties.textpb",' + ' "top_level_project": {' + ' "ref": "refs/heads/main",' + ' "repo": {' + ' "host": "chromium.googlesource.com",' + ' "project": "chromium/src"' + ' }' + ' }' ' },' ' "builder_group": "chromium.webrtc.fyi",' + ' "led_builder_is_bootstrapped": true,' ' "recipe": "chromium"' '}' execution_timeout_secs: 7200 @@ -81079,26 +81121,33 @@ dimensions: "os:Ubuntu-16.04|Ubuntu-18.04" dimensions: "pool:luci.chromium.webrtc.fyi" exe { - cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" - cipd_version: "refs/heads/main" - cmd: "luciexe" + cipd_package: "infra/chromium/bootstrapper/${platform}" + cipd_version: "latest" + cmd: "bootstrapper" } properties: '{' - ' "$build/goma": {' - ' "enable_ats": true,' - ' "rpc_extra_params": "?prod",' - ' "server_host": "goma.chromium.org",' - ' "use_luci_auth": true' + ' "$bootstrap/exe": {' + ' "exe": {' + ' "cipd_package": "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",' + ' "cipd_version": "refs/heads/main",' + ' "cmd": [' + ' "luciexe"' + ' ]' + ' }' ' },' - ' "$recipe_engine/resultdb/test_presentation": {' - ' "column_keys": [],' - ' "grouping_keys": [' - ' "status",' - ' "v.test_suite"' - ' ]' + ' "$bootstrap/properties": {' + ' "properties_file": "infra/config/generated/builders/webrtc.fyi/WebRTC Chromium FYI Android Builder ARM64 (dbg)/properties.textpb",' + ' "top_level_project": {' + ' "ref": "refs/heads/main",' + ' "repo": {' + ' "host": "chromium.googlesource.com",' + ' "project": "chromium/src"' + ' }' + ' }' ' },' ' "builder_group": "chromium.webrtc.fyi",' + ' "led_builder_is_bootstrapped": true,' ' "recipe": "chromium"' '}' execution_timeout_secs: 7200 @@ -81123,20 +81172,33 @@ dimensions: "os:Ubuntu-16.04|Ubuntu-18.04" dimensions: "pool:luci.chromium.webrtc.fyi" exe { - cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" - cipd_version: "refs/heads/main" - cmd: "luciexe" + cipd_package: "infra/chromium/bootstrapper/${platform}" + cipd_version: "latest" + cmd: "bootstrapper" } properties: '{' - ' "$recipe_engine/resultdb/test_presentation": {' - ' "column_keys": [],' - ' "grouping_keys": [' - ' "status",' - ' "v.test_suite"' - ' ]' + ' "$bootstrap/exe": {' + ' "exe": {' + ' "cipd_package": "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",' + ' "cipd_version": "refs/heads/main",' + ' "cmd": [' + ' "luciexe"' + ' ]' + ' }' + ' },' + ' "$bootstrap/properties": {' + ' "properties_file": "infra/config/generated/builders/webrtc.fyi/WebRTC Chromium FYI Android Tests (dbg) (M Nexus5X)/properties.textpb",' + ' "top_level_project": {' + ' "ref": "refs/heads/main",' + ' "repo": {' + ' "host": "chromium.googlesource.com",' + ' "project": "chromium/src"' + ' }' + ' }' ' },' ' "builder_group": "chromium.webrtc.fyi",' + ' "led_builder_is_bootstrapped": true,' ' "recipe": "chromium"' '}' execution_timeout_secs: 7200 @@ -81161,20 +81223,33 @@ dimensions: "os:Ubuntu-16.04|Ubuntu-18.04" dimensions: "pool:luci.chromium.webrtc.fyi" exe { - cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" - cipd_version: "refs/heads/main" - cmd: "luciexe" + cipd_package: "infra/chromium/bootstrapper/${platform}" + cipd_version: "latest" + cmd: "bootstrapper" } properties: '{' - ' "$recipe_engine/resultdb/test_presentation": {' - ' "column_keys": [],' - ' "grouping_keys": [' - ' "status",' - ' "v.test_suite"' - ' ]' + ' "$bootstrap/exe": {' + ' "exe": {' + ' "cipd_package": "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",' + ' "cipd_version": "refs/heads/main",' + ' "cmd": [' + ' "luciexe"' + ' ]' + ' }' + ' },' + ' "$bootstrap/properties": {' + ' "properties_file": "infra/config/generated/builders/webrtc.fyi/WebRTC Chromium FYI Android Tests (dbg) (N Nexus5X)/properties.textpb",' + ' "top_level_project": {' + ' "ref": "refs/heads/main",' + ' "repo": {' + ' "host": "chromium.googlesource.com",' + ' "project": "chromium/src"' + ' }' + ' }' ' },' ' "builder_group": "chromium.webrtc.fyi",' + ' "led_builder_is_bootstrapped": true,' ' "recipe": "chromium"' '}' execution_timeout_secs: 7200 @@ -81199,26 +81274,33 @@ dimensions: "os:Ubuntu-16.04|Ubuntu-18.04" dimensions: "pool:luci.chromium.webrtc.fyi" exe { - cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" - cipd_version: "refs/heads/main" - cmd: "luciexe" + cipd_package: "infra/chromium/bootstrapper/${platform}" + cipd_version: "latest" + cmd: "bootstrapper" } properties: '{' - ' "$build/goma": {' - ' "enable_ats": true,' - ' "rpc_extra_params": "?prod",' - ' "server_host": "goma.chromium.org",' - ' "use_luci_auth": true' + ' "$bootstrap/exe": {' + ' "exe": {' + ' "cipd_package": "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",' + ' "cipd_version": "refs/heads/main",' + ' "cmd": [' + ' "luciexe"' + ' ]' + ' }' ' },' - ' "$recipe_engine/resultdb/test_presentation": {' - ' "column_keys": [],' - ' "grouping_keys": [' - ' "status",' - ' "v.test_suite"' - ' ]' + ' "$bootstrap/properties": {' + ' "properties_file": "infra/config/generated/builders/webrtc.fyi/WebRTC Chromium FYI Linux Builder/properties.textpb",' + ' "top_level_project": {' + ' "ref": "refs/heads/main",' + ' "repo": {' + ' "host": "chromium.googlesource.com",' + ' "project": "chromium/src"' + ' }' + ' }' ' },' ' "builder_group": "chromium.webrtc.fyi",' + ' "led_builder_is_bootstrapped": true,' ' "recipe": "chromium"' '}' execution_timeout_secs: 7200 @@ -81243,26 +81325,33 @@ dimensions: "os:Ubuntu-16.04|Ubuntu-18.04" dimensions: "pool:luci.chromium.webrtc.fyi" exe { - cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" - cipd_version: "refs/heads/main" - cmd: "luciexe" + cipd_package: "infra/chromium/bootstrapper/${platform}" + cipd_version: "latest" + cmd: "bootstrapper" } properties: '{' - ' "$build/goma": {' - ' "enable_ats": true,' - ' "rpc_extra_params": "?prod",' - ' "server_host": "goma.chromium.org",' - ' "use_luci_auth": true' + ' "$bootstrap/exe": {' + ' "exe": {' + ' "cipd_package": "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",' + ' "cipd_version": "refs/heads/main",' + ' "cmd": [' + ' "luciexe"' + ' ]' + ' }' ' },' - ' "$recipe_engine/resultdb/test_presentation": {' - ' "column_keys": [],' - ' "grouping_keys": [' - ' "status",' - ' "v.test_suite"' - ' ]' + ' "$bootstrap/properties": {' + ' "properties_file": "infra/config/generated/builders/webrtc.fyi/WebRTC Chromium FYI Linux Builder (dbg)/properties.textpb",' + ' "top_level_project": {' + ' "ref": "refs/heads/main",' + ' "repo": {' + ' "host": "chromium.googlesource.com",' + ' "project": "chromium/src"' + ' }' + ' }' ' },' ' "builder_group": "chromium.webrtc.fyi",' + ' "led_builder_is_bootstrapped": true,' ' "recipe": "chromium"' '}' execution_timeout_secs: 7200 @@ -81287,20 +81376,33 @@ dimensions: "os:Ubuntu-16.04|Ubuntu-18.04" dimensions: "pool:luci.chromium.webrtc.fyi" exe { - cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" - cipd_version: "refs/heads/main" - cmd: "luciexe" + cipd_package: "infra/chromium/bootstrapper/${platform}" + cipd_version: "latest" + cmd: "bootstrapper" } properties: '{' - ' "$recipe_engine/resultdb/test_presentation": {' - ' "column_keys": [],' - ' "grouping_keys": [' - ' "status",' - ' "v.test_suite"' - ' ]' + ' "$bootstrap/exe": {' + ' "exe": {' + ' "cipd_package": "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",' + ' "cipd_version": "refs/heads/main",' + ' "cmd": [' + ' "luciexe"' + ' ]' + ' }' + ' },' + ' "$bootstrap/properties": {' + ' "properties_file": "infra/config/generated/builders/webrtc.fyi/WebRTC Chromium FYI Linux Tester/properties.textpb",' + ' "top_level_project": {' + ' "ref": "refs/heads/main",' + ' "repo": {' + ' "host": "chromium.googlesource.com",' + ' "project": "chromium/src"' + ' }' + ' }' ' },' ' "builder_group": "chromium.webrtc.fyi",' + ' "led_builder_is_bootstrapped": true,' ' "recipe": "chromium"' '}' execution_timeout_secs: 7200 @@ -81376,25 +81478,33 @@ dimensions: "os:Mac" dimensions: "pool:luci.chromium.webrtc.fyi" exe { - cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" - cipd_version: "refs/heads/main" - cmd: "luciexe" + cipd_package: "infra/chromium/bootstrapper/${platform}" + cipd_version: "latest" + cmd: "bootstrapper" } properties: '{' - ' "$build/goma": {' - ' "rpc_extra_params": "?prod",' - ' "server_host": "goma.chromium.org",' - ' "use_luci_auth": true' + ' "$bootstrap/exe": {' + ' "exe": {' + ' "cipd_package": "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",' + ' "cipd_version": "refs/heads/main",' + ' "cmd": [' + ' "luciexe"' + ' ]' + ' }' ' },' - ' "$recipe_engine/resultdb/test_presentation": {' - ' "column_keys": [],' - ' "grouping_keys": [' - ' "status",' - ' "v.test_suite"' - ' ]' + ' "$bootstrap/properties": {' + ' "properties_file": "infra/config/generated/builders/webrtc.fyi/WebRTC Chromium FYI Mac Builder (dbg)/properties.textpb",' + ' "top_level_project": {' + ' "ref": "refs/heads/main",' + ' "repo": {' + ' "host": "chromium.googlesource.com",' + ' "project": "chromium/src"' + ' }' + ' }' ' },' ' "builder_group": "chromium.webrtc.fyi",' + ' "led_builder_is_bootstrapped": true,' ' "recipe": "chromium"' '}' execution_timeout_secs: 7200 @@ -81470,26 +81580,33 @@ dimensions: "os:Windows-10" dimensions: "pool:luci.chromium.webrtc.fyi" exe { - cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" - cipd_version: "refs/heads/main" - cmd: "luciexe" + cipd_package: "infra/chromium/bootstrapper/${platform}" + cipd_version: "latest" + cmd: "bootstrapper" } properties: '{' - ' "$build/goma": {' - ' "enable_ats": true,' - ' "rpc_extra_params": "?prod",' - ' "server_host": "goma.chromium.org",' - ' "use_luci_auth": true' + ' "$bootstrap/exe": {' + ' "exe": {' + ' "cipd_package": "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",' + ' "cipd_version": "refs/heads/main",' + ' "cmd": [' + ' "luciexe"' + ' ]' + ' }' ' },' - ' "$recipe_engine/resultdb/test_presentation": {' - ' "column_keys": [],' - ' "grouping_keys": [' - ' "status",' - ' "v.test_suite"' - ' ]' + ' "$bootstrap/properties": {' + ' "properties_file": "infra/config/generated/builders/webrtc.fyi/WebRTC Chromium FYI Win Builder/properties.textpb",' + ' "top_level_project": {' + ' "ref": "refs/heads/main",' + ' "repo": {' + ' "host": "chromium.googlesource.com",' + ' "project": "chromium/src"' + ' }' + ' }' ' },' ' "builder_group": "chromium.webrtc.fyi",' + ' "led_builder_is_bootstrapped": true,' ' "recipe": "chromium"' '}' execution_timeout_secs: 7200 @@ -81514,26 +81631,33 @@ dimensions: "os:Windows-10" dimensions: "pool:luci.chromium.webrtc.fyi" exe { - cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" - cipd_version: "refs/heads/main" - cmd: "luciexe" + cipd_package: "infra/chromium/bootstrapper/${platform}" + cipd_version: "latest" + cmd: "bootstrapper" } properties: '{' - ' "$build/goma": {' - ' "enable_ats": true,' - ' "rpc_extra_params": "?prod",' - ' "server_host": "goma.chromium.org",' - ' "use_luci_auth": true' + ' "$bootstrap/exe": {' + ' "exe": {' + ' "cipd_package": "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",' + ' "cipd_version": "refs/heads/main",' + ' "cmd": [' + ' "luciexe"' + ' ]' + ' }' ' },' - ' "$recipe_engine/resultdb/test_presentation": {' - ' "column_keys": [],' - ' "grouping_keys": [' - ' "status",' - ' "v.test_suite"' - ' ]' + ' "$bootstrap/properties": {' + ' "properties_file": "infra/config/generated/builders/webrtc.fyi/WebRTC Chromium FYI Win Builder (dbg)/properties.textpb",' + ' "top_level_project": {' + ' "ref": "refs/heads/main",' + ' "repo": {' + ' "host": "chromium.googlesource.com",' + ' "project": "chromium/src"' + ' }' + ' }' ' },' ' "builder_group": "chromium.webrtc.fyi",' + ' "led_builder_is_bootstrapped": true,' ' "recipe": "chromium"' '}' execution_timeout_secs: 7200 @@ -81558,20 +81682,33 @@ dimensions: "os:Windows-10" dimensions: "pool:luci.chromium.webrtc.fyi" exe { - cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" - cipd_version: "refs/heads/main" - cmd: "luciexe" + cipd_package: "infra/chromium/bootstrapper/${platform}" + cipd_version: "latest" + cmd: "bootstrapper" } properties: '{' - ' "$recipe_engine/resultdb/test_presentation": {' - ' "column_keys": [],' - ' "grouping_keys": [' - ' "status",' - ' "v.test_suite"' - ' ]' + ' "$bootstrap/exe": {' + ' "exe": {' + ' "cipd_package": "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",' + ' "cipd_version": "refs/heads/main",' + ' "cmd": [' + ' "luciexe"' + ' ]' + ' }' + ' },' + ' "$bootstrap/properties": {' + ' "properties_file": "infra/config/generated/builders/webrtc.fyi/WebRTC Chromium FYI Win10 Tester/properties.textpb",' + ' "top_level_project": {' + ' "ref": "refs/heads/main",' + ' "repo": {' + ' "host": "chromium.googlesource.com",' + ' "project": "chromium/src"' + ' }' + ' }' ' },' ' "builder_group": "chromium.webrtc.fyi",' + ' "led_builder_is_bootstrapped": true,' ' "recipe": "chromium"' '}' execution_timeout_secs: 7200 @@ -81596,20 +81733,33 @@ dimensions: "os:Windows-10" dimensions: "pool:luci.chromium.webrtc.fyi" exe { - cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" - cipd_version: "refs/heads/main" - cmd: "luciexe" + cipd_package: "infra/chromium/bootstrapper/${platform}" + cipd_version: "latest" + cmd: "bootstrapper" } properties: '{' - ' "$recipe_engine/resultdb/test_presentation": {' - ' "column_keys": [],' - ' "grouping_keys": [' - ' "status",' - ' "v.test_suite"' - ' ]' + ' "$bootstrap/exe": {' + ' "exe": {' + ' "cipd_package": "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build",' + ' "cipd_version": "refs/heads/main",' + ' "cmd": [' + ' "luciexe"' + ' ]' + ' }' + ' },' + ' "$bootstrap/properties": {' + ' "properties_file": "infra/config/generated/builders/webrtc.fyi/WebRTC Chromium FYI Win7 Tester/properties.textpb",' + ' "top_level_project": {' + ' "ref": "refs/heads/main",' + ' "repo": {' + ' "host": "chromium.googlesource.com",' + ' "project": "chromium/src"' + ' }' + ' }' ' },' ' "builder_group": "chromium.webrtc.fyi",' + ' "led_builder_is_bootstrapped": true,' ' "recipe": "chromium"' '}' execution_timeout_secs: 7200
diff --git a/infra/config/recipes.star b/infra/config/recipes.star index a6a8ff6..f26cde0 100644 --- a/infra/config/recipes.star +++ b/infra/config/recipes.star
@@ -167,6 +167,7 @@ build_recipe( name = "recipe:chromium_codesearch", + use_python3 = True, ) build_recipe( @@ -206,6 +207,7 @@ build_recipe( name = "recipe:flakiness/generate_builder_test_data", + use_python3 = True, ) build_recipe(
diff --git a/infra/config/subprojects/webrtc/webrtc.fyi.star b/infra/config/subprojects/webrtc/webrtc.fyi.star index 442bdd3..fb20b88 100644 --- a/infra/config/subprojects/webrtc/webrtc.fyi.star +++ b/infra/config/subprojects/webrtc/webrtc.fyi.star
@@ -2,7 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -load("//lib/builders.star", "cpu", "defaults", "goma", "os", "xcode", base_builder = "builder") +load("//lib/builders.star", "builder", "cpu", "defaults", "goma", "os", "xcode") luci.bucket( name = "webrtc.fyi", @@ -33,10 +33,6 @@ refs = ["refs/heads/main"], ) -def builder(**kwargs): - kwargs.setdefault("bootstrap", False) - return base_builder(**kwargs) - defaults.bucket.set("webrtc.fyi") defaults.builder_group.set("chromium.webrtc.fyi") defaults.builderless.set(None) @@ -91,7 +87,7 @@ triggered_by = ["WebRTC Chromium FYI Linux Builder"], ) -base_builder( +builder( name = "WebRTC Chromium FYI Mac Builder", goma_backend = goma.backend.RBE_PROD, os = os.MAC_ANY, @@ -103,7 +99,7 @@ os = os.MAC_ANY, ) -base_builder( +builder( name = "WebRTC Chromium FYI Mac Tester", os = os.MAC_ANY, triggered_by = ["WebRTC Chromium FYI Mac Builder"],
diff --git a/ios/chrome/browser/web/session_state/web_session_state_tab_helper.mm b/ios/chrome/browser/web/session_state/web_session_state_tab_helper.mm index 80834e2f..80448019 100644 --- a/ios/chrome/browser/web/session_state/web_session_state_tab_helper.mm +++ b/ios/chrome/browser/web/session_state/web_session_state_tab_helper.mm
@@ -25,6 +25,7 @@ #import "ios/chrome/browser/web/session_state/web_session_state_cache_factory.h" #include "ios/web/common/features.h" #import "ios/web/public/js_messaging/web_frame.h" +#include "ios/web/public/navigation/navigation_context.h" #import "ios/web/public/navigation/navigation_manager.h" #import "ios/web/public/session/serializable_user_data_manager.h" #include "ios/web/public/web_client.h" @@ -143,6 +144,11 @@ void WebSessionStateTabHelper::DidFinishNavigation( web::WebState* web_state, web::NavigationContext* navigation_context) { + // Don't record navigations that result in downloads, since these will be + // discarded and there's no simple callback when discarded. + if (navigation_context->IsDownload()) + return; + MarkStale(); }
diff --git a/ios/google_internal/frameworks/chrome_internal_dynamic_framework.ios.zip.sha1 b/ios/google_internal/frameworks/chrome_internal_dynamic_framework.ios.zip.sha1 index 56cc450..6fe05c4 100644 --- a/ios/google_internal/frameworks/chrome_internal_dynamic_framework.ios.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_internal_dynamic_framework.ios.zip.sha1
@@ -1 +1 @@ -2d8bb27e02d5d092785cb9100f3976ce3b37269e \ No newline at end of file +0fe01f9d4b7424331da308a61e7939d567a11d55 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/chrome_internal_dynamic_framework.iossimulator.zip.sha1 b/ios/google_internal/frameworks/chrome_internal_dynamic_framework.iossimulator.zip.sha1 index 83b5ea1..1dfdccc8 100644 --- a/ios/google_internal/frameworks/chrome_internal_dynamic_framework.iossimulator.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_internal_dynamic_framework.iossimulator.zip.sha1
@@ -1 +1 @@ -c8d893765ef5f4c39c10f49b4c88e78be19b3d21 \ No newline at end of file +27fedb580a9633202acf44158fffdb4f27d8b816 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.ios.zip.sha1 b/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.ios.zip.sha1 index 9f60573..bf59af37 100644 --- a/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.ios.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.ios.zip.sha1
@@ -1 +1 @@ -868da5622f0bdd2d6033b7c37f53f08d97d448d7 \ No newline at end of file +ba357f50103a3974624047b8ebd2c415d6f6f53b \ No newline at end of file
diff --git a/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.iossimulator.zip.sha1 b/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.iossimulator.zip.sha1 index c619b04..62a7623 100644 --- a/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.iossimulator.zip.sha1 +++ b/ios/google_internal/frameworks/chrome_sso_internal_dynamic_framework.iossimulator.zip.sha1
@@ -1 +1 @@ -59e22d439dbda6ef847030286402ae9d0cfd4b20 \ No newline at end of file +059085c52e21060454dd55e7e74c8ec63b59bd2e \ No newline at end of file
diff --git a/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.ios.zip.sha1 b/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.ios.zip.sha1 index 9370173..0e1bbd3 100644 --- a/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.ios.zip.sha1 +++ b/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.ios.zip.sha1
@@ -1 +1 @@ -cee9e70719d0d0cef77b62f2b3781c10be9dd7ed \ No newline at end of file +7336f1ed746e24b333dbd5674e2948941e5543e1 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.iossimulator.zip.sha1 b/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.iossimulator.zip.sha1 index 1c4a046..b91281b8 100644 --- a/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.iossimulator.zip.sha1 +++ b/ios/google_internal/frameworks/remoting_dogfood_internal_dynamic_framework.iossimulator.zip.sha1
@@ -1 +1 @@ -055b4f0ed3983bf4a68d9a2e7c074320a9656196 \ No newline at end of file +b7fc9806b689fadc9338ac66afb034b7fe5b8c77 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/remoting_internal_dynamic_framework.ios.zip.sha1 b/ios/google_internal/frameworks/remoting_internal_dynamic_framework.ios.zip.sha1 index 4f3a30a0..60aa40f 100644 --- a/ios/google_internal/frameworks/remoting_internal_dynamic_framework.ios.zip.sha1 +++ b/ios/google_internal/frameworks/remoting_internal_dynamic_framework.ios.zip.sha1
@@ -1 +1 @@ -2e26f0794916f3f7604f80f9215eb1b1ceaab125 \ No newline at end of file +71a7e89179d5e4855810c204906a07907c41cdab \ No newline at end of file
diff --git a/ios/google_internal/frameworks/remoting_internal_dynamic_framework.iossimulator.zip.sha1 b/ios/google_internal/frameworks/remoting_internal_dynamic_framework.iossimulator.zip.sha1 index ac87a23d8..7980b3e 100644 --- a/ios/google_internal/frameworks/remoting_internal_dynamic_framework.iossimulator.zip.sha1 +++ b/ios/google_internal/frameworks/remoting_internal_dynamic_framework.iossimulator.zip.sha1
@@ -1 +1 @@ -7d92d2d19fa31e1ba01758047e66281dbe5e6379 \ No newline at end of file +5b92d128b9ba57c5e2097c70b2d6286ac8e197ac \ No newline at end of file
diff --git a/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.ios.zip.sha1 b/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.ios.zip.sha1 index 22277060..637480e 100644 --- a/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.ios.zip.sha1 +++ b/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.ios.zip.sha1
@@ -1 +1 @@ -26f37956fda5a1da1efd930de3883dc114636423 \ No newline at end of file +e7f91031023e5688ecf8cfa56b105443d3568594 \ No newline at end of file
diff --git a/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.iossimulator.zip.sha1 b/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.iossimulator.zip.sha1 index 32707db..d9368b50 100644 --- a/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.iossimulator.zip.sha1 +++ b/ios/google_internal/frameworks/web_view_shell_internal_dynamic_framework.iossimulator.zip.sha1
@@ -1 +1 @@ -653de0181cf868fa57be1c75e846cb0c4c6eeb07 \ No newline at end of file +2f898eb7f00d2c187d28026935edc6c171c82f03 \ No newline at end of file
diff --git a/ios/testing/BUILD.gn b/ios/testing/BUILD.gn index 37354aa..6bd2d5a 100644 --- a/ios/testing/BUILD.gn +++ b/ios/testing/BUILD.gn
@@ -45,8 +45,6 @@ sources = [ "scoped_block_swizzler.h", "scoped_block_swizzler.mm", - "scoped_method_swizzler.h", - "scoped_method_swizzler.mm", ] deps = [ "//base" ] } @@ -100,7 +98,6 @@ sources = [ "ocmock_complex_type_helper_unittest.mm", "scoped_block_swizzler_unittest.mm", - "scoped_method_swizzler_unittest.mm", ] assert_no_deps = ios_assert_no_deps
diff --git a/ios/testing/scoped_method_swizzler.h b/ios/testing/scoped_method_swizzler.h deleted file mode 100644 index 39ea73cc..0000000 --- a/ios/testing/scoped_method_swizzler.h +++ /dev/null
@@ -1,35 +0,0 @@ -// Copyright 2019 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_TESTING_SCOPED_METHOD_SWIZZLER_H_ -#define IOS_TESTING_SCOPED_METHOD_SWIZZLER_H_ - -#include <objc/runtime.h> - -class ScopedMethodSwizzler { - public: - // Constructs a new ScopedMethodSwizzler object and replaces the - // implementation of |selector_to_replace| on the |target| class with the - // given |replacing_selector|. ScopedMethodSwizzler swizzles instance methods. - // |selector_to_replace| has to be implemented on the class. - ScopedMethodSwizzler(Class target, - SEL selector_to_replace, - SEL replacing_selector); - - ScopedMethodSwizzler(const ScopedMethodSwizzler&) = delete; - ScopedMethodSwizzler& operator=(const ScopedMethodSwizzler&) = delete; - - // Destroys the ScopedMethodSwizzler object, removing the swizzled method and - // reinstalling the original method implementation. - virtual ~ScopedMethodSwizzler(); - - private: - // The method that is to be swizzled. - Method original_method_; - - // The method that replaces the original method. - Method replacing_method_; -}; - -#endif // IOS_TESTING_SCOPED_METHOD_SWIZZLER_H_
diff --git a/ios/testing/scoped_method_swizzler.mm b/ios/testing/scoped_method_swizzler.mm deleted file mode 100644 index 01b21d1..0000000 --- a/ios/testing/scoped_method_swizzler.mm +++ /dev/null
@@ -1,24 +0,0 @@ -// Copyright 2019 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/testing/scoped_method_swizzler.h" - -#include "base/check.h" - -#if !defined(__has_feature) || !__has_feature(objc_arc) -#error "This file requires ARC support." -#endif - -ScopedMethodSwizzler::ScopedMethodSwizzler(Class klass, - SEL selector_to_replace, - SEL replacing_selector) { - original_method_ = class_getInstanceMethod(klass, selector_to_replace); - DCHECK(original_method_); - replacing_method_ = class_getInstanceMethod(klass, replacing_selector); - method_exchangeImplementations(original_method_, replacing_method_); -} - -ScopedMethodSwizzler::~ScopedMethodSwizzler() { - method_exchangeImplementations(original_method_, replacing_method_); -}
diff --git a/ios/testing/scoped_method_swizzler_unittest.mm b/ios/testing/scoped_method_swizzler_unittest.mm deleted file mode 100644 index 1442e05a..0000000 --- a/ios/testing/scoped_method_swizzler_unittest.mm +++ /dev/null
@@ -1,66 +0,0 @@ -// Copyright 2019 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/testing/scoped_method_swizzler.h" - -#import <Foundation/Foundation.h> - -#include "testing/gtest/include/gtest/gtest.h" -#import "testing/gtest_mac.h" -#include "testing/platform_test.h" - -#if !defined(__has_feature) || !__has_feature(objc_arc) -#error "This file requires ARC support." -#endif - -// Class containing methods that will be swizzled by the unittests. -@interface ScopedMethodSwizzlerTestClass : NSObject - -- (NSString*)instanceMethodToSwizzle; -- (NSString*)swizzledInstanceMethod; - -@end - -namespace { - -NSString* const kOriginalInstanceValue = @"Bizz"; -NSString* const kSwizzledInstanceValue = @"Buzz"; - -using ScopedMethodSwizzlerTest = PlatformTest; - -// Tests that swizzling an instance method works properly. -TEST_F(ScopedMethodSwizzlerTest, SwizzlingInstanceMethod) { - ScopedMethodSwizzlerTestClass* target = - [[ScopedMethodSwizzlerTestClass alloc] init]; - - EXPECT_NSEQ(kOriginalInstanceValue, [target instanceMethodToSwizzle]); - EXPECT_NSEQ(kSwizzledInstanceValue, [target swizzledInstanceMethod]); - - { - ScopedMethodSwizzler swizzler([ScopedMethodSwizzlerTestClass class], - @selector(instanceMethodToSwizzle), - @selector(swizzledInstanceMethod)); - EXPECT_NSEQ(kSwizzledInstanceValue, [target instanceMethodToSwizzle]); - EXPECT_NSEQ(kOriginalInstanceValue, [target swizzledInstanceMethod]); - } - - EXPECT_NSEQ(kOriginalInstanceValue, [target instanceMethodToSwizzle]); - EXPECT_NSEQ(kSwizzledInstanceValue, [target swizzledInstanceMethod]); -} - -} // namespace - -#pragma mark - ScopedMethodSwizzlerTestClass - -@implementation ScopedMethodSwizzlerTestClass - -- (NSString*)instanceMethodToSwizzle { - return kOriginalInstanceValue; -} - -- (NSString*)swizzledInstanceMethod { - return kSwizzledInstanceValue; -} - -@end
diff --git a/ios/web/js_messaging/web_frame_impl.h b/ios/web/js_messaging/web_frame_impl.h index ff85ed2..54cb105 100644 --- a/ios/web/js_messaging/web_frame_impl.h +++ b/ios/web/js_messaging/web_frame_impl.h
@@ -71,6 +71,8 @@ bool ExecuteJavaScript( const std::string& script, base::OnceCallback<void(const base::Value*)> callback) override; + bool ExecuteJavaScript(const std::string& script, + ExecuteJavaScriptCallbackWithError callback) override; // WebFrameContentWorldAPI: bool CallJavaScriptFunctionInContentWorld( @@ -142,6 +144,15 @@ int message_id, bool reply_with_result); + // Converts the given callback into a |ExecuteJavaScriptCallbackWithError| + // callback. This function improves code sharing by being a bridge + // between the various ExecuteJavaScript() functions. + ExecuteJavaScriptCallbackWithError ExecuteJavaScriptCallbackAdapter( + base::OnceCallback<void(const base::Value*)> callback); + // Prints the information about the error that was generated from the + // execution of the given arbitrary JavaScript string. + void LogScriptWarning(NSString* script, NSError* error); + // Runs the request associated with the message with id |message_id|. The // completion callback, if any, associated with |message_id| will be called // with |result|.
diff --git a/ios/web/js_messaging/web_frame_impl.mm b/ios/web/js_messaging/web_frame_impl.mm index 4c7e7ec..a96605db 100644 --- a/ios/web/js_messaging/web_frame_impl.mm +++ b/ios/web/js_messaging/web_frame_impl.mm
@@ -261,35 +261,22 @@ } bool WebFrameImpl::ExecuteJavaScript(const std::string& script) { - DCHECK(base::ios::IsRunningOnIOS14OrLater()); - DCHECK(frame_info_); - - if (!IsMainFrame()) { - return false; - } - - NSString* ns_script = base::SysUTF8ToNSString(script); - void (^completion_handler)(id, NSError*) = ^void(id value, NSError* error) { - if (error) { - DLOG(WARNING) << "Script execution of:" - << base::SysNSStringToUTF16(ns_script) - << "\nfailed with error: " - << base::SysNSStringToUTF16( - error.userInfo[NSLocalizedDescriptionKey]); - } - }; - - if (@available(iOS 14.0, *)) { - web::ExecuteJavaScript(frame_info_.webView, WKContentWorld.pageWorld, - frame_info_, ns_script, completion_handler); - return true; - } - return false; + return ExecuteJavaScript(script, + base::DoNothingAs<void(const base::Value*)>()); } bool WebFrameImpl::ExecuteJavaScript( const std::string& script, base::OnceCallback<void(const base::Value*)> callback) { + ExecuteJavaScriptCallbackWithError callback_with_error = + ExecuteJavaScriptCallbackAdapter(std::move(callback)); + + return ExecuteJavaScript(script, std::move(callback_with_error)); +} + +bool WebFrameImpl::ExecuteJavaScript( + const std::string& script, + ExecuteJavaScriptCallbackWithError callback) { DCHECK(base::ios::IsRunningOnIOS14OrLater()); DCHECK(frame_info_); @@ -298,20 +285,14 @@ } NSString* ns_script = base::SysUTF8ToNSString(script); - // Because Objective-C blocks treat scoped-variables - // as const, we have to redefine the callback with the - // __block keyword to be able to run the callback inside - // the completion handler. __block auto internal_callback = std::move(callback); void (^completion_handler)(id, NSError*) = ^void(id value, NSError* error) { if (error) { - DLOG(WARNING) << "Script execution of:" - << base::SysNSStringToUTF16(ns_script) - << "\nfailed with error: " - << base::SysNSStringToUTF16( - error.userInfo[NSLocalizedDescriptionKey]); + LogScriptWarning(ns_script, error); + std::move(internal_callback).Run(nullptr, true); } else { - std::move(internal_callback).Run(ValueResultFromWKResult(value).get()); + std::move(internal_callback) + .Run(ValueResultFromWKResult(value).get(), false); } }; @@ -324,6 +305,28 @@ return false; } +WebFrame::ExecuteJavaScriptCallbackWithError +WebFrameImpl::ExecuteJavaScriptCallbackAdapter( + base::OnceCallback<void(const base::Value*)> callback) { + // Because blocks treat scoped-variables + // as const, we have to redefine the callback with the + // __block keyword to be able to run the callback inside + // the completion handler. + __block auto internal_callback = std::move(callback); + return base::BindOnce(^(const base::Value* value, bool error) { + if (!error) { + std::move(internal_callback).Run(value); + } + }); +} + +void WebFrameImpl::LogScriptWarning(NSString* script, NSError* error) { + DLOG(WARNING) << "Script execution of:" << base::SysNSStringToUTF16(script) + << "\nfailed with error: " + << base::SysNSStringToUTF16( + error.userInfo[NSLocalizedDescriptionKey]); +} + bool WebFrameImpl::ExecuteJavaScriptFunction( JavaScriptContentWorld* content_world, const std::string& name,
diff --git a/ios/web/public/js_messaging/web_frame.h b/ios/web/public/js_messaging/web_frame.h index aa732d1..c26be12 100644 --- a/ios/web/public/js_messaging/web_frame.h +++ b/ios/web/public/js_messaging/web_frame.h
@@ -80,6 +80,17 @@ const std::string& script, base::OnceCallback<void(const base::Value*)> callback) = 0; + using ExecuteJavaScriptCallbackWithError = + base::OnceCallback<void(const base::Value*, bool)>; + // Executes the given |script| and returns whether the script was run. + // If the script is successfully executed, |callback| is called with + // the result. Otherwise, |callback| is called with the bool. The + // bool parameter in the |callback| is used to signal that an error + // during the execution of the |script| occurred. + virtual bool ExecuteJavaScript( + const std::string& script, + ExecuteJavaScriptCallbackWithError callback) = 0; + // Returns the WebFrameInternal instance for this object. virtual WebFrameInternal* GetWebFrameInternal() = 0;
diff --git a/ios/web/test/fakes/fake_web_frame_impl.cc b/ios/web/test/fakes/fake_web_frame_impl.cc index 79fa95cc..36d17aa 100644 --- a/ios/web/test/fakes/fake_web_frame_impl.cc +++ b/ios/web/test/fakes/fake_web_frame_impl.cc
@@ -155,6 +155,12 @@ return false; } +bool FakeWebFrameImpl::ExecuteJavaScript( + const std::string& script, + base::OnceCallback<void(const base::Value*, bool)> callback) { + return false; +} + void FakeWebFrameImpl::AddJsResultForFunctionCall( base::Value* js_result, const std::string& function_name) {
diff --git a/ios/web/test/fakes/fake_web_frame_impl.h b/ios/web/test/fakes/fake_web_frame_impl.h index 702a374..e8f8b86 100644 --- a/ios/web/test/fakes/fake_web_frame_impl.h +++ b/ios/web/test/fakes/fake_web_frame_impl.h
@@ -45,6 +45,9 @@ bool ExecuteJavaScript( const std::string& script, base::OnceCallback<void(const base::Value*)> callback) override; + bool ExecuteJavaScript( + const std::string& script, + base::OnceCallback<void(const base::Value*, bool)> callback) override; // FakeWebFrame: std::string GetLastJavaScriptCall() const override;
diff --git a/ios/web/web_state/ui/crw_web_controller_unittest.mm b/ios/web/web_state/ui/crw_web_controller_unittest.mm index 9be980a..f2d18f0 100644 --- a/ios/web/web_state/ui/crw_web_controller_unittest.mm +++ b/ios/web/web_state/ui/crw_web_controller_unittest.mm
@@ -1108,6 +1108,7 @@ delegate_.child_windows()[0]->SetDelegate(&delegate_); CloseWindow(); + base::RunLoop().RunUntilIdle(); EXPECT_TRUE(delegate_.child_windows().empty()); EXPECT_TRUE(delegate_.popups().empty());
diff --git a/ios/web/web_state/ui/crw_wk_ui_handler.mm b/ios/web/web_state/ui/crw_wk_ui_handler.mm index 5e429ca..ec3fe482 100644 --- a/ios/web/web_state/ui/crw_wk_ui_handler.mm +++ b/ios/web/web_state/ui/crw_wk_ui_handler.mm
@@ -109,8 +109,19 @@ } - (void)webViewDidClose:(WKWebView*)webView { - if (self.webStateImpl && self.webStateImpl->HasOpener()) - self.webStateImpl->CloseWebState(); + if (self.webStateImpl && self.webStateImpl->HasOpener()) { + __weak __typeof(self) weakSelf = self; + // -webViewDidClose will typically trigger another webState to activate, + // which may in turn also close. To prevent reentrant modificationre in + // WebStateList, trigger a PostTask here. + base::SequencedTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::BindOnce(^{ + web::WebStateImpl* webStateImpl = weakSelf.webStateImpl; + if (webStateImpl) { + webStateImpl->CloseWebState(); + } + })); + } } - (void)webView:(WKWebView*)webView
diff --git a/media/base/video_frame_metadata.cc b/media/base/video_frame_metadata.cc index bc37c5f..46fe0bb 100644 --- a/media/base/video_frame_metadata.cc +++ b/media/base/video_frame_metadata.cc
@@ -18,47 +18,57 @@ VideoFrameMetadata::VideoFrameMetadata(const VideoFrameMetadata& other) = default; -#define MERGE_FIELD(a, source) \ - if (source.a) \ - this->a = source.a - void VideoFrameMetadata::MergeMetadataFrom( const VideoFrameMetadata& metadata_source) { - MERGE_FIELD(allow_overlay, metadata_source); - MERGE_FIELD(capture_begin_time, metadata_source); - MERGE_FIELD(capture_end_time, metadata_source); - MERGE_FIELD(capture_counter, metadata_source); - MERGE_FIELD(capture_update_rect, metadata_source); - MERGE_FIELD(copy_mode, metadata_source); - MERGE_FIELD(end_of_stream, metadata_source); - MERGE_FIELD(frame_duration, metadata_source); - MERGE_FIELD(frame_rate, metadata_source); - MERGE_FIELD(interactive_content, metadata_source); - MERGE_FIELD(reference_time, metadata_source); - MERGE_FIELD(read_lock_fences_enabled, metadata_source); - MERGE_FIELD(transformation, metadata_source); - MERGE_FIELD(texture_owner, metadata_source); - MERGE_FIELD(wants_promotion_hint, metadata_source); - MERGE_FIELD(protected_video, metadata_source); - MERGE_FIELD(hw_protected, metadata_source); - MERGE_FIELD(overlay_plane_id, metadata_source); - MERGE_FIELD(power_efficient, metadata_source); - MERGE_FIELD(texture_origin_is_top_left, metadata_source); - MERGE_FIELD(device_scale_factor, metadata_source); - MERGE_FIELD(page_scale_factor, metadata_source); - MERGE_FIELD(root_scroll_offset_x, metadata_source); - MERGE_FIELD(root_scroll_offset_y, metadata_source); - MERGE_FIELD(top_controls_visible_height, metadata_source); - MERGE_FIELD(decode_begin_time, metadata_source); - MERGE_FIELD(decode_end_time, metadata_source); - MERGE_FIELD(processing_time, metadata_source); - MERGE_FIELD(rtp_timestamp, metadata_source); - MERGE_FIELD(receive_time, metadata_source); - MERGE_FIELD(wallclock_frame_duration, metadata_source); - MERGE_FIELD(maximum_composition_delay_in_frames, metadata_source); + static const VideoFrameMetadata kDefaultMetadata; + +#define MERGE_OPTIONAL_FIELD(a, source) \ + if (source.a) \ + this->a = source.a + +#define MERGE_VALUE_FIELD(a, source) \ + if (source.a != kDefaultMetadata.a) \ + this->a = source.a + + MERGE_VALUE_FIELD(allow_overlay, metadata_source); + MERGE_OPTIONAL_FIELD(capture_begin_time, metadata_source); + MERGE_OPTIONAL_FIELD(capture_end_time, metadata_source); + MERGE_OPTIONAL_FIELD(capture_counter, metadata_source); + MERGE_OPTIONAL_FIELD(capture_update_rect, metadata_source); + MERGE_OPTIONAL_FIELD(copy_mode, metadata_source); + MERGE_VALUE_FIELD(end_of_stream, metadata_source); + MERGE_OPTIONAL_FIELD(frame_duration, metadata_source); + MERGE_OPTIONAL_FIELD(frame_rate, metadata_source); + MERGE_VALUE_FIELD(interactive_content, metadata_source); + MERGE_OPTIONAL_FIELD(reference_time, metadata_source); + MERGE_VALUE_FIELD(read_lock_fences_enabled, metadata_source); + MERGE_OPTIONAL_FIELD(transformation, metadata_source); + MERGE_VALUE_FIELD(texture_owner, metadata_source); + MERGE_VALUE_FIELD(wants_promotion_hint, metadata_source); + MERGE_VALUE_FIELD(dcomp_surface, metadata_source); + MERGE_VALUE_FIELD(protected_video, metadata_source); + MERGE_VALUE_FIELD(hw_protected, metadata_source); #if BUILDFLAG(USE_VAAPI) - MERGE_FIELD(hw_va_protected_session_id, metadata_source); + MERGE_OPTIONAL_FIELD(hw_va_protected_session_id, metadata_source); #endif + MERGE_OPTIONAL_FIELD(overlay_plane_id, metadata_source); + MERGE_VALUE_FIELD(power_efficient, metadata_source); + MERGE_VALUE_FIELD(texture_origin_is_top_left, metadata_source); + MERGE_OPTIONAL_FIELD(device_scale_factor, metadata_source); + MERGE_OPTIONAL_FIELD(page_scale_factor, metadata_source); + MERGE_OPTIONAL_FIELD(root_scroll_offset_x, metadata_source); + MERGE_OPTIONAL_FIELD(root_scroll_offset_y, metadata_source); + MERGE_OPTIONAL_FIELD(top_controls_visible_height, metadata_source); + MERGE_OPTIONAL_FIELD(decode_begin_time, metadata_source); + MERGE_OPTIONAL_FIELD(decode_end_time, metadata_source); + MERGE_OPTIONAL_FIELD(processing_time, metadata_source); + MERGE_OPTIONAL_FIELD(rtp_timestamp, metadata_source); + MERGE_OPTIONAL_FIELD(receive_time, metadata_source); + MERGE_OPTIONAL_FIELD(wallclock_frame_duration, metadata_source); + MERGE_OPTIONAL_FIELD(maximum_composition_delay_in_frames, metadata_source); + +#undef MERGE_VALUE_FIELD +#undef MERGE_OPTIONAL_FIELD } } // namespace media
diff --git a/media/base/video_frame_metadata.h b/media/base/video_frame_metadata.h index ebdb44d..53950ef9 100644 --- a/media/base/video_frame_metadata.h +++ b/media/base/video_frame_metadata.h
@@ -16,6 +16,8 @@ namespace media { +// NOTE: When adding new VideoFrameMetadata fields, please ensure you update the +// MergeMetadataFrom() method. struct MEDIA_EXPORT VideoFrameMetadata { VideoFrameMetadata(); ~VideoFrameMetadata() = default;
diff --git a/media/base/video_frame_unittest.cc b/media/base/video_frame_unittest.cc index 7d9fac9..c6b15a8 100644 --- a/media/base/video_frame_unittest.cc +++ b/media/base/video_frame_unittest.cc
@@ -789,6 +789,7 @@ partial_metadata.reference_time = kTempTicks; partial_metadata.processing_time = kTempDelta; partial_metadata.allow_overlay = false; + partial_metadata.texture_origin_is_top_left = false; // Merging partial metadata into full metadata partially override it. full_metadata.MergeMetadataFrom(partial_metadata); @@ -797,6 +798,7 @@ EXPECT_EQ(partial_metadata.reference_time, kTempTicks); EXPECT_EQ(partial_metadata.processing_time, kTempDelta); EXPECT_EQ(partial_metadata.allow_overlay, false); + EXPECT_EQ(partial_metadata.texture_origin_is_top_left, false); } } // namespace media
diff --git a/media/gpu/v4l2/test/vp9_decoder.cc b/media/gpu/v4l2/test/vp9_decoder.cc index ebbbe3e..e171c5c 100644 --- a/media/gpu/v4l2/test/vp9_decoder.cc +++ b/media/gpu/v4l2/test/vp9_decoder.cc
@@ -428,6 +428,9 @@ if (!v4l2_ioctl_->DQBuf(CAPTURE_queue_, &index)) LOG(ERROR) << "VIDIOC_DQBUF failed for CAPTURE queue."; + RefreshReferenceSlots(frame_hdr.refresh_frame_flags, + CAPTURE_queue_->GetBuffer(index)); + if (!v4l2_ioctl_->DQBuf(OUTPUT_queue_, &index)) LOG(ERROR) << "VIDIOC_DQBUF failed for OUTPUT queue."; @@ -436,8 +439,6 @@ // in kernel 5.17, VIDIOC_G_EXT_CTRLS ioctl call is no longer needed, see: // https://lwn.net/Articles/855419/ - // TODO(stevecho): call RefreshReferenceSlots() once decoded buffer is ready. - if (!v4l2_ioctl_->MediaRequestIocReinit(OUTPUT_queue_)) LOG(ERROR) << "MEDIA_REQUEST_IOC_REINIT failed.";
diff --git a/media/video/av1_video_encoder.cc b/media/video/av1_video_encoder.cc index 6d2842d..6f29b2e 100644 --- a/media/video/av1_video_encoder.cc +++ b/media/video/av1_video_encoder.cc
@@ -267,6 +267,7 @@ #undef CALL_AOM_CONTROL options_ = options; + originally_configured_size_ = options.frame_size; output_cb_ = BindToCurrentLoop(std::move(output_cb)); codec_ = std::move(codec); std::move(done_cb).Run(EncoderStatus::Codes::kOk); @@ -316,12 +317,11 @@ } } - const bool is_yuv = IsYuvPlanar(frame->format()); - if (frame->visible_rect().size() != options_.frame_size || !is_yuv) { + const bool i420 = frame->format() == PIXEL_FORMAT_I420; + if (frame->visible_rect().size() != options_.frame_size || !i420) { auto resized_frame = frame_pool_.CreateFrame( - is_yuv ? frame->format() : PIXEL_FORMAT_I420, options_.frame_size, - gfx::Rect(options_.frame_size), options_.frame_size, - frame->timestamp()); + PIXEL_FORMAT_I420, options_.frame_size, gfx::Rect(options_.frame_size), + options_.frame_size, frame->timestamp()); if (resized_frame) { Status conv_status = @@ -398,6 +398,15 @@ return; } + if (options.frame_size.width() > originally_configured_size_.width() || + options.frame_size.height() > originally_configured_size_.height()) { + auto status = EncoderStatus( + EncoderStatus::Codes::kEncoderUnsupportedConfig, + "libaom doesn't support dynamically increasing frame dimensions"); + std::move(done_cb).Run(std::move(status)); + return; + } + aom_codec_enc_cfg_t new_config = config_; aom_svc_params_t new_svc_params; if (auto status = SetUpAomConfig(options, new_config, new_svc_params);
diff --git a/media/video/av1_video_encoder.h b/media/video/av1_video_encoder.h index 01a5eed..4b672ba0 100644 --- a/media/video/av1_video_encoder.h +++ b/media/video/av1_video_encoder.h
@@ -57,6 +57,7 @@ // coming from real frames. aom_codec_pts_t artificial_timestamp_ = 0; + gfx::Size originally_configured_size_; base::TimeDelta last_frame_timestamp_; gfx::ColorSpace last_frame_color_space_; int temporal_svc_frame_index_ = 0;
diff --git a/net/cookies/cookie_access_delegate.cc b/net/cookies/cookie_access_delegate.cc index 2b7b6698..75c796d 100644 --- a/net/cookies/cookie_access_delegate.cc +++ b/net/cookies/cookie_access_delegate.cc
@@ -4,7 +4,11 @@ #include "net/cookies/cookie_access_delegate.h" +#include "base/callback.h" #include "base/stl_util.h" +#include "net/base/schemeful_site.h" +#include "net/cookies/cookie_partition_key.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -34,18 +38,22 @@ } // static -absl::optional<CookiePartitionKey> -CookieAccessDelegate::FirstPartySetifyPartitionKey( +void CookieAccessDelegate::FirstPartySetifyPartitionKey( const CookieAccessDelegate* delegate, - const CookiePartitionKey& cookie_partition_key) { - if (!delegate) - return cookie_partition_key; + const CookiePartitionKey& cookie_partition_key, + base::OnceCallback<void(absl::optional<CookiePartitionKey>)> callback) { + if (!delegate) { + std::move(callback).Run(cookie_partition_key); + return; + } absl::optional<SchemefulSite> fps_owner_site = delegate->FindFirstPartySetOwner(cookie_partition_key.site()); - if (!fps_owner_site) - return cookie_partition_key; - return CookiePartitionKey::FromWire(fps_owner_site.value(), - cookie_partition_key.nonce()); + if (!fps_owner_site) { + std::move(callback).Run(cookie_partition_key); + return; + } + std::move(callback).Run(CookiePartitionKey::FromWire( + fps_owner_site.value(), cookie_partition_key.nonce())); } } // namespace net
diff --git a/net/cookies/cookie_access_delegate.h b/net/cookies/cookie_access_delegate.h index 5007c3f1..7a56396 100644 --- a/net/cookies/cookie_access_delegate.h +++ b/net/cookies/cookie_access_delegate.h
@@ -76,9 +76,12 @@ // Converts the CookiePartitionKey's site to its First-Party Set owner if // the site is in a nontrivial set. - static absl::optional<CookiePartitionKey> FirstPartySetifyPartitionKey( + // + // May invoke `callback` either synchronously or asynchronously. + static void FirstPartySetifyPartitionKey( const CookieAccessDelegate* delegate, - const CookiePartitionKey& cookie_partition_key); + const CookiePartitionKey& cookie_partition_key, + base::OnceCallback<void(absl::optional<CookiePartitionKey>)> callback); // Computes the First-Party Sets. //
diff --git a/net/test/cert_builder.cc b/net/test/cert_builder.cc index de7e893..d5c1141 100644 --- a/net/test/cert_builder.cc +++ b/net/test/cert_builder.cc
@@ -86,6 +86,24 @@ : CertBuilder(orig_cert, issuer, /*unique_subject_key_identifier=*/true) {} // static +std::unique_ptr<CertBuilder> CertBuilder::FromFile( + const base::FilePath& cert_and_key_file, + CertBuilder* issuer) { + scoped_refptr<X509Certificate> cert = ImportCertFromFile(cert_and_key_file); + if (!cert) + return nullptr; + + bssl::UniquePtr<EVP_PKEY> private_key( + LoadPrivateKeyFromFile(cert_and_key_file)); + if (!private_key) + return nullptr; + + auto builder = base::WrapUnique(new CertBuilder(cert->cert_buffer(), issuer)); + builder->key_ = std::move(private_key); + return builder; +} + +// static std::unique_ptr<CertBuilder> CertBuilder::FromStaticCert(CRYPTO_BUFFER* cert, EVP_PKEY* key) { std::unique_ptr<CertBuilder> builder = base::WrapUnique( @@ -101,6 +119,21 @@ return builder; } +// static +std::unique_ptr<CertBuilder> CertBuilder::FromStaticCertFile( + const base::FilePath& cert_and_key_file) { + scoped_refptr<X509Certificate> cert = ImportCertFromFile(cert_and_key_file); + if (!cert) + return nullptr; + + bssl::UniquePtr<EVP_PKEY> private_key( + LoadPrivateKeyFromFile(cert_and_key_file)); + if (!private_key) + return nullptr; + + return CertBuilder::FromStaticCert(cert->cert_buffer(), private_key.get()); +} + CertBuilder::~CertBuilder() = default; // static
diff --git a/net/test/cert_builder.h b/net/test/cert_builder.h index b4f220f..8efb8b5 100644 --- a/net/test/cert_builder.h +++ b/net/test/cert_builder.h
@@ -19,6 +19,10 @@ class GURL; +namespace base { +class FilePath; +} + namespace net { namespace der { @@ -42,11 +46,23 @@ CertBuilder(CRYPTO_BUFFER* orig_cert, CertBuilder* issuer); ~CertBuilder(); + // Initializes a CertBuilder using the certificate and private key from + // |cert_and_key_file| as a template. If |issuer| is null then the generated + // certificate will be self-signed. Otherwise, it will be signed using + // |issuer|. + static std::unique_ptr<CertBuilder> FromFile( + const base::FilePath& cert_and_key_file, + CertBuilder* issuer); + // Creates a CertBuilder that will return a static |cert| and |key|. // This may be passed as the |issuer| param of another CertBuilder to create // a cert chain that ends in a pre-defined certificate. static std::unique_ptr<CertBuilder> FromStaticCert(CRYPTO_BUFFER* cert, EVP_PKEY* key); + // Like FromStaticCert, but loads the certificate and private key from the + // PEM file |cert_and_key_file|. + static std::unique_ptr<CertBuilder> FromStaticCertFile( + const base::FilePath& cert_and_key_file); // Creates a simple leaf->intermediate->root chain of CertBuilders with no AIA // or CrlDistributionPoint extensions, and leaf having a subjectAltName of
diff --git a/net/test/cert_test_util.cc b/net/test/cert_test_util.cc index 627e689..da16d54 100644 --- a/net/test/cert_test_util.cc +++ b/net/test/cert_test_util.cc
@@ -64,10 +64,8 @@ } scoped_refptr<X509Certificate> ImportCertFromFile( - const base::FilePath& certs_dir, - base::StringPiece cert_file) { + const base::FilePath& cert_path) { base::ScopedAllowBlockingForTesting allow_blocking; - base::FilePath cert_path = certs_dir.AppendASCII(cert_file); std::string cert_data; if (!base::ReadFileToString(cert_path, &cert_data)) return nullptr; @@ -81,6 +79,12 @@ return certs_in_file[0]; } +scoped_refptr<X509Certificate> ImportCertFromFile( + const base::FilePath& certs_dir, + base::StringPiece cert_file) { + return ImportCertFromFile(certs_dir.AppendASCII(cert_file)); +} + bssl::UniquePtr<EVP_PKEY> LoadPrivateKeyFromFile( const base::FilePath& key_path) { std::string key_string;
diff --git a/net/test/cert_test_util.h b/net/test/cert_test_util.h index 1bb8d539..5e9fcfee 100644 --- a/net/test/cert_test_util.h +++ b/net/test/cert_test_util.h
@@ -90,6 +90,12 @@ base::StringPiece cert_file, int format); +// Imports a single certificate from |cert_path|. +// If the file contains multiple certificates, the first certificate found +// will be returned. +scoped_refptr<X509Certificate> ImportCertFromFile( + const base::FilePath& cert_path); + // Imports a single certificate from |cert_file|. // |certs_dir| represents the test certificates directory. |cert_file| is the // name of the certificate file. If cert_file contains multiple certificates,
diff --git a/net/test/embedded_test_server/embedded_test_server.cc b/net/test/embedded_test_server/embedded_test_server.cc index 25c94d6..66380af48 100644 --- a/net/test/embedded_test_server/embedded_test_server.cc +++ b/net/test/embedded_test_server/embedded_test_server.cc
@@ -415,44 +415,27 @@ base::ScopedAllowBlockingForTesting allow_blocking; base::FilePath certs_dir(GetTestCertsDirectory()); - // Load root cert and key: - scoped_refptr<X509Certificate> root_cert = - ImportCertFromFile(certs_dir, "root_ca_cert.pem"); - if (!root_cert) - return false; - - bssl::UniquePtr<EVP_PKEY> root_private_key( - LoadPrivateKeyFromFile(certs_dir.AppendASCII("root_ca_cert.pem"))); - if (!root_private_key) - return false; - - std::unique_ptr<CertBuilder> static_root = CertBuilder::FromStaticCert( - root_cert->cert_buffer(), root_private_key.get()); + std::unique_ptr<CertBuilder> static_root = CertBuilder::FromStaticCertFile( + certs_dir.AppendASCII("root_ca_cert.pem")); // Will be nullptr if cert_config_.intermediate == kNone. std::unique_ptr<CertBuilder> intermediate; std::unique_ptr<CertBuilder> leaf; if (cert_config_.intermediate != IntermediateType::kNone) { - CertificateList orig_leaf_and_intermediate = CreateCertificateListFromFile( - certs_dir, "ok_cert_by_intermediate.pem", X509Certificate::FORMAT_AUTO); - if (orig_leaf_and_intermediate.size() != 2) + intermediate = CertBuilder::FromFile( + certs_dir.AppendASCII("intermediate_ca_cert.pem"), static_root.get()); + if (!intermediate) return false; - intermediate = std::make_unique<CertBuilder>( - orig_leaf_and_intermediate[1]->cert_buffer(), static_root.get()); - - leaf = std::make_unique<CertBuilder>( - orig_leaf_and_intermediate[0]->cert_buffer(), intermediate.get()); + leaf = CertBuilder::FromFile(certs_dir.AppendASCII("ok_cert.pem"), + intermediate.get()); } else { - scoped_refptr<X509Certificate> orig_leaf = - ImportCertFromFile(certs_dir, "ok_cert.pem"); - if (!orig_leaf) - return false; - - leaf = std::make_unique<CertBuilder>(orig_leaf->cert_buffer(), - static_root.get()); + leaf = CertBuilder::FromFile(certs_dir.AppendASCII("ok_cert.pem"), + static_root.get()); } + if (!leaf) + return false; std::vector<GURL> leaf_ca_issuers_urls; std::vector<GURL> leaf_ocsp_urls;
diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index afbb3ab..9639f915 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc
@@ -178,7 +178,7 @@ Permission current_required_permission = PERMISSION_DEV; #include "ppapi/thunk/interfaces_ppb_public_dev.h" } -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) { Permission current_required_permission = PERMISSION_PRIVATE; #include "ppapi/thunk/interfaces_ppb_private.h" @@ -191,7 +191,7 @@ Permission current_required_permission = PERMISSION_PDF; #include "ppapi/thunk/interfaces_ppb_private_pdf.h" } -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) { Permission current_required_permission = PERMISSION_DEV_CHANNEL; #include "ppapi/thunk/interfaces_ppb_public_dev_channel.h" @@ -249,7 +249,7 @@ AddPPB(PPB_VAR_INTERFACE_1_0, PPB_Var_Shared::GetVarInterface1_0(), PERMISSION_NONE); -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) // PPB (browser) interfaces. // Do not add more stuff here, they should be added to interface_list*.h // TODO(brettw) remove these. @@ -272,7 +272,7 @@ AddProxy(API_ID_PPP_INPUT_EVENT, &ProxyFactory<PPP_InputEvent_Proxy>); AddPPP(PPP_INPUT_EVENT_INTERFACE, PPP_InputEvent_Proxy::GetProxyInterface()); AddProxy(API_ID_PPP_INSTANCE, &ProxyFactory<PPP_Instance_Proxy>); -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) AddPPP(PPP_INSTANCE_INTERFACE_1_1, PPP_Instance_Proxy::GetInstanceInterface()); AddProxy(API_ID_PPP_INSTANCE_PRIVATE, @@ -287,7 +287,7 @@ AddPPP(PPP_PRINTING_DEV_INTERFACE, PPP_Printing_Proxy::GetProxyInterface()); AddProxy(API_ID_PPP_TEXT_INPUT, &ProxyFactory<PPP_TextInput_Proxy>); AddPPP(PPP_TEXTINPUT_DEV_INTERFACE, PPP_TextInput_Proxy::GetProxyInterface()); -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) AddProxy(API_ID_PPP_PDF, &ProxyFactory<PPP_Pdf_Proxy>); AddPPP(PPP_PDF_INTERFACE, PPP_Pdf_Proxy::GetProxyInterface()); AddProxy(API_ID_PPP_FIND_PRIVATE, &ProxyFactory<PPP_Find_Proxy>);
diff --git a/ppapi/proxy/nacl_message_scanner.cc b/ppapi/proxy/nacl_message_scanner.cc index 5b48060..c9801cc 100644 --- a/ppapi/proxy/nacl_message_scanner.cc +++ b/ppapi/proxy/nacl_message_scanner.cc
@@ -356,7 +356,7 @@ DCHECK(!new_msg_ptr->get()); bool rewrite_msg = -#if defined(OS_WIN) || defined(OS_MAC) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) true; #else false;
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 7a9c887..e9e2c47 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h
@@ -12,6 +12,7 @@ #include <vector> #include "base/sync_socket.h" +#include "build/build_config.h" #ifdef WIN32 // base/sync_socket.h will define MemoryBarrier (a Win32 macro) that @@ -627,13 +628,13 @@ std::string /* interface_name */, bool /* result */) -#if !defined(OS_NACL) && !defined(NACL_WIN64) +#if !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) // Network state notification from the browser for implementing // PPP_NetworkState_Dev. IPC_MESSAGE_CONTROL1(PpapiMsg_SetNetworkState, bool /* online */) -#endif // !defined(OS_NACL) && !defined(NACL_WIN64) +#endif // !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) // PPB_Audio. @@ -857,13 +858,13 @@ PP_Instance /* instance */, uint32_t /* desired_number_of_characters */) -#if !defined(OS_NACL) && !defined(NACL_WIN64) +#if !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) // PPP_Instance_Private. IPC_SYNC_MESSAGE_ROUTED1_1(PpapiMsg_PPPInstancePrivate_GetInstanceObject, PP_Instance /* instance */, ppapi::proxy::SerializedVar /* result */) -#endif // !defined(OS_NACL) && !defined(NACL_WIN64) +#endif // !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) // This message is sent from the renderer to the PNaCl compiler process // (NaCl untrusted code -- a nexe). This implements the init_callback() @@ -1188,7 +1189,7 @@ int64_t /* object_data */, ppapi::proxy::SerializedVar /* result */) -#if !defined(OS_NACL) && !defined(NACL_WIN64) +#if !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) // PPB_Buffer. IPC_SYNC_MESSAGE_ROUTED2_2( PpapiHostMsg_PPBBuffer_Create, @@ -1197,7 +1198,7 @@ ppapi::HostResource /* result_resource */, ppapi::proxy::SerializedHandle /* result_shm_handle */) -#endif // !defined(OS_NACL) && !defined(NACL_WIN64) +#endif // !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) // PPB_Testing. IPC_SYNC_MESSAGE_ROUTED3_1( @@ -1216,7 +1217,7 @@ PpapiHostMsg_PPBTesting_SetMinimumArrayBufferSizeForShmem, uint32_t /* threshold */) -#if !defined(OS_NACL) && !defined(NACL_WIN64) +#if !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) // PPB_VideoDecoder_Dev. // (Messages from plugin to renderer.) @@ -1271,7 +1272,7 @@ IPC_MESSAGE_ROUTED2(PpapiMsg_PPPVideoDecoder_NotifyError, ppapi::HostResource /* video_decoder */, PP_VideoDecodeError_Dev /* error */) -#endif // !defined(OS_NACL) && !defined(NACL_WIN64) +#endif // !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) //----------------------------------------------------------------------------- // Resource call/reply messages. @@ -1989,7 +1990,7 @@ int32_t /* error */) IPC_MESSAGE_CONTROL0(PpapiHostMsg_VideoEncoder_Close) -#if !defined(OS_NACL) && !defined(NACL_WIN64) +#if !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) // Audio input. IPC_MESSAGE_CONTROL0(PpapiHostMsg_AudioInput_Create) @@ -2171,6 +2172,6 @@ IPC_MESSAGE_CONTROL1(PpapiPluginMsg_VideoCapture_OnBufferReady, uint32_t /* buffer */) -#endif // !defined(OS_NACL) && !defined(NACL_WIN64) +#endif // !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) #endif // PPAPI_PROXY_PPAPI_MESSAGES_H_
diff --git a/ppapi/proxy/ppapi_param_traits.cc b/ppapi/proxy/ppapi_param_traits.cc index d65410b..cdd45eb 100644 --- a/ppapi/proxy/ppapi_param_traits.cc +++ b/ppapi/proxy/ppapi_param_traits.cc
@@ -320,7 +320,7 @@ std::string* l) { } -#if !defined(OS_NACL) && !defined(NACL_WIN64) +#if !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) // PPBFlash_DrawGlyphs_Params -------------------------------------------------- // static void ParamTraits<ppapi::proxy::PPBFlash_DrawGlyphs_Params>::Write( @@ -431,9 +431,9 @@ const param_type& p, std::string* l) { } -#endif // !defined(OS_NACL) && !defined(NACL_WIN64) +#endif // !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) -#if !defined(OS_NACL) && !defined(NACL_WIN64) +#if !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) // ppapi::PepperFilePath ------------------------------------------------------- // static @@ -469,7 +469,7 @@ l->append(")"); } -#endif // !defined(OS_NACL) && !defined(NACL_WIN64) +#endif // !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) // PPB_X509Certificate_Fields --------------------------------------------------
diff --git a/ppapi/proxy/ppapi_param_traits.h b/ppapi/proxy/ppapi_param_traits.h index 24b6e8e..de638ec9 100644 --- a/ppapi/proxy/ppapi_param_traits.h +++ b/ppapi/proxy/ppapi_param_traits.h
@@ -155,7 +155,7 @@ static void Log(const param_type& p, std::string* l); }; -#if !defined(OS_NACL) && !defined(NACL_WIN64) +#if !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) template <> struct ParamTraits<ppapi::PepperFilePath> { typedef ppapi::PepperFilePath param_type; @@ -166,7 +166,7 @@ static void Log(const param_type& p, std::string* l); }; -#endif // !defined(OS_NACL) && !defined(NACL_WIN64) +#endif // !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) template<> struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::PPB_X509Certificate_Fields> {
diff --git a/ppapi/proxy/ppb_audio_proxy.cc b/ppapi/proxy/ppb_audio_proxy.cc index eb9bc87..62cb8c3 100644 --- a/ppapi/proxy/ppb_audio_proxy.cc +++ b/ppapi/proxy/ppb_audio_proxy.cc
@@ -74,7 +74,7 @@ } Audio::~Audio() { -#if defined(OS_NACL) +#if BUILDFLAG(IS_NACL) // Invoke StopPlayback() to ensure audio back-end has a chance to send the // escape value over the sync socket, which will terminate the client side // audio callback loop. This is required for NaCl Plugins that can't escape @@ -170,7 +170,7 @@ bool handled = true; IPC_BEGIN_MESSAGE_MAP(PPB_Audio_Proxy, msg) // Don't build host side into NaCl IRT. -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBAudio_Create, OnMsgCreate) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBAudio_StartOrStop, OnMsgStartOrStop) @@ -182,7 +182,7 @@ return handled; } -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) void PPB_Audio_Proxy::OnMsgCreate(PP_Instance instance_id, int32_t sample_rate, uint32_t sample_frame_count, @@ -307,7 +307,7 @@ return PP_OK; } -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) // Processed in the plugin (message from host). void PPB_Audio_Proxy::OnMsgNotifyAudioStreamCreated(
diff --git a/ppapi/proxy/ppb_core_proxy.cc b/ppapi/proxy/ppb_core_proxy.cc index f0dc3668..20bc81a 100644 --- a/ppapi/proxy/ppb_core_proxy.cc +++ b/ppapi/proxy/ppb_core_proxy.cc
@@ -56,7 +56,7 @@ PP_CompletionCallback callback, int32_t result) { DCHECK(callback.func); -#if defined(OS_NACL) +#if BUILDFLAG(IS_NACL) // Some NaCl apps pass a negative delay, so we just sanitize to 0, to run as // soon as possible. MessageLoop checks that the delay is non-negative. if (delay_in_ms < 0) @@ -112,7 +112,7 @@ } bool PPB_Core_Proxy::OnMessageReceived(const IPC::Message& msg) { -#if defined(OS_NACL) +#if BUILDFLAG(IS_NACL) return false; #else bool handled = true; @@ -128,7 +128,7 @@ #endif } -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) void PPB_Core_Proxy::OnMsgAddRefResource(const HostResource& resource) { ppb_core_impl_->AddRefResource(resource.host_resource()); } @@ -136,7 +136,7 @@ void PPB_Core_Proxy::OnMsgReleaseResource(const HostResource& resource) { ppb_core_impl_->ReleaseResource(resource.host_resource()); } -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) } // namespace proxy } // namespace ppapi
diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.cc b/ppapi/proxy/ppb_graphics_3d_proxy.cc index 8b138ef..854b91e9 100644 --- a/ppapi/proxy/ppb_graphics_3d_proxy.cc +++ b/ppapi/proxy/ppb_graphics_3d_proxy.cc
@@ -30,13 +30,13 @@ namespace { -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) base::UnsafeSharedMemoryRegion TransportSHMHandle( Dispatcher* dispatcher, const base::UnsafeSharedMemoryRegion& region) { return dispatcher->ShareUnsafeSharedMemoryRegionWithRemote(region); } -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) gpu::CommandBuffer::State GetErrorState() { gpu::CommandBuffer::State error_state; @@ -256,7 +256,7 @@ bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PPB_Graphics3D_Proxy, msg) -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_Create, OnMsgCreate) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_SetGetBuffer, @@ -276,7 +276,7 @@ OnMsgTakeFrontBuffer) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_EnsureWorkVisible, OnMsgEnsureWorkVisible) -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics3D_SwapBuffersACK, OnMsgSwapBuffersACK) @@ -287,7 +287,7 @@ return handled; } -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) void PPB_Graphics3D_Proxy::OnMsgCreate( PP_Instance instance, HostResource share_context, @@ -414,7 +414,7 @@ if (enter.succeeded()) enter.object()->EnsureWorkVisible(); } -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) void PPB_Graphics3D_Proxy::OnMsgSwapBuffersACK(const HostResource& resource, int32_t pp_error) { @@ -423,14 +423,14 @@ static_cast<Graphics3D*>(enter.object())->SwapBuffersACK(pp_error); } -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( int32_t result, const HostResource& context) { dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( API_ID_PPB_GRAPHICS_3D, context, result)); } -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) } // namespace proxy } // namespace ppapi
diff --git a/ppapi/proxy/ppb_image_data_proxy.cc b/ppapi/proxy/ppb_image_data_proxy.cc index a793283..8f656e3 100644 --- a/ppapi/proxy/ppb_image_data_proxy.cc +++ b/ppapi/proxy/ppb_image_data_proxy.cc
@@ -31,7 +31,7 @@ #include "ppapi/thunk/enter.h" #include "ppapi/thunk/thunk.h" -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) #include "skia/ext/platform_canvas.h" #include "ui/surface/transport_dib.h" #endif @@ -370,17 +370,17 @@ // PlatformImageData ----------------------------------------------------------- -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) PlatformImageData::PlatformImageData( const HostResource& resource, const PP_ImageDataDesc& desc, base::UnsafeSharedMemoryRegion image_region) : ImageData(resource, PPB_ImageData_Shared::PLATFORM, desc) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) transport_dib_ = TransportDIB::CreateWithHandle(std::move(image_region)); #else transport_dib_ = TransportDIB::Map(std::move(image_region)); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) } PlatformImageData::~PlatformImageData() = default; @@ -410,7 +410,7 @@ SkCanvas* PlatformImageData::GetCanvas() { return mapped_canvas_.get(); } -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) // SimpleImageData ------------------------------------------------------------- @@ -489,7 +489,7 @@ break; } case PPB_ImageData_Shared::PLATFORM: { -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) ppapi::proxy::SerializedHandle image_handle; dispatcher->Send(new PpapiHostMsg_PPBImageData_CreatePlatform( kApiID, instance, format, size, init_to_zero, &result, &desc, @@ -517,7 +517,7 @@ bool PPB_ImageData_Proxy::OnMessageReceived(const IPC::Message& msg) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PPB_ImageData_Proxy, msg) -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBImageData_CreatePlatform, OnHostMsgCreatePlatform) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBImageData_CreateSimple, @@ -531,7 +531,7 @@ return handled; } -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) // static PP_Resource PPB_ImageData_Proxy::CreateImageData( PP_Instance instance, @@ -639,7 +639,7 @@ result_image_handle->set_null_shmem_region(); } } -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) void PPB_ImageData_Proxy::OnPluginMsgNotifyUnusedImageData( const HostResource& old_image_data) {
diff --git a/ppapi/proxy/ppb_image_data_proxy.h b/ppapi/proxy/ppb_image_data_proxy.h index 3bcf57a4..2980dce5 100644 --- a/ppapi/proxy/ppb_image_data_proxy.h +++ b/ppapi/proxy/ppb_image_data_proxy.h
@@ -27,9 +27,9 @@ #include "ppapi/shared_impl/resource.h" #include "ppapi/thunk/ppb_image_data_api.h" -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) #include "third_party/skia/include/core/SkRefCnt.h" -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) class TransportDIB; @@ -83,7 +83,7 @@ // PlatformImageData is a full featured image data resource which can access // the underlying platform-specific canvas and |image_region|. This can't be // used by NaCl apps. -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) class PPAPI_PROXY_EXPORT PlatformImageData : public ImageData { public: PlatformImageData(const ppapi::HostResource& resource, @@ -106,7 +106,7 @@ // Null when the image isn't mapped. std::unique_ptr<SkCanvas> mapped_canvas_; }; -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) // SimpleImageData is a simple, platform-independent image data resource which // can be used by NaCl. It can also be used by trusted apps when access to the
diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc index 9bd064e..dae79cd 100644 --- a/ppapi/proxy/ppb_instance_proxy.cc +++ b/ppapi/proxy/ppb_instance_proxy.cc
@@ -58,7 +58,7 @@ namespace { -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) const char kSerializationError[] = "Failed to convert a PostMessage " "argument from a PP_Var to a Javascript value. It may have cycles or be of " "an unsupported type."; @@ -100,13 +100,13 @@ // This must happen OUTSIDE of ExecuteScript since the SerializedVars use // the dispatcher upon return of the function (converting the // SerializedVarReturnValue/OutParam to a SerializedVar in the destructor). -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) ScopedModuleReference death_grip(dispatcher()); #endif bool handled = true; IPC_BEGIN_MESSAGE_MAP(PPB_Instance_Proxy, msg) -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) // Plugin -> Host messages. IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetWindowObject, OnHostMsgGetWindowObject) @@ -170,7 +170,7 @@ OnHostMsgGetPluginInstanceURL) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginReferrerURL, OnHostMsgGetPluginReferrerURL) -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) // Host -> Plugin messages. IPC_MESSAGE_HANDLER(PpapiMsg_PPBInstance_MouseLockComplete, @@ -358,7 +358,7 @@ new_singleton = new UMAPrivateResource(connection, instance); break; // Flash/trusted resources aren't needed for NaCl. -#if !defined(OS_NACL) && !defined(NACL_WIN64) +#if !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) case BROWSER_FONT_SINGLETON_ID: new_singleton = new BrowserFontSingletonResource(connection, instance); break; @@ -374,7 +374,7 @@ case PDF_SINGLETON_ID: NOTREACHED(); break; -#endif // !defined(OS_NACL) && !defined(NACL_WIN64) +#endif // !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) } if (!new_singleton.get()) { @@ -427,7 +427,7 @@ return result.Return(dispatcher()); } -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) PP_Var PPB_Instance_Proxy::ResolveRelativeToDocument( PP_Instance instance, PP_Var relative, @@ -481,7 +481,7 @@ result.Return(dispatcher()), components); } -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) void PPB_Instance_Proxy::PostMessage(PP_Instance instance, PP_Var message) { @@ -618,7 +618,7 @@ API_ID_PPB_INSTANCE, instance, text, caret, anchor)); } -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) void PPB_Instance_Proxy::OnHostMsgGetWindowObject( PP_Instance instance, SerializedVarReturnValue result) { @@ -941,7 +941,7 @@ anchor); } } -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance, int32_t result) { @@ -960,13 +960,13 @@ data->mouse_lock_callback->Run(result); } -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, PP_Instance instance) { dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( API_ID_PPB_INSTANCE, instance, result)); } -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) void PPB_Instance_Proxy::CancelAnyPendingRequestSurroundingText( PP_Instance instance) {
diff --git a/ppapi/proxy/ppb_instance_proxy.h b/ppapi/proxy/ppb_instance_proxy.h index a84b4872..975eeb6 100644 --- a/ppapi/proxy/ppb_instance_proxy.h +++ b/ppapi/proxy/ppb_instance_proxy.h
@@ -99,7 +99,7 @@ uint32_t anchor) override; PP_Var GetDocumentURL(PP_Instance instance, PP_URLComponents_Dev* components) override; -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) PP_Var ResolveRelativeToDocument(PP_Instance instance, PP_Var relative, PP_URLComponents_Dev* components) override; @@ -110,7 +110,7 @@ PP_URLComponents_Dev* components) override; PP_Var GetPluginReferrerURL(PP_Instance instance, PP_URLComponents_Dev* components) override; -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) static const ApiID kApiID = API_ID_PPB_INSTANCE; @@ -174,7 +174,7 @@ PP_URLComponents_Dev* components, SerializedVarReturnValue result); -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) void OnHostMsgResolveRelativeToDocument(PP_Instance instance, SerializedVarReceiveInput relative, SerializedVarReturnValue result); @@ -188,7 +188,7 @@ SerializedVarReturnValue result); void OnHostMsgGetPluginReferrerURL(PP_Instance instance, SerializedVarReturnValue result); -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) // Host -> Plugin message handlers. void OnPluginMsgMouseLockComplete(PP_Instance instance, int32_t result);
diff --git a/ppapi/proxy/ppp_find_proxy.cc b/ppapi/proxy/ppp_find_proxy.cc index c5d62b7..62dee56 100644 --- a/ppapi/proxy/ppp_find_proxy.cc +++ b/ppapi/proxy/ppp_find_proxy.cc
@@ -15,7 +15,7 @@ namespace { -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) PP_Bool StartFind(PP_Instance instance, const char* text, PP_Bool case_sensitive) {
diff --git a/ppapi/proxy/ppp_graphics_3d_proxy.cc b/ppapi/proxy/ppp_graphics_3d_proxy.cc index 50f7fe56a..3448c1d 100644 --- a/ppapi/proxy/ppp_graphics_3d_proxy.cc +++ b/ppapi/proxy/ppp_graphics_3d_proxy.cc
@@ -16,7 +16,7 @@ namespace { -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) void ContextLost(PP_Instance instance) { HostDispatcher::GetForInstance(instance)->Send( new PpapiMsg_PPPGraphics3D_ContextLost(API_ID_PPP_GRAPHICS_3D, instance)); @@ -28,7 +28,7 @@ #else // The NaCl plugin doesn't need the host side interface - stub it out. static const PPP_Graphics3D graphics_3d_interface = {}; -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) } // namespace
diff --git a/ppapi/proxy/ppp_input_event_proxy.cc b/ppapi/proxy/ppp_input_event_proxy.cc index b256a2b..a44e366 100644 --- a/ppapi/proxy/ppp_input_event_proxy.cc +++ b/ppapi/proxy/ppp_input_event_proxy.cc
@@ -21,7 +21,7 @@ namespace { -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) PP_Bool HandleInputEvent(PP_Instance instance, PP_Resource input_event) { EnterResourceNoLock<PPB_InputEvent_API> enter(input_event, false); if (enter.failed()) { @@ -53,7 +53,7 @@ #else // The NaCl plugin doesn't need the host side interface - stub it out. static const PPP_InputEvent input_event_interface = {}; -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) } // namespace
diff --git a/ppapi/proxy/ppp_instance_proxy.cc b/ppapi/proxy/ppp_instance_proxy.cc index 6809295..0e63fc11 100644 --- a/ppapi/proxy/ppp_instance_proxy.cc +++ b/ppapi/proxy/ppp_instance_proxy.cc
@@ -42,7 +42,7 @@ namespace { -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) PP_Bool DidCreate(PP_Instance instance, uint32_t argc, const char* argn[], @@ -102,7 +102,7 @@ &DidChangeFocus, &HandleDocumentLoad }; -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) } // namespace @@ -126,12 +126,12 @@ PPP_Instance_Proxy::~PPP_Instance_Proxy() { } -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) // static const PPP_Instance* PPP_Instance_Proxy::GetInstanceInterface() { return &instance_interface; } -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) bool PPP_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { if (!dispatcher()->IsPlugin()) @@ -210,11 +210,11 @@ return; data->view = new_data; -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) EnterInstanceAPINoLock<PPB_Flash_Fullscreen_API> enter(instance); if (!enter.failed()) enter.functions()->SetLocalIsFullscreen(instance, flash_fullscreen); -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) ScopedPPResource resource( ScopedPPResource::PassRef(),
diff --git a/ppapi/proxy/ppp_mouse_lock_proxy.cc b/ppapi/proxy/ppp_mouse_lock_proxy.cc index 30aadce..df16a68 100644 --- a/ppapi/proxy/ppp_mouse_lock_proxy.cc +++ b/ppapi/proxy/ppp_mouse_lock_proxy.cc
@@ -15,7 +15,7 @@ namespace { -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) void MouseLockLost(PP_Instance instance) { HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); if (!dispatcher) { @@ -34,7 +34,7 @@ #else // The NaCl plugin doesn't need the host side interface - stub it out. static const PPP_MouseLock mouse_lock_interface = {}; -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) } // namespace
diff --git a/ppapi/proxy/ppp_pdf_proxy.cc b/ppapi/proxy/ppp_pdf_proxy.cc index cffbaad9..707c99a 100644 --- a/ppapi/proxy/ppp_pdf_proxy.cc +++ b/ppapi/proxy/ppp_pdf_proxy.cc
@@ -14,7 +14,7 @@ namespace { -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { // This isn't implemented in the out of process case. return PP_MakeUndefined();
diff --git a/ppapi/proxy/ppp_printing_proxy.cc b/ppapi/proxy/ppp_printing_proxy.cc index c5a2919..988d2df 100644 --- a/ppapi/proxy/ppp_printing_proxy.cc +++ b/ppapi/proxy/ppp_printing_proxy.cc
@@ -22,7 +22,7 @@ namespace { -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) bool HasPrintingPermission(PP_Instance instance) { Dispatcher* dispatcher = HostDispatcher::GetForInstance(instance); if (!dispatcher) @@ -99,7 +99,7 @@ #else // The NaCl plugin doesn't need the host side interface - stub it out. static const PPP_Printing_Dev ppp_printing_interface = {}; -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) } // namespace
diff --git a/ppapi/proxy/ppp_text_input_proxy.cc b/ppapi/proxy/ppp_text_input_proxy.cc index 235e0e0..8a45efe 100644 --- a/ppapi/proxy/ppp_text_input_proxy.cc +++ b/ppapi/proxy/ppp_text_input_proxy.cc
@@ -15,7 +15,7 @@ namespace { -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) void RequestSurroundingText(PP_Instance instance, uint32_t desired_number_of_characters) { proxy::HostDispatcher* dispatcher = @@ -36,7 +36,7 @@ #else // The NaCl plugin doesn't need the host side interface - stub it out. static const PPP_TextInput_Dev g_ppp_text_input_thunk = {}; -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) } // namespace
diff --git a/ppapi/proxy/proxy_channel.cc b/ppapi/proxy/proxy_channel.cc index 6881cd0..351bc44 100644 --- a/ppapi/proxy/proxy_channel.cc +++ b/ppapi/proxy/proxy_channel.cc
@@ -9,7 +9,7 @@ #include "ipc/ipc_platform_file.h" #include "ipc/ipc_sender.h" -#if defined(OS_NACL) +#if BUILDFLAG(IS_NACL) #include <unistd.h> #endif @@ -47,7 +47,7 @@ void ProxyChannel::InitWithTestSink(IPC::Sender* sender) { DCHECK(!test_sink_); test_sink_ = sender; -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) peer_pid_ = base::GetCurrentProcId(); #endif }
diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index aed077b..380fad4 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc
@@ -266,7 +266,7 @@ // On the plugin side, we create PlatformImageData resources for trusted // plugins and SimpleImageData resources for untrusted ones. PPB_ImageData_Shared::ImageDataType type = -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) PPB_ImageData_Shared::PLATFORM; #else PPB_ImageData_Shared::SIMPLE; @@ -375,7 +375,7 @@ return (new WebSocketResource(GetConnection(), instance))->GetReference(); } -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) PP_Resource ResourceCreationProxy::CreateX509CertificatePrivate( PP_Instance instance) { return PPB_X509Certificate_Private_Proxy::CreateProxyResource(instance); @@ -429,7 +429,7 @@ instance, context3d_id, profile); } -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) bool ResourceCreationProxy::Send(IPC::Message* msg) { return dispatcher()->Send(msg);
diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h index a7c3a219..f98bc14 100644 --- a/ppapi/proxy/resource_creation_proxy.h +++ b/ppapi/proxy/resource_creation_proxy.h
@@ -153,7 +153,7 @@ PP_Resource CreateVideoEncoder(PP_Instance instance) override; PP_Resource CreateVpnProvider(PP_Instance instance) override; PP_Resource CreateWebSocket(PP_Instance instance) override; -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) PP_Resource CreateX509CertificatePrivate(PP_Instance instance) override; PP_Resource CreateAudioInput(PP_Instance instance) override; PP_Resource CreateAudioOutput(PP_Instance instance) override; @@ -170,7 +170,7 @@ PP_Instance instance, PP_Resource context3d_id, PP_VideoDecoder_Profile profile) override; -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) bool Send(IPC::Message* msg) override; bool OnMessageReceived(const IPC::Message& msg) override;
diff --git a/ppapi/proxy/serialized_handle.cc b/ppapi/proxy/serialized_handle.cc index b394aa4..15b7f44 100644 --- a/ppapi/proxy/serialized_handle.cc +++ b/ppapi/proxy/serialized_handle.cc
@@ -11,7 +11,7 @@ #include "build/build_config.h" #include "ipc/ipc_platform_file.h" -#if defined(OS_NACL) +#if BUILDFLAG(IS_NACL) #include <unistd.h> #endif
diff --git a/ppapi/proxy/video_decoder_resource_unittest.cc b/ppapi/proxy/video_decoder_resource_unittest.cc index 3d4e082..fbfc86c 100644 --- a/ppapi/proxy/video_decoder_resource_unittest.cc +++ b/ppapi/proxy/video_decoder_resource_unittest.cc
@@ -33,7 +33,7 @@ const size_t kDecodeBufferSize = 16; const uint32_t kDecodeId = 5; const uint32_t kTextureId1 = 1; -#if !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS) +#if !BUILDFLAG(IS_WIN) || !defined(ARCH_CPU_64_BITS) const uint32_t kTextureId2 = 2; #endif const uint32_t kNumRequestedTextures = 2; @@ -383,7 +383,7 @@ // TODO(bbudge) Fix sync message testing on Windows 64 bit builds. The reply // message for GetShm isn't received, causing Decode to fail. // http://crbug.com/379260 -#if !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS) +#if !BUILDFLAG(IS_WIN) || !defined(ARCH_CPU_64_BITS) TEST_F(VideoDecoderResourceTest, DecodeAndGetPicture) { LockingResourceReleaser decoder(CreateAndInitializeDecoder()); ResourceMessageCallParams params, params2; @@ -449,12 +449,12 @@ ASSERT_FALSE(uncalled_cb.called()); ASSERT_EQ(kDecodeId, picture.decode_id); } -#endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS) +#endif // !BUILDFLAG(IS_WIN) || !defined(ARCH_CPU_64_BITS) // TODO(bbudge) Fix sync message testing on Windows 64 bit builds. The reply // message for GetShm isn't received, causing Decode to fail. // http://crbug.com/379260 -#if !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS) +#if !BUILDFLAG(IS_WIN) || !defined(ARCH_CPU_64_BITS) TEST_F(VideoDecoderResourceTest, RecyclePicture) { LockingResourceReleaser decoder(CreateAndInitializeDecoder()); ResourceMessageCallParams params; @@ -485,7 +485,7 @@ ClearCallbacks(decoder.get()); } -#endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS) +#endif // !BUILDFLAG(IS_WIN) || !defined(ARCH_CPU_64_BITS) TEST_F(VideoDecoderResourceTest, Flush) { LockingResourceReleaser decoder(CreateAndInitializeDecoder()); @@ -531,7 +531,7 @@ // TODO(bbudge) Fix sync message testing on Windows 64 bit builds. The reply // message for GetShm isn't received, causing Decode to fail. // http://crbug.com/379260 -#if !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS) +#if !BUILDFLAG(IS_WIN) || !defined(ARCH_CPU_64_BITS) TEST_F(VideoDecoderResourceTest, NotifyError) { LockingResourceReleaser decoder(CreateAndInitializeDecoder()); ResourceMessageCallParams params; @@ -569,7 +569,7 @@ ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallReset(decoder.get(), &uncalled_cb)); ASSERT_FALSE(uncalled_cb.called()); } -#endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS) +#endif // !BUILDFLAG(IS_WIN) || !defined(ARCH_CPU_64_BITS) } // namespace proxy } // namespace ppapi
diff --git a/ppapi/shared_impl/file_ref_create_info.cc b/ppapi/shared_impl/file_ref_create_info.cc index 95059c9..933ce511 100644 --- a/ppapi/shared_impl/file_ref_create_info.cc +++ b/ppapi/shared_impl/file_ref_create_info.cc
@@ -19,9 +19,9 @@ const base::FilePath::StringType& path = in_path.value(); size_t pos = path.rfind(base::FilePath::kSeparators[0]); CHECK(pos != base::FilePath::StringType::npos); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return base::WideToUTF8(path.substr(pos + 1)); -#elif defined(OS_POSIX) +#elif BUILDFLAG(IS_POSIX) return path.substr(pos + 1); #else #error "Unsupported platform."
diff --git a/ppapi/shared_impl/file_ref_util.cc b/ppapi/shared_impl/file_ref_util.cc index a517b3f..3976e4f 100644 --- a/ppapi/shared_impl/file_ref_util.cc +++ b/ppapi/shared_impl/file_ref_util.cc
@@ -25,9 +25,9 @@ const base::FilePath::StringType& file_path = path.value(); size_t pos = file_path.rfind(base::FilePath::kSeparators[0]); CHECK(pos != base::FilePath::StringType::npos); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return base::WideToUTF8(file_path.substr(pos + 1)); -#elif defined(OS_POSIX) +#elif BUILDFLAG(IS_POSIX) return file_path.substr(pos + 1); #else #error "Unsupported platform."
diff --git a/ppapi/shared_impl/platform_file.cc b/ppapi/shared_impl/platform_file.cc index 68afe97..ca97a6d 100644 --- a/ppapi/shared_impl/platform_file.cc +++ b/ppapi/shared_impl/platform_file.cc
@@ -10,9 +10,9 @@ // TODO(piman/brettw): Change trusted interface to return a PP_FileHandle, // those casts are ugly. base::PlatformFile IntToPlatformFile(int32_t handle) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return reinterpret_cast<HANDLE>(static_cast<intptr_t>(handle)); -#elif defined(OS_POSIX) +#elif BUILDFLAG(IS_POSIX) return handle; #else #error Not implemented. @@ -20,9 +20,9 @@ } int32_t PlatformFileToInt(base::PlatformFile handle) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return static_cast<int32_t>(reinterpret_cast<intptr_t>(handle)); -#elif defined(OS_POSIX) +#elif BUILDFLAG(IS_POSIX) return handle; #else #error Not implemented.
diff --git a/ppapi/shared_impl/ppapi_constants.h b/ppapi/shared_impl/ppapi_constants.h index 1aa54b1..528dfe2 100644 --- a/ppapi/shared_impl/ppapi_constants.h +++ b/ppapi/shared_impl/ppapi_constants.h
@@ -10,11 +10,11 @@ namespace ppapi { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) const char kCorbTestPluginName[] = "corb_test_plugin.dll"; -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) const char kCorbTestPluginName[] = "corb_test_plugin.plugin"; -#elif defined(OS_POSIX) +#elif BUILDFLAG(IS_POSIX) const char kCorbTestPluginName[] = "libcorb_test_plugin.so"; #endif
diff --git a/ppapi/shared_impl/ppapi_permissions.cc b/ppapi/shared_impl/ppapi_permissions.cc index ec223030..c48b8b5e 100644 --- a/ppapi/shared_impl/ppapi_permissions.cc +++ b/ppapi/shared_impl/ppapi_permissions.cc
@@ -26,7 +26,7 @@ PpapiPermissions PpapiPermissions::GetForCommandLine(uint32_t base_perms) { uint32_t additional_permissions = 0; -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) // Testing permissions. The testing flag implies all permissions since the // test plugin needs to test all interfaces. if (base::CommandLine::ForCurrentProcess()->HasSwitch(
diff --git a/ppapi/shared_impl/ppb_image_data_shared.cc b/ppapi/shared_impl/ppb_image_data_shared.cc index 0bfd740..b59cb8f 100644 --- a/ppapi/shared_impl/ppb_image_data_shared.cc +++ b/ppapi/shared_impl/ppb_image_data_shared.cc
@@ -7,7 +7,7 @@ #include "base/notreached.h" #include "build/build_config.h" -#if !defined(OS_NACL) && !defined(NACL_WIN64) +#if !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) #include "third_party/skia/include/core/SkTypes.h" #endif @@ -15,7 +15,7 @@ // static PP_ImageDataFormat PPB_ImageData_Shared::GetNativeImageDataFormat() { -#if defined(OS_NACL) +#if BUILDFLAG(IS_NACL) // In NaCl, just default to something. If we're wrong, it will be converted // later. // TODO(dmichael): Really proxy this.
diff --git a/ppapi/shared_impl/private/net_address_private_impl.cc b/ppapi/shared_impl/private/net_address_private_impl.cc index 8868ead..8930e480 100644 --- a/ppapi/shared_impl/private/net_address_private_impl.cc +++ b/ppapi/shared_impl/private/net_address_private_impl.cc
@@ -18,11 +18,11 @@ #include "ppapi/shared_impl/var.h" #include "ppapi/thunk/thunk.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <windows.h> #include <winsock2.h> #include <ws2tcpip.h> -#elif defined(OS_POSIX) && !defined(OS_NACL) +#elif BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_NACL) #include <arpa/inet.h> #include <netinet/in.h> #include <sys/socket.h> @@ -389,7 +389,7 @@ } // namespace thunk // For the NaCl target, all we need are the API functions and the thunk. -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) // static bool NetAddressPrivateImpl::ValidateNetAddress( @@ -484,7 +484,7 @@ address->Assign(net_addr->address, address_size); return true; } -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) // static std::string NetAddressPrivateImpl::DescribeNetAddress(
diff --git a/ppapi/shared_impl/private/net_address_private_impl_constants.cc b/ppapi/shared_impl/private/net_address_private_impl_constants.cc index 46e7686b..58193c0 100644 --- a/ppapi/shared_impl/private/net_address_private_impl_constants.cc +++ b/ppapi/shared_impl/private/net_address_private_impl_constants.cc
@@ -9,9 +9,9 @@ namespace ppapi { -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) // static const PP_NetAddress_Private NetAddressPrivateImpl::kInvalidNetAddress = { 0 }; -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) } // namespace ppapi
diff --git a/ppapi/thunk/interfaces_ppb_private.h b/ppapi/thunk/interfaces_ppb_private.h index 49827d5c..2d59bf3 100644 --- a/ppapi/thunk/interfaces_ppb_private.h +++ b/ppapi/thunk/interfaces_ppb_private.h
@@ -14,7 +14,7 @@ PROXIED_API(PPB_X509Certificate_Private) -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) PROXIED_IFACE(PPB_X509CERTIFICATE_PRIVATE_INTERFACE_0_1, PPB_X509Certificate_Private_0_1) PROXIED_IFACE(PPB_BROWSERFONT_TRUSTED_INTERFACE_1_0, @@ -27,6 +27,6 @@ PPB_FileChooserTrusted_0_6) PROXIED_IFACE(PPB_FILEREFPRIVATE_INTERFACE_0_1, PPB_FileRefPrivate_0_1) -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) #include "ppapi/thunk/interfaces_postamble.h"
diff --git a/ppapi/thunk/interfaces_ppb_private_pdf.h b/ppapi/thunk/interfaces_ppb_private_pdf.h index f28dcaf4..efe5645 100644 --- a/ppapi/thunk/interfaces_ppb_private_pdf.h +++ b/ppapi/thunk/interfaces_ppb_private_pdf.h
@@ -7,13 +7,14 @@ // no-include-guard-because-multiply-included +#include "build/build_config.h" #include "ppapi/thunk/interfaces_preamble.h" // See interfaces_ppb_private_no_permissions.h for other private interfaces. -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) PROXIED_IFACE(PPB_PDF_INTERFACE, PPB_PDF) PROXIED_IFACE(PPB_FIND_PRIVATE_INTERFACE_0_3, PPB_Find_Private_0_3) -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) #include "ppapi/thunk/interfaces_postamble.h"
diff --git a/ppapi/thunk/interfaces_ppb_public_dev.h b/ppapi/thunk/interfaces_ppb_public_dev.h index 7d452e6..3459ed7 100644 --- a/ppapi/thunk/interfaces_ppb_public_dev.h +++ b/ppapi/thunk/interfaces_ppb_public_dev.h
@@ -8,6 +8,7 @@ // no-include-guard-because-multiply-included // NOLINT(build/header_guard) +#include "build/build_config.h" #include "ppapi/thunk/interfaces_preamble.h" // Map the old dev console interface to the stable one (which is the same) to @@ -22,7 +23,7 @@ PROXIED_IFACE(PPB_TEXTINPUT_DEV_INTERFACE_0_2, PPB_TextInput_Dev_0_2) PROXIED_IFACE(PPB_VIEW_DEV_INTERFACE_0_1, PPB_View_Dev_0_1) -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) PROXIED_API(PPB_Buffer) PROXIED_API(PPB_VideoDecoder) @@ -41,6 +42,6 @@ PROXIED_IFACE(PPB_URLUTIL_DEV_INTERFACE_0_7, PPB_URLUtil_Dev_0_7) PROXIED_IFACE(PPB_VIDEOCAPTURE_DEV_INTERFACE_0_3, PPB_VideoCapture_Dev_0_3) PROXIED_IFACE(PPB_VIDEODECODER_DEV_INTERFACE_0_16, PPB_VideoDecoder_Dev_0_16) -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) #include "ppapi/thunk/interfaces_postamble.h"
diff --git a/ppapi/thunk/ppb_instance_api.h b/ppapi/thunk/ppb_instance_api.h index 157dc86..7949435 100644 --- a/ppapi/thunk/ppb_instance_api.h +++ b/ppapi/thunk/ppb_instance_api.h
@@ -140,7 +140,7 @@ // Testing and URLUtil. virtual PP_Var GetDocumentURL(PP_Instance instance, PP_URLComponents_Dev* components) = 0; -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) // URLUtil. virtual PP_Var ResolveRelativeToDocument( PP_Instance instance, @@ -153,7 +153,7 @@ PP_URLComponents_Dev* components) = 0; virtual PP_Var GetPluginReferrerURL(PP_Instance instance, PP_URLComponents_Dev* components) = 0; -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) static const ApiID kApiID = API_ID_PPB_INSTANCE; };
diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index 30a2681..c20ed8f1 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h
@@ -174,7 +174,7 @@ virtual PP_Resource CreateVideoEncoder(PP_Instance instance) = 0; virtual PP_Resource CreateVpnProvider(PP_Instance instance) = 0; virtual PP_Resource CreateWebSocket(PP_Instance instance) = 0; -#if !defined(OS_NACL) +#if !BUILDFLAG(IS_NACL) virtual PP_Resource CreateX509CertificatePrivate(PP_Instance instance) = 0; virtual PP_Resource CreateAudioInput(PP_Instance instance) = 0; virtual PP_Resource CreateAudioOutput(PP_Instance instance) = 0; @@ -191,7 +191,7 @@ PP_Instance instance, PP_Resource context3d_id, PP_VideoDecoder_Profile profile) = 0; -#endif // !defined(OS_NACL) +#endif // !BUILDFLAG(IS_NACL) static const ApiID kApiID = API_ID_RESOURCE_CREATION; };
diff --git a/remoting/base/auto_thread.cc b/remoting/base/auto_thread.cc index 7ff953c..8b91584 100644 --- a/remoting/base/auto_thread.cc +++ b/remoting/base/auto_thread.cc
@@ -19,11 +19,11 @@ #include "build/build_config.h" #include "remoting/base/auto_thread_task_runner.h" -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) #include "base/files/file_descriptor_watcher_posix.h" #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/win/scoped_com_initializer.h" #endif @@ -31,7 +31,7 @@ namespace { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) std::unique_ptr<base::win::ScopedCOMInitializer> CreateComInitializer( AutoThread::ComInitType type) { std::unique_ptr<base::win::ScopedCOMInitializer> initializer; @@ -83,7 +83,7 @@ return CreateWithType(name, joiner, base::MessagePumpType::DEFAULT); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // static scoped_refptr<AutoThreadTaskRunner> AutoThread::CreateWithLoopAndComInitTypes( const char* name, @@ -102,7 +102,7 @@ AutoThread::AutoThread(const char* name) : startup_data_(nullptr), -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) com_init_type_(COM_INIT_NONE), #endif thread_(), @@ -113,7 +113,7 @@ AutoThread::AutoThread(const char* name, AutoThreadTaskRunner* joiner) : startup_data_(nullptr), -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) com_init_type_(COM_INIT_NONE), #endif thread_(), @@ -137,7 +137,7 @@ scoped_refptr<AutoThreadTaskRunner> AutoThread::StartWithType( base::MessagePumpType type) { DCHECK(thread_.is_null()); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) DCHECK(com_init_type_ != COM_INIT_STA || type == base::MessagePumpType::UI); #endif @@ -166,7 +166,7 @@ return startup_data.task_runner; } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) void AutoThread::SetComInitType(ComInitType com_init_type) { DCHECK_EQ(com_init_type_, COM_INIT_NONE); com_init_type_ = com_init_type; @@ -213,14 +213,14 @@ // startup_data_ can't be touched anymore since the starting thread is now // unlocked. -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) // Allow threads running a MessageLoopForIO to use FileDescriptorWatcher. std::unique_ptr<base::FileDescriptorWatcher> file_descriptor_watcher; if (single_thread_task_executor.type() == base::MessagePumpType::IO) { file_descriptor_watcher = std::make_unique<base::FileDescriptorWatcher>( single_thread_task_executor.task_runner()); } -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) // Initialize COM on the thread, if requested. std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer( CreateComInitializer(com_init_type_));
diff --git a/remoting/base/auto_thread.h b/remoting/base/auto_thread.h index a5d4097..225a09cf 100644 --- a/remoting/base/auto_thread.h +++ b/remoting/base/auto_thread.h
@@ -44,7 +44,7 @@ const char* name, scoped_refptr<AutoThreadTaskRunner> joiner); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Create an AutoThread initialized for COM. |com_init_type| specifies the // type of COM apartment to initialize. enum ComInitType { COM_INIT_NONE, COM_INIT_STA, COM_INIT_MTA }; @@ -76,7 +76,7 @@ // thread will exit when no references to the TaskRunner remain. scoped_refptr<AutoThreadTaskRunner> StartWithType(base::MessagePumpType type); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Configures the thread to initialize the specified COM apartment type. // SetComInitType() must be called before Start(). void SetComInitType(ComInitType com_init_type); @@ -95,7 +95,7 @@ struct StartupData; raw_ptr<StartupData> startup_data_; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Specifies which kind of COM apartment to initialize, if any. ComInitType com_init_type_; #endif
diff --git a/remoting/base/auto_thread_unittest.cc b/remoting/base/auto_thread_unittest.cc index 5572811..f021f16 100644 --- a/remoting/base/auto_thread_unittest.cc +++ b/remoting/base/auto_thread_unittest.cc
@@ -15,7 +15,7 @@ #include "build/build_config.h" #include "testing/gtest/include/gtest/gtest.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <objbase.h> #endif @@ -33,7 +33,7 @@ task_runner->PostTask(FROM_HERE, base::BindOnce(&SetFlagTask, success)); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) void CheckComAptTypeTask(APTTYPE* apt_type_out, HRESULT* hresult) { typedef HRESULT (WINAPI * CoGetApartmentTypeFunc) (APTTYPE*, APTTYPEQUALIFIER*); @@ -136,7 +136,7 @@ EXPECT_TRUE(success); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) TEST_F(AutoThreadTest, ThreadWithComMta) { scoped_refptr<base::TaskRunner> task_runner = AutoThread::CreateWithLoopAndComInitTypes(kThreadName, main_task_runner_, @@ -178,6 +178,6 @@ // COM activity in this test process, so allow both types here. EXPECT_TRUE(apt_type == APTTYPE_MAINSTA || apt_type == APTTYPE_STA); } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) } // namespace remoting
diff --git a/remoting/base/chromoting_event.cc b/remoting/base/chromoting_event.cc index 98caa0e..57b518c3 100644 --- a/remoting/base/chromoting_event.cc +++ b/remoting/base/chromoting_event.cc
@@ -7,6 +7,7 @@ #include "base/strings/string_util.h" #include "base/strings/stringize_macros.h" #include "base/system/sys_info.h" +#include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "remoting/base/name_value_map.h" @@ -189,17 +190,17 @@ SetString(kCpuKey, base::SysInfo::OperatingSystemArchitecture()); SetString(kOsVersionKey, base::SysInfo::OperatingSystemVersion()); SetString(kWebAppVersionKey, STRINGIZE(VERSION)); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) Os os = Os::CHROMOTING_LINUX; #elif BUILDFLAG(IS_CHROMEOS_ASH) Os os = Os::CHROMOTING_CHROMEOS; -#elif defined(OS_IOS) +#elif BUILDFLAG(IS_IOS) Os os = Os::CHROMOTING_IOS; -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) Os os = Os::CHROMOTING_MAC; -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) Os os = Os::CHROMOTING_WINDOWS; -#elif defined(OS_ANDROID) +#elif BUILDFLAG(IS_ANDROID) Os os = Os::CHROMOTING_ANDROID; #else Os os = Os::OTHER;
diff --git a/remoting/base/host_settings.cc b/remoting/base/host_settings.cc index d351d93..10e5046 100644 --- a/remoting/base/host_settings.cc +++ b/remoting/base/host_settings.cc
@@ -7,11 +7,11 @@ #include "base/no_destructor.h" #include "build/build_config.h" -#if defined(OS_APPLE) || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) +#if BUILDFLAG(IS_APPLE) || (BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS)) #include "remoting/base/file_host_settings.h" -#endif // defined(OS_LINUX) +#endif // BUILDFLAG(IS_LINUX) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "remoting/base/host_settings_win.h" #endif // defined (OS_WIN) @@ -44,10 +44,10 @@ // static HostSettings* HostSettings::GetInstance() { -#if defined(OS_APPLE) || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) +#if BUILDFLAG(IS_APPLE) || (BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS)) static base::NoDestructor<FileHostSettings> instance( FileHostSettings::GetSettingsFilePath()); -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) static base::NoDestructor<HostSettingsWin> instance; #else // HostSettings is currently neither implemented nor used on other platforms.
diff --git a/remoting/base/logging.h b/remoting/base/logging.h index 7eccc56d..126ff57 100644 --- a/remoting/base/logging.h +++ b/remoting/base/logging.h
@@ -8,7 +8,7 @@ #include "base/logging.h" #include "build/build_config.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <guiddef.h> #endif @@ -22,7 +22,7 @@ #define HOST_LOG LOG(INFO) #define HOST_DLOG DLOG(INFO) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // {2db51ca1-4fd8-4b88-b5a2-fb8606b66b02} constexpr GUID kRemotingHostLogProviderGuid = { 0x2db51ca1,
diff --git a/remoting/base/url_request_context_getter.cc b/remoting/base/url_request_context_getter.cc index 3033d54..c14aafa 100644 --- a/remoting/base/url_request_context_getter.cc +++ b/remoting/base/url_request_context_getter.cc
@@ -15,10 +15,10 @@ #include "net/url_request/url_request_context_builder.h" #include "remoting/base/vlog_net_log.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/win/windows_version.h" #include "net/log/net_log.h" -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) namespace remoting { @@ -35,7 +35,7 @@ net::URLRequestContextBuilder builder; builder.DisableHttpCache(); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) if (base::win::GetVersion() <= base::win::Version::WIN7) { // The network stack of Windows 7 and older systems has a bug such that // proxy resolution always fails and blocks each request for ~10-30 @@ -46,7 +46,7 @@ std::move(proxy_config_service_), net::NetLog::Get()); builder.set_proxy_resolution_service(std::move(proxy_resolution_service)); } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) if (proxy_config_service_) { builder.set_proxy_config_service(std::move(proxy_config_service_));
diff --git a/remoting/base/user_settings.cc b/remoting/base/user_settings.cc index 2ad37e9..705106dc 100644 --- a/remoting/base/user_settings.cc +++ b/remoting/base/user_settings.cc
@@ -8,7 +8,7 @@ #include "base/notreached.h" #include "build/build_config.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "remoting/base/user_settings_win.h" #endif @@ -19,7 +19,7 @@ UserSettings::~UserSettings() = default; UserSettings* UserSettings::GetInstance() { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) static base::NoDestructor<UserSettingsWin> instance; return instance.get(); #else
diff --git a/remoting/client/chromoting_client_runtime_unittest.cc b/remoting/client/chromoting_client_runtime_unittest.cc index 2b4eea9..2d2ba04 100644 --- a/remoting/client/chromoting_client_runtime_unittest.cc +++ b/remoting/client/chromoting_client_runtime_unittest.cc
@@ -2,14 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/run_loop.h" -#include "remoting/base/auto_thread_task_runner.h" #include "remoting/client/chromoting_client_runtime.h" + +#include "base/run_loop.h" +#include "build/build_config.h" +#include "remoting/base/auto_thread_task_runner.h" #include "testing/gtest/include/gtest/gtest.h" namespace remoting { -#if defined(OS_IOS) || defined(OS_ANDROID) +#if BUILDFLAG(IS_IOS) || BUILDFLAG(IS_ANDROID) // A simple test that starts and stop the runtime. This tests the runtime // operates properly and all threads and message loops are valid.
diff --git a/remoting/client/client_telemetry_logger.cc b/remoting/client/client_telemetry_logger.cc index 5d292ac2..265679aa 100644 --- a/remoting/client/client_telemetry_logger.cc +++ b/remoting/client/client_telemetry_logger.cc
@@ -11,9 +11,10 @@ #include "base/logging.h" #include "base/rand_util.h" #include "base/strings/stringprintf.h" +#include "build/build_config.h" #include "remoting/base/telemetry_log_writer.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include <android/log.h> #endif // OS_ANDROID @@ -114,7 +115,7 @@ void ClientTelemetryLogger::PrintLogStatistics( const protocol::PerformanceTracker& perf_tracker) { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) __android_log_print( ANDROID_LOG_INFO, "stats", #else
diff --git a/remoting/client/display/sys_opengl.h b/remoting/client/display/sys_opengl.h index 0351fc8..96b9175 100644 --- a/remoting/client/display/sys_opengl.h +++ b/remoting/client/display/sys_opengl.h
@@ -7,18 +7,18 @@ #include "build/build_config.h" -#if defined(OS_IOS) +#if BUILDFLAG(IS_IOS) #include <OpenGLES/ES3/gl.h> -#elif defined(OS_LINUX) || defined(OS_CHROMEOS) +#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #define GL_GLEXT_PROTOTYPES #include <GL/gl.h> #include <GL/glext.h> -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) #define GL_GLEXT_PROTOTYPES #include <OpenGL/gl.h> #include <OpenGL/glext.h> #else #include <GLES3/gl3.h> -#endif // defined(OS_IOS) +#endif // BUILDFLAG(IS_IOS) #endif // REMOTING_CLIENT_DISPLAY_SYS_OPENGL_H_
diff --git a/remoting/client/notification/notification_client.cc b/remoting/client/notification/notification_client.cc index 37a69cd..0b8f40e 100644 --- a/remoting/client/notification/notification_client.cc +++ b/remoting/client/notification/notification_client.cc
@@ -21,7 +21,7 @@ #include "remoting/client/notification/version_range.h" #include "ui/base/l10n/l10n_util.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "base/android/locale_utils.h" #endif @@ -29,9 +29,9 @@ namespace { -#if defined(OS_IOS) +#if BUILDFLAG(IS_IOS) constexpr char kCurrentPlatform[] = "IOS"; -#elif defined(OS_ANDROID) +#elif BUILDFLAG(IS_ANDROID) constexpr char kCurrentPlatform[] = "ANDROID"; #else constexpr char kCurrentPlatform[] = "UNKNOWN"; @@ -208,7 +208,7 @@ kCurrentPlatform, kCurrentVersion, base::SysInfo::OperatingSystemVersion(), -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // GetApplicationLocale() returns empty string on Android since we // don't pack any .pak file into the apk, so we need to get the locale // string directly.
diff --git a/remoting/codec/webrtc_video_encoder_gpu.cc b/remoting/codec/webrtc_video_encoder_gpu.cc index 0dde5cc..e6cc24e 100644 --- a/remoting/codec/webrtc_video_encoder_gpu.cc +++ b/remoting/codec/webrtc_video_encoder_gpu.cc
@@ -31,7 +31,7 @@ #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/win/scoped_com_initializer.h" #endif @@ -51,7 +51,7 @@ gpu::GpuPreferences CreateGpuPreferences() { gpu::GpuPreferences gpu_preferences; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) gpu_preferences.enable_media_foundation_vea_on_windows7 = true; #endif return gpu_preferences; @@ -130,7 +130,7 @@ void RunAnyPendingEncode(); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // This object is required by Chromium to ensure proper init/uninit of COM on // this thread. The guidance is to match the lifetime of this object to the // lifetime of the thread if possible. @@ -340,7 +340,7 @@ void WebrtcVideoEncoderGpu::Core::BeginInitialization() { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) if (!scoped_com_initializer_) { scoped_com_initializer_ = std::make_unique<base::win::ScopedCOMInitializer>(); @@ -397,7 +397,7 @@ // static bool WebrtcVideoEncoderGpu::IsSupportedByH264( const WebrtcVideoEncoderSelector::Profile& profile) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // This object is required by Chromium to ensure proper init/uninit of COM on // this thread. The guidance is to match the lifetime of this object to the // lifetime of the thread if possible. Since we are still experimenting with
diff --git a/remoting/codec/webrtc_video_encoder_vpx.cc b/remoting/codec/webrtc_video_encoder_vpx.cc index d77b9087..9fc19d3 100644 --- a/remoting/codec/webrtc_video_encoder_vpx.cc +++ b/remoting/codec/webrtc_video_encoder_vpx.cc
@@ -85,11 +85,11 @@ const webrtc::DesktopSize& size) { SetCommonCodecParameters(config, size); -#if defined(OS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS) +#if BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS) // On Linux, using too many threads for VP8 encoding has been linked to high // CPU usage on machines that are under stress. See http://crbug.com/1151148. config->g_threads = std::min(config->g_threads, 2U); -#endif // defined(OS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS) +#endif // BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS_LACROS) // Value of 2 means using the real time profile. This is basically a // redundant option since we explicitly select real time mode when doing
diff --git a/remoting/host/base/switches.cc b/remoting/host/base/switches.cc index ce9f987f..81a194b 100644 --- a/remoting/host/base/switches.cc +++ b/remoting/host/base/switches.cc
@@ -23,13 +23,13 @@ const char kProcessTypeFileChooser[] = "file_chooser"; const char kProcessTypeUrlForwarderConfigurator[] = "url_forwarder_configurator"; -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) const char kProcessTypeXSessionChooser[] = "xsession_chooser"; -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) const char kEvaluateCapabilitySwitchName[] = "evaluate-type"; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) const char kEvaluateD3D[] = "d3d-support"; const char kEvaluate3dDisplayMode[] = "3d-display-mode"; const char kSetUpUrlForwarderSwitchName[] = "setup"; @@ -42,7 +42,7 @@ const char kMojoPipeToken[] = "mojo-pipe-token"; -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) const char kCheckPermissionSwitchName[] = "check-permission"; const char kCheckAccessibilityPermissionSwitchName[] = "check-accessibility-permission";
diff --git a/remoting/host/base/switches.h b/remoting/host/base/switches.h index 4769406..c5a2956 100644 --- a/remoting/host/base/switches.h +++ b/remoting/host/base/switches.h
@@ -35,14 +35,14 @@ extern const char kProcessTypeEvaluateCapability[]; extern const char kProcessTypeFileChooser[]; extern const char kProcessTypeUrlForwarderConfigurator[]; -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) extern const char kProcessTypeXSessionChooser[]; -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) extern const char kEvaluateCapabilitySwitchName[]; // Values for kEvaluateCapabilitySwitchName. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Executes EvaluateD3D() function. extern const char kEvaluateD3D[]; // Executes Evaluate3dDisplayMode() function. @@ -65,7 +65,7 @@ // processes. extern const char kMojoPipeToken[]; -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) // NativeMessagingHost switch to check for required OS permissions and request // them if necessary. extern const char kCheckPermissionSwitchName[];
diff --git a/remoting/host/base/username.cc b/remoting/host/base/username.cc index 73766dde..62c2f58 100644 --- a/remoting/host/base/username.cc +++ b/remoting/host/base/username.cc
@@ -9,16 +9,16 @@ #include "base/notreached.h" #include "build/build_config.h" -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) #include <pwd.h> #include <sys/types.h> #include <unistd.h> -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) namespace remoting { std::string GetUsername() { -#if defined(OS_POSIX) && !defined(OS_ANDROID) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) long buf_size = sysconf(_SC_GETPW_R_SIZE_MAX); if (buf_size <= 0) return std::string(); @@ -31,7 +31,7 @@ #else NOTIMPLEMENTED(); return std::string(); -#endif // defined(OS_POSIX) && !defined(OS_ANDROID) +#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) } } // namespace remoting
diff --git a/remoting/host/basic_desktop_environment.cc b/remoting/host/basic_desktop_environment.cc index f6ca2f2..aaa3e1c 100644 --- a/remoting/host/basic_desktop_environment.cc +++ b/remoting/host/basic_desktop_environment.cc
@@ -25,7 +25,7 @@ #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" #include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "remoting/host/win/evaluate_d3d.h" #endif @@ -135,7 +135,7 @@ std::unique_ptr<DesktopAndCursorConditionalComposer> BasicDesktopEnvironment::CreateComposingVideoCapturer() { -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) // Mac includes the mouse cursor in the captured image in curtain mode. if (options_.enable_curtaining()) return nullptr; @@ -176,7 +176,7 @@ watchdog.Arm(); desktop_capture_options().x_display()->IgnoreXServerGrabs(); watchdog.Disarm(); -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) options_.desktop_capture_options()->set_allow_directx_capturer( IsD3DAvailable()); #endif
diff --git a/remoting/host/branding.cc b/remoting/host/branding.cc index df7eee6a..ade20f7 100644 --- a/remoting/host/branding.cc +++ b/remoting/host/branding.cc
@@ -15,7 +15,7 @@ // The actual location of the files is ultimately determined by the service // daemon and native messaging host - these defaults are only used in case the // command-line switches are absent. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #ifdef OFFICIAL_BUILD const base::FilePath::CharType kConfigDir[] = FILE_PATH_LITERAL("Google\\Chrome Remote Desktop"); @@ -23,7 +23,7 @@ const base::FilePath::CharType kConfigDir[] = FILE_PATH_LITERAL("Chromoting"); #endif -#elif defined(OS_APPLE) +#elif BUILDFLAG(IS_APPLE) const base::FilePath::CharType kConfigDir[] = FILE_PATH_LITERAL("Chrome Remote Desktop"); #else @@ -35,16 +35,16 @@ namespace remoting { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) const wchar_t kWindowsServiceName[] = L"chromoting"; #endif base::FilePath GetConfigDir() { base::FilePath app_data_dir; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) base::PathService::Get(base::DIR_COMMON_APP_DATA, &app_data_dir); -#elif defined(OS_APPLE) +#elif BUILDFLAG(IS_APPLE) base::PathService::Get(base::DIR_APP_DATA, &app_data_dir); #else base::PathService::Get(base::DIR_HOME, &app_data_dir);
diff --git a/remoting/host/branding.h b/remoting/host/branding.h index 575f3fb..1452803 100644 --- a/remoting/host/branding.h +++ b/remoting/host/branding.h
@@ -10,7 +10,7 @@ namespace remoting { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Windows chromoting service name. extern const wchar_t kWindowsServiceName[]; #endif
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc index 5bf16f8..c7021c5 100644 --- a/remoting/host/chromoting_host.cc +++ b/remoting/host/chromoting_host.cc
@@ -31,7 +31,7 @@ #include "remoting/protocol/transport_context.h" #include "remoting/protocol/webrtc_connection_to_client.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <windows.h> #endif @@ -124,7 +124,7 @@ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK(!ipc_server_); -#if defined(OS_LINUX) || defined(OS_WIN) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) ipc_server_ = std::make_unique<MojoIpcServer<mojom::ChromotingHostServices>>( GetChromotingHostServicesServerName(), this); ipc_server_->StartServer(); @@ -244,7 +244,7 @@ << "No connected remote desktop client was found."; return; } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) DWORD peer_session_id; if (!ProcessIdToSessionId(ipc_server_->current_peer_pid(), &peer_session_id)) {
diff --git a/remoting/host/chromoting_host_context.cc b/remoting/host/chromoting_host_context.cc index 5270294..b2a1684 100644 --- a/remoting/host/chromoting_host_context.cc +++ b/remoting/host/chromoting_host_context.cc
@@ -117,18 +117,18 @@ std::unique_ptr<ChromotingHostContext> ChromotingHostContext::Create( scoped_refptr<AutoThreadTaskRunner> ui_task_runner) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // On Windows the AudioCapturer requires COM, so we run a single-threaded // apartment, which requires a UI thread. scoped_refptr<AutoThreadTaskRunner> audio_task_runner = AutoThread::CreateWithLoopAndComInitTypes( "ChromotingAudioThread", ui_task_runner, base::MessagePumpType::UI, AutoThread::COM_INIT_STA); -#else // !defined(OS_WIN) +#else // !BUILDFLAG(IS_WIN) scoped_refptr<AutoThreadTaskRunner> audio_task_runner = AutoThread::CreateWithType("ChromotingAudioThread", ui_task_runner, base::MessagePumpType::IO); -#endif // !defined(OS_WIN) +#endif // !BUILDFLAG(IS_WIN) scoped_refptr<AutoThreadTaskRunner> file_task_runner = AutoThread::CreateWithType("ChromotingFileThread", ui_task_runner, base::MessagePumpType::IO); @@ -143,16 +143,16 @@ // on a UI thread. scoped_refptr<AutoThreadTaskRunner> input_task_runner = AutoThread::CreateWithType("ChromotingInputThread", ui_task_runner, -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) base::MessagePumpType::UI); #else base::MessagePumpType::IO); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) return base::WrapUnique(new ChromotingHostContext( ui_task_runner, audio_task_runner, file_task_runner, input_task_runner, network_task_runner, -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) // Mac requires a UI thread for the capturer. AutoThread::CreateWithType("ChromotingCaptureThread", ui_task_runner, base::MessagePumpType::UI),
diff --git a/remoting/host/chromoting_host_services_client.cc b/remoting/host/chromoting_host_services_client.cc index 35a0f5d..33c5db9 100644 --- a/remoting/host/chromoting_host_services_client.cc +++ b/remoting/host/chromoting_host_services_client.cc
@@ -14,7 +14,7 @@ #include "remoting/host/ipc_constants.h" #include "remoting/host/mojom/chromoting_host_services.mojom.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <windows.h> #include "remoting/host/win/acl_util.h" @@ -24,7 +24,7 @@ namespace { -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) constexpr char kChromeRemoteDesktopSessionEnvVar[] = "CHROME_REMOTE_DESKTOP_SESSION"; #endif @@ -47,7 +47,7 @@ // static bool ChromotingHostServicesClient::Initialize() { DCHECK(!g_initialized); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // The ChromotingHostServices server runs under the LocalService account, // which normally isn't allowed to query process info like session ID of a // process running under a different account, so we add an ACL to allow it. @@ -104,7 +104,7 @@ if (session_services_remote_.is_bound()) { return true; } -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) if (!environment_->HasVar(kChromeRemoteDesktopSessionEnvVar)) { LOG(WARNING) << "Current desktop environment is not remotable."; return false;
diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc index 50fb575..3fbcce09 100644 --- a/remoting/host/client_session.cc +++ b/remoting/host/client_session.cc
@@ -88,11 +88,11 @@ extension_manager_ = std::make_unique<HostExtensionSessionManager>(extensions, this); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // LocalInputMonitorWin filters out an echo of the injected input before it // reaches |remote_input_filter_|. remote_input_filter_.SetExpectLocalEcho(false); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) } ClientSession::~ClientSession() { @@ -702,7 +702,7 @@ break; case protocol::SessionConfig::Protocol::WEBRTC: { -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) mouse_clamping_filter_.set_input_size(size.WidthAsPixels(), size.HeightAsPixels()); #else @@ -711,7 +711,7 @@ // TODO(sergeyu): Fix InputInjector implementations to use DIPs as well. mouse_clamping_filter_.set_input_size(size.WidthAsDips(), size.HeightAsDips()); -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) } } } @@ -826,7 +826,7 @@ // display configuration supports capturing the entire desktop. LOG(INFO) << " Webrtc desktop size " << default_webrtc_desktop_size_; if (show_display_id_ == webrtc::kInvalidScreenId) { -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) // On MacOS, there are situations where webrtc cannot capture the entire // desktop (e.g, when there are displays with different DPIs). We detect // this situation by comparing the full desktop size (calculated above @@ -844,7 +844,7 @@ #else // Windows/Linux can capture full desktop if multiple displays. can_capture_full_desktop_ = true; -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) } // Generate and send VideoLayout message.
diff --git a/remoting/host/client_session_unittest.cc b/remoting/host/client_session_unittest.cc index 8849222..0330e87 100644 --- a/remoting/host/client_session_unittest.cc +++ b/remoting/host/client_session_unittest.cc
@@ -600,11 +600,11 @@ connection_->input_stub()->InjectMouseEvent(MakeMouseMoveEvent(100, 101)); -#if !defined(OS_WIN) +#if !BUILDFLAG(IS_WIN) // The OS echoes the injected event back. client_session_->OnLocalPointerMoved(webrtc::DesktopVector(100, 101), ui::ET_MOUSE_MOVED); -#endif // !defined(OS_WIN) +#endif // !BUILDFLAG(IS_WIN) // This one should get throught as well. connection_->input_stub()->InjectMouseEvent(MakeMouseMoveEvent(200, 201));
diff --git a/remoting/host/config_file_watcher.cc b/remoting/host/config_file_watcher.cc index 20c94ea95..2dbe53c 100644 --- a/remoting/host/config_file_watcher.cc +++ b/remoting/host/config_file_watcher.cc
@@ -27,11 +27,11 @@ const base::FilePath::CharType kDefaultHostConfigFile[] = FILE_PATH_LITERAL("host.json"); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Maximum number of times to try reading the configuration file before // reporting an error. const int kMaxRetries = 3; -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) class ConfigFileWatcherImpl : public base::RefCountedThreadSafe<ConfigFileWatcherImpl> { @@ -203,7 +203,7 @@ std::string config; if (!base::ReadFileToString(config_path_, &config)) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // EACCESS may indicate a locking or sharing violation. Retry a few times // before reporting an error. if (errno == EACCES && retries_ < kMaxRetries) { @@ -213,7 +213,7 @@ config_updated_timer_->Reset(); return; } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) PLOG(ERROR) << "Failed to read '" << config_path_.value() << "'";
diff --git a/remoting/host/desktop_display_info.cc b/remoting/host/desktop_display_info.cc index 2f624cd..6728557 100644 --- a/remoting/host/desktop_display_info.cc +++ b/remoting/host/desktop_display_info.cc
@@ -99,14 +99,14 @@ unsigned int disp_index = disp_id; if (full_desktop) { -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) // For Mac, we need to calculate the offset relative to the default // display. disp_index = 0; #else // For other platforms, the origin for full desktop is 0,0. return webrtc::DesktopVector(); -#endif // !defined(OS_APPLE) +#endif // !BUILDFLAG(IS_APPLE) } if (displays_.size() == 0) { @@ -132,7 +132,7 @@ } webrtc::DesktopVector topleft(dx, dy); -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) // Mac display offsets need to be relative to the main display's origin. if (full_desktop) { // For full desktop, this is the offset to the topleft display coord. @@ -145,7 +145,7 @@ #else // Return offset to this screen, relative to topleft. return origin.subtract(topleft); -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) } void DesktopDisplayInfo::AddDisplay(const DisplayGeometry& display) {
diff --git a/remoting/host/desktop_display_info_unittest.cc b/remoting/host/desktop_display_info_unittest.cc index b01d893..f9acc37 100644 --- a/remoting/host/desktop_display_info_unittest.cc +++ b/remoting/host/desktop_display_info_unittest.cc
@@ -82,13 +82,13 @@ AddDisplay(0, 0, 500, 400); AddDisplay(-300, 0, 300, 200); -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) VerifyDisplayOffset(FROM_HERE, 0, 0, 0); VerifyDisplayOffset(FROM_HERE, 1, -300, 0); #else VerifyDisplayOffset(FROM_HERE, 0, 300, 0); VerifyDisplayOffset(FROM_HERE, 1, 0, 0); -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) } // +---------o------------+ @@ -100,13 +100,13 @@ AddDisplay(-300, 0, 300, 200); AddDisplay(0, 0, 500, 400); -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) VerifyDisplayOffset(FROM_HERE, 0, -300, 0); VerifyDisplayOffset(FROM_HERE, 1, 0, 0); #else VerifyDisplayOffset(FROM_HERE, 0, 0, 0); VerifyDisplayOffset(FROM_HERE, 1, 300, 0); -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) } // +---------o------------+ @@ -119,7 +119,7 @@ AddDisplay(0, 0, 500, 400); // Default display. AddDisplay(500, 50, 400, 350); -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) VerifyDisplayOffset(FROM_HERE, 0, -300, 0); VerifyDisplayOffset(FROM_HERE, 1, 0, 0); VerifyDisplayOffset(FROM_HERE, 2, 500, 50); @@ -127,7 +127,7 @@ VerifyDisplayOffset(FROM_HERE, 0, 0, 0); VerifyDisplayOffset(FROM_HERE, 1, 300, 0); VerifyDisplayOffset(FROM_HERE, 2, 800, 50); -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) } // x o-----------+ - 0 @@ -144,7 +144,7 @@ AddDisplay(300, 400, 600, 450); AddDisplay(-300, 350, 300, 200); -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) VerifyDisplayOffset(FROM_HERE, 0, 0, 0); VerifyDisplayOffset(FROM_HERE, 1, 300, 400); VerifyDisplayOffset(FROM_HERE, 2, -300, 350); @@ -152,7 +152,7 @@ VerifyDisplayOffset(FROM_HERE, 0, 300, 0); VerifyDisplayOffset(FROM_HERE, 1, 600, 400); VerifyDisplayOffset(FROM_HERE, 2, 0, 350); -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) } // x +-------+ -- -50 @@ -181,7 +181,7 @@ AddDisplay(70, 100, 65, 20); AddDisplay(0, 0, 80, 55); // Default display. -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) // Relative to display 6. VerifyDisplayOffset(FROM_HERE, 0, 80, -10); VerifyDisplayOffset(FROM_HERE, 1, 60, -50); @@ -198,7 +198,7 @@ VerifyDisplayOffset(FROM_HERE, 4, 30, 30); VerifyDisplayOffset(FROM_HERE, 5, 140, 150); VerifyDisplayOffset(FROM_HERE, 6, 70, 50); -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) } } // namespace remoting
diff --git a/remoting/host/desktop_process.cc b/remoting/host/desktop_process.cc index 608f44e..d779a22 100644 --- a/remoting/host/desktop_process.cc +++ b/remoting/host/desktop_process.cc
@@ -24,9 +24,9 @@ #include "remoting/host/desktop_environment.h" #include "remoting/host/desktop_session_agent.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/win/windows_version.h" -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) namespace remoting { @@ -76,7 +76,7 @@ void DesktopProcess::LockWorkstation() { DCHECK(caller_task_runner_->BelongsToCurrentThread()); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) if (base::win::OSInfo::GetInstance()->version_type() == base::win::VersionType::SUITE_HOME) { return; @@ -87,7 +87,7 @@ } #else NOTREACHED(); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) } bool DesktopProcess::OnMessageReceived(const IPC::Message& message) { @@ -134,16 +134,16 @@ // Launch the audio capturing thread. scoped_refptr<AutoThreadTaskRunner> audio_task_runner; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // On Windows the AudioCapturer requires COM, so we run a single-threaded // apartment, which requires a UI thread. audio_task_runner = AutoThread::CreateWithLoopAndComInitTypes( "ChromotingAudioThread", caller_task_runner_, base::MessagePumpType::UI, AutoThread::COM_INIT_STA); -#else // !defined(OS_WIN) +#else // !BUILDFLAG(IS_WIN) audio_task_runner = AutoThread::CreateWithType( "ChromotingAudioThread", caller_task_runner_, base::MessagePumpType::IO); -#endif // !defined(OS_WIN) +#endif // !BUILDFLAG(IS_WIN) // Create a desktop agent. desktop_agent_ =
diff --git a/remoting/host/desktop_process_main.cc b/remoting/host/desktop_process_main.cc index 4c93ecd..138fce7 100644 --- a/remoting/host/desktop_process_main.cc +++ b/remoting/host/desktop_process_main.cc
@@ -76,7 +76,7 @@ // Create a platform-dependent environment factory. std::unique_ptr<DesktopEnvironmentFactory> desktop_environment_factory; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // base::Unretained() is safe here: |desktop_process| outlives run_loop.Run(). auto inject_sas_closure = base::BindRepeating( &DesktopProcess::InjectSas, base::Unretained(&desktop_process)); @@ -87,11 +87,11 @@ std::make_unique<SessionDesktopEnvironmentFactory>( ui_task_runner, video_capture_task_runner, input_task_runner, ui_task_runner, inject_sas_closure, lock_workstation_closure); -#else // !defined(OS_WIN) +#else // !BUILDFLAG(IS_WIN) desktop_environment_factory.reset(new Me2MeDesktopEnvironmentFactory( ui_task_runner, video_capture_task_runner, input_task_runner, ui_task_runner)); -#endif // !defined(OS_WIN) +#endif // !BUILDFLAG(IS_WIN) if (!desktop_process.Start(std::move(desktop_environment_factory))) return kInitializationFailed; @@ -105,8 +105,8 @@ } // namespace remoting -#if !defined(OS_WIN) +#if !BUILDFLAG(IS_WIN) int main(int argc, char** argv) { return remoting::HostMain(argc, argv); } -#endif // !defined(OS_WIN) +#endif // !BUILDFLAG(IS_WIN)
diff --git a/remoting/host/desktop_session_agent.cc b/remoting/host/desktop_session_agent.cc index 067fad0..85e7327 100644 --- a/remoting/host/desktop_session_agent.cc +++ b/remoting/host/desktop_session_agent.cc
@@ -49,7 +49,7 @@ #include "third_party/webrtc/modules/desktop_capture/mouse_cursor.h" #include "third_party/webrtc/modules/desktop_capture/shared_memory.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <windows.h> #include "base/memory/writable_shared_memory_region.h" @@ -67,7 +67,7 @@ static std::unique_ptr<SharedMemoryImpl> Create(size_t size, int id, base::OnceClosure on_deleted_callback) { webrtc::SharedMemory::Handle handle = webrtc::SharedMemory::kInvalidHandle; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // webrtc::ScreenCapturer uses webrtc::SharedMemory::handle() only on // windows. This handle must be writable. A WritableSharedMemoryRegion is // created, and then it is converted to read-only. On the windows platform, @@ -119,7 +119,7 @@ base::OnceClosure on_deleted_callback) : SharedMemory(mapping.memory(), mapping.size(), handle, id), on_deleted_callback_(std::move(on_deleted_callback)) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) , writable_handle_(handle) #endif @@ -131,7 +131,7 @@ base::OnceClosure on_deleted_callback_; base::ReadOnlySharedMemoryRegion region_; base::WritableSharedMemoryMapping mapping_; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Owns the handle passed to the base class which is used by // webrtc::ScreenCapturer. base::win::ScopedHandle writable_handle_; @@ -410,11 +410,11 @@ remote_input_filter_ = std::make_unique<RemoteInputFilter>(input_tracker_.get()); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // LocalInputMonitorWin filters out an echo of the injected input before it // reaches |remote_input_filter_|. remote_input_filter_->SetExpectLocalEcho(false); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) // Start the input injector. std::unique_ptr<protocol::ClipboardStub> clipboard_stub(
diff --git a/remoting/host/desktop_session_proxy.cc b/remoting/host/desktop_session_proxy.cc index 5bbfde6..43534a4 100644 --- a/remoting/host/desktop_session_proxy.cc +++ b/remoting/host/desktop_session_proxy.cc
@@ -43,9 +43,9 @@ #include "third_party/webrtc/modules/desktop_capture/mouse_cursor.h" #include "third_party/webrtc/modules/desktop_capture/shared_memory.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/win/scoped_handle.h" -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) namespace remoting {
diff --git a/remoting/host/evaluate_capability.cc b/remoting/host/evaluate_capability.cc index 3fd9edd..34a29e5 100644 --- a/remoting/host/evaluate_capability.cc +++ b/remoting/host/evaluate_capability.cc
@@ -20,7 +20,7 @@ #include "remoting/host/base/switches.h" #include "remoting/host/ipc_constants.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "remoting/host/win/evaluate_3d_display_mode.h" #include "remoting/host/win/evaluate_d3d.h" #endif @@ -45,7 +45,7 @@ base::FilePath directory; result = base::PathService::Get(base::DIR_EXE, &directory); DCHECK(result); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) if (path.BaseName().value() == FILE_PATH_LITERAL("remoting_unittests.exe")) { return directory.Append(FILE_PATH_LITERAL("capability_test_stub.exe")); } @@ -55,7 +55,7 @@ } #endif -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) if (path.BaseName().value() == FILE_PATH_LITERAL("chrome-remote-desktop-host")) { return path; @@ -65,14 +65,14 @@ } return directory.Append(FILE_PATH_LITERAL("remoting_me2me_host")); -#elif defined(OS_APPLE) +#elif BUILDFLAG(IS_APPLE) if (path.BaseName().value() == FILE_PATH_LITERAL("remoting_me2me_host")) { return path; } return directory.Append(FILE_PATH_LITERAL( "remoting_me2me_host.app/Contents/MacOS/remoting_me2me_host")); -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) if (path.BaseName().value() == FILE_PATH_LITERAL("remoting_console.exe")) { return path; } @@ -92,7 +92,7 @@ } // namespace int EvaluateCapabilityLocally(const std::string& type) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) if (type == kEvaluateD3D) { return EvaluateD3D(); } @@ -120,7 +120,7 @@ // TODO(crbug.com/1144161): Do not perform blocking operations on the IO // thread. ScopedBypassIOThreadRestrictions bypass; -#if DCHECK_IS_ON() && !defined(OS_WIN) +#if DCHECK_IS_ON() && !BUILDFLAG(IS_WIN) const bool result = #endif base::GetAppOutputWithExitCode(command, output, &exit_code); @@ -128,7 +128,7 @@ // On Windows, base::GetAppOutputWithExitCode() usually returns false when // receiving "unknown" exit code. See // https://cs.chromium.org/chromium/src/base/process/launch_win.cc?rcl=39ec40095376e8d977decbdc5d7ca28ba7d39cf2&l=130 -#if DCHECK_IS_ON() && !defined(OS_WIN) +#if DCHECK_IS_ON() && !BUILDFLAG(IS_WIN) DCHECK(result) << "Failed to execute process " << command.GetCommandLineString() << ", exit code " << exit_code;
diff --git a/remoting/host/file_transfer/local_file_operations.cc b/remoting/host/file_transfer/local_file_operations.cc index 8c1b613..51bb90e4 100644 --- a/remoting/host/file_transfer/local_file_operations.cc +++ b/remoting/host/file_transfer/local_file_operations.cc
@@ -45,7 +45,7 @@ } scoped_refptr<base::SequencedTaskRunner> CreateFileTaskRunner() { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // On Windows, we use user impersonation to write files as the currently // logged-in user, while the process as a whole runs as SYSTEM. Since user // impersonation is per-thread on Windows, we need a dedicated thread to
diff --git a/remoting/host/heartbeat_sender.cc b/remoting/host/heartbeat_sender.cc index 55239969..5f3b67df 100644 --- a/remoting/host/heartbeat_sender.cc +++ b/remoting/host/heartbeat_sender.cc
@@ -33,7 +33,7 @@ #include "remoting/signaling/signaling_address.h" #include "services/network/public/cpp/shared_url_loader_factory.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/strings/utf_string_conversions.h" // Needed for GetComputerNameExW/ComputerNameDnsFullyQualified. @@ -111,9 +111,9 @@ std::string GetHostname() { // TODO(crbug.com/1052397): Revisit the macro expression once build flag // switch of lacros-chrome is complete. -#if defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) return net::GetHostName(); -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) wchar_t buffer[MAX_PATH] = {0}; DWORD size = MAX_PATH; if (!::GetComputerNameExW(ComputerNameDnsFullyQualified, buffer, &size)) {
diff --git a/remoting/host/heartbeat_sender_unittest.cc b/remoting/host/heartbeat_sender_unittest.cc index 43b2546..a5c5ce9a 100644 --- a/remoting/host/heartbeat_sender_unittest.cc +++ b/remoting/host/heartbeat_sender_unittest.cc
@@ -75,7 +75,7 @@ // TODO(crbug.com/1052397): Revisit the macro expression once build flag switch // of lacros-chrome is complete. -#if defined(OS_WIN) || defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) ASSERT_EQ(is_googler, request->has_hostname()); #else ASSERT_FALSE(request->has_hostname());
diff --git a/remoting/host/host_attributes.cc b/remoting/host/host_attributes.cc index 9bd6cff6..a54f32b1 100644 --- a/remoting/host/host_attributes.cc +++ b/remoting/host/host_attributes.cc
@@ -16,7 +16,7 @@ #include "build/branding_buildflags.h" #include "build/build_config.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/win/windows_version.h" #include "media/base/win/mf_initializer.h" #include "media/gpu/windows/media_foundation_video_encode_accelerator_win.h" @@ -99,7 +99,7 @@ result.push_back(attribute.name); } } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) { GetD3DCapabilities(&result); @@ -122,7 +122,7 @@ media::InitializeMediaFoundation()) { result.push_back("HWEncoder"); } -#elif defined(OS_LINUX) || defined(OS_CHROMEOS) +#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) result.push_back("HWEncoder"); #endif
diff --git a/remoting/host/host_details.cc b/remoting/host/host_details.cc index 9e9cdff..3290e44 100644 --- a/remoting/host/host_details.cc +++ b/remoting/host/host_details.cc
@@ -8,7 +8,7 @@ #include "build/build_config.h" #include "build/chromeos_buildflags.h" -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #include "base/linux_util.h" #endif @@ -17,15 +17,15 @@ // Get the host Operating System Name, removing the need to check for OS // definitions and keeps the keys used consistent. std::string GetHostOperatingSystemName() { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return "Windows"; -#elif defined(OS_APPLE) +#elif BUILDFLAG(IS_APPLE) return "Mac"; #elif BUILDFLAG(IS_CHROMEOS_ASH) return "ChromeOS"; -#elif defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) +#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) return "Linux"; -#elif defined(OS_ANDROID) +#elif BUILDFLAG(IS_ANDROID) return "Android"; #else #error "Unsupported host OS" @@ -35,7 +35,7 @@ // Get the host Operating System Version, removing the need to check for OS // definitions and keeps the format used consistent. std::string GetHostOperatingSystemVersion() { -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) return base::GetLinuxDistro(); #else return base::SysInfo::OperatingSystemVersion();
diff --git a/remoting/host/host_main.cc b/remoting/host/host_main.cc index 6deec87..d8ca9ec 100644 --- a/remoting/host/host_main.cc +++ b/remoting/host/host_main.cc
@@ -28,31 +28,31 @@ #include "remoting/host/setup/me2me_native_messaging_host.h" #include "remoting/host/usage_stats_consent.h" -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) #include "base/mac/scoped_nsautorelease_pool.h" -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <windows.h> #include <commctrl.h> #include <shellapi.h> -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) namespace remoting { // Known entry points. int HostProcessMain(); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) int DaemonProcessMain(); int DesktopProcessMain(); int FileChooserMain(); int RdpDesktopSessionMain(); int UrlForwarderConfiguratorMain(); -#endif // defined(OS_WIN) -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_WIN) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) int XSessionChooserMain(); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) namespace { @@ -63,15 +63,15 @@ "\n" "Options:\n" -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) " --audio-pipe-name=<pipe> - Sets the pipe name to capture audio on " "Linux.\n" -#endif // defined(OS_LINUX) +#endif // BUILDFLAG(IS_LINUX) -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) " --list-audio-devices - List all audio devices and their device " "UID.\n" -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) " --console - Runs the daemon interactively.\n" " --elevate=<binary> - Runs <binary> elevated.\n" @@ -85,7 +85,7 @@ printf(kUsageMessage, program_name.MaybeAsASCII().c_str()); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Runs the binary specified by the command line, elevated. int RunElevated() { @@ -132,7 +132,7 @@ return kSuccessExitCode; } -#endif // !defined(OS_WIN) +#endif // !BUILDFLAG(IS_WIN) // Select the entry point corresponding to the process type. MainRoutineFn SelectMainRoutine(const std::string& process_type) { @@ -140,7 +140,7 @@ if (process_type == kProcessTypeHost) { main_routine = &HostProcessMain; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) } else if (process_type == kProcessTypeDaemon) { main_routine = &DaemonProcessMain; } else if (process_type == kProcessTypeDesktop) { @@ -151,11 +151,11 @@ main_routine = &RdpDesktopSessionMain; } else if (process_type == kProcessTypeUrlForwarderConfigurator) { main_routine = &UrlForwarderConfiguratorMain; -#endif // defined(OS_WIN) -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_WIN) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) } else if (process_type == kProcessTypeXSessionChooser) { main_routine = &XSessionChooserMain; -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) } return main_routine; @@ -164,7 +164,7 @@ } // namespace int HostMain(int argc, char** argv) { -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) // Needed so we don't leak objects when threads are created. base::mac::ScopedNSAutoreleasePool pool; #endif @@ -185,11 +185,11 @@ return kSuccessExitCode; } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) if (command_line->HasSwitch(kElevateSwitchName)) { return RunElevated(); } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) // Assume the host process by default. std::string process_type = kProcessTypeHost; @@ -222,13 +222,13 @@ } #endif // defined(REMOTING_ENABLE_BREAKPAD) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Register and initialize common controls. INITCOMMONCONTROLSEX info; info.dwSize = sizeof(info); info.dwICC = ICC_STANDARD_CLASSES; InitCommonControlsEx(&info); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) MainRoutineFn main_routine = SelectMainRoutine(process_type); if (!main_routine) {
diff --git a/remoting/host/input_monitor/local_input_monitor_unittest.cc b/remoting/host/input_monitor/local_input_monitor_unittest.cc index 1ae9ffe..db00b5d 100644 --- a/remoting/host/input_monitor/local_input_monitor_unittest.cc +++ b/remoting/host/input_monitor/local_input_monitor_unittest.cc
@@ -34,12 +34,12 @@ void SetUp() override; base::test::TaskEnvironment task_environment_ { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) base::test::TaskEnvironment::MainThreadType::UI -#else // !defined(OS_WIN) +#else // !BUILDFLAG(IS_WIN) // Required to watch a file descriptor from NativeMessageProcessHost. base::test::TaskEnvironment::MainThreadType::IO -#endif // !defined(OS_WIN) +#endif // !BUILDFLAG(IS_WIN) }; base::RunLoop run_loop_;
diff --git a/remoting/host/ipc_constants.cc b/remoting/host/ipc_constants.cc index 634afea..ffffae9b 100644 --- a/remoting/host/ipc_constants.cc +++ b/remoting/host/ipc_constants.cc
@@ -16,7 +16,7 @@ namespace { -#if !defined(NDEBUG) && defined(OS_LINUX) +#if !defined(NDEBUG) && BUILDFLAG(IS_LINUX) // Use a different IPC name for Linux debug builds so that we can run the host // directly from out/Debug without interfering with the production host that // might also be running. @@ -45,9 +45,9 @@ base::FilePath path = dir_path.Append(binary); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) path = path.ReplaceExtension(FILE_PATH_LITERAL("exe")); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) *full_path = path; return true;
diff --git a/remoting/host/it2me/it2me_host.cc b/remoting/host/it2me/it2me_host.cc index a4039fb..8a3fbec 100644 --- a/remoting/host/it2me/it2me_host.cc +++ b/remoting/host/it2me/it2me_host.cc
@@ -388,17 +388,17 @@ UpdateClientDomainListPolicy(std::move(client_domain_list_vector)); } - std::string port_range_string; - if (policies->GetString(policy::key::kRemoteAccessHostUdpPortRange, - &port_range_string)) { - UpdateHostUdpPortRangePolicy(port_range_string); + const std::string* port_range_string = + policies->FindStringKey(policy::key::kRemoteAccessHostUdpPortRange); + if (port_range_string) { + UpdateHostUdpPortRangePolicy(*port_range_string); } - int max_clipboard_size; - if (policies->GetInteger(policy::key::kRemoteAccessHostClipboardSizeBytes, - &max_clipboard_size)) { - if (max_clipboard_size >= 0) { - max_clipboard_size_ = max_clipboard_size; + absl::optional<int> max_clipboard_size = + policies->FindIntKey(policy::key::kRemoteAccessHostClipboardSizeBytes); + if (max_clipboard_size.has_value()) { + if (max_clipboard_size.value() >= 0) { + max_clipboard_size_ = max_clipboard_size.value(); } } }
diff --git a/remoting/host/it2me/it2me_host_unittest.cc b/remoting/host/it2me/it2me_host_unittest.cc index cf10a8e6..a8a395b 100644 --- a/remoting/host/it2me/it2me_host_unittest.cc +++ b/remoting/host/it2me/it2me_host_unittest.cc
@@ -34,9 +34,9 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #include "base/linux_util.h" -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) namespace remoting { @@ -232,7 +232,7 @@ It2MeHostTest::~It2MeHostTest() = default; void It2MeHostTest::SetUp() { -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Need to prime the host OS version value for linux to prevent IO on the // network thread. base::GetLinuxDistro() caches the result. base::GetLinuxDistro();
diff --git a/remoting/host/it2me/it2me_native_messaging_host.cc b/remoting/host/it2me/it2me_native_messaging_host.cc index 6ceaa053..3a7b620 100644 --- a/remoting/host/it2me/it2me_native_messaging_host.cc +++ b/remoting/host/it2me/it2me_native_messaging_host.cc
@@ -43,12 +43,12 @@ #include "remoting/signaling/xmpp_log_to_server.h" #include "services/network/public/cpp/shared_url_loader_factory.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/command_line.h" #include "base/files/file_path.h" #include "remoting/host/win/elevated_native_messaging_host.h" -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) namespace remoting { @@ -56,12 +56,12 @@ namespace { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) const base::FilePath::CharType kBaseHostBinaryName[] = FILE_PATH_LITERAL("remote_assistance_host.exe"); const base::FilePath::CharType kElevatedHostBinaryName[] = FILE_PATH_LITERAL("remote_assistance_host_uiaccess.exe"); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) constexpr char kAnonymousUserName[] = "anonymous_user"; @@ -204,7 +204,7 @@ return; } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Requests that the support host is launched with UiAccess on Windows. // This value, in conjuction with the platform policy, is used to determine // if an elevated host should be used. @@ -562,7 +562,7 @@ absl::optional<bool> It2MeNativeMessagingHost::GetAllowElevatedHostPolicyValue() { DCHECK(policy_received_); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) std::unique_ptr<base::DictionaryValue> platform_policies = policy_watcher_->GetPlatformPolicies(); if (platform_policies) { @@ -575,7 +575,7 @@ return value; } } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) return absl::nullopt; } @@ -641,7 +641,7 @@ return auth_service_with_token.substr(strlen(kOAuth2ServicePrefix)); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) bool It2MeNativeMessagingHost::DelegateToElevatedHost( std::unique_ptr<base::DictionaryValue> message) { @@ -672,7 +672,7 @@ return false; } -#else // !defined(OS_WIN) +#else // !BUILDFLAG(IS_WIN) bool It2MeNativeMessagingHost::DelegateToElevatedHost( std::unique_ptr<base::DictionaryValue> message) { @@ -680,6 +680,6 @@ return false; } -#endif // !defined(OS_WIN) +#endif // !BUILDFLAG(IS_WIN) } // namespace remoting
diff --git a/remoting/host/it2me/it2me_native_messaging_host.h b/remoting/host/it2me/it2me_native_messaging_host.h index ca6b608..e4dc459b 100644 --- a/remoting/host/it2me/it2me_native_messaging_host.h +++ b/remoting/host/it2me/it2me_native_messaging_host.h
@@ -114,12 +114,12 @@ // Forward messages to an |elevated_host_|. bool use_elevated_host_ = false; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Controls the lifetime of the elevated native messaging host process. // Note: 'elevated' in this instance means having the UiAccess privilege, not // being run as a higher privilege user. std::unique_ptr<ElevatedNativeMessagingHost> elevated_host_; -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) raw_ptr<Client> client_ = nullptr; DelegatingSignalStrategy::IqCallback incoming_message_callback_;
diff --git a/remoting/host/it2me/it2me_native_messaging_host_main.cc b/remoting/host/it2me/it2me_native_messaging_host_main.cc index c507991..deadd8c 100644 --- a/remoting/host/it2me/it2me_native_messaging_host_main.cc +++ b/remoting/host/it2me/it2me_native_messaging_host_main.cc
@@ -30,32 +30,32 @@ #include "remoting/host/resources.h" #include "remoting/host/usage_stats_consent.h" -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #include <gtk/gtk.h> #include "base/linux_util.h" #include "ui/events/platform/x11/x11_event_source.h" #include "ui/gfx/x/xlib_support.h" -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) #include "base/mac/mac_util.h" #include "base/mac/scoped_nsautorelease_pool.h" #include "remoting/host/desktop_capturer_checker.h" #include "remoting/host/mac/permission_utils.h" -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <windows.h> #include <commctrl.h> -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) namespace remoting { namespace { -#if defined(OS_WIN) && defined(OFFICIAL_BUILD) +#if BUILDFLAG(IS_WIN) && defined(OFFICIAL_BUILD) bool CurrentProcessHasUiAccess() { HANDLE process_token; OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &process_token); @@ -69,18 +69,18 @@ CloseHandle(process_token); return uiaccess_value != 0; } -#endif // defined(OS_WIN) && defined(OFFICIAL_BUILD) +#endif // BUILDFLAG(IS_WIN) && defined(OFFICIAL_BUILD) } // namespace // Creates a It2MeNativeMessagingHost instance, attaches it to stdin/stdout and // runs the task executor until It2MeNativeMessagingHost signals shutdown. int It2MeNativeMessagingHostMain(int argc, char** argv) { -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Initialize Xlib for multi-threaded use, allowing non-Chromium code to // use X11 safely (such as the WebRTC capturer, GTK ...) x11::InitXlib(); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // This object instance is required by Chrome code (such as // SingleThreadTaskExecutor). @@ -90,10 +90,10 @@ remoting::InitHostLogging(); remoting::HostSettings::Initialize(); -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) // Needed so we don't leak objects when threads are created. base::mac::ScopedNSAutoreleasePool pool; -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) #if defined(REMOTING_ENABLE_BREAKPAD) // Initialize Breakpad as early as possible. On Mac the command-line needs to @@ -104,13 +104,13 @@ } #endif // defined(REMOTING_ENABLE_BREAKPAD) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Register and initialize common controls. INITCOMMONCONTROLSEX info; info.dwSize = sizeof(info); info.dwICC = ICC_STANDARD_CLASSES; InitCommonControlsEx(&info); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) // Required to find the ICU data file, used by some file_util routines. base::i18n::InitializeICU(); @@ -121,7 +121,7 @@ remoting::LoadResources(""); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Required for any calls into GTK functions, such as the Disconnect and // Continue windows. Calling with nullptr arguments because we don't have // any command line arguments for gtk to consume. @@ -134,13 +134,13 @@ // Need to prime the host OS version value for linux to prevent IO on the // network thread. base::GetLinuxDistro() caches the result. base::GetLinuxDistro(); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) base::File read_file; base::File write_file; bool is_process_elevated_ = false; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) const base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); @@ -202,7 +202,7 @@ SetStdHandle(STD_INPUT_HANDLE, nullptr); SetStdHandle(STD_OUTPUT_HANDLE, nullptr); } -#elif defined(OS_POSIX) +#elif BUILDFLAG(IS_POSIX) // The files are automatically closed. read_file = base::File(STDIN_FILENO); write_file = base::File(STDOUT_FILENO); @@ -213,7 +213,7 @@ base::SingleThreadTaskExecutor main_task_executor(base::MessagePumpType::UI); base::RunLoop run_loop; -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) auto* cmd_line = base::CommandLine::ForCurrentProcess(); if (cmd_line->HasSwitch(kCheckAccessibilityPermissionSwitchName)) { return mac::CanInjectInput() ? EXIT_SUCCESS : EXIT_FAILURE; @@ -228,7 +228,7 @@ } return mac::CanRecordScreen() ? EXIT_SUCCESS : EXIT_FAILURE; } -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) // NetworkChangeNotifier must be initialized after SingleThreadTaskExecutor. std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier( @@ -243,9 +243,9 @@ std::unique_ptr<extensions::NativeMessagingChannel> channel( new PipeMessagingChannel(std::move(read_file), std::move(write_file))); -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) PipeMessagingChannel::ReopenStdinStdout(); -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) std::unique_ptr<ChromotingHostContext> context = ChromotingHostContext::Create(new remoting::AutoThreadTaskRunner( @@ -254,7 +254,7 @@ PolicyWatcher::CreateWithTaskRunner(context->file_task_runner(), context->management_service()); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Create an X11EventSource on all UI threads, so the global X11 connection // (x11::Connection::Get()) can dispatch X events. auto event_source = @@ -263,7 +263,7 @@ input_task_runner->PostTask(FROM_HERE, base::BindOnce([]() { new ui::X11EventSource(x11::Connection::Get()); })); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) std::unique_ptr<extensions::NativeMessageHost> host( new It2MeNativeMessagingHost(is_process_elevated_, @@ -276,11 +276,11 @@ // Run the loop until channel is alive. run_loop.Run(); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) input_task_runner->PostTask(FROM_HERE, base::BindOnce([]() { delete ui::X11EventSource::GetInstance(); })); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Block until tasks blocking shutdown have completed their execution. base::ThreadPoolInstance::Get()->Shutdown();
diff --git a/remoting/host/it2me_desktop_environment.cc b/remoting/host/it2me_desktop_environment.cc index 43bc1f8..f92dbba8 100644 --- a/remoting/host/it2me_desktop_environment.cc +++ b/remoting/host/it2me_desktop_environment.cc
@@ -17,10 +17,10 @@ #include "remoting/host/input_monitor/local_input_monitor.h" #include "remoting/protocol/capability_names.h" -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) #include <sys/types.h> #include <unistd.h> -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) namespace remoting { @@ -51,7 +51,7 @@ bool enable_user_interface = options.enable_user_interface(); bool enable_notifications = options.enable_notifications(); // The host UI should be created on the UI thread. -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) // Don't try to display any UI on top of the system's login screen as this // is rejected by the Window Server on OS X 10.7.4, and prevents the // capturer from working (http://crbug.com/140984). @@ -60,7 +60,7 @@ // running in the LoginWindow context, and refactor this into a separate // function to be used here and in CurtainMode::ActivateCurtain(). enable_user_interface = getuid() != 0; -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) // Create the continue window. The implication of this window is that the // session length will be limited. If the user interface is disabled,
diff --git a/remoting/host/me2me_desktop_environment.cc b/remoting/host/me2me_desktop_environment.cc index f9e071a..d534a772 100644 --- a/remoting/host/me2me_desktop_environment.cc +++ b/remoting/host/me2me_desktop_environment.cc
@@ -27,14 +27,14 @@ #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) #include <sys/types.h> #include <unistd.h> -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/win/windows_version.h" -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) namespace remoting { @@ -76,7 +76,7 @@ capabilities += protocol::kFileTransferCapability; } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) capabilities += " "; capabilities += protocol::kSendAttentionSequenceAction; @@ -85,7 +85,7 @@ capabilities += " "; capabilities += protocol::kLockWorkstationAction; } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) if (desktop_environment_options().enable_remote_open_url() && IsRemoteOpenUrlSupported()) { @@ -143,9 +143,9 @@ // Otherwise, if the session is shared with the local user start monitoring // the local input and create the in-session UI. -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) bool want_user_interface = false; -#elif defined(OS_APPLE) +#elif BUILDFLAG(IS_APPLE) // Don't try to display any UI on top of the system's login screen as this // is rejected by the Window Server on OS X 10.7.4, and prevents the // capturer from working (http://crbug.com/140984). @@ -167,7 +167,7 @@ client_session_control); // Create the disconnect window. -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) disconnect_window_ = HostWindow::CreateAutoHidingDisconnectWindow(LocalInputMonitor::Create( caller_task_runner(), input_task_runner(), ui_task_runner()));
diff --git a/remoting/host/mojo_ipc/mojo_ipc_server.cc b/remoting/host/mojo_ipc/mojo_ipc_server.cc index 0c1bd22..265f43d 100644 --- a/remoting/host/mojo_ipc/mojo_ipc_server.cc +++ b/remoting/host/mojo_ipc/mojo_ipc_server.cc
@@ -16,10 +16,10 @@ #include "build/build_config.h" #include "remoting/host/mojo_ipc/mojo_server_endpoint_connector.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/strings/stringprintf.h" #include "base/win/win_util.h" -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) namespace remoting { @@ -34,7 +34,7 @@ mojo::NamedPlatformChannel::Options options; options.server_name = server_name; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) options.enforce_uniqueness = false; // Create a named pipe owned by the current user (the LocalService account // (SID: S-1-5-19) when running in the network process) which is available to @@ -47,7 +47,7 @@ } options.security_descriptor = base::StringPrintf( L"O:%lsG:%lsD:(A;;GA;;;AU)", user_sid.c_str(), user_sid.c_str()); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) mojo::NamedPlatformChannel channel(options); return channel.TakeServerEndpoint();
diff --git a/remoting/host/mojo_ipc/mojo_ipc_test_util.cc b/remoting/host/mojo_ipc/mojo_ipc_test_util.cc index 8e1e6b3..b6ae3890 100644 --- a/remoting/host/mojo_ipc/mojo_ipc_test_util.cc +++ b/remoting/host/mojo_ipc/mojo_ipc_test_util.cc
@@ -18,7 +18,7 @@ mojo::NamedPlatformChannel::ServerName GenerateRandomServerName() { std::string temp_path; -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) // Posix server names should start with the temp directory path. Otherwise the // socket file will be created under the current working directory. base::FilePath temp_file_path;
diff --git a/remoting/host/mojo_ipc/mojo_ipc_util.cc b/remoting/host/mojo_ipc/mojo_ipc_util.cc index 7dff0a0..c9cf74f 100644 --- a/remoting/host/mojo_ipc/mojo_ipc_util.cc +++ b/remoting/host/mojo_ipc/mojo_ipc_util.cc
@@ -8,7 +8,7 @@ #include "build/build_config.h" -#if defined(OS_POSIX) && !defined(OS_MAC) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/logging.h" @@ -18,7 +18,7 @@ mojo::NamedPlatformChannel::ServerName WorkingDirectoryIndependentServerNameFromUTF8(base::StringPiece name) { -#if defined(OS_POSIX) && !defined(OS_MAC) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) // The channel name on non-mac POSIX (basically Linux) is the path to a unix // domain socket, so it needs to be an absolute path to allow the IPC binary // to be executed from any working directory.
diff --git a/remoting/host/native_messaging/native_messaging_reader.cc b/remoting/host/native_messaging/native_messaging_reader.cc index 8290746..bfe6916697 100644 --- a/remoting/host/native_messaging/native_messaging_reader.cc +++ b/remoting/host/native_messaging/native_messaging_reader.cc
@@ -23,12 +23,12 @@ #include "base/values.h" #include "build/build_config.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <windows.h> #include "base/threading/platform_thread.h" #include "base/win/scoped_handle.h" -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) namespace { @@ -160,7 +160,7 @@ NativeMessagingReader::~NativeMessagingReader() { read_task_runner_->DeleteSoon(FROM_HERE, core_.release()); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // The ReadMessage() method uses a blocking read (on all platforms) which // cause a deadlock if the owning thread attempts to destroy this object // while there is a read operation pending. @@ -181,7 +181,7 @@ PLOG(ERROR) << "CancelSynchronousIo() failed"; } } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) } void NativeMessagingReader::Start(const MessageCallback& message_callback,
diff --git a/remoting/host/native_messaging/native_messaging_reader_unittest.cc b/remoting/host/native_messaging/native_messaging_reader_unittest.cc index c0309b8..1d1a597 100644 --- a/remoting/host/native_messaging/native_messaging_reader_unittest.cc +++ b/remoting/host/native_messaging/native_messaging_reader_unittest.cc
@@ -112,7 +112,7 @@ ASSERT_TRUE(on_error_signaled_); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // This scenario is only a problem on Windows as closing the write pipe there // does not trigger the parent process to close the read pipe. TEST_F(NativeMessagingReaderTest, ReaderDestroyedByOwner) { @@ -124,7 +124,7 @@ reader_.reset(); ASSERT_FALSE(on_error_signaled_); } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) TEST_F(NativeMessagingReaderTest, SingleGoodMessage) { WriteMessage("{\"foo\": 42}");
diff --git a/remoting/host/native_messaging/pipe_messaging_channel.cc b/remoting/host/native_messaging/pipe_messaging_channel.cc index 1603e8f7..914a218 100644 --- a/remoting/host/native_messaging/pipe_messaging_channel.cc +++ b/remoting/host/native_messaging/pipe_messaging_channel.cc
@@ -30,7 +30,7 @@ // static void PipeMessagingChannel::ReopenStdinStdout() { -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) base::FilePath dev_null("/dev/null"); int new_stdin = base::File(dev_null, base::File::FLAG_OPEN | base::File::FLAG_READ) @@ -40,7 +40,7 @@ base::File(dev_null, base::File::FLAG_OPEN | base::File::FLAG_WRITE) .TakePlatformFile(); DCHECK_EQ(new_stdout, STDOUT_FILENO); -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) } void PipeMessagingChannel::Start(EventHandler* event_handler) {
diff --git a/remoting/host/policy_watcher.cc b/remoting/host/policy_watcher.cc index 588c211..75410c188 100644 --- a/remoting/host/policy_watcher.cc +++ b/remoting/host/policy_watcher.cc
@@ -34,12 +34,12 @@ #include "base/json/json_reader.h" #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "components/policy/core/common/policy_loader_win.h" -#elif defined(OS_APPLE) +#elif BUILDFLAG(IS_APPLE) #include "components/policy/core/common/policy_loader_mac.h" #include "components/policy/core/common/preferences_mac.h" -#elif defined(OS_POSIX) && !defined(OS_ANDROID) +#elif BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) #include "components/policy/core/common/config_dir_policy_loader.h" #endif @@ -49,7 +49,7 @@ namespace { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) constexpr wchar_t kChromePolicyKey[] = L"SOFTWARE\\Policies\\Google\\Chrome"; #endif @@ -384,7 +384,7 @@ const policy::PolicyMap& current = policy_service_->GetPolicies(ns); OnPolicyUpdated(ns, current, current); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) WatchForRegistryChanges(); #endif } @@ -416,7 +416,7 @@ CreateSchemaRegistry())); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) void PolicyWatcher::WatchForRegistryChanges() { if (!policy_key_.Valid()) { auto open_result = @@ -451,21 +451,21 @@ // (even on Chromium) so that policy enforcement can't be bypassed by running // Chromium. std::unique_ptr<policy::AsyncPolicyLoader> policy_loader; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) policy_loader = std::make_unique<policy::PolicyLoaderWin>( file_task_runner, management_service, kChromePolicyKey); -#elif defined(OS_APPLE) +#elif BUILDFLAG(IS_APPLE) CFStringRef bundle_id = CFSTR("com.google.Chrome"); policy_loader = std::make_unique<policy::PolicyLoaderMac>( file_task_runner, policy::PolicyLoaderMac::GetManagedPolicyPath(bundle_id), new MacPreferences(), bundle_id); -#elif defined(OS_POSIX) && !defined(OS_ANDROID) +#elif BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) policy_loader = std::make_unique<policy::ConfigDirPolicyLoader>( file_task_runner, base::FilePath(FILE_PATH_LITERAL("/etc/opt/chrome/policies")), policy::POLICY_SCOPE_MACHINE); -#elif defined(OS_ANDROID) +#elif BUILDFLAG(IS_ANDROID) NOTIMPLEMENTED(); policy::PolicyServiceImpl::Providers providers; std::unique_ptr<policy::PolicyService> owned_policy_service(
diff --git a/remoting/host/policy_watcher.h b/remoting/host/policy_watcher.h index 3e3e3c1..2b0d08cb 100644 --- a/remoting/host/policy_watcher.h +++ b/remoting/host/policy_watcher.h
@@ -14,7 +14,7 @@ #include "build/build_config.h" #include "components/policy/core/common/policy_service.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/win/registry.h" #endif @@ -156,7 +156,7 @@ const policy::PolicyMap& current) override; void OnPolicyServiceInitialized(policy::PolicyDomain domain) override; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) void WatchForRegistryChanges(); #endif @@ -183,7 +183,7 @@ std::unique_ptr<policy::ConfigurationPolicyProvider> owned_policy_provider_; std::unique_ptr<policy::PolicyService> owned_policy_service_; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // |policy_key_| relies on |policy_service_| to notify the host of policy // changes. Make sure |policy_key_| is destroyed to prevent any notifications // from firing while the above objects are being torn down.
diff --git a/remoting/host/policy_watcher_unittest.cc b/remoting/host/policy_watcher_unittest.cc index 3541227..28b6522 100644 --- a/remoting/host/policy_watcher_unittest.cc +++ b/remoting/host/policy_watcher_unittest.cc
@@ -517,7 +517,7 @@ ON_CALL(mock_log, Log(_, _, _, _, _)).WillByDefault(testing::Return(true)); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // The PolicyWatcher on Windows tries to open a handle to the Chrome policy // registry key on Windows which fails on the Chromium bots. The warning that // gets logged cases the subsequent log assertion to fail so this check was @@ -589,7 +589,7 @@ testing::InSequence sequence; EXPECT_CALL(mock_policy_callback_, OnPolicyUpdatePtr(IsPolicies(&nat_true_others_default_))); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // This setting only affects Windows, it is ignored on other platforms so the // 2 SetPolicies calls won't result in any calls to OnPolicyUpdate. EXPECT_CALL(mock_policy_callback_, @@ -597,7 +597,7 @@ EXPECT_CALL( mock_policy_callback_, OnPolicyUpdatePtr(IsPolicies(&remote_assistance_uiaccess_false_))); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) SetPolicies(empty_); StartWatching(); @@ -640,7 +640,7 @@ testing::InSequence sequence; EXPECT_CALL(mock_policy_callback_, OnPolicyUpdatePtr(IsPolicies(&nat_true_others_default_))); -#if !defined(OS_WIN) +#if !BUILDFLAG(IS_WIN) EXPECT_CALL(mock_policy_callback_, OnPolicyUpdatePtr(IsPolicies(&username_true_))); EXPECT_CALL(mock_policy_callback_, @@ -716,7 +716,7 @@ i.Advance()) { expected_schema[i.key()] = i.value().type(); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // RemoteAccessHostMatchUsername is marked in policy_templates.json as not // supported on Windows and therefore is (by design) excluded from the schema. expected_schema.erase(key::kRemoteAccessHostMatchUsername); @@ -730,7 +730,7 @@ expected_schema.erase(key::kRemoteAccessHostTokenValidationUrl); expected_schema.erase(key::kRemoteAccessHostTokenValidationCertificateIssuer); expected_schema.erase(key::kRemoteAccessHostAllowUiAccessForRemoteAssistance); -#else // !defined(OS_WIN) +#else // !BUILDFLAG(IS_WIN) // RemoteAssistanceHostAllowUiAccess does not exist on non-Windows platforms. expected_schema.erase(key::kRemoteAccessHostAllowUiAccessForRemoteAssistance); #endif
diff --git a/remoting/host/remote_open_url/remote_open_url_client.cc b/remoting/host/remote_open_url/remote_open_url_client.cc index f3abd24..b6f9dea8 100644 --- a/remoting/host/remote_open_url/remote_open_url_client.cc +++ b/remoting/host/remote_open_url/remote_open_url_client.cc
@@ -15,9 +15,9 @@ #include "remoting/host/mojom/chromoting_host_services.mojom.h" #include "remoting/host/mojom/remote_url_opener.mojom.h" -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) #include "remoting/host/remote_open_url/remote_open_url_client_delegate_linux.h" -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) #include "remoting/host/remote_open_url/remote_open_url_client_delegate_win.h" #endif @@ -28,9 +28,9 @@ constexpr base::TimeDelta kRequestTimeout = base::Seconds(5); std::unique_ptr<RemoteOpenUrlClient::Delegate> CreateDelegate() { -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) return std::make_unique<RemoteOpenUrlClientDelegateLinux>(); -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) return std::make_unique<RemoteOpenUrlClientDelegateWin>(); #else NOTREACHED();
diff --git a/remoting/host/remote_open_url/remote_open_url_constants.cc b/remoting/host/remote_open_url/remote_open_url_constants.cc index b32b7d1..0dc94302 100644 --- a/remoting/host/remote_open_url/remote_open_url_constants.cc +++ b/remoting/host/remote_open_url/remote_open_url_constants.cc
@@ -10,7 +10,7 @@ const char kRemoteOpenUrlDataChannelName[] = "remote-open-url"; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #if defined(OFFICIAL_BUILD) const wchar_t kUrlForwarderProgId[] = L"ChromeRemoteDesktopUrlForwarder";
diff --git a/remoting/host/remote_open_url/remote_open_url_constants.h b/remoting/host/remote_open_url/remote_open_url_constants.h index 1c6257f..4d807f6d37 100644 --- a/remoting/host/remote_open_url/remote_open_url_constants.h +++ b/remoting/host/remote_open_url/remote_open_url_constants.h
@@ -11,7 +11,7 @@ extern const char kRemoteOpenUrlDataChannelName[]; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // The ProgID of the URL forwarder. extern const wchar_t kUrlForwarderProgId[];
diff --git a/remoting/host/remote_open_url/remote_open_url_util.cc b/remoting/host/remote_open_url/remote_open_url_util.cc index 1710da5..ce3cad5d 100644 --- a/remoting/host/remote_open_url/remote_open_url_util.cc +++ b/remoting/host/remote_open_url/remote_open_url_util.cc
@@ -7,7 +7,7 @@ #include "base/logging.h" #include "build/build_config.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/win/registry.h" #include "base/win/windows_types.h" #include "base/win/windows_version.h" @@ -15,7 +15,7 @@ namespace remoting { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #if defined(OFFICIAL_BUILD) const wchar_t kUrlForwarderRegisteredAppName[] = @@ -30,9 +30,9 @@ #endif // defined (OS_WIN) bool IsRemoteOpenUrlSupported() { -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) return true; -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) // The modern default apps settings dialog is only available to Windows 8+. // Given older Windows versions are EOL, we only advertise the feature on // Windows 8+.
diff --git a/remoting/host/remote_open_url/url_forwarder_configurator.cc b/remoting/host/remote_open_url/url_forwarder_configurator.cc index 0f4ee27..71fdd92 100644 --- a/remoting/host/remote_open_url/url_forwarder_configurator.cc +++ b/remoting/host/remote_open_url/url_forwarder_configurator.cc
@@ -12,7 +12,7 @@ UrlForwarderConfigurator::~UrlForwarderConfigurator() = default; -#if !defined(OS_LINUX) && !defined(OS_WIN) +#if !BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_WIN) // static std::unique_ptr<UrlForwarderConfigurator> UrlForwarderConfigurator::Create() { @@ -22,6 +22,6 @@ return nullptr; } -#endif // !defined(OS_LINUX) && !defined(OS_WIN) +#endif // !BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_WIN) } // namespace remoting
diff --git a/remoting/host/remoting_me2me_host.cc b/remoting/host/remoting_me2me_host.cc index 44271ba..06e272d 100644 --- a/remoting/host/remoting_me2me_host.cc +++ b/remoting/host/remoting_me2me_host.cc
@@ -106,24 +106,24 @@ #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/webrtc/api/scoped_refptr.h" -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) #include <signal.h> #include <sys/types.h> #include <unistd.h> #include "base/file_descriptor_posix.h" #include "remoting/host/pam_authorization_factory_posix.h" #include "remoting/host/posix/signal_handler.h" -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) #include "base/mac/mac_util.h" #include "base/mac/scoped_cftyperef.h" #include "remoting/host/audio_capturer_mac.h" #include "remoting/host/desktop_capturer_checker.h" #include "remoting/host/mac/permission_utils.h" -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #include <gtk/gtk.h> #include "base/linux_util.h" @@ -131,21 +131,21 @@ #include "remoting/host/linux/certificate_watcher.h" #include "ui/events/platform/x11/x11_event_source.h" #include "ui/gfx/x/xlib_support.h" -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <commctrl.h> #include "base/win/registry.h" #include "base/win/scoped_handle.h" #include "base/win/windows_version.h" #include "remoting/host/pairing_registry_delegate_win.h" #include "remoting/host/win/session_desktop_environment.h" -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) using remoting::protocol::PairingRegistry; using remoting::protocol::NetworkSettings; -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) // The following creates a section that tells Mac OS X that it is OK to let us // inject input in the login screen. Just the name of the section is important, @@ -154,7 +154,7 @@ __attribute__((section ("__CGPreLoginApp,__cgpreloginapp"))) static const char magic_section[] = ""; -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) namespace { @@ -167,17 +167,17 @@ const char kStdinConfigPath[] = "-"; #endif // !defined(REMOTING_MULTI_PROCESS) -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // The command line switch used to pass name of the pipe to capture audio on // linux. const char kAudioPipeSwitchName[] = "audio-pipe-name"; -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) // The command line switch used to pass name of the unix domain socket used to // listen for security key requests. const char kAuthSocknameSwitchName[] = "ssh-auth-sockname"; -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) // The command line switch used by the parent to request the host to signal it // when it is successfully started. @@ -285,7 +285,7 @@ void ShutdownOnNetworkThread(); -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) // Callback passed to RegisterSignalHandler() to handle SIGTERM events. void SigTermHandler(int signal_number); #endif @@ -355,7 +355,7 @@ void GoOffline(const std::string& host_offline_reason); void OnHostOfflineReasonAck(bool success); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // mojom::RemotingHostControl implementation. void CrashHostProcess(const std::string& function_name, const std::string& file_name, @@ -368,7 +368,7 @@ std::unique_ptr<ChromotingHostContext> context_; -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Watch for certificate changes and kill the host when changes occur std::unique_ptr<CertificateWatcher> cert_watcher_; #endif @@ -463,13 +463,13 @@ mojo::AssociatedReceiver<mojom::RemotingHostControl> remoting_host_control_{ this}; -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) // When using the command line option to check the Accessibility or Screen // Recording permission, these track the permission state and indicate that // the host should exit immediately with the result. bool checking_permission_state_ = false; bool permission_granted_ = false; -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) }; HostProcess::HostProcess(std::unique_ptr<ChromotingHostContext> context, @@ -487,7 +487,7 @@ StartOnUiThread(); -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) if (checking_permission_state_) { *exit_code_out = (permission_granted_ ? EXIT_SUCCESS : EXIT_FAILURE); } @@ -510,7 +510,7 @@ } bool HostProcess::InitWithCommandLine(const base::CommandLine* cmd_line) { -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) if (cmd_line->HasSwitch(kCheckAccessibilityPermissionSwitchName)) { checking_permission_state_ = true; permission_granted_ = mac::CanInjectInput(); @@ -539,7 +539,7 @@ } return false; } -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) // Mojo keeps the task runner passed to it alive forever, so an // AutoThreadTaskRunner should not be passed to it. Otherwise, the process may @@ -731,22 +731,22 @@ } #endif // !defined(REMOTING_MULTI_PROCESS) -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) remoting::RegisterSignalHandler( SIGTERM, base::BindRepeating(&HostProcess::SigTermHandler, base::Unretained(this))); -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) } void HostProcess::ShutdownOnNetworkThread() { DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); config_watcher_.reset(); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) cert_watcher_.reset(); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) } -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) void HostProcess::SigTermHandler(int signal_number) { DCHECK(signal_number == SIGTERM); DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); @@ -775,7 +775,7 @@ if (allow_pairing_) { // On Windows |pairing_registry_| is initialized in // InitializePairingRegistry(). -#if !defined(OS_WIN) +#if !BUILDFLAG(IS_WIN) if (!pairing_registry_) { std::unique_ptr<PairingRegistry::Delegate> delegate = CreatePairingRegistryDelegate(); @@ -784,7 +784,7 @@ pairing_registry_ = new PairingRegistry(context_->file_task_runner(), std::move(delegate)); } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) pairing_registry = pairing_registry_; } @@ -800,7 +800,7 @@ DCHECK(third_party_auth_config_.token_url.is_valid()); DCHECK(third_party_auth_config_.token_validation_url.is_valid()); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) if (!cert_watcher_) { cert_watcher_ = std::make_unique<CertificateWatcher>( base::BindRepeating(&HostProcess::ShutdownHost, @@ -809,7 +809,7 @@ cert_watcher_->Start(); } cert_watcher_->SetMonitor(host_->status_monitor()); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) scoped_refptr<protocol::TokenValidatorFactory> token_validator_factory = new TokenValidatorFactoryImpl(third_party_auth_config_, key_pair_, @@ -819,10 +819,10 @@ token_validator_factory); } -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) // On Linux and Mac, perform a PAM authorization step after authentication. factory = std::make_unique<PamAuthorizationFactory>(std::move(factory)); -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) host_->SetAuthenticatorFactory(std::move(factory)); } @@ -914,7 +914,7 @@ base::BindRepeating(&HostProcess::OnPolicyUpdate, base::Unretained(this)), base::BindRepeating(&HostProcess::OnPolicyError, base::Unretained(this))); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // If an audio pipe is specific on the command-line then initialize // AudioCapturerLinux to capture from it. base::FilePath audio_pipe_name = base::CommandLine::ForCurrentProcess()-> @@ -923,9 +923,9 @@ remoting::AudioCapturerLinux::InitializePipeReader( context_->audio_task_runner(), audio_pipe_name); } -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) base::FilePath security_key_socket_name = base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( kAuthSocknameSwitchName); @@ -935,7 +935,7 @@ } else { security_key_extension_supported_ = false; } -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) // Create a desktop environment factory appropriate to the build type & // platform. @@ -975,7 +975,7 @@ // It is now safe for the HostProcess to be deleted. self_ = nullptr; -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Cause the global AudioPipeReader to be freed, otherwise the audio // thread will remain in-use and prevent the process from exiting. // TODO(wez): DesktopEnvironmentFactory should own the pipe reader. @@ -998,7 +998,7 @@ return; } HOST_LOG << "Host ready to receive connections."; -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) if (signal_parent_) { kill(getppid(), SIGUSR1); signal_parent_ = false; @@ -1011,7 +1011,7 @@ ShutdownHost(kHostDeletedExitCode); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) void HostProcess::ApplyHostConfig(base::Value config) { DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); OnConfigParsed(std::move(config)); @@ -1050,7 +1050,7 @@ // initialized. CreateAuthenticatorFactory(); } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) // Applies the host config, returning true if successful. bool HostProcess::ApplyConfig(const base::Value& config) { @@ -1276,7 +1276,7 @@ !base::StartsWith(host_owner_, username + std::string("@"), base::CompareCase::INSENSITIVE_ASCII); -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) // On Mac, we run as root at the login screen, so the username won't match. // However, there's no need to enforce the policy at the login screen, as // the client will have to reconnect if a login occurs. @@ -1288,10 +1288,10 @@ // Curtain-mode on Windows presents the standard OS login prompt to the user // for each connection, removing the need for an explicit user-name matching // check. -#if defined(OS_WIN) && defined(REMOTING_RDP_SESSION) +#if BUILDFLAG(IS_WIN) && defined(REMOTING_RDP_SESSION) if (desktop_environment_options_.enable_curtaining()) return; -#endif // defined(OS_WIN) && defined(REMOTING_RDP_SESSION) +#endif // BUILDFLAG(IS_WIN) && defined(REMOTING_RDP_SESSION) // Shutdown the host if the username does not match. if (shutdown) { @@ -1357,15 +1357,15 @@ // Returns true if the host has to be restarted after this policy update. DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); - std::string string_value; - if (!policies->GetString(policy::key::kRemoteAccessHostUdpPortRange, - &string_value)) { + const std::string* string_value = + policies->FindStringKey(policy::key::kRemoteAccessHostUdpPortRange); + if (!string_value) { return false; } - if (!PortRange::Parse(string_value, &udp_port_range_)) { + if (!PortRange::Parse(*string_value, &udp_port_range_)) { // PolicyWatcher verifies that the value is formatted correctly. - LOG(FATAL) << "Invalid port range: " << string_value; + LOG(FATAL) << "Invalid port range: " << *string_value; } HOST_LOG << "Policy restricts UDP port range to: " << udp_port_range_; return true; @@ -1382,7 +1382,7 @@ desktop_environment_options_.set_enable_curtaining(curtain_required.value()); -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) if (curtain_required.value()) { // When curtain mode is in effect on Mac, the host process runs in the // user's switched-out session, but launchd will also run an instance at @@ -1685,7 +1685,7 @@ // The feature is enabled for all Googlers using a supported platform. desktop_environment_options_.set_enable_remote_open_url(is_googler_); -#if defined(OS_LINUX) || !defined(NDEBUG) +#if BUILDFLAG(IS_LINUX) || !defined(NDEBUG) // Experimental feature. Enabled on Linux for easier testing. if (is_googler_) { desktop_environment_options_.set_enable_remote_webauthn(true); @@ -1741,7 +1741,7 @@ HostEventLogger::Create(host_->status_monitor(), kApplicationName); #endif // !defined(REMOTING_MULTI_PROCESS) -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) // Don't run the permission-checks as root (i.e. at the login screen), as they // are not actionable there. // Also, the permission-checks are not needed on MacOS 10.15+, as they are @@ -1750,7 +1750,7 @@ if (getuid() != 0U && base::mac::IsAtMostOS10_14()) { mac::PromptUserToChangeTrustStateIfNeeded(context_->ui_task_runner()); } -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) host_->Start(host_owner_); host_->StartChromotingHostServices(); @@ -1870,7 +1870,7 @@ } } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) void HostProcess::CrashHostProcess(const std::string& function_name, const std::string& file_name, int line_number) { @@ -1882,7 +1882,7 @@ int HostProcessMain() { HOST_LOG << "Starting host process: version " << STRINGIZE(VERSION); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Initialize Xlib for multi-threaded use, allowing non-Chromium code to // use X11 safely (such as the WebRTC capturer, GTK ...) x11::InitXlib(); @@ -1902,7 +1902,7 @@ // Need to prime the host OS version value for linux to prevent IO on the // network thread. base::GetLinuxDistro() caches the result. base::GetLinuxDistro(); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) base::ThreadPoolInstance::CreateAndStartWithDefaultParams("Me2Me"); @@ -1919,7 +1919,7 @@ std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier( net::NetworkChangeNotifier::CreateIfNeeded()); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Create an X11EventSource on all UI threads, so the global X11 connection // (x11::Connection::Get()) can dispatch X events. auto event_source = @@ -1927,7 +1927,7 @@ context->input_task_runner()->PostTask( FROM_HERE, base::BindOnce([]() { new ui::X11EventSource(x11::Connection::Get()); })); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Create & start the HostProcess using these threads. // TODO(wez): The HostProcess holds a reference to itself until Shutdown().
diff --git a/remoting/host/resources_unittest.cc b/remoting/host/resources_unittest.cc index b29f70c..1cd23a4 100644 --- a/remoting/host/resources_unittest.cc +++ b/remoting/host/resources_unittest.cc
@@ -33,7 +33,7 @@ #endif // BUILDFLAGdefined(GOOGLE_CRANDING) // Chrome-style i18n is not used on Windows or Android. -#if defined(OS_WIN) || defined(OS_ANDROID) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_ANDROID) EXPECT_FALSE(resources_available_); #else EXPECT_TRUE(resources_available_);
diff --git a/remoting/host/security_key/fake_security_key_ipc_server.cc b/remoting/host/security_key/fake_security_key_ipc_server.cc index 0ccf292..c21769c 100644 --- a/remoting/host/security_key/fake_security_key_ipc_server.cc +++ b/remoting/host/security_key/fake_security_key_ipc_server.cc
@@ -88,7 +88,7 @@ base::TimeDelta request_timeout) { mojo::NamedPlatformChannel::Options options; options.server_name = server_name; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) options.enforce_uniqueness = false; #endif mojo::NamedPlatformChannel channel(options);
diff --git a/remoting/host/security_key/remote_security_key_main.cc b/remoting/host/security_key/remote_security_key_main.cc index cdd23cd..a46c6ac 100644 --- a/remoting/host/security_key/remote_security_key_main.cc +++ b/remoting/host/security_key/remote_security_key_main.cc
@@ -22,16 +22,16 @@ #include "remoting/host/security_key/security_key_ipc_client.h" #include "remoting/host/security_key/security_key_message_handler.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <windows.h> #include "remoting/host/win/acl_util.h" -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) namespace remoting { int StartRemoteSecurityKey() { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) if (!AddProcessAccessRightForWellKnownSid( WinLocalServiceSid, PROCESS_QUERY_LIMITED_INFORMATION)) { return kInitializationFailed; @@ -54,7 +54,7 @@ // handles as soon as we retrieve the corresponding file handles. SetStdHandle(STD_INPUT_HANDLE, nullptr); SetStdHandle(STD_OUTPUT_HANDLE, nullptr); -#elif defined(OS_POSIX) +#elif BUILDFLAG(IS_POSIX) // The files are automatically closed. base::File read_file(STDIN_FILENO); base::File write_file(STDOUT_FILENO);
diff --git a/remoting/host/security_key/security_key_auth_handler.h b/remoting/host/security_key/security_key_auth_handler.h index 6bbe16d..bc5ff4e 100644 --- a/remoting/host/security_key/security_key_auth_handler.h +++ b/remoting/host/security_key/security_key_auth_handler.h
@@ -42,11 +42,11 @@ const SendMessageCallback& send_message_callback, scoped_refptr<base::SingleThreadTaskRunner> file_task_runner); -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) // Specify the name of the socket to listen to security key requests on. static void SetSecurityKeySocketName( const base::FilePath& security_key_socket_name); -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) // Sets the callback used to send messages to the client. virtual void SetSendMessageCallback(const SendMessageCallback& callback) = 0;
diff --git a/remoting/host/security_key/security_key_ipc_client.cc b/remoting/host/security_key/security_key_ipc_client.cc index aaa6b5c3..d0b5164 100644 --- a/remoting/host/security_key/security_key_ipc_client.cc +++ b/remoting/host/security_key/security_key_ipc_client.cc
@@ -16,7 +16,7 @@ #include "ipc/ipc_listener.h" #include "remoting/host/security_key/security_key_ipc_constants.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <Windows.h> #endif @@ -104,7 +104,7 @@ void SecurityKeyIpcClient::OnChannelConnected(int32_t peer_pid) { DCHECK(thread_checker_.CalledOnValidThread()); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) DWORD peer_session_id; if (!ProcessIdToSessionId(peer_pid, &peer_session_id)) { PLOG(ERROR) << "ProcessIdToSessionId failed"; @@ -119,7 +119,7 @@ std::move(connection_error_callback_).Run(); return; } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) std::move(connected_callback_).Run(); }
diff --git a/remoting/host/security_key/security_key_ipc_client_unittest.cc b/remoting/host/security_key/security_key_ipc_client_unittest.cc index 56398bd3..6b09da76 100644 --- a/remoting/host/security_key/security_key_ipc_client_unittest.cc +++ b/remoting/host/security_key/security_key_ipc_client_unittest.cc
@@ -17,7 +17,7 @@ #include "remoting/host/security_key/security_key_ipc_constants.h" #include "testing/gtest/include/gtest/gtest.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <windows.h> #endif @@ -125,14 +125,14 @@ SecurityKeyIpcClientTest::~SecurityKeyIpcClientTest() = default; void SecurityKeyIpcClientTest::SetUp() { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) DWORD session_id = 0; // If we are on Windows, then we need to set the correct session ID or the // IPC connection will not be created successfully. ASSERT_TRUE(ProcessIdToSessionId(GetCurrentProcessId(), &session_id)); session_id_ = session_id; security_key_ipc_client_.SetExpectedIpcServerSessionIdForTest(session_id_); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) } void SecurityKeyIpcClientTest::OperationComplete(bool failed) { @@ -338,7 +338,7 @@ ASSERT_TRUE(operation_failed_); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) TEST_F(SecurityKeyIpcClientTest, SecurityKeyIpcServerRunningInWrongSession) { // Set the expected session Id to a different session than we are running in. security_key_ipc_client_.SetExpectedIpcServerSessionIdForTest(session_id_ + @@ -359,6 +359,6 @@ EstablishConnection(/*expect_error=*/true); } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) } // namespace remoting
diff --git a/remoting/host/security_key/security_key_ipc_constants.cc b/remoting/host/security_key/security_key_ipc_constants.cc index 0100a9a..3a3e1830 100644 --- a/remoting/host/security_key/security_key_ipc_constants.cc +++ b/remoting/host/security_key/security_key_ipc_constants.cc
@@ -7,11 +7,11 @@ #include "base/lazy_instance.h" #include "build/build_config.h" -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/logging.h" -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) namespace { @@ -43,14 +43,14 @@ std::string GetChannelNamePathPrefixForTest() { std::string base_path; -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) base::FilePath base_file_path; if (base::GetTempDir(&base_file_path)) { base_path = base_file_path.AsEndingWithSeparator().value(); } else { LOG(ERROR) << "Failed to retrieve temporary directory."; } -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) return base_path; }
diff --git a/remoting/host/security_key/security_key_ipc_server_impl.cc b/remoting/host/security_key/security_key_ipc_server_impl.cc index ccd0ac2..097571ef 100644 --- a/remoting/host/security_key/security_key_ipc_server_impl.cc +++ b/remoting/host/security_key/security_key_ipc_server_impl.cc
@@ -22,13 +22,13 @@ #include "remoting/base/logging.h" #include "remoting/host/client_session_details.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <windows.h> #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "base/win/win_util.h" -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) namespace { @@ -74,7 +74,7 @@ mojo::NamedPlatformChannel::Options options; options.server_name = server_name; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) options.enforce_uniqueness = false; // Create a named pipe owned by the current user (the LocalService account // (SID: S-1-5-19) when running in the network process) which is available to @@ -87,7 +87,7 @@ options.security_descriptor = base::StringPrintf( L"O:%lsG:%lsD:(A;;GA;;;AU)", user_sid.c_str(), user_sid.c_str()); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) mojo::NamedPlatformChannel channel(options); mojo_connection_ = std::make_unique<mojo::IsolatedConnection>(); @@ -140,7 +140,7 @@ void SecurityKeyIpcServerImpl::OnChannelConnected(int32_t peer_pid) { DCHECK(thread_checker_.CalledOnValidThread()); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) bool channel_error = false; DWORD peer_session_id; if (!ProcessIdToSessionId(peer_pid, &peer_session_id)) { @@ -155,9 +155,9 @@ OnChannelError(); return; } -#else // !defined(OS_WIN) +#else // !BUILDFLAG(IS_WIN) CHECK_EQ(client_session_details_->desktop_session_id(), UINT32_MAX); -#endif // !defined(OS_WIN) +#endif // !BUILDFLAG(IS_WIN) if (connect_callback_) { std::move(connect_callback_).Run();
diff --git a/remoting/host/security_key/security_key_ipc_server_unittest.cc b/remoting/host/security_key/security_key_ipc_server_unittest.cc index c17b64f1..83215a4 100644 --- a/remoting/host/security_key/security_key_ipc_server_unittest.cc +++ b/remoting/host/security_key/security_key_ipc_server_unittest.cc
@@ -22,7 +22,7 @@ #include "remoting/host/security_key/security_key_ipc_constants.h" #include "testing/gtest/include/gtest/gtest.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <windows.h> #endif @@ -94,10 +94,10 @@ SecurityKeyIpcServerTest::SecurityKeyIpcServerTest() : run_loop_(new base::RunLoop()) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) EXPECT_TRUE(ProcessIdToSessionId( GetCurrentProcessId(), reinterpret_cast<DWORD*>(&peer_session_id_))); -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) security_key_ipc_server_ = remoting::SecurityKeyIpcServer::Create( kTestConnectionId, this, base::Milliseconds(kInitialConnectTimeoutMs), @@ -351,7 +351,7 @@ } // Flaky on mac, https://crbug.com/936583 -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) #define MAYBE_NoSecurityKeyRequestTimeout DISABLED_NoSecurityKeyRequestTimeout #else #define MAYBE_NoSecurityKeyRequestTimeout NoSecurityKeyRequestTimeout @@ -460,7 +460,7 @@ // because the channel shutdown is a series of asynchronous tasks posted on the // IO thread, and there is not a way to synchronize it with the test main // thread. -#if !defined(OS_APPLE) +#if !BUILDFLAG(IS_APPLE) TEST_F(SecurityKeyIpcServerTest, CleanupPendingConnection) { // Test that servers correctly close pending OS connections on // |server_name|. If multiple servers do remain, the client may happen to @@ -511,9 +511,9 @@ // Typically the client will be the one to close the connection. fake_ipc_client.CloseIpcConnection(); } -#endif // !defined(OS_APPLE) +#endif // !BUILDFLAG(IS_APPLE) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) TEST_F(SecurityKeyIpcServerTest, IpcConnectionFailsFromInvalidSession) { // Change the expected session ID to not match the current session. peer_session_id_++; @@ -532,6 +532,6 @@ RunPendingTasks(); ASSERT_FALSE(fake_ipc_client.ipc_channel_connected()); } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) } // namespace remoting
diff --git a/remoting/host/server_log_entry_host_unittest.cc b/remoting/host/server_log_entry_host_unittest.cc index 553e665..2209315 100644 --- a/remoting/host/server_log_entry_host_unittest.cc +++ b/remoting/host/server_log_entry_host_unittest.cc
@@ -45,16 +45,16 @@ key_value_pairs["session-state"] = "connected"; std::set<std::string> keys; keys.insert("cpu"); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) key_value_pairs["os-name"] = "Windows"; keys.insert("os-version"); -#elif defined(OS_APPLE) +#elif BUILDFLAG(IS_APPLE) key_value_pairs["os-name"] = "Mac"; keys.insert("os-version"); #elif BUILDFLAG(IS_CHROMEOS_ASH) key_value_pairs["os-name"] = "ChromeOS"; keys.insert("os-version"); -#elif defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) +#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) key_value_pairs["os-name"] = "Linux"; keys.insert("os-version"); #endif
diff --git a/remoting/host/setup/daemon_controller.cc b/remoting/host/setup/daemon_controller.cc index 341b3d2..fca5091a 100644 --- a/remoting/host/setup/daemon_controller.cc +++ b/remoting/host/setup/daemon_controller.cc
@@ -27,7 +27,7 @@ delegate_(std::move(delegate)) { // Launch the delegate thread. delegate_thread_ = std::make_unique<AutoThread>(kDaemonControllerThreadName); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) delegate_thread_->SetComInitType(AutoThread::COM_INIT_STA); delegate_task_runner_ = delegate_thread_->StartWithType(base::MessagePumpType::UI);
diff --git a/remoting/host/setup/me2me_native_messaging_host.cc b/remoting/host/setup/me2me_native_messaging_host.cc index 767c83f..1c8a2e2 100644 --- a/remoting/host/setup/me2me_native_messaging_host.cc +++ b/remoting/host/setup/me2me_native_messaging_host.cc
@@ -31,15 +31,15 @@ #include "remoting/host/pin_hash.h" #include "remoting/protocol/pairing_registry.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "remoting/host/win/elevated_native_messaging_host.h" -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) namespace { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) const int kElevatedHostTimeoutSeconds = 300; -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) // redirect_uri to use when authenticating service accounts (service account // codes are obtained "out-of-band", i.e., not through an OAuth redirect). @@ -50,9 +50,9 @@ "pairingRegistry", "oauthClient", "getRefreshTokenFromAuthCode", -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) "it2mePermissionCheck", -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) }; // Helper to extract the "config" part of a message as a DictionaryValue. @@ -79,7 +79,7 @@ scoped_refptr<protocol::PairingRegistry> pairing_registry, std::unique_ptr<OAuthClient> oauth_client) : needs_elevation_(needs_elevation), -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) parent_window_handle_(parent_window_handle), #endif host_context_(std::move(host_context)), @@ -582,7 +582,7 @@ client_->CloseChannel(std::string()); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) Me2MeNativeMessagingHost::DelegationResult Me2MeNativeMessagingHost::DelegateToElevatedHost( @@ -613,7 +613,7 @@ } } -#else // defined(OS_WIN) +#else // BUILDFLAG(IS_WIN) Me2MeNativeMessagingHost::DelegationResult Me2MeNativeMessagingHost::DelegateToElevatedHost( @@ -622,6 +622,6 @@ return DELEGATION_FAILED; } -#endif // !defined(OS_WIN) +#endif // !BUILDFLAG(IS_WIN) } // namespace remoting
diff --git a/remoting/host/setup/me2me_native_messaging_host.h b/remoting/host/setup/me2me_native_messaging_host.h index a3489193..73fb940 100644 --- a/remoting/host/setup/me2me_native_messaging_host.h +++ b/remoting/host/setup/me2me_native_messaging_host.h
@@ -135,13 +135,13 @@ bool needs_elevation_; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Controls the lifetime of the elevated native messaging host process. std::unique_ptr<ElevatedNativeMessagingHost> elevated_host_; // Handle of the parent window. intptr_t parent_window_handle_; -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) raw_ptr<extensions::NativeMessageHost::Client> client_; std::unique_ptr<ChromotingHostContext> host_context_;
diff --git a/remoting/host/setup/me2me_native_messaging_host_main.cc b/remoting/host/setup/me2me_native_messaging_host_main.cc index 6f849bb..2417f7f 100644 --- a/remoting/host/setup/me2me_native_messaging_host_main.cc +++ b/remoting/host/setup/me2me_native_messaging_host_main.cc
@@ -39,17 +39,17 @@ #include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/transitional_url_loader_factory_owner.h" -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) #include "base/mac/scoped_nsautorelease_pool.h" -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/process/process_info.h" #include "base/win/registry.h" #include "remoting/host/pairing_registry_delegate_win.h" #include <windows.h> -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) #if defined(USE_GLIB) && !BUILDFLAG(IS_CHROMEOS_ASH) #include <glib-object.h> @@ -70,10 +70,10 @@ remoting::InitHostLogging(); -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) // Needed so we don't leak objects when threads are created. base::mac::ScopedNSAutoreleasePool pool; -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) #if defined(USE_GLIB) && !BUILDFLAG(IS_CHROMEOS_ASH) // g_type_init will be deprecated in 2.36. 2.35 is the development @@ -111,7 +111,7 @@ scoped_refptr<DaemonController> daemon_controller = DaemonController::Create(); -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) if (command_line->HasSwitch(kCheckPermissionSwitchName)) { int exit_code; daemon_controller->CheckPermission( @@ -128,7 +128,7 @@ run_loop.Run(); return exit_code; } -#endif // defined(OS_APPLE) +#endif // BUILDFLAG(IS_APPLE) // Pass handle of the native view to the controller so that the UAC prompts // are focused properly. @@ -146,7 +146,7 @@ base::File write_file; bool needs_elevation = false; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) needs_elevation = !base::IsCurrentProcessElevated(); if (command_line->HasSwitch(kElevateSwitchName)) { @@ -200,7 +200,7 @@ SetStdHandle(STD_INPUT_HANDLE, nullptr); SetStdHandle(STD_OUTPUT_HANDLE, nullptr); } -#elif defined(OS_POSIX) +#elif BUILDFLAG(IS_POSIX) // The files will be automatically closed. read_file = base::File(STDIN_FILENO); write_file = base::File(STDOUT_FILENO); @@ -221,7 +221,7 @@ // Create the pairing registry. scoped_refptr<PairingRegistry> pairing_registry; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) base::win::RegKey root; LONG result = root.Open(HKEY_LOCAL_MACHINE, kPairingRegistryKeyName, KEY_READ); @@ -262,10 +262,10 @@ pairing_registry = new PairingRegistry(io_thread.task_runner(), std::move(delegate)); -#else // defined(OS_WIN) +#else // BUILDFLAG(IS_WIN) pairing_registry = CreatePairingRegistry(io_thread.task_runner()); -#endif // !defined(OS_WIN) +#endif // !BUILDFLAG(IS_WIN) std::unique_ptr<NativeMessagingPipe> native_messaging_pipe( new NativeMessagingPipe()); @@ -274,9 +274,9 @@ std::unique_ptr<extensions::NativeMessagingChannel> channel( new PipeMessagingChannel(std::move(read_file), std::move(write_file))); -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) PipeMessagingChannel::ReopenStdinStdout(); -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) std::unique_ptr<ChromotingHostContext> context = ChromotingHostContext::Create(new remoting::AutoThreadTaskRunner(
diff --git a/remoting/host/setup/start_host_main.cc b/remoting/host/setup/start_host_main.cc index 2f1d47b..3d9c51c64 100644 --- a/remoting/host/setup/start_host_main.cc +++ b/remoting/host/setup/start_host_main.cc
@@ -27,21 +27,21 @@ #include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/transitional_url_loader_factory_owner.h" -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) #include <termios.h> #include <unistd.h> -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) #include "remoting/host/setup/daemon_controller_delegate_linux.h" #include "remoting/host/setup/start_host_as_root.h" -#endif // defined(OS_LINUX) +#endif // BUILDFLAG(IS_LINUX) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/process/process_info.h" #include <windows.h> -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) namespace remoting { @@ -57,7 +57,7 @@ // Lets us hide the PIN that a user types. void SetEcho(bool echo) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) DWORD mode; HANDLE console_handle = GetStdHandle(STD_INPUT_HANDLE); if (!GetConsoleMode(console_handle, &mode)) { @@ -75,7 +75,7 @@ term.c_lflag &= ~ECHO; } tcsetattr(STDIN_FILENO, TCSANOW, &term); -#endif // !defined(OS_WIN) +#endif // !BUILDFLAG(IS_WIN) } // Reads a newline-terminated string from stdin. @@ -126,12 +126,12 @@ } // namespace int StartHostMain(int argc, char** argv) { -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) // Minimize the amount of code that runs as root on Posix systems. if (getuid() == 0) { return remoting::StartHostAsRoot(argc, argv); } -#endif // defined(OS_LINUX) +#endif // BUILDFLAG(IS_LINUX) // google_apis::GetOAuth2ClientID/Secret need a static CommandLine. base::CommandLine::Init(argc, argv); @@ -163,7 +163,7 @@ // for the account which generated |code|. std::string host_owner = command_line->GetSwitchValueASCII("host-owner"); -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) if (command_line->HasSwitch("no-start")) { // On Linux, registering the host with systemd and starting it is the only // reason start_host requires root. The --no-start options skips that final @@ -173,15 +173,15 @@ // controller code, and must be configured on the Linux delegate explicitly. DaemonControllerDelegateLinux::set_start_host_after_setup(false); } -#endif // defined(OS_LINUX) -#if defined(OS_WIN) +#endif // BUILDFLAG(IS_LINUX) +#if BUILDFLAG(IS_WIN) // The tool must be run elevated on Windows so the host has access to the // directories used to store the configuration JSON files. if (!base::IsCurrentProcessElevated()) { fprintf(stderr, "Error: %s must be run as an elevated process.", argv[0]); return 1; } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) if (command_line->HasSwitch("help") || command_line->HasSwitch("h") || command_line->HasSwitch("?") || !command_line->GetArgs().empty()) {
diff --git a/remoting/host/setup/test_util.cc b/remoting/host/setup/test_util.cc index 5b82005..153d181 100644 --- a/remoting/host/setup/test_util.cc +++ b/remoting/host/setup/test_util.cc
@@ -5,9 +5,9 @@ #include "build/build_config.h" #include "remoting/host/setup/test_util.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <windows.h> -#elif defined(OS_POSIX) +#elif BUILDFLAG(IS_POSIX) #include <unistd.h> #endif @@ -15,7 +15,7 @@ bool MakePipe(base::File* read_file, base::File* write_file) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) base::PlatformFile read_handle; base::PlatformFile write_handle; if (!CreatePipe(&read_handle, &write_handle, nullptr, 0)) @@ -23,7 +23,7 @@ *read_file = base::File(read_handle); *write_file = base::File(write_handle); return true; -#elif defined(OS_POSIX) +#elif BUILDFLAG(IS_POSIX) int fds[2]; if (pipe(fds) == 0) { *read_file = base::File(fds[0]);
diff --git a/remoting/host/shutdown_watchdog.cc b/remoting/host/shutdown_watchdog.cc index f08343a..6907cab 100644 --- a/remoting/host/shutdown_watchdog.cc +++ b/remoting/host/shutdown_watchdog.cc
@@ -9,9 +9,9 @@ #include "base/logging.h" #include "build/build_config.h" -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) #include <unistd.h> -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) namespace remoting {
diff --git a/remoting/host/third_party_auth_config.cc b/remoting/host/third_party_auth_config.cc index b05de583..a04365f 100644 --- a/remoting/host/third_party_auth_config.cc +++ b/remoting/host/third_party_auth_config.cc
@@ -75,7 +75,9 @@ const std::string& policy_name, bool* policy_present, std::string* policy_value) { - if (policy_dict.GetString(policy_name, policy_value)) { + DCHECK(policy_value); + if (const std::string* value = policy_dict.FindStringKey(policy_name)) { + *policy_value = *value; *policy_present = true; } else { policy_value->clear();
diff --git a/remoting/host/token_validator_base.cc b/remoting/host/token_validator_base.cc index dbead62..12ca8d7 100644 --- a/remoting/host/token_validator_base.cc +++ b/remoting/host/token_validator_base.cc
@@ -24,9 +24,9 @@ #include "net/ssl/client_cert_store.h" #if defined(USE_NSS_CERTS) #include "net/ssl/client_cert_store_nss.h" -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) #include "net/ssl/client_cert_store_win.h" -#elif defined(OS_APPLE) +#elif BUILDFLAG(IS_APPLE) #include "net/ssl/client_cert_store_mac.h" #endif #include "net/ssl/ssl_cert_request_info.h" @@ -104,7 +104,7 @@ return c1->valid_expiry() < c2->valid_expiry(); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) crypto::ScopedHCERTSTORE OpenLocalMachineCertStore() { return crypto::ScopedHCERTSTORE(::CertOpenStore( CERT_STORE_PROV_SYSTEM, 0, NULL, @@ -209,7 +209,7 @@ #if defined(USE_NSS_CERTS) client_cert_store = new net::ClientCertStoreNSS( net::ClientCertStoreNSS::PasswordDelegateFactory()); -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) // The network process is running as "Local Service" whose "Current User" // cert store doesn't contain any certificates. Use the "Local Machine" // store instead. @@ -217,7 +217,7 @@ // Machine" cert store needs to allow access by "Local Service". client_cert_store = new net::ClientCertStoreWin( base::BindRepeating(&OpenLocalMachineCertStore)); -#elif defined(OS_APPLE) +#elif BUILDFLAG(IS_APPLE) client_cert_store = new net::ClientCertStoreMac(); #else // OpenSSL does not use the ClientCertStore infrastructure.
diff --git a/remoting/host/user_setting_keys.h b/remoting/host/user_setting_keys.h index 5de01f6..9379b6a6 100644 --- a/remoting/host/user_setting_keys.h +++ b/remoting/host/user_setting_keys.h
@@ -10,7 +10,7 @@ namespace remoting { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Windows settings are stored in the registry where the key and value names use // pascal case. @@ -18,7 +18,7 @@ constexpr UserSettingKey kWinPreviousDefaultWebBrowserProgId = "PreviousDefaultBrowserProgId"; -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) } // namespace remoting
diff --git a/remoting/host/webauthn/remote_webauthn_main.cc b/remoting/host/webauthn/remote_webauthn_main.cc index b4277b1..3b8dcbc 100644 --- a/remoting/host/webauthn/remote_webauthn_main.cc +++ b/remoting/host/webauthn/remote_webauthn_main.cc
@@ -21,9 +21,9 @@ #include "remoting/host/native_messaging/pipe_messaging_channel.h" #include "remoting/host/webauthn/remote_webauthn_native_messaging_host.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <windows.h> -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) namespace remoting { @@ -46,10 +46,10 @@ base::File read_file; base::File write_file; -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) read_file = base::File(STDIN_FILENO); write_file = base::File(STDOUT_FILENO); -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) // GetStdHandle() returns pseudo-handles for stdin and stdout even if // the hosting executable specifies "Windows" subsystem. However the // returned handles are invalid in that case unless standard input and @@ -75,9 +75,9 @@ auto channel = std::make_unique<PipeMessagingChannel>(std::move(read_file), std::move(write_file)); -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) PipeMessagingChannel::ReopenStdinStdout(); -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) auto native_messaging_host = std::make_unique<RemoteWebAuthnNativeMessagingHost>(task_runner);
diff --git a/remoting/protocol/connection_unittest.cc b/remoting/protocol/connection_unittest.cc index e1cd6a16..1e8b2b39 100644 --- a/remoting/protocol/connection_unittest.cc +++ b/remoting/protocol/connection_unittest.cc
@@ -482,7 +482,7 @@ } // crbug.com/1224862: Tests are flaky on Mac. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_Disconnect DISABLED_Disconnect #else #define MAYBE_Disconnect Disconnect @@ -499,7 +499,7 @@ } // crbug.com/1224862: Tests are flaky on Mac. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_Control DISABLED_Control #else #define MAYBE_Control Control @@ -523,7 +523,7 @@ } // crbug.com/1224862: Tests are flaky on Mac. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_Events DISABLED_Events #else #define MAYBE_Events Events @@ -547,7 +547,7 @@ } // crbug.com/1224862: Tests are flaky on Mac. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_Video DISABLED_Video #else #define MAYBE_Video Video @@ -566,7 +566,7 @@ } // crbug.com/1224862: Tests are flaky on Mac. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_VideoWithSlowSignaling DISABLED_VideoWithSlowSignaling #else #define MAYBE_VideoWithSlowSignaling VideoWithSlowSignaling @@ -588,7 +588,7 @@ } // crbug.com/1224862: Tests are flaky on Mac. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_DestroyOnIncomingMessage DISABLED_DestroyOnIncomingMessage #else #define MAYBE_DestroyOnIncomingMessage DestroyOnIncomingMessage @@ -669,9 +669,9 @@ // Slow/fails on Linux ASan/TSan (crbug.com/1045344) and flaky on Mac // (crbug.com/1237376). -#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && \ +#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && \ (defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER)) || \ - defined(OS_MAC) + BUILDFLAG(IS_MAC) #define MAYBE_Audio DISABLED_Audio #else #define MAYBE_Audio Audio
diff --git a/remoting/protocol/ice_config.cc b/remoting/protocol/ice_config.cc index 1d147259..d4fec7c 100644 --- a/remoting/protocol/ice_config.cc +++ b/remoting/protocol/ice_config.cc
@@ -122,10 +122,10 @@ IceConfig ice_config; // Parse lifetimeDuration field. - std::string lifetime_str; + const std::string* lifetime_str = + dictionary.FindStringKey("lifetimeDuration"); base::TimeDelta lifetime; - if (!dictionary.GetString("lifetimeDuration", &lifetime_str) || - !ParseLifetime(lifetime_str, &lifetime)) { + if (!lifetime_str || !ParseLifetime(*lifetime_str, &lifetime)) { LOG(ERROR) << "Received invalid lifetimeDuration value: " << lifetime_str; // If the |lifetimeDuration| field is missing or cannot be parsed then mark
diff --git a/remoting/protocol/ice_connection_to_client.cc b/remoting/protocol/ice_connection_to_client.cc index 5dc54343..6fc254d5 100644 --- a/remoting/protocol/ice_connection_to_client.cc +++ b/remoting/protocol/ice_connection_to_client.cc
@@ -9,6 +9,7 @@ #include "base/bind.h" #include "base/location.h" #include "base/memory/ptr_util.h" +#include "build/build_config.h" #include "net/base/io_buffer.h" #include "remoting/codec/audio_encoder.h" #include "remoting/codec/audio_encoder_opus.h" @@ -32,7 +33,7 @@ std::unique_ptr<AudioEncoder> CreateAudioEncoder( const protocol::SessionConfig& config) { -#if defined(OS_IOS) +#if BUILDFLAG(IS_IOS) // TODO(nicholss): iOS should not use Opus. This is to prevent us from // depending on //media. In the future we will use webrtc for connection // and this will be a non-issue.
diff --git a/remoting/protocol/ice_transport_unittest.cc b/remoting/protocol/ice_transport_unittest.cc index 6310b3e0..1a9e41a 100644 --- a/remoting/protocol/ice_transport_unittest.cc +++ b/remoting/protocol/ice_transport_unittest.cc
@@ -213,7 +213,7 @@ }; // crbug.com/1224862: Tests are flaky on Mac. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_DataStream DISABLED_DataStream #else #define MAYBE_DataStream DataStream @@ -237,7 +237,7 @@ } // crbug.com/1224862: Tests are flaky on Mac. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_MuxDataStream DISABLED_MuxDataStream #else #define MAYBE_MuxDataStream MuxDataStream @@ -261,7 +261,7 @@ } // crbug.com/1224862: Tests are flaky on Mac. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_FailedChannelAuth DISABLED_FailedChannelAuth #else #define MAYBE_FailedChannelAuth FailedChannelAuth @@ -341,7 +341,7 @@ } // crbug.com/1224862: Tests are flaky on Mac. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_TestDelayedSignaling DISABLED_TestDelayedSignaling #else #define MAYBE_TestDelayedSignaling TestDelayedSignaling
diff --git a/remoting/protocol/webrtc_transport_unittest.cc b/remoting/protocol/webrtc_transport_unittest.cc index 7044c26..d8f41c7 100644 --- a/remoting/protocol/webrtc_transport_unittest.cc +++ b/remoting/protocol/webrtc_transport_unittest.cc
@@ -370,7 +370,7 @@ }; // crbug.com/1224862: Tests are flaky on Mac. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_Connects DISABLED_Connects #else #define MAYBE_Connects Connects @@ -393,7 +393,7 @@ } // crbug.com/1224862: Tests are flaky on Mac. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_DataStream DISABLED_DataStream #else #define MAYBE_DataStream DataStream @@ -430,7 +430,7 @@ } // crbug.com/1224862: Tests are flaky on Mac. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_DataStreamLate DISABLED_DataStreamLate #else #define MAYBE_DataStreamLate DataStreamLate @@ -452,7 +452,7 @@ } // crbug.com/1224862: Tests are flaky on Mac. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_TerminateDataChannel DISABLED_TerminateDataChannel #else #define MAYBE_TerminateDataChannel TerminateDataChannel @@ -491,7 +491,7 @@ } // crbug.com/1224862: Tests are flaky on Mac. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #define MAYBE_ThreadJoinBlockedDuringConnectionTeardown_WatchdogFired \ DISABLED_ThreadJoinBlockedDuringConnectionTeardown_WatchdogFired #else
diff --git a/remoting/resources/remoting_strings.grd b/remoting/resources/remoting_strings.grd index d717637..3f09aa2 100644 --- a/remoting/resources/remoting_strings.grd +++ b/remoting/resources/remoting_strings.grd
@@ -334,7 +334,7 @@ Google LLC </message> <message name="IDS_COPYRIGHT" desc="The copyright message specified in the version information of each Chrome Remote Desktop Host executable. It should be updated every year."> - Copyright 2021 Google LLC. All Rights Reserved. + Copyright 2022 Google LLC. All Rights Reserved. </message> <message name="IDS_DISPLAY_SERVICE_NAME" desc="The name of the Windows service installed by Chrome Remote Desktop."> Chrome Remote Desktop Service @@ -376,7 +376,7 @@ The Chromium Authors </message> <message name="IDS_COPYRIGHT" desc="The copyright message specified in the version information of each Chromoting Host executable. It should be updated every year."> - Copyright 2021 The Chromium Authors. All Rights Reserved. + Copyright 2022 The Chromium Authors. All Rights Reserved. </message> <message name="IDS_DISPLAY_SERVICE_NAME" desc="The name of the Windows service installed by Chromoting."> Chromoting Service
diff --git a/remoting/signaling/ftl_host_device_id_provider.cc b/remoting/signaling/ftl_host_device_id_provider.cc index db4d6b1..15e3feb 100644 --- a/remoting/signaling/ftl_host_device_id_provider.cc +++ b/remoting/signaling/ftl_host_device_id_provider.cc
@@ -11,13 +11,13 @@ namespace { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) constexpr char kDeviceIdPrefix[] = "crd-win-host-"; -#elif defined(OS_APPLE) +#elif BUILDFLAG(IS_APPLE) constexpr char kDeviceIdPrefix[] = "crd-mac-host-"; #elif BUILDFLAG(IS_CHROMEOS_ASH) constexpr char kDeviceIdPrefix[] = "crd-cros-host-"; -#elif defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) +#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) constexpr char kDeviceIdPrefix[] = "crd-linux-host-"; #else constexpr char kDeviceIdPrefix[] = "crd-unknown-host-";
diff --git a/remoting/signaling/ftl_services_context.cc b/remoting/signaling/ftl_services_context.cc index 8a49221..9267f5d 100644 --- a/remoting/signaling/ftl_services_context.cc +++ b/remoting/signaling/ftl_services_context.cc
@@ -89,9 +89,9 @@ client_info->set_version_minor(VERSION_BUILD); client_info->set_version_point(VERSION_PATCH); ftl::Platform_Type platform_type; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) platform_type = ftl::Platform_Type_FTL_ANDROID; -#elif defined(OS_IOS) +#elif BUILDFLAG(IS_IOS) platform_type = ftl::Platform_Type_FTL_IOS; #else platform_type = ftl::Platform_Type_FTL_DESKTOP;
diff --git a/remoting/test/it2me_cli_host_main.cc b/remoting/test/it2me_cli_host_main.cc index de55256..9552e22 100644 --- a/remoting/test/it2me_cli_host_main.cc +++ b/remoting/test/it2me_cli_host_main.cc
@@ -12,9 +12,9 @@ #include "remoting/host/resources.h" #include "remoting/test/it2me_cli_host.h" -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #include "base/linux_util.h" -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) int main(int argc, char const* argv[]) { base::AtExitManager exitManager; @@ -25,11 +25,11 @@ return 0; } -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Need to prime the host OS version value for linux to prevent IO on the // network thread. base::GetLinuxDistro() caches the result. base::GetLinuxDistro(); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) base::SingleThreadTaskExecutor io_task_executor(base::MessagePumpType::IO); remoting::It2MeCliHost cli_host;
diff --git a/remoting/test/it2me_standalone_host.cc b/remoting/test/it2me_standalone_host.cc index d0798d2c..00cf3be 100644 --- a/remoting/test/it2me_standalone_host.cc +++ b/remoting/test/it2me_standalone_host.cc
@@ -15,6 +15,7 @@ #include "base/memory/ref_counted.h" #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" +#include "build/build_config.h" #include "remoting/base/auto_thread_task_runner.h" #include "remoting/host/chromoting_host_context.h" #include "remoting/host/host_extension.h" @@ -50,7 +51,7 @@ context_->ui_task_runner()), connection_(base::WrapUnique(new testing::NiceMock<MockSession>())), session_jid_(kSessionJid), -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // We cannot support audio capturing for linux, since a pipe name is // needed to initialize AudioCapturerLinux. config_(protocol::SessionConfig::ForTest()),
diff --git a/remoting/test/it2me_standalone_host_main.cc b/remoting/test/it2me_standalone_host_main.cc index 57f773f..ac6f33e 100644 --- a/remoting/test/it2me_standalone_host_main.cc +++ b/remoting/test/it2me_standalone_host_main.cc
@@ -5,23 +5,24 @@ #include "base/at_exit.h" #include "base/check_op.h" #include "base/command_line.h" +#include "build/build_config.h" #include "remoting/host/resources.h" #include "remoting/proto/event.pb.h" #include "remoting/test/it2me_standalone_host.h" -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #include <gtk/gtk.h> #include "base/linux_util.h" #include "ui/events/platform/x11/x11_event_source.h" -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) int main(int argc, const char** argv) { base::AtExitManager at_exit_manager; base::CommandLine::Init(argc, argv); remoting::test::It2MeStandaloneHost host; -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Create an X11EventSource so the global X11 connection // (x11::Connection::Get()) can dispatch X events. auto event_source = @@ -39,7 +40,7 @@ // Need to prime the host OS version value for linux to prevent IO on the // network thread. base::GetLinuxDistro() caches the result. base::GetLinuxDistro(); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) remoting::LoadResources(""); host.StartOutputTimer(); host.Run();
diff --git a/services/audio/input_controller.h b/services/audio/input_controller.h index d0c32bf..17a2c37 100644 --- a/services/audio/input_controller.h +++ b/services/audio/input_controller.h
@@ -40,7 +40,7 @@ class InputStreamActivityMonitor; // Only do power monitoring for non-mobile platforms to save resources. -#if !defined(OS_ANDROID) && !defined(OS_IOS) +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) #define AUDIO_POWER_MONITORING #endif
diff --git a/services/audio/input_sync_writer.cc b/services/audio/input_sync_writer.cc index 5221973d..529322042 100644 --- a/services/audio/input_sync_writer.cc +++ b/services/audio/input_sync_writer.cc
@@ -258,7 +258,7 @@ } void InputSyncWriter::CheckTimeSinceLastWrite() { -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) static const base::TimeDelta kLogDelayThreadhold = base::Milliseconds(500); base::TimeTicks new_write_time = base::TimeTicks::Now();
diff --git a/services/audio/input_sync_writer.h b/services/audio/input_sync_writer.h index bf7ece2a..06d9739 100644 --- a/services/audio/input_sync_writer.h +++ b/services/audio/input_sync_writer.h
@@ -21,7 +21,7 @@ #include "media/base/audio_parameters.h" #include "services/audio/input_controller.h" -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) #include "base/file_descriptor_posix.h" #endif
diff --git a/services/audio/input_sync_writer_unittest.cc b/services/audio/input_sync_writer_unittest.cc index 22a6ac5..7d2ca88 100644 --- a/services/audio/input_sync_writer_unittest.cc +++ b/services/audio/input_sync_writer_unittest.cc
@@ -135,7 +135,7 @@ // with a glitch summary from the destructor. Besides that only for errors // and fifo info. int GetTotalNumberOfExpectedLogCalls(int expected_calls_due_to_error) { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) return expected_calls_due_to_error + 1; #else return expected_calls_due_to_error + 2;
diff --git a/services/audio/output_controller.h b/services/audio/output_controller.h index 666181c..4d8a4ca 100644 --- a/services/audio/output_controller.h +++ b/services/audio/output_controller.h
@@ -141,7 +141,7 @@ // Indicates whether audio power level analysis will be performed. If false, // ReadCurrentPowerAndClip() can not be called. static constexpr bool will_monitor_audio_levels() { -#if defined(OS_ANDROID) || defined(OS_IOS) +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS) return false; #else return true;
diff --git a/services/audio/owning_audio_manager_accessor.h b/services/audio/owning_audio_manager_accessor.h index 988353c..fb60c9e9 100644 --- a/services/audio/owning_audio_manager_accessor.h +++ b/services/audio/owning_audio_manager_accessor.h
@@ -12,7 +12,7 @@ #include "build/build_config.h" #include "services/audio/service.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/win/scoped_com_initializer.h" #endif @@ -48,7 +48,7 @@ void Shutdown() final; private: -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // Required to access CoreAudio. base::win::ScopedCOMInitializer com_initializer_{ base::win::ScopedCOMInitializer::kMTA};
diff --git a/services/audio/public/cpp/debug_recording_session.cc b/services/audio/public/cpp/debug_recording_session.cc index b6c161a..a513c55 100644 --- a/services/audio/public/cpp/debug_recording_session.cc +++ b/services/audio/public/cpp/debug_recording_session.cc
@@ -17,7 +17,7 @@ namespace { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define NumberToStringType base::NumberToWString #else #define NumberToStringType base::NumberToString
diff --git a/services/audio/public/cpp/output_device_unittest.cc b/services/audio/public/cpp/output_device_unittest.cc index 8ccd4a3b..15ce47a 100644 --- a/services/audio/public/cpp/output_device_unittest.cc +++ b/services/audio/public/cpp/output_device_unittest.cc
@@ -148,7 +148,7 @@ CHECK(reader->IsValid()); time_stamp = base::TimeTicks::Now(); -#if defined(OS_FUCHSIA) +#if BUILDFLAG(IS_FUCHSIA) // TODO(https://crbug.com/838367): Fuchsia bots use nested virtualization, // which can result in unusually long scheduling delays, so allow a longer // timeout.
diff --git a/services/audio/service.cc b/services/audio/service.cc index 52caf1e..e51ab35 100644 --- a/services/audio/service.cc +++ b/services/audio/service.cc
@@ -15,6 +15,7 @@ #include "base/task/single_thread_task_runner.h" #include "base/time/default_tick_clock.h" #include "base/trace_event/trace_event.h" +#include "build/build_config.h" #include "media/audio/audio_manager.h" #include "media/base/bind_to_current_loop.h" #include "services/audio/debug_recording.h" @@ -23,7 +24,7 @@ #include "services/audio/service_metrics.h" #include "services/audio/system_info.h" -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) #include "media/audio/mac/audio_device_listener_mac.h" #endif @@ -157,7 +158,7 @@ void Service::InitializeDeviceMonitor() { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); -#if defined(OS_APPLE) +#if BUILDFLAG(IS_APPLE) if (audio_device_listener_mac_) return;
diff --git a/services/audio/service.h b/services/audio/service.h index 2af08620..c0a69f374 100644 --- a/services/audio/service.h +++ b/services/audio/service.h
@@ -117,7 +117,7 @@ std::unique_ptr<AudioManagerAccessor> audio_manager_accessor_; const bool enable_remote_client_support_; std::unique_ptr<base::SystemMonitor> system_monitor_; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) std::unique_ptr<media::AudioDeviceListenerMac> audio_device_listener_mac_; #endif std::unique_ptr<SystemInfo> system_info_;
diff --git a/services/audio/sync_reader.cc b/services/audio/sync_reader.cc index acc5a8a..f6587208 100644 --- a/services/audio/sync_reader.cc +++ b/services/audio/sync_reader.cc
@@ -90,7 +90,7 @@ namespace audio { -#if !defined(OS_MAC) && !BUILDFLAG(IS_CHROMEOS_ASH) && \ +#if !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_CHROMEOS_ASH) && \ !BUILDFLAG(IS_CHROMEOS_LACROS) const base::Feature kDynamicAudioTimeout{"DynamicAudioTimeout", base::FEATURE_DISABLED_BY_DEFAULT}; @@ -115,7 +115,7 @@ renderer_missed_callback_count_(0), trailing_renderer_missed_callback_count_(0), buffer_index_(0) { -#if defined(OS_MAC) || BUILDFLAG(IS_CHROMEOS_ASH) || \ +#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS_ASH) || \ BUILDFLAG(IS_CHROMEOS_LACROS) maximum_wait_time_ = params.GetBufferDuration() / 2; #else
diff --git a/services/audio/sync_reader.h b/services/audio/sync_reader.h index 626c28a..c6b1fae 100644 --- a/services/audio/sync_reader.h +++ b/services/audio/sync_reader.h
@@ -21,7 +21,7 @@ #include "media/base/audio_latency.h" #include "services/audio/output_controller.h" -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) #include "base/file_descriptor_posix.h" #endif
diff --git a/services/audio/test/debug_recording_session_unittest.cc b/services/audio/test/debug_recording_session_unittest.cc index 15fb673..0aef5fec 100644 --- a/services/audio/test/debug_recording_session_unittest.cc +++ b/services/audio/test/debug_recording_session_unittest.cc
@@ -28,7 +28,7 @@ namespace { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #define NumberToStringType base::NumberToWString #else #define NumberToStringType base::NumberToString
diff --git a/services/cert_verifier/cert_verifier_creation.cc b/services/cert_verifier/cert_verifier_creation.cc index 68c99ef..962046b 100644 --- a/services/cert_verifier/cert_verifier_creation.cc +++ b/services/cert_verifier/cert_verifier_creation.cc
@@ -86,7 +86,7 @@ scoped_refptr<net::CertVerifyProc> CreateOldDefaultWithoutCaching( scoped_refptr<net::CertNetFetcher> cert_net_fetcher) { scoped_refptr<net::CertVerifyProc> verify_proc; -#if defined(OS_FUCHSIA) || defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_FUCHSIA) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) verify_proc = net::CertVerifyProc::CreateBuiltinVerifyProc(std::move(cert_net_fetcher)); #else @@ -104,7 +104,7 @@ scoped_refptr<net::CertNetFetcher> cert_net_fetcher) { scoped_refptr<net::CertVerifyProc> verify_proc; #if BUILDFLAG(CHROME_ROOT_STORE_SUPPORTED) && \ - (defined(OS_LINUX) || defined(OS_WIN)) + (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN)) verify_proc = net::CreateCertVerifyProcBuiltin( std::move(cert_net_fetcher), net::CreateSslSystemTrustStoreChromeRoot()); #elif BUILDFLAG(BUILTIN_CERT_VERIFIER_FEATURE_SUPPORTED) @@ -119,9 +119,9 @@ } // namespace bool IsUsingCertNetFetcher() { -#if defined(OS_ANDROID) || defined(OS_FUCHSIA) || defined(OS_CHROMEOS) || \ - defined(OS_LINUX) || \ - BUILDFLAG(TRIAL_COMPARISON_CERT_VERIFIER_SUPPORTED) || \ +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA) || \ + BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX) || \ + BUILDFLAG(TRIAL_COMPARISON_CERT_VERIFIER_SUPPORTED) || \ BUILDFLAG(BUILTIN_CERT_VERIFIER_FEATURE_SUPPORTED) return true; #else
diff --git a/services/cert_verifier/integration_tests/network_service_unittest.cc b/services/cert_verifier/integration_tests/network_service_unittest.cc index 1660abc7..f25e216 100644 --- a/services/cert_verifier/integration_tests/network_service_unittest.cc +++ b/services/cert_verifier/integration_tests/network_service_unittest.cc
@@ -146,7 +146,7 @@ }; // CRLSets are not supported on iOS and Android system verifiers. -#if !defined(OS_IOS) && !defined(OS_ANDROID) +#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) class NetworkServiceCRLSetTest : public NetworkServiceIntegrationTest { public: @@ -368,10 +368,10 @@ net::CERT_STATUS_REVOKED); } -#endif // !defined(OS_IOS) && !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) // TODO(crbug.com/860189): AIA tests fail on iOS -#if defined(OS_IOS) +#if BUILDFLAG(IS_IOS) #define MAYBE(test_name) DISABLED_##test_name #else #define MAYBE(test_name) test_name
diff --git a/services/cert_verifier/integration_tests/ssl_config_service_mojo_unittest.cc b/services/cert_verifier/integration_tests/ssl_config_service_mojo_unittest.cc index 9801a44..05ca5ea 100644 --- a/services/cert_verifier/integration_tests/ssl_config_service_mojo_unittest.cc +++ b/services/cert_verifier/integration_tests/ssl_config_service_mojo_unittest.cc
@@ -96,7 +96,7 @@ scoped_refptr<CertNetFetcherURLLoader> cert_net_fetcher_url_loader_; }; -#if !defined(OS_IOS) && !defined(OS_ANDROID) +#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) TEST_F(SSLConfigServiceMojoTestWithCertVerifier, CRLSetIsApplied) { mojo::Remote<network::mojom::SSLConfigClient> ssl_config_client; @@ -163,6 +163,6 @@ net::test::IsError(net::ERR_CERT_REVOKED)); } -#endif // !defined(OS_IOS) && !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID) } // namespace cert_verifier
diff --git a/services/cert_verifier/trial_comparison_cert_verifier_mojo.cc b/services/cert_verifier/trial_comparison_cert_verifier_mojo.cc index 93c07e9b..92ecd8c3 100644 --- a/services/cert_verifier/trial_comparison_cert_verifier_mojo.cc +++ b/services/cert_verifier/trial_comparison_cert_verifier_mojo.cc
@@ -13,18 +13,18 @@ #include "net/der/encode_values.h" #include "net/der/parse_values.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "net/cert/cert_verify_proc_mac.h" #include "net/cert/internal/trust_store_mac.h" #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "net/cert/cert_verify_proc_win.h" #endif namespace { -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) cert_verifier::mojom::CertVerifierDebugInfo::MacTrustImplType TrustImplTypeToMojom(net::TrustStoreMac::TrustImplType input) { switch (input) { @@ -103,7 +103,7 @@ mojom::CertVerifierDebugInfoPtr debug_info = mojom::CertVerifierDebugInfo::New(); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) auto* mac_platform_debug_info = net::CertVerifyProcMac::ResultDebugData::Get(&primary_result); if (mac_platform_debug_info) { @@ -130,9 +130,9 @@ debug_info->mac_trust_impl = TrustImplTypeToMojom(mac_trust_debug_info->trust_impl()); } -#endif // defined(OS_MAC) +#endif // BUILDFLAG(IS_MAC) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) auto* win_platform_debug_info = net::CertVerifyProcWin::ResultDebugData::Get(&primary_result); if (win_platform_debug_info) { @@ -143,7 +143,7 @@ debug_info->win_platform_debug_info->authroot_sequence_number = win_platform_debug_info->authroot_sequence_number(); } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) auto* cert_verify_proc_builtin_debug_data = net::CertVerifyProcBuiltinResultDebugData::Get(&trial_result);
diff --git a/services/cert_verifier/trial_comparison_cert_verifier_mojo_unittest.cc b/services/cert_verifier/trial_comparison_cert_verifier_mojo_unittest.cc index 2a6ef513..5b89e32 100644 --- a/services/cert_verifier/trial_comparison_cert_verifier_mojo_unittest.cc +++ b/services/cert_verifier/trial_comparison_cert_verifier_mojo_unittest.cc
@@ -15,11 +15,11 @@ #include "net/test/test_data_directory.h" #include "testing/gtest/include/gtest/gtest.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "net/cert/cert_verify_proc_mac.h" #include "net/cert/internal/trust_store_mac.h" #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "net/cert/cert_verify_proc_win.h" #endif @@ -109,7 +109,7 @@ base::Time time = base::Time::Now(); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) constexpr uint32_t kExpectedTrustResult = 4; constexpr int32_t kExpectedResultCode = -12345; std::vector<net::CertVerifyProcMac::ResultDebugData::CertEvidenceInfo> @@ -136,7 +136,7 @@ mac_trust_debug_info->UpdateTrustDebugInfo( kExpectedTrustDebugInfo, net::TrustStoreMac::TrustImplType::kSimple); #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) std::vector<uint8_t> authroot_sequence{'T', 'E', 'S', 'T'}; net::CertVerifyProcWin::ResultDebugData::Create(time, authroot_sequence, &primary_result); @@ -180,7 +180,7 @@ std::string(report.sct_list.begin(), report.sct_list.end())); ASSERT_TRUE(report.debug_info); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) ASSERT_TRUE(report.debug_info->mac_platform_debug_info); EXPECT_EQ(kExpectedTrustResult, report.debug_info->mac_platform_debug_info->trust_result); @@ -203,7 +203,7 @@ cert_verifier::mojom::CertVerifierDebugInfo::MacTrustImplType::kSimple, report.debug_info->mac_trust_impl); #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) ASSERT_TRUE(report.debug_info->win_platform_debug_info); EXPECT_EQ(time, report.debug_info->win_platform_debug_info->authroot_this_update);
diff --git a/services/data_decoder/data_decoder_service.cc b/services/data_decoder/data_decoder_service.cc index c571706..d0fbb5a 100644 --- a/services/data_decoder/data_decoder_service.cc +++ b/services/data_decoder/data_decoder_service.cc
@@ -24,7 +24,7 @@ #include "services/data_decoder/ble_scan_parser_impl.h" #endif // BUILDFLAG(IS_CHROMEOS_ASH) -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) #include "services/data_decoder/image_decoder_impl.h" #endif @@ -46,7 +46,7 @@ void DataDecoderService::BindImageDecoder( mojo::PendingReceiver<mojom::ImageDecoder> receiver) { -#if defined(OS_IOS) +#if BUILDFLAG(IS_IOS) LOG(FATAL) << "ImageDecoder not supported on iOS."; #else if (drop_image_decoders_)
diff --git a/services/data_decoder/image_decoder_impl_unittest.cc b/services/data_decoder/image_decoder_impl_unittest.cc index 3010966..5ee8fc7 100644 --- a/services/data_decoder/image_decoder_impl_unittest.cc +++ b/services/data_decoder/image_decoder_impl_unittest.cc
@@ -145,7 +145,7 @@ static_cast<uint64_t>(kTestMaxImageSize)); // Android does its own image shrinking for memory conservation deeper in // the decode, so more specific tests here won't work. -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) EXPECT_EQ(widths[i] >> i, request.bitmap().width()); EXPECT_EQ(heights[i] >> i, request.bitmap().height());
diff --git a/services/data_decoder/public/cpp/data_decoder.cc b/services/data_decoder/public/cpp/data_decoder.cc index 5408a16f..3e9315f 100644 --- a/services/data_decoder/public/cpp/data_decoder.cc +++ b/services/data_decoder/public/cpp/data_decoder.cc
@@ -15,11 +15,11 @@ #include "services/data_decoder/public/mojom/json_parser.mojom.h" #include "services/data_decoder/public/mojom/xml_parser.mojom.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "services/data_decoder/public/cpp/json_sanitizer.h" #endif -#if defined(OS_IOS) +#if BUILDFLAG(IS_IOS) #include "base/task/post_task.h" #include "services/data_decoder/data_decoder_service.h" // nogncheck #endif @@ -107,7 +107,7 @@ DataDecoder::ResultCallback<V> callback_; }; -#if defined(OS_IOS) +#if BUILDFLAG(IS_IOS) void BindInProcessService( mojo::PendingReceiver<mojom::DataDecoderService> receiver) { static base::NoDestructor<scoped_refptr<base::SequencedTaskRunner>> @@ -140,7 +140,7 @@ if (provider) { provider->BindDataDecoderService(service_.BindNewPipeAndPassReceiver()); } else { -#if defined(OS_IOS) +#if BUILDFLAG(IS_IOS) BindInProcessService(service_.BindNewPipeAndPassReceiver()); #else LOG(FATAL) << "data_decoder::ServiceProvider::Set() must be called " @@ -158,7 +158,7 @@ void DataDecoder::ParseJson(const std::string& json, ValueParseCallback callback) { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // For Android, we use the in-process sanitizer and then parse with a simple // JSONReader. JsonSanitizer::Sanitize(
diff --git a/services/device/binder_overrides.cc b/services/device/binder_overrides.cc index cac7f1ac..77ad17f3 100644 --- a/services/device/binder_overrides.cc +++ b/services/device/binder_overrides.cc
@@ -5,6 +5,7 @@ #include "services/device/binder_overrides.h" #include "base/no_destructor.h" +#include "build/build_config.h" namespace device { namespace internal { @@ -14,7 +15,7 @@ return *binder; } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) NFCProviderBinder& GetNFCProviderBinderOverride() { static base::NoDestructor<NFCProviderBinder> binder; return *binder;
diff --git a/services/device/binder_overrides.h b/services/device/binder_overrides.h index d6aa092..36f55d3 100644 --- a/services/device/binder_overrides.h +++ b/services/device/binder_overrides.h
@@ -11,7 +11,7 @@ #include "mojo/public/cpp/bindings/pending_receiver.h" #include "services/device/public/mojom/geolocation_context.mojom.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "services/device/public/mojom/nfc_provider.mojom.h" #endif @@ -23,7 +23,7 @@ COMPONENT_EXPORT(DEVICE_SERVICE_BINDER_OVERRIDES) GeolocationContextBinder& GetGeolocationContextBinderOverride(); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) using NFCProviderBinder = base::RepeatingCallback<void( mojo::PendingReceiver<device::mojom::NFCProvider>)>; COMPONENT_EXPORT(DEVICE_SERVICE_BINDER_OVERRIDES)
diff --git a/services/device/device_posture/device_posture_platform_provider.cc b/services/device/device_posture/device_posture_platform_provider.cc index 7582a0a..32bb39f 100644 --- a/services/device/device_posture/device_posture_platform_provider.cc +++ b/services/device/device_posture/device_posture_platform_provider.cc
@@ -7,9 +7,9 @@ #include "build/build_config.h" #include "services/device/device_posture/device_posture_provider_impl.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "services/device/device_posture/device_posture_platform_provider_win.h" -#elif defined(OS_ANDROID) +#elif BUILDFLAG(IS_ANDROID) #include "services/device/device_posture/device_posture_platform_provider_android.h" #endif @@ -18,9 +18,9 @@ // static std::unique_ptr<DevicePosturePlatformProvider> DevicePosturePlatformProvider::Create() { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return std::make_unique<DevicePosturePlatformProviderWin>(); -#elif defined(OS_ANDROID) +#elif BUILDFLAG(IS_ANDROID) return std::make_unique<DevicePosturePlatformProviderAndroid>(); #else return nullptr;
diff --git a/services/device/device_service.cc b/services/device/device_service.cc index 1081fb5..11a7b29 100644 --- a/services/device/device_service.cc +++ b/services/device/device_service.cc
@@ -35,7 +35,7 @@ #include "services/network/public/cpp/shared_url_loader_factory.h" #include "ui/gfx/native_widget_types.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "base/android/jni_android.h" #include "services/device/device_service_jni_headers/InterfaceRegistrar_jni.h" #include "services/device/screen_orientation/screen_orientation_listener_android.h" @@ -46,7 +46,7 @@ #include "services/device/vibration/vibration_manager_impl.h" #endif -#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(USE_UDEV) +#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && defined(USE_UDEV) #include "services/device/hid/input_service_linux.h" #endif @@ -56,7 +56,7 @@ namespace { -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) constexpr bool IsLaCrOS() { #if BUILDFLAG(IS_CHROMEOS_LACROS) return true; @@ -66,7 +66,7 @@ } #endif -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) void BindLaCrOSHidManager( mojo::PendingReceiver<device::mojom::HidManager> receiver) { #if BUILDFLAG(IS_CHROMEOS_LACROS) @@ -115,14 +115,14 @@ params->wake_lock_context_callback) { receivers_.Add(this, std::move(receiver)); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) java_nfc_delegate_.Reset(params->java_nfc_delegate); #endif #if defined(IS_SERIAL_ENABLED_PLATFORM) serial_port_manager_ = std::make_unique<SerialPortManagerImpl>( io_task_runner_, base::ThreadTaskRunnerHandle::Get()); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // On macOS the SerialDeviceEnumerator needs to run on the UI thread so that // it has access to a CFRunLoop where it can register a notification source. serial_port_manager_task_runner_ = base::ThreadTaskRunnerHandle::Get(); @@ -134,16 +134,16 @@ #endif #endif // defined(IS_SERIAL_ENABLED_PLATFORM) -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) // Ensure that the battery backend is initialized now; otherwise it may end up // getting initialized on access during destruction, when it's no longer safe // to initialize. device::BatteryStatusService::GetInstance(); -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) } DeviceService::~DeviceService() { -#if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) // NOTE: We don't call this on Chrome OS due to https://crbug.com/856771, as // Shutdown() implicitly depends on DBusThreadManager, which may already be // destroyed by the time DeviceService is destroyed. Fortunately on Chrome OS @@ -183,14 +183,14 @@ void DeviceService::BindBatteryMonitor( mojo::PendingReceiver<mojom::BatteryMonitor> receiver) { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) GetJavaInterfaceProvider()->GetInterface(std::move(receiver)); #else BatteryMonitorImpl::Create(std::move(receiver)); #endif } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // static void DeviceService::OverrideNFCProviderBinderForTesting( NFCProviderBinder binder) { @@ -209,14 +209,14 @@ void DeviceService::BindVibrationManager( mojo::PendingReceiver<mojom::VibrationManager> receiver) { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) GetJavaInterfaceProvider()->GetInterface(std::move(receiver)); #else VibrationManagerImpl::Create(std::move(receiver)); #endif } -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) void DeviceService::BindHidManager( mojo::PendingReceiver<mojom::HidManager> receiver) { if (IsLaCrOS() && !HidManagerImpl::IsHidServiceTesting()) { @@ -243,7 +243,7 @@ } #endif -#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(USE_UDEV) +#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && defined(USE_UDEV) void DeviceService::BindInputDeviceManager( mojo::PendingReceiver<mojom::InputDeviceManager> receiver) { file_task_runner_->PostTask( @@ -301,7 +301,7 @@ void DeviceService::BindScreenOrientationListener( mojo::PendingReceiver<mojom::ScreenOrientationListener> receiver) { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) if (io_task_runner_) { io_task_runner_->PostTask( FROM_HERE, base::BindOnce(&ScreenOrientationListenerAndroid::Create, @@ -322,7 +322,7 @@ sensor_provider_->Bind(std::move(receiver)); } -#if defined(OS_ANDROID) || defined(OS_WIN) +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) void DeviceService::BindDevicePostureProvider( mojo::PendingReceiver<mojom::DevicePostureProvider> receiver) { if (!device_posture_provider_) { @@ -391,7 +391,7 @@ usb_device_manager_test_->BindReceiver(std::move(receiver)); } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) service_manager::InterfaceProvider* DeviceService::GetJavaInterfaceProvider() { if (!java_interface_provider_initialized_) { mojo::PendingRemote<service_manager::mojom::InterfaceProvider> provider;
diff --git a/services/device/device_service.h b/services/device/device_service.h index 3320dc4..ddaf32a 100644 --- a/services/device/device_service.h +++ b/services/device/device_service.h
@@ -41,7 +41,7 @@ #include "services/device/wake_lock/wake_lock_provider.h" #include "services/service_manager/public/cpp/interface_provider.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "base/android/scoped_java_ref.h" #include "services/device/public/mojom/nfc_provider.mojom.h" #else @@ -53,7 +53,7 @@ #include "services/device/public/mojom/bluetooth_system.mojom.h" #endif -#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(USE_UDEV) +#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && defined(USE_UDEV) #include "services/device/public/mojom/input_service.mojom.h" #endif @@ -68,12 +68,12 @@ namespace device { -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) class HidManagerImpl; class SerialPortManagerImpl; #endif -#if defined(OS_ANDROID) || defined(OS_WIN) +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) class DevicePostureProviderImpl; #endif @@ -103,9 +103,9 @@ raw_ptr<GeolocationManager> geolocation_manager = nullptr; WakeLockContextCallback wake_lock_context_callback; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) base::android::ScopedJavaGlobalRef<jobject> java_nfc_delegate; -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) }; std::unique_ptr<DeviceService> CreateDeviceService( @@ -133,7 +133,7 @@ static void OverrideGeolocationContextBinderForTesting( GeolocationContextBinder binder); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Allows tests to override how frame hosts bind NFCProvider receivers. using NFCProviderBinder = base::RepeatingCallback<void( mojo::PendingReceiver<device::mojom::NFCProvider>)>; @@ -151,7 +151,7 @@ void BindGeolocationControl( mojo::PendingReceiver<mojom::GeolocationControl> receiver) override; -#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(USE_UDEV) +#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && defined(USE_UDEV) void BindInputDeviceManager( mojo::PendingReceiver<mojom::InputDeviceManager> receiver) override; #endif @@ -159,7 +159,7 @@ void BindBatteryMonitor( mojo::PendingReceiver<mojom::BatteryMonitor> receiver) override; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) void BindNFCProvider( mojo::PendingReceiver<mojom::NFCProvider> receiver) override; #endif @@ -167,7 +167,7 @@ void BindVibrationManager( mojo::PendingReceiver<mojom::VibrationManager> receiver) override; -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) void BindHidManager( mojo::PendingReceiver<mojom::HidManager> receiver) override; #endif @@ -193,7 +193,7 @@ void BindSensorProvider( mojo::PendingReceiver<mojom::SensorProvider> receiver) override; -#if defined(OS_ANDROID) || defined(OS_WIN) +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) void BindDevicePostureProvider( mojo::PendingReceiver<mojom::DevicePostureProvider> receiver) override; #endif @@ -231,7 +231,7 @@ WakeLockContextCallback wake_lock_context_callback_; WakeLockProvider wake_lock_provider_; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Binds |java_interface_provider_| to an interface registry that exposes // factories for the interfaces that are provided via Java on Android. service_manager::InterfaceProvider* GetJavaInterfaceProvider(); @@ -255,7 +255,7 @@ scoped_refptr<base::SequencedTaskRunner> serial_port_manager_task_runner_; #endif // defined(IS_SERIAL_ENABLED_PLATFORM) -#if defined(OS_ANDROID) || defined(OS_WIN) +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) std::unique_ptr<DevicePostureProviderImpl> device_posture_provider_; #endif
diff --git a/services/device/device_service_test_base.cc b/services/device/device_service_test_base.cc index ca8053c..e799fdbb 100644 --- a/services/device/device_service_test_base.cc +++ b/services/device/device_service_test_base.cc
@@ -11,12 +11,13 @@ #include "base/task/post_task.h" #include "base/task/single_thread_task_runner.h" #include "base/task/thread_pool.h" +#include "build/build_config.h" #include "services/device/device_service.h" #include "services/device/public/cpp/geolocation/location_provider.h" #include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h" #include "services/network/test/test_network_connection_tracker.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "services/device/public/cpp/test/fake_geolocation_manager.h" #endif @@ -63,7 +64,7 @@ void DeviceServiceTestBase::SetUp() { GeolocationManager* geolocation_manager = nullptr; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) fake_geolocation_manager_ = std::make_unique<FakeGeolocationManager>(); geolocation_manager = fake_geolocation_manager_.get(); #endif
diff --git a/services/device/device_service_test_base.h b/services/device/device_service_test_base.h index d6c287c..eeedf1a 100644 --- a/services/device/device_service_test_base.h +++ b/services/device/device_service_test_base.h
@@ -51,7 +51,7 @@ scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) std::unique_ptr<FakeGeolocationManager> fake_geolocation_manager_; #endif
diff --git a/services/device/generic_sensor/platform_sensor_provider.cc b/services/device/generic_sensor/platform_sensor_provider.cc index 19a1fac..41e6d0c 100644 --- a/services/device/generic_sensor/platform_sensor_provider.cc +++ b/services/device/generic_sensor/platform_sensor_provider.cc
@@ -4,17 +4,18 @@ #include "services/device/generic_sensor/platform_sensor_provider.h" +#include "build/build_config.h" #include "build/chromeos_buildflags.h" #if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) #include "chromeos/components/sensors/buildflags.h" #endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "services/device/generic_sensor/platform_sensor_provider_mac.h" -#elif defined(OS_ANDROID) +#elif BUILDFLAG(IS_ANDROID) #include "services/device/generic_sensor/platform_sensor_provider_android.h" -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) #include "base/win/windows_version.h" #include "build/build_config.h" #include "services/device/generic_sensor/platform_sensor_provider_win.h" @@ -25,7 +26,7 @@ #elif defined(USE_UDEV) #include "services/device/generic_sensor/platform_sensor_provider_linux.h" #endif // BUILDFLAG(USE_IIOSERVICE) -#elif defined(OS_LINUX) && defined(USE_UDEV) +#elif BUILDFLAG(IS_LINUX) && defined(USE_UDEV) #include "services/device/generic_sensor/platform_sensor_provider_linux.h" #endif @@ -33,11 +34,11 @@ // static std::unique_ptr<PlatformSensorProvider> PlatformSensorProvider::Create() { -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) return std::make_unique<PlatformSensorProviderMac>(); -#elif defined(OS_ANDROID) +#elif BUILDFLAG(IS_ANDROID) return std::make_unique<PlatformSensorProviderAndroid>(); -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) if (PlatformSensorProvider::UseWindowsWinrt()) { return std::make_unique<PlatformSensorProviderWinrt>(); } else { @@ -49,14 +50,14 @@ #elif defined(USE_UDEV) return std::make_unique<PlatformSensorProviderLinux>(); #endif // BUILDFLAG(USE_IIOSERVICE) -#elif defined(OS_LINUX) && defined(USE_UDEV) +#elif BUILDFLAG(IS_LINUX) && defined(USE_UDEV) return std::make_unique<PlatformSensorProviderLinux>(); #else return nullptr; #endif } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // static bool PlatformSensorProvider::UseWindowsWinrt() { // TODO: Windows version dependency should eventually be updated to
diff --git a/services/device/geolocation/geolocation_provider_impl.cc b/services/device/geolocation/geolocation_provider_impl.cc index dc0d12f..3ad39d7 100644 --- a/services/device/geolocation/geolocation_provider_impl.cc +++ b/services/device/geolocation/geolocation_provider_impl.cc
@@ -18,13 +18,14 @@ #include "base/task/single_thread_task_runner.h" #include "base/threading/thread_task_runner_handle.h" #include "base/time/default_tick_clock.h" +#include "build/build_config.h" #include "net/base/network_change_notifier.h" #include "services/device/geolocation/location_arbitrator.h" #include "services/device/geolocation/position_cache_impl.h" #include "services/device/public/cpp/geolocation/geoposition.h" #include "services/network/public/cpp/shared_url_loader_factory.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "base/android/jni_android.h" #include "services/device/geolocation/geolocation_jni_headers/LocationProviderFactory_jni.h" #endif @@ -58,7 +59,7 @@ g_custom_location_provider_callback.Get() = custom_location_provider_getter; g_geolocation_manager = geolocation_manager; if (use_gms_core_location_provider) { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) JNIEnv* env = base::android::AttachCurrentThread(); Java_LocationProviderFactory_useGmsCoreLocationProvider(env); #else @@ -175,7 +176,7 @@ } else { if (!IsRunning()) { base::Thread::Options options; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) options.message_pump_type = base::MessagePumpType::NS_RUNLOOP; #endif StartWithOptions(std::move(options));
diff --git a/services/device/geolocation/geolocation_service_unittest.cc b/services/device/geolocation/geolocation_service_unittest.cc index 757a18f7..460e172 100644 --- a/services/device/geolocation/geolocation_service_unittest.cc +++ b/services/device/geolocation/geolocation_service_unittest.cc
@@ -23,7 +23,7 @@ #include "services/device/public/mojom/geolocation_context.mojom.h" #include "services/device/public/mojom/geolocation_control.mojom.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "services/device/public/cpp/test/fake_geolocation_manager.h" #endif @@ -98,14 +98,14 @@ mojo::Remote<mojom::GeolocationConfig> geolocation_config_; }; -#if BUILDFLAG(IS_CHROMEOS_ASH) || defined(OS_ANDROID) +#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_ANDROID) // ChromeOS fails to perform network geolocation when zero wifi networks are // detected in a scan: https://crbug.com/767300. #else TEST_F(GeolocationServiceUnitTest, UrlWithApiKey) { // To align with user expectation we do not make Network Location Requests // on macOS unless the browser has Location Permission from the OS. -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) fake_geolocation_manager_->SetSystemPermission( LocationSystemPermissionStatus::kAllowed); #endif
diff --git a/services/device/geolocation/location_arbitrator.cc b/services/device/geolocation/location_arbitrator.cc index d5d8494..cedf1d2 100644 --- a/services/device/geolocation/location_arbitrator.cc +++ b/services/device/geolocation/location_arbitrator.cc
@@ -149,7 +149,7 @@ scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, const std::string& api_key) { DCHECK(url_loader_factory); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Android uses its own SystemLocationProvider. return nullptr; #else @@ -161,7 +161,7 @@ std::unique_ptr<LocationProvider> LocationArbitrator::NewSystemLocationProvider() { -#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_FUCHSIA) return nullptr; #else return device::NewSystemLocationProvider(main_task_runner_,
diff --git a/services/device/geolocation/network_location_provider.cc b/services/device/geolocation/network_location_provider.cc index 110959b..391d1fb 100644 --- a/services/device/geolocation/network_location_provider.cc +++ b/services/device/geolocation/network_location_provider.cc
@@ -15,12 +15,13 @@ #include "base/task/task_runner.h" #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" +#include "build/build_config.h" #include "net/traffic_annotation/network_traffic_annotation.h" #include "services/device/geolocation/position_cache.h" #include "services/device/public/cpp/geolocation/geoposition.h" #include "services/network/public/cpp/shared_url_loader_factory.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "services/device/public/cpp/device_features.h" #endif @@ -57,7 +58,7 @@ base::BindRepeating(&NetworkLocationProvider::OnLocationResponse, base::Unretained(this)))) { DCHECK(position_cache_); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) geolocation_manager_ = geolocation_manager; permission_observers_ = geolocation_manager->GetObserverList(); permission_observers_->AddObserver(this); @@ -72,7 +73,7 @@ NetworkLocationProvider::~NetworkLocationProvider() { DCHECK(thread_checker_.CalledOnValidThread()); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) permission_observers_->RemoveObserver(this); #endif if (IsStarted()) @@ -116,7 +117,7 @@ void NetworkLocationProvider::OnWifiDataUpdate() { DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(IsStarted()); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) if (!is_system_permission_granted_) { if (!is_awaiting_initial_permission_status_) { mojom::Geoposition error_position; @@ -204,7 +205,7 @@ void NetworkLocationProvider::RequestPosition() { DCHECK(thread_checker_.CalledOnValidThread()); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) if (!is_system_permission_granted_) { return; }
diff --git a/services/device/geolocation/network_location_provider.h b/services/device/geolocation/network_location_provider.h index a6674a4..ff58889 100644 --- a/services/device/geolocation/network_location_provider.h +++ b/services/device/geolocation/network_location_provider.h
@@ -73,7 +73,7 @@ WifiDataProviderManager::WifiDataUpdateCallback wifi_data_update_callback_; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Used to keep track of macOS System Permission changes. Also, ensures // lifetime of PermissionObserverList as the BrowserProcess may destroy its // reference on the UI Thread before we destroy this provider.
diff --git a/services/device/geolocation/network_location_provider_unittest.cc b/services/device/geolocation/network_location_provider_unittest.cc index e237454c..11ecc7d6 100644 --- a/services/device/geolocation/network_location_provider_unittest.cc +++ b/services/device/geolocation/network_location_provider_unittest.cc
@@ -34,7 +34,7 @@ #include "services/network/test/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "services/device/public/cpp/test/fake_geolocation_manager.h" #endif @@ -134,7 +134,7 @@ std::unique_ptr<LocationProvider> CreateProvider( bool set_permission_granted, const std::string& api_key = std::string()) { -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) fake_geolocation_manager_ = std::make_unique<FakeGeolocationManager>(); auto provider = std::make_unique<NetworkLocationProvider>( test_url_loader_factory_.GetSafeWeakWrapper(), @@ -160,7 +160,7 @@ bool grant_system_permission_by_default_ = true; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) std::unique_ptr<FakeGeolocationManager> fake_geolocation_manager_; #endif @@ -580,7 +580,7 @@ CheckRequestIsValid(kScanCount, 0); } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // Tests that, callbacks and network requests are never made until we have // system location permission. TEST_F(GeolocationNetworkProviderTest, MacOSSystemPermissionsTest) {
diff --git a/services/device/hid/hid_connection_impl_unittest.cc b/services/device/hid/hid_connection_impl_unittest.cc index 7b54227e..3acdee97 100644 --- a/services/device/hid/hid_connection_impl_unittest.cc +++ b/services/device/hid/hid_connection_impl_unittest.cc
@@ -19,9 +19,9 @@ namespace { -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) const uint64_t kTestDeviceId = 123; -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) const wchar_t* kTestDeviceId = L"123"; #else const char* kTestDeviceId = "123";
diff --git a/services/device/hid/hid_device_info.h b/services/device/hid/hid_device_info.h index 860b6cb..6f72dd23 100644 --- a/services/device/hid/hid_device_info.h +++ b/services/device/hid/hid_device_info.h
@@ -20,9 +20,9 @@ namespace device { -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) typedef uint64_t HidPlatformDeviceId; -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) typedef std::wstring HidPlatformDeviceId; #else typedef std::string HidPlatformDeviceId;
diff --git a/services/device/hid/hid_manager_unittest.cc b/services/device/hid/hid_manager_unittest.cc index 6112f24..a1d25a6 100644 --- a/services/device/hid/hid_manager_unittest.cc +++ b/services/device/hid/hid_manager_unittest.cc
@@ -27,9 +27,9 @@ using ::testing::ElementsAreArray; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) const uint64_t kTestDeviceIds[] = {0, 1, 2, 3}; -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) const wchar_t* const kTestDeviceIds[] = {L"0", L"1", L"2", L"3"}; #else const char* const kTestDeviceIds[] = {"0", "1", "2", "3"};
diff --git a/services/device/hid/hid_service.cc b/services/device/hid/hid_service.cc index 9150948..bde2cde0 100644 --- a/services/device/hid/hid_service.cc +++ b/services/device/hid/hid_service.cc
@@ -16,11 +16,11 @@ #include "build/build_config.h" #include "components/device_event_log/device_event_log.h" -#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(USE_UDEV) +#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && defined(USE_UDEV) #include "services/device/hid/hid_service_linux.h" -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) #include "services/device/hid/hid_service_mac.h" -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) #include "services/device/hid/hid_service_win.h" #endif @@ -59,11 +59,11 @@ // static std::unique_ptr<HidService> HidService::Create() { -#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(USE_UDEV) +#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && defined(USE_UDEV) return base::WrapUnique(new HidServiceLinux()); -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) return base::WrapUnique(new HidServiceMac()); -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) return base::WrapUnique(new HidServiceWin()); #else return nullptr;
diff --git a/services/device/public/cpp/hid/hid_device_filter_unittest.cc b/services/device/public/cpp/hid/hid_device_filter_unittest.cc index 32581d1..1e34d8c 100644 --- a/services/device/public/cpp/hid/hid_device_filter_unittest.cc +++ b/services/device/public/cpp/hid/hid_device_filter_unittest.cc
@@ -15,9 +15,9 @@ namespace { -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) const uint64_t kTestDeviceId = 42; -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) const wchar_t* kTestDeviceId = L"device1"; #else const char* kTestDeviceId = "device1";
diff --git a/services/device/public/cpp/test/fake_usb_device_manager.cc b/services/device/public/cpp/test/fake_usb_device_manager.cc index 1a3868e..bda03d4 100644 --- a/services/device/public/cpp/test/fake_usb_device_manager.cc +++ b/services/device/public/cpp/test/fake_usb_device_manager.cc
@@ -10,6 +10,7 @@ #include "base/containers/contains.h" #include "base/threading/thread_task_runner_handle.h" +#include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "mojo/public/cpp/bindings/associated_remote.h" #include "services/device/public/cpp/test/fake_usb_device.h" @@ -70,7 +71,7 @@ std::move(device_receiver), std::move(device_client)); } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) void FakeUsbDeviceManager::RefreshDeviceInfo( const std::string& guid, RefreshDeviceInfoCallback callback) {
diff --git a/services/device/public/cpp/test/fake_usb_device_manager.h b/services/device/public/cpp/test/fake_usb_device_manager.h index c852093a..cf8339a 100644 --- a/services/device/public/cpp/test/fake_usb_device_manager.h +++ b/services/device/public/cpp/test/fake_usb_device_manager.h
@@ -84,7 +84,7 @@ mojo::PendingReceiver<device::mojom::UsbDevice> device_receiver, mojo::PendingRemote<mojom::UsbDeviceClient> device_client) override; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) void RefreshDeviceInfo(const std::string& guid, RefreshDeviceInfoCallback callback) override; #endif
diff --git a/services/device/serial/serial_device_enumerator.cc b/services/device/serial/serial_device_enumerator.cc index 9c56d8a3..e622a4f 100644 --- a/services/device/serial/serial_device_enumerator.cc +++ b/services/device/serial/serial_device_enumerator.cc
@@ -10,11 +10,11 @@ #include "build/build_config.h" #include "components/device_event_log/device_event_log.h" -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #include "services/device/serial/serial_device_enumerator_linux.h" -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) #include "services/device/serial/serial_device_enumerator_mac.h" -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) #include "services/device/serial/serial_device_enumerator_win.h" #endif @@ -23,11 +23,11 @@ // static std::unique_ptr<SerialDeviceEnumerator> SerialDeviceEnumerator::Create( scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) return SerialDeviceEnumeratorLinux::Create(); -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) return std::make_unique<SerialDeviceEnumeratorMac>(); -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) return std::make_unique<SerialDeviceEnumeratorWin>(std::move(ui_task_runner)); #else #error "No implementation of SerialDeviceEnumerator on this platform." @@ -67,7 +67,7 @@ if (it == ports_.end()) return absl::nullopt; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) if (use_alternate_path) return it->second->alternate_path; #endif
diff --git a/services/device/serial/serial_io_handler_posix.cc b/services/device/serial/serial_io_handler_posix.cc index 4c99b68..6978e52 100644 --- a/services/device/serial/serial_io_handler_posix.cc +++ b/services/device/serial/serial_io_handler_posix.cc
@@ -17,7 +17,7 @@ #include "build/chromeos_buildflags.h" #include "components/device_event_log/device_event_log.h" -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #include <asm-generic/ioctls.h> #include <linux/serial.h> @@ -36,9 +36,9 @@ }; } -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include <IOKit/serial/ioss.h> #endif @@ -68,7 +68,7 @@ BITRATE_TO_SPEED_CASE(9600) BITRATE_TO_SPEED_CASE(19200) BITRATE_TO_SPEED_CASE(38400) -#if !defined(OS_MAC) +#if !BUILDFLAG(IS_MAC) BITRATE_TO_SPEED_CASE(57600) BITRATE_TO_SPEED_CASE(115200) BITRATE_TO_SPEED_CASE(230400) @@ -82,7 +82,7 @@ #undef BITRATE_TO_SPEED_CASE } -#if !defined(OS_LINUX) && !defined(OS_CHROMEOS) +#if !BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS) // Convert a known nominal speed into an integral bitrate. Returns |true| // if the conversion was successful and |false| otherwise. bool SpeedConstantToBitrate(speed_t speed, int* bitrate) { @@ -156,7 +156,7 @@ } bool SerialIoHandlerPosix::ConfigurePortImpl() { -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) struct termios2 config; if (ioctl(file().GetPlatformFile(), TCGETS2, &config) < 0) { #else @@ -179,11 +179,11 @@ DCHECK(options().bitrate); speed_t bitrate_opt = B0; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) bool need_iossiospeed = false; #endif if (BitrateToSpeedConstant(options().bitrate, &bitrate_opt)) { -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) config.c_cflag &= ~CBAUD; config.c_cflag |= bitrate_opt; #else @@ -192,11 +192,11 @@ #endif } else { // Attempt to set a custom speed. -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) config.c_cflag &= ~CBAUD; config.c_cflag |= CBAUDEX; config.c_ispeed = config.c_ospeed = options().bitrate; -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) // cfsetispeed and cfsetospeed sometimes work for custom baud rates on OS // X but the IOSSIOSPEED ioctl is more reliable but has to be done after // the rest of the port parameters are set or else it will be overwritten. @@ -264,7 +264,7 @@ config.c_cflag &= ~CRTSCTS; } -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) if (ioctl(file().GetPlatformFile(), TCSETS2, &config) < 0) { #else if (tcsetattr(file().GetPlatformFile(), TCSANOW, &config) != 0) { @@ -273,7 +273,7 @@ return false; } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) if (need_iossiospeed) { speed_t bitrate = options().bitrate; if (ioctl(file().GetPlatformFile(), IOSSIOSPEED, &bitrate) == -1) { @@ -505,7 +505,7 @@ } mojom::SerialConnectionInfoPtr SerialIoHandlerPosix::GetPortInfo() const { -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) struct termios2 config; if (ioctl(file().GetPlatformFile(), TCGETS2, &config) < 0) { #else @@ -517,7 +517,7 @@ } auto info = mojom::SerialConnectionInfo::New(); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Linux forces c_ospeed to contain the correct value, which is nice. info->bitrate = config.c_ospeed; #else
diff --git a/services/device/usb/mojo/device_manager_impl.cc b/services/device/usb/mojo/device_manager_impl.cc index 2ba6ce1..fdf37447 100644 --- a/services/device/usb/mojo/device_manager_impl.cc +++ b/services/device/usb/mojo/device_manager_impl.cc
@@ -15,6 +15,7 @@ #include "base/callback_helpers.h" #include "base/files/file_util.h" #include "base/memory/ptr_util.h" +#include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "mojo/public/cpp/bindings/associated_remote.h" #include "services/device/public/cpp/usb/usb_utils.h" @@ -85,7 +86,7 @@ /*allow_security_key_requests=*/true); } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) void DeviceManagerImpl::RefreshDeviceInfo(const std::string& guid, RefreshDeviceInfoCallback callback) { scoped_refptr<UsbDevice> device = usb_service_->GetDevice(guid); @@ -116,7 +117,7 @@ std::move(callback).Run(device->device_info().Clone()); } -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) #if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) void DeviceManagerImpl::CheckAccess(const std::string& guid,
diff --git a/services/device/usb/mojo/device_manager_impl.h b/services/device/usb/mojo/device_manager_impl.h index 4781e18..030614d 100644 --- a/services/device/usb/mojo/device_manager_impl.h +++ b/services/device/usb/mojo/device_manager_impl.h
@@ -66,13 +66,13 @@ mojo::PendingReceiver<mojom::UsbDevice> device_receiver, mojo::PendingRemote<mojom::UsbDeviceClient> device_client) override; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) void RefreshDeviceInfo(const std::string& guid, RefreshDeviceInfoCallback callback) override; void OnPermissionGrantedToRefresh(scoped_refptr<UsbDevice> device, RefreshDeviceInfoCallback callback, bool granted); -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) #if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) void CheckAccess(const std::string& guid,
diff --git a/services/device/usb/usb_service.cc b/services/device/usb/usb_service.cc index 7c23cce..3e771d9 100644 --- a/services/device/usb/usb_service.cc +++ b/services/device/usb/usb_service.cc
@@ -19,14 +19,14 @@ #include "services/device/usb/usb_device.h" #include "services/device/usb/usb_device_handle.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "services/device/usb/usb_service_android.h" #elif defined(USE_UDEV) #include "services/device/usb/usb_service_linux.h" -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) #include "services/device/usb/usb_service_impl.h" #include "services/device/usb/usb_service_mac.h" -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) #include "services/device/usb/usb_service_win.h" #endif @@ -48,13 +48,13 @@ // static std::unique_ptr<UsbService> UsbService::Create() { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) return base::WrapUnique(new UsbServiceAndroid()); #elif defined(USE_UDEV) return base::WrapUnique(new UsbServiceLinux()); -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) return base::WrapUnique(new UsbServiceWin()); -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) if (base::FeatureList::IsEnabled(kNewUsbBackend)) return base::WrapUnique(new UsbServiceMac()); else
diff --git a/services/device/usb/usb_service_unittest.cc b/services/device/usb/usb_service_unittest.cc index ada5b04..42b4f456 100644 --- a/services/device/usb/usb_service_unittest.cc +++ b/services/device/usb/usb_service_unittest.cc
@@ -54,7 +54,7 @@ } } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) TEST_F(UsbServiceTest, GetDevicesNewBackend) { base::test::ScopedFeatureList features; features.InitAndEnableFeature(device::kNewUsbBackend); @@ -66,7 +66,7 @@ loop.Run(); } } -#endif // defined(OS_MAC) +#endif // BUILDFLAG(IS_MAC) TEST_F(UsbServiceTest, ClaimGadget) { if (!UsbTestGadget::IsTestEnabled() || !usb_service_)
diff --git a/services/device/vibration/vibration_manager_impl_unittest.cc b/services/device/vibration/vibration_manager_impl_unittest.cc index d53beea..e84b8cc 100644 --- a/services/device/vibration/vibration_manager_impl_unittest.cc +++ b/services/device/vibration/vibration_manager_impl_unittest.cc
@@ -3,11 +3,12 @@ // found in the LICENSE file. #include "base/run_loop.h" +#include "build/build_config.h" #include "mojo/public/cpp/bindings/remote.h" #include "services/device/device_service_test_base.h" #include "services/device/public/mojom/vibration_manager.mojom.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "base/android/jni_android.h" #include "services/device/vibration/android/vibration_jni_headers/VibrationManagerImpl_jni.h" #else @@ -48,7 +49,7 @@ } int64_t GetVibrationMilliSeconds() { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) return Java_VibrationManagerImpl_getVibrateMilliSecondsForTesting( base::android::AttachCurrentThread()); #else @@ -57,7 +58,7 @@ } bool GetVibrationCancelled() { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) return Java_VibrationManagerImpl_getVibrateCancelledForTesting( base::android::AttachCurrentThread()); #else
diff --git a/services/device/wake_lock/power_save_blocker/power_save_blocker.h b/services/device/wake_lock/power_save_blocker/power_save_blocker.h index 026407b2..570eac5 100644 --- a/services/device/wake_lock/power_save_blocker/power_save_blocker.h +++ b/services/device/wake_lock/power_save_blocker/power_save_blocker.h
@@ -14,7 +14,7 @@ #include "build/build_config.h" #include "services/device/public/mojom/wake_lock.mojom.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "ui/android/view_android.h" #endif // OS_ANDROID @@ -41,7 +41,7 @@ virtual ~PowerSaveBlocker(); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // On Android, the mojom::WakeLockType::kPreventDisplaySleep type of // PowerSaveBlocker should associated with a View, so the blocker can be // removed by the platform. Note that |view_android| is guaranteed to be
diff --git a/services/device/wake_lock/wake_lock.cc b/services/device/wake_lock/wake_lock.cc index f54a772..d2c635d 100644 --- a/services/device/wake_lock/wake_lock.cc +++ b/services/device/wake_lock/wake_lock.cc
@@ -7,6 +7,7 @@ #include <utility> #include "base/bind.h" +#include "build/build_config.h" #include "services/device/wake_lock/wake_lock_context.h" namespace device { @@ -23,7 +24,7 @@ type_(type), reason_(reason), description_(std::make_unique<std::string>(description)), -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) context_id_(context_id), native_view_getter_(native_view_getter), #endif @@ -79,7 +80,7 @@ ChangeTypeCallback callback) { DCHECK(main_task_runner_->RunsTasksInCurrentSequence()); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) LOG(ERROR) << "WakeLock::ChangeType() has no effect on Android."; std::move(callback).Run(false); #else @@ -128,7 +129,7 @@ if (type_ != mojom::WakeLockType::kPreventDisplaySleep) return; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) if (context_id_ == WakeLockContext::WakeLockInvalidContextId) { LOG(ERROR) << "Client must pass a valid context_id when requests wake lock " "on Android.";
diff --git a/services/device/wake_lock/wake_lock.h b/services/device/wake_lock/wake_lock.h index bab0f7ae..e2e8622 100644 --- a/services/device/wake_lock/wake_lock.h +++ b/services/device/wake_lock/wake_lock.h
@@ -89,7 +89,7 @@ mojom::WakeLockReason reason_; std::unique_ptr<std::string> description_; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) int context_id_; WakeLockContextCallback native_view_getter_; #endif
diff --git a/services/device/wake_lock/wake_lock_unittest.cc b/services/device/wake_lock/wake_lock_unittest.cc index b393125..0382c006 100644 --- a/services/device/wake_lock/wake_lock_unittest.cc +++ b/services/device/wake_lock/wake_lock_unittest.cc
@@ -9,6 +9,7 @@ #include "base/bind.h" #include "base/run_loop.h" +#include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_remote.h" @@ -203,7 +204,7 @@ // multiple clients. Has no effect on Android either. TEST_F(WakeLockTest, ChangeType) { EXPECT_FALSE(HasWakeLock()); -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) // Call ChangeType() on a wake lock that is in inactive status. EXPECT_TRUE(ChangeType(device::mojom::WakeLockType::kPreventAppSuspension)); EXPECT_TRUE(ChangeType(device::mojom::WakeLockType::kPreventDisplaySleep));
diff --git a/services/media_session/public/cpp/features.cc b/services/media_session/public/cpp/features.cc index b3fd5ee..c576bf2 100644 --- a/services/media_session/public/cpp/features.cc +++ b/services/media_session/public/cpp/features.cc
@@ -15,7 +15,7 @@ // changes to behavior. It is enabled by default on all platforms except Android. const base::Feature kMediaSessionService { "MediaSessionService", -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) base::FEATURE_ENABLED_BY_DEFAULT #else base::FEATURE_DISABLED_BY_DEFAULT
diff --git a/services/media_session/public/cpp/media_image.h b/services/media_session/public/cpp/media_image.h index 40706060..d70036a 100644 --- a/services/media_session/public/cpp/media_image.h +++ b/services/media_session/public/cpp/media_image.h
@@ -13,13 +13,13 @@ #include "ui/gfx/geometry/size.h" #include "url/gurl.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include <jni.h> #include "base/android/scoped_java_ref.h" -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) namespace media_session { @@ -32,7 +32,7 @@ bool operator==(const MediaImage& other) const; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Creates a Java array of MediaImage instances and returns the JNI ref. static base::android::ScopedJavaLocalRef<jobjectArray> ToJavaArray( JNIEnv* env,
diff --git a/services/media_session/public/cpp/media_metadata.h b/services/media_session/public/cpp/media_metadata.h index 13596e1..beb571dd 100644 --- a/services/media_session/public/cpp/media_metadata.h +++ b/services/media_session/public/cpp/media_metadata.h
@@ -12,13 +12,13 @@ #include "build/build_config.h" #include "url/gurl.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include <jni.h> #include "base/android/scoped_java_ref.h" -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) namespace media_session { @@ -33,7 +33,7 @@ bool operator==(const MediaMetadata& other) const; bool operator!=(const MediaMetadata& other) const; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Creates a Java MediaMetadata instance and returns the JNI ref. base::android::ScopedJavaLocalRef<jobject> CreateJavaObject( JNIEnv* env) const;
diff --git a/services/media_session/public/cpp/media_position.h b/services/media_session/public/cpp/media_position.h index 9d8a7a8..773dcb9 100644 --- a/services/media_session/public/cpp/media_position.h +++ b/services/media_session/public/cpp/media_position.h
@@ -10,13 +10,13 @@ #include "base/time/time.h" #include "build/build_config.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include <jni.h> #include "base/android/scoped_java_ref.h" -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) namespace IPC { template <class P> @@ -48,7 +48,7 @@ bool end_of_media); ~MediaPosition(); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Creates a Java MediaPosition instance and returns the JNI ref. base::android::ScopedJavaLocalRef<jobject> CreateJavaObject( JNIEnv* env) const;
diff --git a/services/network/cookie_manager.cc b/services/network/cookie_manager.cc index 0503a986..f0660ff 100644 --- a/services/network/cookie_manager.cc +++ b/services/network/cookie_manager.cc
@@ -7,6 +7,7 @@ #include <utility> #include "base/bind.h" +#include "base/callback.h" #include "base/callback_helpers.h" #include "base/process/process.h" #include "build/build_config.h" @@ -16,11 +17,13 @@ #include "net/cookies/cookie_constants.h" #include "net/cookies/cookie_monster.h" #include "net/cookies/cookie_options.h" +#include "net/cookies/cookie_partition_key.h" #include "net/cookies/cookie_store.h" #include "net/cookies/cookie_util.h" #include "net/url_request/url_request_context.h" #include "services/network/cookie_access_delegate_impl.h" #include "services/network/session_cleanup_cookie_store.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" using CookieDeletionInfo = net::CookieDeletionInfo; @@ -94,7 +97,7 @@ const net::CookieOptions& cookie_options, const net::CookiePartitionKeyCollection& cookie_partition_key_collection, GetCookieListCallback callback) { -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) if (g_crash_on_get_cookie_list) base::Process::TerminateCurrentProcessImmediately(1); #endif @@ -110,50 +113,81 @@ const GURL& source_url, const net::CookieOptions& cookie_options, SetCanonicalCookieCallback callback) { - std::unique_ptr<net::CanonicalCookie> cookie_ptr = - std::make_unique<net::CanonicalCookie>(cookie); - if (absl::optional<net::CookiePartitionKey> cookie_partition_key = - cookie.PartitionKey()) { - absl::optional<net::CookiePartitionKey> fps_cookie_partition_key = - net::CookieAccessDelegate::FirstPartySetifyPartitionKey( - cookie_store_->cookie_access_delegate(), - cookie_partition_key.value()); - if (fps_cookie_partition_key != cookie_partition_key) { - cookie_ptr = net::CanonicalCookie::FromStorage( - cookie.Name(), cookie.Value(), cookie.Domain(), cookie.Path(), - cookie.CreationDate(), cookie.ExpiryDate(), cookie.LastAccessDate(), - cookie.IsSecure(), cookie.IsHttpOnly(), cookie.SameSite(), - cookie.Priority(), cookie.IsSameParty(), fps_cookie_partition_key, - cookie.SourceScheme(), cookie.SourcePort()); - if (!cookie_ptr) { - std::move(callback).Run( - net::CookieAccessResult(net::CookieInclusionStatus( - net::CookieInclusionStatus::ExclusionReason:: - EXCLUDE_FAILURE_TO_STORE))); - return; - } + absl::optional<net::CookiePartitionKey> cookie_partition_key = + cookie.PartitionKey(); + base::OnceCallback<void(absl::optional<net::CookiePartitionKey>)> + on_got_first_party_set_key = + base::BindOnce(&CookieManager::OnGotFirstPartySetPartitionKeyForSet, + weak_factory_.GetWeakPtr(), source_url, cookie_options, + std::make_unique<net::CanonicalCookie>(cookie), + std::move(callback), cookie_partition_key); + if (!cookie_partition_key) { + std::move(on_got_first_party_set_key).Run(absl::nullopt); + return; + } + net::CookieAccessDelegate::FirstPartySetifyPartitionKey( + cookie_store_->cookie_access_delegate(), cookie_partition_key.value(), + std::move(on_got_first_party_set_key)); +} + +void CookieManager::OnGotFirstPartySetPartitionKeyForSet( + const GURL& source_url, + const net::CookieOptions& cookie_options, + std::unique_ptr<net::CanonicalCookie> cookie, + SetCanonicalCookieCallback callback, + absl::optional<net::CookiePartitionKey> cookie_partition_key, + absl::optional<net::CookiePartitionKey> fps_cookie_partition_key) { + if (cookie_partition_key.has_value() && + fps_cookie_partition_key != cookie_partition_key) { + cookie = net::CanonicalCookie::FromStorage( + cookie->Name(), cookie->Value(), cookie->Domain(), cookie->Path(), + cookie->CreationDate(), cookie->ExpiryDate(), cookie->LastAccessDate(), + cookie->IsSecure(), cookie->IsHttpOnly(), cookie->SameSite(), + cookie->Priority(), cookie->IsSameParty(), fps_cookie_partition_key, + cookie->SourceScheme(), cookie->SourcePort()); + if (!cookie) { + std::move(callback).Run( + net::CookieAccessResult(net::CookieInclusionStatus( + net::CookieInclusionStatus::ExclusionReason:: + EXCLUDE_FAILURE_TO_STORE))); + return; } } - cookie_store_->SetCanonicalCookieAsync(std::move(cookie_ptr), source_url, + cookie_store_->SetCanonicalCookieAsync(std::move(cookie), source_url, cookie_options, std::move(callback)); } void CookieManager::DeleteCanonicalCookie( const net::CanonicalCookie& cookie, DeleteCanonicalCookieCallback callback) { - std::unique_ptr<net::CanonicalCookie> cookie_ptr = - std::make_unique<net::CanonicalCookie>(cookie); - if (absl::optional<net::CookiePartitionKey> cookie_partition_key = - cookie.PartitionKey()) { - absl::optional<net::CookiePartitionKey> fps_cookie_partition_key = - net::CookieAccessDelegate::FirstPartySetifyPartitionKey( - cookie_store_->cookie_access_delegate(), - cookie_partition_key.value()); - if (fps_cookie_partition_key && !cookie_partition_key->site().opaque()) - DCHECK_EQ(cookie_partition_key.value(), fps_cookie_partition_key.value()); + absl::optional<net::CookiePartitionKey> cookie_partition_key = + cookie.PartitionKey(); + + base::OnceCallback<void(absl::optional<net::CookiePartitionKey>)> + on_got_first_party_set_key = base::BindOnce( + &CookieManager::OnGotFirstPartySetPartitionKeyForDelete, + weak_factory_.GetWeakPtr(), + std::make_unique<net::CanonicalCookie>(cookie), std::move(callback), + cookie_partition_key); + + if (!cookie_partition_key || cookie_partition_key->site().opaque()) { + std::move(on_got_first_party_set_key).Run(absl::nullopt); + return; } + net::CookieAccessDelegate::FirstPartySetifyPartitionKey( + cookie_store_->cookie_access_delegate(), cookie_partition_key.value(), + std::move(on_got_first_party_set_key)); +} + +void CookieManager::OnGotFirstPartySetPartitionKeyForDelete( + std::unique_ptr<net::CanonicalCookie> cookie, + DeleteCanonicalCookieCallback callback, + absl::optional<net::CookiePartitionKey> cookie_partition_key, + absl::optional<net::CookiePartitionKey> fps_cookie_partition_key) { + if (cookie_partition_key && fps_cookie_partition_key) + DCHECK_EQ(cookie_partition_key.value(), fps_cookie_partition_key.value()); cookie_store_->DeleteCanonicalCookieAsync( - *cookie_ptr, + *cookie, base::BindOnce( [](DeleteCanonicalCookieCallback callback, uint32_t num_deleted) { std::move(callback).Run(num_deleted > 0);
diff --git a/services/network/cookie_manager.h b/services/network/cookie_manager.h index bb988d9..903ea211 100644 --- a/services/network/cookie_manager.h +++ b/services/network/cookie_manager.h
@@ -11,6 +11,7 @@ #include "base/component_export.h" #include "base/memory/raw_ptr.h" +#include "base/memory/weak_ptr.h" #include "components/content_settings/core/common/content_settings.h" #include "mojo/public/cpp/bindings/receiver_set.h" #include "mojo/public/cpp/bindings/remote.h" @@ -136,6 +137,24 @@ // Handles connection errors on change listener pipes. void RemoveChangeListener(ListenerRegistration* registration); + // Called after getting the First-Party-Set-aware partition key when setting a + // cookie. + void OnGotFirstPartySetPartitionKeyForSet( + const GURL& source_url, + const net::CookieOptions& cookie_options, + std::unique_ptr<net::CanonicalCookie> cookie, + SetCanonicalCookieCallback callback, + absl::optional<net::CookiePartitionKey> cookie_partition_key, + absl::optional<net::CookiePartitionKey> fps_cookie_partition_key); + + // Called after getting the First-Party-Set-aware partition key when deleting + // a cookie. + void OnGotFirstPartySetPartitionKeyForDelete( + std::unique_ptr<net::CanonicalCookie> cookie, + DeleteCanonicalCookieCallback callback, + absl::optional<net::CookiePartitionKey> cookie_partition_key, + absl::optional<net::CookiePartitionKey> fps_cookie_partition_key); + const raw_ptr<net::CookieStore> cookie_store_; scoped_refptr<SessionCleanupCookieStore> session_cleanup_cookie_store_; mojo::ReceiverSet<mojom::CookieManager> receivers_; @@ -143,6 +162,8 @@ // Note: RestrictedCookieManager and CookieAccessDelegate store pointers to // |cookie_settings_|. CookieSettings cookie_settings_; + + base::WeakPtrFactory<CookieManager> weak_factory_{this}; }; COMPONENT_EXPORT(NETWORK_SERVICE)
diff --git a/services/network/host_resolver.cc b/services/network/host_resolver.cc index 1829e94..9986bce 100644 --- a/services/network/host_resolver.cc +++ b/services/network/host_resolver.cc
@@ -25,7 +25,7 @@ #include "services/network/resolve_host_request.h" #include "third_party/abseil-cpp/absl/types/optional.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "net/base/features.h" #include "services/network/radio_monitor_android.h" #endif @@ -127,7 +127,7 @@ if (rv != net::ERR_IO_PENDING) return; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) if (base::FeatureList::IsEnabled(net::features::kRecordRadioWakeupTrigger)) { MaybeRecordResolveHostForWakeupTrigger(optional_parameters); }
diff --git a/services/network/host_resolver_unittest.cc b/services/network/host_resolver_unittest.cc index c5c8c52..3b9e067 100644 --- a/services/network/host_resolver_unittest.cc +++ b/services/network/host_resolver_unittest.cc
@@ -41,7 +41,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "base/android/radio_utils.h" #include "base/test/metrics/histogram_tester.h" #include "base/test/scoped_feature_list.h" @@ -1574,7 +1574,7 @@ } #endif // BUILDFLAG(ENABLE_MDNS) -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) class HostResolverRecordRadioWakeupTest : public HostResolverTest { public: @@ -1625,7 +1625,7 @@ mojom::ResolveHostParameters::Purpose::kPreconnect, 1); } -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) } // namespace } // namespace network
diff --git a/services/network/network_change_manager.cc b/services/network/network_change_manager.cc index a5c58e0..3009cdfc 100644 --- a/services/network/network_change_manager.cc +++ b/services/network/network_change_manager.cc
@@ -8,6 +8,7 @@ #include <utility> #include "base/bind.h" +#include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "net/base/network_change_notifier.h" @@ -49,7 +50,7 @@ clients_.push_back(std::move(client_remote)); } -#if BUILDFLAG(IS_CHROMEOS_ASH) || defined(OS_ANDROID) +#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_ANDROID) void NetworkChangeManager::OnNetworkChanged( bool dns_changed, bool ip_address_changed,
diff --git a/services/network/network_change_manager.h b/services/network/network_change_manager.h index fd20629..b5bc84fd 100644 --- a/services/network/network_change_manager.h +++ b/services/network/network_change_manager.h
@@ -45,7 +45,7 @@ mojo::PendingRemote<mojom::NetworkChangeManagerClient> client_remote) override; -#if BUILDFLAG(IS_CHROMEOS_ASH) || defined(OS_ANDROID) +#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_ANDROID) void OnNetworkChanged( bool dns_changed, bool ip_address_changed,
diff --git a/services/network/network_context.cc b/services/network/network_context.cc index 4402b71..4f399e5 100644 --- a/services/network/network_context.cc +++ b/services/network/network_context.cc
@@ -136,9 +136,9 @@ #include "services/network/cert_verifier_with_trust_anchors.h" #endif // BUILDFLAG(IS_CHROMEOS_ASH) -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) #include "services/network/websocket_factory.h" -#endif // !defined(OS_IOS) +#endif // !BUILDFLAG(IS_IOS) #if BUILDFLAG(ENABLE_REPORTING) #include "net/base/http_user_agent_settings.h" @@ -157,7 +157,7 @@ #include "services/network/p2p/socket_manager.h" #endif -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "base/android/application_status_listener.h" #endif @@ -287,7 +287,7 @@ std::move(filter_origins)); } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) class NetworkContextApplicationStatusListener : public base::android::ApplicationStatusListener { public: @@ -451,7 +451,7 @@ #endif params_(std::move(params)), on_connection_close_callback_(std::move(on_connection_close_callback)), -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) app_status_listener_( std::make_unique<NetworkContextApplicationStatusListener>()), #endif @@ -459,14 +459,14 @@ cors_preflight_controller_(network_service), cors_non_wildcard_request_headers_support_(base::FeatureList::IsEnabled( features::kCorsNonWildcardRequestHeadersSupport)) { -#if defined(OS_WIN) && DCHECK_IS_ON() +#if BUILDFLAG(IS_WIN) && DCHECK_IS_ON() if (params_->file_paths) { DCHECK(params_->win_permissions_set) << "Permissions not set on files. Network context should be created " "using CreateNetworkContextInNetworkService rather than directly on " "the network service."; } -#endif // defined(OS_WIN) && DCHECK_IS_ON() +#endif // BUILDFLAG(IS_WIN) && DCHECK_IS_ON() mojo::PendingRemote<mojom::URLLoaderFactory> url_loader_factory_for_cert_net_fetcher; mojo::PendingReceiver<mojom::URLLoaderFactory> @@ -529,7 +529,7 @@ sct_auditing_handler()->SetEnabled(params_->enable_sct_auditing); #endif -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) if (params_->cookie_manager) GetCookieManager(std::move(params_->cookie_manager)); #endif @@ -548,7 +548,7 @@ #if BUILDFLAG(ENABLE_REPORTING) is_observing_reporting_service_(false), #endif -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) app_status_listener_( std::make_unique<NetworkContextApplicationStatusListener>()), #endif @@ -1546,7 +1546,7 @@ mojo::PendingRemote<mojom::WebSocketAuthenticationHandler> auth_handler, mojo::PendingRemote<mojom::TrustedHeaderClient> header_client, const absl::optional<base::UnguessableToken>& throttling_profile_id) { -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) if (!websocket_factory_) websocket_factory_ = std::make_unique<WebSocketFactory>(this); @@ -1558,7 +1558,7 @@ static_cast<net::NetworkTrafficAnnotationTag>(traffic_annotation), std::move(handshake_client), std::move(url_loader_network_observer), std::move(auth_handler), std::move(header_client), throttling_profile_id); -#endif // !defined(OS_IOS) +#endif // !BUILDFLAG(IS_IOS) } void NetworkContext::CreateWebTransport( @@ -2072,12 +2072,12 @@ http_auth_dynamic_network_service_params->enable_negotiate_port); http_auth_merged_preferences_.set_basic_over_http_enabled( http_auth_dynamic_network_service_params->basic_over_http_enabled); -#if defined(OS_POSIX) || defined(OS_FUCHSIA) +#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) http_auth_merged_preferences_.set_ntlm_v2_enabled( http_auth_dynamic_network_service_params->ntlm_v2_enabled); #endif -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) http_auth_merged_preferences_.set_auth_android_negotiate_account_type( http_auth_dynamic_network_service_params->android_negotiate_account_type); #endif @@ -2255,7 +2255,7 @@ std::move(params_->proxy_resolver_factory)); } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) if (params_->windows_system_proxy_resolver) { // TODO(https://crbug.com/1032820): Connect to proxy_resolver_win service. } @@ -2281,7 +2281,7 @@ } cache_params.reset_cache = params_->reset_http_cache_backend; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) cache_params.app_status_listener = app_status_listener(); #endif builder.EnableHttpCache(cache_params); @@ -2497,10 +2497,10 @@ certificate_report_sender_.get()); } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) result.url_request_context->set_check_cleartext_permitted( params_->check_clear_text_permitted); -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) #if BUILDFLAG(IS_CT_SUPPORTED) if (params_->enable_expect_ct_reporting) {
diff --git a/services/network/network_context.h b/services/network/network_context.h index 08d7391..cec665b 100644 --- a/services/network/network_context.h +++ b/services/network/network_context.h
@@ -182,7 +182,7 @@ return params_ && params_->allow_any_cors_exempt_header_for_browser; } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) base::android::ApplicationStatusListener* app_status_listener() const { return app_status_listener_.get(); } @@ -669,7 +669,7 @@ // If non-null, called when the mojo pipe for the NetworkContext is closed. OnConnectionCloseCallback on_connection_close_callback_; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) std::unique_ptr<base::android::ApplicationStatusListener> app_status_listener_; #endif @@ -692,9 +692,9 @@ mojo::UniqueReceiverSet<mojom::HasTrustTokensAnswerer> has_trust_tokens_answerers_; -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) std::unique_ptr<WebSocketFactory> websocket_factory_; -#endif // !defined(OS_IOS) +#endif // !BUILDFLAG(IS_IOS) // These must be below the URLRequestContext, so they're destroyed before it // is.
diff --git a/services/network/network_context_unittest.cc b/services/network/network_context_unittest.cc index adef22b..afc980e 100644 --- a/services/network/network_context_unittest.cc +++ b/services/network/network_context_unittest.cc
@@ -3837,7 +3837,7 @@ } // Config overrides are not supported on iOS. -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) TEST_F(NetworkContextTest, CreateHostResolverWithConfigOverrides) { // Inject a factory to control and capture created net::HostResolvers. TestResolverFactory* factory = @@ -3914,7 +3914,7 @@ EXPECT_THAT(response_client.result_addresses().value().endpoints(), testing::ElementsAre(CreateExpectedEndPoint(kResult, 80))); } -#endif // defined(OS_IOS) +#endif // BUILDFLAG(IS_IOS) TEST_F(NetworkContextTest, ActivateDohProbes) { auto resolver = std::make_unique<net::MockHostResolver>(); @@ -5868,7 +5868,7 @@ } }; -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Flaky crashes on Linux: https://crbug.com/1115201 #define MAYBE_CustomProxyUsesSpecifiedProxyList \ DISABLED_CustomProxyUsesSpecifiedProxyList
diff --git a/services/network/network_service.cc b/services/network/network_service.cc index e878973..8a02b9f 100644 --- a/services/network/network_service.cc +++ b/services/network/network_service.cc
@@ -26,6 +26,7 @@ #include "base/task/thread_pool.h" #include "base/timer/timer.h" #include "base/values.h" +#include "build/build_config.h" #include "build/chromecast_buildflags.h" #include "build/chromeos_buildflags.h" #include "components/network_session_configurator/common/network_features.h" @@ -71,17 +72,17 @@ #include "services/network/public/mojom/network_service_test.mojom.h" #include "services/network/url_loader.h" -#if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) +#if BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_ARMEL) #include "crypto/openssl_util.h" #include "third_party/boringssl/src/include/openssl/cpu.h" #endif -#if (defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && \ +#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && \ !BUILDFLAG(IS_CHROMECAST) #include "components/os_crypt/key_storage_config_linux.h" #endif -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "base/android/application_status_listener.h" #include "net/android/http_auth_negotiate_android.h" #endif @@ -120,7 +121,7 @@ } } -#if defined(OS_ANDROID) && BUILDFLAG(USE_KERBEROS) +#if BUILDFLAG(IS_ANDROID) && BUILDFLAG(USE_KERBEROS) // Used for Negotiate authentication on Android, which needs to generate tokens // in the browser process. class NetworkServiceAuthNegotiateAndroid : public net::HttpAuthMechanism { @@ -279,7 +280,7 @@ initialized_ = true; -#if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) +#if BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_ARMEL) // Make sure OpenSSL is initialized before using it to histogram data. crypto::EnsureOpenSSLInit(); @@ -654,7 +655,7 @@ ->OnPeerToPeerConnectionsCountChange(count); } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) void NetworkService::OnApplicationStateChange( base::android::ApplicationState state) { for (auto* network_context : network_contexts_) @@ -730,7 +731,7 @@ #endif // BUILDFLAG(IS_CT_SUPPORTED) -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) void NetworkService::DumpWithoutCrashing(base::Time dump_request_time) { static base::debug::CrashKeyString* time_key = base::debug::AllocateCrashKeyString("time_since_dump_request_ms", @@ -772,7 +773,7 @@ if (!http_auth_static_network_service_params_) { return net::HttpAuthHandlerFactory::CreateDefault( network_context->GetHttpAuthPreferences() -#if defined(OS_ANDROID) && BUILDFLAG(USE_KERBEROS) +#if BUILDFLAG(IS_ANDROID) && BUILDFLAG(USE_KERBEROS) , base::BindRepeating(&CreateAuthSystem, network_context) #endif @@ -786,7 +787,7 @@ , http_auth_static_network_service_params_->gssapi_library_name #endif -#if defined(OS_ANDROID) && BUILDFLAG(USE_KERBEROS) +#if BUILDFLAG(IS_ANDROID) && BUILDFLAG(USE_KERBEROS) , base::BindRepeating(&CreateAuthSystem, network_context) #endif
diff --git a/services/network/network_service.h b/services/network/network_service.h index 2fac6bb..c6ce966c 100644 --- a/services/network/network_service.h +++ b/services/network/network_service.h
@@ -167,7 +167,7 @@ void OnMemoryPressure(base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) override; void OnPeerToPeerConnectionsCountChange(uint32_t count) override; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) void OnApplicationStateChange(base::android::ApplicationState state) override; #endif void SetEnvironment( @@ -189,7 +189,7 @@ void SetCtEnforcementEnabled(bool enabled) override; #endif -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) void DumpWithoutCrashing(base::Time dump_request_time) override; #endif void BindTestInterface(
diff --git a/services/network/network_service_network_delegate.cc b/services/network/network_service_network_delegate.cc index d9b9da7..c765b468 100644 --- a/services/network/network_service_network_delegate.cc +++ b/services/network/network_service_network_delegate.cc
@@ -26,7 +26,7 @@ #include "services/network/url_loader.h" #include "url/gurl.h" -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) #include "services/network/websocket.h" #endif @@ -110,11 +110,11 @@ if (url_loader) return url_loader->OnBeforeStartTransaction(headers, std::move(callback)); -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) WebSocket* web_socket = WebSocket::ForRequest(*request); if (web_socket) return web_socket->OnBeforeStartTransaction(headers, std::move(callback)); -#endif // !defined(OS_IOS) +#endif // !BUILDFLAG(IS_IOS) return net::OK; } @@ -135,14 +135,14 @@ preserve_fragment_on_redirect_url)); } -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) WebSocket* web_socket = WebSocket::ForRequest(*request); if (web_socket) { chain->AddResult(web_socket->OnHeadersReceived( chain->CreateCallback(), original_response_headers, override_response_headers, preserve_fragment_on_redirect_url)); } -#endif // !defined(OS_IOS) +#endif // !BUILDFLAG(IS_IOS) chain->AddResult(HandleClearSiteDataHeader(request, chain->CreateCallback(), original_response_headers)); @@ -213,13 +213,13 @@ if (url_loader) { allowed = url_loader->AllowCookies(request.url(), request.site_for_cookies()); -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) } else { WebSocket* web_socket = WebSocket::ForRequest(request); if (web_socket) { allowed = web_socket->AllowCookies(request.url()); } -#endif // !defined(OS_IOS) +#endif // !BUILDFLAG(IS_IOS) } if (!allowed) ExcludeAllCookies(net::CookieInclusionStatus::EXCLUDE_USER_PREFERENCES, @@ -243,11 +243,11 @@ URLLoader* url_loader = URLLoader::ForRequest(request); if (url_loader) return url_loader->AllowCookies(request.url(), request.site_for_cookies()); -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) WebSocket* web_socket = WebSocket::ForRequest(request); if (web_socket) return web_socket->AllowCookies(request.url()); -#endif // !defined(OS_IOS) +#endif // !BUILDFLAG(IS_IOS) return true; }
diff --git a/services/network/network_service_unittest.cc b/services/network/network_service_unittest.cc index 1a29e98..20b3a1e 100644 --- a/services/network/network_service_unittest.cc +++ b/services/network/network_service_unittest.cc
@@ -155,7 +155,7 @@ } // Platforms where Negotiate can be used. -#if BUILDFLAG(USE_KERBEROS) && !defined(OS_ANDROID) +#if BUILDFLAG(USE_KERBEROS) && !BUILDFLAG(IS_ANDROID) // Returns the negotiate factory, if one exists, to query its configuration. net::HttpAuthHandlerNegotiate::Factory* GetNegotiateFactory( NetworkContext* network_context) { @@ -184,25 +184,25 @@ EXPECT_TRUE(auth_handler_factory->GetSchemeFactory(net::kDigestAuthScheme)); EXPECT_TRUE(auth_handler_factory->GetSchemeFactory(net::kNtlmAuthScheme)); -#if BUILDFLAG(USE_KERBEROS) && !defined(OS_ANDROID) +#if BUILDFLAG(USE_KERBEROS) && !BUILDFLAG(IS_ANDROID) ASSERT_TRUE(GetNegotiateFactory(&network_context)); -#if defined(OS_POSIX) && !BUILDFLAG(IS_CHROMEOS_ASH) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_CHROMEOS_ASH) EXPECT_EQ("", GetNegotiateFactory(&network_context)->GetLibraryNameForTesting()); #endif -#endif // BUILDFLAG(USE_KERBEROS) && !defined(OS_ANDROID) +#endif // BUILDFLAG(USE_KERBEROS) && !BUILDFLAG(IS_ANDROID) EXPECT_FALSE(auth_handler_factory->http_auth_preferences() ->NegotiateDisableCnameLookup()); EXPECT_FALSE( auth_handler_factory->http_auth_preferences()->NegotiateEnablePort()); -#if defined(OS_POSIX) || defined(OS_FUCHSIA) +#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) EXPECT_TRUE(auth_handler_factory->http_auth_preferences()->NtlmV2Enabled()); -#endif // defined(OS_POSIX) || defined(OS_FUCHSIA) -#if defined(OS_ANDROID) +#endif // BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) +#if BUILDFLAG(IS_ANDROID) EXPECT_EQ("", auth_handler_factory->http_auth_preferences() ->AuthAndroidNegotiateAccountType()); -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) } TEST_F(NetworkServiceTest, AuthSchemesDigestAndNtlmOnly) { @@ -462,7 +462,7 @@ } // DnsClient isn't supported on iOS. -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) TEST_F(NetworkServiceTest, DnsClientEnableDisable) { // Create valid DnsConfig. @@ -785,10 +785,10 @@ EXPECT_FALSE(dns_client_ptr->factory()->doh_probes_running()); } -#endif // !defined(OS_IOS) +#endif // !BUILDFLAG(IS_IOS) // |ntlm_v2_enabled| is only supported on POSIX platforms. -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) TEST_F(NetworkServiceTest, AuthNtlmV2Enabled) { // Set |ntlm_v2_enabled| to false before creating any NetworkContexts. mojom::HttpAuthDynamicParamsPtr auth_params = @@ -821,10 +821,10 @@ service()->ConfigureHttpAuthPrefs(std::move(auth_params)); EXPECT_FALSE(auth_handler_factory->http_auth_preferences()->NtlmV2Enabled()); } -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) // |android_negotiate_account_type| is only supported on Android. -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) TEST_F(NetworkServiceTest, AuthAndroidNegotiateAccountType) { const char kInitialAccountType[] = "Scorpio"; const char kFinalAccountType[] = "Pisces"; @@ -855,7 +855,7 @@ EXPECT_EQ(kFinalAccountType, auth_handler_factory->http_auth_preferences() ->AuthAndroidNegotiateAccountType()); } -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) static int GetGlobalMaxConnectionsPerProxy() { return net::ClientSocketPoolManager::max_sockets_per_proxy_server( @@ -1240,7 +1240,7 @@ // mojom:NetworkChangeManager isn't supported on iOS. // See the same ifdef in CreateNetworkChangeNotifierIfNeeded. -#if defined(OS_IOS) +#if BUILDFLAG(IS_IOS) #define MAYBE_NetworkChangeManagerRequest DISABLED_NetworkChangeManagerRequest #else #define MAYBE_NetworkChangeManagerRequest NetworkChangeManagerRequest
diff --git a/services/network/p2p/socket_udp.cc b/services/network/p2p/socket_udp.cc index ebae0cde..78405f51 100644 --- a/services/network/p2p/socket_udp.cc +++ b/services/network/p2p/socket_udp.cc
@@ -73,7 +73,7 @@ net::NetLog* net_log) { net::UDPServerSocket* socket = new net::UDPServerSocket(net_log, net::NetLogSource()); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) socket->UseNonBlockingIO(); #endif
diff --git a/services/network/public/cpp/features.cc b/services/network/public/cpp/features.cc index f129162..6b6f94f 100644 --- a/services/network/public/cpp/features.cc +++ b/services/network/public/cpp/features.cc
@@ -22,7 +22,7 @@ base::FEATURE_ENABLED_BY_DEFAULT}; // Enables the network service. const base::Feature kNetworkService { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) "NetworkService", #else "NetworkServiceNotSupported", @@ -107,8 +107,8 @@ // Enable usage of hardcoded DoH upgrade mapping for use in automatic mode. const base::Feature kDnsOverHttpsUpgrade { "DnsOverHttpsUpgrade", -#if BUILDFLAG(IS_CHROMEOS_ASH) || defined(OS_MAC) || defined(OS_ANDROID) || \ - defined(OS_WIN) +#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_MAC) || \ + BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) base::FEATURE_ENABLED_BY_DEFAULT #else base::FEATURE_DISABLED_BY_DEFAULT
diff --git a/services/network/resource_scheduler/resource_scheduler.cc b/services/network/resource_scheduler/resource_scheduler.cc index c3d7e13c..3ecc992 100644 --- a/services/network/resource_scheduler/resource_scheduler.cc +++ b/services/network/resource_scheduler/resource_scheduler.cc
@@ -41,11 +41,11 @@ #include "third_party/abseil-cpp/absl/types/optional.h" #include "url/scheme_host_port.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "base/android/radio_utils.h" #include "base/power_monitor/power_monitor.h" #include "net/android/network_library.h" -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) namespace network { @@ -998,7 +998,7 @@ request->Start(start_mode); } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) void RecordMetricsForWeakSignalThrottlingDuration() const { if (weak_signal_throttling_start_timestamp_.has_value()) { base::TimeDelta time_since_throttling_start = @@ -1035,7 +1035,7 @@ return maybe_level.has_value() && *maybe_level <= base::android::RadioSignalLevel::kModerate; } -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) // While the radio signal is weak and the device is on battery power, we // only allow short periods when IDLE browser requests can be sent. @@ -1050,7 +1050,7 @@ return; } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) if (!base::android::RadioUtils::IsSupported()) return; @@ -1101,7 +1101,7 @@ // Not currently throttling, so start throttling. weak_signal_throttling_start_timestamp_ = tick_clock_->NowTicks(); -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) } // Returns true if |request| should be throttled to avoid unnecessary
diff --git a/services/network/tcp_bound_socket_unittest.cc b/services/network/tcp_bound_socket_unittest.cc index 418d7b9..6f66e1d1 100644 --- a/services/network/tcp_bound_socket_unittest.cc +++ b/services/network/tcp_bound_socket_unittest.cc
@@ -229,7 +229,7 @@ // // Don't run on Apple platforms because this pattern ends in a connect timeout // on OSX (after 25+ seconds) instead of connection refused. -#if !defined(OS_APPLE) +#if !BUILDFLAG(IS_APPLE) TEST_F(TCPBoundSocketTest, ConnectError) { mojo::Remote<mojom::TCPBoundSocket> bound_socket1; net::IPEndPoint bound_address1; @@ -251,7 +251,7 @@ &connected_socket, mojo::NullRemote(), &client_socket_receive_handle, &client_socket_send_handle)); } -#endif // !defined(OS_APPLE) +#endif // !BUILDFLAG(IS_APPLE) // Test listen failure. @@ -261,7 +261,7 @@ // // Apple platforms don't allow binding multiple TCP sockets to the same port // even with SO_REUSEADDR enabled. -#if !defined(OS_WIN) && !defined(OS_APPLE) +#if !BUILDFLAG(IS_WIN) && !BUILDFLAG(IS_APPLE) TEST_F(TCPBoundSocketTest, ListenError) { // Bind a socket. mojo::Remote<mojom::TCPBoundSocket> bound_socket1; @@ -288,7 +288,7 @@ EXPECT_TRUE(result == net::ERR_ADDRESS_IN_USE || result == net::ERR_INVALID_ARGUMENT); } -#endif // !defined(OS_WIN) && !defined(OS_APPLE) +#endif // !BUILDFLAG(IS_WIN) && !BUILDFLAG(IS_APPLE) // Test the case bind succeeds, and transfer some data. TEST_F(TCPBoundSocketTest, ReadWrite) {
diff --git a/services/network/tcp_socket_unittest.cc b/services/network/tcp_socket_unittest.cc index 962ca46..a713410d 100644 --- a/services/network/tcp_socket_unittest.cc +++ b/services/network/tcp_socket_unittest.cc
@@ -41,7 +41,7 @@ #include "services/network/tcp_server_socket.h" #include "testing/gtest/include/gtest/gtest.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "base/mac/mac_util.h" #endif @@ -580,7 +580,7 @@ int result = observer()->WaitForWriteError(); bool result_ok = result == net::ERR_CONNECTION_RESET || result == net::ERR_CONNECTION_ABORTED; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // On some macOS kernels, send() on a closing TCP socket can return // EPROTOTYPE, which is unknown to the net stack and gets mapped to // net::ERR_FAILED.
diff --git a/services/network/test/test_network_context_client.h b/services/network/test/test_network_context_client.h index 59441a3..7366307 100644 --- a/services/network/test/test_network_context_client.h +++ b/services/network/test/test_network_context_client.h
@@ -41,7 +41,7 @@ void OnCanSendDomainReliabilityUpload( const GURL& origin, OnCanSendDomainReliabilityUploadCallback callback) override {} -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) void OnGenerateHttpNegotiateAuthToken( const std::string& server_auth_token, bool can_delegate,
diff --git a/services/network/test/test_utils.cc b/services/network/test/test_utils.cc index 3a4aaad4..d2494b3 100644 --- a/services/network/test/test_utils.cc +++ b/services/network/test/test_utils.cc
@@ -13,7 +13,7 @@ #include "services/network/public/mojom/network_context.mojom.h" #include "services/network/public/mojom/url_response_head.mojom.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/dcheck_is_on.h" #endif @@ -51,7 +51,7 @@ mojom::NetworkContextParamsPtr CreateNetworkContextParamsForTesting() { mojom::NetworkContextParamsPtr params = mojom::NetworkContextParams::New(); -#if defined(OS_WIN) && DCHECK_IS_ON() +#if BUILDFLAG(IS_WIN) && DCHECK_IS_ON() // For unit tests, no need to verify that permissions on the files are // correct, as this testing is done in integration tests. params->win_permissions_set = true;
diff --git a/services/network/trust_tokens/operating_system_matching.cc b/services/network/trust_tokens/operating_system_matching.cc index e9d6b03..2389307 100644 --- a/services/network/trust_tokens/operating_system_matching.cc +++ b/services/network/trust_tokens/operating_system_matching.cc
@@ -9,7 +9,7 @@ namespace network { bool IsCurrentOperatingSystem(mojom::TrustTokenKeyCommitmentResult::Os os) { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) return os == mojom::TrustTokenKeyCommitmentResult::Os::kAndroid; #else return false;
diff --git a/services/network/trust_tokens/trust_token_request_issuance_helper_unittest.cc b/services/network/trust_tokens/trust_token_request_issuance_helper_unittest.cc index b348db6..2fd73783 100644 --- a/services/network/trust_tokens/trust_token_request_issuance_helper_unittest.cc +++ b/services/network/trust_tokens/trust_token_request_issuance_helper_unittest.cc
@@ -954,7 +954,7 @@ auto local_operation_delegate = std::make_unique<StrictMock<MockLocalOperationDelegate>>(); auto metrics_delegate = std::make_unique<StrictMock<MockMetricsDelegate>>(); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) EXPECT_CALL(*cryptographer, Initialize(_, _)).WillOnce(Return(true)); EXPECT_CALL(*cryptographer, AddKey(_)).WillOnce(Return(true)); EXPECT_CALL(*cryptographer, BeginIssuance(_)) @@ -972,7 +972,7 @@ EXPECT_CALL(*local_operation_delegate, FulfillIssuance(_, _)) .WillOnce(WithArgs<1>(Invoke(receive_answer))); EXPECT_CALL(*metrics_delegate, WillExecutePlatformProvidedOperation()); -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) TrustTokenRequestIssuanceHelper helper( *SuitableTrustTokenOrigin::Create(GURL("https://toplevel.com/")), @@ -987,19 +987,19 @@ // if we're not on Android, we should observe error saying we couldn't execute // issuance locally. ASSERT_EQ(ExecuteBeginOperationAndWaitForResult(&helper, request.get()), -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) mojom::TrustTokenOperationStatus::kUnknownError #else mojom::TrustTokenOperationStatus::kUnavailable -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) ); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) histograms.ExpectUniqueSample( "Net.TrustTokens.IssuanceHelperLocalFulfillResult", mojom::FulfillTrustTokenIssuanceAnswer::Status::kUnknownError, /*expected_count=*/1); -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) } } // namespace network
diff --git a/services/network/udp_socket_unittest.cc b/services/network/udp_socket_unittest.cc index a1cd83a..c9b28d53 100644 --- a/services/network/udp_socket_unittest.cc +++ b/services/network/udp_socket_unittest.cc
@@ -283,7 +283,7 @@ } // TODO(crbug.com/1014916): These two tests are very flaky on Fuchsia. -#if defined(OS_FUCHSIA) +#if BUILDFLAG(IS_FUCHSIA) #define MAYBE_TestReadSendTo DISABLED_TestReadSendTo #define MAYBE_TestUnexpectedSequences DISABLED_TestUnexpectedSequences #else @@ -669,8 +669,8 @@ EXPECT_EQ(std::vector<uint8_t>(), result.data.value()); } -#if defined(OS_ANDROID) || defined(OS_IOS) || defined(OS_MAC) || \ - defined(OS_FUCHSIA) +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS) || BUILDFLAG(IS_MAC) || \ + BUILDFLAG(IS_FUCHSIA) // Some Android devices do not support multicast socket. // The ones supporting multicast need WifiManager.MulticastLock to enable it. // https://developer.android.com/reference/android/net/wifi/WifiManager.MulticastLock.html @@ -680,7 +680,7 @@ #define MAYBE_JoinMulticastGroup DISABLED_JoinMulticastGroup #else #define MAYBE_JoinMulticastGroup JoinMulticastGroup -#endif // defined(OS_ANDROID) || defined(OS_IOS) || defined(OS_MAC) +#endif // BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS) || BUILDFLAG(IS_MAC) TEST_F(UDPSocketTest, MAYBE_JoinMulticastGroup) { const char kGroup[] = "237.132.100.17";
diff --git a/services/network/url_loader.cc b/services/network/url_loader.cc index 8112ae2..efe549c 100644 --- a/services/network/url_loader.cc +++ b/services/network/url_loader.cc
@@ -94,7 +94,7 @@ #include "third_party/abseil-cpp/absl/types/optional.h" #include "url/origin.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "net/base/features.h" #include "services/network/radio_monitor_android.h" #endif @@ -713,7 +713,7 @@ request.net_log_reference_info.value()); } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) if (base::FeatureList::IsEnabled(net::features::kRecordRadioWakeupTrigger)) { MaybeRecordURLLoaderCreationForWakeupTrigger(request, traffic_annotation); }
diff --git a/services/network/url_loader_unittest.cc b/services/network/url_loader_unittest.cc index 2a7a0214..c39c929a 100644 --- a/services/network/url_loader_unittest.cc +++ b/services/network/url_loader_unittest.cc
@@ -111,7 +111,7 @@ #include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "base/android/radio_utils.h" #include "net/android/radio_activity_tracker.h" #include "services/network/radio_monitor_android.h" @@ -857,9 +857,9 @@ base::File OpenFileForUpload(const base::FilePath& file_path) { int open_flags = base::File::FLAG_OPEN | base::File::FLAG_READ; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) open_flags |= base::File::FLAG_ASYNC; -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) base::File file(file_path, open_flags); EXPECT_TRUE(file.IsValid()); return file; @@ -4387,7 +4387,7 @@ int sign_count_ = 0; }; -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) TEST_F(URLLoaderTest, ClientAuthRespondTwice) { // This tests that one URLLoader can handle two client cert requests. @@ -5068,7 +5068,7 @@ EXPECT_EQ(0, client_cert_observer.on_certificate_requested_counter()); EXPECT_EQ(net::OK, client()->completion_status().error_code); } -#endif // !defined(OS_IOS) +#endif // !BUILDFLAG(IS_IOS) TEST_F(URLLoaderTest, CookieReporting) { { @@ -7345,7 +7345,7 @@ EXPECT_FALSE(accept_ch_frame_observer.called()); } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) namespace { @@ -7421,6 +7421,6 @@ CheckRadioWakeupTriggerHistograms(histograms, /*expected_count=*/0); } -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) } // namespace network
diff --git a/services/network/url_request_context_builder_mojo.cc b/services/network/url_request_context_builder_mojo.cc index afdb870..0065adc 100644 --- a/services/network/url_request_context_builder_mojo.cc +++ b/services/network/url_request_context_builder_mojo.cc
@@ -13,7 +13,7 @@ #include "services/network/network_context.h" #include "services/network/proxy_service_mojo.h" #include "services/network/public/cpp/features.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "net/proxy_resolution/win/dhcp_pac_file_fetcher_win.h" #elif BUILDFLAG(IS_CHROMEOS_ASH) #include "services/network/dhcp_pac_file_fetcher_mojo.h" @@ -42,7 +42,7 @@ std::unique_ptr<net::DhcpPacFileFetcher> URLRequestContextBuilderMojo::CreateDhcpPacFileFetcher( net::URLRequestContext* context) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return std::make_unique<net::DhcpPacFileFetcherWin>(context); #elif BUILDFLAG(IS_CHROMEOS_ASH) return std::make_unique<DhcpPacFileFetcherMojo>(
diff --git a/services/network/websocket.cc b/services/network/websocket.cc index 4d863631..ef70ed56 100644 --- a/services/network/websocket.cc +++ b/services/network/websocket.cc
@@ -57,7 +57,7 @@ // The capacity of the data pipe to use for received messages, in bytes. Optimal // value depends on the platform. -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) constexpr uint32_t kReceiveDataPipeCapacity = 1 << 16; #else // |2^n - delta| is better than 2^n on Linux. See crrev.com/c/1792208.
diff --git a/services/preferences/tracked/device_id_unittest.cc b/services/preferences/tracked/device_id_unittest.cc index 11c16b4..3f176eb 100644 --- a/services/preferences/tracked/device_id_unittest.cc +++ b/services/preferences/tracked/device_id_unittest.cc
@@ -12,7 +12,7 @@ std::string second_machine_id; const MachineIdStatus kExpectedStatus = -#if defined(OS_WIN) || defined(OS_MAC) +#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) MachineIdStatus::SUCCESS; #else MachineIdStatus::NOT_IMPLEMENTED;
diff --git a/services/preferences/tracked/tracked_persistent_pref_store_factory.cc b/services/preferences/tracked/tracked_persistent_pref_store_factory.cc index b27c167..86bc888 100644 --- a/services/preferences/tracked/tracked_persistent_pref_store_factory.cc +++ b/services/preferences/tracked/tracked_persistent_pref_store_factory.cc
@@ -22,7 +22,7 @@ #include "services/preferences/tracked/temp_scoped_dir_cleaner.h" #include "services/preferences/tracked/tracked_preferences_migration.h" -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/files/scoped_temp_dir.h" #include "base/strings/string_util.h" #include "services/preferences/tracked/registry_hash_store_contents_win.h" @@ -49,7 +49,7 @@ GetExternalVerificationPrefHashStorePair( const prefs::mojom::TrackedPersistentPrefStoreConfiguration& config, scoped_refptr<TempScopedDirCleaner> temp_dir_cleaner) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) return std::make_pair( std::make_unique<PrefHashStoreImpl>(config.registry_seed, config.legacy_device_id, @@ -87,7 +87,7 @@ config->tracking_configuration.clear(); scoped_refptr<TempScopedDirCleaner> temp_scoped_dir_cleaner; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // For tests that create a profile in a ScopedTempDir, share a ref_counted // object between the unprotected and protected hash filter's // RegistryHashStoreContentsWin which will clear the registry keys when
diff --git a/services/resource_coordinator/memory_instrumentation/coordinator_impl.cc b/services/resource_coordinator/memory_instrumentation/coordinator_impl.cc index 6869d2b..d604c15 100644 --- a/services/resource_coordinator/memory_instrumentation/coordinator_impl.cc +++ b/services/resource_coordinator/memory_instrumentation/coordinator_impl.cc
@@ -30,7 +30,7 @@ #include "services/resource_coordinator/public/mojom/memory_instrumentation/constants.mojom.h" #include "services/resource_coordinator/public/mojom/memory_instrumentation/memory_instrumentation.mojom.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "base/mac/mac_util.h" #endif
diff --git a/services/resource_coordinator/memory_instrumentation/coordinator_impl_unittest.cc b/services/resource_coordinator/memory_instrumentation/coordinator_impl_unittest.cc index 1731a2cf..e7bccb67 100644 --- a/services/resource_coordinator/memory_instrumentation/coordinator_impl_unittest.cc +++ b/services/resource_coordinator/memory_instrumentation/coordinator_impl_unittest.cc
@@ -453,7 +453,7 @@ // This ifdef is here to match the sandboxing behavior of the client. // On Linux, all memory dumps come from the browser client. On all other // platforms, they are expected to come from each individual client. -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) EXPECT_CALL(browser_client, RequestOSMemoryDumpMock( _, AllOf(Contains(kBrowserPid), Contains(kRendererPid)), _)) @@ -483,7 +483,7 @@ results[0] = FillRawOSDump(kRendererPid); std::move(callback).Run(true, std::move(results)); })); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Make the browser respond correctly but pretend the renderer is "stuck" // by storing a callback. @@ -630,7 +630,7 @@ MemoryAllocatorDump::kUnitsBytes, 1024 * 2); std::move(callback).Run(true, args.dump_guid, std::move(pmd)); })); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) EXPECT_CALL(browser_client, RequestOSMemoryDumpMock(_, AllOf(Contains(1), Contains(2)), _)) .WillOnce(Invoke( @@ -671,7 +671,7 @@ results[0]->resident_set_kb = 2; std::move(callback).Run(true, std::move(results)); })); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) MockGlobalMemoryDumpCallback callback; EXPECT_CALL(callback, OnCall(true, NotNull())) @@ -715,7 +715,7 @@ // This ifdef is here to match the sandboxing behavior of the client. // On Linux, all memory dumps come from the browser client. On all other // platforms, they are expected to come from each individual client. -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) EXPECT_CALL(browser_client, RequestOSMemoryDumpMock( _, AllOf(Contains(kBrowserPid), Contains(kRendererPid)), _)) @@ -745,7 +745,7 @@ results[0] = FillRawOSDump(kRendererPid); std::move(callback).Run(true, std::move(results)); })); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) MockGetVmRegionsForHeapProfilerCallback callback; EXPECT_CALL(callback, OnCall(_)) @@ -832,7 +832,7 @@ } // crbug.com: 1238428: flaky on Linux. -#if defined(OS_LINUX) +#if BUILDFLAG(IS_LINUX) #define MAYBE_DumpsAreAddedToTraceWhenRequested \ DISABLED_DumpsAreAddedToTraceWhenRequested #else @@ -892,7 +892,7 @@ // This ifdef is here to match the sandboxing behavior of the client. // On Linux, all memory dumps come from the browser client. On all other // platforms, they are expected to come from each individual client. -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) EXPECT_CALL(client_process_1, RequestOSMemoryDumpMock(_, _, _)) .WillOnce(Invoke( [](mojom::MemoryMapOption, const std::vector<base::ProcessId>& pids, @@ -940,7 +940,7 @@ results[0] = FillRawOSDump(kGpuPid); std::move(callback).Run(true, std::move(results)); })); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) base::RunLoop run_loop; @@ -1020,7 +1020,7 @@ std::move(callback).Run(true, args.dump_guid, std::move(pmd)); })); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) EXPECT_CALL(browser_client, RequestOSMemoryDumpMock(_, Contains(1), _)) .WillOnce(Invoke( [](mojom::MemoryMapOption, const std::vector<base::ProcessId>& pids, @@ -1044,7 +1044,7 @@ results[0]->resident_set_kb = 1; std::move(callback).Run(true, std::move(results)); })); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) base::test::TestFuture<bool, memory_instrumentation::mojom::GlobalMemoryDumpPtr>
diff --git a/services/resource_coordinator/memory_instrumentation/queued_request_dispatcher.cc b/services/resource_coordinator/memory_instrumentation/queued_request_dispatcher.cc index 9b28a5e..5d253396 100644 --- a/services/resource_coordinator/memory_instrumentation/queued_request_dispatcher.cc +++ b/services/resource_coordinator/memory_instrumentation/queued_request_dispatcher.cc
@@ -27,7 +27,7 @@ #include "third_party/perfetto/protos/perfetto/trace/memory_graph.pbzero.h" #include "third_party/perfetto/protos/perfetto/trace/trace_packet.pbzero.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "base/mac/mac_util.h" #endif @@ -51,12 +51,12 @@ uint32_t CalculatePrivateFootprintKb(const mojom::RawOSMemDump& os_dump, uint32_t shared_resident_kb) { DCHECK(os_dump.platform_private_footprint); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || \ - defined(OS_FUCHSIA) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || \ + BUILDFLAG(IS_FUCHSIA) uint64_t rss_anon_bytes = os_dump.platform_private_footprint->rss_anon_bytes; uint64_t vm_swap_bytes = os_dump.platform_private_footprint->vm_swap_bytes; return (rss_anon_bytes + vm_swap_bytes) / 1024; -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) if (base::mac::IsAtLeastOS10_12()) { uint64_t phys_footprint_bytes = os_dump.platform_private_footprint->phys_footprint_bytes; @@ -73,7 +73,7 @@ 1024) - base::saturated_cast<int32_t>(shared_resident_kb)); } -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) return base::saturated_cast<int32_t>( os_dump.platform_private_footprint->private_bytes / 1024); #else @@ -91,7 +91,7 @@ os_dump->is_peak_rss_resettable = internal_os_dump.is_peak_rss_resettable; os_dump->private_footprint_kb = CalculatePrivateFootprintKb(internal_os_dump, shared_resident_kb); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) os_dump->private_footprint_swap_kb = internal_os_dump.platform_private_footprint->vm_swap_bytes / 1024; #endif @@ -270,12 +270,12 @@ // On most platforms each process can dump data about their own process // so ask each process to do so Linux is special see below. -#if !defined(OS_LINUX) && !defined(OS_CHROMEOS) +#if !BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS) request->pending_responses.insert({client_info.pid, ResponseType::kOSDump}); client->RequestOSMemoryDump(request->memory_map_option(), {base::kNullProcessId}, base::BindOnce(os_callback, client_info.pid)); -#endif // !defined(OS_LINUX) && !defined(OS_CHROMEOS) +#endif // !BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS) // If we are in the single pid case, then we've already found the only // process we're looking for. @@ -285,7 +285,7 @@ // In some cases, OS stats can only be dumped from a privileged process to // get around to sandboxing/selinux restrictions (see crbug.com/461788). -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) std::vector<base::ProcessId> pids; mojom::ClientProcess* browser_client = nullptr; base::ProcessId browser_client_pid = base::kNullProcessId; @@ -310,7 +310,7 @@ browser_client->RequestOSMemoryDump(request->memory_map_option(), pids, std::move(callback)); } -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // In this case, we have not found the pid we are looking for so increment // the failed dump count and exit. @@ -331,7 +331,7 @@ const OsCallback& os_callback) { // On Linux, OS stats can only be dumped from a privileged process to // get around to sandboxing/selinux restrictions (see crbug.com/461788). -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) mojom::ClientProcess* browser_client = nullptr; base::ProcessId browser_client_pid = 0; for (const auto& client_info : clients) { @@ -366,7 +366,7 @@ base::BindOnce(os_callback, client_info.pid)); } } -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) } // static @@ -382,7 +382,7 @@ // each client process provides 1 OS dump, % the case where the client is // disconnected mid dump. OSMemDumpMap& extra_os_dumps = response.second.os_dumps; -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) for (auto& kv : extra_os_dumps) { auto pid = kv.first == base::kNullProcessId ? original_pid : kv.first; DCHECK(results.find(pid) == results.end()); @@ -444,7 +444,7 @@ // crash). In the latter case (OS_LINUX) we expect the full map to come // from the browser process response. OSMemDumpMap& extra_os_dumps = response.second.os_dumps; -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) for (const auto& kv : extra_os_dumps) { auto pid = kv.first == base::kNullProcessId ? original_pid : kv.first; DCHECK_EQ(pid_to_os_dump[pid], nullptr); @@ -518,7 +518,7 @@ mojom::OSMemDumpPtr os_dump = nullptr; if (raw_os_dump) { uint64_t shared_resident_kb = 0; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // The resident, anonymous shared memory for each process is only // relevant on macOS. const auto process_graph_it =
diff --git a/services/resource_coordinator/public/cpp/memory_instrumentation/browser_metrics.cc b/services/resource_coordinator/public/cpp/memory_instrumentation/browser_metrics.cc index 0f29ccb..b0fa593 100644 --- a/services/resource_coordinator/public/cpp/memory_instrumentation/browser_metrics.cc +++ b/services/resource_coordinator/public/cpp/memory_instrumentation/browser_metrics.cc
@@ -53,7 +53,7 @@ } base::TimeDelta GetDelayForNextMemoryLog() { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) base::TimeDelta mean_time = base::Minutes(5); #else base::TimeDelta mean_time = base::Minutes(30);
diff --git a/services/resource_coordinator/public/cpp/memory_instrumentation/client_process_impl.cc b/services/resource_coordinator/public/cpp/memory_instrumentation/client_process_impl.cc index 0559f0a..e32845d 100644 --- a/services/resource_coordinator/public/cpp/memory_instrumentation/client_process_impl.cc +++ b/services/resource_coordinator/public/cpp/memory_instrumentation/client_process_impl.cc
@@ -150,7 +150,7 @@ args.pids = pids; args.callback = std::move(callback); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // If the most recent chrome memory dump hasn't finished, wait for that to // finish. if (most_recent_chrome_memory_dump_guid_.has_value()) {
diff --git a/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics.cc b/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics.cc index f8c11ab4..00f325c 100644 --- a/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics.cc +++ b/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics.cc
@@ -16,7 +16,7 @@ std::vector<mojom::VmRegionPtr> results; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // On macOS, fetching all memory maps is very slow. See // https://crbug.com/826913 and https://crbug.com/1035401. results = GetProcessModules(pid);
diff --git a/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics.h b/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics.h index 1fdd28f..62d73b2 100644 --- a/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics.h +++ b/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics.h
@@ -45,9 +45,10 @@ mojom::RawOSMemDump*); static std::vector<mojom::VmRegionPtr> GetProcessMemoryMaps(base::ProcessId); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) static void SetProcSmapsForTesting(FILE*); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || + // BUILDFLAG(IS_ANDROID) private: FRIEND_TEST_ALL_PREFIXES(OSMetricsTest, ParseProcSmaps); @@ -57,11 +58,11 @@ FRIEND_TEST_ALL_PREFIXES(heap_profiling::ProfilingJsonExporterTest, MemoryMaps); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) static std::vector<mojom::VmRegionPtr> GetProcessModules(base::ProcessId); #endif -#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) // Provides information on the dump state of resident pages. These values are // written to logs. New enum values can be added, but existing enums must // never be renumbered or deleted and reused. @@ -96,7 +97,8 @@ // TODO(chiniforooshan): move to /base/process/process_metrics_linux.cc after // making sure that peak RSS is useful. static size_t GetPeakResidentSetSize(base::ProcessId pid); -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || + // BUILDFLAG(IS_ANDROID) }; } // namespace memory_instrumentation
diff --git a/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics_linux.cc b/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics_linux.cc index 11b885e..0324357 100644 --- a/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics_linux.cc +++ b/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics_linux.cc
@@ -309,7 +309,7 @@ dump->peak_resident_set_kb = GetPeakResidentSetSize(pid); dump->is_peak_rss_resettable = ResetPeakRSSIfPossible(pid); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #if BUILDFLAG(SUPPORTS_CODE_ORDERING) if (!base::android::AreAnchorsSane()) { DLOG(WARNING) << "Incorrect code ordering"; @@ -333,7 +333,7 @@ dump->native_library_pages_bitmap = std::move(accessed_pages_bitmap); #endif // BUILDFLAG(SUPPORTS_CODE_ORDERING) -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) return true; }
diff --git a/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics_unittest.cc b/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics_unittest.cc index 06eb57db..a43b569c 100644 --- a/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics_unittest.cc +++ b/services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics_unittest.cc
@@ -12,24 +12,24 @@ #include "build/build_config.h" #include "testing/gtest/include/gtest/gtest.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include <libgen.h> #include <mach-o/dyld.h> #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <windows.h> #include "base/strings/sys_string_conversions.h" #endif -#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) #include <sys/mman.h> #endif namespace memory_instrumentation { -#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) namespace { const char kTestSmaps1[] = "00400000-004be000 r-xp 00000000 fc:01 1234 /file/1\n" @@ -128,7 +128,8 @@ } } // namespace -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || + // BUILDFLAG(IS_ANDROID) TEST(OSMetricsTest, GivesNonZeroResults) { base::ProcessId pid = base::kNullProcessId; @@ -136,17 +137,17 @@ dump.platform_private_footprint = mojom::PlatformPrivateFootprint::New(); EXPECT_TRUE(OSMetrics::FillOSMemoryDump(pid, &dump)); EXPECT_TRUE(dump.platform_private_footprint); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || \ - defined(OS_FUCHSIA) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) || \ + BUILDFLAG(IS_FUCHSIA) EXPECT_GT(dump.platform_private_footprint->rss_anon_bytes, 0u); -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) EXPECT_GT(dump.platform_private_footprint->private_bytes, 0u); -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) EXPECT_GT(dump.platform_private_footprint->internal_bytes, 0u); #endif } -#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) TEST(OSMetricsTest, ParseProcSmaps) { const uint32_t kProtR = mojom::VmRegion::kProtectionFlagsRead; const uint32_t kProtW = mojom::VmRegion::kProtectionFlagsWrite; @@ -253,9 +254,10 @@ EXPECT_EQ(pages == accessed_pages_set, true); } -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || + // BUILDFLAG(IS_ANDROID) -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) void DummyFunction() {} TEST(OSMetricsTest, TestWinModuleReading) { @@ -304,9 +306,9 @@ EXPECT_TRUE(found_executable); EXPECT_TRUE(found_region_with_dummy); } -#endif // defined(OS_WIN) +#endif // BUILDFLAG(IS_WIN) -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) namespace { void CheckMachORegions(const std::vector<mojom::VmRegionPtr>& maps) { @@ -347,6 +349,6 @@ maps = OSMetrics::GetProcessModules(base::kNullProcessId); CheckMachORegions(maps); } -#endif // defined(OS_MAC) +#endif // BUILDFLAG(IS_MAC) } // namespace memory_instrumentation
diff --git a/services/resource_coordinator/public/cpp/memory_instrumentation/tracing_observer_proto.cc b/services/resource_coordinator/public/cpp/memory_instrumentation/tracing_observer_proto.cc index 70690e7..1f13caf 100644 --- a/services/resource_coordinator/public/cpp/memory_instrumentation/tracing_observer_proto.cc +++ b/services/resource_coordinator/public/cpp/memory_instrumentation/tracing_observer_proto.cc
@@ -231,7 +231,7 @@ ApplyPathFiltering(region->mapped_file, is_argument_filtering_enabled)); // The following stats are only well defined on Linux-derived OSes. -#if !defined(OS_MAC) && !defined(OS_WIN) +#if !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_WIN) entry->set_proportional_resident_kb( region->byte_stats_proportional_resident / 1024); entry->set_private_dirty_kb(region->byte_stats_private_dirty_resident /
diff --git a/services/resource_coordinator/public/cpp/memory_instrumentation/tracing_observer_proto_unittest.cc b/services/resource_coordinator/public/cpp/memory_instrumentation/tracing_observer_proto_unittest.cc index f21f995..7fafec0 100644 --- a/services/resource_coordinator/public/cpp/memory_instrumentation/tracing_observer_proto_unittest.cc +++ b/services/resource_coordinator/public/cpp/memory_instrumentation/tracing_observer_proto_unittest.cc
@@ -123,7 +123,7 @@ return memory_instrumentation::mojom::OSMemDump( resident_set_kb, /*peak_resident_set_kb=*/resident_set_kb, /*is_peak_rss_resettable=*/true, private_footprint_kb, shared_footprint_kb -#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) , 0 #endif @@ -131,7 +131,7 @@ } // crbug.com/1242040: flaky on linux, chromeos -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #define MAYBE_AddChromeDumpToTraceIfEnabled_When_TraceLog_Disabled \ DISABLED_AddChromeDumpToTraceIfEnabled_When_TraceLog_Disabled #else
diff --git a/services/resource_coordinator/public/cpp/memory_instrumentation/tracing_observer_traced_value.cc b/services/resource_coordinator/public/cpp/memory_instrumentation/tracing_observer_traced_value.cc index 402bb50..fe62211 100644 --- a/services/resource_coordinator/public/cpp/memory_instrumentation/tracing_observer_traced_value.cc +++ b/services/resource_coordinator/public/cpp/memory_instrumentation/tracing_observer_traced_value.cc
@@ -138,7 +138,7 @@ is_argument_filtering_enabled)); // The following stats are only well defined on Linux-derived OSes. -#if !defined(OS_MAC) && !defined(OS_WIN) +#if !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_WIN) value->BeginDictionary("bs"); // byte stats value->SetString( "pss",
diff --git a/services/service_manager/public/cpp/service_executable/main.cc b/services/service_manager/public/cpp/service_executable/main.cc index db84083..b6f6e8b 100644 --- a/services/service_manager/public/cpp/service_executable/main.cc +++ b/services/service_manager/public/cpp/service_executable/main.cc
@@ -22,11 +22,11 @@ #include "services/service_manager/public/cpp/service_executable/service_main.h" #include "services/service_manager/public/mojom/service.mojom.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "base/mac/bundle_locations.h" #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include <windows.h> #endif @@ -49,7 +49,7 @@ } } if (apps_to_debug.empty() || base::Contains(apps_to_debug, app)) { -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) std::wstring appw = base::UTF8ToWide(app); std::wstring message = base::UTF8ToWide( base::StringPrintf("%s - %ld", app.c_str(), GetCurrentProcessId())); @@ -68,7 +68,7 @@ base::AtExitManager at_exit; base::CommandLine::Init(argc, argv); -#if !defined(OFFICIAL_BUILD) && defined(OS_WIN) +#if !defined(OFFICIAL_BUILD) && BUILDFLAG(IS_WIN) base::RouteStdioToConsole(false); #endif
diff --git a/services/service_manager/public/cpp/service_executable/service_executable_environment.cc b/services/service_manager/public/cpp/service_executable/service_executable_environment.cc index 172f9d8..9beb2d9 100644 --- a/services/service_manager/public/cpp/service_executable/service_executable_environment.cc +++ b/services/service_manager/public/cpp/service_executable/service_executable_environment.cc
@@ -19,7 +19,7 @@ #include "sandbox/policy/switches.h" #include "services/service_manager/public/cpp/service_executable/switches.h" -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #include "base/rand_util.h" #include "base/system/sys_info.h" #include "sandbox/policy/linux/sandbox_linux.h" @@ -32,7 +32,7 @@ : ipc_thread_("IPC Thread") { DCHECK(!base::CurrentThread::Get()); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); if (command_line.HasSwitch(sandbox::policy::switches::kServiceSandboxType)) {
diff --git a/services/service_manager/service_instance.cc b/services/service_manager/service_instance.cc index 5de3bb5..efb3838 100644 --- a/services/service_manager/service_instance.cc +++ b/services/service_manager/service_instance.cc
@@ -12,6 +12,7 @@ #include "base/logging.h" #include "base/strings/strcat.h" #include "base/strings/utf_string_conversions.h" +#include "build/build_config.h" #include "mojo/public/cpp/bindings/callback_helpers.h" #include "services/service_manager/public/cpp/constants.h" #include "services/service_manager/public/mojom/constants.mojom.h" @@ -19,10 +20,10 @@ #include "services/service_manager/service_process_host.h" #include "ui/base/l10n/l10n_util.h" -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) #include "sandbox/policy/mojom/sandbox.mojom.h" #include "services/service_manager/service_process_launcher.h" -#endif // !defined(OS_IOS) +#endif // !BUILDFLAG(IS_IOS) namespace service_manager { @@ -129,7 +130,7 @@ } void ServiceInstance::SetPID(base::ProcessId pid) { -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) // iOS does not support base::Process and simply passes 0 here, so elide // this check on that platform. if (pid == base::kNullProcessId) { @@ -154,7 +155,7 @@ service_manager_->NotifyServiceCreated(*this); } -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) bool ServiceInstance::StartWithProcessHost( std::unique_ptr<ServiceProcessHost> host, sandbox::mojom::Sandbox sandbox_type) { @@ -185,7 +186,7 @@ StartWithRemote(std::move(remote)); return true; } -#endif // !defined(OS_IOS) +#endif // !BUILDFLAG(IS_IOS) void ServiceInstance::BindProcessMetadataReceiver( mojo::PendingReceiver<mojom::ProcessMetadata> receiver) {
diff --git a/services/service_manager/service_instance.h b/services/service_manager/service_instance.h index e5d03b7..c1eba74 100644 --- a/services/service_manager/service_instance.h +++ b/services/service_manager/service_instance.h
@@ -71,11 +71,11 @@ // Starts this instance using an already-established Service pipe. void StartWithRemote(mojo::PendingRemote<mojom::Service> remote); -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) // Starts this instance from a path to a service executable on disk. bool StartWithProcessHost(std::unique_ptr<ServiceProcessHost> host, sandbox::mojom::Sandbox sandbox_type); -#endif // !defined(OS_IOS) +#endif // !BUILDFLAG(IS_IOS) // Binds an endpoint for this instance to receive metadata about its // corresponding service process, if any. @@ -177,7 +177,7 @@ // instances in the system. const bool can_contact_all_services_; -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) std::unique_ptr<ServiceProcessHost> process_host_; #endif
diff --git a/services/service_manager/service_manager.cc b/services/service_manager/service_manager.cc index 493a95a..19c43d650 100644 --- a/services/service_manager/service_manager.cc +++ b/services/service_manager/service_manager.cc
@@ -31,7 +31,7 @@ #include "services/service_manager/service_instance.h" #include "services/service_manager/service_process_host.h" -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) #include "services/service_manager/service_process_launcher.h" #endif @@ -41,14 +41,14 @@ const char kCapability_ServiceManager[] = "service_manager:service_manager"; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) const char kServiceExecutableExtension[] = ".service.exe"; -#elif !defined(OS_IOS) +#elif !BUILDFLAG(IS_IOS) const char kServiceExecutableExtension[] = ".service"; #endif base::ProcessId GetCurrentPid() { -#if defined(OS_IOS) +#if BUILDFLAG(IS_IOS) // iOS does not support base::Process. return 0; #else @@ -68,7 +68,7 @@ class DefaultServiceProcessHost : public ServiceProcessHost { public: explicit DefaultServiceProcessHost(const base::FilePath& executable_path) -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) : launcher_(nullptr, executable_path) #endif { @@ -85,18 +85,18 @@ sandbox::mojom::Sandbox sandbox_type, const std::u16string& display_name, LaunchCallback callback) override { -#if defined(OS_IOS) +#if BUILDFLAG(IS_IOS) return mojo::NullRemote(); #else // TODO(https://crbug.com/781334): Support sandboxing. CHECK_EQ(sandbox_type, sandbox::mojom::Sandbox::kNoSandbox); return launcher_.Start(identity, sandbox::mojom::Sandbox::kNoSandbox, std::move(callback)); -#endif // defined(OS_IOS) +#endif // BUILDFLAG(IS_IOS) } private: -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) ServiceProcessLauncher launcher_; #endif }; @@ -304,7 +304,7 @@ break; } -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) case Manifest::ExecutionMode::kOutOfProcessBuiltin: { auto process_host = delegate_->CreateProcessHostForBuiltinServiceInstance( target_instance->identity()); @@ -333,11 +333,11 @@ } break; } -#else // !defined(OS_IOS) +#else // !BUILDFLAG(IS_IOS) default: NOTREACHED(); return nullptr; -#endif // !defined(OS_IOS) +#endif // !BUILDFLAG(IS_IOS) } return target_instance;
diff --git a/services/service_manager/service_process_launcher.cc b/services/service_manager/service_process_launcher.cc index 5f32c48e..a9520e7 100644 --- a/services/service_manager/service_process_launcher.cc +++ b/services/service_manager/service_process_launcher.cc
@@ -39,11 +39,11 @@ #include "services/service_manager/public/mojom/service.mojom.h" #include "services/service_manager/switches.h" -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) #include "sandbox/linux/services/namespace_sandbox.h" #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "base/win/windows_version.h" #include <windows.h> @@ -187,7 +187,7 @@ mojo::OutgoingInvitation invitation) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); base::LaunchOptions options; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) options.handles_to_inherit = handle_passing_info; options.stdin_handle = INVALID_HANDLE_VALUE; options.stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE); @@ -212,29 +212,29 @@ options.stdout_handle != options.stderr_handle) { options.handles_to_inherit.push_back(options.stderr_handle); } -#elif defined(OS_FUCHSIA) +#elif BUILDFLAG(IS_FUCHSIA) // LaunchProcess will share stdin/out/err with the child process by default. if (!sandbox::policy::IsUnsandboxedSandboxType(sandbox_type)) NOTIMPLEMENTED(); options.handles_to_transfer = std::move(handle_passing_info); -#elif defined(OS_POSIX) +#elif BUILDFLAG(IS_POSIX) const base::FileHandleMappingVector fd_mapping{ {STDIN_FILENO, STDIN_FILENO}, {STDOUT_FILENO, STDOUT_FILENO}, {STDERR_FILENO, STDERR_FILENO}, }; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) options.fds_to_remap = fd_mapping; options.mach_ports_for_rendezvous = handle_passing_info; #else handle_passing_info.insert(handle_passing_info.end(), fd_mapping.begin(), fd_mapping.end()); options.fds_to_remap = handle_passing_info; -#endif // defined(OS_MAC) +#endif // BUILDFLAG(IS_MAC) #endif DVLOG(2) << "Launching child with command line: " << child_command_line->GetCommandLineString(); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) if (!sandbox::policy::IsUnsandboxedSandboxType(sandbox_type)) { child_process_ = sandbox::NamespaceSandbox::LaunchProcess(*child_command_line, options);
diff --git a/services/service_manager/tests/background_service_manager_unittest.cc b/services/service_manager/tests/background_service_manager_unittest.cc index c0fd87b..2146603 100644 --- a/services/service_manager/tests/background_service_manager_unittest.cc +++ b/services/service_manager/tests/background_service_manager_unittest.cc
@@ -77,7 +77,7 @@ // Uses BackgroundServiceManager to start the service manager in the background // and connects to background_service_manager_test_service, verifying we can // send a message to the service. -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // TODO(crbug.com/589784): This test is disabled, as it fails // on the Android GN bot. #define MAYBE_Basic DISABLED_Basic
diff --git a/services/service_manager/tests/connect/connect_unittest.cc b/services/service_manager/tests/connect/connect_unittest.cc index 0d58379..57fc873 100644 --- a/services/service_manager/tests/connect/connect_unittest.cc +++ b/services/service_manager/tests/connect/connect_unittest.cc
@@ -20,6 +20,7 @@ #include "base/test/task_environment.h" #include "base/test/test_suite.h" #include "base/token.h" +#include "build/build_config.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/receiver_set.h" #include "mojo/public/cpp/bindings/remote.h" @@ -707,7 +708,7 @@ base::Process process; mojom::ConnectResult result = service_manager::test::LaunchAndConnectToProcess( -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) base::StrCat({kTestExeName, ".exe"}), #else kTestExeName,
diff --git a/services/service_manager/tests/service_manager/service_manager_unittest.cc b/services/service_manager/tests/service_manager/service_manager_unittest.cc index 28d9e201..ade150b 100644 --- a/services/service_manager/tests/service_manager/service_manager_unittest.cc +++ b/services/service_manager/tests/service_manager/service_manager_unittest.cc
@@ -255,7 +255,7 @@ CHECK(base::PathService::Get(base::DIR_GEN_TEST_DATA_ROOT, &target_path)); target_path = target_path.AppendASCII(kTestTargetName); -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) target_path = target_path.AddExtensionASCII("exe"); #endif
diff --git a/services/service_manager/tests/service_process_launcher_unittest.cc b/services/service_manager/tests/service_process_launcher_unittest.cc index 3c18f4a..bf47a02 100644 --- a/services/service_manager/tests/service_process_launcher_unittest.cc +++ b/services/service_manager/tests/service_process_launcher_unittest.cc
@@ -24,7 +24,7 @@ const char kTestServiceName[] = "service_process_launcher_test_service"; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) const base::FilePath::CharType kServiceExtension[] = FILE_PATH_LITERAL(".service.exe"); #else @@ -68,12 +68,12 @@ size_t adjust_count_ = 0; }; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // TODO(qsr): Multiprocess service manager tests are not supported on android. #define MAYBE_StartJoin DISABLED_StartJoin #else #define MAYBE_StartJoin StartJoin -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) TEST(ServiceProcessLauncherTest, MAYBE_StartJoin) { base::test::TaskEnvironment task_environment; @@ -99,7 +99,7 @@ EXPECT_EQ(1u, service_process_launcher_delegate.get_and_clear_adjust_count()); } -#if !defined(OS_POSIX) || defined(OS_MAC) +#if !BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_MAC) // Verify that if ServiceProcessLauncher cannot launch a process running the // service from the specified path, then we are able to clean up without e.g. // double-freeing the platform-channel handle reserved for the peer. @@ -125,7 +125,7 @@ launcher.reset(); task_environment.RunUntilIdle(); } -#endif // !defined(OS_POSIX) || defined(OS_MAC) +#endif // !BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_MAC) } // namespace } // namespace service_manager
diff --git a/services/service_manager/tests/util.cc b/services/service_manager/tests/util.cc index 1eeea73..6b2e3c8 100644 --- a/services/service_manager/tests/util.cc +++ b/services/service_manager/tests/util.cc
@@ -82,13 +82,13 @@ loop.Run(); base::LaunchOptions options; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) options.handles_to_inherit = handle_passing_info; -#elif defined(OS_FUCHSIA) +#elif BUILDFLAG(IS_FUCHSIA) options.handles_to_transfer = handle_passing_info; -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) options.mach_ports_for_rendezvous = handle_passing_info; -#elif defined(OS_POSIX) +#elif BUILDFLAG(IS_POSIX) options.fds_to_remap = handle_passing_info; #endif *process = base::LaunchProcess(child_command_line, options);
diff --git a/services/shape_detection/shape_detection_service.cc b/services/shape_detection/shape_detection_service.cc index 408955b..06369fa5 100644 --- a/services/shape_detection/shape_detection_service.cc +++ b/services/shape_detection/shape_detection_service.cc
@@ -9,17 +9,18 @@ #include "base/bind.h" #include "build/branding_buildflags.h" +#include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "services/shape_detection/text_detection_impl.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "base/android/jni_android.h" #include "services/shape_detection/shape_detection_jni_headers/InterfaceRegistrar_jni.h" #endif -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "services/shape_detection/barcode_detection_provider_mac.h" -#elif defined(OS_ANDROID) +#elif BUILDFLAG(IS_ANDROID) // No C++ code, barcode detection comes from Java. #elif BUILDFLAG(GOOGLE_CHROME_BRANDING) && \ (BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)) @@ -28,11 +29,11 @@ #include "services/shape_detection/barcode_detection_provider_impl.h" #endif -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) #include "services/shape_detection/face_detection_provider_win.h" -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) #include "services/shape_detection/face_detection_provider_mac.h" -#elif defined(OS_ANDROID) +#elif BUILDFLAG(IS_ANDROID) // No C++ code, face detection comes from Java. #else #include "services/shape_detection/face_detection_provider_impl.h" @@ -49,11 +50,11 @@ void ShapeDetectionService::BindBarcodeDetectionProvider( mojo::PendingReceiver<mojom::BarcodeDetectionProvider> receiver) { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) Java_InterfaceRegistrar_bindBarcodeDetectionProvider( base::android::AttachCurrentThread(), receiver.PassPipe().release().value()); -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) BarcodeDetectionProviderMac::Create(std::move(receiver)); #elif BUILDFLAG(GOOGLE_CHROME_BRANDING) && \ (BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS)) @@ -65,13 +66,13 @@ void ShapeDetectionService::BindFaceDetectionProvider( mojo::PendingReceiver<mojom::FaceDetectionProvider> receiver) { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) Java_InterfaceRegistrar_bindFaceDetectionProvider( base::android::AttachCurrentThread(), receiver.PassPipe().release().value()); -#elif defined(OS_MAC) +#elif BUILDFLAG(IS_MAC) FaceDetectionProviderMac::Create(std::move(receiver)); -#elif defined(OS_WIN) +#elif BUILDFLAG(IS_WIN) FaceDetectionProviderWin::Create(std::move(receiver)); #else FaceDetectionProviderImpl::Create(std::move(receiver)); @@ -80,7 +81,7 @@ void ShapeDetectionService::BindTextDetection( mojo::PendingReceiver<mojom::TextDetection> receiver) { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) Java_InterfaceRegistrar_bindTextDetection( base::android::AttachCurrentThread(), receiver.PassPipe().release().value());
diff --git a/services/test/run_all_unittests.cc b/services/test/run_all_unittests.cc index b71e6fd..b43f9fe 100644 --- a/services/test/run_all_unittests.cc +++ b/services/test/run_all_unittests.cc
@@ -18,7 +18,7 @@ #include "ui/base/resource/resource_scale_factor.h" #include "ui/base/ui_base_paths.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "base/android/jni_android.h" #endif @@ -37,7 +37,7 @@ void Initialize() override { base::TestSuite::Initialize(); -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) ui::RegisterPathProvider(); base::FilePath ui_test_pak_path; @@ -45,7 +45,7 @@ ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); base::FilePath path; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) ASSERT_TRUE(base::PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &path)); #else ASSERT_TRUE(base::PathService::Get(base::DIR_ASSETS, &path)); @@ -54,14 +54,14 @@ path.Append(FILE_PATH_LITERAL("bluetooth_test_strings.pak")); ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( bluetooth_test_strings, ui::kScaleFactorNone); -#endif // !defined(OS_IOS) +#endif // !BUILDFLAG(IS_IOS) // base::TestSuite and ViewsInit both try to load icu. That's ok for tests. base::i18n::AllowMultipleInitializeCallsForTesting(); } void Shutdown() override { -#if !defined(OS_IOS) +#if !BUILDFLAG(IS_IOS) ui::ResourceBundle::CleanupSharedInstance(); #endif
diff --git a/services/tracing/perfetto/consumer_host.cc b/services/tracing/perfetto/consumer_host.cc index d20cb71..d663ff72 100644 --- a/services/tracing/perfetto/consumer_host.cc +++ b/services/tracing/perfetto/consumer_host.cc
@@ -662,7 +662,7 @@ } } -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // TODO(crbug.com/1158482): Support writing to a file directly on Windows. DCHECK(!output_file.IsValid()) << "Tracing directly to a file isn't supported yet on Windows";
diff --git a/services/tracing/perfetto/system_perfetto_unittest.cc b/services/tracing/perfetto/system_perfetto_unittest.cc index b55b2e4..1bfd73b70 100644 --- a/services/tracing/perfetto/system_perfetto_unittest.cc +++ b/services/tracing/perfetto/system_perfetto_unittest.cc
@@ -38,9 +38,9 @@ #include "third_party/perfetto/protos/perfetto/config/trace_config.pb.h" #include "third_party/perfetto/protos/perfetto/trace/trace.pb.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "base/android/build_info.h" // nogncheck -#endif // defined(OS_ANDROID) +#endif namespace tracing { @@ -242,7 +242,7 @@ const char* old_tmp_dir_ = nullptr; }; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Flaky on Android: crbug.com/1262132#c17 #define MAYBE_SystemTraceEndToEnd DISABLED_SystemTraceEndToEnd #else @@ -288,7 +288,7 @@ PerfettoProducer::DeleteSoonForTesting(std::move(system_producer)); } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Flaky on Android: crbug.com/1262132#c17 #define MAYBE_OneSystemSourceWithMultipleLocalSources \ DISABLED_OneSystemSourceWithMultipleLocalSources @@ -393,7 +393,7 @@ PerfettoProducer::DeleteSoonForTesting(std::move(system_producer)); } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Flaky on Android: crbug.com/1262132#c17 #define MAYBE_MultipleSystemSourceWithOneLocalSourcesLocalFirst \ DISABLED_MultipleSystemSourceWithOneLocalSourcesLocalFirst @@ -518,7 +518,7 @@ PerfettoProducer::DeleteSoonForTesting(std::move(system_producer)); } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Flaky on Android: crbug.com/1262132#c17 #define MAYBE_MultipleSystemAndLocalSources \ DISABLED_MultipleSystemAndLocalSources @@ -634,7 +634,7 @@ PerfettoProducer::DeleteSoonForTesting(std::move(system_producer)); } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Flaky on Android: crbug.com/1262132#c17 #define MAYBE_MultipleSystemAndLocalSourcesLocalFirst \ DISABLED_MultipleSystemAndLocalSourcesLocalFirst @@ -747,7 +747,7 @@ PerfettoProducer::DeleteSoonForTesting(std::move(system_producer)); } -#if defined(OS_CHROMEOS) || defined(OS_ANDROID) +#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) // Flaky on all CrOS platforms: crbug.com/1262132#c18 // Flaky on Android: crbug.com/1262132 #define MAYBE_SystemTraceWhileLocalStartupTracing \ @@ -859,7 +859,7 @@ PerfettoProducer::DeleteSoonForTesting(std::move(system_producer)); } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Failing on android-pie-arm64-dbg, see crbug.com/1262132. TEST_F(SystemPerfettoTest, DISABLED_SystemToLowAPILevel) { if (base::android::BuildInfo::GetInstance()->sdk_int() >= @@ -945,23 +945,23 @@ EXPECT_FALSE(ShouldSetupSystemTracing()); } } -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Flaky on Android: crbug.com/1262132#c17 #define MAYBE_RespectsFeatureList DISABLED_RespectsFeatureList #else #define MAYBE_RespectsFeatureList RespectsFeatureList #endif TEST_F(SystemPerfettoTest, MAYBE_RespectsFeatureList) { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) if (base::android::BuildInfo::GetInstance()->is_debug_android()) { // The feature list is ignored on debug android builds so we should have a // real system producer so just bail out of this test. EXPECT_TRUE(ShouldSetupSystemTracing()); return; } -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) { base::test::ScopedFeatureList feature_list; feature_list.InitAndEnableFeature(features::kEnablePerfettoSystemTracing); @@ -974,7 +974,7 @@ } } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Flaky on Android: crbug.com/1262132#c17 TEST_F(SystemPerfettoTest, DISABLED_RespectsFeaturePreAndroidPie) { if (base::android::BuildInfo::GetInstance()->sdk_int() >= @@ -1051,10 +1051,10 @@ EXPECT_EQ(0u, run_test(/* enable_feature = */ false)); EXPECT_EQ(1u, run_test(/* enable_feature = */ true)); } -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) TEST_F(SystemPerfettoTest, DISABLED_EnablePerfettoSystemTracingDefaultState) { -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) EXPECT_EQ(features::kEnablePerfettoSystemTracing.default_state, base::FEATURE_ENABLED_BY_DEFAULT); #else @@ -1074,18 +1074,18 @@ EXPECT_FALSE(PerfettoTracedProcess::Get()->system_producer()); PerfettoTracedProcess::Get()->SetupSystemTracing(); EXPECT_TRUE(PerfettoTracedProcess::Get()->system_producer()); -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) EXPECT_FALSE(PerfettoTracedProcess::Get() ->system_producer() ->IsDummySystemProducerForTesting()); -#else // defined(OS_POSIX) +#else // BUILDFLAG(IS_POSIX) EXPECT_TRUE(PerfettoTracedProcess::Get() ->system_producer() ->IsDummySystemProducerForTesting()); -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) } -#if defined(OS_POSIX) && !defined(OS_ANDROID) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) TEST_F(SystemPerfettoTest, SandboxedOpenProducerSocket) { const char* kProducerSockEnvName = "PERFETTO_PRODUCER_SOCK_NAME"; auto system_service = CreateMockSystemService(); @@ -1153,7 +1153,7 @@ EXPECT_EQ(1u, system_consumer.received_test_packets()); PerfettoProducer::DeleteSoonForTesting(std::move(system_producer)); } -#endif // defined(OS_POSIX) && !defined(OS_ANDROID) +#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) } // namespace } // namespace tracing
diff --git a/services/tracing/public/cpp/perfetto/perfetto_config.cc b/services/tracing/public/cpp/perfetto/perfetto_config.cc index b6826bf..6d7dfa75 100644 --- a/services/tracing/public/cpp/perfetto/perfetto_config.cc +++ b/services/tracing/public/cpp/perfetto/perfetto_config.cc
@@ -124,7 +124,7 @@ // TODO(crbug.com/1052397): Revisit once build flag switch of lacros-chrome is // complete. #if BUILDFLAG(IS_CHROMEOS_ASH) || \ - (BUILDFLAG(IS_CHROMECAST) && defined(OS_LINUX)) + (BUILDFLAG(IS_CHROMECAST) && BUILDFLAG(IS_LINUX)) if (source_names.empty() || source_names.count(tracing::mojom::kSystemTraceDataSourceName) == 1) { AddDataSourceConfig(
diff --git a/services/tracing/public/cpp/perfetto/perfetto_producer.h b/services/tracing/public/cpp/perfetto/perfetto_producer.h index 4497ad2..19cf9153 100644 --- a/services/tracing/public/cpp/perfetto/perfetto_producer.h +++ b/services/tracing/public/cpp/perfetto/perfetto_producer.h
@@ -114,7 +114,7 @@ // TODO(crbug.com/839071): Find a good compromise between performance and // data granularity (mainly relevant to running with small buffer sizes // when we use background tracing) on Android. -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) static constexpr size_t kSMBPageSizeBytes = 4 * 1024; #else static constexpr size_t kSMBPageSizeBytes = 32 * 1024;
diff --git a/services/tracing/public/cpp/perfetto/perfetto_traced_process.cc b/services/tracing/public/cpp/perfetto/perfetto_traced_process.cc index e72bcee..a4b8c2dc 100644 --- a/services/tracing/public/cpp/perfetto/perfetto_traced_process.cc +++ b/services/tracing/public/cpp/perfetto/perfetto_traced_process.cc
@@ -24,7 +24,7 @@ #include "services/tracing/public/mojom/tracing_service.mojom.h" #include "third_party/perfetto/include/perfetto/tracing/tracing.h" -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) // As per 'gn help check': /* If you have conditional includes, make sure the build conditions and the @@ -35,11 +35,11 @@ // non-android builds. #include "services/tracing/public/cpp/perfetto/posix_system_producer.h" // nogncheck #include "third_party/perfetto/include/perfetto/ext/tracing/ipc/default_socket.h" // nogncheck -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) namespace tracing { namespace { -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) // Set to use the dummy producer for Chrome OS browser_tests and // content_browsertests to keep the system producer from causing flakes. static bool g_system_producer_enabled = true; @@ -48,20 +48,20 @@ std::unique_ptr<SystemProducer> NewSystemProducer( base::tracing::PerfettoTaskRunner* runner, const char* socket_name) { -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) DCHECK(socket_name); if (g_system_producer_enabled) return std::make_unique<PosixSystemProducer>(socket_name, runner); -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) return std::make_unique<DummyProducer>(runner); } const char* MaybeSocket() { -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) return perfetto::GetProducerSocket(); #else return nullptr; -#endif // defined(OS_POSIX) +#endif // BUILDFLAG(IS_POSIX) } void OnPerfettoLogMessage(perfetto::base::LogMessageCallbackArgs args) { @@ -346,7 +346,7 @@ init_args.backends |= perfetto::kCustomBackend; // TODO(eseckler): Not yet supported on Android to avoid binary size regression // of the consumer IPC messages. We'll need a way to exclude them. -#if defined(OS_POSIX) && !defined(OS_ANDROID) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) // We currently only use the client library system backend for the consumer // side, which is only allowed in the browser process. Furthermore, on // non-Android platforms, sandboxed processes need to delegate the socket @@ -438,7 +438,7 @@ } void PerfettoTracedProcess::SetSystemProducerEnabledForTesting(bool enabled) { -#if defined(OS_POSIX) +#if BUILDFLAG(IS_POSIX) // If set to disabled, use the dummy implementation to prevent the real system // producer from interfering with browser tests. g_system_producer_enabled = enabled;
diff --git a/services/tracing/public/cpp/perfetto/perfetto_tracing_backend.cc b/services/tracing/public/cpp/perfetto/perfetto_tracing_backend.cc index 3328c0f..558b90f8 100644 --- a/services/tracing/public/cpp/perfetto/perfetto_tracing_backend.cc +++ b/services/tracing/public/cpp/perfetto/perfetto_tracing_backend.cc
@@ -35,7 +35,7 @@ // TODO(crbug.com/83907): Find a good compromise between performance and // data granularity (mainly relevant to running with small buffer sizes // when we use background tracing) on Android. -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) constexpr size_t kDefaultSMBPageSizeBytes = 4 * 1024; #else constexpr size_t kDefaultSMBPageSizeBytes = 32 * 1024; @@ -376,7 +376,7 @@ perfetto::base::ScopedFile file) override { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); trace_config_ = trace_config; -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // TODO(crbug.com/1158482): Add support on Windows. DCHECK(!file) << "Tracing directly to a file isn't supported on Windows yet";
diff --git a/services/tracing/public/cpp/perfetto/posix_system_producer.cc b/services/tracing/public/cpp/perfetto/posix_system_producer.cc index 52f3071..c0e5aab0 100644 --- a/services/tracing/public/cpp/perfetto/posix_system_producer.cc +++ b/services/tracing/public/cpp/perfetto/posix_system_producer.cc
@@ -24,11 +24,11 @@ #include "third_party/perfetto/include/perfetto/protozero/scattered_stream_writer.h" #include "third_party/perfetto/protos/perfetto/common/track_event_descriptor.pbzero.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "base/android/build_info.h" -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) #include "mojo/public/cpp/bindings/remote.h" #include "services/tracing/public/cpp/system_tracing_service.h" #endif @@ -390,10 +390,10 @@ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); state_ = State::kConnecting; const char* host_package_name = nullptr; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) host_package_name = base::android::BuildInfo::GetInstance()->host_package_name(); -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) // On android we want to include if this is webview inside of an app or // Android Chrome. To aid this we add the host_package_name to differentiate @@ -425,7 +425,7 @@ return; } -#if !defined(OS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) // If the child process hasn't received the Mojo remote, try again later. auto& remote = TracedProcessImpl::GetInstance()->system_tracing_service(); if (!remote.is_bound()) { @@ -467,17 +467,17 @@ // Open the socket remotely using Mojo. remote->OpenProducerSocket(std::move(callback)); -#endif // !defined(OS_ANDROID) +#endif // !BUILDFLAG(IS_ANDROID) } bool PosixSystemProducer::SkipIfOnAndroidAndPreAndroidPie() const { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) return disallow_pre_android_pie_ && base::android::BuildInfo::GetInstance()->sdk_int() < base::android::SDK_VERSION_P; #else return false; -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) } void PosixSystemProducer::InvokeStoredOnDisconnectCallbacks() { @@ -515,7 +515,7 @@ } bool PosixSystemProducer::SandboxForbidsSocketConnection() { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Android renderer can connect to the producer socket directly. return false; #else
diff --git a/services/tracing/public/cpp/perfetto/trace_event_data_source.cc b/services/tracing/public/cpp/perfetto/trace_event_data_source.cc index 1425a75..7d8fc33 100644 --- a/services/tracing/public/cpp/perfetto/trace_event_data_source.cc +++ b/services/tracing/public/cpp/perfetto/trace_event_data_source.cc
@@ -65,7 +65,7 @@ #include "third_party/perfetto/protos/perfetto/trace/track_event/process_descriptor.pbzero.h" #include "third_party/perfetto/protos/perfetto/trace/track_event/track_descriptor.pbzero.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "base/android/application_status_listener.h" #include "base/android/build_info.h" #include "base/trace_event/application_state_proto_android.h" @@ -87,7 +87,7 @@ TraceEventMetadataSource* g_trace_event_metadata_source_for_testing = nullptr; void EmitRecurringUpdates() { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) static const ChromeProcessDescriptor::ProcessType process_type = GetProcessType( base::trace_event::TraceLog::GetInstance()->process_name()); @@ -196,7 +196,7 @@ void TraceEventMetadataSource::WriteMetadataPacket( perfetto::protos::pbzero::ChromeMetadataPacket* metadata_proto, bool privacy_filtering_enabled) { -#if defined(OS_ANDROID) && defined(OFFICIAL_BUILD) +#if BUILDFLAG(IS_ANDROID) && defined(OFFICIAL_BUILD) // Version code is only set for official builds on Android. const char* version_code_str = base::android::BuildInfo::GetInstance()->package_version_code(); @@ -206,7 +206,7 @@ DCHECK(res); metadata_proto->set_chrome_version_code(version_code); } -#endif // defined(OS_ANDROID) && defined(OFFICIAL_BUILD) +#endif // BUILDFLAG(IS_ANDROID) && defined(OFFICIAL_BUILD) AutoLockWithDeferredTaskPosting lock(lock_); @@ -1444,17 +1444,17 @@ // the writer is only destroyed on the perfetto sequence in this case. perfetto::TraceWriter* writer; bool privacy_filtering_enabled; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) bool is_system_producer; -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) { AutoLockWithDeferredTaskPosting lock(lock_); writer = trace_writer_.get(); privacy_filtering_enabled = privacy_filtering_enabled_; -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) is_system_producer = producer_ == PerfettoTracedProcess::Get()->system_producer(); -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) } if (!writer) { @@ -1515,7 +1515,7 @@ chrome_process->set_crash_trace_id(*crash_trace_id); } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // Host app package name is only recorded if the corresponding TraceLog // setting is set to true and privacy filtering is disabled or this is a // system trace. @@ -1529,7 +1529,7 @@ base::android::BuildInfo::GetInstance()->host_package_name()); } } -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) // TODO(eseckler): Set other fields on |chrome_process|.
diff --git a/services/tracing/public/cpp/perfetto/trace_event_data_source_unittest.cc b/services/tracing/public/cpp/perfetto/trace_event_data_source_unittest.cc index c421ace0..0954b6d 100644 --- a/services/tracing/public/cpp/perfetto/trace_event_data_source_unittest.cc +++ b/services/tracing/public/cpp/perfetto/trace_event_data_source_unittest.cc
@@ -57,7 +57,7 @@ #include "third_party/perfetto/protos/perfetto/trace/track_event/thread_descriptor.pb.h" #include "third_party/perfetto/protos/perfetto/trace/track_event/track_descriptor.pb.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "base/android/build_info.h" #endif @@ -972,7 +972,7 @@ MetadataHasNamedValue(metadata1, "before_int", 42); } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) TEST_F(TraceEventDataSourceTest, PackageNameNotRecordedPrivacyFilteringDisabledTraceLogNotSet) { StartTraceEventDataSource(/* privacy_filtering_enabled = false */);
diff --git a/services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler.cc b/services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler.cc index 95af89f..cc58f4f5 100644 --- a/services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler.cc +++ b/services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler.cc
@@ -601,7 +601,7 @@ // static void TracingSamplerProfiler::MangleModuleIDIfNeeded(std::string* module_id) { -#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Linux ELF module IDs are 160bit integers, which we need to mangle // down to 128bit integers to match the id that Breakpad outputs. // Example on version '66.0.3359.170' x64: @@ -753,7 +753,7 @@ profile_builder_ = profile_builder.get(); // Create and start the stack sampling profiler. -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #if ANDROID_ARM64_UNWINDING_SUPPORTED const auto create_unwinders = []() { std::vector<std::unique_ptr<base::Unwinder>> unwinders; @@ -773,13 +773,13 @@ module_cache)); profiler_->Start(); #endif -#else // defined(OS_ANDROID) +#else // BUILDFLAG(IS_ANDROID) profiler_ = std::make_unique<base::StackSamplingProfiler>( sampled_thread_token_, params, std::move(profile_builder)); if (aux_unwinder_factory_) profiler_->AddAuxUnwinder(aux_unwinder_factory_.Run()); profiler_->Start(); -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) #if BUILDFLAG(ENABLE_LOADER_LOCK_SAMPLING) if (loader_lock_sampling_thread_)
diff --git a/services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler.h b/services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler.h index 7b6fbd762..224630e 100644 --- a/services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler.h +++ b/services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler.h
@@ -25,14 +25,14 @@ #include "services/tracing/public/cpp/perfetto/interning_index.h" #include "third_party/perfetto/include/perfetto/ext/tracing/core/trace_writer.h" -#if defined(OS_ANDROID) && defined(ARCH_CPU_ARM64) && \ +#if BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_ARM64) && \ BUILDFLAG(CAN_UNWIND_WITH_FRAME_POINTERS) #define ANDROID_ARM64_UNWINDING_SUPPORTED 1 #else #define ANDROID_ARM64_UNWINDING_SUPPORTED 0 #endif -#if defined(OS_ANDROID) && BUILDFLAG(CAN_UNWIND_WITH_CFI_TABLE) && \ +#if BUILDFLAG(IS_ANDROID) && BUILDFLAG(CAN_UNWIND_WITH_CFI_TABLE) && \ defined(OFFICIAL_BUILD) #define ANDROID_CFI_UNWINDING_SUPPORTED 1 #else @@ -129,7 +129,7 @@ // TODO(ssid): Consider using an interning scheme to reduce memory usage // and increase the sample size. -#if defined(OS_ANDROID) || defined(OS_IOS) +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS) // We usually sample at 50ms, and expect that tracing should have started in // 10s (5s for 2 threads). Approximately 100 frames and 200 samples would use // 300KiB. @@ -183,7 +183,7 @@ // Returns whether of not the sampler profiling is able to unwind the stack // on this platform. constexpr static bool IsStackUnwindingSupported() { -#if defined(OS_MAC) || defined(OS_WIN) && defined(_WIN64) || \ +#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) && defined(_WIN64) || \ ANDROID_ARM64_UNWINDING_SUPPORTED || ANDROID_CFI_UNWINDING_SUPPORTED return true; #else
diff --git a/services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler_unittest.cc b/services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler_unittest.cc index 56012df..6554b1f 100644 --- a/services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler_unittest.cc +++ b/services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler_unittest.cc
@@ -27,7 +27,7 @@ #include "services/tracing/public/cpp/stack_sampling/loader_lock_sampling_thread_win.h" #endif -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "base/mac/mac_util.h" #endif @@ -186,7 +186,7 @@ }; bool ShouldSkipTestForMacOS11() { -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) // The sampling profiler does not work on macOS 11 and is disabled. // See https://crbug.com/1101399 and https://crbug.com/1098119. // DCHECK here so that when the sampling profiler is re-enabled on macOS 11, @@ -469,7 +469,7 @@ base::TimeTicks()); } -#if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) TEST_F(TracingProfileBuilderTest, MangleELFModuleID) { TestModule module; // See explanation for the module_id mangling in
diff --git a/services/tracing/public/cpp/trace_event_agent.cc b/services/tracing/public/cpp/trace_event_agent.cc index bd7ed5c..edd35b2 100644 --- a/services/tracing/public/cpp/trace_event_agent.cc +++ b/services/tracing/public/cpp/trace_event_agent.cc
@@ -24,7 +24,7 @@ #include "services/tracing/public/cpp/trace_event_args_allowlist.h" #include "services/tracing/public/cpp/tracing_features.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "services/tracing/public/cpp/stack_sampling/reached_code_data_source_android.h" #endif @@ -53,7 +53,7 @@ PerfettoTracedProcess::Get()->AddDataSource( TraceEventDataSource::GetInstance()); TracingSamplerProfiler::RegisterDataSource(); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) PerfettoTracedProcess::Get()->AddDataSource(ReachedCodeDataSource::Get()); #endif }
diff --git a/services/tracing/public/cpp/traced_process.cc b/services/tracing/public/cpp/traced_process.cc index 44dc94e..ecf6ea7 100644 --- a/services/tracing/public/cpp/traced_process.cc +++ b/services/tracing/public/cpp/traced_process.cc
@@ -8,7 +8,7 @@ #include "build/build_config.h" -#if !defined(OS_NACL) && !defined(OS_IOS) +#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_IOS) #include "services/tracing/public/cpp/traced_process_impl.h" #endif @@ -16,7 +16,7 @@ // static void TracedProcess::ResetTracedProcessReceiver() { -#if !defined(OS_NACL) && !defined(OS_IOS) +#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_IOS) tracing::TracedProcessImpl::GetInstance()->ResetTracedProcessReceiver(); #endif } @@ -24,7 +24,7 @@ // static void TracedProcess::OnTracedProcessRequest( mojo::PendingReceiver<mojom::TracedProcess> receiver) { -#if !defined(OS_NACL) && !defined(OS_IOS) +#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_IOS) tracing::TracedProcessImpl::GetInstance()->OnTracedProcessRequest( std::move(receiver)); #endif @@ -33,8 +33,8 @@ // static void TracedProcess::EnableSystemTracingService( mojo::PendingRemote<mojom::SystemTracingService> remote) { -#if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_NACL) && \ - !defined(OS_IOS) +#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_NACL) && \ + !BUILDFLAG(IS_IOS) tracing::TracedProcessImpl::GetInstance()->EnableSystemTracingService( std::move(remote)); #endif
diff --git a/services/tracing/public/cpp/tracing_features.cc b/services/tracing/public/cpp/tracing_features.cc index 557982a..7099279 100644 --- a/services/tracing/public/cpp/tracing_features.cc +++ b/services/tracing/public/cpp/tracing_features.cc
@@ -14,7 +14,7 @@ #include "build/chromecast_buildflags.h" #include "components/tracing/common/tracing_switches.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "base/android/build_info.h" // nogncheck #endif @@ -23,7 +23,7 @@ // Runs the tracing service as an in-process browser service. const base::Feature kTracingServiceInProcess { "TracingServiceInProcess", -#if defined(OS_ANDROID) || BUILDFLAG(IS_CHROMECAST) +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_CHROMECAST) base::FEATURE_ENABLED_BY_DEFAULT #else base::FEATURE_DISABLED_BY_DEFAULT @@ -32,7 +32,7 @@ const base::Feature kEnablePerfettoSystemTracing{ "EnablePerfettoSystemTracing", -#if defined(OS_CHROMEOS) +#if BUILDFLAG(IS_CHROMEOS) base::FEATURE_ENABLED_BY_DEFAULT #else base::FEATURE_DISABLED_BY_DEFAULT @@ -55,11 +55,11 @@ namespace tracing { bool ShouldSetupSystemTracing() { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) if (base::android::BuildInfo::GetInstance()->is_debug_android()) { return true; } -#endif // defined(OS_ANDROID) +#endif // BUILDFLAG(IS_ANDROID) if (base::FeatureList::GetInstance()) { return base::FeatureList::IsEnabled(features::kEnablePerfettoSystemTracing); }
diff --git a/services/tracing/tracing_service.cc b/services/tracing/tracing_service.cc index fa0bc1fb..11bf87d 100644 --- a/services/tracing/tracing_service.cc +++ b/services/tracing/tracing_service.cc
@@ -7,6 +7,7 @@ #include <utility> #include "base/bind.h" +#include "build/build_config.h" #include "services/tracing/perfetto/consumer_host.h" #include "services/tracing/perfetto/perfetto_service.h" #include "services/tracing/public/mojom/traced_process.mojom.h" @@ -72,7 +73,7 @@ std::move(service_receiver))); } -#if !defined(OS_NACL) && !defined(OS_IOS) +#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_IOS) void TracingService::BindConsumerHost( mojo::PendingReceiver<mojom::ConsumerHost> receiver) { ConsumerHost::BindConsumerReceiver(perfetto_service_, std::move(receiver));
diff --git a/services/tracing/tracing_service.h b/services/tracing/tracing_service.h index 5af6514..bda3cde0 100644 --- a/services/tracing/tracing_service.h +++ b/services/tracing/tracing_service.h
@@ -27,7 +27,7 @@ // mojom::TracingService implementation: void Initialize(std::vector<mojom::ClientInfoPtr> clients) override; void AddClient(mojom::ClientInfoPtr client) override; -#if !defined(OS_NACL) && !defined(OS_IOS) +#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_IOS) void BindConsumerHost( mojo::PendingReceiver<mojom::ConsumerHost> receiver) override; #endif
diff --git a/services/tracing/tracing_service_unittest.cc b/services/tracing/tracing_service_unittest.cc index 6d0b374..4790098 100644 --- a/services/tracing/tracing_service_unittest.cc +++ b/services/tracing/tracing_service_unittest.cc
@@ -371,7 +371,7 @@ EXPECT_EQ(kNumPackets, ReadAndCountTestPackets(*session)); } -#if !defined(OS_WIN) +#if !BUILDFLAG(IS_WIN) // TODO(crbug.com/1158482): Support tracing to file on Windows. TEST_F(TracingServiceTest, TraceToFile) { // Set up API bindings.
diff --git a/services/video_capture/broadcasting_receiver.cc b/services/video_capture/broadcasting_receiver.cc index 18b211b..83aeae9d 100644 --- a/services/video_capture/broadcasting_receiver.cc +++ b/services/video_capture/broadcasting_receiver.cc
@@ -28,7 +28,7 @@ void CloneSharedBufferToRawFileDescriptorHandle( const mojo::ScopedSharedBufferHandle& source, media::mojom::VideoBufferHandlePtr* target) { -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // |source| is unwrapped to a |PlatformSharedMemoryRegion|, from whence a file // descriptor can be extracted which is then mojo-wrapped. base::subtle::PlatformSharedMemoryRegion platform_region = @@ -222,7 +222,7 @@ } break; case media::VideoCaptureBufferType::kGpuMemoryBuffer: -#if defined(OS_WIN) +#if BUILDFLAG(IS_WIN) // On windows with MediaFoundationD3D11VideoCapture if the // texture capture path fails, a ShMem buffer might be produced instead. DCHECK(buffer_handle_->is_shared_buffer_handle()); @@ -240,7 +240,7 @@ ConvertRawFileDescriptorToSharedBuffer() { DCHECK(buffer_handle_->is_shared_memory_via_raw_file_descriptor()); -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // The conversion unwraps the descriptor from its mojo handle to the raw file // descriptor (ie, an int). This is used to create a // PlatformSharedMemoryRegion which is then wrapped as a
diff --git a/services/video_capture/public/uma/video_capture_service_event.cc b/services/video_capture/public/uma/video_capture_service_event.cc index a5a8733..4cfe2c4 100644 --- a/services/video_capture/public/uma/video_capture_service_event.cc +++ b/services/video_capture/public/uma/video_capture_service_event.cc
@@ -6,6 +6,7 @@ #include "base/logging.h" #include "base/metrics/histogram_macros.h" +#include "build/build_config.h" namespace video_capture { namespace uma { @@ -57,7 +58,7 @@ DVLOG(4) << "Logged DurationUntilReconnectAfterCapture"; } -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) void LogMacbookRetryGetDeviceInfosEvent(MacbookRetryGetDeviceInfosEvent event) { UMA_HISTOGRAM_ENUMERATION( "Media.VideoCapture.MacBook.RetryGetDeviceInfosEvent", event,
diff --git a/services/video_capture/public/uma/video_capture_service_event.h b/services/video_capture/public/uma/video_capture_service_event.h index 9405dac..2947099 100644 --- a/services/video_capture/public/uma/video_capture_service_event.h +++ b/services/video_capture/public/uma/video_capture_service_event.h
@@ -29,7 +29,7 @@ NUM_VIDEO_CAPTURE_SERVICE_EVENT }; -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) enum MacbookRetryGetDeviceInfosEvent { PROVIDER_RECEIVED_ZERO_INFOS_STOPPING_SERVICE = 0, PROVIDER_SERVICE_STOPPED_ISSUING_RETRY = 1, @@ -61,7 +61,7 @@ void LogDurationUntilReconnectAfterEnumerationOnly(base::TimeDelta duration); void LogDurationUntilReconnectAfterCapture(base::TimeDelta duration); -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) void LogMacbookRetryGetDeviceInfosEvent(MacbookRetryGetDeviceInfosEvent event); #endif
diff --git a/services/video_capture/test/fake_device_unittest.cc b/services/video_capture/test/fake_device_unittest.cc index 8a11406c..46db0f96 100644 --- a/services/video_capture/test/fake_device_unittest.cc +++ b/services/video_capture/test/fake_device_unittest.cc
@@ -159,7 +159,7 @@ // This requires the linux platform, where shared regions are backed by a file // descriptor. -#if defined(OS_LINUX) || defined(OS_CHROMEOS) +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) TEST_F(FakeVideoCaptureDeviceTest, ReceiveFramesViaFileDescriptorHandlesForSharedMemory) { base::RunLoop wait_loop; @@ -229,6 +229,6 @@ wait_loop.Run(); EXPECT_FALSE(found_unexpected_all_zero_frame); } -#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) +#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) } // namespace video_capture
diff --git a/services/video_capture/video_capture_service_impl.cc b/services/video_capture/video_capture_service_impl.cc index 81af458..fb9bba9 100644 --- a/services/video_capture/video_capture_service_impl.cc +++ b/services/video_capture/video_capture_service_impl.cc
@@ -28,7 +28,7 @@ #include "services/video_capture/virtual_device_enabled_device_factory.h" #include "services/viz/public/cpp/gpu/gpu.h" -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) #include "media/capture/video/mac/video_capture_device_factory_mac.h" #endif @@ -150,7 +150,7 @@ } void VideoCaptureServiceImpl::SetRetryCount(int32_t count) { -#if defined(OS_MAC) +#if BUILDFLAG(IS_MAC) media::VideoCaptureDeviceFactoryMac::SetGetDevicesInfoRetryCount(count); #endif }
diff --git a/services/viz/privileged/mojom/compositing/renderer_settings_mojom_traits.cc b/services/viz/privileged/mojom/compositing/renderer_settings_mojom_traits.cc index be035b7..4a52423 100644 --- a/services/viz/privileged/mojom/compositing/renderer_settings_mojom_traits.cc +++ b/services/viz/privileged/mojom/compositing/renderer_settings_mojom_traits.cc
@@ -4,9 +4,10 @@ #include "services/viz/privileged/mojom/compositing/renderer_settings_mojom_traits.h" +#include "build/build_config.h" #include "services/viz/public/cpp/compositing/resource_settings_mojom_traits.h" -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) #include "ui/gfx/mojom/color_space_mojom_traits.h" #endif @@ -46,7 +47,7 @@ out->auto_resize_output_surface = data.auto_resize_output_surface(); out->requires_alpha_channel = data.requires_alpha_channel(); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) if (!data.ReadInitialScreenSize(&out->initial_screen_size)) return false;
diff --git a/services/viz/privileged/mojom/compositing/renderer_settings_mojom_traits.h b/services/viz/privileged/mojom/compositing/renderer_settings_mojom_traits.h index 42456c97..615288e 100644 --- a/services/viz/privileged/mojom/compositing/renderer_settings_mojom_traits.h +++ b/services/viz/privileged/mojom/compositing/renderer_settings_mojom_traits.h
@@ -101,7 +101,7 @@ return input.requires_alpha_channel; } -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) static gfx::Size initial_screen_size(const viz::RendererSettings& input) { return input.initial_screen_size; }
diff --git a/services/viz/public/cpp/compositing/transferable_resource_mojom_traits.cc b/services/viz/public/cpp/compositing/transferable_resource_mojom_traits.cc index 0235fef..40a15ae 100644 --- a/services/viz/public/cpp/compositing/transferable_resource_mojom_traits.cc +++ b/services/viz/public/cpp/compositing/transferable_resource_mojom_traits.cc
@@ -4,6 +4,7 @@ #include "services/viz/public/cpp/compositing/transferable_resource_mojom_traits.h" +#include "build/build_config.h" #include "gpu/ipc/common/mailbox_holder_mojom_traits.h" #include "gpu/ipc/common/mailbox_mojom_traits.h" #include "gpu/ipc/common/sync_token_mojom_traits.h" @@ -33,11 +34,11 @@ out->is_software = data.is_software(); out->is_overlay_candidate = data.is_overlay_candidate(); -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) out->is_backed_by_surface_texture = data.is_backed_by_surface_texture(); #endif -#if defined(OS_ANDROID) || defined(OS_WIN) +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) out->wants_promotion_hint = data.wants_promotion_hint(); #endif
diff --git a/services/viz/public/cpp/compositing/transferable_resource_mojom_traits.h b/services/viz/public/cpp/compositing/transferable_resource_mojom_traits.h index 057dedb..ff137ab 100644 --- a/services/viz/public/cpp/compositing/transferable_resource_mojom_traits.h +++ b/services/viz/public/cpp/compositing/transferable_resource_mojom_traits.h
@@ -57,7 +57,7 @@ static bool is_backed_by_surface_texture( const viz::TransferableResource& resource) { -#if defined(OS_ANDROID) +#if BUILDFLAG(IS_ANDROID) // TransferableResource has this in an #ifdef, but mojo doesn't let us. // TODO(https://crbug.com/671901) return resource.is_backed_by_surface_texture; @@ -67,7 +67,7 @@ } static bool wants_promotion_hint(const viz::TransferableResource& resource) { -#if defined(OS_ANDROID) || defined(OS_WIN) +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) // TransferableResource has this in an #ifdef, but mojo doesn't let us. // TODO(https://crbug.com/671901) return resource.wants_promotion_hint;
diff --git a/styleguide/c++/c++11.md b/styleguide/c++/c++11.md index 25aa358..3e2971f 100644 --- a/styleguide/c++/c++11.md +++ b/styleguide/c++/c++11.md
@@ -480,6 +480,7 @@ **Notes:** *** promo See [discussion thread](https://groups.google.com/a/chromium.org/g/cxx/c/op2ePZnjP0w). +*** ### maybe_unused attribute <sup>[allowed]</sup>
diff --git a/testing/buildbot/chromium.chromiumos.json b/testing/buildbot/chromium.chromiumos.json index 5d8eaa5..463c74e 100644 --- a/testing/buildbot/chromium.chromiumos.json +++ b/testing/buildbot/chromium.chromiumos.json
@@ -209,6 +209,7 @@ } ] }, + "quickrun_shards": 2, "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" }, "test": "cc_unittests", @@ -1173,6 +1174,7 @@ } ] }, + "quickrun_shards": 24, "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", "shards": 12 }, @@ -1220,6 +1222,7 @@ } ] }, + "quickrun_shards": 60, "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", "shards": 24 }, @@ -1272,6 +1275,7 @@ } ] }, + "quickrun_shards": 40, "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", "shards": 20 }, @@ -5027,6 +5031,7 @@ ], "gtest_tests": [ { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5044,6 +5049,7 @@ "test_id_prefix": "ninja://third_party/abseil-cpp:absl_hardening_tests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5061,6 +5067,7 @@ "test_id_prefix": "ninja://ui/accessibility:accessibility_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5078,6 +5085,7 @@ "test_id_prefix": "ninja://extensions/shell:app_shell_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5095,6 +5103,7 @@ "test_id_prefix": "ninja://ui/aura:aura_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5112,6 +5121,7 @@ "test_id_prefix": "ninja://base:base_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5129,6 +5139,7 @@ "test_id_prefix": "ninja://third_party/blink/common:blink_common_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5146,6 +5157,7 @@ "test_id_prefix": "ninja://third_party/blink/renderer/platform:blink_fuzzer_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5163,6 +5175,7 @@ "test_id_prefix": "ninja://third_party/blink/renderer/platform/heap:blink_heap_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5180,6 +5193,7 @@ "test_id_prefix": "ninja://third_party/blink/renderer/platform:blink_platform_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5198,6 +5212,7 @@ "test_id_prefix": "ninja://third_party/blink/renderer/controller:blink_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5215,6 +5230,7 @@ "test_id_prefix": "ninja://third_party/boringssl:boringssl_crypto_tests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5235,6 +5251,7 @@ "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.browser_tests.filter" ], + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5257,6 +5274,7 @@ "args": [ "--gtest_filter=-*UsingRealWebcam*" ], + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5274,6 +5292,7 @@ "test_id_prefix": "ninja://media/capture:capture_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5291,6 +5310,7 @@ "test_id_prefix": "ninja://media/cast:cast_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5308,6 +5328,7 @@ "test_id_prefix": "ninja://cc:cc_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5325,6 +5346,7 @@ "test_id_prefix": "ninja://chrome/test:chrome_app_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5342,6 +5364,7 @@ "test_id_prefix": "ninja://chrome/test/chromedriver:chromedriver_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5359,6 +5382,7 @@ "test_id_prefix": "ninja://chromeos:chromeos_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5376,6 +5400,7 @@ "test_id_prefix": "ninja://ui/color:color_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5396,6 +5421,7 @@ "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.components_unittests.filter" ], + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5413,6 +5439,7 @@ "test_id_prefix": "ninja://components:components_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5433,6 +5460,7 @@ "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.content_browsertests.filter" ], + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5451,6 +5479,7 @@ "test_id_prefix": "ninja://content/test:content_browsertests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5468,6 +5497,7 @@ "test_id_prefix": "ninja://content/test:content_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5485,6 +5515,7 @@ "test_id_prefix": "ninja://third_party/crashpad/crashpad:crashpad_tests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5502,6 +5533,7 @@ "test_id_prefix": "ninja://crypto:crypto_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5519,6 +5551,7 @@ "test_id_prefix": "ninja://dbus:dbus_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5536,6 +5569,7 @@ "test_id_prefix": "ninja://device:device_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5553,6 +5587,7 @@ "test_id_prefix": "ninja://ui/display:display_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5573,6 +5608,7 @@ "args": [ "--gtest_filter=-BluetoothShellApiTest.ApiSanityCheck:BluetoothSocketApiTest.Listen:BluetoothSocketApiTest.PermissionDenied" ], + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5593,6 +5629,7 @@ "args": [ "--gtest_filter=-NativeExtensionBindingsSystemUnittest*:BluetoothSocketApiUnittest.CreateThenClose:FeatureProviderTest.PermissionFeatureAvailability" ], + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5610,6 +5647,7 @@ "test_id_prefix": "ninja://extensions:extensions_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5627,6 +5665,7 @@ "test_id_prefix": "ninja://components/services/filesystem:filesystem_service_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5644,6 +5683,7 @@ "test_id_prefix": "ninja://google_apis/gcm:gcm_unit_tests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5661,6 +5701,7 @@ "test_id_prefix": "ninja://ui/gfx:gfx_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5678,6 +5719,7 @@ "test_id_prefix": "ninja://gin:gin_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5695,6 +5737,7 @@ "test_id_prefix": "ninja://google_apis:google_apis_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5712,6 +5755,7 @@ "test_id_prefix": "ninja://gpu:gpu_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5732,6 +5776,7 @@ "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter" ], + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5750,6 +5795,7 @@ "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5767,6 +5813,7 @@ "test_id_prefix": "ninja://ipc:ipc_tests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5787,6 +5834,7 @@ "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.filter" ], + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5809,6 +5857,7 @@ "--ash-chrome-path-override=../../lacros_version_skew_tests_v94.0.4606.104/test_ash_chrome", "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter" ], + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5838,6 +5887,7 @@ "--ash-chrome-path-override=../../lacros_version_skew_tests_v96.0.4664.13/test_ash_chrome", "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter" ], + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5867,6 +5917,7 @@ "--ash-chrome-path-override=../../lacros_version_skew_tests_v97.0.4669.0/test_ash_chrome", "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter" ], + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5896,6 +5947,7 @@ "--ash-chrome-path-override=../../lacros_version_skew_tests_v97.0.4683.0/test_ash_chrome", "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter" ], + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5924,6 +5976,7 @@ "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.filter" ], + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5946,6 +5999,7 @@ "--ash-chrome-path-override=../../lacros_version_skew_tests_v94.0.4606.104/test_ash_chrome", "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter" ], + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -5975,6 +6029,7 @@ "--ash-chrome-path-override=../../lacros_version_skew_tests_v96.0.4664.13/test_ash_chrome", "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter" ], + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6004,6 +6059,7 @@ "--ash-chrome-path-override=../../lacros_version_skew_tests_v97.0.4669.0/test_ash_chrome", "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter" ], + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6033,6 +6089,7 @@ "--ash-chrome-path-override=../../lacros_version_skew_tests_v97.0.4683.0/test_ash_chrome", "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter" ], + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6058,6 +6115,7 @@ "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6075,6 +6133,7 @@ "test_id_prefix": "ninja://chrome/test:lacros_chrome_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6092,6 +6151,7 @@ "test_id_prefix": "ninja://ui/latency:latency_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6109,6 +6169,7 @@ "test_id_prefix": "ninja://third_party/libjingle_xmpp:libjingle_xmpp_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6126,6 +6187,7 @@ "test_id_prefix": "ninja://third_party/liburlpattern:liburlpattern_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6143,6 +6205,7 @@ "test_id_prefix": "ninja://media:media_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6160,6 +6223,7 @@ "test_id_prefix": "ninja://ui/message_center:message_center_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6177,6 +6241,7 @@ "test_id_prefix": "ninja://media/midi:midi_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6194,6 +6259,7 @@ "test_id_prefix": "ninja://mojo/core:mojo_core_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6211,6 +6277,7 @@ "test_id_prefix": "ninja://mojo:mojo_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6228,6 +6295,7 @@ "test_id_prefix": "ninja://components/nacl/loader:nacl_loader_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6245,6 +6313,7 @@ "test_id_prefix": "ninja://ui/native_theme:native_theme_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6262,6 +6331,7 @@ "test_id_prefix": "ninja://net:net_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6279,6 +6349,7 @@ "test_id_prefix": "ninja://pdf:pdf_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6296,6 +6367,7 @@ "test_id_prefix": "ninja://third_party/perfetto:perfetto_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6313,6 +6385,7 @@ "test_id_prefix": "ninja://ppapi:ppapi_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6330,6 +6403,7 @@ "test_id_prefix": "ninja://printing:printing_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6347,6 +6421,7 @@ "test_id_prefix": "ninja://remoting:remoting_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6364,6 +6439,7 @@ "test_id_prefix": "ninja://sandbox/linux:sandbox_linux_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6381,6 +6457,7 @@ "test_id_prefix": "ninja://services/service_manager/tests:service_manager_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6398,6 +6475,7 @@ "test_id_prefix": "ninja://services:services_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6415,6 +6493,7 @@ "test_id_prefix": "ninja://ui/shell_dialogs:shell_dialogs_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6432,6 +6511,7 @@ "test_id_prefix": "ninja://skia:skia_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6449,6 +6529,7 @@ "test_id_prefix": "ninja://ui/snapshot:snapshot_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6466,6 +6547,7 @@ "test_id_prefix": "ninja://sql:sql_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6486,6 +6568,7 @@ "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.sync_integration_tests.filter" ], + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6503,6 +6586,7 @@ "test_id_prefix": "ninja://chrome/test:sync_integration_tests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6520,6 +6604,7 @@ "test_id_prefix": "ninja://ui/base:ui_base_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6540,6 +6625,7 @@ "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.unit_tests.filter" ], + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6557,6 +6643,7 @@ "test_id_prefix": "ninja://chrome/test:unit_tests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6577,6 +6664,7 @@ "args": [ "--gtest_filter=-DesktopWidgetFocusManagerTest.AnchoredDialogInDesktopNativeWidgetAura:DesktopWidgetTest*:DesktopWindowTreeHostPlatformTest*:EditableComboboxTest*:MenuRunnerTest*:TextfieldTest*:TooltipControllerTest*:TooltipStateManagerTest*" ], + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6594,6 +6682,7 @@ "test_id_prefix": "ninja://ui/views:views_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6611,6 +6700,7 @@ "test_id_prefix": "ninja://components/viz:viz_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6628,6 +6718,7 @@ "test_id_prefix": "ninja://ui/wm:wm_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -6645,6 +6736,7 @@ "test_id_prefix": "ninja://third_party/blink/renderer/platform/wtf:wtf_unittests/" }, { + "isolate_profile_data": true, "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py"
diff --git a/testing/buildbot/chromium.gpu.json b/testing/buildbot/chromium.gpu.json index 4fa22bd..45f5b33 100644 --- a/testing/buildbot/chromium.gpu.json +++ b/testing/buildbot/chromium.gpu.json
@@ -4606,6 +4606,7 @@ } ], "idempotent": false, + "quickrun_shards": 4, "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", "shards": 2 },
diff --git a/testing/buildbot/chromium.win.json b/testing/buildbot/chromium.win.json index aacaa6e3..592a2c6 100644 --- a/testing/buildbot/chromium.win.json +++ b/testing/buildbot/chromium.win.json
@@ -1834,7 +1834,7 @@ "os": "Windows-10-19042" } ], - "quickrun_shards": 30, + "quickrun_shards": 40, "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", "shards": 15 }, @@ -2101,6 +2101,7 @@ "os": "Windows-10-19042" } ], + "quickrun_shards": 18, "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", "shards": 6 }, @@ -2597,6 +2598,7 @@ "os": "Windows-10-19042" } ], + "quickrun_shards": 8, "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", "shards": 3 }, @@ -3189,6 +3191,7 @@ "os": "Windows-10-19042" } ], + "quickrun_shards": 3, "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" }, "test": "sync_integration_tests",
diff --git a/testing/buildbot/test_suite_exceptions.pyl b/testing/buildbot/test_suite_exceptions.pyl index 5298e3e..b16f9c4 100644 --- a/testing/buildbot/test_suite_exceptions.pyl +++ b/testing/buildbot/test_suite_exceptions.pyl
@@ -679,7 +679,7 @@ # This is for slow test execution that often becomes a critical path of # swarming jobs. crbug.com/868114 'shards': 15, - 'quickrun_shards': 30, + 'quickrun_shards': 40, } }, 'Win11 Tests x64': { @@ -822,6 +822,11 @@ '--test-launcher-filter-file=../../testing/buildbot/filters/android.emulator.cc_unittests.filter', ], }, + 'chromeos-amd64-generic-rel': { + 'swarming': { + 'quickrun_shards': 2, + }, + }, 'fuchsia-code-coverage': { 'swarming': { 'shards': 4, @@ -1241,6 +1246,9 @@ 'args': [ '--disable-features=WebRTC-H264WithOpenH264FFmpeg', ], + 'swarming': { + 'quickrun_shards': 18, + }, }, 'Win10 Tests x64 (dbg)': { 'experiment_percentage': 100, @@ -1883,6 +1891,11 @@ 'shards': 6, }, }, + 'Win10 Tests x64': { + 'swarming': { + 'quickrun_shards': 8 + }, + }, # temporary, https://crbug.com/818832 'Win10 Tests x64 (dbg)': { 'experiment_percentage': 100, @@ -2811,6 +2824,11 @@ 'shards': 6, }, }, + 'Win10 Tests x64': { + 'swarming': { + 'quickrun_shards': 3, + }, + }, 'Win10 Tests x64 (dbg)': { 'experiment_percentage': 100, # https://crbug.com/840369 }, @@ -2939,6 +2957,11 @@ }, 'experiment_percentage': 100, }, + 'chromeos-amd64-generic-rel': { + 'swarming': { + 'quickrun_shards': 24, + }, + }, 'chromeos-eve-chrome': { 'args': [ # TODO(crbug.com/1191132): Re-enable. @@ -2994,6 +3017,11 @@ 'Win10 Tests x64 (dbg)': { 'experiment_percentage': 100, # crbug.com/870673 }, + 'chromeos-amd64-generic-rel': { + 'swarming': { + 'quickrun_shards': 60, + }, + }, }, 'remove_from': [ # TODO(crbug.com/1141234): Restore when there's more DUTs @@ -3302,6 +3330,15 @@ }, }, }, + 'webgl_conformance_d3d11_passthrough_tests': { + 'modifications': { + 'Win10 x64 Release (NVIDIA)': { + 'swarming': { + 'quickrun_shards': 4, + }, + }, + }, + }, 'webgl_conformance_gl_passthrough_tests': { 'remove_from': [ # crbug.com/555545 and crbug.com/649824: @@ -3337,6 +3374,13 @@ # constrained. crbug.com/950690 'Mac FYI Retina Debug (NVIDIA)', ], + 'modifications': { + 'chromeos-amd64-generic-rel': { + 'swarming': { + 'quickrun_shards': 40, + }, + }, + }, }, 'webgpu_blink_web_tests': { 'modifications': {
diff --git a/testing/buildbot/waterfalls.pyl b/testing/buildbot/waterfalls.pyl index 0d6c42fd..7140b9c 100644 --- a/testing/buildbot/waterfalls.pyl +++ b/testing/buildbot/waterfalls.pyl
@@ -1578,6 +1578,7 @@ }, 'linux-lacros-tester-rel': { 'mixins': [ + 'isolate_profile_data', 'linux-bionic', ], 'additional_compile_targets': [
diff --git a/testing/variations/fieldtrial_testing_config.json b/testing/variations/fieldtrial_testing_config.json index 5e4c1aa..bb54bf7 100644 --- a/testing/variations/fieldtrial_testing_config.json +++ b/testing/variations/fieldtrial_testing_config.json
@@ -5410,6 +5410,23 @@ ] } ], + "NetworkServiceDedicatedThread": [ + { + "platforms": [ + "android", + "android_weblayer", + "android_webview" + ], + "experiments": [ + { + "name": "Disabled", + "disable_features": [ + "NetworkServiceDedicatedThread" + ] + } + ] + } + ], "NoWakeUpsForCanceledTasks": [ { "platforms": [ @@ -9287,7 +9304,6 @@ "WhatsNewPageExperiment": [ { "platforms": [ - "chromeos", "linux", "mac", "windows"
diff --git a/third_party/README.md b/third_party/README.md index c809883b..09147cb 100644 --- a/third_party/README.md +++ b/third_party/README.md
@@ -1,4 +1,5 @@ The third_party directory contains sources from other projects. For guidelines on adding a new package to the third_party directory -can be found at [docs/adding_to_third_party.md](docs/adding_to_third_party.md) +can be found at +[//docs/adding_to_third_party.md](../docs/adding_to_third_party.md)
diff --git a/third_party/blink/public/mojom/loader/resource_load_info_notifier.mojom b/third_party/blink/public/mojom/loader/resource_load_info_notifier.mojom index 76d7a92..303b346 100644 --- a/third_party/blink/public/mojom/loader/resource_load_info_notifier.mojom +++ b/third_party/blink/public/mojom/loader/resource_load_info_notifier.mojom
@@ -14,11 +14,6 @@ // This interface is used to notify loading stats of the resource. interface ResourceLoadInfoNotifier { - // Called to update information to determine whether a user gesture should - // carryover to future navigations, when a request is initiated. - [EnableIf=is_android] - NotifyUpdateUserGestureCarryoverInfo(); - // Called to notify the request has been redirected. NotifyResourceRedirectReceived(network.mojom.URLRequestRedirectInfo redirect_info, network.mojom.URLResponseHead redirect_response);
diff --git a/third_party/blink/public/mojom/service_worker/service_worker.mojom b/third_party/blink/public/mojom/service_worker/service_worker.mojom index 5355f73..652473e2 100644 --- a/third_party/blink/public/mojom/service_worker/service_worker.mojom +++ b/third_party/blink/public/mojom/service_worker/service_worker.mojom
@@ -180,9 +180,6 @@ // ServiceWorkerGlobalScope#registration object and // ServiceWorkerGlobalScope#serviceWorker object. JavaScript execution of the // service worker does not start until this message is received. - // When the service worker is new and going to be registered, - // |subresource_loader_factories| is non-null and it should be used for all - // subsequent requests. // |reporting_observer_receiver| will be set to the worker global scope so // that reports queued to the remote of |reporting_observer_receiver| will // be notified to ReportingObservers registered with the global scope. @@ -191,7 +188,6 @@ ServiceWorkerRegistrationObjectInfo registration_info, ServiceWorkerObjectInfo service_worker_info, FetchHandlerExistence fetch_handler_existence, - URLLoaderFactoryBundle? subresource_loader_factories, pending_receiver<ReportingObserver>? reporting_observer_receiver); // These methods dispatch InstallEvent and ActivateEvent to the
diff --git a/third_party/blink/public/platform/resource_load_info_notifier_wrapper.h b/third_party/blink/public/platform/resource_load_info_notifier_wrapper.h index 6fad292..809723b 100644 --- a/third_party/blink/public/platform/resource_load_info_notifier_wrapper.h +++ b/third_party/blink/public/platform/resource_load_info_notifier_wrapper.h
@@ -42,9 +42,6 @@ scoped_refptr<base::SingleThreadTaskRunner> task_runner); ~ResourceLoadInfoNotifierWrapper(); -#if defined(OS_ANDROID) - void NotifyUpdateUserGestureCarryoverInfo(); -#endif void NotifyResourceLoadInitiated( int64_t request_id, const GURL& request_url,
diff --git a/third_party/blink/public/platform/weak_wrapper_resource_load_info_notifier.h b/third_party/blink/public/platform/weak_wrapper_resource_load_info_notifier.h index 016bf64..2b1b6d56 100644 --- a/third_party/blink/public/platform/weak_wrapper_resource_load_info_notifier.h +++ b/third_party/blink/public/platform/weak_wrapper_resource_load_info_notifier.h
@@ -27,9 +27,6 @@ // blink::mojom::ResourceLoadInfoNotifier overrides, these methods should be // called from the same thread. -#if defined(OS_ANDROID) - void NotifyUpdateUserGestureCarryoverInfo() override; -#endif void NotifyResourceRedirectReceived( const net::RedirectInfo& redirect_info, network::mojom::URLResponseHeadPtr redirect_response) override;
diff --git a/third_party/blink/renderer/core/html/fenced_frame/html_fenced_frame_element.cc b/third_party/blink/renderer/core/html/fenced_frame/html_fenced_frame_element.cc index d4be6f6..c977d173 100644 --- a/third_party/blink/renderer/core/html/fenced_frame/html_fenced_frame_element.cc +++ b/third_party/blink/renderer/core/html/fenced_frame/html_fenced_frame_element.cc
@@ -95,6 +95,9 @@ } void HTMLFencedFrameElement::DidNotifySubtreeInsertionsToDocument() { + if (!SubframeLoadingDisabler::CanLoadFrame(*this)) + return; + frame_delegate_->DidGetInserted(); Navigate(); }
diff --git a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc index f4f2ca4f..d2a49ac7 100644 --- a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc +++ b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc
@@ -1586,7 +1586,6 @@ mojom::blink::ServiceWorkerRegistrationObjectInfoPtr registration_info, mojom::blink::ServiceWorkerObjectInfoPtr service_worker_info, mojom::blink::FetchHandlerExistence fetch_hander_existence, - std::unique_ptr<PendingURLLoaderFactoryBundle> subresource_loader_factories, mojo::PendingReceiver<mojom::blink::ReportingObserver> reporting_observer_receiver) { DCHECK(IsContextThread()); @@ -1597,13 +1596,6 @@ service_worker_host_.Bind(std::move(service_worker_host), GetTaskRunner(TaskType::kInternalDefault)); - if (subresource_loader_factories) { - static_cast<WebServiceWorkerFetchContextImpl*>(web_worker_fetch_context()) - ->GetSubresourceLoaderUpdater() - ->UpdateSubresourceLoaderFactories( - std::move(subresource_loader_factories)); - } - // Set ServiceWorkerGlobalScope#registration. DCHECK_NE(registration_info->registration_id, mojom::blink::kInvalidServiceWorkerRegistrationId);
diff --git a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.h b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.h index 0375f00..a15a0b2 100644 --- a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.h +++ b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.h
@@ -62,7 +62,6 @@ class ExceptionState; class FetchEvent; -class PendingURLLoaderFactoryBundle; class RespondWithObserver; class RequestInit; class ScriptPromise; @@ -408,8 +407,6 @@ mojom::blink::ServiceWorkerRegistrationObjectInfoPtr registration_info, mojom::blink::ServiceWorkerObjectInfoPtr service_worker_info, mojom::blink::FetchHandlerExistence fetch_handler_existence, - std::unique_ptr<PendingURLLoaderFactoryBundle> - subresource_loader_factories, mojo::PendingReceiver<mojom::blink::ReportingObserver>) override; void DispatchInstallEvent(DispatchInstallEventCallback callback) override; void AbortInstallEvent(int event_id,
diff --git a/third_party/blink/renderer/modules/service_worker/web_embedded_worker_impl_test.cc b/third_party/blink/renderer/modules/service_worker/web_embedded_worker_impl_test.cc index e1ca3b7..9ad1b56 100644 --- a/third_party/blink/renderer/modules/service_worker/web_embedded_worker_impl_test.cc +++ b/third_party/blink/renderer/modules/service_worker/web_embedded_worker_impl_test.cc
@@ -212,7 +212,6 @@ KURL("https://example.com"), std::move(service_worker_object_host), service_worker_object.InitWithNewEndpointAndPassReceiver()), mojom::blink::FetchHandlerExistence::EXISTS, - /*subresource_loader_factories=*/nullptr, /*reporting_observer_receiver=*/mojo::NullReceiver()); // To make the other side callable.
diff --git a/third_party/blink/renderer/modules/service_worker/web_service_worker_fetch_context_impl.cc b/third_party/blink/renderer/modules/service_worker/web_service_worker_fetch_context_impl.cc index bdc58ed..671bba0 100644 --- a/third_party/blink/renderer/modules/service_worker/web_service_worker_fetch_context_impl.cc +++ b/third_party/blink/renderer/modules/service_worker/web_service_worker_fetch_context_impl.cc
@@ -196,11 +196,6 @@ MSG_ROUTING_NONE, std::move(task_runner)); } -mojom::blink::SubresourceLoaderUpdater* -WebServiceWorkerFetchContextImpl::GetSubresourceLoaderUpdater() { - return this; -} - void WebServiceWorkerFetchContextImpl::UpdateSubresourceLoaderFactories( std::unique_ptr<PendingURLLoaderFactoryBundle> subresource_loader_factories) {
diff --git a/third_party/blink/renderer/modules/service_worker/web_service_worker_fetch_context_impl.h b/third_party/blink/renderer/modules/service_worker/web_service_worker_fetch_context_impl.h index d069db73..2838a0a 100644 --- a/third_party/blink/renderer/modules/service_worker/web_service_worker_fetch_context_impl.h +++ b/third_party/blink/renderer/modules/service_worker/web_service_worker_fetch_context_impl.h
@@ -73,8 +73,6 @@ TakePendingWorkerTimingReceiver(int request_id) override; void SetIsOfflineMode(bool) override; - mojom::blink::SubresourceLoaderUpdater* GetSubresourceLoaderUpdater(); - // mojom::blink::SubresourceLoaderUpdater implementation: void UpdateSubresourceLoaderFactories( std::unique_ptr<PendingURLLoaderFactoryBundle>
diff --git a/third_party/blink/renderer/modules/webcodecs/BUILD.gn b/third_party/blink/renderer/modules/webcodecs/BUILD.gn index b3442be..b1effb8 100644 --- a/third_party/blink/renderer/modules/webcodecs/BUILD.gn +++ b/third_party/blink/renderer/modules/webcodecs/BUILD.gn
@@ -106,7 +106,6 @@ sources = [ "audio_data_test.cc", "audio_decoder_broker_test.cc", - "audio_encoder_test.cc", "decoder_selector_test.cc", "decoder_template_test.cc", "encoded_video_chunk_test.cc", @@ -114,6 +113,7 @@ "image_decoder_external_test.cc", "reclaimable_codec_test.cc", "video_decoder_broker_test.cc", + "video_decoder_test.cc", "video_encoder_test.cc", "video_frame_monitor_test.cc", "video_frame_test.cc",
diff --git a/third_party/blink/renderer/modules/webcodecs/audio_encoder_test.cc b/third_party/blink/renderer/modules/webcodecs/audio_encoder_test.cc deleted file mode 100644 index ba3851d..0000000 --- a/third_party/blink/renderer/modules/webcodecs/audio_encoder_test.cc +++ /dev/null
@@ -1,107 +0,0 @@ -// Copyright 2021 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 "third_party/blink/renderer/modules/webcodecs/audio_encoder.h" - -#include "testing/gmock/include/gmock/gmock.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/blink/renderer/bindings/core/v8/script_function.h" -#include "third_party/blink/renderer/bindings/core/v8/script_promise_tester.h" -#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h" -#include "third_party/blink/renderer/bindings/modules/v8/v8_audio_encoder_config.h" -#include "third_party/blink/renderer/bindings/modules/v8/v8_audio_encoder_init.h" -#include "third_party/blink/renderer/core/testing/mock_function_scope.h" - -namespace blink { - -namespace { - -class AudioEncoderTest : public testing::Test { - public: - AudioEncoderTest() = default; - ~AudioEncoderTest() override = default; -}; - -AudioEncoderConfig* CreateConfig() { - auto* config = MakeGarbageCollected<AudioEncoderConfig>(); - config->setCodec("opus"); - config->setSampleRate(44100); - config->setNumberOfChannels(2); - return config; -} - -AudioEncoder* CreateEncoder(ScriptState* script_state, - const AudioEncoderInit* init, - ExceptionState& exception_state) { - return MakeGarbageCollected<AudioEncoder>(script_state, init, - exception_state); -} - -AudioEncoderInit* CreateInit(v8::Local<v8::Function> output_callback, - v8::Local<v8::Function> error_callback) { - auto* init = MakeGarbageCollected<AudioEncoderInit>(); - init->setOutput(V8EncodedAudioChunkOutputCallback::Create(output_callback)); - init->setError(V8WebCodecsErrorCallback::Create(error_callback)); - return init; -} - -TEST_F(AudioEncoderTest, CodecReclamation) { - V8TestingScope v8_scope; - auto& es = v8_scope.GetExceptionState(); - auto* script_state = v8_scope.GetScriptState(); - - MockFunctionScope mock_function_scope(script_state); - - // Create an audio encoder. - auto* init = CreateInit(mock_function_scope.ExpectNoCall(), - mock_function_scope.ExpectCall()); - auto* encoder = CreateEncoder(script_state, init, es); - ASSERT_FALSE(es.HadException()); - - // Simulate backgrounding to enable reclamation. - if (!encoder->is_backgrounded_for_testing()) { - encoder->SimulateLifecycleStateForTesting( - scheduler::SchedulingLifecycleState::kHidden); - DCHECK(encoder->is_backgrounded_for_testing()); - } - - auto* config = CreateConfig(); - encoder->configure(config, es); - ASSERT_FALSE(es.HadException()); - { - // We need this to make sure that configuration has completed. - auto promise = encoder->flush(es); - ScriptPromiseTester tester(script_state, promise); - tester.WaitUntilSettled(); - ASSERT_TRUE(tester.IsFulfilled()); - } - - // The encoder should be active, for reclamation purposes. - ASSERT_TRUE(encoder->IsReclamationTimerActiveForTesting()); - - // Resetting the encoder should prevent codec reclamation, silently. - encoder->reset(es); - ASSERT_FALSE(encoder->IsReclamationTimerActiveForTesting()); - - // Reconfiguring the encoder should restart the reclamation timer. - encoder->configure(config, es); - ASSERT_FALSE(es.HadException()); - { - // We need this to make sure that configuration has completed. - auto promise = encoder->flush(es); - ScriptPromiseTester tester(script_state, promise); - tester.WaitUntilSettled(); - ASSERT_TRUE(tester.IsFulfilled()); - } - - ASSERT_TRUE(encoder->IsReclamationTimerActiveForTesting()); - - // Reclaiming a configured encoder should call the error callback. - encoder->SimulateCodecReclaimedForTesting(); - ASSERT_FALSE(encoder->IsReclamationTimerActiveForTesting()); -} - -} // namespace - -} // namespace blink
diff --git a/third_party/blink/renderer/modules/webcodecs/decoder_template.cc b/third_party/blink/renderer/modules/webcodecs/decoder_template.cc index bc5bc09..a62ac42 100644 --- a/third_party/blink/renderer/modules/webcodecs/decoder_template.cc +++ b/third_party/blink/renderer/modules/webcodecs/decoder_template.cc
@@ -68,8 +68,8 @@ DecoderTemplate<Traits>::DecoderTemplate(ScriptState* script_state, const InitType* init, ExceptionState& exception_state) - : ReclaimableCodec(ExecutionContext::From(script_state)), - ExecutionContextLifecycleObserver(ExecutionContext::From(script_state)), + : ReclaimableCodec(ReclaimableCodec::CodecType::kDecoder, + ExecutionContext::From(script_state)), script_state_(script_state), state_(V8CodecState::Enum::kUnconfigured), trace_counter_id_(g_sequence_num_for_counters.GetNext()) { @@ -299,9 +299,9 @@ DCHECK_EQ(request->type, Request::Type::kConfigure); DCHECK(request->media_config); - if (decoder_ && + if (decoder() && pending_decodes_.size() + 1 > - static_cast<size_t>(Traits::GetMaxDecodeRequests(*decoder_))) { + static_cast<size_t>(Traits::GetMaxDecodeRequests(*decoder()))) { // Try again after OnDecodeDone(). return false; } @@ -334,10 +334,10 @@ if (request->reset_generation != reset_generation_) return; - if (!decoder_) { + if (!decoder()) { decoder_ = Traits::CreateDecoder(*ExecutionContext::From(script_state_), gpu_factories_.value(), logger_->log()); - if (!decoder_) { + if (!decoder()) { Shutdown(logger_->MakeException( "Internal error: Could not create decoder.", media::DecoderStatus::Codes::kFailedToCreateDecoder)); @@ -350,7 +350,7 @@ // which can happen if InitializeDecoder() calls it synchronously. initializing_sync_ = true; Traits::InitializeDecoder( - *decoder_, request->low_delay.value(), *request->media_config, + *decoder(), request->low_delay.value(), *request->media_config, WTF::Bind(&DecoderTemplate::OnInitializeDone, WrapWeakPersistent(this)), WTF::BindRepeating(&DecoderTemplate::OnOutput, WrapWeakPersistent(this), reset_generation_)); @@ -359,7 +359,7 @@ } // Processing continues in OnFlushDone(). - decoder_->Decode( + decoder()->Decode( media::DecoderBuffer::CreateEOSBuffer(), WTF::Bind(&DecoderTemplate::OnFlushDone, WrapWeakPersistent(this))); } @@ -372,7 +372,7 @@ DCHECK_EQ(request->type, Request::Type::kDecode); DCHECK_GT(num_pending_decodes_, 0); - if (!decoder_) { + if (!decoder()) { Shutdown( logger_->MakeException("Decoding error: no decoder found.", media::DecoderStatus::Codes::kNotInitialized)); @@ -380,7 +380,7 @@ } if (pending_decodes_.size() + 1 > - static_cast<size_t>(Traits::GetMaxDecodeRequests(*decoder_))) { + static_cast<size_t>(Traits::GetMaxDecodeRequests(*decoder()))) { // Try again after OnDecodeDone(). return false; } @@ -413,9 +413,9 @@ GetTraceNames()->decode.c_str(), *request->decoder_buffer); } - decoder_->Decode(std::move(request->decoder_buffer), - WTF::Bind(&DecoderTemplate::OnDecodeDone, - WrapWeakPersistent(this), pending_decode_id_)); + decoder()->Decode(std::move(request->decoder_buffer), + WTF::Bind(&DecoderTemplate::OnDecodeDone, + WrapWeakPersistent(this), pending_decode_id_)); return true; } @@ -429,10 +429,10 @@ // flush() can only be called when state = "configured", in which case we // should always have a decoder. - DCHECK(decoder_); + DCHECK(decoder()); if (pending_decodes_.size() + 1 > - static_cast<size_t>(Traits::GetMaxDecodeRequests(*decoder_))) { + static_cast<size_t>(Traits::GetMaxDecodeRequests(*decoder()))) { // Try again after OnDecodeDone(). return false; } @@ -441,7 +441,7 @@ pending_request_ = request; pending_request_->StartTracing(); - decoder_->Decode( + decoder()->Decode( media::DecoderBuffer::CreateEOSBuffer(), WTF::Bind(&DecoderTemplate::OnFlushDone, WrapWeakPersistent(this))); return true; @@ -457,12 +457,12 @@ // Signal [[codec implementation]] to cease producing output for the previous // configuration. - if (decoder_) { + if (decoder()) { pending_request_ = request; pending_request_->StartTracing(); // Processing continues in OnResetDone(). - decoder_->Reset( + decoder()->Reset( WTF::Bind(&DecoderTemplate::OnResetDone, WrapWeakPersistent(this))); } @@ -492,7 +492,7 @@ // Abort all upcoming work. ResetAlgorithm(); - PauseCodecReclamation(); + ReleaseCodecPressure(); // Store the error callback so that we can use it after clearing state. V8WebCodecsErrorCallback* error_cb = error_cb_.Get(); @@ -598,7 +598,7 @@ // Processing continues in OnInitializeDone(). Traits::InitializeDecoder( - *decoder_, is_flush ? low_delay_ : pending_request_->low_delay.value(), + *decoder(), is_flush ? low_delay_ : pending_request_->low_delay.value(), is_flush ? *active_config_ : *pending_request_->media_config, WTF::Bind(&DecoderTemplate::OnInitializeDone, WrapWeakPersistent(this)), WTF::BindRepeating(&DecoderTemplate::OnOutput, WrapWeakPersistent(this), @@ -635,11 +635,14 @@ if (is_flush) { pending_request_->resolver.Release()->Resolve(); } else { - logger_->SendPlayerNameInformation(*GetExecutionContext(), - Traits::GetName()); - Traits::UpdateDecoderLog(*decoder_, *pending_request_->media_config, + Traits::UpdateDecoderLog(*decoder(), *pending_request_->media_config, logger_->log()); + if (decoder()->IsPlatformDecoder()) + ApplyCodecPressure(); + else + ReleaseCodecPressure(); + low_delay_ = pending_request_->low_delay.value(); active_config_ = std::move(pending_request_->media_config); } @@ -753,13 +756,14 @@ template <typename Traits> void DecoderTemplate<Traits>::OnCodecReclaimed(DOMException* exception) { TRACE_EVENT0(kCategory, GetTraceNames()->reclaimed.c_str()); + DCHECK(is_applying_codec_pressure()); if (state_.AsEnum() == V8CodecState::Enum::kUnconfigured) { decoder_.reset(); // This codec isn't holding on to any resources, and doesn't need to be // reclaimed. - PauseCodecReclamation(); + ReleaseCodecPressure(); return; }
diff --git a/third_party/blink/renderer/modules/webcodecs/decoder_template.h b/third_party/blink/renderer/modules/webcodecs/decoder_template.h index 4c310db..a8054c6 100644 --- a/third_party/blink/renderer/modules/webcodecs/decoder_template.h +++ b/third_party/blink/renderer/modules/webcodecs/decoder_template.h
@@ -42,8 +42,7 @@ class MODULES_EXPORT DecoderTemplate : public ScriptWrappable, public ActiveScriptWrappable<DecoderTemplate<Traits>>, - public ReclaimableCodec, - public ExecutionContextLifecycleObserver { + public ReclaimableCodec { public: typedef typename Traits::ConfigType ConfigType; typedef typename Traits::MediaConfigType MediaConfigType; @@ -93,10 +92,10 @@ // Sets the HardwarePreference on the |decoder_|. // The default implementation does nothing and must be overridden by derived // classes if needed. - // Decoder virtual void SetHardwarePreference(HardwarePreference preference); - MediaDecoderType* decoder() { return decoder_.get(); } + // Virtual for UTs. + virtual MediaDecoderType* decoder() { return decoder_.get(); } // Convert a chunk to a DecoderBuffer. You can assume that the last // configuration sent to MakeMediaConfig() is the active configuration for
diff --git a/third_party/blink/renderer/modules/webcodecs/decoder_template_test.cc b/third_party/blink/renderer/modules/webcodecs/decoder_template_test.cc index 006c1f8..1b562aed 100644 --- a/third_party/blink/renderer/modules/webcodecs/decoder_template_test.cc +++ b/third_party/blink/renderer/modules/webcodecs/decoder_template_test.cc
@@ -149,12 +149,12 @@ #if defined(OS_LINUX) && defined(THREAD_SANITIZER) // https://crbug.com/1247967 -#define MAYBE_CodecReclamation DISABLED_CodecReclamation +#define MAYBE_NoPressureByDefault DISABLED_NoPressureByDefault #else -#define MAYBE_CodecReclamation CodecReclamation +#define MAYBE_NoPressureByDefault NoPressureByDefault #endif -// Ensures codecs can be reclaimed in a configured or unconfigured state. -TYPED_TEST(DecoderTemplateTest, MAYBE_CodecReclamation) { +// Ensures codecs do not apply reclamation pressure by default. +TYPED_TEST(DecoderTemplateTest, MAYBE_NoPressureByDefault) { V8TestingScope v8_scope; // Create a decoder. @@ -162,40 +162,17 @@ auto* decoder = this->CreateDecoder(v8_scope.GetScriptState(), this->CreateInit(mock_function.ExpectNoCall(), - mock_function.ExpectCall()), + mock_function.ExpectNoCall()), v8_scope.GetExceptionState()); ASSERT_TRUE(decoder); ASSERT_FALSE(v8_scope.GetExceptionState().HadException()); - // Simulate backgrounding to enable reclamation. - if (!decoder->is_backgrounded_for_testing()) { - decoder->SimulateLifecycleStateForTesting( - scheduler::SchedulingLifecycleState::kHidden); - DCHECK(decoder->is_backgrounded_for_testing()); - } - // Configure the decoder. decoder->configure(this->CreateConfig(), v8_scope.GetExceptionState()); ASSERT_FALSE(v8_scope.GetExceptionState().HadException()); - ASSERT_TRUE(decoder->IsReclamationTimerActiveForTesting()); - - // Resets count as activity for decoders. - decoder->reset(v8_scope.GetExceptionState()); - ASSERT_TRUE(decoder->IsReclamationTimerActiveForTesting()); - - // Reclaiming a reset decoder should not call the error callback. - decoder->SimulateCodecReclaimedForTesting(); - ASSERT_FALSE(decoder->IsReclamationTimerActiveForTesting()); - - // Configure the decoder once more. - decoder->configure(this->CreateConfig(), v8_scope.GetExceptionState()); - ASSERT_FALSE(v8_scope.GetExceptionState().HadException()); - ASSERT_TRUE(decoder->IsReclamationTimerActiveForTesting()); - - // Reclaiming a configured decoder should call the error callback. - decoder->SimulateCodecReclaimedForTesting(); - ASSERT_FALSE(decoder->IsReclamationTimerActiveForTesting()); + // Codecs shouldn't apply pressure by default. + ASSERT_FALSE(decoder->is_applying_codec_pressure()); } } // namespace
diff --git a/third_party/blink/renderer/modules/webcodecs/encoder_base.cc b/third_party/blink/renderer/modules/webcodecs/encoder_base.cc index faed4d8..6024cd7 100644 --- a/third_party/blink/renderer/modules/webcodecs/encoder_base.cc +++ b/third_party/blink/renderer/modules/webcodecs/encoder_base.cc
@@ -56,8 +56,8 @@ EncoderBase<Traits>::EncoderBase(ScriptState* script_state, const InitType* init, ExceptionState& exception_state) - : ReclaimableCodec(ExecutionContext::From(script_state)), - ExecutionContextLifecycleObserver(ExecutionContext::From(script_state)), + : ReclaimableCodec(ReclaimableCodec::CodecType::kEncoder, + ExecutionContext::From(script_state)), state_(V8CodecState::Enum::kUnconfigured), script_state_(script_state), trace_counter_id_(g_sequence_num_for_counters.GetNext()) { @@ -203,10 +203,6 @@ state_ = V8CodecState(V8CodecState::Enum::kUnconfigured); ResetInternal(); - - // This codec isn't holding on to any resources, and doesn't need to be - // reclaimed. - PauseCodecReclamation(); } template <typename Traits> @@ -230,6 +226,10 @@ // the call stack and continu executing code belonging to deleted // |media_encoder_|. callback_runner_->DeleteSoon(FROM_HERE, std::move(media_encoder_)); + + // This codec isn't holding on to any resources, and doesn't need to be + // reclaimed. + ReleaseCodecPressure(); } template <typename Traits> @@ -245,7 +245,6 @@ state_ = V8CodecState(V8CodecState::Enum::kClosed); ResetInternal(); - PauseCodecReclamation(); // Errors are permanent. Shut everything down. error_callback_.Clear();
diff --git a/third_party/blink/renderer/modules/webcodecs/encoder_base.h b/third_party/blink/renderer/modules/webcodecs/encoder_base.h index 9c1cd31..f904de3f 100644 --- a/third_party/blink/renderer/modules/webcodecs/encoder_base.h +++ b/third_party/blink/renderer/modules/webcodecs/encoder_base.h
@@ -35,8 +35,7 @@ class MODULES_EXPORT EncoderBase : public ScriptWrappable, public ActiveScriptWrappable<EncoderBase<Traits>>, - public ReclaimableCodec, - public ExecutionContextLifecycleObserver { + public ReclaimableCodec { public: using InitType = typename Traits::Init; using ConfigType = typename Traits::Config;
diff --git a/third_party/blink/renderer/modules/webcodecs/reclaimable_codec.cc b/third_party/blink/renderer/modules/webcodecs/reclaimable_codec.cc index cf73380..a4e164d 100644 --- a/third_party/blink/renderer/modules/webcodecs/reclaimable_codec.cc +++ b/third_party/blink/renderer/modules/webcodecs/reclaimable_codec.cc
@@ -21,14 +21,15 @@ "OnlyReclaimBackgroundWebCodecs", base::FEATURE_ENABLED_BY_DEFAULT}; constexpr base::TimeDelta ReclaimableCodec::kInactivityReclamationThreshold; -constexpr base::TimeDelta ReclaimableCodec::kTimerPeriod; -ReclaimableCodec::ReclaimableCodec(ExecutionContext* context) - : tick_clock_(base::DefaultTickClock::GetInstance()), +ReclaimableCodec::ReclaimableCodec(CodecType type, ExecutionContext* context) + : ExecutionContextLifecycleObserver(context), + tick_clock_(base::DefaultTickClock::GetInstance()), + inactivity_threshold_(kInactivityReclamationThreshold), last_activity_(tick_clock_->NowTicks()), activity_timer_(Thread::Current()->GetTaskRunner(), this, - &ReclaimableCodec::ActivityTimerFired) { + &ReclaimableCodec::OnActivityTimerFired) { DCHECK(context); if (base::FeatureList::IsEnabled(kOnlyReclaimBackgroundWebCodecs)) { // Do this last, it will immediately re-enter via OnLifecycleStateChanged(). @@ -42,6 +43,30 @@ } } +void ReclaimableCodec::Trace(Visitor* visitor) const { + visitor->Trace(activity_timer_); + ExecutionContextLifecycleObserver::Trace(visitor); +} + +void ReclaimableCodec::ApplyCodecPressure() { + if (is_applying_pressure_) + return; + + is_applying_pressure_ = true; + + OnReclamationPreconditionsUpdated(); +} + +void ReclaimableCodec::ReleaseCodecPressure() { + if (!is_applying_pressure_) { + DCHECK(!activity_timer_.IsActive()); + return; + } + + is_applying_pressure_ = false; + OnReclamationPreconditionsUpdated(); +} + void ReclaimableCodec::OnLifecycleStateChanged( scheduler::SchedulingLifecycleState lifecycle_state) { DVLOG(5) << __func__ @@ -56,35 +81,17 @@ is_backgrounded_ = is_backgrounded; - // Nothing to do when paused. - if (is_reclamation_paused_) { - DCHECK(!activity_timer_.IsActive()); - return; - } - - if (is_backgrounded_) { - // (Re)entered background, so start timer again from "now". + // Make sure we wait the full inactivity timer period before reclaiming a + // newly backgrounded codec. + if (is_backgrounded_) MarkCodecActive(); - DCHECK(activity_timer_.IsActive()); - } else { - // We're in foreground, so pause reclamation to improve UX. - PauseCodecReclamationInternal(); - } + + OnReclamationPreconditionsUpdated(); } -void ReclaimableCodec::MarkCodecActive() { - DVLOG(5) << __func__; - is_reclamation_paused_ = false; - last_activity_ = tick_clock_->NowTicks(); - last_tick_was_inactive_ = false; - - if (!is_backgrounded_) { - DCHECK(!activity_timer_.IsActive()); - DVLOG(5) << __func__ << " Suppressing reclamation of foreground codec."; - return; - } - - StartTimer(); +void ReclaimableCodec::SimulateLifecycleStateForTesting( + scheduler::SchedulingLifecycleState state) { + OnLifecycleStateChanged(state); } void ReclaimableCodec::SimulateCodecReclaimedForTesting() { @@ -93,45 +100,49 @@ } void ReclaimableCodec::SimulateActivityTimerFiredForTesting() { - ActivityTimerFired(nullptr); + OnActivityTimerFired(nullptr); } -void ReclaimableCodec::SimulateLifecycleStateForTesting( - scheduler::SchedulingLifecycleState state) { - OnLifecycleStateChanged(state); +void ReclaimableCodec::MarkCodecActive() { + last_activity_ = tick_clock_->NowTicks(); + last_tick_was_inactive_ = false; } -void ReclaimableCodec::PauseCodecReclamation() { - DVLOG(5) << __func__; - is_reclamation_paused_ = true; - PauseCodecReclamationInternal(); +void ReclaimableCodec::OnReclamationPreconditionsUpdated() { + if (AreReclamationPreconditionsMet()) + StartIdleReclamationTimer(); + else + StopIdleReclamationTimer(); } -void ReclaimableCodec::PauseCodecReclamationInternal() { - DVLOG(5) << __func__; - activity_timer_.Stop(); +bool ReclaimableCodec::AreReclamationPreconditionsMet() { + return is_applying_pressure_ && is_backgrounded_; } -void ReclaimableCodec::StartTimer() { - DCHECK(is_backgrounded_); - DCHECK(!is_reclamation_paused_); +void ReclaimableCodec::StartIdleReclamationTimer() { + DCHECK(AreReclamationPreconditionsMet()); if (activity_timer_.IsActive()) return; if (base::FeatureList::IsEnabled(kReclaimInactiveWebCodecs)) { DVLOG(5) << __func__ << " Starting timer."; - activity_timer_.StartRepeating(kTimerPeriod, FROM_HERE); + activity_timer_.StartRepeating(inactivity_threshold_ / 2, FROM_HERE); } } -void ReclaimableCodec::ActivityTimerFired(TimerBase*) { - DCHECK(is_backgrounded_); - DCHECK(!is_reclamation_paused_); +void ReclaimableCodec::StopIdleReclamationTimer() { + DCHECK(!AreReclamationPreconditionsMet()); + + activity_timer_.Stop(); +} + +void ReclaimableCodec::OnActivityTimerFired(TimerBase*) { DCHECK(base::FeatureList::IsEnabled(kReclaimInactiveWebCodecs)); + DCHECK(AreReclamationPreconditionsMet()); auto time_inactive = tick_clock_->NowTicks() - last_activity_; - bool is_inactive = time_inactive >= kInactivityReclamationThreshold; + bool is_inactive = time_inactive >= inactivity_threshold_; // Do not immediately reclaim. Make sure the codec is inactive for 2 ticks. // Otherwise, tabs that were suspended could see their codecs reclaimed @@ -143,12 +154,7 @@ "Codec reclaimed due to inactivity.")); } - last_tick_was_inactive_ = - time_inactive >= (kInactivityReclamationThreshold / 2); -} - -void ReclaimableCodec::Trace(Visitor* visitor) const { - visitor->Trace(activity_timer_); + last_tick_was_inactive_ = time_inactive >= (inactivity_threshold_ / 2); } } // namespace blink
diff --git a/third_party/blink/renderer/modules/webcodecs/reclaimable_codec.h b/third_party/blink/renderer/modules/webcodecs/reclaimable_codec.h index 4ec8682..d64546c 100644 --- a/third_party/blink/renderer/modules/webcodecs/reclaimable_codec.h +++ b/third_party/blink/renderer/modules/webcodecs/reclaimable_codec.h
@@ -7,6 +7,7 @@ #include "base/feature_list.h" #include "third_party/blink/renderer/core/execution_context/execution_context.h" +#include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_observer.h" #include "third_party/blink/renderer/modules/modules_export.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" #include "third_party/blink/renderer/platform/scheduler/public/frame_or_worker_scheduler.h" @@ -25,62 +26,85 @@ extern const MODULES_EXPORT base::Feature kReclaimInactiveWebCodecs; extern const MODULES_EXPORT base::Feature kOnlyReclaimBackgroundWebCodecs; -class MODULES_EXPORT ReclaimableCodec : public GarbageCollectedMixin { +class MODULES_EXPORT ReclaimableCodec + : public ExecutionContextLifecycleObserver { public: - explicit ReclaimableCodec(ExecutionContext*); + // Use 1.5 minutes since some RDP clients are only ticking at 1 FPM. + static constexpr base::TimeDelta kInactivityReclamationThreshold = + base::Seconds(90); + + enum class CodecType { + kDecoder, + kEncoder, + }; + + ReclaimableCodec(CodecType, ExecutionContext*); + ~ReclaimableCodec() override = default; // GarbageCollectedMixin override. void Trace(Visitor*) const override; + // Apply or release pressure, if this codec is holding on to constrained + // resources. + void ApplyCodecPressure(); + void ReleaseCodecPressure(); + + // Notified when throttling state is changed. May be called consecutively + // with the same value. + void OnLifecycleStateChanged(scheduler::SchedulingLifecycleState); + + bool is_applying_codec_pressure() const { return is_applying_pressure_; } + + // Test support. + void SimulateCodecReclaimedForTesting(); + void SimulateActivityTimerFiredForTesting(); + void SimulateLifecycleStateForTesting(scheduler::SchedulingLifecycleState); + bool IsReclamationTimerActiveForTesting() { return activity_timer_.IsActive(); } bool is_backgrounded_for_testing() { return is_backgrounded_; } - void SimulateCodecReclaimedForTesting(); - void SimulateActivityTimerFiredForTesting(); - void SimulateLifecycleStateForTesting(scheduler::SchedulingLifecycleState); - void set_tick_clock_for_testing(const base::TickClock* clock) { tick_clock_ = clock; } - // Use 1.5 minutes since some RDP clients are only ticking at 1 FPM. - static constexpr base::TimeDelta kInactivityReclamationThreshold = - base::Seconds(90); - static constexpr base::TimeDelta kTimerPeriod = - kInactivityReclamationThreshold / 2; - - // Notified when throttling state is changed. May be called consecutively - // with the same value. - void OnLifecycleStateChanged(scheduler::SchedulingLifecycleState); - protected: // Pushes back the time at which |this| can be reclaimed due to inactivity. - // Starts a inactivity reclamation timer, if it isn't already running. void MarkCodecActive(); - // Called when a codec should no longer be reclaimed, such as when it is not - // holding on to any resources. - // - // Calling MarkCodecActive() will automatically unpause reclamation. - void PauseCodecReclamation(); - virtual void OnCodecReclaimed(DOMException*) = 0; + base::TimeTicks last_activity_for_testing() const { return last_activity_; } + private: - void ActivityTimerFired(TimerBase*); - void StartTimer(); - void PauseCodecReclamationInternal(); + // Starts the idle reclamation timer if all preconditions are met, or stops it + // otherwise. Called when any of the following criteria change: + // - |this| applies/releases codec pressure. + // - |this|'s background status changes. + void OnReclamationPreconditionsUpdated(); + + bool AreReclamationPreconditionsMet(); + + void StartIdleReclamationTimer(); + void StopIdleReclamationTimer(); + + void OnActivityTimerFired(TimerBase*); // This is used to make sure that there are two consecutive ticks of the // timer, before we reclaim for inactivity. This prevents immediately // reclaiming otherwise active codecs, right after a page suspended/resumed. bool last_tick_was_inactive_ = false; + // Whether this codec is holding on to platform resources. + bool is_applying_pressure_ = false; + const base::TickClock* tick_clock_; + // Period of time after which a codec is considered to be inactive. + base::TimeDelta inactivity_threshold_; + base::TimeTicks last_activity_; HeapTaskRunnerTimer<ReclaimableCodec> activity_timer_; @@ -89,10 +113,6 @@ // covered by other windows. bool is_backgrounded_ = false; - // True if PauseCodecReclamation() has been called more recently than - // MarkCodecActive(), or if the codec is already reclaimed. - bool is_reclamation_paused_ = true; - // Handle to unhook from FrameOrWorkerScheduler upon destruction. std::unique_ptr<FrameOrWorkerScheduler::LifecycleObserverHandle> observer_handle_;
diff --git a/third_party/blink/renderer/modules/webcodecs/reclaimable_codec_test.cc b/third_party/blink/renderer/modules/webcodecs/reclaimable_codec_test.cc index 2e1e157..d936353 100644 --- a/third_party/blink/renderer/modules/webcodecs/reclaimable_codec_test.cc +++ b/third_party/blink/renderer/modules/webcodecs/reclaimable_codec_test.cc
@@ -17,19 +17,23 @@ namespace { +constexpr base::TimeDelta kTimerPeriod = + ReclaimableCodec::kInactivityReclamationThreshold / 2; + class FakeReclaimableCodec final : public GarbageCollected<FakeReclaimableCodec>, public ReclaimableCodec { public: - explicit FakeReclaimableCodec(ExecutionContext* context) - : ReclaimableCodec(context) {} + FakeReclaimableCodec(ReclaimableCodec::CodecType type, + ExecutionContext* context) + : ReclaimableCodec(type, context) {} void SimulateActivity() { MarkCodecActive(); reclaimed_ = false; } - void SimulateReset() { PauseCodecReclamation(); } + void SimulateReset() { ReleaseCodecPressure(); } void OnCodecReclaimed(DOMException* ex) final { reclaimed_ = true; } @@ -41,13 +45,24 @@ bool reclaimed() const { return reclaimed_; } private: + // ContextLifecycleObserver override. + void ContextDestroyed() override {} + bool reclaimed_ = false; }; } // namespace +class BaseReclaimableCodecTest + : public testing::TestWithParam<ReclaimableCodec::CodecType> { + public: + FakeReclaimableCodec* CreateCodec(ExecutionContext* context) { + return MakeGarbageCollected<FakeReclaimableCodec>(GetParam(), context); + } +}; + // Testing w/ flags allowing only reclamation of background codecs. -class ReclaimBackgroundOnlyTest : public testing::Test { +class ReclaimBackgroundOnlyTest : public BaseReclaimableCodecTest { public: ReclaimBackgroundOnlyTest() { std::vector<base::Feature> enabled_features{ @@ -62,7 +77,7 @@ // Testing w/ flags allowing reclamation of both foreground and background // codecs. -class ReclaimForegroundSameAsBackgroundTest : public testing::Test { +class ReclaimForegroundSameAsBackgroundTest : public BaseReclaimableCodecTest { public: ReclaimForegroundSameAsBackgroundTest() { std::vector<base::Feature> enabled_features{kReclaimInactiveWebCodecs}; @@ -76,7 +91,7 @@ }; // Testing kill-switch scenario w/ all flags disabled. -class ReclaimDisabledTest : public testing::Test { +class ReclaimDisabledTest : public BaseReclaimableCodecTest { public: ReclaimDisabledTest() { std::vector<base::Feature> enabled_features{}; @@ -98,12 +113,8 @@ kExpectAlreadyInBackground, }; -void TestBackgroundInactivityTimerStartStops(TestParam background_type) { - V8TestingScope v8_scope; - - auto* codec = MakeGarbageCollected<FakeReclaimableCodec>( - v8_scope.GetExecutionContext()); - +void TestBackgroundInactivityTimerStartStops(TestParam background_type, + FakeReclaimableCodec* codec) { if (background_type == TestParam::kSimulateBackgrounding) { EXPECT_FALSE(codec->is_backgrounded_for_testing()); codec->SimulateLifecycleStateForTesting( @@ -113,17 +124,17 @@ EXPECT_TRUE(codec->is_backgrounded_for_testing()); } - // Codecs should not be reclaimable for inactivity until first activity. + // Codecs should not be reclaimable for inactivity until pressure is applied. EXPECT_FALSE(codec->IsReclamationTimerActiveForTesting()); codec->SimulateReset(); EXPECT_FALSE(codec->IsReclamationTimerActiveForTesting()); - // Activity should start the timer. - codec->SimulateActivity(); + // Applying pressure should start the timer. + codec->ApplyCodecPressure(); EXPECT_TRUE(codec->IsReclamationTimerActiveForTesting()); - // More activity should not stop the timer. + // Activity should not stop the timer. codec->SimulateActivity(); EXPECT_TRUE(codec->IsReclamationTimerActiveForTesting()); @@ -132,16 +143,12 @@ EXPECT_FALSE(codec->IsReclamationTimerActiveForTesting()); // It should be possible to restart the timer after stopping it. - codec->SimulateActivity(); + codec->ApplyCodecPressure(); EXPECT_TRUE(codec->IsReclamationTimerActiveForTesting()); } -void TestBackgroundInactivityTimerWorks(TestParam background_type) { - V8TestingScope v8_scope; - - auto* codec = MakeGarbageCollected<FakeReclaimableCodec>( - v8_scope.GetExecutionContext()); - +void TestBackgroundInactivityTimerWorks(TestParam background_type, + FakeReclaimableCodec* codec) { if (background_type == TestParam::kSimulateBackgrounding) { EXPECT_FALSE(codec->is_backgrounded_for_testing()); codec->SimulateLifecycleStateForTesting( @@ -151,29 +158,30 @@ EXPECT_TRUE(codec->is_backgrounded_for_testing()); } - // Codecs should not be reclaimable for inactivity until first activity. + // Codecs should not be reclaimable for inactivity until pressure is applied. EXPECT_FALSE(codec->IsReclamationTimerActiveForTesting()); base::SimpleTestTickClock tick_clock; codec->set_tick_clock_for_testing(&tick_clock); - // Activity should start the timer. - codec->SimulateActivity(); + // Applying pressure should start the timer. + codec->ApplyCodecPressure(); EXPECT_TRUE(codec->IsReclamationTimerActiveForTesting()); EXPECT_FALSE(codec->reclaimed()); // Fire when codec is fresh to ensure first tick isn't treated as idle. + codec->SimulateActivity(); codec->SimulateActivityTimerFiredForTesting(); EXPECT_FALSE(codec->reclaimed()); // One timer period should not be enough to reclaim the codec. - tick_clock.Advance(ReclaimableCodec::kTimerPeriod); + tick_clock.Advance(kTimerPeriod); codec->SimulateActivityTimerFiredForTesting(); EXPECT_FALSE(codec->reclaimed()); // Advancing an additional timer period should be enough to trigger // reclamation. - tick_clock.Advance(ReclaimableCodec::kTimerPeriod); + tick_clock.Advance(kTimerPeriod); codec->SimulateActivityTimerFiredForTesting(); EXPECT_TRUE(codec->reclaimed()); @@ -182,44 +190,64 @@ codec->set_tick_clock_for_testing(base::DefaultTickClock::GetInstance()); } -TEST_F(ReclaimBackgroundOnlyTest, BackgroundInactivityTimerStartStops) { - // Only background reclamation permitted, so simulate backgrouding. - TestBackgroundInactivityTimerStartStops(TestParam::kSimulateBackgrounding); -} - -TEST_F(ReclaimBackgroundOnlyTest, BackgroundInactivityTimerWorks) { - // Only background reclamation permitted, so simulate backgrouding. - TestBackgroundInactivityTimerWorks(TestParam::kSimulateBackgrounding); -} - -TEST_F(ReclaimForegroundSameAsBackgroundTest, - BackgroundInactivityTimerStartStops) { - // Foreground codecs are treated as always backgrounded w/ these feature flags - TestBackgroundInactivityTimerStartStops( - TestParam::kExpectAlreadyInBackground); -} - -TEST_F(ReclaimForegroundSameAsBackgroundTest, BackgroundInactivityTimerWorks) { - // Foreground codecs are treated as always backgrounded w/ these feature flags - TestBackgroundInactivityTimerWorks(TestParam::kExpectAlreadyInBackground); -} - -TEST_F(ReclaimBackgroundOnlyTest, ForegroundInactivityTimerNeverStarts) { +TEST_P(ReclaimBackgroundOnlyTest, BackgroundInactivityTimerStartStops) { V8TestingScope v8_scope; - auto* codec = MakeGarbageCollected<FakeReclaimableCodec>( - v8_scope.GetExecutionContext()); + // Only background reclamation permitted, so simulate backgrouding. + TestBackgroundInactivityTimerStartStops( + TestParam::kSimulateBackgrounding, + CreateCodec(v8_scope.GetExecutionContext())); +} + +TEST_P(ReclaimBackgroundOnlyTest, BackgroundInactivityTimerWorks) { + V8TestingScope v8_scope; + + // Only background reclamation permitted, so simulate backgrouding. + TestBackgroundInactivityTimerWorks( + TestParam::kSimulateBackgrounding, + CreateCodec(v8_scope.GetExecutionContext())); +} + +TEST_P(ReclaimForegroundSameAsBackgroundTest, + BackgroundInactivityTimerStartStops) { + V8TestingScope v8_scope; + + // Foreground codecs are treated as always backgrounded w/ these feature flags + TestBackgroundInactivityTimerStartStops( + TestParam::kExpectAlreadyInBackground, + CreateCodec(v8_scope.GetExecutionContext())); +} + +TEST_P(ReclaimForegroundSameAsBackgroundTest, BackgroundInactivityTimerWorks) { + V8TestingScope v8_scope; + + // Foreground codecs are treated as always backgrounded w/ these feature flags + TestBackgroundInactivityTimerWorks( + TestParam::kExpectAlreadyInBackground, + CreateCodec(v8_scope.GetExecutionContext())); +} + +TEST_P(ReclaimBackgroundOnlyTest, ForegroundInactivityTimerNeverStarts) { + V8TestingScope v8_scope; + + auto* codec = CreateCodec(v8_scope.GetExecutionContext()); // Test codec should start in foreground when kOnlyReclaimBackgroundWebCodecs // enabled. EXPECT_FALSE(codec->is_backgrounded_for_testing()); - // Codecs should not be reclaimable for inactivity until first activity. + // Codecs should not be reclaimable for inactivity until pressure is applied. EXPECT_FALSE(codec->IsReclamationTimerActiveForTesting()); base::SimpleTestTickClock tick_clock; codec->set_tick_clock_for_testing(&tick_clock); + // Applying pressure should not start timer while we remain in foreground. + codec->ApplyCodecPressure(); + EXPECT_FALSE(codec->IsReclamationTimerActiveForTesting()); + EXPECT_FALSE(codec->is_backgrounded_for_testing()); + EXPECT_FALSE(codec->reclaimed()); + // First activity should not start timer while we remain in foreground. codec->SimulateActivity(); EXPECT_FALSE(codec->IsReclamationTimerActiveForTesting()); @@ -227,7 +255,7 @@ EXPECT_FALSE(codec->reclaimed()); // Advancing time by any amount shouldn't change the above. - tick_clock.Advance(ReclaimableCodec::kTimerPeriod * 100); + tick_clock.Advance(kTimerPeriod * 100); EXPECT_FALSE(codec->IsReclamationTimerActiveForTesting()); EXPECT_FALSE(codec->is_backgrounded_for_testing()); EXPECT_FALSE(codec->reclaimed()); @@ -243,24 +271,23 @@ codec->set_tick_clock_for_testing(base::DefaultTickClock::GetInstance()); } -TEST_F(ReclaimBackgroundOnlyTest, ForegroundCodecReclaimedOnceBackgrounded) { +TEST_P(ReclaimBackgroundOnlyTest, ForegroundCodecReclaimedOnceBackgrounded) { V8TestingScope v8_scope; - auto* codec = MakeGarbageCollected<FakeReclaimableCodec>( - v8_scope.GetExecutionContext()); + auto* codec = CreateCodec(v8_scope.GetExecutionContext()); // Test codec should start in foreground when kOnlyReclaimBackgroundWebCodecs // enabled. EXPECT_FALSE(codec->is_backgrounded_for_testing()); - // Codecs should not be reclaimable for inactivity until first activity. + // Codecs should not be reclaimable for inactivity until pressure is applied. EXPECT_FALSE(codec->IsReclamationTimerActiveForTesting()); base::SimpleTestTickClock tick_clock; codec->set_tick_clock_for_testing(&tick_clock); - // First activity should not start timer while we remain in foreground. - codec->SimulateActivity(); + // Pressure should not start the timer while we are still in the foreground. + codec->ApplyCodecPressure(); EXPECT_FALSE(codec->IsReclamationTimerActiveForTesting()); EXPECT_FALSE(codec->is_backgrounded_for_testing()); EXPECT_FALSE(codec->reclaimed()); @@ -273,7 +300,7 @@ EXPECT_FALSE(codec->reclaimed()); // Advancing 1 period shouldn't reclaim (it takes 2). - tick_clock.Advance(ReclaimableCodec::kTimerPeriod); + tick_clock.Advance(kTimerPeriod); codec->SimulateActivityTimerFiredForTesting(); EXPECT_FALSE(codec->reclaimed()); @@ -285,7 +312,7 @@ EXPECT_FALSE(codec->reclaimed()); // Advancing any amount of time shouldn't reclaim while in foreground. - tick_clock.Advance(ReclaimableCodec::kTimerPeriod * 100); + tick_clock.Advance(kTimerPeriod * 100); EXPECT_FALSE(codec->IsReclamationTimerActiveForTesting()); EXPECT_FALSE(codec->is_backgrounded_for_testing()); EXPECT_FALSE(codec->reclaimed()); @@ -302,13 +329,13 @@ EXPECT_FALSE(codec->reclaimed()); // Timer should be fresh such that one period is not enough to reclaim. - tick_clock.Advance(ReclaimableCodec::kTimerPeriod); + tick_clock.Advance(kTimerPeriod); codec->SimulateActivityTimerFiredForTesting(); EXPECT_TRUE(codec->is_backgrounded_for_testing()); EXPECT_FALSE(codec->reclaimed()); // Advancing twice through the period should finally reclaim. - tick_clock.Advance(ReclaimableCodec::kTimerPeriod); + tick_clock.Advance(kTimerPeriod); codec->SimulateActivityTimerFiredForTesting(); EXPECT_TRUE(codec->is_backgrounded_for_testing()); EXPECT_TRUE(codec->reclaimed()); @@ -318,11 +345,10 @@ codec->set_tick_clock_for_testing(base::DefaultTickClock::GetInstance()); } -TEST_F(ReclaimBackgroundOnlyTest, RepeatLifecycleEventsDontBreakState) { +TEST_P(ReclaimBackgroundOnlyTest, RepeatLifecycleEventsDontBreakState) { V8TestingScope v8_scope; - auto* codec = MakeGarbageCollected<FakeReclaimableCodec>( - v8_scope.GetExecutionContext()); + auto* codec = CreateCodec(v8_scope.GetExecutionContext()); // Test codec should start in foreground when kOnlyReclaimBackgroundWebCodecs // enabled. @@ -333,14 +359,15 @@ scheduler::SchedulingLifecycleState::kNotThrottled); EXPECT_FALSE(codec->is_backgrounded_for_testing()); - // Codecs should not be reclaimable for inactivity until first activity. + // Codecs should not be reclaimable until pressure is exceeded. EXPECT_FALSE(codec->IsReclamationTimerActiveForTesting()); base::SimpleTestTickClock tick_clock; codec->set_tick_clock_for_testing(&tick_clock); - // First activity should not start timer while we remain in foreground. - codec->SimulateActivity(); + // Applying pressure should not start the timer while we remain in the + // foreground. + codec->ApplyCodecPressure(); EXPECT_FALSE(codec->IsReclamationTimerActiveForTesting()); EXPECT_FALSE(codec->is_backgrounded_for_testing()); EXPECT_FALSE(codec->reclaimed()); @@ -353,7 +380,7 @@ EXPECT_FALSE(codec->reclaimed()); // Advancing 1 period shouldn't reclaim (it takes 2). - tick_clock.Advance(ReclaimableCodec::kTimerPeriod); + tick_clock.Advance(kTimerPeriod); codec->SimulateActivityTimerFiredForTesting(); EXPECT_FALSE(codec->reclaimed()); @@ -372,7 +399,7 @@ EXPECT_FALSE(codec->reclaimed()); // Advancing one final time through the period should finally reclaim. - tick_clock.Advance(ReclaimableCodec::kTimerPeriod); + tick_clock.Advance(kTimerPeriod); codec->SimulateActivityTimerFiredForTesting(); EXPECT_TRUE(codec->is_backgrounded_for_testing()); EXPECT_TRUE(codec->reclaimed()); @@ -382,29 +409,28 @@ codec->set_tick_clock_for_testing(base::DefaultTickClock::GetInstance()); } -TEST_F(ReclaimDisabledTest, ReclamationKillSwitch) { +TEST_P(ReclaimDisabledTest, ReclamationKillSwitch) { V8TestingScope v8_scope; - auto* codec = MakeGarbageCollected<FakeReclaimableCodec>( - v8_scope.GetExecutionContext()); + auto* codec = CreateCodec(v8_scope.GetExecutionContext()); // Test codec should start in background when kOnlyReclaimBackgroundWebCodecs // is disabled. EXPECT_TRUE(codec->is_backgrounded_for_testing()); - // Codecs should not be reclaimable for inactivity until first activity. + // Codecs should not be reclaimable until pressure is applied. EXPECT_FALSE(codec->IsReclamationTimerActiveForTesting()); base::SimpleTestTickClock tick_clock; codec->set_tick_clock_for_testing(&tick_clock); - // Reclamation disabled, so activity should not start the timer. - codec->SimulateActivity(); + // Reclamation disabled, so applying pressure should not start the timer. + codec->ApplyCodecPressure(); EXPECT_FALSE(codec->IsReclamationTimerActiveForTesting()); EXPECT_FALSE(codec->reclaimed()); // Advancing any period should not be enough to reclaim the codec. - tick_clock.Advance(ReclaimableCodec::kTimerPeriod * 10); + tick_clock.Advance(kTimerPeriod * 10); EXPECT_FALSE(codec->reclaimed()); // Restore default tick clock since |codec| is a garbage collected object that @@ -412,4 +438,64 @@ codec->set_tick_clock_for_testing(base::DefaultTickClock::GetInstance()); } +TEST_P(ReclaimBackgroundOnlyTest, PressureChangesUpdateTimer) { + V8TestingScope v8_scope; + + auto* codec = CreateCodec(v8_scope.GetExecutionContext()); + + // Test codec should start in foreground when kOnlyReclaimBackgroundWebCodecs + // enabled. + EXPECT_FALSE(codec->is_backgrounded_for_testing()); + + // Codecs should not apply pressure by default. + EXPECT_FALSE(codec->is_applying_codec_pressure()); + + // Codecs should not be reclaimable by default. + EXPECT_FALSE(codec->IsReclamationTimerActiveForTesting()); + + // The codec must be backgrounded for the timer to be active. + codec->SimulateLifecycleStateForTesting( + scheduler::SchedulingLifecycleState::kHidden); + EXPECT_TRUE(codec->is_backgrounded_for_testing()); + EXPECT_FALSE(codec->IsReclamationTimerActiveForTesting()); + + // Applying codec pressure should start the timer. + codec->ApplyCodecPressure(); + EXPECT_TRUE(codec->is_applying_codec_pressure()); + EXPECT_TRUE(codec->IsReclamationTimerActiveForTesting()); + + // Releasing codec pressure should stop the timer. + codec->ReleaseCodecPressure(); + EXPECT_FALSE(codec->is_applying_codec_pressure()); + EXPECT_FALSE(codec->IsReclamationTimerActiveForTesting()); + + // Re-applying codec pressure should start the timer. + codec->ApplyCodecPressure(); + EXPECT_TRUE(codec->is_applying_codec_pressure()); + EXPECT_TRUE(codec->IsReclamationTimerActiveForTesting()); + + // Re-releasing codec pressure should stop the timer. + codec->ReleaseCodecPressure(); + EXPECT_FALSE(codec->is_applying_codec_pressure()); + EXPECT_FALSE(codec->IsReclamationTimerActiveForTesting()); +} + +INSTANTIATE_TEST_SUITE_P( + , + ReclaimBackgroundOnlyTest, + testing::Values(ReclaimableCodec::CodecType::kDecoder, + ReclaimableCodec::CodecType::kEncoder)); + +INSTANTIATE_TEST_SUITE_P( + , + ReclaimForegroundSameAsBackgroundTest, + testing::Values(ReclaimableCodec::CodecType::kDecoder, + ReclaimableCodec::CodecType::kEncoder)); + +INSTANTIATE_TEST_SUITE_P( + , + ReclaimDisabledTest, + testing::Values(ReclaimableCodec::CodecType::kDecoder, + ReclaimableCodec::CodecType::kEncoder)); + } // namespace blink
diff --git a/third_party/blink/renderer/modules/webcodecs/video_decoder_test.cc b/third_party/blink/renderer/modules/webcodecs/video_decoder_test.cc new file mode 100644 index 0000000..d5a8785 --- /dev/null +++ b/third_party/blink/renderer/modules/webcodecs/video_decoder_test.cc
@@ -0,0 +1,197 @@ +// Copyright 2021 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 "third_party/blink/renderer/modules/webcodecs/video_decoder.h" + +#include "base/threading/sequenced_task_runner_handle.h" +#include "build/build_config.h" +#include "media/base/mock_filters.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "third_party/blink/renderer/bindings/core/v8/script_function.h" +#include "third_party/blink/renderer/bindings/core/v8/script_promise_tester.h" +#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h" +#include "third_party/blink/renderer/bindings/modules/v8/v8_video_decoder_config.h" +#include "third_party/blink/renderer/bindings/modules/v8/v8_video_decoder_init.h" +#include "third_party/blink/renderer/core/testing/mock_function_scope.h" +#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h" + +// For FakeVideoDecoder. +#if BUILDFLAG(USE_PROPRIETARY_CODECS) +#include "media/filters/h264_to_annex_b_bitstream_converter.h" // nogncheck +#include "media/formats/mp4/box_definitions.h" // nogncheck +#endif + +namespace blink { + +namespace { + +using testing::_; +using testing::Unused; + +class FakeVideoDecoder : public VideoDecoder { + public: + FakeVideoDecoder(ScriptState* script_state, + const VideoDecoderInit* init, + ExceptionState& exception_state) + : VideoDecoder(script_state, init, exception_state) {} + ~FakeVideoDecoder() override = default; + + void SetupMockHardwareDecoder(base::RepeatingClosure quit_closure) { + mock_decoder_ = std::make_unique<media::MockVideoDecoder>( + /*is_platform_decoder=*/true, /*supports_decription=*/false, + /*decoder_id=*/1); + SetupExpectations(std::move(quit_closure)); + } + + void SetupMockSoftwareDecoder(base::RepeatingClosure quit_closure) { + mock_decoder_ = std::make_unique<media::MockVideoDecoder>( + /*is_platform_decoder=*/false, /*supports_decription=*/false, + /*decoder_id=*/2); + SetupExpectations(std::move(quit_closure)); + } + + private: + void SetHardwarePreference(HardwarePreference preference) override {} + + void SetupExpectations(base::RepeatingClosure quit_closure) { + EXPECT_CALL(*mock_decoder_, GetMaxDecodeRequests()) + .WillRepeatedly(testing::Return(4)); + + EXPECT_CALL(*mock_decoder_, Decode_(_, _)) + .WillOnce([](Unused, media::VideoDecoder::DecodeCB& decode_cb) { + base::SequencedTaskRunnerHandle::Get()->PostTask( + FROM_HERE, + base::BindOnce(std::move(decode_cb), media::OkStatus())); + }); + + EXPECT_CALL(*mock_decoder_, Initialize_(_, _, _, _, _, _)) + .WillOnce([quit_closure](Unused, Unused, Unused, + media::VideoDecoder::InitCB& init_cb, Unused, + Unused) { + base::SequencedTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::BindOnce(std::move(init_cb), media::OkStatus())); + base::SequencedTaskRunnerHandle::Get()->PostTask( + FROM_HERE, std::move(quit_closure)); + }); + } + + MediaDecoderType* decoder() override { return mock_decoder_.get(); } + + std::unique_ptr<media::MockVideoDecoder> mock_decoder_; +}; + +class VideoDecoderTest : public testing::Test { + public: + VideoDecoderTest() = default; + ~VideoDecoderTest() override = default; + + FakeVideoDecoder* CreateFakeDecoder(ScriptState* script_state, + VideoDecoderInit* init, + ExceptionState& exception_state) { + return MakeGarbageCollected<FakeVideoDecoder>(script_state, init, + exception_state); + } + + VideoDecoderInit* CreateVideoDecoderInit(MockFunctionScope& mock_functions) { + auto* init = MakeGarbageCollected<VideoDecoderInit>(); + init->setOutput( + V8VideoFrameOutputCallback::Create(mock_functions.ExpectNoCall())); + init->setError( + V8WebCodecsErrorCallback::Create(mock_functions.ExpectNoCall())); + return init; + } + + VideoDecoderConfig* CreateVideoConfig() { + auto* config = MakeGarbageCollected<VideoDecoderConfig>(); + config->setCodec("vp09.00.10.08"); + return config; + } +}; + +TEST_F(VideoDecoderTest, HardwareDecodersApplyPressure) { + V8TestingScope v8_scope; + MockFunctionScope mock_functions(v8_scope.GetScriptState()); + + auto* fake_decoder = CreateFakeDecoder(v8_scope.GetScriptState(), + CreateVideoDecoderInit(mock_functions), + v8_scope.GetExceptionState()); + + ASSERT_TRUE(fake_decoder); + ASSERT_FALSE(v8_scope.GetExceptionState().HadException()); + + ASSERT_FALSE(fake_decoder->is_applying_codec_pressure()); + + { + base::RunLoop run_loop; + fake_decoder->SetupMockHardwareDecoder(run_loop.QuitClosure()); + + fake_decoder->configure(CreateVideoConfig(), v8_scope.GetExceptionState()); + ASSERT_FALSE(v8_scope.GetExceptionState().HadException()); + run_loop.Run(); + } + + // Make sure VideoDecoders apply pressure when configured with a HW decoder. + ASSERT_TRUE(fake_decoder->is_applying_codec_pressure()); + + { + base::RunLoop run_loop; + fake_decoder->SetupMockSoftwareDecoder(run_loop.QuitClosure()); + + fake_decoder->configure(CreateVideoConfig(), v8_scope.GetExceptionState()); + ASSERT_FALSE(v8_scope.GetExceptionState().HadException()); + run_loop.Run(); + } + + // Make sure the pressure is released when reconfigured with a SW decoder. + ASSERT_FALSE(fake_decoder->is_applying_codec_pressure()); +} + +TEST_F(VideoDecoderTest, ResetReleasesPressure) { + V8TestingScope v8_scope; + MockFunctionScope mock_functions(v8_scope.GetScriptState()); + + auto* fake_decoder = CreateFakeDecoder(v8_scope.GetScriptState(), + CreateVideoDecoderInit(mock_functions), + v8_scope.GetExceptionState()); + + ASSERT_TRUE(fake_decoder); + ASSERT_FALSE(v8_scope.GetExceptionState().HadException()); + + // Create a HW decoder. + { + base::RunLoop run_loop; + fake_decoder->SetupMockHardwareDecoder(run_loop.QuitClosure()); + + fake_decoder->configure(CreateVideoConfig(), v8_scope.GetExceptionState()); + ASSERT_FALSE(v8_scope.GetExceptionState().HadException()); + run_loop.Run(); + } + + // Make sure VideoDecoders apply pressure when configured with a HW decoder. + ASSERT_TRUE(fake_decoder->is_applying_codec_pressure()); + + // Satisfy reclamation preconditions. + fake_decoder->SimulateLifecycleStateForTesting( + scheduler::SchedulingLifecycleState::kHidden); + + // The reclamation timer should be running. + EXPECT_TRUE(fake_decoder->IsReclamationTimerActiveForTesting()); + + // Reset the codec. + fake_decoder->reset(v8_scope.GetExceptionState()); + + // The underlying codec might not be internally released. + ASSERT_TRUE(fake_decoder->is_applying_codec_pressure()); + EXPECT_TRUE(fake_decoder->IsReclamationTimerActiveForTesting()); + + // Reclaiming the codec after a period of inactivity should release pressure. + fake_decoder->SimulateCodecReclaimedForTesting(); + ASSERT_FALSE(fake_decoder->is_applying_codec_pressure()); + EXPECT_FALSE(fake_decoder->IsReclamationTimerActiveForTesting()); +} + +} // namespace + +} // namespace blink
diff --git a/third_party/blink/renderer/modules/webcodecs/video_encoder.cc b/third_party/blink/renderer/modules/webcodecs/video_encoder.cc index ef91364..60197fc 100644 --- a/third_party/blink/renderer/modules/webcodecs/video_encoder.cc +++ b/third_party/blink/renderer/modules/webcodecs/video_encoder.cc
@@ -452,8 +452,13 @@ return VerifyCodecSupportStatic(config, &exception_state); } -void VideoEncoder::UpdateEncoderLog(std::string encoder_name, - bool is_hw_accelerated) { +void VideoEncoder::OnMediaEncoderCreated(std::string encoder_name, + bool is_hw_accelerated) { + if (is_hw_accelerated) + ApplyCodecPressure(); + else + ReleaseCodecPressure(); + // TODO(https://crbug.com/1139089) : Add encoder properties. media::MediaLog* log = logger_->log(); @@ -511,16 +516,16 @@ switch (codec) { case media::VideoCodec::kAV1: result = CreateAv1VideoEncoder(); - self->UpdateEncoderLog("Av1VideoEncoder", false); + self->OnMediaEncoderCreated("Av1VideoEncoder", false); break; case media::VideoCodec::kVP8: case media::VideoCodec::kVP9: result = CreateVpxVideoEncoder(); - self->UpdateEncoderLog("VpxVideoEncoder", false); + self->OnMediaEncoderCreated("VpxVideoEncoder", false); break; case media::VideoCodec::kH264: result = CreateOpenH264VideoEncoder(); - self->UpdateEncoderLog("OpenH264VideoEncoder", false); + self->OnMediaEncoderCreated("OpenH264VideoEncoder", false); break; default: break; @@ -538,13 +543,13 @@ auto result = CreateAcceleratedVideoEncoder( config.profile, config.options, gpu_factories); if (result) - UpdateEncoderLog("AcceleratedVideoEncoder", true); + OnMediaEncoderCreated("AcceleratedVideoEncoder", true); return result; } case HardwarePreference::kNoPreference: if (auto result = CreateAcceleratedVideoEncoder( config.profile, config.options, gpu_factories)) { - UpdateEncoderLog("AcceleratedVideoEncoder", true); + OnMediaEncoderCreated("AcceleratedVideoEncoder", true); return std::make_unique<media::VideoEncoderFallback>( std::move(result), ConvertToBaseOnceCallback(CrossThreadBindOnce(
diff --git a/third_party/blink/renderer/modules/webcodecs/video_encoder.h b/third_party/blink/renderer/modules/webcodecs/video_encoder.h index 2b4f9e0..cb3d786 100644 --- a/third_party/blink/renderer/modules/webcodecs/video_encoder.h +++ b/third_party/blink/renderer/modules/webcodecs/video_encoder.h
@@ -60,8 +60,7 @@ static const char* GetName(); }; -class MODULES_EXPORT VideoEncoder final - : public EncoderBase<VideoEncoderTraits> { +class MODULES_EXPORT VideoEncoder : public EncoderBase<VideoEncoderTraits> { DEFINE_WRAPPERTYPEINFO(); public: @@ -77,7 +76,7 @@ // ScriptWrappable override. bool HasPendingActivity() const override; - private: + protected: using Base = EncoderBase<VideoEncoderTraits>; using ParsedConfig = VideoEncoderTraits::ParsedConfig; @@ -92,7 +91,7 @@ void ProcessReconfigure(Request* request) override; void ResetInternal() override; - void UpdateEncoderLog(std::string encoder_name, bool is_hw_accelerated); + void OnMediaEncoderCreated(std::string encoder_name, bool is_hw_accelerated); static std::unique_ptr<media::VideoEncoder> CreateSoftwareVideoEncoder( VideoEncoder* self, media::VideoCodec codec); @@ -101,6 +100,11 @@ ExceptionState&) override; bool VerifyCodecSupport(ParsedConfig*, ExceptionState&) override; + // Virtual for UTs. + virtual std::unique_ptr<media::VideoEncoder> CreateMediaVideoEncoder( + const ParsedConfig& config, + media::GpuVideoAcceleratorFactories* gpu_factories); + void ContinueConfigureWithGpuFactories( Request* request, media::GpuVideoAcceleratorFactories* gpu_factories); @@ -108,9 +112,6 @@ media::VideoCodecProfile profile, const media::VideoEncoder::Options& options, media::GpuVideoAcceleratorFactories* gpu_factories); - std::unique_ptr<media::VideoEncoder> CreateMediaVideoEncoder( - const ParsedConfig& config, - media::GpuVideoAcceleratorFactories* gpu_factories); bool CanReconfigure(ParsedConfig& original_config, ParsedConfig& new_config) override; scoped_refptr<media::VideoFrame> ReadbackTextureBackedFrameToMemory(
diff --git a/third_party/blink/renderer/modules/webcodecs/video_encoder_test.cc b/third_party/blink/renderer/modules/webcodecs/video_encoder_test.cc index 692d81c..aca6d71d 100644 --- a/third_party/blink/renderer/modules/webcodecs/video_encoder_test.cc +++ b/third_party/blink/renderer/modules/webcodecs/video_encoder_test.cc
@@ -4,6 +4,7 @@ #include "third_party/blink/renderer/modules/webcodecs/video_encoder.h" +#include "media/base/mock_filters.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/blink/renderer/bindings/core/v8/script_function.h" @@ -25,6 +26,50 @@ namespace { +using testing::_; +using testing::Return; +using testing::Unused; + +class FakeVideoEncoder : public VideoEncoder { + public: + FakeVideoEncoder(ScriptState* script_state, + const VideoEncoderInit* init, + ExceptionState& exception_state) + : VideoEncoder(script_state, init, exception_state) {} + ~FakeVideoEncoder() override = default; + + void SetupMockEncoderCreation(bool is_hw_accelerated, + base::RepeatingClosure quit_closure) { + next_mock_encoder_ = std::make_unique<media::MockVideoEncoder>(); + mock_encoder_is_hw_ = is_hw_accelerated; + SetupExpectations(quit_closure); + } + + private: + void SetupExpectations(base::RepeatingClosure quit_closure) { + EXPECT_CALL(*next_mock_encoder_, Initialize(_, _, _, _)) + .WillOnce([quit_closure](Unused, Unused, Unused, + media::VideoEncoder::EncoderStatusCB done_cb) { + base::SequencedTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::BindOnce(std::move(done_cb), + media::EncoderStatus::Codes::kOk)); + base::SequencedTaskRunnerHandle::Get()->PostTask( + FROM_HERE, std::move(quit_closure)); + }); + } + + std::unique_ptr<media::VideoEncoder> CreateMediaVideoEncoder( + const ParsedConfig& config, + media::GpuVideoAcceleratorFactories* gpu_factories) override { + EXPECT_TRUE(next_mock_encoder_); + OnMediaEncoderCreated("MockEncoderName", mock_encoder_is_hw_); + return std::move(next_mock_encoder_); + } + + bool mock_encoder_is_hw_; + std::unique_ptr<media::MockVideoEncoder> next_mock_encoder_; +}; + class VideoEncoderTest : public testing::Test { public: VideoEncoderTest() = default; @@ -46,6 +91,13 @@ exception_state); } +FakeVideoEncoder* CreateFakeEncoder(ScriptState* script_state, + const VideoEncoderInit* init, + ExceptionState& exception_state) { + return MakeGarbageCollected<FakeVideoEncoder>(script_state, init, + exception_state); +} + VideoEncoderInit* CreateInit(v8::Local<v8::Function> output_callback, v8::Local<v8::Function> error_callback) { auto* init = MakeGarbageCollected<VideoEncoderInit>(); @@ -130,8 +182,8 @@ // Create a video encoder. auto* init = - CreateInit(mock_function.ExpectNoCall(), mock_function.ExpectCall()); - auto* encoder = CreateEncoder(script_state, init, es); + CreateInit(mock_function.ExpectNoCall(), mock_function.ExpectNoCall()); + auto* encoder = CreateFakeEncoder(script_state, init, es); ASSERT_FALSE(es.HadException()); // Simulate backgrounding to enable reclamation. @@ -141,40 +193,35 @@ DCHECK(encoder->is_backgrounded_for_testing()); } + // Make sure VideoEncoder doesn't apply pressure by default. + EXPECT_FALSE(encoder->is_applying_codec_pressure()); + auto* config = CreateConfig(); - encoder->configure(config, es); - ASSERT_FALSE(es.HadException()); { - // We need this to make sure that configuration has completed. - auto promise = encoder->flush(es); - ScriptPromiseTester tester(script_state, promise); - tester.WaitUntilSettled(); - ASSERT_TRUE(tester.IsFulfilled()); + base::RunLoop run_loop; + encoder->SetupMockEncoderCreation(true, run_loop.QuitClosure()); + + encoder->configure(config, es); + ASSERT_FALSE(es.HadException()); + run_loop.Run(); } - // The encoder should be active, for reclamation purposes. - ASSERT_TRUE(encoder->IsReclamationTimerActiveForTesting()); + // Make sure VideoEncoders apply pressure when configured with a HW encoder. + EXPECT_TRUE(encoder->is_applying_codec_pressure()); - // Resetting the encoder should prevent codec reclamation, silently. - encoder->reset(es); - ASSERT_FALSE(encoder->IsReclamationTimerActiveForTesting()); - - // Reconfiguring the encoder should restart the reclamation timer. - encoder->configure(config, es); - ASSERT_FALSE(es.HadException()); + // Change codec to avoid a pure reconfigure. + config->setCodec("avc1.42001E"); { - // We need this to make sure that configuration has completed. - auto promise = encoder->flush(es); - ScriptPromiseTester tester(script_state, promise); - tester.WaitUntilSettled(); - ASSERT_TRUE(tester.IsFulfilled()); + base::RunLoop run_loop; + encoder->SetupMockEncoderCreation(false, run_loop.QuitClosure()); + + encoder->configure(config, es); + ASSERT_FALSE(es.HadException()); + run_loop.Run(); } - ASSERT_TRUE(encoder->IsReclamationTimerActiveForTesting()); - - // Reclaiming a configured encoder should call the error callback. - encoder->SimulateCodecReclaimedForTesting(); - ASSERT_FALSE(encoder->IsReclamationTimerActiveForTesting()); + // Make sure the pressure is released when reconfigured with a SW encoder. + EXPECT_FALSE(encoder->is_applying_codec_pressure()); } } // namespace
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 28da55d..abc5e63 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
@@ -39,23 +39,6 @@ ResourceLoadInfoNotifierWrapper::~ResourceLoadInfoNotifierWrapper() = default; -#if defined(OS_ANDROID) -void ResourceLoadInfoNotifierWrapper::NotifyUpdateUserGestureCarryoverInfo() { - DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); - if (task_runner_->BelongsToCurrentThread()) { - if (weak_wrapper_resource_load_info_notifier_) { - weak_wrapper_resource_load_info_notifier_ - ->NotifyUpdateUserGestureCarryoverInfo(); - } - return; - } - task_runner_->PostTask( - FROM_HERE, base::BindOnce(&mojom::ResourceLoadInfoNotifier:: - NotifyUpdateUserGestureCarryoverInfo, - weak_wrapper_resource_load_info_notifier_)); -} -#endif - void ResourceLoadInfoNotifierWrapper::NotifyResourceLoadInitiated( int64_t request_id, const GURL& request_url,
diff --git a/third_party/blink/renderer/platform/exported/weak_wrapper_resource_load_info_notifier.cc b/third_party/blink/renderer/platform/exported/weak_wrapper_resource_load_info_notifier.cc index 3bc90ec..74e1ee1 100644 --- a/third_party/blink/renderer/platform/exported/weak_wrapper_resource_load_info_notifier.cc +++ b/third_party/blink/renderer/platform/exported/weak_wrapper_resource_load_info_notifier.cc
@@ -24,14 +24,6 @@ redirect_info, std::move(redirect_response)); } -#if defined(OS_ANDROID) -void WeakWrapperResourceLoadInfoNotifier:: - NotifyUpdateUserGestureCarryoverInfo() { - DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); - resource_load_info_notifier_->NotifyUpdateUserGestureCarryoverInfo(); -} -#endif - void WeakWrapperResourceLoadInfoNotifier::NotifyResourceResponseReceived( int64_t request_id, const GURL& final_url,
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 3d0443ea..3fb67038 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
@@ -259,15 +259,6 @@ WebBackForwardCacheLoaderHelper back_forward_cache_loader_helper) { CheckSchemeForReferrerPolicy(*request); -#if defined(OS_ANDROID) - // Main frame shouldn't come here. - DCHECK(!(request->is_main_frame && - IsRequestDestinationFrame(request->destination))); - if (request->has_user_gesture) { - resource_load_info_notifier_wrapper->NotifyUpdateUserGestureCarryoverInfo(); - } -#endif - // Compute a unique request_id for this renderer process. int request_id = MakeRequestID(); request_info_ = std::make_unique<PendingRequestInfo>(
diff --git a/third_party/blink/renderer/platform/loader/fetch/url_loader/worker_main_script_loader_unittest.cc b/third_party/blink/renderer/platform/loader/fetch/url_loader/worker_main_script_loader_unittest.cc index 8ed7f468..1afb0b5 100644 --- a/third_party/blink/renderer/platform/loader/fetch/url_loader/worker_main_script_loader_unittest.cc +++ b/third_party/blink/renderer/platform/loader/fetch/url_loader/worker_main_script_loader_unittest.cc
@@ -115,9 +115,6 @@ const FakeResourceLoadInfoNotifier&) = delete; // blink::mojom::ResourceLoadInfoNotifier overrides. -#if defined(OS_ANDROID) - void NotifyUpdateUserGestureCarryoverInfo() override {} -#endif void NotifyResourceRedirectReceived( const net::RedirectInfo& redirect_info, network::mojom::URLResponseHeadPtr redirect_response) override {}
diff --git a/third_party/blink/renderer/platform/scheduler/main_thread/frame_scheduler_impl.cc b/third_party/blink/renderer/platform/scheduler/main_thread/frame_scheduler_impl.cc index e8e82492a8..49ec61ed 100644 --- a/third_party/blink/renderer/platform/scheduler/main_thread/frame_scheduler_impl.cc +++ b/third_party/blink/renderer/platform/scheduler/main_thread/frame_scheduler_impl.cc
@@ -211,7 +211,7 @@ queue->DetachFromMainThreadScheduler(); DCHECK(!queue->GetFrameScheduler()); - queue->GetTaskQueue()->SetBlameContext(nullptr); + queue->SetBlameContext(nullptr); } } // namespace @@ -567,7 +567,7 @@ scoped_refptr<MainThreadTaskQueue> task_queue = frame_task_queue_controller_->NewResourceLoadingTaskQueue(); resource_loading_task_queue_priorities_.insert( - task_queue, task_queue->GetTaskQueue()->GetQueuePriority()); + task_queue, task_queue->GetQueuePriority()); return ResourceLoadingTaskRunnerHandleImpl::WrapTaskRunner(task_queue); } @@ -788,8 +788,7 @@ frame_task_queue_controller_->GetAllTaskQueuesAndVoters()) { auto* task_queue = task_queue_and_voter.first; if (task_queue->CanBeFrozen()) { - task_queue->GetTaskQueue()->SetShouldReportPostedTasksWhenDisabled( - should_report); + task_queue->SetShouldReportPostedTasksWhenDisabled(should_report); } } } @@ -1181,7 +1180,7 @@ base::sequence_manager::TaskQueue::QueueEnabledVoter* voter) { DCHECK(parent_page_scheduler_); - task_queue->GetTaskQueue()->SetBlameContext(blame_context_); + task_queue->SetBlameContext(blame_context_); UpdateQueuePolicy(task_queue, voter); if (task_queue->CanBeThrottled()) {
diff --git a/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.cc b/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.cc index 9d61067..87f90d6 100644 --- a/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.cc +++ b/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.cc
@@ -1415,8 +1415,7 @@ if (pair.first->GetPrioritisationType() == MainThreadTaskQueue::QueueTraits::PrioritisationType:: kCompositor && - pair.first->GetTaskQueue() - ->HasTaskToRunImmediatelyOrReadyDelayedTask()) + pair.first->HasTaskToRunImmediatelyOrReadyDelayedTask()) return true; } return main_thread_only().blocking_input_expected_soon; @@ -2227,11 +2226,11 @@ // // TODO(altimin): automatically enter top-level for all task queues associated // with renderer scheduler which do not have a corresponding frame. - control_task_queue_->GetTaskQueue()->SetBlameContext(blame_context); - DefaultTaskQueue()->GetTaskQueue()->SetBlameContext(blame_context); - compositor_task_queue_->GetTaskQueue()->SetBlameContext(blame_context); + control_task_queue_->SetBlameContext(blame_context); + DefaultTaskQueue()->SetBlameContext(blame_context); + compositor_task_queue_->SetBlameContext(blame_context); idle_helper_.IdleTaskRunner()->SetBlameContext(blame_context); - v8_task_queue_->GetTaskQueue()->SetBlameContext(blame_context); + v8_task_queue_->SetBlameContext(blame_context); } void MainThreadSchedulerImpl::AddRAILModeObserver(RAILModeObserver* observer) {
diff --git a/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_task_queue.cc b/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_task_queue.cc index 4ca1809..d19711a 100644 --- a/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_task_queue.cc +++ b/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_task_queue.cc
@@ -199,8 +199,7 @@ task_queue_->SetOnTaskCompletedHandler( base::BindRepeating(&MainThreadSchedulerImpl::OnTaskCompleted, main_thread_scheduler_->GetWeakPtr(), nullptr)); - task_queue_->SetOnTaskPostedHandler( - internal::TaskQueueImpl::OnTaskPostedHandler()); + on_ipc_task_posted_callback_handle_.reset(); task_queue_->SetTaskExecutionTraceLogger( internal::TaskQueueImpl::TaskExecutionTraceLogger()); @@ -210,18 +209,14 @@ void MainThreadTaskQueue::SetOnIPCTaskPosted( base::RepeatingCallback<void(const base::sequence_manager::Task&)> on_ipc_task_posted_callback) { - if (task_queue_->HasImpl()) { - // We use the frame_scheduler_ to track metrics so as to ensure that metrics - // are not tied to individual task queues. - task_queue_->SetOnTaskPostedHandler(on_ipc_task_posted_callback); - } + // We use the frame_scheduler_ to track metrics so as to ensure that metrics + // are not tied to individual task queues. + on_ipc_task_posted_callback_handle_ = task_queue_->AddOnTaskPostedHandler( + std::move(on_ipc_task_posted_callback)); } void MainThreadTaskQueue::DetachOnIPCTaskPostedWhileInBackForwardCache() { - if (task_queue_->HasImpl()) { - task_queue_->SetOnTaskPostedHandler( - internal::TaskQueueImpl::OnTaskPostedHandler()); - } + on_ipc_task_posted_callback_handle_.reset(); } void MainThreadTaskQueue::ShutdownTaskQueue() {
diff --git a/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_task_queue.h b/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_task_queue.h index eaee4d0..675c60eb 100644 --- a/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_task_queue.h +++ b/third_party/blink/renderer/platform/scheduler/main_thread/main_thread_task_queue.h
@@ -489,6 +489,18 @@ bool IsQueueEnabled() const { return task_queue_->IsQueueEnabled(); } bool IsEmpty() const { return task_queue_->IsEmpty(); } + bool HasTaskToRunImmediatelyOrReadyDelayedTask() const { + return task_queue_->HasTaskToRunImmediatelyOrReadyDelayedTask(); + } + + void SetBlameContext(base::trace_event::BlameContext* blame_context) { + task_queue_->SetBlameContext(blame_context); + } + + void SetShouldReportPostedTasksWhenDisabled(bool should_report) { + task_queue_->SetShouldReportPostedTasksWhenDisabled(should_report); + } + base::WeakPtr<MainThreadTaskQueue> AsWeakPtr() { return weak_ptr_factory_.GetWeakPtr(); } @@ -552,6 +564,9 @@ // The WakeUpBudgetPool for this TaskQueue, if any. WakeUpBudgetPool* wake_up_budget_pool_{nullptr}; // NOT OWNED + std::unique_ptr<TaskQueue::OnTaskPostedCallbackHandle> + on_ipc_task_posted_callback_handle_; + base::WeakPtrFactory<MainThreadTaskQueue> weak_ptr_factory_{this}; };
diff --git a/third_party/blink/renderer/platform/wtf/vector.h b/third_party/blink/renderer/platform/wtf/vector.h index cdbee39..38e7158 100644 --- a/third_party/blink/renderer/platform/wtf/vector.h +++ b/third_party/blink/renderer/platform/wtf/vector.h
@@ -103,296 +103,6 @@ ANNOTATE_NEW_BUFFER(buffer, capacity, size) #endif // defined(ADDRESS_SANITIZER) -template <bool needsDestruction, typename T> -struct VectorDestructor; - -template <typename T> -struct VectorDestructor<false, T> { - STATIC_ONLY(VectorDestructor); - static void Destruct(T*, T*) {} -}; - -template <typename T> -struct VectorDestructor<true, T> { - STATIC_ONLY(VectorDestructor); - static void Destruct(T* begin, T* end) { - for (T* cur = begin; cur != end; ++cur) - cur->~T(); - } -}; - -template <bool unusedSlotsMustBeZeroed, typename T> -struct VectorUnusedSlotClearer; - -template <typename T> -struct VectorUnusedSlotClearer<false, T> { - STATIC_ONLY(VectorUnusedSlotClearer); - static void Clear(T*, T*) {} -#if DCHECK_IS_ON() - static void CheckCleared(const T*, const T*) {} -#endif -}; - -template <typename T> -struct VectorUnusedSlotClearer<true, T> { - STATIC_ONLY(VectorUnusedSlotClearer); - static void Clear(T* begin, T* end) { - AtomicMemzero(reinterpret_cast<void*>(begin), sizeof(T) * (end - begin)); - } - -#if DCHECK_IS_ON() - static void CheckCleared(const T* begin, const T* end) { - const unsigned char* unused_area = - reinterpret_cast<const unsigned char*>(begin); - const unsigned char* end_address = - reinterpret_cast<const unsigned char*>(end); - DCHECK_GE(end_address, unused_area); - for (int i = 0; i < end_address - unused_area; ++i) - DCHECK(!unused_area[i]); - } -#endif -}; - -template <bool canInitializeWithMemset, typename T, typename Allocator> -struct VectorInitializer; - -template <typename T, typename Allocator> -struct VectorInitializer<false, T, Allocator> { - STATIC_ONLY(VectorInitializer); - static void Initialize(T* begin, T* end) { - for (T* cur = begin; cur != end; ++cur) - ConstructTraits<T, VectorTraits<T>, Allocator>::Construct(cur); - } -}; - -template <typename T, typename Allocator> -struct VectorInitializer<true, T, Allocator> { - STATIC_ONLY(VectorInitializer); - static void Initialize(T* begin, T* end) { - memset(begin, 0, - reinterpret_cast<char*>(end) - reinterpret_cast<char*>(begin)); - } -}; - -template <bool canMoveWithMemcpy, typename T, typename Allocator> -struct VectorMover; - -template <typename T, typename Allocator> -struct VectorMover<false, T, Allocator> { - STATIC_ONLY(VectorMover); - using Traits = ConstructTraits<T, VectorTraits<T>, Allocator>; - static void Move(T* src, T* src_end, T* dst, bool has_inline_buffer) { - while (src != src_end) { - T* newly_created = Traits::Construct(dst, std::move(*src)); - if (has_inline_buffer) - Traits::NotifyNewElement(newly_created); - src->~T(); - ++dst; - ++src; - } - } - static void MoveOverlapping(T* src, - T* src_end, - T* dst, - bool has_inline_buffer) { - if (src > dst) { - Move(src, src_end, dst, has_inline_buffer); - } else { - T* dst_end = dst + (src_end - src); - while (src != src_end) { - --src_end; - --dst_end; - T* newly_created = Traits::Construct(dst_end, std::move(*src_end)); - if (has_inline_buffer) - Traits::NotifyNewElement(newly_created); - src_end->~T(); - } - } - } - static void Swap(T* src, T* src_end, T* dst) { - std::swap_ranges(src, src_end, dst); - const size_t len = src_end - src; - Traits::NotifyNewElements(src, len); - Traits::NotifyNewElements(dst, len); - } -}; - -template <typename T, typename Allocator> -struct VectorMover<true, T, Allocator> { - STATIC_ONLY(VectorMover); - using Traits = ConstructTraits<T, VectorTraits<T>, Allocator>; - static void MoveImpl(const T* src, const T* src_end, T* dst) { - size_t bytes = reinterpret_cast<const char*>(src_end) - - reinterpret_cast<const char*>(src); - if (Allocator::kIsGarbageCollected) { - AtomicWriteMemcpy(dst, src, bytes); - } else { - memcpy(dst, src, bytes); - } - } - - static void Move(const T* src, - const T* src_end, - T* dst, - bool has_inline_buffer) { - if (LIKELY(dst && src)) { - MoveImpl(src, src_end, dst); - if (has_inline_buffer) - Traits::NotifyNewElements(dst, src_end - src); - } - } - - static void MoveOverlappingImpl(const T* src, const T* src_end, T* dst) { - if (Allocator::kIsGarbageCollected) { - if (src == dst) - return; - if (dst < src) { - for (; src < src_end; ++src, ++dst) - AtomicWriteMemcpy<sizeof(T)>(dst, src); - } else { - --src_end; - T* dst_end = dst + (src_end - src); - for (; src_end >= src; --src_end, --dst_end) - AtomicWriteMemcpy<sizeof(T)>(dst_end, src_end); - } - } else { - memmove(dst, src, - reinterpret_cast<const char*>(src_end) - - reinterpret_cast<const char*>(src)); - } - } - - static void MoveOverlapping(const T* src, - const T* src_end, - T* dst, - bool has_inline_buffer) { - if (LIKELY(dst && src)) { - MoveOverlappingImpl(src, src_end, dst); - if (has_inline_buffer) - Traits::NotifyNewElements(dst, src_end - src); - } - } - - static void SwapImpl(T* src, T* src_end, T* dst) { - if (Allocator::kIsGarbageCollected) { - constexpr size_t boundary = std::max(alignof(T), sizeof(size_t)); - alignas(boundary) char buf[sizeof(T)]; - for (; src < src_end; ++src, ++dst) { - memcpy(buf, dst, sizeof(T)); - AtomicWriteMemcpy<sizeof(T)>(dst, src); - AtomicWriteMemcpy<sizeof(T)>(src, buf); - } - } else { - std::swap_ranges(reinterpret_cast<char*>(src), - reinterpret_cast<char*>(src_end), - reinterpret_cast<char*>(dst)); - } - } - - static void Swap(T* src, T* src_end, T* dst) { - SwapImpl(src, src_end, dst); - const size_t len = src_end - src; - Traits::NotifyNewElements(src, len); - Traits::NotifyNewElements(dst, len); - } -}; - -template <bool canCopyWithMemcpy, typename T, typename Allocator> -struct VectorCopier; - -template <typename T, typename Allocator> -struct VectorCopier<false, T, Allocator> { - STATIC_ONLY(VectorCopier); - static void Copy(const T* src, const T* src_end, T* dst) { - std::copy(src, src_end, dst); - } - - template <typename U> - static void UninitializedCopy(const U* src, const U* src_end, T* dst) { - while (src != src_end) { - ConstructTraits<T, VectorTraits<T>, Allocator>::ConstructAndNotifyElement( - dst, *src); - ++dst; - ++src; - } - } -}; - -template <typename T, typename Allocator> -struct VectorCopier<true, T, Allocator> { - STATIC_ONLY(VectorCopier); - static void Copy(const T* src, const T* src_end, T* dst) { - if (Allocator::kIsGarbageCollected) { - AtomicWriteMemcpy(dst, src, - reinterpret_cast<const char*>(src_end) - - reinterpret_cast<const char*>(src)); - } else { - memcpy(dst, src, - reinterpret_cast<const char*>(src_end) - - reinterpret_cast<const char*>(src)); - } - } - - static void UninitializedCopy(const T* src, const T* src_end, T* dst) { - if (LIKELY(dst && src)) { - Copy(src, src_end, dst); - ConstructTraits<T, VectorTraits<T>, Allocator>::NotifyNewElements( - dst, src_end - src); - } - } - template <typename U> - static void UninitializedCopy(const U* src, const U* src_end, T* dst) { - VectorCopier<false, T, Allocator>::UninitializedCopy(src, src_end, dst); - } -}; - -template <bool canFillWithMemset, typename T, typename Allocator> -struct VectorFiller; - -template <typename T, typename Allocator> -struct VectorFiller<false, T, Allocator> { - STATIC_ONLY(VectorFiller); - static void UninitializedFill(T* dst, T* dst_end, const T& val) { - while (dst != dst_end) { - ConstructTraits<T, VectorTraits<T>, Allocator>::ConstructAndNotifyElement( - dst, T(val)); - ++dst; - } - } -}; - -template <typename T, typename Allocator> -struct VectorFiller<true, T, Allocator> { - STATIC_ONLY(VectorFiller); - static void UninitializedFill(T* dst, T* dst_end, const T& val) { - static_assert(sizeof(T) == sizeof(char), "size of type should be one"); - memset(dst, val, dst_end - dst); - } -}; - -template <bool canCompareWithMemcmp, typename T> -struct VectorComparer; - -template <typename T> -struct VectorComparer<false, T> { - STATIC_ONLY(VectorComparer); - static bool Compare(const T* a, const T* b, size_t size) { - DCHECK(a); - DCHECK(b); - return std::equal(a, a + size, b); - } -}; - -template <typename T> -struct VectorComparer<true, T> { - STATIC_ONLY(VectorComparer); - static bool Compare(const T* a, const T* b, size_t size) { - DCHECK(a); - DCHECK(b); - return memcmp(a, b, sizeof(T) * size) == 0; - } -}; - template <typename T> struct VectorElementComparer { STATIC_ONLY(VectorElementComparer); @@ -418,53 +128,166 @@ template <typename T, typename Allocator> struct VectorTypeOperations { STATIC_ONLY(VectorTypeOperations); + + using ConstructTraits = WTF::ConstructTraits<T, VectorTraits<T>, Allocator>; + static void Destruct(T* begin, T* end) { - VectorDestructor<VectorTraits<T>::kNeedsDestruction, T>::Destruct(begin, - end); + if constexpr (VectorTraits<T>::kNeedsDestruction) { + for (T* cur = begin; cur != end; ++cur) + cur->~T(); + } } static void Initialize(T* begin, T* end) { - VectorInitializer<VectorTraits<T>::kCanInitializeWithMemset, T, - Allocator>::Initialize(begin, end); + if constexpr (VectorTraits<T>::kCanInitializeWithMemset) { + memset(begin, 0, + reinterpret_cast<char*>(end) - reinterpret_cast<char*>(begin)); + } else { + for (T* cur = begin; cur != end; ++cur) + ConstructTraits::Construct(cur); + } } - static void Move(T* src, T* src_end, T* dst, bool has_inline_buffer = true) { - VectorMover<VectorTraits<T>::kCanMoveWithMemcpy, T, Allocator>::Move( - src, src_end, dst, has_inline_buffer); + static void Move(T* const src, + T* const src_end, + T* const dst, + bool has_inline_buffer = true) { + if constexpr (VectorTraits<T>::kCanMoveWithMemcpy) { + if (!LIKELY(src && dst)) + return; + + size_t bytes = reinterpret_cast<const char*>(src_end) - + reinterpret_cast<const char*>(src); + if constexpr (Allocator::kIsGarbageCollected) + AtomicWriteMemcpy(dst, src, bytes); + else + memcpy(dst, src, bytes); + + if (has_inline_buffer) + ConstructTraits::NotifyNewElements(dst, src_end - src); + } else { + for (T *s = src, *d = dst; s != src_end; ++s, ++d) { + T* newly_created = ConstructTraits::Construct(d, std::move(*s)); + if (has_inline_buffer) + ConstructTraits::NotifyNewElement(newly_created); + s->~T(); + } + } } - static void MoveOverlapping(T* src, - T* src_end, - T* dst, + static void MoveOverlapping(T* const src, + T* const src_end, + T* const dst, bool has_inline_buffer = true) { - VectorMover<VectorTraits<T>::kCanMoveWithMemcpy, T, - Allocator>::MoveOverlapping(src, src_end, dst, - has_inline_buffer); + if constexpr (VectorTraits<T>::kCanMoveWithMemcpy) { + if (!LIKELY(src && dst)) + return; + + if constexpr (Allocator::kIsGarbageCollected) { + if (dst < src) { + for (T *s = src, *d = dst; s < src_end; ++s, ++d) + AtomicWriteMemcpy<sizeof(T)>(d, s); + } else if (dst > src) { + T* s = src_end - 1; + T* d = dst + (s - src); + for (; s >= src; --s, --d) + AtomicWriteMemcpy<sizeof(T)>(d, s); + } + } else { + memmove(dst, src, + reinterpret_cast<const char*>(src_end) - + reinterpret_cast<const char*>(src)); + } + + if (has_inline_buffer) + ConstructTraits::NotifyNewElements(dst, src_end - src); + } else { + if (dst < src) { + Move(src, src_end, dst, has_inline_buffer); + } else if (dst > src) { + T* s = src_end - 1; + T* d = dst + (s - src); + for (; s >= src; --s, --d) { + T* newly_created = ConstructTraits::Construct(d, std::move(*s)); + if (has_inline_buffer) + ConstructTraits::NotifyNewElement(newly_created); + s->~T(); + } + } + } } - static void Swap(T* src, T* src_end, T* dst) { - VectorMover<VectorTraits<T>::kCanMoveWithMemcpy, T, Allocator>::Swap( - src, src_end, dst); + static void Swap(T* const src, T* const src_end, T* const dst) { + if constexpr (!VectorTraits<T>::kCanMoveWithMemcpy) { + std::swap_ranges(src, src_end, dst); + } else if constexpr (Allocator::kIsGarbageCollected) { + constexpr size_t boundary = std::max(alignof(T), sizeof(size_t)); + alignas(boundary) char buf[sizeof(T)]; + for (T *s = src, *d = dst; s < src_end; ++s, ++d) { + memcpy(buf, d, sizeof(T)); + AtomicWriteMemcpy<sizeof(T)>(d, s); + AtomicWriteMemcpy<sizeof(T)>(s, buf); + } + } else { + std::swap_ranges(reinterpret_cast<char*>(src), + reinterpret_cast<char*>(src_end), + reinterpret_cast<char*>(dst)); + } + + const size_t len = src_end - src; + ConstructTraits::NotifyNewElements(src, len); + ConstructTraits::NotifyNewElements(dst, len); } static void Copy(const T* src, const T* src_end, T* dst) { - VectorCopier<VectorTraits<T>::kCanCopyWithMemcpy, T, Allocator>::Copy( - src, src_end, dst); + if constexpr (!VectorTraits<T>::kCanCopyWithMemcpy) { + std::copy(src, src_end, dst); + } else if constexpr (Allocator::kIsGarbageCollected) { + AtomicWriteMemcpy(dst, src, + reinterpret_cast<const char*>(src_end) - + reinterpret_cast<const char*>(src)); + } else { + memcpy(dst, src, + reinterpret_cast<const char*>(src_end) - + reinterpret_cast<const char*>(src)); + } } - static void UninitializedCopy(const T* src, const T* src_end, T* dst) { - VectorCopier<VectorTraits<T>::kCanCopyWithMemcpy, T, - Allocator>::UninitializedCopy(src, src_end, dst); + template <typename U> + static void UninitializedCopy(const U* src, const U* src_end, T* dst) { + if constexpr (std::is_same_v<T, U> && VectorTraits<T>::kCanCopyWithMemcpy) { + if (!LIKELY(dst && src)) + return; + Copy(src, src_end, dst); + ConstructTraits::NotifyNewElements(dst, src_end - src); + } else { + while (src != src_end) { + ConstructTraits::ConstructAndNotifyElement(dst, *src); + ++dst; + ++src; + } + } } static void UninitializedFill(T* dst, T* dst_end, const T& val) { - VectorFiller<VectorTraits<T>::kCanFillWithMemset, T, - Allocator>::UninitializedFill(dst, dst_end, val); + if constexpr (VectorTraits<T>::kCanFillWithMemset) { + static_assert(sizeof(T) == sizeof(char), "size of type should be one"); + memset(dst, val, dst_end - dst); + } else { + while (dst != dst_end) { + ConstructTraits::ConstructAndNotifyElement(dst, T(val)); + ++dst; + } + } } static bool Compare(const T* a, const T* b, size_t size) { - return VectorComparer<VectorTraits<T>::kCanCompareWithMemcmp, T>::Compare( - a, b, size); + DCHECK(a); + DCHECK(b); + if constexpr (VectorTraits<T>::kCanCompareWithMemcmp) + return memcmp(a, b, sizeof(T) * size) == 0; + else + return std::equal(a, a + size, b); } template <typename U> @@ -524,7 +347,8 @@ !Allocator::kIsGarbageCollected || IsTraceableInCollectionTrait<VectorTraits<T>>::value, "Type in garbage collected vectors should be traceable in collection"); - VectorUnusedSlotClearer<Allocator::kIsGarbageCollected, T>::Clear(from, to); + if constexpr (Allocator::kIsGarbageCollected) + AtomicMemzero(reinterpret_cast<void*>(from), sizeof(T) * (to - from)); } void CheckUnusedSlots(const T* from, const T* to) { @@ -533,8 +357,15 @@ !Allocator::kIsGarbageCollected || IsTraceableInCollectionTrait<VectorTraits<T>>::value, "Type in garbage collected vectors should be traceable in collection"); - VectorUnusedSlotClearer<Allocator::kIsGarbageCollected, T>::CheckCleared( - from, to); + if constexpr (Allocator::kIsGarbageCollected) { + const unsigned char* unused_area = + reinterpret_cast<const unsigned char*>(from); + const unsigned char* end_address = + reinterpret_cast<const unsigned char*>(to); + DCHECK_GE(end_address, unused_area); + for (; unused_area != end_address; ++unused_area) + DCHECK(!*unused_area); + } #endif } @@ -1950,8 +1781,7 @@ T* dest = end(); MARKING_AWARE_ANNOTATE_CHANGE_SIZE(Allocator, begin(), capacity(), size_, new_size); - VectorCopier<VectorTraits<T>::kCanCopyWithMemcpy, T, - Allocator>::UninitializedCopy(data, &data[data_size], dest); + TypeOperations::UninitializedCopy(data, &data[data_size], dest); size_ = new_size; } @@ -2040,8 +1870,7 @@ new_size); T* spot = begin() + position; TypeOperations::MoveOverlapping(spot, end(), spot + data_size); - VectorCopier<VectorTraits<T>::kCanCopyWithMemcpy, T, - Allocator>::UninitializedCopy(data, &data[data_size], spot); + TypeOperations::UninitializedCopy(data, &data[data_size], spot); size_ = new_size; }
diff --git a/third_party/blink/web_tests/TestExpectations b/third_party/blink/web_tests/TestExpectations index a7b04ca6..f4858a3 100644 --- a/third_party/blink/web_tests/TestExpectations +++ b/third_party/blink/web_tests/TestExpectations
@@ -1136,6 +1136,7 @@ crbug.com/1284270 [ Linux ] external/wpt/css/css-ui/compute-kind-widget-no-fallback-props-001.html [ Failure ] crbug.com/1284270 [ Mac10.12 ] external/wpt/css/css-ui/compute-kind-widget-no-fallback-props-001.html [ Failure ] crbug.com/1284270 [ Mac10.13 ] external/wpt/css/css-ui/compute-kind-widget-no-fallback-props-001.html [ Failure ] +crbug.com/1284270 [ Mac10.14 ] external/wpt/css/css-ui/compute-kind-widget-no-fallback-props-001.html [ Failure ] crbug.com/1284270 [ Mac10.15 ] external/wpt/css/css-ui/compute-kind-widget-no-fallback-props-001.html [ Failure ] crbug.com/1284270 [ Mac11 ] external/wpt/css/css-ui/compute-kind-widget-no-fallback-props-001.html [ Failure ] crbug.com/1284270 [ Mac11-arm64 ] external/wpt/css/css-ui/compute-kind-widget-no-fallback-props-001.html [ Failure ] @@ -3083,13 +3084,12 @@ crbug.com/626703 [ Mac10.15 ] external/wpt/css/css-text/letter-spacing/letter-spacing-bengali-yaphala-001.html [ Failure ] crbug.com/626703 [ Mac11 ] external/wpt/css/css-text/letter-spacing/letter-spacing-bengali-yaphala-001.html [ Failure ] crbug.com/626703 [ Mac11-arm64 ] external/wpt/css/css-text/letter-spacing/letter-spacing-bengali-yaphala-001.html [ Failure ] -crbug.com/626703 [ Mac10.14 ] external/wpt/css/css-ui/compute-kind-widget-no-fallback-props-001.html [ Timeout ] crbug.com/626703 [ Mac10.14 ] external/wpt/html/canvas/element/manual/wide-gamut-canvas/canvas-createImageBitmap-e_srgb.html [ Timeout ] crbug.com/626703 [ Mac10.14 ] external/wpt/html/semantics/forms/form-submission-0/multipart-formdata.window.html [ Timeout ] crbug.com/626703 [ Mac10.14 ] external/wpt/video-rvfc/request-video-frame-callback-during-xr-session.https.html [ Timeout ] crbug.com/626703 [ Mac10.14 ] external/wpt/webxr/ar-module/xrSession_interactionMode.https.html [ Timeout ] -crbug.com/626703 [ Mac10.13 ] virtual/fenced-frame-mparch/wpt_internal/fenced_frame/document-referrer.html [ Timeout Failure ] -crbug.com/626703 [ Mac10.13 ] virtual/fenced-frame-shadow-dom/wpt_internal/fenced_frame/document-referrer.html [ Timeout Failure ] +crbug.com/626703 [ Mac10.13 ] virtual/fenced-frame-mparch/wpt_internal/fenced_frame/document-referrer.html [ Failure Timeout ] +crbug.com/626703 [ Mac10.13 ] virtual/fenced-frame-shadow-dom/wpt_internal/fenced_frame/document-referrer.html [ Failure Timeout ] crbug.com/626703 [ Mac10.14 ] external/wpt/web-share/share-url-invalid.https.html [ Timeout ] crbug.com/626703 [ Mac10.14 ] external/wpt/webxr/depth-sensing/cpu/depth_sensing_cpu_staleView.https.html [ Timeout ] crbug.com/626703 [ Mac10.14 ] virtual/scroll-unification/external/wpt/dom/events/scrolling/overscroll-event-fired-to-document.html [ Timeout ]
diff --git a/third_party/blink/web_tests/WebGPUExpectations b/third_party/blink/web_tests/WebGPUExpectations index d821a933..9f3383c 100644 --- a/third_party/blink/web_tests/WebGPUExpectations +++ b/third_party/blink/web_tests/WebGPUExpectations
@@ -286,6 +286,16 @@ crbug.com/dawn/666 wpt_internal/webgpu/cts.https.html?q=webgpu:api,validation,capability_checks,features,texture_formats:render_bundle_encoder_descriptor_depth_stencil_format:format="depth32float-stencil8";* [ Failure ] crbug.com/dawn/666 wpt_internal/webgpu/cts.https.html?q=webgpu:api,validation,capability_checks,features,texture_formats:texture_descriptor:format="depth24unorm-stencil8";* [ Failure ] crbug.com/dawn/666 wpt_internal/webgpu/cts.https.html?q=webgpu:api,validation,capability_checks,features,texture_formats:texture_descriptor:format="depth32float-stencil8";* [ Failure ] +crbug.com/dawn/666 wpt_internal/webgpu/cts.https.html?q=webgpu:api,validation,createRenderPipeline:depth_stencil_state,depth_aspect,depth_test:isAsync=false;format="stencil8";* [ Failure ] +crbug.com/dawn/666 wpt_internal/webgpu/cts.https.html?q=webgpu:api,validation,createRenderPipeline:depth_stencil_state,depth_aspect,depth_test:isAsync=true;format="stencil8";* [ Failure ] +crbug.com/dawn/666 wpt_internal/webgpu/cts.https.html?q=webgpu:api,validation,createRenderPipeline:depth_stencil_state,depth_aspect,depth_write:isAsync=false;format="stencil8";* [ Failure ] +crbug.com/dawn/666 wpt_internal/webgpu/cts.https.html?q=webgpu:api,validation,createRenderPipeline:depth_stencil_state,depth_aspect,depth_write:isAsync=true;format="stencil8";* [ Failure ] +crbug.com/dawn/666 wpt_internal/webgpu/cts.https.html?q=webgpu:api,validation,createRenderPipeline:depth_stencil_state,format:isAsync=false;format="stencil8" [ Failure ] +crbug.com/dawn/666 wpt_internal/webgpu/cts.https.html?q=webgpu:api,validation,createRenderPipeline:depth_stencil_state,format:isAsync=true;format="stencil8" [ Failure ] +crbug.com/dawn/666 wpt_internal/webgpu/cts.https.html?q=webgpu:api,validation,createRenderPipeline:depth_stencil_state,stencil_aspect,stencil_test:isAsync=false;format="stencil8";* [ Failure ] +crbug.com/dawn/666 wpt_internal/webgpu/cts.https.html?q=webgpu:api,validation,createRenderPipeline:depth_stencil_state,stencil_aspect,stencil_test:isAsync=true;format="stencil8";* [ Failure ] +crbug.com/dawn/666 wpt_internal/webgpu/cts.https.html?q=webgpu:api,validation,createRenderPipeline:depth_stencil_state,stencil_aspect,stencil_write:isAsync=false;format="stencil8";* [ Failure ] +crbug.com/dawn/666 wpt_internal/webgpu/cts.https.html?q=webgpu:api,validation,createRenderPipeline:depth_stencil_state,stencil_aspect,stencil_write:isAsync=true;format="stencil8";* [ Failure ] # Need to clamp depth in shader on Vulkan crbug.com/dawn/1125 [ Linux ] wpt_internal/webgpu/cts.https.html?q=webgpu:api,operation,rendering,depth_clip_clamp:depth_clamp_and_clip:clampDepth=false;writeDepth=true;* [ Failure ] @@ -466,6 +476,8 @@ # (NVIDIA-only) Started failing when the test was added. crbug.com/tint/1287 [ Linux ] wpt_internal/webgpu/cts.https.html?q=webgpu:shader,execution,shader_io,shared_structs:shared_between_stages:* [ Failure ] +crbug.com/dawn/1256 [ Linux ] wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:* [ Crash ] + ### ### Windows (D3D12) specific ###
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 6d1c51b..daed6473 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
@@ -64012,6 +64012,19 @@ ] }, "text": { + "bidi-flag-emoji-02.html": [ + "d6c92b903c6655670e7d38b279a245eda4c428e9", + [ + null, + [ + [ + "/css/CSS2/text/bidi-flag-emoji-02-ref.html", + "==" + ] + ], + {} + ] + ], "bidi-flag-emoji.html": [ "a184db265942723a7728030390cedf2eccaa15f2", [ @@ -117643,6 +117656,32 @@ ] ] }, + "grid-with-content-dynamic-display-001.html": [ + "e9f121b000202f00e81aff0debd3d4b799d616b9", + [ + null, + [ + [ + "/css/reference/ref-filled-green-100px-square-only.html", + "==" + ] + ], + {} + ] + ], + "grid-with-content-dynamic-display-002.html": [ + "02f536344d86f9572bcf2a095dcdcc4cb56181fa", + [ + null, + [ + [ + "/css/reference/ref-filled-green-100px-square-only.html", + "==" + ] + ], + {} + ] + ], "grid-with-dynamic-img.html": [ "ff7d2b8069c74e43ec10e72d4709c661e7874d97", [ @@ -238894,6 +238933,10 @@ "53463b38f4154029f9fadf7c337119f9828f57b4", [] ], + "bidi-flag-emoji-02-ref.html": [ + "f1ea3145d3a0824c96727d337d1dcf2c89070832", + [] + ], "bidi-flag-emoji-ref.html": [ "84585a264fd30383a5b60839185b1151b08c6bd0", [] @@ -277182,8 +277225,8 @@ "71a19de6904fd6fc6ef706a21a08168d65f87158", [] ], - "open-consume-activation.https.html.headers": [ - "63b60e490f47f4db77d33d7a4ca2f5b9a4181de8", + "direct-sockets-disabled-by-permissions-policy.https.sub.html.headers": [ + "ba6f09f55b393880aadf79a41d9220313ed294c8", [] ], "open-without-user-gesture.https.html.headers": [ @@ -288434,7 +288477,7 @@ ], "resources": { "common.js": [ - "86de148321d15b38a52cf1a0562de617e1633327", + "e11e2307defd6e4bba7006e2add47e7aad965a6f", [] ], "serviceworker-partitioning-helper.js": [ @@ -302536,7 +302579,7 @@ ] }, "lint.ignore": [ - "8078f2622c5ab831a2afb428505f9f03bb79fc7f", + "b9973747dc6ca675b335a0d01350d214c71503ca", [] ], "loading": { @@ -309129,6 +309172,10 @@ "6c61a34a4ec2e75096db0eb9f7748b142f0db7bb", [] ], + "mock-direct-sockets.js": [ + "caab177b9869d88aa00bafc55ca5f36725449bd2", + [] + ], "mock-facedetection.js": [ "7ae658621ee9c34b9dc1091777ef4ccaff950a02", [] @@ -386498,8 +386545,8 @@ ] }, "direct-sockets": { - "open-consume-activation.https.html": [ - "6cbf017712b197886fb2d8d620927ee03506f6d4", + "direct-sockets-disabled-by-permissions-policy.https.sub.html": [ + "03760e795027cc2c63257ca56f3256c31c74d637", [ null, { @@ -442149,6 +442196,36 @@ } ] ], + "broadcast-channel.tentative.window.js": [ + "255a71920992328cf3e3b504a2a20aeda8b45f6f", + [ + "html/cross-origin-embedder-policy/anonymous-iframe/broadcast-channel.tentative.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" + ] + ] + } + ] + ], "cookie-store.tentative.https.window.js": [ "60a856c7584681d20d12b72dcd951cd4fd43e2a1", [ @@ -442272,6 +442349,36 @@ } ] ], + "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", [ @@ -442285,6 +442392,36 @@ ] } ] + ], + "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": [
diff --git a/third_party/blink/web_tests/external/wpt/css/css-grid/grid-with-content-dynamic-display-001.html b/third_party/blink/web_tests/external/wpt/css/css-grid/grid-with-content-dynamic-display-001.html new file mode 100644 index 0000000..e9f121b --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-grid/grid-with-content-dynamic-display-001.html
@@ -0,0 +1,50 @@ +<!doctype html> +<html> +<head> +<meta charset="utf-8"> +<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1740702"> +<link rel="match" href="../reference/ref-filled-green-100px-square-only.html"> +<style> + #grid { + display: grid; + width: 100px; + height: 100px; + background: red; + } + + #initiallyHidden { + display: none; + width: 100px; + height: 100px; + background: green; + } +</style> +</head> +<body> + <p>Test passes if there is a filled green square.</p> + <div id="grid"> + <div> + <div> + <div> + <div id="initiallyHidden"> + </div> + </div> + </div> + </div> + </div> + <script> + "use strict"; + + const grid = document.getElementById("grid"); + const initiallyHidden = document.getElementById("initiallyHidden"); + document.documentElement.offsetHeight; // Flush layout + + // Fails in buggy Firefox build because it prevents reflows from happening + getComputedStyle(grid).getPropertyValue("grid-template-columns"); + + document.documentElement.offsetHeight; // Flush layout again + + initiallyHidden.style.display = "block"; // This should trigger a reflow. + </script> +</body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-grid/grid-with-content-dynamic-display-002.html b/third_party/blink/web_tests/external/wpt/css/css-grid/grid-with-content-dynamic-display-002.html new file mode 100644 index 0000000..02f5363 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-grid/grid-with-content-dynamic-display-002.html
@@ -0,0 +1,50 @@ +<!doctype html> +<html> +<head> +<meta charset="utf-8"> +<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1740702"> +<link rel="match" href="../reference/ref-filled-green-100px-square-only.html"> +<style> + #grid { + display: grid; + width: 100px; + height: 90px; + background: red; + } + + #initiallyHidden { + display: none; + width: 100px; + height: 100px; + background: green; + } +</style> +</head> +<body> + <p>Test passes if there is a filled green square.</p> + <div id="grid"> + <div> + <div> + <div> + <div id="initiallyHidden"> + </div> + </div> + </div> + </div> + </div> + <script> + "use strict"; + + const grid = document.getElementById("grid"); + const initiallyHidden = document.getElementById("initiallyHidden"); + document.documentElement.offsetHeight; // Flush layout + + // Fails in buggy Firefox build because it prevents reflows from happening + grid.style.paddingBottom = "10px"; + + document.documentElement.offsetHeight; // Flush layout again + + initiallyHidden.style.display = "block"; // This should trigger a reflow. + </script> +</body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/webcodecs/videoFrame-canvasImageSource.html b/third_party/blink/web_tests/external/wpt/webcodecs/videoFrame-canvasImageSource.html index 7857269..ea47085 100644 --- a/third_party/blink/web_tests/external/wpt/webcodecs/videoFrame-canvasImageSource.html +++ b/third_party/blink/web_tests/external/wpt/webcodecs/videoFrame-canvasImageSource.html
@@ -89,12 +89,7 @@ frame.close(); }, 'SVGImageElement constructed VideoFrame'); -test(t => { - let canvas = document.querySelector('canvas'); - canvas.width = 320; - canvas.height = 240; - - // Draw and verify four colors image. +function drawFourColors(canvas) { let ctx = canvas.getContext('2d'); ctx.fillStyle = '#FFFF00'; // yellow ctx.fillRect(0, 0, canvas.width / 2, canvas.height / 2); @@ -105,6 +100,16 @@ ctx.fillStyle = '#00FF00'; // green ctx.fillRect(canvas.width / 2, canvas.height / 2, canvas.width / 2, canvas.height / 2); +} + +test(t => { + let canvas = document.querySelector('canvas'); + canvas.width = 320; + canvas.height = 240; + + // Draw and verify four colors image. + drawFourColors(canvas); + let ctx = canvas.getContext('2d'); verifyFourColorsImage(canvas.width, canvas.height, ctx); let frame = new VideoFrame(canvas); @@ -113,4 +118,25 @@ verifyFourColorsImage(canvas.width, canvas.height, ctx); frame.close(); }, 'Canvas element constructed VideoFrame'); + +test(t => { + let canvas = document.querySelector('canvas'); + canvas.width = 320; + canvas.height = 240; + + // Draw and verify four colors image. + drawFourColors(canvas); + let ctx = canvas.getContext('2d'); + verifyFourColorsImage(canvas.width, canvas.height, ctx); + + // Set a different timestamp to try and ensure the same frame isn't reused. + let frame = new VideoFrame(canvas, {timestamp: 0}); + let frame_copy = new VideoFrame(frame, {timestamp: 1}); + frame.close(); + + ctx.clearRect(0, 0, canvas.width, canvas.height); + ctx.drawImage(frame_copy, 0, 0); + verifyFourColorsImage(canvas.width, canvas.height, ctx); + frame_copy.close(); +}, 'Copy of canvas element constructed VideoFrame'); </script>
diff --git a/third_party/blink/web_tests/webgpu/internal_cts_test_splits.pyl b/third_party/blink/web_tests/webgpu/internal_cts_test_splits.pyl index c37c121..67d04f0 100644 --- a/third_party/blink/web_tests/webgpu/internal_cts_test_splits.pyl +++ b/third_party/blink/web_tests/webgpu/internal_cts_test_splits.pyl
@@ -235,4 +235,59 @@ 'wpt_internal/webgpu/cts.https.html?q=webgpu:shader,execution,zero_init:compute,zero_init:storageClass="workgroup";workgroupSize=[7,7,3];batch__=0;*', 'wpt_internal/webgpu/cts.https.html?q=webgpu:shader,execution,zero_init:compute,zero_init:storageClass="private";workgroupSize=[1,1,1];batch__=0;*', 'wpt_internal/webgpu/cts.https.html?q=webgpu:shader,execution,zero_init:compute,zero_init:storageClass="function";workgroupSize=[1,1,1];batch__=0;*', + + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="r8unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="r16float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="r32float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rg8unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rg16float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rg32float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rgba8unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rgba8unorm-srgb";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="bgra8unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="bgra8unorm-srgb";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rgb10a2unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rgba16float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rgba32float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="r8unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="r16float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="r32float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rg8unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rg16float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rg32float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rgba8unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rgba8unorm-srgb";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="bgra8unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="bgra8unorm-srgb";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rgb10a2unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rgba16float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rgba32float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="r8unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="r16float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="r32float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rg8unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rg16float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rg32float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rgba8unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rgba8unorm-srgb";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="bgra8unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="bgra8unorm-srgb";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rgb10a2unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rgba16float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rgba32float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="r8unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="r16float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="r32float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rg8unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rg16float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rg32float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rgba8unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rgba8unorm-srgb";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="bgra8unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="bgra8unorm-srgb";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rgb10a2unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rgba16float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rgba32float";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="r8unorm";*', + 'wpt_internal/webgpu/cts.https.html?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="r16float";*', ]
diff --git a/third_party/blink/web_tests/wpt_internal/fenced_frame/subframe-loading.html b/third_party/blink/web_tests/wpt_internal/fenced_frame/subframe-loading.html new file mode 100644 index 0000000..b809b55 --- /dev/null +++ b/third_party/blink/web_tests/wpt_internal/fenced_frame/subframe-loading.html
@@ -0,0 +1,30 @@ +<!DOCTYPE html> +<title>Test Subframe Loading Disabler</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<body> +<script> + +promise_test(async () => { + const container = document.body.appendChild(document.createElement("div")); + + // Create a helper iframe that triggers loading the new fenced frame + // simultaneously when the parent container is removed. + const helperFrame = container.appendChild(document.createElement("iframe")); + + helperFrame.contentWindow.onunload = function() { + const fenced_frame = document.createElement("fencedframe"); + fenced_frame.src = "resources/dummy.html"; + container.appendChild(fenced_frame); + }; + + // If the fenced frame loads when it's not supposed to, + // a DCHECK will catch that and cause the test to crash. + document.body.removeChild(container); + +}, "Fenced frames should not load if its parent has subframe loading disabled"); + +</script> +</body> +</html> \ No newline at end of file
diff --git a/third_party/blink/web_tests/wpt_internal/webgpu/cts.https.html b/third_party/blink/web_tests/wpt_internal/webgpu/cts.https.html index f7d2c112..33ea690 100644 --- a/third_party/blink/web_tests/wpt_internal/webgpu/cts.https.html +++ b/third_party/blink/web_tests/wpt_internal/webgpu/cts.https.html
@@ -70,6 +70,8 @@ <meta name=variant content='?q=webgpu:api,operation,buffers,map_oom:mapAsync:*'> <meta name=variant content='?q=webgpu:api,operation,buffers,map_oom:mappedAtCreation,full_getMappedRange:*'> <meta name=variant content='?q=webgpu:api,operation,buffers,map_oom:mappedAtCreation,smaller_getMappedRange:*'> +<meta name=variant content='?q=webgpu:api,operation,buffers,threading:serialize:*'> +<meta name=variant content='?q=webgpu:api,operation,buffers,threading:destroyed:*'> <meta name=variant content='?q=webgpu:api,operation,command_buffer,basic:empty:*'> <meta name=variant content='?q=webgpu:api,operation,command_buffer,basic:b2t2b:*'> <meta name=variant content='?q=webgpu:api,operation,command_buffer,basic:b2t2t2b:*'> @@ -1214,11 +1216,15 @@ <meta name=variant content='?q=webgpu:api,operation,command_buffer,programmable,state_tracking:one_bind_group_multiple_slots:*'> <meta name=variant content='?q=webgpu:api,operation,command_buffer,programmable,state_tracking:bind_group_multiple_sets:*'> <meta name=variant content='?q=webgpu:api,operation,command_buffer,programmable,state_tracking:compatible_pipelines:*'> +<meta name=variant content='?q=webgpu:api,operation,command_buffer,render,state_tracking:set_index_buffer_without_changing_buffer:*'> +<meta name=variant content='?q=webgpu:api,operation,command_buffer,render,state_tracking:set_vertex_buffer_without_changing_buffer:*'> +<meta name=variant content='?q=webgpu:api,operation,command_buffer,render,state_tracking:change_pipeline_before_and_after_vertex_buffer:*'> <meta name=variant content='?q=webgpu:api,operation,compute,basic:memcpy:*'> <meta name=variant content='?q=webgpu:api,operation,compute,basic:large_dispatch:*'> <meta name=variant content='?q=webgpu:api,operation,device,lost:not_lost_on_gc:*'> <meta name=variant content='?q=webgpu:api,operation,device,lost:lost_on_destroy:*'> <meta name=variant content='?q=webgpu:api,operation,device,lost:same_object:*'> +<meta name=variant content='?q=webgpu:api,operation,labels:object_has_descriptor_label:*'> <meta name=variant content='?q=webgpu:api,operation,memory_sync,buffer,ww:same_cmdbuf:*'> <meta name=variant content='?q=webgpu:api,operation,memory_sync,buffer,ww:separate_cmdbufs:*'> <meta name=variant content='?q=webgpu:api,operation,memory_sync,buffer,ww:separate_submits:*'> @@ -1232,8 +1238,15 @@ <meta name=variant content='?q=webgpu:api,operation,onSubmittedWorkDone:many,serial:*'> <meta name=variant content='?q=webgpu:api,operation,onSubmittedWorkDone:many,parallel:*'> <meta name=variant content='?q=webgpu:api,operation,onSubmittedWorkDone:many,parallel_order:*'> +<meta name=variant content='?q=webgpu:api,operation,pipeline,default_layout:getBindGroupLayout_js_object:*'> +<meta name=variant content='?q=webgpu:api,operation,pipeline,default_layout:incompatible_with_explicit:*'> +<meta name=variant content='?q=webgpu:api,operation,pipeline,default_layout:layout:*'> <meta name=variant content='?q=webgpu:api,operation,queue,writeBuffer:array_types:*'> <meta name=variant content='?q=webgpu:api,operation,queue,writeBuffer:multiple_writes_at_different_offsets_and_sizes:*'> +<meta name=variant content='?q=webgpu:api,operation,render_pass,clear_value:stored:*'> +<meta name=variant content='?q=webgpu:api,operation,render_pass,clear_value:loaded:*'> +<meta name=variant content='?q=webgpu:api,operation,render_pass,clear_value:srgb:*'> +<meta name=variant content='?q=webgpu:api,operation,render_pass,clear_value:layout:*'> <meta name=variant content='?q=webgpu:api,operation,render_pass,resolve:render_pass_resolve:*'> <meta name=variant content='?q=webgpu:api,operation,render_pass,storeOp:render_pass_store_op,color_attachment_with_depth_stencil_attachment:*'> <meta name=variant content='?q=webgpu:api,operation,render_pass,storeOp:render_pass_store_op,color_attachment_only:*'> @@ -1298,6 +1311,7 @@ <meta name=variant content='?q=webgpu:api,operation,rendering,draw:arguments:first=3;count=3;first_instance=2;*'> <meta name=variant content='?q=webgpu:api,operation,rendering,draw:arguments:first=3;count=6;first_instance=0;*'> <meta name=variant content='?q=webgpu:api,operation,rendering,draw:arguments:first=3;count=6;first_instance=2;*'> +<meta name=variant content='?q=webgpu:api,operation,rendering,draw:default_arguments:*'> <meta name=variant content='?q=webgpu:api,operation,rendering,draw:vertex_attributes,basic:*'> <meta name=variant content='?q=webgpu:api,operation,rendering,draw:vertex_attributes,formats:*'> <meta name=variant content='?q=webgpu:api,operation,rendering,draw:largeish_buffer:*'> @@ -1949,6 +1963,7 @@ <meta name=variant content='?q=webgpu:api,validation,buffer,mapping:unmap,state,mappingPending:*'> <meta name=variant content='?q=webgpu:api,validation,buffer,mapping:gc_behavior,mappedAtCreation:*'> <meta name=variant content='?q=webgpu:api,validation,buffer,mapping:gc_behavior,mapAsync:*'> +<meta name=variant content='?q=webgpu:api,validation,capability_checks,features,depth_clip_control:createRenderPipeline:*'> <meta name=variant content='?q=webgpu:api,validation,capability_checks,features,query_types:createQuerySet:*'> <meta name=variant content='?q=webgpu:api,validation,capability_checks,features,texture_formats:texture_descriptor:*'> <meta name=variant content='?q=webgpu:api,validation,capability_checks,features,texture_formats:depth_stencil_state:*'> @@ -1984,9 +1999,16 @@ <meta name=variant content='?q=webgpu:api,validation,createRenderPipeline:create_vertex_only_pipeline_with_without_depth_stencil_state:*'> <meta name=variant content='?q=webgpu:api,validation,createRenderPipeline:at_least_one_color_state_is_required_for_complete_pipeline:*'> <meta name=variant content='?q=webgpu:api,validation,createRenderPipeline:color_formats_must_be_renderable:*'> +<meta name=variant content='?q=webgpu:api,validation,createRenderPipeline:depth_stencil_state,format:*'> +<meta name=variant content='?q=webgpu:api,validation,createRenderPipeline:depth_stencil_state,depth_aspect,depth_test:*'> +<meta name=variant content='?q=webgpu:api,validation,createRenderPipeline:depth_stencil_state,depth_aspect,depth_write:*'> +<meta name=variant content='?q=webgpu:api,validation,createRenderPipeline:depth_stencil_state,stencil_aspect,stencil_test:*'> +<meta name=variant content='?q=webgpu:api,validation,createRenderPipeline:depth_stencil_state,stencil_aspect,stencil_write:*'> <meta name=variant content='?q=webgpu:api,validation,createRenderPipeline:sample_count_must_be_valid:*'> <meta name=variant content='?q=webgpu:api,validation,createRenderPipeline:pipeline_output_targets:*'> <meta name=variant content='?q=webgpu:api,validation,createRenderPipeline:pipeline_output_targets,blend:*'> +<meta name=variant content='?q=webgpu:api,validation,createRenderPipeline:pipeline_output_targets,format_blendable:*'> +<meta name=variant content='?q=webgpu:api,validation,createRenderPipeline:pipeline_output_targets,blend_min_max:*'> <meta name=variant content='?q=webgpu:api,validation,createRenderPipeline:pipeline_layout,device_mismatch:*'> <meta name=variant content='?q=webgpu:api,validation,createRenderPipeline:shader_module,device_mismatch:*'> <meta name=variant content='?q=webgpu:api,validation,createSampler:lodMinAndMaxClamp:*'> @@ -3365,6 +3387,58 @@ <meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gl_context_canvas:canvasType="offscreen";contextName="webgl2";dstColorFormat="rgb10a2unorm";*'> <meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gl_context_canvas:canvasType="offscreen";contextName="webgl2";dstColorFormat="rgba16float";*'> <meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gl_context_canvas:canvasType="offscreen";contextName="webgl2";dstColorFormat="rgba32float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="r8unorm";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="r16float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="r32float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rg8unorm";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rg16float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rg32float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rgba8unorm";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rgba8unorm-srgb";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="bgra8unorm";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="bgra8unorm-srgb";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rgb10a2unorm";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rgba16float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rgba32float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="r8unorm";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="r16float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="r32float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rg8unorm";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rg16float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rg32float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rgba8unorm";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rgba8unorm-srgb";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="bgra8unorm";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="bgra8unorm-srgb";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rgb10a2unorm";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rgba16float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="onscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rgba32float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="r8unorm";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="r16float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="r32float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rg8unorm";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rg16float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rg32float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rgba8unorm";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rgba8unorm-srgb";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="bgra8unorm";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="bgra8unorm-srgb";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rgb10a2unorm";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rgba16float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=true;dstColorFormat="rgba32float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="r8unorm";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="r16float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="r32float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rg8unorm";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rg16float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rg32float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rgba8unorm";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rgba8unorm-srgb";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="bgra8unorm";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="bgra8unorm-srgb";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rgb10a2unorm";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rgba16float";*'> +<meta name=variant content='?q=webgpu:web_platform,copyToTexture,canvas:copy_contents_from_gpu_context_canvas:canvasType="offscreen";srcAndDstInSameGPUDevice=false;dstColorFormat="rgba32float";*'> <meta name=variant content='?q=webgpu:web_platform,external_texture,video:importExternalTexture,sample:*'> <meta name=variant content='?q=webgpu:web_platform,external_texture,video:importExternalTexture,destroy:*'> <meta name=variant content='?q=webgpu:web_platform,external_texture,video:importExternalTexture,compute:*'>
diff --git a/third_party/freetype/README.chromium b/third_party/freetype/README.chromium index feda1a3..d092790 100644 --- a/third_party/freetype/README.chromium +++ b/third_party/freetype/README.chromium
@@ -1,7 +1,7 @@ Name: FreeType URL: http://www.freetype.org/ -Version: VER-2-11-1-40-gb647dbdeb -Revision: b647dbdeb8d5389a7e05ca5284842b4b757ee723 +Version: VER-2-11-1-42-gee52b5712 +Revision: ee52b57121c2dcb74e0c30d98cdb3bae5b3e7cb9 CPEPrefix: cpe:/a:freetype:freetype:2.11.1 License: Custom license "inspired by the BSD, Artistic, and IJG (Independent JPEG Group) licenses"
diff --git a/third_party/harfbuzz-ng/BUILD.gn b/third_party/harfbuzz-ng/BUILD.gn index 8974379c..c46820fc 100644 --- a/third_party/harfbuzz-ng/BUILD.gn +++ b/third_party/harfbuzz-ng/BUILD.gn
@@ -340,10 +340,6 @@ defines += [ "HAVE_PTHREAD" ] } - if (is_mac) { - defines += [ "HAVE_XLOCALE_H" ] - } - if (enable_paint_preview) { # Paint Previews make use of CFF subsetting. However, enabling this is # expensive for binary size so only compile it when Paint Previews are
diff --git a/third_party/harfbuzz-ng/README.chromium b/third_party/harfbuzz-ng/README.chromium index 8e2bc57..8e06ae46 100644 --- a/third_party/harfbuzz-ng/README.chromium +++ b/third_party/harfbuzz-ng/README.chromium
@@ -1,10 +1,10 @@ Name: harfbuzz-ng Short Name: harfbuzz-ng URL: http://harfbuzz.org -Version: 3.2.0-42 +Version: 3.2.0-50 CPEPrefix: cpe:/a:harfbuzz_project:harfbuzz:3.2.0 -Date: 20220112 -Revision: b8c2c1ab3778755a23ea449ba334959693388687 +Date: 20220113 +Revision: 0acf466c44143de2e9b9cc0375cb25ec67cb132f Security Critical: yes License: MIT License File: src/COPYING
diff --git a/third_party/webgpu-cts/ts_sources.txt b/third_party/webgpu-cts/ts_sources.txt index 66ce380..f01df90 100644 --- a/third_party/webgpu-cts/ts_sources.txt +++ b/third_party/webgpu-cts/ts_sources.txt
@@ -141,7 +141,9 @@ src/webgpu/api/operation/memory_sync/buffer/ww.spec.ts src/webgpu/api/operation/memory_sync/texture/rw_and_wr.spec.ts src/webgpu/api/operation/memory_sync/texture/ww.spec.ts +src/webgpu/api/operation/pipeline/default_layout.spec.ts src/webgpu/api/operation/queue/writeBuffer.spec.ts +src/webgpu/api/operation/render_pass/clear_value.spec.ts src/webgpu/api/operation/render_pass/resolve.spec.ts src/webgpu/api/operation/render_pass/storeOp.spec.ts src/webgpu/api/operation/render_pass/storeop2.spec.ts @@ -158,6 +160,7 @@ src/webgpu/api/operation/rendering/depth_clip_clamp.spec.ts src/webgpu/api/operation/rendering/draw.spec.ts src/webgpu/api/operation/rendering/indirect_draw.spec.ts +src/webgpu/api/operation/rendering/robust_access_index.spec.ts src/webgpu/api/operation/resource_init/buffer.spec.ts src/webgpu/util/texture/subresource.ts src/webgpu/api/operation/resource_init/check_texture/by_copy.ts @@ -170,7 +173,6 @@ src/webgpu/api/operation/shader_module/compilation_info.spec.ts src/webgpu/api/operation/texture_view/read.spec.ts src/webgpu/api/operation/texture_view/write.spec.ts -src/webgpu/api/operation/vertex_state/basic.spec.ts src/webgpu/api/operation/vertex_state/correctness.spec.ts src/webgpu/api/operation/vertex_state/index_format.spec.ts src/webgpu/api/validation/validation_test.ts @@ -192,7 +194,7 @@ src/webgpu/api/validation/buffer/destroy.spec.ts src/webgpu/api/validation/buffer/mapping.spec.ts src/webgpu/api/validation/buffer/threading.spec.ts -src/webgpu/api/validation/capability_checks/features/depth_clamping.spec.ts +src/webgpu/api/validation/capability_checks/features/depth_clip_control.spec.ts src/webgpu/api/validation/capability_checks/features/query_types.spec.ts src/webgpu/api/validation/capability_checks/features/texture_formats.spec.ts src/webgpu/api/validation/encoding/beginRenderPass.spec.ts @@ -286,7 +288,6 @@ src/webgpu/web_platform/copyToTexture/ImageBitmap.spec.ts src/webgpu/web_platform/copyToTexture/canvas.spec.ts src/webgpu/web_platform/copyToTexture/video.spec.ts -src/webgpu/web_platform/external_texture/canvas.spec.ts src/webgpu/web_platform/external_texture/video.spec.ts src/webgpu/web_platform/reftests/gpu_ref_test.ts src/webgpu/web_platform/reftests/canvas_clear.html.ts
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index c827d5a..59535f8 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -58835,23 +58835,23 @@ <int value="0" label="Pinned toolbar icon and presentation"/> <int value="1" label="Pinned toolbar icon and tab mirroring"/> <int value="2" label="Pinned toolbar icon and desktop mirroring"/> - <int value="3" label="Pinned toolbar icon and local file"/> + <int value="3" label="(Obsolete) Pinned toolbar icon and local file"/> <int value="4" label="Ephemeral icon and presentation"/> <int value="5" label="Ephemeral icon and tab mirroring"/> <int value="6" label="Ephemeral icon and desktop mirroring"/> - <int value="7" label="Ephemeral icon and local file"/> + <int value="7" label="(Obsolete) Ephemeral icon and local file"/> <int value="8" label="Context menu and presentation"/> <int value="9" label="Context menu and tab mirroring"/> <int value="10" label="Context menu and desktop mirroring"/> - <int value="11" label="Context menu and local file"/> + <int value="11" label="(Obsolete) Context menu and local file"/> <int value="12" label="Page and presentation"/> <int value="13" label="Page and tab mirroring"/> <int value="14" label="Page and desktop mirroring"/> - <int value="15" label="Page and local file"/> + <int value="15" label="(Obsolete) Page and local file"/> <int value="16" label="App menu and presentation"/> <int value="17" label="App menu and tab mirroring"/> <int value="18" label="App menu and desktop mirroring"/> - <int value="19" label="App menu and local file"/> + <int value="19" label="(Obsolete) App menu and local file"/> </enum> <enum name="MediaRouterDialogOpenOrigin">
diff --git a/tools/metrics/histograms/histograms_index.txt b/tools/metrics/histograms/histograms_index.txt index 6ccd5ba4..2a435af6 100644 --- a/tools/metrics/histograms/histograms_index.txt +++ b/tools/metrics/histograms/histograms_index.txt
@@ -16,6 +16,7 @@ tools/metrics/histograms/metadata/chrome/histograms.xml tools/metrics/histograms/metadata/chromeos/histograms.xml tools/metrics/histograms/metadata/chromeos_hps/histograms.xml +tools/metrics/histograms/metadata/chromeos_settings/histograms.xml tools/metrics/histograms/metadata/cloud/histograms.xml tools/metrics/histograms/metadata/commerce/histograms.xml tools/metrics/histograms/metadata/compositing/histograms.xml
diff --git a/tools/metrics/histograms/metadata/accessibility/histograms.xml b/tools/metrics/histograms/metadata/accessibility/histograms.xml index b8d4a28..4719701 100644 --- a/tools/metrics/histograms/metadata/accessibility/histograms.xml +++ b/tools/metrics/histograms/metadata/accessibility/histograms.xml
@@ -1978,7 +1978,7 @@ </histogram> <histogram name="TextToSpeech.Event" enum="TextToSpeechEvent" - expires_after="2022-05-10"> + expires_after="2022-07-11"> <owner>dtseng@chromium.org</owner> <owner>katie@chromium.org</owner> <owner>chrome-a11y-core@google.com</owner> @@ -1988,7 +1988,7 @@ </histogram> <histogram name="TextToSpeech.Utterance.FromExtensionAPI" - enum="TextToSpeechFromExtensionAPI" expires_after="2022-05-10"> + enum="TextToSpeechFromExtensionAPI" expires_after="2022-07-11"> <owner>dtseng@chromium.org</owner> <owner>katie@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/android/histograms.xml b/tools/metrics/histograms/metadata/android/histograms.xml index 09d4795..6472bf9 100644 --- a/tools/metrics/histograms/metadata/android/histograms.xml +++ b/tools/metrics/histograms/metadata/android/histograms.xml
@@ -1663,6 +1663,19 @@ </summary> </histogram> +<histogram name="Android.Intent.BlockedExternalNavLastGestureTime" units="ms" + expires_after="M103"> + <owner>mthiesse@chromium.org</owner> + <owner>yfriedman@chromium.org</owner> + <summary> + When a navigation to an external protocol is blocked due to a missing + gesture on the redirect chain, records the time in milliseconds since the + last time the user touched the screen before the navigation. Note that this + notion is decoupled from the last user activation in blink due to quirks + around how the RedirectHandler works. + </summary> +</histogram> + <histogram name="Android.Intent.IntentUriWithSelector" enum="Boolean" expires_after="M102"> <owner>mthiesse@chromium.org</owner> @@ -1753,7 +1766,7 @@ </histogram> <histogram name="Android.Jank.AsyncTaskGetOnUiThreadStatus" - enum="AsyncTaskStatus" expires_after="2022-05-10"> + enum="AsyncTaskStatus" expires_after="2022-07-11"> <owner>smaier@chromium.org</owner> <owner>agrieve@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/autofill/histograms.xml b/tools/metrics/histograms/metadata/autofill/histograms.xml index 04407de..b13c689 100644 --- a/tools/metrics/histograms/metadata/autofill/histograms.xml +++ b/tools/metrics/histograms/metadata/autofill/histograms.xml
@@ -423,7 +423,7 @@ </histogram> <histogram name="Autofill.AutofilledFieldAtSubmission.ByStateSelectionField" - enum="AutofillSourceForStateSelectionField" expires_after="M102"> + enum="AutofillSourceForStateSelectionField" expires_after="2022-07-11"> <owner>vidhanj@google.com</owner> <owner>koerber@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/blink/histograms.xml b/tools/metrics/histograms/metadata/blink/histograms.xml index 159c763..09a98f9 100644 --- a/tools/metrics/histograms/metadata/blink/histograms.xml +++ b/tools/metrics/histograms/metadata/blink/histograms.xml
@@ -308,7 +308,7 @@ </histogram> <histogram name="Blink.Canvas.HibernationEvents" enum="CanvasHibernationEvent" - expires_after="2022-05-08"> + expires_after="2022-07-11"> <owner>fserb@chromium.org</owner> <summary> Records the occurrence of events related to 2D canvas GPU resource @@ -2695,7 +2695,7 @@ </histogram> <histogram base="true" name="Blink.PrePaint.UpdateTime" units="microseconds" - expires_after="2022-05-08"> + expires_after="2022-07-11"> <!-- Name completed by histogram_suffixes name="BlinkUpdateTimePreFCPSuffixes" --> <!-- Name completed by histogram_suffixes name="BlinkUpdateTimePostFCPSuffixes" --> @@ -3106,7 +3106,7 @@ </histogram> <histogram name="Blink.Sms.Receive.TimeUserCancel" units="ms" - expires_after="2022-05-01"> + expires_after="2022-07-11"> <owner>yigu@chromium.org</owner> <owner>goto@chromium.org</owner> <owner>web-identity@google.com</owner> @@ -3514,7 +3514,7 @@ </histogram> <histogram name="Blink.V8.InitPerIsolateData" units="microseconds" - expires_after="2022-05-08"> + expires_after="2022-07-11"> <owner>sky@chromium.org</owner> <owner>yukishiino@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/browser/histograms.xml b/tools/metrics/histograms/metadata/browser/histograms.xml index aa81de2..7654b2cb 100644 --- a/tools/metrics/histograms/metadata/browser/histograms.xml +++ b/tools/metrics/histograms/metadata/browser/histograms.xml
@@ -438,7 +438,7 @@ </histogram> <histogram name="Browser.PaintPreview.Player.CompositorProcessStartupTime" - units="ms" expires_after="2022-05-08"> + units="ms" expires_after="2022-07-11"> <owner>ckitagawa@chromium.org</owner> <owner>yashard@chromium.org</owner> <owner>fredmello@chromium.org</owner> @@ -456,7 +456,7 @@ </histogram> <histogram name="Browser.PaintPreview.Player.TimeToFirstBitmap" units="ms" - expires_after="2022-05-08"> + expires_after="2022-07-11"> <owner>ckitagawa@chromium.org</owner> <owner>yashard@chromium.org</owner> <owner>fredmello@chromium.org</owner> @@ -524,7 +524,7 @@ </histogram> <histogram name="Browser.PaintPreview.TabbedPlayer.TimeToFirstBitmap" - units="ms" expires_after="2022-05-08"> + units="ms" expires_after="2022-07-11"> <owner>ckitagawa@chromium.org</owner> <owner>yashard@chromium.org</owner> <owner>fredmello@chromium.org</owner> @@ -1068,7 +1068,7 @@ </histogram> <histogram name="BrowserRenderProcessHost.SpareProcessMaybeTakeAction" - enum="SpareProcessMaybeTakeAction" expires_after="2022-05-08"> + enum="SpareProcessMaybeTakeAction" expires_after="2022-07-11"> <owner>alexmos@chromium.org</owner> <owner>lukasza@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/chromeos/histograms.xml b/tools/metrics/histograms/metadata/chromeos/histograms.xml index 3dcaee7..9baf666 100644 --- a/tools/metrics/histograms/metadata/chromeos/histograms.xml +++ b/tools/metrics/histograms/metadata/chromeos/histograms.xml
@@ -1450,447 +1450,6 @@ </summary> </histogram> -<histogram - name="ChromeOS.Settings.Accessibility.FullscreenMagnifierFocusFollowing" - enum="BooleanToggled" expires_after="2022-10-29"> - <owner>josiahk@chromium.org</owner> - <owner>chromium-accessibility@chromium.org</owner> - <summary> - Records when a user changes the kFullscreenMagnifierFocusFollowing setting - on the Accessibility page. - </summary> -</histogram> - -<histogram - name="ChromeOS.Settings.Accessibility.FullscreenMagnifierMouseFollowingMode" - enum="MagnifierMouseFollowingMode" expires_after="2022-12-13"> - <owner>josiahk@chromium.org</owner> - <owner>chromium-accessibility@chromium.org</owner> - <summary> - Recorded when a user changes the value of the - kFullscreenMagnifierMouseFollowingMode setting on the Accessibility page. - Records the value of the setting. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.Apps.DoNotDisturbOnOff" - enum="BooleanToggled" expires_after="2022-09-01"> - <owner>hsuregan@chromium.org</owner> - <owner>jimmyxgong@chromium.org</owner> - <summary> - Records when a user changes the kDoNotDisturbOnOff setting in the - Notifications subpage of the Apps section. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.Bluetooth.BluetoothOnOff" - enum="BooleanToggled" expires_after="2022-04-24"> - <owner>khorimoto@chromium.org</owner> - <owner>hsuregan@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary> - Records when users change the kBluetoothOnOff setting on the Bluetooth page. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.BlurredWindowDuration" units="ms" - expires_after="2022-09-01"> - <owner>khorimoto@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary> - The amount of time between when the settings window becomes blurred and when - the user focuses it again. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.Device.KeyboardFunctionKeys" - enum="BooleanToggled" expires_after="2022-03-15"> - <owner>jimmyxgong@chromium.org</owner> - <owner>zentaro@chromium.org</owner> - <owner>cros-peripherals@google.com</owner> - <summary> - Records when a user changes the kKeyboardFunctionKeys setting on the Device - page. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.Device.TouchpadSpeedValue" - enum="TouchpadSensitivity" expires_after="2022-02-06"> - <owner>khorimoto@chromium.org</owner> - <owner>hsuregan@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary> - Records when users change the Touchpad Speed on the Device page. The value - saved is equal to the sensitivity value set on the slider, which ranges from - 1 to 5. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.Inputs.ShortcutReminderDismissed" - enum="SettingsInputsShortcutReminderState" expires_after="2022-05-01"> - <owner>mlcui@google.com</owner> - <owner>cros-borders@google.com</owner> - <summary> - Records when users dismiss the shortcut reminder banner in Chrome OS' Inputs - OS settings page. The value saved indicates the keyboard shortcuts that were - previously shown in the banner before the user dismissed the banner. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.Languages.Browser.Interaction" - enum="SettingsLanguagesPageBrowserInteraction" expires_after="2021-08-01"> - <obsolete> - Deprecated as of M88, as the languages browser settings page has been - replaced with the languages OS settings page. - </obsolete> - <owner>myy@chromium.org</owner> - <owner>essential-inputs-team@google.com</owner> - <summary> - Records when users interact with an element in the Chrome OS's Languages - browser settings page. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.Languages.Browser.OfferToTranslateCheckbox" - enum="BooleanChecked" expires_after="2021-05-30"> - <obsolete> - Deprecated as of M88, as the languages browser settings page has been - replaced with the languages OS settings page. - </obsolete> - <owner>myy@chromium.org</owner> - <owner>essential-inputs-team@google.com</owner> - <summary> - Records when users check/uncheck "Offer to translate pages in this - language" checkbox. - </summary> -</histogram> - -<histogram base="true" name="ChromeOS.Settings.Languages.Browser.Toggle" - enum="BooleanToggled" expires_after="2021-05-30"> - <obsolete> - Deprecated as of M88, as the languages browser settings page has been - replaced with the languages OS settings page. - </obsolete> -<!-- Name completed by histogram_suffixes name="SettingsLanguagesPageToggle" --> - - <owner>myy@chromium.org</owner> - <owner>essential-inputs-team@google.com</owner> - <summary> - Records when users interact with a toggle in the Chrome OS's Languages - browser settings page. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.Languages.Interaction" - enum="SettingsLanguagesPageInteraction" expires_after="2022-04-10"> - <owner>myy@chromium.org</owner> - <owner>essential-inputs-team@google.com</owner> - <summary> - Records when users interact with different element in the Chrome OS's - Languages OS settings page. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.Languages.OfferToTranslateCheckbox" - enum="BooleanChecked" expires_after="2022-04-24"> - <owner>myy@chromium.org</owner> - <owner>essential-inputs-team@google.com</owner> - <summary> - Records when users check/uncheck "Offer to translate pages in this - language" checkbox in OS Settings - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.Languages.SupportPageVisits" - enum="SettingsLanguagesSupportPage" expires_after="2022-05-01"> - <owner>myy@chromium.org</owner> - <owner>essential-inputs-team@google.com</owner> - <summary> - Records when users visit a language settings support page for Chrome OS. - </summary> -</histogram> - -<histogram base="true" name="ChromeOS.Settings.Languages.Toggle" - enum="BooleanToggled" expires_after="2022-04-24"> -<!-- Name completed by histogram_suffixes name="SettingsLanguagesPageToggle" --> - - <owner>myy@chromium.org</owner> - <owner>essential-inputs-team@google.com</owner> - <summary> - Records when users interact with a toggle in the Chrome OS's Languages OS - settings page. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.LoadCompletedTime" units="ms" - expires_after="2022-04-01"> - <owner>khorimoto@chromium.org</owner> - <owner>cros-system-services@google.com</owner> - <summary> - The amount of time between the render frame host StartProvisionalLoad event - and the render frame DocumentOnLoadCompleted event for the Chrome OS - settings page. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.LoadDocumentTime" units="ms" - expires_after="2022-04-01"> - <owner>khorimoto@chromium.org</owner> - <owner>cros-system-services@google.com</owner> - <summary> - The amount of time between the render frame host StartProvisionalLoad and - DidFinishDocumentLoad events for the Chrome OS settings page. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.NotificationPage.PermissionOnOff" - enum="BooleanToggled" expires_after="2022-09-01"> - <owner>hsuregan@chromium.org</owner> - <owner>jimmyxgong@chromium.org</owner> - <summary> - Records when a user changes the notification permission of any app in the - Notifications subpage of the Apps section. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.NumCharsOfQueries" units="characters" - expires_after="2022-02-06"> - <owner>khorimoto@chromium.org</owner> - <owner>hsuregan@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary> - The number of characters for queries used to fetch results from the Settings - Search Mojo API. - </summary> -</histogram> - -<histogram base="true" name="ChromeOS.Settings.NumClicksUntilChange" - units="clicks" expires_after="2022-09-01"> -<!-- Name completed by histogram_suffixes name="OsSettingsChangeType" --> - - <owner>khorimoto@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary>The number of clicks before changing a setting.</summary> -</histogram> - -<histogram base="true" name="ChromeOS.Settings.NumNavigationsUntilChange" - units="navigations" expires_after="2022-09-01"> -<!-- Name completed by histogram_suffixes name="OsSettingsChangeType" --> - - <owner>khorimoto@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary>The number of navigations before changing a setting.</summary> -</histogram> - -<histogram base="true" name="ChromeOS.Settings.NumSearchesUntilChange" - units="searches" expires_after="2022-09-01"> -<!-- Name completed by histogram_suffixes name="OsSettingsChangeType" --> - - <owner>khorimoto@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary>The number of searches before changing a setting.</summary> -</histogram> - -<histogram name="ChromeOS.Settings.NumSearchResultsFetched" units="results" - expires_after="2022-02-06"> - <owner>khorimoto@chromium.org</owner> - <owner>hsuregan@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary> - The number of search results fetched each time a successful search request - is made to the Settings Search Mojo API. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.OsBannerInteraction" - enum="CrosSettingsOsBannerInteraction" expires_after="2020-12-20"> - <owner>jamescook@chromium.org</owner> - <owner>cros-system-services@google.com</owner> - <summary> - Records whether the "try your Chrome OS settings" banner was shown - when the user opened a new Chrome browser settings tab and also records - interactions with the banner. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.PathVisited" enum="WebUISettingsPathHashes" - expires_after="2022-04-10"> - <owner>khorimoto@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary> - Paths visited within chrome://os-settings. For evaluating popularity and - priorities for OS Settings UI. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.People.AddAccountCount" units="accounts" - expires_after="2022-03-15"> - <owner>khorimoto@chromium.org</owner> - <owner>hsuregan@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary> - Records when users click the Add Account button on the People page. The - number of the account that would be added is saved, e.g. a sample of 2 means - the user entered the add account dialog for a 2nd account. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.Privacy.PeripheralDataAccessProtection" - enum="BooleanEnabled" expires_after="2022-11-30"> - <owner>jimmyxgong@chromium.org</owner> - <owner>cros-peripherals@google.com</owner> - <summary> - Records when the users clicks on the Peripheral Data Access toggle. A true - value refers to the user enables peripheral data access protection (toggle - is turned on). - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.SearchLatency" units="ms" - expires_after="2022-09-01"> - <owner>khorimoto@chromium.org</owner> - <owner>hsuregan@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary> - The time fetching search results from the Settings Search Mojo API. Recorded - when getSearchHandler().search() completes. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.SearchRequests" - enum="OsSettingSearchRequestTypes" expires_after="2022-04-17"> - <owner>khorimoto@chromium.org</owner> - <owner>hsuregan@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary> - The number of search requests made to the Settings Search Mojo API. For - search requests that succeeded with a response, the number of search - requests that had results which were discarded, and the number of search - requests that were shown to the user. Recorded when - getSearchHandler().search() completes. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.SearchRequestsPerSession" - units="mojo search requests" expires_after="2022-09-01"> - <owner>khorimoto@chromium.org</owner> - <owner>hsuregan@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary> - The number of search requests made to the Settings Search Mojo API in one - session of the settings app. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.SearchResultSectionSelected" - enum="OsSettingsSection" expires_after="2022-04-17"> - <owner>khorimoto@chromium.org</owner> - <owner>hsuregan@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary> - Section search results clicked by user in the OS settings search box. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.SearchResultSettingSelected" - enum="OsSetting" expires_after="2022-09-01"> - <owner>khorimoto@chromium.org</owner> - <owner>hsuregan@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary> - Setting search results clicked by user in the OS settings search box. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.SearchResultSubpageSelected" - enum="OsSettingsSubpage" expires_after="2022-04-24"> - <owner>khorimoto@chromium.org</owner> - <owner>hsuregan@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary> - Subpage search results clicked by user in the OS settings search box. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.SearchResultTypeSelected" - enum="OsSettingsSearchResultType" expires_after="2022-04-24"> - <owner>khorimoto@chromium.org</owner> - <owner>hsuregan@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary> - Type of search results clicked by user in the OS settings search box. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.SettingChanged" enum="OsSetting" - expires_after="2022-09-01"> - <owner>khorimoto@chromium.org</owner> - <owner>hsuregan@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary> - Records the the setting id when the user changes a setting. Note that some - of the values of the OsSetting enum aren't strictly settings (such as - kKeyboardShortcuts, which is just a hyperlink). All of the recorded values - appear in the settings page. - </summary> -</histogram> - -<histogram base="true" name="ChromeOS.Settings.TimeUntilChange" units="ms" - expires_after="2022-09-01"> -<!-- Name completed by histogram_suffixes name="OsSettingsChangeType" --> - - <owner>khorimoto@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary> - The time spent on the settings page before changing a setting. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.UserActionOnSearchResultsShown" - enum="OsSettingSearchBoxUserAction" expires_after="2022-02-06"> - <owner>khorimoto@chromium.org</owner> - <owner>hsuregan@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary> - The user action taken when search results exist and are displayed. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.Wifi.AddNetwork" - enum="NetworkDiscoveryState" expires_after="2022-03-30"> - <owner>jonmann@chromium.org</owner> - <owner>khorimoto@chromium.org</owner> - <owner>tnagel@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <owner>cros-privacy-core@google.com</owner> - <summary> - Recorded when the user adds a WiFi network that has not been added before. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.Wifi.Hidden" enum="BooleanToggled" - expires_after="2022-03-30"> - <owner>jonmann@chromium.org</owner> - <owner>khorimoto@chromium.org</owner> - <owner>tnagel@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <owner>cros-privacy-core@google.com</owner> - <summary> - Recorded when the "Hidden" Wi-Fi network toggle is changed by the - user. - </summary> -</histogram> - -<histogram name="ChromeOS.Settings.WindowOpenDuration" units="ms" - expires_after="2022-09-01"> - <owner>khorimoto@chromium.org</owner> - <owner>cros-customization@google.com</owner> - <summary> - The amount of time between when a Chrome OS settings window is opened and - when it is closed. - </summary> -</histogram> - <histogram name="ChromeOS.Sharesheet.AppCount" units="apps" expires_after="M95"> <obsolete> Replaced with pattern histogram ChromeOS.Sharesheet.AppCount.{AppType}.
diff --git a/tools/metrics/histograms/metadata/chromeos_settings/OWNERS b/tools/metrics/histograms/metadata/chromeos_settings/OWNERS new file mode 100644 index 0000000..8961bd82 --- /dev/null +++ b/tools/metrics/histograms/metadata/chromeos_settings/OWNERS
@@ -0,0 +1,5 @@ +per-file OWNERS=file://tools/metrics/histograms/metadata/METRIC_REVIEWER_OWNERS + +# Prefer sending CLs to the owners listed below. +# Use chromium-metrics-reviews@google.com as a backup. +xiaohuic@chromium.org
diff --git a/tools/metrics/histograms/metadata/chromeos_settings/histograms.xml b/tools/metrics/histograms/metadata/chromeos_settings/histograms.xml new file mode 100644 index 0000000..c854f91 --- /dev/null +++ b/tools/metrics/histograms/metadata/chromeos_settings/histograms.xml
@@ -0,0 +1,468 @@ +<!-- +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. +--> + +<!-- +This file is used to generate a comprehensive list of Chrome OS Settings +histograms along with a detailed description for each histogram. + +For best practices on writing histogram descriptions, see +https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/histograms/README.md + +Prefer owners from the OWNERS file in this directory. If you need a metrics +reviewer, please send CLs to chromium-metrics-reviews@google.com rather than to +specific individuals. These CLs will be automatically reassigned to a reviewer +within about 5 minutes. This approach helps the metrics team to load-balance +incoming reviews. Googlers can read more about this at go/gwsq-gerrit. +--> + +<histogram-configuration> + +<histograms> + +<histogram + name="ChromeOS.Settings.Accessibility.FullscreenMagnifierFocusFollowing" + enum="BooleanToggled" expires_after="2022-10-29"> + <owner>josiahk@chromium.org</owner> + <owner>chromium-accessibility@chromium.org</owner> + <summary> + Records when a user changes the kFullscreenMagnifierFocusFollowing setting + on the Accessibility page. + </summary> +</histogram> + +<histogram + name="ChromeOS.Settings.Accessibility.FullscreenMagnifierMouseFollowingMode" + enum="MagnifierMouseFollowingMode" expires_after="2022-12-13"> + <owner>josiahk@chromium.org</owner> + <owner>chromium-accessibility@chromium.org</owner> + <summary> + Recorded when a user changes the value of the + kFullscreenMagnifierMouseFollowingMode setting on the Accessibility page. + Records the value of the setting. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.Apps.DoNotDisturbOnOff" + enum="BooleanToggled" expires_after="2022-09-01"> + <owner>hsuregan@chromium.org</owner> + <owner>jimmyxgong@chromium.org</owner> + <summary> + Records when a user changes the kDoNotDisturbOnOff setting in the + Notifications subpage of the Apps section. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.Bluetooth.BluetoothOnOff" + enum="BooleanToggled" expires_after="2022-04-24"> + <owner>khorimoto@chromium.org</owner> + <owner>hsuregan@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary> + Records when users change the kBluetoothOnOff setting on the Bluetooth page. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.BlurredWindowDuration" units="ms" + expires_after="2022-09-01"> + <owner>khorimoto@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary> + The amount of time between when the settings window becomes blurred and when + the user focuses it again. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.Device.KeyboardFunctionKeys" + enum="BooleanToggled" expires_after="2022-03-15"> + <owner>jimmyxgong@chromium.org</owner> + <owner>zentaro@chromium.org</owner> + <owner>cros-peripherals@google.com</owner> + <summary> + Records when a user changes the kKeyboardFunctionKeys setting on the Device + page. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.Device.TouchpadSpeedValue" + enum="TouchpadSensitivity" expires_after="2022-02-06"> + <owner>khorimoto@chromium.org</owner> + <owner>hsuregan@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary> + Records when users change the Touchpad Speed on the Device page. The value + saved is equal to the sensitivity value set on the slider, which ranges from + 1 to 5. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.Inputs.ShortcutReminderDismissed" + enum="SettingsInputsShortcutReminderState" expires_after="2022-05-01"> + <owner>mlcui@google.com</owner> + <owner>cros-borders@google.com</owner> + <summary> + Records when users dismiss the shortcut reminder banner in Chrome OS' Inputs + OS settings page. The value saved indicates the keyboard shortcuts that were + previously shown in the banner before the user dismissed the banner. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.Languages.Browser.Interaction" + enum="SettingsLanguagesPageBrowserInteraction" expires_after="2021-08-01"> + <obsolete> + Deprecated as of M88, as the languages browser settings page has been + replaced with the languages OS settings page. + </obsolete> + <owner>myy@chromium.org</owner> + <owner>essential-inputs-team@google.com</owner> + <summary> + Records when users interact with an element in the Chrome OS's Languages + browser settings page. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.Languages.Browser.OfferToTranslateCheckbox" + enum="BooleanChecked" expires_after="2021-05-30"> + <obsolete> + Deprecated as of M88, as the languages browser settings page has been + replaced with the languages OS settings page. + </obsolete> + <owner>myy@chromium.org</owner> + <owner>essential-inputs-team@google.com</owner> + <summary> + Records when users check/uncheck "Offer to translate pages in this + language" checkbox. + </summary> +</histogram> + +<histogram base="true" name="ChromeOS.Settings.Languages.Browser.Toggle" + enum="BooleanToggled" expires_after="2021-05-30"> + <obsolete> + Deprecated as of M88, as the languages browser settings page has been + replaced with the languages OS settings page. + </obsolete> +<!-- Name completed by histogram_suffixes name="SettingsLanguagesPageToggle" --> + + <owner>myy@chromium.org</owner> + <owner>essential-inputs-team@google.com</owner> + <summary> + Records when users interact with a toggle in the Chrome OS's Languages + browser settings page. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.Languages.Interaction" + enum="SettingsLanguagesPageInteraction" expires_after="2022-04-10"> + <owner>myy@chromium.org</owner> + <owner>essential-inputs-team@google.com</owner> + <summary> + Records when users interact with different element in the Chrome OS's + Languages OS settings page. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.Languages.OfferToTranslateCheckbox" + enum="BooleanChecked" expires_after="2022-04-24"> + <owner>myy@chromium.org</owner> + <owner>essential-inputs-team@google.com</owner> + <summary> + Records when users check/uncheck "Offer to translate pages in this + language" checkbox in OS Settings + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.Languages.SupportPageVisits" + enum="SettingsLanguagesSupportPage" expires_after="2022-05-01"> + <owner>myy@chromium.org</owner> + <owner>essential-inputs-team@google.com</owner> + <summary> + Records when users visit a language settings support page for Chrome OS. + </summary> +</histogram> + +<histogram base="true" name="ChromeOS.Settings.Languages.Toggle" + enum="BooleanToggled" expires_after="2022-04-24"> +<!-- Name completed by histogram_suffixes name="SettingsLanguagesPageToggle" --> + + <owner>myy@chromium.org</owner> + <owner>essential-inputs-team@google.com</owner> + <summary> + Records when users interact with a toggle in the Chrome OS's Languages OS + settings page. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.LoadCompletedTime" units="ms" + expires_after="2022-04-01"> + <owner>khorimoto@chromium.org</owner> + <owner>cros-system-services@google.com</owner> + <summary> + The amount of time between the render frame host StartProvisionalLoad event + and the render frame DocumentOnLoadCompleted event for the Chrome OS + settings page. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.LoadDocumentTime" units="ms" + expires_after="2022-04-01"> + <owner>khorimoto@chromium.org</owner> + <owner>cros-system-services@google.com</owner> + <summary> + The amount of time between the render frame host StartProvisionalLoad and + DidFinishDocumentLoad events for the Chrome OS settings page. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.NotificationPage.PermissionOnOff" + enum="BooleanToggled" expires_after="2022-09-01"> + <owner>hsuregan@chromium.org</owner> + <owner>jimmyxgong@chromium.org</owner> + <summary> + Records when a user changes the notification permission of any app in the + Notifications subpage of the Apps section. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.NumCharsOfQueries" units="characters" + expires_after="2022-02-06"> + <owner>khorimoto@chromium.org</owner> + <owner>hsuregan@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary> + The number of characters for queries used to fetch results from the Settings + Search Mojo API. + </summary> +</histogram> + +<histogram base="true" name="ChromeOS.Settings.NumClicksUntilChange" + units="clicks" expires_after="2022-09-01"> +<!-- Name completed by histogram_suffixes name="OsSettingsChangeType" --> + + <owner>khorimoto@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary>The number of clicks before changing a setting.</summary> +</histogram> + +<histogram base="true" name="ChromeOS.Settings.NumNavigationsUntilChange" + units="navigations" expires_after="2022-09-01"> +<!-- Name completed by histogram_suffixes name="OsSettingsChangeType" --> + + <owner>khorimoto@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary>The number of navigations before changing a setting.</summary> +</histogram> + +<histogram base="true" name="ChromeOS.Settings.NumSearchesUntilChange" + units="searches" expires_after="2022-09-01"> +<!-- Name completed by histogram_suffixes name="OsSettingsChangeType" --> + + <owner>khorimoto@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary>The number of searches before changing a setting.</summary> +</histogram> + +<histogram name="ChromeOS.Settings.NumSearchResultsFetched" units="results" + expires_after="2022-02-06"> + <owner>khorimoto@chromium.org</owner> + <owner>hsuregan@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary> + The number of search results fetched each time a successful search request + is made to the Settings Search Mojo API. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.OsBannerInteraction" + enum="CrosSettingsOsBannerInteraction" expires_after="2020-12-20"> + <owner>jamescook@chromium.org</owner> + <owner>cros-system-services@google.com</owner> + <summary> + Records whether the "try your Chrome OS settings" banner was shown + when the user opened a new Chrome browser settings tab and also records + interactions with the banner. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.PathVisited" enum="WebUISettingsPathHashes" + expires_after="2022-04-10"> + <owner>khorimoto@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary> + Paths visited within chrome://os-settings. For evaluating popularity and + priorities for OS Settings UI. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.People.AddAccountCount" units="accounts" + expires_after="2022-03-15"> + <owner>khorimoto@chromium.org</owner> + <owner>hsuregan@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary> + Records when users click the Add Account button on the People page. The + number of the account that would be added is saved, e.g. a sample of 2 means + the user entered the add account dialog for a 2nd account. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.Privacy.PeripheralDataAccessProtection" + enum="BooleanEnabled" expires_after="2022-11-30"> + <owner>jimmyxgong@chromium.org</owner> + <owner>cros-peripherals@google.com</owner> + <summary> + Records when the users clicks on the Peripheral Data Access toggle. A true + value refers to the user enables peripheral data access protection (toggle + is turned on). + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.SearchLatency" units="ms" + expires_after="2022-09-01"> + <owner>khorimoto@chromium.org</owner> + <owner>hsuregan@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary> + The time fetching search results from the Settings Search Mojo API. Recorded + when getSearchHandler().search() completes. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.SearchRequests" + enum="OsSettingSearchRequestTypes" expires_after="2022-04-17"> + <owner>khorimoto@chromium.org</owner> + <owner>hsuregan@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary> + The number of search requests made to the Settings Search Mojo API. For + search requests that succeeded with a response, the number of search + requests that had results which were discarded, and the number of search + requests that were shown to the user. Recorded when + getSearchHandler().search() completes. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.SearchRequestsPerSession" + units="mojo search requests" expires_after="2022-09-01"> + <owner>khorimoto@chromium.org</owner> + <owner>hsuregan@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary> + The number of search requests made to the Settings Search Mojo API in one + session of the settings app. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.SearchResultSectionSelected" + enum="OsSettingsSection" expires_after="2022-04-17"> + <owner>khorimoto@chromium.org</owner> + <owner>hsuregan@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary> + Section search results clicked by user in the OS settings search box. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.SearchResultSettingSelected" + enum="OsSetting" expires_after="2022-09-01"> + <owner>khorimoto@chromium.org</owner> + <owner>hsuregan@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary> + Setting search results clicked by user in the OS settings search box. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.SearchResultSubpageSelected" + enum="OsSettingsSubpage" expires_after="2022-04-24"> + <owner>khorimoto@chromium.org</owner> + <owner>hsuregan@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary> + Subpage search results clicked by user in the OS settings search box. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.SearchResultTypeSelected" + enum="OsSettingsSearchResultType" expires_after="2022-04-24"> + <owner>khorimoto@chromium.org</owner> + <owner>hsuregan@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary> + Type of search results clicked by user in the OS settings search box. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.SettingChanged" enum="OsSetting" + expires_after="2022-09-01"> + <owner>khorimoto@chromium.org</owner> + <owner>hsuregan@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary> + Records the the setting id when the user changes a setting. Note that some + of the values of the OsSetting enum aren't strictly settings (such as + kKeyboardShortcuts, which is just a hyperlink). All of the recorded values + appear in the settings page. + </summary> +</histogram> + +<histogram base="true" name="ChromeOS.Settings.TimeUntilChange" units="ms" + expires_after="2022-09-01"> +<!-- Name completed by histogram_suffixes name="OsSettingsChangeType" --> + + <owner>khorimoto@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary> + The time spent on the settings page before changing a setting. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.UserActionOnSearchResultsShown" + enum="OsSettingSearchBoxUserAction" expires_after="2022-02-06"> + <owner>khorimoto@chromium.org</owner> + <owner>hsuregan@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary> + The user action taken when search results exist and are displayed. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.Wifi.AddNetwork" + enum="NetworkDiscoveryState" expires_after="2022-03-30"> + <owner>jonmann@chromium.org</owner> + <owner>khorimoto@chromium.org</owner> + <owner>tnagel@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <owner>cros-privacy-core@google.com</owner> + <summary> + Recorded when the user adds a WiFi network that has not been added before. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.Wifi.Hidden" enum="BooleanToggled" + expires_after="2022-03-30"> + <owner>jonmann@chromium.org</owner> + <owner>khorimoto@chromium.org</owner> + <owner>tnagel@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <owner>cros-privacy-core@google.com</owner> + <summary> + Recorded when the "Hidden" Wi-Fi network toggle is changed by the + user. + </summary> +</histogram> + +<histogram name="ChromeOS.Settings.WindowOpenDuration" units="ms" + expires_after="2022-09-01"> + <owner>khorimoto@chromium.org</owner> + <owner>cros-customization@google.com</owner> + <summary> + The amount of time between when a Chrome OS settings window is opened and + when it is closed. + </summary> +</histogram> + +</histograms> + +</histogram-configuration>
diff --git a/tools/metrics/histograms/metadata/content/histograms.xml b/tools/metrics/histograms/metadata/content/histograms.xml index d9b821ed5..ea53ace 100644 --- a/tools/metrics/histograms/metadata/content/histograms.xml +++ b/tools/metrics/histograms/metadata/content/histograms.xml
@@ -538,7 +538,7 @@ </histogram> <histogram name="ContentSettings.Popups" enum="ContentSettingPopupAction" - expires_after="2022-05-08"> + expires_after="2022-07-11"> <owner>charleszhao@chromium.org</owner> <owner>lazzzis@google.com</owner> <owner>src/components/blocked_content/OWNERS</owner> @@ -961,7 +961,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.Network.Duration" units="ms" - expires_after="2022-07-03"> + expires_after="2022-07-11"> <owner>carlosk@chromium.org</owner> <owner>harringtond@chromium.org</owner> <owner>feed@chromium.org</owner> @@ -1046,7 +1046,7 @@ </histogram> <histogram name="ContentSuggestions.Feed.Network.TokenFetchStatus" - enum="GoogleServiceAuthError" expires_after="2022-05-01"> + enum="GoogleServiceAuthError" expires_after="2022-07-11"> <owner>carlosk@chromium.org</owner> <owner>harringtond@chromium.org</owner> <owner>feed@chromium.org</owner>
diff --git a/tools/metrics/histograms/metadata/cookie/histograms.xml b/tools/metrics/histograms/metadata/cookie/histograms.xml index f6c10c1..6e68227c 100644 --- a/tools/metrics/histograms/metadata/cookie/histograms.xml +++ b/tools/metrics/histograms/metadata/cookie/histograms.xml
@@ -256,7 +256,7 @@ </histogram> <histogram name="Cookie.ExpirationDuration400DaysLTE" units="days" - expires_after="M101"> + expires_after="2022-07-11"> <owner>arichiv@chromium.org</owner> <owner>bingler@chromium.org</owner> <summary> @@ -403,7 +403,7 @@ </histogram> <histogram name="Cookie.IsSamePartyValid" enum="BooleanValid" - expires_after="2022-05-08"> + expires_after="2022-07-11"> <owner>cfredric@chromium.org</owner> <owner>kaustubhag@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/download/histograms.xml b/tools/metrics/histograms/metadata/download/histograms.xml index bba04778..5a1f5db 100644 --- a/tools/metrics/histograms/metadata/download/histograms.xml +++ b/tools/metrics/histograms/metadata/download/histograms.xml
@@ -63,7 +63,7 @@ </histogram> <histogram name="Download.BandwidthOverallBytesPerSecond2" units="bytes/second" - expires_after="2022-05-08"> + expires_after="2022-07-11"> <owner>qinmin@chromium.org</owner> <owner>xingliu@chromium.org</owner> <summary> @@ -1260,7 +1260,7 @@ </histogram> <histogram name="Download.ShowedDownloadWarning" enum="DownloadItem.DangerType" - expires_after="2022-05-08"> + expires_after="2022-07-11"> <owner>drubery@chromium.org</owner> <owner>chrome-safebrowsing-alerts@chromium.org</owner> <summary> @@ -1311,7 +1311,7 @@ </histogram> <histogram name="Download.UserValidatedDangerousDownload" - enum="DownloadItem.DangerType" expires_after="2022-05-08"> + enum="DownloadItem.DangerType" expires_after="2022-07-11"> <owner>drubery@chromium.org</owner> <owner>chrome-safebrowsing-team@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/event/histograms.xml b/tools/metrics/histograms/metadata/event/histograms.xml index fe7f01d..762fe21 100644 --- a/tools/metrics/histograms/metadata/event/histograms.xml +++ b/tools/metrics/histograms/metadata/event/histograms.xml
@@ -23,188 +23,6 @@ <histograms> <variants name="EventLatencyBreakdown"> - <variant name="Activation" summary="the duration of the activation stage"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant name="BeginImplFrameToSendBeginMainFrame" - summary="the time from when the compositor impl frame is started to when - BeginMainFrame is sent"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant name="BrowserToRendererCompositor" - summary="the time from when the event is generated until the first - compositor stage after the event arrives in the renderer"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant name="Commit" summary="the duration of the commit stage"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant name="EndActivateToSubmitCompositorFrame" - summary="the time from when an activation is complete to the next - SubmitCompositorFrame"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant name="EndCommitToActivation" - summary="the time from when a commit is complete to the beginning of the - next activation"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant name="SendBeginMainFrameToCommit" - summary="the time from when the BeginMainFrame is sent to the beginning - of the commit"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant name="SendBeginMainFrameToCommit.Animate" - summary="the time portion of SendBeginMainFrameToCommit spent on - animations"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant name="SendBeginMainFrameToCommit.BeginMainSentToStarted" - summary="the time portion of SendBeginMainFrameToCommit spent before - starting main thread work"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant name="SendBeginMainFrameToCommit.Composite" - summary="the time portion of SendBeginMainFrameToCommit spent on - compositing"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant name="SendBeginMainFrameToCommit.CompositeCommit" - summary="the time portion of SendBeginMainFrameToCommit spent on - composite commit"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant name="SendBeginMainFrameToCommit.CompositingAssignments" - summary="the time portion of SendBeginMainFrameToCommit spent on - updating compositing assignments"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant name="SendBeginMainFrameToCommit.CompositingInputs" - summary="the time portion of SendBeginMainFrameToCommit spent on - updating compositing inputs"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant name="SendBeginMainFrameToCommit.HandleInputEvents" - summary="the time portion of SendBeginMainFrameToCommit spent on - handling imput events"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant name="SendBeginMainFrameToCommit.LayoutUpdate" - summary="the time portion of SendBeginMainFrameToCommit spent on layout - update"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant name="SendBeginMainFrameToCommit.Paint" - summary="the time portion of SendBeginMainFrameToCommit spent on paint"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant name="SendBeginMainFrameToCommit.Prepaint" - summary="the time portion of SendBeginMainFrameToCommit spent on - prepaint"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant name="SendBeginMainFrameToCommit.ScrollingCoordinator" - summary="the time portion of SendBeginMainFrameToCommit spent on - scrolling coordinator"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant name="SendBeginMainFrameToCommit.StyleUpdate" - summary="the time portion of SendBeginMainFrameToCommit spent on style - update"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant name="SendBeginMainFrameToCommit.UpdateLayers" - summary="the time portion of SendBeginMainFrameToCommit spent on - updating layers"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant name="SubmitCompositorFrameToPresentationCompositorFrame" - summary="the time from when the compositor frame is submitted to the - display compositor to when it is presented"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant - name="SubmitCompositorFrameToPresentationCompositorFrame.ReceivedCompositorFrameToStartDraw" - summary="the time from when the compositor frame is received to when it - starts to draw"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant - name="SubmitCompositorFrameToPresentationCompositorFrame.StartDrawToSwapStart" - summary="the time from when the compositor frame is started to draw to - when it starts swap"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant - name="SubmitCompositorFrameToPresentationCompositorFrame.SubmitToReceiveCompositorFrame" - summary="the time from when the compositor frame is submitted to when it - is received"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant - name="SubmitCompositorFrameToPresentationCompositorFrame.SwapEndToPresentationCompositorFrame" - summary="the time from when the compositor frame ends swap to when it is - presented"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> - <variant - name="SubmitCompositorFrameToPresentationCompositorFrame.SwapStartToSwapEnd" - summary="the time from when the compositor frame starts to swap to when - it ends swap"> - <obsolete> - Obsolete as of M90. Breakdowns are being tracked in UKM. - </obsolete> - </variant> <variant name="TotalLatency" summary="total latency from when the event is generated until the frame is presented on screen"/> @@ -372,53 +190,6 @@ </summary> </histogram> -<histogram name="Event.FractionOfTimeWithoutUserInput" units="%" - expires_after="2021-06-16"> - <obsolete> - Removed December 2021. - </obsolete> - <owner>sullivan@chromium.org</owner> - <owner>speed-metrics-dev@chromium.org</owner> - <summary> - For each 10 second window, reports the fraction of the time there was no - user input. We consider there to be no user input if we haven't received any - events for > 50ms. - </summary> -</histogram> - -<histogram name="Event.FrameEventRouting.NoGestureTarget" units="units" - expires_after="2020-02-23"> - <obsolete> - Removed 2020.10.20 - no longer in use. - </obsolete> - <owner>wjmaclean@chromium.org</owner> - <summary> - Record whether we unexpectedly encounter an empty gesture queue while - routing gesture events to frames' renderers: true => empty queue, false - => non-empty queue. - </summary> -</histogram> - -<histogram name="Event.FrameEventRouting.TouchEventAckQueueSize" units="units" - expires_after="2020-07-19"> - <obsolete> - 2020.10.21 - Removed. - </obsolete> - <owner>wjmaclean@chromium.org</owner> - <owner>kenrb@chromium.org</owner> - <summary> - The size of the TouchEventAckQueue, recorded each time we process an event - ack (the queue usually, but not always, decreases in size during ack - processing). Ideally this queue will operate at length close to zero, - depending on how long it takes for events to travel to a renderer and be - processed and an ack sent back. As the size increases it indicates decreased - responsiveness of renderers with respect to touch events. One purpose of - this metric is to develop a sense of normal queue sizes for different - platforms. Initially we expect queue length to be less than 20 most of the - time, but this is a guess. - </summary> -</histogram> - <histogram name="Event.GestureCreated" enum="UIEventType" expires_after="2020-03-01"> <owner>kuscher@google.com</owner> @@ -431,18 +202,6 @@ </summary> </histogram> -<histogram name="Event.HitTest" enum="EventHitTest" expires_after="2020-05-31"> - <obsolete> - Removed in M88. - </obsolete> - <owner>dtapuska@chromium.org</owner> - <summary> - For each hit test, records whether it was a hit or miss, and why. - - Team: input-dev@chromium.org. - </summary> -</histogram> - <histogram name="Event.HitTestValidity" enum="EventHitTestValidity" expires_after="M85"> <owner>dtapuska@chromium.org</owner> @@ -513,22 +272,6 @@ </summary> </histogram> -<histogram name="Event.InputEventPrediction.Scroll.WrongDirection" - enum="Boolean" expires_after="M97"> - <obsolete> - Removed 2021-12-02. - </obsolete> - <owner>flackr@chromium.org</owner> - <owner>joalmei@microsoft.com</owner> - <summary> - Boolean that indicates whether the prediction is in the same direction as - the real trajectory at the same prediction time. True means the direction is - not the same (wrong direction). - - Team: input-dev@chromium.org. - </summary> -</histogram> - <histogram name="Event.InputEventPrediction.Scroll.{ScoreType}" units="pixels" expires_after="M97"> <owner>flackr@chromium.org</owner> @@ -707,71 +450,6 @@ </summary> </histogram> -<histogram name="Event.Latency.OS_WIN.HIGH_RES" units="ms" - expires_after="2021-12-01"> - <obsolete> - Removed 2021-04-22 - replaced by Event.Latency.OS2. - </obsolete> - <owner>joenotcharles@chromium.org</owner> - <owner>catan-team@chromium.org</owner> - <summary> - Experimental Windows-only histogram similar to Event.Latency.OS, but - recorded only for MOUSE_PRESSED, KEY_PRESSED and TOUCH_PRESSED events and - including the true time between when the event is generated by the OS and - when it is received by Chrome. - - On Windows, ui::Event structures include a timestamp based on the time the - event is received, not when it is generated, so the cross-platform - Event.Latency.OS histograms which are based on this timestamp are wrong. - - This metric is only reported from clients with high-resolution clocks. - Clients with low-resolution clocks record Event.Latency.OS_WIN.LOW_RES - instead. Once we validate that there is no difference between the two - metrics and all is working as expected we will combine them into a single - cross-platform event latency metric. - </summary> -</histogram> - -<histogram name="Event.Latency.OS_WIN.LOW_RES" units="ms" - expires_after="2021-12-01"> - <obsolete> - Removed 2021-04-22 - replaced by Event.Latency.OS2. - </obsolete> - <owner>joenotcharles@chromium.org</owner> - <owner>catan-team@chromium.org</owner> - <summary> - Experimental Windows-only histogram similar to Event.Latency.OS, but - recorded only for MOUSE_PRESSED, KEY_PRESSED and TOUCH_PRESSED events and - including the true time between when the event is generated by the OS and - when it is received by Chrome. - - On Windows, ui::Event structures include a timestamp based on the time the - event is received, not when it is generated, so the cross-platform - Event.Latency.OS histograms which are based on this timestamp are wrong. - - This metric is only reported from clients with low-resolution clocks. - Clients with high-resolution clocks record Event.Latency.OS_WIN.HIGH_RES - instead. Once we validate that there is no difference between the two - metrics and all is working as expected we will combine them into a single - cross-platform event latency metric. - </summary> -</histogram> - -<histogram name="Event.Latency.OS_WIN_IS_VALID" enum="Boolean" - expires_after="2021-12-01"> - <obsolete> - Removed 2021-04-22 - replaced by Event.Latency.OS2. - </obsolete> - <owner>joenotcharles@chromium.org</owner> - <owner>catan-team@chromium.org</owner> - <summary> - Windows-only boolean that records whether an input event has a valid OS - timestamp, recorded for MOUSE_PRESSED, KEY_PRESSED and TOUCH_PRESSED events - when they are received by Chrome. This is used to estimate the bias caused - by skipping events with invalid timestamps in Event.Latency.OS_WIN.*. - </summary> -</histogram> - <histogram name="Event.Latency.Scroll.Wheel.TimeToHandled2" units="microseconds" expires_after="2021-12-19"> <owner>flackr@chromium.org</owner> @@ -793,29 +471,6 @@ </summary> </histogram> -<histogram name="Event.Latency.Scroll.Wheel.TimeToScrollUpdateSwapBegin2" - units="microseconds" expires_after="2020-06-21"> - <obsolete> - Removed 2021-01-14 - replaced by Event.Latency.Scroll(Begin|Update).Wheel.*. - </obsolete> - <owner>flackr@chromium.org</owner> - <summary> - Time between initial creation of a wheel event and start of the frame swap - on the GPU service caused by the generated ScrollUpdate gesture event. If no - swap was induced by the event, no recording is made. Unlike - Event.Latency.ScrollUpdate.Wheel.TimeToScrollUpdateSwapBegin2 this metric - includes the first GSU of every scrolling sequence as well. - - Team: input-dev@chromium.org. - - Warning: This metric may include reports from clients with low-resolution - clocks (i.e. on Windows, ref. |TimeTicks::IsHighResolution()|). Such reports - will cause this metric to have an abnormal distribution. When considering - revising this histogram, see UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES for the - solution. - </summary> -</histogram> - <histogram name="Event.Latency.ScrollBegin.Scrollbar.BrowserNotifiedToBeforeGpuSwap2" units="microseconds" expires_after="2022-06-01"> @@ -975,28 +630,6 @@ </summary> </histogram> -<histogram name="Event.Latency.ScrollBegin.Touch.AverageLag" units="pixels" - expires_after="M97"> - <obsolete> - Removed 2021.06.30 - replaced by AverageLagPresentation, which is more - accurate. - </obsolete> - <owner>flackr@chromium.org</owner> - <owner>joalmei@microsoft.com</owner> - <owner>input-dev@chromium.org</owner> - <summary> - Measures an average distance that represents how the page sticks to the - finger when user scrolls. Only reports touch scrolling. See - https://docs.google.com/document/d/154jddNiKtxELBvrjLz9v6A7sA1J3iwQQzySHgtY12Oo/ - - This is the lag caused by the Gesture Scroll Begin Event. In each touch - interaction there is a GSB followed by multiple Gesture Scroll Updates, - which are separately logged by Event.Latency.ScrollUpdate.Touch.AverageLag. - - Team: input-dev@chromium.org. - </summary> -</histogram> - <histogram name="Event.Latency.ScrollBegin.Touch.AverageLagPresentation" units="pixels" expires_after="2022-05-01"> <owner>flackr@chromium.org</owner> @@ -1600,62 +1233,6 @@ </summary> </histogram> -<histogram name="Event.Latency.ScrollUpdate.Touch.AverageLag" units="pixels" - expires_after="M97"> - <obsolete> - Removed 2021.06.30 - replaced by AverageLagPresentation, which is more - accurate. - </obsolete> - <owner>flackr@chromium.org</owner> - <owner>joalmei@microsoft.com</owner> - <owner>input-dev@chromium.org</owner> - <summary> - Measures an average distance that represents how the page sticks to the - finger when user scrolls. Only reports touch scrolling. See - https://docs.google.com/document/d/154jddNiKtxELBvrjLz9v6A7sA1J3iwQQzySHgtY12Oo/ - - This is the lag caused by the Gesture Scroll Updates occourring in the - lifetime of a scroll interaction. - - Team: input-dev@chromium.org. - </summary> -</histogram> - -<histogram - name="Event.Latency.ScrollUpdate.Touch.AverageLag.{PredictionImpact}" - units="pixels" expires_after="M97"> - <obsolete> - Removed 2021.06.30 - replaced by AverageLagPresentation.{PredictionImpact}, - which is more accurate. - </obsolete> - <owner>flackr@chromium.org</owner> - <owner>joalmei@microsoft.com</owner> - <owner>input-dev@chromium.org</owner> - <summary> - Improvement of prediction in touch lag. It is defined as - (Lag_without_prediction - Lag_with_prediction). - - Lag is the distance between the finger position and the rendered position. - - When positive, prediction improves touch performance (reduces lag). When - negative, prediction worsens touch performance (increases lag). - - The duration of the interaction/interval is either 1s, or the time from when - the user starts scrolling to lifting the finger, whichever is smaller. - - Lag_with_prediction = - Event.Latency.ScrollUpdate.Touch.AverageLagPresentation - Lag_without_prediction = - Event.Latency.ScrollUpdate.Touch.AverageLagPresentation.NoPrediction - - Team: input-dev@chromium.org. - </summary> - <token key="PredictionImpact"> - <variant name="PredictionNegative" summary="Negative impact values"/> - <variant name="PredictionPositive" summary="Positive impact values"/> - </token> -</histogram> - <histogram name="Event.Latency.ScrollUpdate.Touch.AverageLagPresentation" units="pixels" expires_after="2022-05-08"> <owner>flackr@chromium.org</owner> @@ -2160,37 +1737,6 @@ </summary> </histogram> -<histogram name="Event.TouchDuration" units="ms" expires_after="M77"> - <obsolete> - Removed 2021.03.30 - no longer in use. - </obsolete> - <owner>kuscher@google.com</owner> - <owner>flackr@chromium.org</owner> - <summary> - The duration of a touch-sequence. Only measured for single finger gestures. - This replaces Ash.TouchDuration2, which did not record events on Android and - Windows. - - Team: input-dev@chromium.org. - </summary> -</histogram> - -<histogram name="Event.TouchMaxDistance" units="pixels" expires_after="M77"> - <obsolete> - Removed 2021.03.30 - replaced by Event.MaxDragDistance.*. - </obsolete> - <owner>kuscher@google.com</owner> - <owner>flackr@chromium.org</owner> - <summary> - The maximum euclidean distance in dips (device independent pixel) which a - touch point has travelled away from its starting point. Only measured for - single finger gestures. This replaces Ash.TouchMaxDistance, which did not - record events on Android and Windows. - - Team: input-dev@chromium.org. - </summary> -</histogram> - <histogram name="Event.TouchSelection.Duration" units="ms" expires_after="M77"> <owner>nzolghadr@chromium.org</owner> <summary> @@ -2375,14 +1921,6 @@ <variant name="TotalLatencyToSwapBegin" summary="total latency from when the event is generated until the gpu-swap is started"/> - <variant name="TotalLatencyToSwapEnd" - summary="total latency from when the event is generated until the - gpu-swap is completed"> - <obsolete> - Deprecated as of 07/2020. Replaced with TotalLatencyToSwapBegin variant - which measures what we actually intended to measure. - </obsolete> - </variant> </token> </histogram>
diff --git a/tools/metrics/histograms/metadata/extensions/histograms.xml b/tools/metrics/histograms/metadata/extensions/histograms.xml index 8b118fc..7ecce096 100644 --- a/tools/metrics/histograms/metadata/extensions/histograms.xml +++ b/tools/metrics/histograms/metadata/extensions/histograms.xml
@@ -500,7 +500,7 @@ </histogram> <histogram name="Extensions.Debugger.UserIsInDeveloperMode" - enum="InDeveloperMode" expires_after="2022-03-04"> + enum="InDeveloperMode" expires_after="2022-07-11"> <owner>ghazale@chromium.org</owner> <owner>extensions-core@chromium.org</owner> <summary> @@ -759,7 +759,7 @@ </histogram> <histogram name="Extensions.DevTools.UserIsInDeveloperMode" - enum="InDeveloperMode" expires_after="2022-03-04"> + enum="InDeveloperMode" expires_after="2022-07-11"> <owner>ghazale@chromium.org</owner> <owner>extensions-core@chromium.org</owner> <summary> @@ -1126,7 +1126,7 @@ </histogram> <histogram name="Extensions.ExtensionDisabledRemotely2" - enum="ExtensionUpdateCheckDataKey" expires_after="2022-05-08"> + enum="ExtensionUpdateCheckDataKey" expires_after="2022-07-11"> <owner>drubery@chromium.org</owner> <owner>chrome-safebrowsing-alerts@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/geolocation/histograms.xml b/tools/metrics/histograms/metadata/geolocation/histograms.xml index 2c6576dd..f79c01a 100644 --- a/tools/metrics/histograms/metadata/geolocation/histograms.xml +++ b/tools/metrics/histograms/metadata/geolocation/histograms.xml
@@ -87,7 +87,7 @@ </histogram> <histogram name="Geolocation.LocationUpdate.ErrorCode" - enum="GeopositionErrorCode" expires_after="2022-04-17"> + enum="GeopositionErrorCode" expires_after="2022-07-11"> <owner>mattreynolds@chromium.org</owner> <owner>device-dev@chromium.org</owner> <summary>Error code for the geoposition sent to the renderers.</summary>
diff --git a/tools/metrics/histograms/metadata/gpu/histograms.xml b/tools/metrics/histograms/metadata/gpu/histograms.xml index 4d065cd..6399dce 100644 --- a/tools/metrics/histograms/metadata/gpu/histograms.xml +++ b/tools/metrics/histograms/metadata/gpu/histograms.xml
@@ -196,23 +196,6 @@ </summary> </histogram> -<histogram name="Display.GenerateDisplayId.CollisionDetection" - enum="BooleanDisplayIdCollision" expires_after="2022-09-01"> - <obsolete> - Replaced by Display.MultipleDisplays.GenerateId.CollisionDetection in M95. - </obsolete> - <owner>gildekel@chromium.org</owner> - <owner>seanpaul@chromium.org</owner> - <owner>chromeos-gfx-display@google.com</owner> - <summary> - Whether or not displays produced identical display IDs due to insufficient - EDIDs. This may occur when identical displays (same make and model) lack - serial numbers in both the EDID's block zero or S/N descriptor block. - Recorded every time Chrome OS detects a change in display configuration and - attempts to get an updated list of available displays. - </summary> -</histogram> - <histogram name="Display.MultipleDisplays.GenerateId.CollisionDetection" enum="BooleanDisplayIdCollision" expires_after="2022-09-01"> <owner>gildekel@chromium.org</owner> @@ -432,54 +415,6 @@ </summary> </histogram> -<histogram name="GPU.BlacklistFeatureTestResults" - enum="GPUBlocklistFeatureTestResults" expires_after="M89"> - <obsolete> - Replaced by GPU.BlocklistFeatureTestResults in M89. - </obsolete> - <owner>vmiura@chromium.org</owner> - <summary> - Counts number of browser invocations for which a GPU feature is - allowed/blacklisted/disabled. - </summary> -</histogram> - -<histogram name="GPU.BlacklistFeatureTestResultsWindows2" - enum="GPUBlocklistFeatureTestResultsWindows2" expires_after="M89"> - <obsolete> - Removed in Oct 2020. - </obsolete> - <owner>vmiura@chromium.org</owner> - <summary> - Counts number of browser invocations for which a GPU feature is - allowed/blacklisted/disabled in various Windows sub-versions. - </summary> -</histogram> - -<histogram name="GPU.BlacklistTestResultsPerDisabledEntry" - enum="GPUBlocklistTestResultPerEntry" expires_after="M85"> - <obsolete> - Removed before M86. - </obsolete> - <owner>vmiura@chromium.org</owner> - <summary> - Counts number of browser invocations for which a disabled blacklist entry is - matched. - </summary> -</histogram> - -<histogram name="GPU.BlacklistTestResultsPerEntry" - enum="GPUBlocklistTestResultPerEntry" expires_after="M89"> - <obsolete> - Replaced by GPU.BlocklistTestResultsPerEntry in M89. - </obsolete> - <owner>vmiura@chromium.org</owner> - <summary> - Counts number of browser invocations for which the GPU process is blocked - due to a blocklist entry match. - </summary> -</histogram> - <histogram name="GPU.BlocklistFeatureTestResults" enum="GPUBlocklistFeatureTestResults" expires_after="2022-06-26"> <owner>vmiura@chromium.org</owner> @@ -546,16 +481,6 @@ </summary> </histogram> -<histogram name="GPU.ContextMemory" units="MB" expires_after="2020-09-13"> - <obsolete> - Obsoleted since 2020/10/15. Unused and expired. Replaced by - Memory.Gpu.PrivateMemoryFootprint, Memory.GPU.PeakMemoryUsage, and - Memory.GPU.PeakMemoryAllocationSource. - </obsolete> - <owner>ericrk@chromium.org</owner> - <summary>The amount of memory used by a GL Context.</summary> -</histogram> - <histogram name="GPU.D3D11_B8G8R8A8_RenderTargetSupport" enum="BooleanSuccess" expires_after="M85"> <owner>vmiura@chromium.org</owner> @@ -620,35 +545,6 @@ </summary> </histogram> -<histogram name="GPU.DirectComposition.CompositionMode" - enum="DxgiFramePresentationMode" expires_after="M92"> - <obsolete> - Obsoleted after M92. Unused and expired. Replaced by - GPU.DirectComposition.CompositionMode2.VideoOrCanvas. - </obsolete> - <owner>sunnyps@chromium.org</owner> - <owner>zmo@chromium.org</owner> - <summary> - How the Desktop Window Manager presented Chrome's DirectComposition layers - to the screen. - </summary> -</histogram> - -<histogram name="GPU.DirectComposition.CompositionMode.MainBuffer" - enum="DxgiFramePresentationMode" expires_after="M92"> - <obsolete> - Obsoleted after M92. Unused and expired. Replaced by - GPU.DirectComposition.CompositionMode2.MainBuffer.FullDamage and - GPU.DirectComposition.CompositionMode2.MainBuffer.PartialDamage. - </obsolete> - <owner>zmo@chromium.org</owner> - <owner>graphics-dev@chromium.org</owner> - <summary> - How the Desktop Window Manager presented Chrome's main DirectComposition - layer to the screen. - </summary> -</histogram> - <histogram name="GPU.DirectComposition.CompositionMode2.MainBuffer.{Damage}" enum="DxgiFramePresentationMode" expires_after="2021-12-31"> <owner>zmo@chromium.org</owner> @@ -682,19 +578,6 @@ </summary> </histogram> -<histogram name="GPU.DirectComposition.CreateVideoProcessorEnumerator" - enum="Hresult" expires_after="2021-07-09"> - <obsolete> - Removed 07/09/2021. CreateVideoProcessorEnumerator rarely fails. - </obsolete> - <owner>magchen@chromium.org</owner> - <owner>zmo@chromium.org</owner> - <summary> - HRESULT return value of ID3D11VideoDevice::CreateVideoProcessorEnumerator in - Direct Composition InitializeVideoProcessor. - </summary> -</histogram> - <histogram name="GPU.DirectComposition.DCLayer.YUVOverlayCount" units="overlays" expires_after="2022-06-26"> <owner>magchen@chromium.org</owner> @@ -767,18 +650,6 @@ </summary> </histogram> -<histogram name="GPU.DirectComposition.FramesSinceColorSpaceChange" - units="frames" expires_after="2021-06-15"> - <obsolete> - Removed 07/2021. - </obsolete> - <owner>sunnyps@chromium.org</owner> - <owner>zmo@chromium.org</owner> - <summary> - How many frames since the last time the layer color format was changed. - </summary> -</histogram> - <histogram name="GPU.DirectComposition.HardwareOverlaysSupported" enum="BooleanOverlaySupported" expires_after="2022-10-01"> <owner>magchen@chromium.org</owner> @@ -826,19 +697,6 @@ <summary>True if Chrome will try to use DirectComposition overlays.</summary> </histogram> -<histogram name="GPU.DirectComposition.OverlaysUsed" enum="BooleanOverlayUsage" - expires_after="2021-05-26"> - <obsolete> - Removed 05/2021. The data has been collected. - </obsolete> - <owner>magchen@chromium.org</owner> - <owner>sunnyps@chromium.org</owner> - <summary> - Whether or not a frame displays an overlay. Recorded when - DCLayerTree::CommitAndClearPendingOverlays() is called. - </summary> -</histogram> - <histogram base="true" name="GPU.DirectComposition.SwapChainCreationResult2" enum="Hresult" expires_after="2019-05-31"> <!-- Name completed by histogram_suffixes name="GPU.DirectComposition.OverlayFormat" --> @@ -872,45 +730,6 @@ </summary> </histogram> -<histogram name="GPU.DirectComposition.UploadVideoImages.CreateCopyTexture" - enum="Hresult" expires_after="2021-07-09"> - <obsolete> - Removed 07/09/2021. CreateTexture2D for a copy texture rarely fails. - </obsolete> - <owner>magchen@chromium.org</owner> - <owner>zmo@chromium.org</owner> - <summary> - HRESULT return value of ID3D11Device::CreateTexture2D in Direct Composition - UploadVideoImages for creating a copy texture. - </summary> -</histogram> - -<histogram name="GPU.DirectComposition.UploadVideoImages.CreateStagingTexture" - enum="Hresult" expires_after="2021-07-09"> - <obsolete> - Removed 07/09/2021. CreateTexture2D for a staging texture rarely fails. - </obsolete> - <owner>magchen@chromium.org</owner> - <owner>zmo@chromium.org</owner> - <summary> - HRESULT return value of ID3D11Device::CreateTexture2D in Direct Composition - UploadVideoImages for creating a staging texture. - </summary> -</histogram> - -<histogram name="GPU.DirectComposition.VideoDeviceCreateVideoProcessor" - enum="Hresult" expires_after="2021-07-09"> - <obsolete> - Removed 07/09/2021. CreateVideoProcessor rarely fails. - </obsolete> - <owner>magchen@chromium.org</owner> - <owner>zmo@chromium.org</owner> - <summary> - HRESULT return value of ID3D11VideoDevice::CreateVideoProcessor in Direct - Composition InitializeVideoProcessor. - </summary> -</histogram> - <histogram name="GPU.DirectComposition.VideoPresentationMode" enum="DirectCompositionVideoPresentationMode" expires_after="2022-03-06"> <owner>sunnyps@chromium.org</owner> @@ -1055,51 +874,6 @@ </summary> </histogram> -<histogram name="GPU.GpuBlockedBetweenSwapsUs2" units="microseconds" - expires_after="2020-12-01"> - <obsolete> - Removed in Nov 2020 (available as local histogram for telemetry runs). - </obsolete> - <owner>vasilyt@chromium.org</owner> - <owner>backer@chromium.org</owner> - <summary> - This metric recorded only with --enable-gpu-blocked-time flag. This is - logged once per frame if the output surface provides timing information. It - measures the time Gpu Main thread was blocked (difference between wall time - and cpu time) during tasks execution for currect frame. Only reported when - there is single surface swap in the same vsync interval. Only reported for - platforms supporting high resolution clocks. - </summary> -</histogram> - -<histogram name="GPU.GPUChannelHostWaitTime2" units="ms" - expires_after="2020-11-18"> - <obsolete> - Used by GPU watchdog V2 finch. Obsolete since 11/18/2020. - </obsolete> - <owner>magchen@chromium.org</owner> - <owner>zmo@chromium.org</owner> - <summary> - The wait time between the IPC message sent from the GPU channel host and the - event sync from the GPU process. If the wait time takes longer than 120 - seconds, 120 seconds will be recoreded. - </summary> -</histogram> - -<histogram name="GPU.GPUChannelHostWaitTime3" units="microseconds" - expires_after="2021-12-01"> - <obsolete> - No longer used as of Jun 2021. - </obsolete> - <owner>magchen@chromium.org</owner> - <owner>zmo@chromium.org</owner> - <summary> - The wait time between the IPC message sent from the GPU channel host and the - event sync from the GPU process. This is the time the browser UI thread - spends blocked. Recorded only for users with high-resolution clocks. - </summary> -</histogram> - <histogram name="GPU.GpuCount" units="gpus" expires_after="2022-06-05"> <owner>zmo@chromium.org</owner> <owner>graphics-dev@chromium.org</owner> @@ -1109,20 +883,6 @@ </summary> </histogram> -<histogram name="GPU.GPUInitializationTime.V2" units="ms" - expires_after="2020-12-15"> - <obsolete> - Removed 12/2020. Moved to GPU.GPUInitializationTime.V3. - </obsolete> - <owner>magchen@chromium.org</owner> - <owner>zmo@chromium.org</owner> - <summary> - The time between the GPU process starts and the GPU Info is collected at GPU - process startup and recorded in browser process when this piece info is sent - back to browser process. The range is between 200ms and 5s. - </summary> -</histogram> - <histogram name="GPU.GPUInitializationTime.V3" units="ms" expires_after="2022-06-12"> <owner>magchen@chromium.org</owner> @@ -1290,24 +1050,6 @@ </summary> </histogram> -<histogram name="Gpu.Metal.ReadWriteTextureSupport" - enum="MetalReadWriteTextureSupportTier" expires_after="2022-05-31"> - <obsolete> - Code producing this histogram has been reverted while we investigate - crashes. Since 2022-01-06. - </obsolete> - <owner>cwallez@chromium.org</owner> - <owner>graphics-dev@chromium.org</owner> - <summary> - Read-write textures are not always supported on Metal. This histograms is - meant to gather information so that the WebGPU W3C group can decide whether - to require support for this feature. The reported tier is the best tier that - was found on the system. Meaning that if only one of the GPUs support - read-write textures, a non-zero tier will be reported. The histogram is - recorded at GPU process startup time. - </summary> -</histogram> - <histogram name="Gpu.Metal.TestShaderCompileTime" units="ms" expires_after="M85"> <owner>ccameron@chromium.org</owner> @@ -1397,20 +1139,6 @@ </summary> </histogram> -<histogram name="GPU.Output.ColorSpace" enum="DXGI_COLOR_SPACE_TYPE" - expires_after="2020-10-11"> - <obsolete> - Will be replaced with a platform agnostic version. Removed Oct 2020. - </obsolete> - <owner>hubbe@chromium.org</owner> - <owner>media-dev@chromium.org</owner> - <summary> - Records the output color space of the monitor as reported by Windows. - Recorded once for each monitor when the gpu process starts. If monitor - enumeration fails, this metric will not be provided. - </summary> -</histogram> - <histogram name="GPU.Output.HDR" enum="Boolean" expires_after="2022-04-24"> <owner>hubbe@chromium.org</owner> <owner>media-dev@chromium.org</owner> @@ -1443,19 +1171,6 @@ </summary> </histogram> -<histogram name="GPU.PreferredGLImplementation" enum="GLImplementation" - expires_after="2021-08-01"> - <obsolete> - Removed in M93 - </obsolete> - <owner>jonahr@google.com</owner> - <owner>graphics-dev@chromium.org</owner> - <summary> - Records the platform-preferred OpenGL implementation mode. Recorded during - GPU process initilization in gl::GetRequestedGLImplementation. - </summary> -</histogram> - <histogram name="GPU.ProcessIntegrityResult" enum="ProcessIntegrityResult" expires_after="2021-12-12"> <owner>zmo@chromium.org</owner> @@ -1587,19 +1302,6 @@ </token> </histogram> -<histogram name="GPU.RequestedGLImplementation" enum="GLImplementation" - expires_after="2021-08-01"> - <obsolete> - Removed in M93 - </obsolete> - <owner>jonahr@google.com</owner> - <owner>graphics-dev@chromium.org</owner> - <summary> - Records the user-requested OpenGL implementation mode. Recorded during GPU - process initilization in gl::GetRequestedGLImplementation. - </summary> -</histogram> - <histogram name="GPU.Sandbox.InitializedSuccessfully" enum="BooleanSuccess" expires_after="2020-08-30"> <owner>vmiura@chromium.org</owner> @@ -1759,73 +1461,6 @@ </summary> </histogram> -<histogram name="GPU.Vulkan.CreateExternalVkSemaphore" units="microseconds" - expires_after="2021-08-09"> - <obsolete> - Removed in M91 - </obsolete> - <owner>backer@chromium.org</owner> - <owner>penghuang@chromium.org</owner> - <owner>vasilyt@chromium.org</owner> - <summary> - The amount of time required to create an external VkSemaphore. Only reported - for platforms supporting high resolution clocks. - </summary> -</histogram> - -<histogram name="GPU.Vulkan.GetVkSemaphoreHandle" units="microseconds" - expires_after="2021-04-04"> - <obsolete> - Removed in M91 - </obsolete> - <owner>backer@chromium.org</owner> - <owner>penghuang@chromium.org</owner> - <owner>vasilyt@chromium.org</owner> - <summary> - The amount of time required to get a file handle from a VkSemaphore. Only - reported for platforms supporting high resolution clocks. - </summary> -</histogram> - -<histogram name="GPU.Vulkan.ImportSemaphoreGLPerSwapBuffers" units="units" - expires_after="2021-08-09"> - <obsolete> - Removed in M91 - </obsolete> - <owner>backer@chromium.org</owner> - <owner>penghuang@chromium.org</owner> - <owner>vasilyt@chromium.org</owner> - <summary>The number of semaphores imported into GL per frame.</summary> -</histogram> - -<histogram name="GPU.Vulkan.ImportVkSemaphoreHandle" units="microseconds" - expires_after="2021-08-09"> - <obsolete> - Removed in M91 - </obsolete> - <owner>backer@chromium.org</owner> - <owner>penghuang@chromium.org</owner> - <owner>vasilyt@chromium.org</owner> - <summary> - The amount of time required to import a VkSemaphore from a file handle. Only - reported for platforms supporting high resolution clocks. - </summary> -</histogram> - -<histogram name="GPU.Vulkan.ImportVkSemaphoreIntoGL" units="microseconds" - expires_after="2021-08-09"> - <obsolete> - Removed in M91 - </obsolete> - <owner>backer@chromium.org</owner> - <owner>penghuang@chromium.org</owner> - <owner>vasilyt@chromium.org</owner> - <summary> - The amount of time required to import a VkSemaphore into GL. Only reported - for platforms supporting high resolution clocks. - </summary> -</histogram> - <histogram name="GPU.Vulkan.PipelineCache.LoadCacheHit" enum="BooleanCacheHit" expires_after="2022-05-08"> <owner>backer@chromium.org</owner> @@ -1885,20 +1520,6 @@ </summary> </histogram> -<histogram name="GPU.Vulkan.QueueSubmitPerSwapBuffers" units="units" - expires_after="2021-07-31"> - <obsolete> - Removed before 2021-07-31. - </obsolete> - <owner>backer@chromium.org</owner> - <owner>penghuang@chromium.org</owner> - <owner>vasilyt@chromium.org</owner> - <summary> - The number of vkQueueSubmit() calls per SwapBuffers. It is recorded when - SwapBuffers() call is completed or skipped. - </summary> -</histogram> - <histogram name="GPU.WaitForVBlankErrorCode" enum="WaitForVBlankErrorCode" expires_after="M85"> <owner>stanisc@chromium.org</owner> @@ -1919,36 +1540,6 @@ </summary> </histogram> -<histogram name="GPU.WatchdogThread.ExtraThreadTime" units="# timeouts" - expires_after="2021-09-01"> - <obsolete> - Removed 08/2021. - </obsolete> -<!-- Name completed by histogram_suffixes name="GPU.WatchdogStage" --> - - <owner>magchen@chromium.org</owner> - <owner>zmo@chromium.org</owner> - <summary> - The number of extra timeouts the GPU main thread needs to make any progress - after the first watchdog timeout. - </summary> -</histogram> - -<histogram name="GPU.WatchdogThread.ExtraThreadTime.NumOfUsers" - units="# timeouts" expires_after="2021-09-01"> - <obsolete> - Removed 08/2021. - </obsolete> - <owner>magchen@chromium.org</owner> - <owner>zmo@chromium.org</owner> - <summary> - Records the number of the watchdog timeout functions being entered at each - timeout after allowing the GPU to finish the current job with extra thread - time. If the user decides to quite Chrome, the recorded count would decrease - at the next timeout. - </summary> -</histogram> - <histogram name="GPU.WatchdogThread.Timeout" enum="GpuWatchdogTimeoutEvent" expires_after="2022-06-19"> <!-- Name completed by histogram_suffixes name="GPU.WatchdogStage" --> @@ -1960,49 +1551,6 @@ </summary> </histogram> -<histogram name="GPU.WatchdogThread.WaitTime" units="ms" - expires_after="2020-11-18"> - <obsolete> - Used for an experiment only. Removed 11/2020. - </obsolete> -<!-- Name completed by histogram_suffixes name="GPU.WatchdogStage" --> - - <owner>magchen@chromium.org</owner> - <owner>zmo@chromium.org</owner> - <summary> - Record the wait time in OnWatchdogTimeout() for the GPU main thread to make - any progress. - </summary> -</histogram> - -<histogram name="GPU.WatchdogThread.WaitTime.NumOfUsers" units="seconds" - expires_after="2020-11-18"> - <obsolete> - Used for an experiment only. Removed 11/2020. - </obsolete> - <owner>magchen@chromium.org</owner> - <owner>zmo@chromium.org</owner> - <summary> - Recorded every second in a 60-second loop that the watchdog was still - running after allowing the GPU to complete the current job within 60 - seconds. If any of the users decided to quit Chrome, the recorded count - would decrease at the next second. - </summary> -</histogram> - -<histogram name="GPU.WatchdogThread.WaitTime.ProgressAfterWait" units="seconds" - expires_after="2020-11-18"> - <obsolete> - Used for an experiment only. Removed 11/2020. - </obsolete> - <owner>magchen@chromium.org</owner> - <owner>zmo@chromium.org</owner> - <summary> - Recorded the time the GPU main thread makes any progress after allowing the - GPU to complete the current job within 60 seconds. - </summary> -</histogram> - <histogram name="GPU.WebGraphicsContext3D_Init_CanLoseContext" enum="GPUWebGraphicsContext3D_Init_CanLoseContext" expires_after="M85"> <owner>vmiura@chromium.org</owner>
diff --git a/tools/metrics/histograms/metadata/histogram_suffixes_list.xml b/tools/metrics/histograms/metadata/histogram_suffixes_list.xml index 316ee46..6eafe6fb 100644 --- a/tools/metrics/histograms/metadata/histogram_suffixes_list.xml +++ b/tools/metrics/histograms/metadata/histogram_suffixes_list.xml
@@ -5502,15 +5502,6 @@ <affected-histogram name="GoogleUpdate.Result.TimeWindow.Unknown"/> </histogram_suffixes> -<histogram_suffixes name="GPU_ContextType" separator="."> - <obsolete> - Expired in 2020/10/15. - </obsolete> - <suffix name="GLES" label="GLES Context."/> - <suffix name="WebGL" label="WebGL Context."/> - <affected-histogram name="GPU.ContextMemory"/> -</histogram_suffixes> - <histogram_suffixes name="GPU_DirectComposition_OverlayFormat" separator="."> <suffix name="BGRA" label="BGRA"/> <suffix name="NV12" label="NV12"/> @@ -5520,17 +5511,6 @@ <affected-histogram name="GPU.DirectComposition.SwapChainCreationResult2"/> </histogram_suffixes> -<histogram_suffixes name="GPU_MemorySamplingTime" separator="."> - <obsolete> - Expired in 2020/10/15. - </obsolete> - <suffix name="Periodic" label="Sampled periodically."/> - <suffix name="Pressure" label="Sampled on CRITICAL memory pressure signal."/> - <suffix name="Shutdown" label="Sampled at shutdown."/> - <affected-histogram name="GPU.ContextMemory.GLES"/> - <affected-histogram name="GPU.ContextMemory.WebGL"/> -</histogram_suffixes> - <histogram_suffixes name="GPU_PeakMemoryAllocationSources" separator="."> <suffix name="CommandBuffer" label="GPU Command Buffer."/> <suffix name="SharedContextState" label="Shared Context State."/> @@ -5582,7 +5562,6 @@ <suffix name="Init" label="Init"/> <suffix name="Normal" label="Normal"/> <suffix name="PowerResume" label="PowerResume"/> - <affected-histogram name="GPU.WatchdogThread.ExtraThreadTime"/> <affected-histogram name="GPU.WatchdogThread.Timeout"/> </histogram_suffixes> @@ -5592,9 +5571,7 @@ <suffix name="GpuRasterization" label="GpuRasterization"/> <suffix name="Webgl" label="Webgl"/> <suffix name="Webgl2" label="Webgl2"/> - <affected-histogram name="GPU.BlacklistFeatureTestResults"/> <affected-histogram name="GPU.BlacklistFeatureTestResultsWindows"/> - <affected-histogram name="GPU.BlacklistFeatureTestResultsWindows2"/> <affected-histogram name="GPU.BlocklistFeatureTestResults"/> </histogram_suffixes>
diff --git a/tools/metrics/histograms/metadata/history/histograms.xml b/tools/metrics/histograms/metadata/history/histograms.xml index eb4fbc7..b5f2326 100644 --- a/tools/metrics/histograms/metadata/history/histograms.xml +++ b/tools/metrics/histograms/metadata/history/histograms.xml
@@ -171,7 +171,7 @@ </histogram> <histogram name="History.ClearBrowsingData.FailedTasksChrome" - enum="ChromeBrowsingDataRemoverTasks" expires_after="2022-04-17"> + enum="ChromeBrowsingDataRemoverTasks" expires_after="2022-07-11"> <owner>dullweber@chromium.org</owner> <owner>msramek@chromium.org</owner> <summary> @@ -498,7 +498,7 @@ </histogram> <histogram name="History.Clusters.Backend.KeywordCache.AllKeywordPhraseCount" - units="count" expires_after="M101"> + units="count" expires_after="2022-07-11"> <owner>manukh@chromium.org</owner> <owner>chrome-memories@google.com</owner> <summary> @@ -514,7 +514,7 @@ </histogram> <histogram name="History.Clusters.Backend.KeywordCache.AllKeywordsCount" - units="count" expires_after="M101"> + units="count" expires_after="2022-07-11"> <owner>manukh@chromium.org</owner> <owner>chrome-memories@google.com</owner> <summary> @@ -530,7 +530,7 @@ </histogram> <histogram name="History.Clusters.Backend.KeywordCache.ShortKeywordPhraseCount" - units="count" expires_after="M101"> + units="count" expires_after="2022-07-11"> <owner>manukh@chromium.org</owner> <owner>chrome-memories@google.com</owner> <summary> @@ -545,7 +545,7 @@ </histogram> <histogram name="History.Clusters.Backend.KeywordCache.ShortKeywordsCount" - units="count" expires_after="M101"> + units="count" expires_after="2022-07-11"> <owner>manukh@chromium.org</owner> <owner>chrome-memories@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/media/histograms.xml b/tools/metrics/histograms/metadata/media/histograms.xml index 5e0f158..a87116f 100644 --- a/tools/metrics/histograms/metadata/media/histograms.xml +++ b/tools/metrics/histograms/metadata/media/histograms.xml
@@ -2063,7 +2063,7 @@ </histogram> <histogram name="Media.EME.CdmInterfaceVersion" enum="GenericEnum" - expires_after="2022-05-07"> + expires_after="2022-07-11"> <owner>xhwang@chromium.org</owner> <owner>media-dev@chromium.org</owner> <summary> @@ -2148,7 +2148,7 @@ </histogram> <histogram name="Media.EME.EncryptionScheme.Initial.Video" - enum="MediaEncryptionScheme" expires_after="2022-05-07"> + enum="MediaEncryptionScheme" expires_after="2022-07-11"> <owner>jrummell@chromium.org</owner> <owner>media-dev@chromium.org</owner> <summary> @@ -4867,7 +4867,7 @@ </histogram> <histogram name="Media.VideoCapture.Mac.Device.CapturedIOSurface" - enum="Boolean" expires_after="2022-04-24"> + enum="Boolean" expires_after="2022-07-11"> <owner>eshr@google.com</owner> <owner>handellm@google.com</owner> <summary> @@ -5360,7 +5360,7 @@ </histogram> <histogram name="Media.VideoRenderer.LowDelay" enum="Boolean" - expires_after="2022-05-07"> + expires_after="2022-07-11"> <owner>xhwang@chromium.org</owner> <owner>media-dev@chromium.org</owner> <summary> @@ -5821,7 +5821,7 @@ </histogram> <histogram name="MediaRouter.CastStreaming.Start.Failure.Native" - enum="MirroringServiceErrorType" expires_after="2022-05-01"> + enum="MirroringServiceErrorType" expires_after="2022-07-11"> <owner>takumif@chromium.org</owner> <owner>openscreen-eng@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/memory/histograms.xml b/tools/metrics/histograms/metadata/memory/histograms.xml index bc45b82a..c01c879 100644 --- a/tools/metrics/histograms/metadata/memory/histograms.xml +++ b/tools/metrics/histograms/metadata/memory/histograms.xml
@@ -507,7 +507,7 @@ </histogram> <histogram name="Memory.Discardable.LargeAllocationFromFreelist" - enum="BooleanLargeAllocationFromFreelist" expires_after="2022-05-08"> + enum="BooleanLargeAllocationFromFreelist" expires_after="2022-07-11"> <owner>thiabaud@google.com</owner> <owner>lizeb@chromium.org</owner> <summary> @@ -547,7 +547,7 @@ </histogram> <histogram name="Memory.DiscardableAllocationSize" units="KB" - expires_after="2022-05-08"> + expires_after="2022-07-11"> <owner>reveman@chromium.org</owner> <owner>thiabaud@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/mobile/histograms.xml b/tools/metrics/histograms/metadata/mobile/histograms.xml index d23473b..67f2625 100644 --- a/tools/metrics/histograms/metadata/mobile/histograms.xml +++ b/tools/metrics/histograms/metadata/mobile/histograms.xml
@@ -93,7 +93,7 @@ </histogram> <histogram name="Mobile.CanonicalURLResult" enum="CanonicalURLResult" - expires_after="M102"> + expires_after="2022-07-11"> <owner>pkl@chromium.org</owner> <owner>sebsg@chromium.org</owner> <owner>tedchoc@chromium.org</owner> @@ -227,7 +227,7 @@ </histogram> <histogram name="Mobile.Messages.Banner.OnScreenTime" units="ms" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>sczs@chromium.org</owner> <owner>thegreenfrog@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/net/histograms.xml b/tools/metrics/histograms/metadata/net/histograms.xml index cbff430..5a0483d 100644 --- a/tools/metrics/histograms/metadata/net/histograms.xml +++ b/tools/metrics/histograms/metadata/net/histograms.xml
@@ -194,7 +194,7 @@ </histogram> <histogram name="Net.AlternateProtocolBrokenLocation" - enum="BrokenAlternateProtocolLocation" expires_after="2022-05-11"> + enum="BrokenAlternateProtocolLocation" expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/OWNERS</owner> <summary> @@ -213,7 +213,7 @@ </histogram> <histogram name="Net.AlternateProtocolUsageGoogle" - enum="AlternateProtocolUsage" expires_after="2022-05-11"> + enum="AlternateProtocolUsage" expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/OWNERS</owner> <summary> @@ -507,7 +507,7 @@ </histogram> <histogram base="true" name="Net.CertVerifier.NameNormalizationPrivateRoots" - enum="NetCertificateNameNormalization" expires_after="2022-05-11"> + enum="NetCertificateNameNormalization" expires_after="2022-07-11"> <owner>mattm@chromium.org</owner> <owner>rsleevi@chromium.org</owner> <summary> @@ -559,7 +559,7 @@ </histogram> <histogram name="Net.CertVerifier_TrialComparisonResult" - enum="CertVerifierTrialComparisonResult" expires_after="2022-05-11"> + enum="CertVerifierTrialComparisonResult" expires_after="2022-07-11"> <owner>mattm@chromium.org</owner> <owner>rsleevi@chromium.org</owner> <summary> @@ -571,7 +571,7 @@ </histogram> <histogram name="Net.ConnectionInfo.MainFrame" enum="ConnectionInfo" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/OWNERS</owner> <summary> @@ -602,7 +602,7 @@ </histogram> <histogram name="Net.Cors.AccessCheckError" enum="CorsAccessCheckError" - expires_after="2022-05-01"> + expires_after="2022-07-11"> <owner>toyoshim@chromium.org</owner> <owner>yhirano@chromium.org</owner> <summary> @@ -668,7 +668,7 @@ </histogram> <histogram name="Net.Cors.PreflightCheckError2" enum="CorsAccessCheckError" - expires_after="2022-05-01"> + expires_after="2022-07-11"> <owner>toyoshim@chromium.org</owner> <owner>yhirano@chromium.org</owner> <summary> @@ -680,7 +680,7 @@ </histogram> <histogram name="Net.Cors.PreflightCheckWarning" enum="CorsAccessCheckError" - expires_after="2022-05-01"> + expires_after="2022-07-11"> <owner>titouan@chromium.org</owner> <owner>clamy@chromium.org</owner> <summary> @@ -692,7 +692,7 @@ </histogram> <histogram name="Net.CountOfBrokenAlternativeServices" units="services" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/OWNERS</owner> <summary> @@ -934,7 +934,7 @@ </histogram> <histogram name="Net.DNS.DnsConfig.SecureDnsMode" enum="SecureDnsModeDetails" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>ericorth@chromium.org</owner> <owner>doh-core@google.com</owner> <summary> @@ -1500,7 +1500,7 @@ </histogram> <histogram name="Net.DNS.ProbeSequence.ConfigChange.Failure.AttemptTime" - units="ms" expires_after="2022-05-11"> + units="ms" expires_after="2022-07-11"> <owner>ericorth@chromium.org</owner> <owner>doh-core@google.com</owner> <summary> @@ -1510,7 +1510,7 @@ </histogram> <histogram name="Net.DNS.ProbeSequence.ConfigChange.Success.AttemptTime" - units="ms" expires_after="2022-05-11"> + units="ms" expires_after="2022-07-11"> <owner>ericorth@chromium.org</owner> <owner>doh-core@google.com</owner> <summary> @@ -2186,7 +2186,7 @@ </histogram> <histogram name="Net.HttpJob.ProxyTypeFailed" enum="ProxyScheme" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>rch@chromium.org</owner> <summary> Scheme of the proxy server used by an HTTP job that failed, or SCHEME_DIRECT @@ -2195,7 +2195,7 @@ </histogram> <histogram name="Net.HttpJob.ProxyTypeSuccess" enum="ProxyScheme" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>rch@chromium.org</owner> <summary> Scheme of the proxy server used by an HTTP job that succeeded, or @@ -2625,7 +2625,7 @@ </histogram> <histogram name="Net.NumQuicSessionsAtShutdown" units="units" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -2738,7 +2738,7 @@ </histogram> <histogram name="Net.QuicActiveSessions" units="units" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -2757,7 +2757,7 @@ </histogram> <histogram name="Net.QuicChromiumClientStream.HandleOnCloseConnectionError" - enum="QuicErrorCodes" expires_after="2022-05-11"> + enum="QuicErrorCodes" expires_after="2022-07-11"> <owner>renjietang@chromium.org</owner> <owner>src/net/OWNERS</owner> <summary> @@ -2976,7 +2976,7 @@ </histogram> <histogram name="Net.QuicHandshakeNotConfirmedNumPacketsReceived" units="units" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -3161,7 +3161,7 @@ </histogram> <histogram name="Net.QuicSession.AcceptChFrameReceivedViaAlps" - enum="AcceptChEntries" expires_after="2022-05-11"> + enum="AcceptChEntries" expires_after="2022-07-11"> <owner>bnc@chromium.org</owner> <owner>src/net/OWNERS</owner> <summary> @@ -3183,7 +3183,7 @@ </histogram> <histogram name="Net.QuicSession.AsyncRead" enum="Boolean" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -3370,7 +3370,7 @@ <histogram name="Net.QuicSession.ConnectionClose.NumOpenStreams.HandshakeTimedOut" - units="units" expires_after="2022-05-11"> + units="units" expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -3379,7 +3379,7 @@ </histogram> <histogram name="Net.QuicSession.ConnectionClose.NumOpenStreams.TimedOut" - units="units" expires_after="2022-05-11"> + units="units" expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary>The number of streams open when a QUIC session timed out.</summary> @@ -3407,7 +3407,7 @@ </histogram> <histogram name="Net.QuicSession.ConnectionCloseErrorCodeClientGoogle" - enum="QuicErrorCodes" expires_after="2022-05-11"> + enum="QuicErrorCodes" expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -3427,7 +3427,7 @@ </histogram> <histogram name="Net.QuicSession.ConnectionCloseErrorCodeServerGoogle" - enum="QuicErrorCodes" expires_after="2022-05-11"> + enum="QuicErrorCodes" expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -3437,7 +3437,7 @@ </histogram> <histogram name="Net.QuicSession.ConnectionCloseErrorCodeServerIetfApplication" - enum="QuicHttp3ErrorCodes" expires_after="2022-05-11"> + enum="QuicHttp3ErrorCodes" expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -3480,7 +3480,7 @@ </histogram> <histogram name="Net.QuicSession.ConnectionCloseErrorCodeServerIetfTransport" - enum="QuicTransportErrorCodes" expires_after="2022-05-11"> + enum="QuicTransportErrorCodes" expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -3491,7 +3491,7 @@ <histogram name="Net.QuicSession.ConnectionCloseErrorCodeServerIetfTransportGoogle" - enum="QuicTransportErrorCodes" expires_after="2022-05-11"> + enum="QuicTransportErrorCodes" expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -3540,7 +3540,7 @@ </histogram> <histogram name="Net.QuicSession.ConnectionFlowControlBlocked" - enum="BooleanBlocked" expires_after="2022-05-11"> + enum="BooleanBlocked" expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -3559,7 +3559,7 @@ </histogram> <histogram name="Net.QuicSession.ConnectionMigration" - enum="QuicConnectionMigrationStatus" expires_after="2022-05-11"> + enum="QuicConnectionMigrationStatus" expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -3693,7 +3693,7 @@ </histogram> <histogram name="Net.QuicSession.FinchConfigIsValid" enum="Boolean" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -3786,7 +3786,7 @@ </histogram> <histogram name="Net.QuicSession.HeaderCompressionRatioHpackReceived" units="%" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -3795,7 +3795,7 @@ </histogram> <histogram name="Net.QuicSession.HeaderCompressionRatioHpackSent" units="%" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -3804,7 +3804,7 @@ </histogram> <histogram name="Net.QuicSession.HeaderCompressionRatioQpackReceived" units="%" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -3966,7 +3966,7 @@ </histogram> <histogram name="Net.QuicSession.MaxReordering" units="units" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -3984,7 +3984,7 @@ </histogram> <histogram name="Net.QuicSession.MaxReorderingTimeLongRtt" units="%" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -3994,7 +3994,7 @@ </histogram> <histogram name="Net.QuicSession.MigrateToSocketSuccess" enum="Boolean" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>renjietang@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -4088,7 +4088,7 @@ </histogram> <histogram name="Net.QuicSession.NumTotalStreams" units="units" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -4193,7 +4193,7 @@ </histogram> <histogram name="Net.QuicSession.PathValidationSuccess" enum="BooleanSuccess" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>renjietang@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -4222,7 +4222,7 @@ </histogram> <histogram name="Net.QuicSession.PortMigration" - enum="QuicConnectionMigrationStatus" expires_after="2022-05-11"> + enum="QuicConnectionMigrationStatus" expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary>The result of a QUIC port migration attempt.</summary> @@ -4349,7 +4349,7 @@ </histogram> <histogram name="Net.QuicSession.QuicVersion" units="units" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary>Version of the QUIC protocol used for this connection.</summary> @@ -4406,7 +4406,7 @@ </histogram> <histogram name="Net.QuicSession.ReceivedSettings.MaxTableCapacity2" - units="bytes" expires_after="2022-05-11"> + units="bytes" expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -4470,7 +4470,7 @@ </histogram> <histogram name="Net.QuicSession.RstStreamErrorCodeServer" - enum="QuicRstStreamErrorCodes" expires_after="2022-05-11"> + enum="QuicRstStreamErrorCodes" expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -4521,7 +4521,7 @@ </histogram> <histogram name="Net.QuicSession.SmoothedRTT" units="ms" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -4601,7 +4601,7 @@ </histogram> <histogram name="Net.QuicSession.StreamCloseErrorCodeServer.HandshakeConfirmed" - enum="QuicErrorCodes" expires_after="2022-05-11"> + enum="QuicErrorCodes" expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -4611,7 +4611,7 @@ </histogram> <histogram name="Net.QuicSession.StreamFlowControlBlocked" - enum="BooleanBlocked" expires_after="2022-05-11"> + enum="BooleanBlocked" expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -4807,7 +4807,7 @@ </histogram> <histogram name="Net.QuicSession.VerifyProofTime" units="ms" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -4858,7 +4858,7 @@ </histogram> <histogram name="Net.QuicSession.ZeroRttReason" - enum="SSLHandshakeEarlyDataReason" expires_after="2022-05-11"> + enum="SSLHandshakeEarlyDataReason" expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -4868,7 +4868,7 @@ </histogram> <histogram name="Net.QuicSession.ZeroRttReasonGoogle" - enum="SSLHandshakeEarlyDataReason" expires_after="2022-05-11"> + enum="SSLHandshakeEarlyDataReason" expires_after="2022-07-11"> <owner>renjietang@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -4879,7 +4879,7 @@ </histogram> <histogram name="Net.QuicSession.ZeroRttReasonNonGoogle" - enum="SSLHandshakeEarlyDataReason" expires_after="2022-05-11"> + enum="SSLHandshakeEarlyDataReason" expires_after="2022-07-11"> <owner>renjietang@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary> @@ -4890,7 +4890,7 @@ </histogram> <histogram name="Net.QuicSession.ZeroRttState" enum="ZeroRttState" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>renjietang@chromium.org</owner> <owner>src/net/quic/OWNERS</owner> <summary>Whether 0-RTT was successfully used in the connection.</summary> @@ -5226,7 +5226,7 @@ </histogram> <histogram name="Net.RestrictedCookieManager.TopFrameOriginOK" enum="Boolean" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>morlovich@chromium.org</owner> <owner>src/net/cookies/OWNERS</owner> <summary> @@ -5355,7 +5355,7 @@ </histogram> <histogram name="Net.SpdyResponseCode" enum="HttpResponseCode" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/OWNERS</owner> <summary> @@ -5378,7 +5378,7 @@ </histogram> <histogram name="Net.SpdySession.AlpsAcceptChEntries" enum="AcceptChEntries" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>bnc@chromium.org</owner> <owner>src/net/OWNERS</owner> <summary> @@ -5390,7 +5390,7 @@ </histogram> <histogram name="Net.SpdySession.AlpsDecoderStatus" enum="AlpsDecoderError" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>bnc@chromium.org</owner> <owner>src/net/OWNERS</owner> <summary> @@ -5412,7 +5412,7 @@ </histogram> <histogram name="Net.SpdySession.ClosedOnError" enum="NetErrorCodes" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/OWNERS</owner> <summary>Net error codes when SpdySession was closed.</summary> @@ -5426,7 +5426,7 @@ </histogram> <histogram name="Net.SpdySession.GoAwayReceived" enum="Http2WireErrorCodes" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>bnc@chromium.org</owner> <owner>src/net/OWNERS</owner> <summary> @@ -5462,7 +5462,7 @@ </histogram> <histogram name="Net.SpdySessionErrorDetails2" enum="SpdyProtocolErrorDetails2" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/OWNERS</owner> <summary>The type of SPDY Protocol error encountered.</summary> @@ -5508,7 +5508,7 @@ </histogram> <histogram name="Net.SpdyStreamsPerSession" units="units" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/OWNERS</owner> <summary>The number of streams issued over a single session.</summary> @@ -5681,7 +5681,7 @@ </histogram> <histogram name="Net.SSLNegotiatedAlpnProtocol" - enum="SSLNegotiatedAlpnProtocol" expires_after="2022-05-11"> + enum="SSLNegotiatedAlpnProtocol" expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/OWNERS</owner> <summary> @@ -5822,7 +5822,7 @@ </histogram> <histogram name="Net.TcpConnectAttempt.LatencyPercentRTT.Error" units="%" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/OWNERS</owner> <summary> @@ -5835,7 +5835,7 @@ </histogram> <histogram name="Net.TcpConnectAttempt.LatencyPercentRTT.Success" units="%" - expires_after="2022-05-11"> + expires_after="2022-07-11"> <owner>dschinazi@chromium.org</owner> <owner>src/net/OWNERS</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/new_tab_page/histograms.xml b/tools/metrics/histograms/metadata/new_tab_page/histograms.xml index 616afce8..8f224ffa9 100644 --- a/tools/metrics/histograms/metadata/new_tab_page/histograms.xml +++ b/tools/metrics/histograms/metadata/new_tab_page/histograms.xml
@@ -107,7 +107,7 @@ </histogram> <histogram name="NewTabPage.Carts.CartCount" units="count" - expires_after="2022-05-08"> + expires_after="2022-07-11"> <owner>wychen@chromium.org</owner> <owner>yuezhanggg@chromium.org</owner> <owner>chrome-shopping@google.com</owner>
diff --git a/tools/metrics/histograms/metadata/offline/histograms.xml b/tools/metrics/histograms/metadata/offline/histograms.xml index 995a5c9..fa8afb0 100644 --- a/tools/metrics/histograms/metadata/offline/histograms.xml +++ b/tools/metrics/histograms/metadata/offline/histograms.xml
@@ -814,7 +814,7 @@ </histogram> <histogram name="OfflinePages.OfflineUsage" enum="OfflinePagesOfflineUsage" - expires_after="2022-05-08"> + expires_after="2022-07-11"> <owner>dimich@chromium.org</owner> <owner>offline-dev@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/omnibox/histograms.xml b/tools/metrics/histograms/metadata/omnibox/histograms.xml index 0478574..c9554895 100644 --- a/tools/metrics/histograms/metadata/omnibox/histograms.xml +++ b/tools/metrics/histograms/metadata/omnibox/histograms.xml
@@ -62,7 +62,7 @@ </histogram> <histogram name="Omnibox.BitmapFetchLatency" units="ms" - expires_after="2022-05-08"> + expires_after="2022-07-11"> <!-- Name completed by histogram_suffixes name="Omnibox.BitmapFetchLatencyCacheSplit" --> <owner>manukh@chromium.org</owner> @@ -716,7 +716,7 @@ </summary> </histogram> -<histogram name="Omnibox.QueryTime2" units="ms" expires_after="2022-05-08"> +<histogram name="Omnibox.QueryTime2" units="ms" expires_after="2022-07-11"> <owner>jdonnelly@chromium.org</owner> <owner>mpearson@chromium.org</owner> <owner>chrome-omnibox-team@google.com</owner> @@ -798,7 +798,7 @@ </histogram> <histogram name="Omnibox.SearchProviderMatches" units="units" - expires_after="2022-05-08"> + expires_after="2022-07-11"> <owner>jdonnelly@chromium.org</owner> <owner>mpearson@chromium.org</owner> <owner>chrome-omnibox-team@google.com</owner> @@ -810,7 +810,7 @@ </histogram> <histogram name="Omnibox.SelectedPosition" units="position" - expires_after="2022-07-03"> + expires_after="2022-07-11"> <owner>jdonnelly@chromium.org</owner> <owner>mpearson@chromium.org</owner> <owner>chrome-omnibox-team@google.com</owner> @@ -948,7 +948,7 @@ <histogram name="Omnibox.SuggestionUsed.Search.NavigationToFirstContentfulPaint" - units="ms" expires_after="2022-05-08"> + units="ms" expires_after="2022-07-11"> <owner>jdonnelly@chromium.org</owner> <owner>mpearson@chromium.org</owner> <owner>chrome-omnibox-team@google.com</owner> @@ -1011,7 +1011,7 @@ </histogram> <histogram name="Omnibox.SuggestRequest.Failure.GoogleResponseTime" units="ms" - expires_after="2022-05-08"> + expires_after="2022-07-11"> <owner>mpearson@chromium.org</owner> <owner>jdonnelly@chromium.org</owner> <owner>cch@chromium.org</owner> @@ -1046,7 +1046,7 @@ </histogram> <histogram name="Omnibox.SuggestRequests" enum="OmniboxSuggestRequests" - expires_after="2022-05-08"> + expires_after="2022-07-11"> <owner>mpearson@chromium.org</owner> <owner>jdonnelly@chromium.org</owner> <owner>cch@chromium.org</owner>
diff --git a/tools/metrics/histograms/metadata/optimization/histograms.xml b/tools/metrics/histograms/metadata/optimization/histograms.xml index 5ca5eb6..2ed1bd2 100644 --- a/tools/metrics/histograms/metadata/optimization/histograms.xml +++ b/tools/metrics/histograms/metadata/optimization/histograms.xml
@@ -281,7 +281,7 @@ </histogram> <histogram name="OptimizationGuide.HintsFetcher.GetHintsRequest.NetErrorCode" - enum="NetErrorCodes" expires_after="2022-05-08"> + enum="NetErrorCodes" expires_after="2022-07-11"> <owner>mcrouse@chromium.org</owner> <owner>sophiechang@chromium.org</owner> <summary> @@ -291,7 +291,7 @@ </histogram> <histogram name="OptimizationGuide.HintsFetcher.GetHintsRequest.Status" - enum="HttpResponseCode" expires_after="2022-05-08"> + enum="HttpResponseCode" expires_after="2022-07-11"> <owner>mcrouse@chromium.org</owner> <owner>sophiechang@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/others/histograms.xml b/tools/metrics/histograms/metadata/others/histograms.xml index 8531103b..fe20e5c 100644 --- a/tools/metrics/histograms/metadata/others/histograms.xml +++ b/tools/metrics/histograms/metadata/others/histograms.xml
@@ -6789,7 +6789,7 @@ </histogram> <histogram name="FirstRun.Stage" enum="FirstRunStageResult" - expires_after="2022-04-30"> + expires_after="2022-07-11"> <owner>tinazwang@chromium.org</owner> <owner>bling-get-started@google.com</owner> <summary> @@ -9010,7 +9010,7 @@ </histogram> <histogram name="MerchantTrust.PageInfo.IsStoreInfoVisible" - enum="BooleanVisible" expires_after="M102"> + enum="BooleanVisible" expires_after="2022-07-11"> <owner>zhiyuancai@chromium.org</owner> <owner>chrome-shopping@google.com</owner> <summary> @@ -11427,7 +11427,7 @@ </histogram> <histogram name="PrefetchedSignedExchangeCache.HeadersSizeTotal" units="bytes" - expires_after="2022-05-01"> + expires_after="2022-07-11"> <owner>horo@chromium.org</owner> <owner>webpackage-dev@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/page/histograms.xml b/tools/metrics/histograms/metadata/page/histograms.xml index d94e196..77579d31 100644 --- a/tools/metrics/histograms/metadata/page/histograms.xml +++ b/tools/metrics/histograms/metadata/page/histograms.xml
@@ -2414,7 +2414,7 @@ </histogram> <histogram name="PageLoad.Internal.Renderer.PresentationTime.DeltaFromSwapTime" - units="ms" expires_after="2022-04-24"> + units="ms" expires_after="2022-07-11"> <owner>jonross@chromium.org</owner> <owner>sadrul@chromium.org</owner> <summary> @@ -2434,7 +2434,7 @@ </histogram> <histogram name="PageLoad.Internal.Renderer.PresentationTime.Valid" - enum="Boolean" expires_after="2022-04-24"> + enum="Boolean" expires_after="2022-07-11"> <owner>jonross@chromium.org</owner> <owner>sadrul@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/permissions/histograms.xml b/tools/metrics/histograms/metadata/permissions/histograms.xml index 73e46334..efcf2fb 100644 --- a/tools/metrics/histograms/metadata/permissions/histograms.xml +++ b/tools/metrics/histograms/metadata/permissions/histograms.xml
@@ -302,7 +302,7 @@ </histogram> <histogram name="Permissions.CrowdDeny.SafeBrowsing.RequestDuration" units="ms" - expires_after="2022-05-01"> + expires_after="2022-07-11"> <owner>andypaicu@chromium.org</owner> <owner>engedy@chromium.org</owner> <owner>hkamila@chromium.org</owner>
diff --git a/tools/metrics/histograms/metadata/power/histograms.xml b/tools/metrics/histograms/metadata/power/histograms.xml index e84a1a6..93c9b90 100644 --- a/tools/metrics/histograms/metadata/power/histograms.xml +++ b/tools/metrics/histograms/metadata/power/histograms.xml
@@ -330,7 +330,7 @@ </histogram> <histogram name="Power.CpuTimeSecondsPerCoreTypeAndFrequency" units="50 MHz" - expires_after="2022-05-08"> + expires_after="2022-07-11"> <owner>eseckler@chromium.org</owner> <owner>skyostil@chromium.org</owner> <summary> @@ -897,7 +897,7 @@ </histogram> <histogram name="Power.IOPMPowerSource.SamplingEventDelta" units="ms" - expires_after="2022-03-01"> + expires_after="2022-07-11"> <owner>pmonette@chromium.org</owner> <owner>catan-team@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/renderer/histograms.xml b/tools/metrics/histograms/metadata/renderer/histograms.xml index 3f51038..0ea3a36 100644 --- a/tools/metrics/histograms/metadata/renderer/histograms.xml +++ b/tools/metrics/histograms/metadata/renderer/histograms.xml
@@ -322,7 +322,7 @@ </histogram> <histogram name="Renderer.Font.Shaping.FCP" units="ms" - expires_after="2022-04-18"> + expires_after="2022-07-11"> <owner>tkent@chromium.org</owner> <owner>kojii@chromium.org</owner> <owner>yosin@chromium.org</owner> @@ -422,7 +422,7 @@ </histogram> <histogram name="Renderer.PaintPreview.Capture.SubframeBlinkCaptureDuration" - units="ms" expires_after="2022-05-08"> + units="ms" expires_after="2022-07-11"> <owner>ckitagawa@chromium.org</owner> <owner>mahmoudi@chromium.org</owner> <owner>fredmello@chromium.org</owner>
diff --git a/tools/metrics/histograms/metadata/safe_browsing/histograms.xml b/tools/metrics/histograms/metadata/safe_browsing/histograms.xml index 4a0882e..4931ff8f 100644 --- a/tools/metrics/histograms/metadata/safe_browsing/histograms.xml +++ b/tools/metrics/histograms/metadata/safe_browsing/histograms.xml
@@ -177,7 +177,7 @@ <histogram name="SafeBrowsing.BrowserThrottle.IsCheckCompletedOnProcessResponse" - enum="BooleanCompleted" expires_after="2022-05-08"> + enum="BooleanCompleted" expires_after="2022-07-11"> <owner>xinghuilu@chromium.org</owner> <owner>chrome-safebrowsing-alerts@google.com</owner> <summary> @@ -1365,7 +1365,7 @@ </histogram> <histogram name="SafeBrowsing.Pref.Enhanced" enum="BooleanEnabled" - expires_after="2022-05-08"> + expires_after="2022-07-11"> <owner>drubery@chromium.org</owner> <owner>chrome-safebrowsing-alerts@google.com</owner> <summary> @@ -1377,7 +1377,7 @@ </histogram> <histogram name="SafeBrowsing.Pref.Extended" enum="BooleanEnabled" - expires_after="2022-05-08"> + expires_after="2022-07-11"> <owner>vakh@chromium.org</owner> <owner>chrome-safebrowsing-alerts@google.com</owner> <summary> @@ -1389,7 +1389,7 @@ </histogram> <histogram name="SafeBrowsing.Pref.General" enum="BooleanEnabled" - expires_after="2022-05-08"> + expires_after="2022-07-11"> <owner>vakh@chromium.org</owner> <owner>chrome-safebrowsing-alerts@google.com</owner> <summary> @@ -1959,7 +1959,7 @@ </histogram> <histogram name="SafeBrowsing.TokenFetcher.ErrorType" - enum="GoogleServiceAuthError" expires_after="2022-04-24"> + enum="GoogleServiceAuthError" expires_after="2022-07-11"> <owner>xinghuilu@chromium.org</owner> <owner>chrome-safebrowsing-alerts@google.com</owner> <summary> @@ -2019,7 +2019,7 @@ </histogram> <histogram name="SafeBrowsing.Triggers.SuspiciousSite.Event" - enum="SuspiciousSiteTriggerEvent" expires_after="2022-05-08"> + enum="SuspiciousSiteTriggerEvent" expires_after="2022-07-11"> <owner>vakh@chromium.org</owner> <owner>chrome-safebrowsing-alerts@google.com</owner> <summary> @@ -2632,7 +2632,7 @@ </histogram> <histogram name="SafeBrowsingBinaryUploadService.ActiveRequestsAtShutdown" - units="requests" expires_after="2022-04-24"> + units="requests" expires_after="2022-07-11"> <owner>domfc@chromium.org</owner> <owner>jgingras@chromium.org</owner> <owner>webprotect-eng@google.com</owner>
diff --git a/tools/metrics/histograms/metadata/sb_client/histograms.xml b/tools/metrics/histograms/metadata/sb_client/histograms.xml index 334c2f7b..42f7d2e 100644 --- a/tools/metrics/histograms/metadata/sb_client/histograms.xml +++ b/tools/metrics/histograms/metadata/sb_client/histograms.xml
@@ -733,7 +733,7 @@ </histogram> <histogram name="SBClientPhishing.LocalModelDetectsPhishing" - enum="BooleanIsPhishing" expires_after="2022-05-08"> + enum="BooleanIsPhishing" expires_after="2022-07-11"> <owner>drubery@chromium.org</owner> <owner>chrome-safebrowsing-alerts@google.com</owner> <summary> @@ -779,7 +779,7 @@ </histogram> <histogram name="SBClientPhishing.ModelDynamicUpdateVersion" - units="client phishing model version" expires_after="2022-05-08"> + units="client phishing model version" expires_after="2022-07-11"> <owner>drubery@chromium.org</owner> <owner>chrome-safebrowsing-alerts@google.com</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/security/histograms.xml b/tools/metrics/histograms/metadata/security/histograms.xml index 71456e9..d5d5d0c 100644 --- a/tools/metrics/histograms/metadata/security/histograms.xml +++ b/tools/metrics/histograms/metadata/security/histograms.xml
@@ -383,7 +383,7 @@ </histogram> <histogram name="Security.PageInfo.TimeOpen" units="units" - expires_after="2022-07-03"> + expires_after="2022-07-11"> <owner>cthomp@chromium.org</owner> <owner>security-enamel@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/sharing/histograms.xml b/tools/metrics/histograms/metadata/sharing/histograms.xml index 98eabe6..251bfa0 100644 --- a/tools/metrics/histograms/metadata/sharing/histograms.xml +++ b/tools/metrics/histograms/metadata/sharing/histograms.xml
@@ -567,7 +567,7 @@ </histogram> <histogram name="Sharing.ShareTargetUpdate.DynamicUpdateResult" - enum="ShareTargetUpdateResult" expires_after="M102"> + enum="ShareTargetUpdateResult" expires_after="2022-07-11"> <owner>jeffreycohen@chromium.org</owner> <owner>kristipark@chromium.org</owner> <owner>src/chrome/browser/share/OWNERS</owner>
diff --git a/tools/metrics/histograms/metadata/sync/histograms.xml b/tools/metrics/histograms/metadata/sync/histograms.xml index 932ca3e..160b4ca 100644 --- a/tools/metrics/histograms/metadata/sync/histograms.xml +++ b/tools/metrics/histograms/metadata/sync/histograms.xml
@@ -808,7 +808,7 @@ </histogram> <histogram name="Sync.Local.RequestTypeOnError" enum="SyncRequestType" - expires_after="2022-04-30"> + expires_after="2022-07-11"> <owner>pastarmovj@chromium.org</owner> <component>Services>Sync</component> <summary>
diff --git a/tools/metrics/histograms/metadata/tab/histograms.xml b/tools/metrics/histograms/metadata/tab/histograms.xml index dd86f08..10b51eb 100644 --- a/tools/metrics/histograms/metadata/tab/histograms.xml +++ b/tools/metrics/histograms/metadata/tab/histograms.xml
@@ -2457,7 +2457,7 @@ </histogram> <histogram name="Tabs.TabSearch.WebUI.LoadDocumentTime" units="ms" - expires_after="2022-03-27"> + expires_after="2022-07-11"> <owner>tluk@chromium.org</owner> <owner>robliao@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/uma/histograms.xml b/tools/metrics/histograms/metadata/uma/histograms.xml index 7ee2e66..86e70193 100644 --- a/tools/metrics/histograms/metadata/uma/histograms.xml +++ b/tools/metrics/histograms/metadata/uma/histograms.xml
@@ -791,7 +791,7 @@ </summary> </histogram> -<histogram name="UMA.Startup.Visibility" enum="StartupVisibility" +<histogram name="UMA.StartupVisibility" enum="StartupVisibility" expires_after="2022-11-01"> <owner>caitlinfischer@google.com</owner> <owner>src/base/metrics/OWNERS</owner>
diff --git a/tools/metrics/histograms/metadata/v8/histograms.xml b/tools/metrics/histograms/metadata/v8/histograms.xml index e1584e8..4a29a23 100644 --- a/tools/metrics/histograms/metadata/v8/histograms.xml +++ b/tools/metrics/histograms/metadata/v8/histograms.xml
@@ -1835,7 +1835,7 @@ </histogram> <histogram name="V8.WasmModuleCodeSizeMiB" units="MB" - expires_after="2022-04-24"> + expires_after="2022-07-11"> <owner>ecmziegler@chromium.org</owner> <owner>adamk@chromium.org</owner> <owner>clemensb@chromium.org</owner>
diff --git a/tools/metrics/histograms/metadata/variations/histograms.xml b/tools/metrics/histograms/metadata/variations/histograms.xml index 692dd49..22fb743 100644 --- a/tools/metrics/histograms/metadata/variations/histograms.xml +++ b/tools/metrics/histograms/metadata/variations/histograms.xml
@@ -420,7 +420,7 @@ </histogram> <histogram name="Variations.SafeMode.Streak.Crashes" units="crashes" - expires_after="2022-05-09"> + expires_after="2022-07-11"> <owner>isherman@chromium.org</owner> <owner>asvitkine@chromium.org</owner> <owner>src/base/metrics/OWNERS</owner> @@ -434,7 +434,7 @@ </histogram> <histogram name="Variations.SafeMode.Streak.FetchFailures" units="failures" - expires_after="2022-05-09"> + expires_after="2022-07-11"> <owner>isherman@chromium.org</owner> <owner>asvitkine@chromium.org</owner> <owner>src/base/metrics/OWNERS</owner>
diff --git a/tools/metrics/histograms/metadata/web_audio/histograms.xml b/tools/metrics/histograms/metadata/web_audio/histograms.xml index db828c1..6509a39 100644 --- a/tools/metrics/histograms/metadata/web_audio/histograms.xml +++ b/tools/metrics/histograms/metadata/web_audio/histograms.xml
@@ -142,7 +142,7 @@ </histogram> <histogram name="WebAudio.AudioDestination.HardwareBufferSize" units="units" - expires_after="2022-04-24"> + expires_after="2022-07-11"> <owner>hongchan@chromium.org</owner> <summary> The buffer size (in audio frames) for WebAudio rendering recommended by the
diff --git a/tools/metrics/histograms/metadata/web_rtc/histograms.xml b/tools/metrics/histograms/metadata/web_rtc/histograms.xml index 491f313..306ca159 100644 --- a/tools/metrics/histograms/metadata/web_rtc/histograms.xml +++ b/tools/metrics/histograms/metadata/web_rtc/histograms.xml
@@ -393,7 +393,7 @@ </histogram> <histogram name="WebRTC.Audio.ApmCaptureOutputLevelAverageRms" - units="dBFS (negated)" expires_after="2022-05-08"> + units="dBFS (negated)" expires_after="2022-07-11"> <owner>peah@chromium.org</owner> <summary> This histogram reports the average RMS of the signal in the output of @@ -405,7 +405,7 @@ </histogram> <histogram name="WebRTC.Audio.ApmCaptureOutputLevelPeakRms" - units="dBFS (negated)" expires_after="2022-05-08"> + units="dBFS (negated)" expires_after="2022-07-11"> <owner>peah@chromium.org</owner> <summary> This histogram reports the peak RMS of the signal in the output of WebRTC's
diff --git a/ui/accessibility/ax_node.h b/ui/accessibility/ax_node.h index fc09e38..7651c7e 100644 --- a/ui/accessibility/ax_node.h +++ b/ui/accessibility/ax_node.h
@@ -384,6 +384,9 @@ const base::StringPairs& GetHtmlAttributes() const { return data().html_attributes; } + bool HasHtmlAttribute(const char* attribute) const { + return data().HasHtmlAttribute(attribute); + } bool GetHtmlAttribute(const char* attribute, std::string* value) const { return data().GetHtmlAttribute(attribute, value); }
diff --git a/ui/accessibility/ax_node_data.cc b/ui/accessibility/ax_node_data.cc index 319cbee..82a4d00 100644 --- a/ui/accessibility/ax_node_data.cc +++ b/ui/accessibility/ax_node_data.cc
@@ -8,6 +8,7 @@ #include <algorithm> #include <set> +#include <type_traits> #include <utility> #include "base/containers/cxx20_erase.h" @@ -437,6 +438,13 @@ return false; } +bool AXNodeData::HasHtmlAttribute(const char* attribute) const { + std::string value; + if (!GetHtmlAttribute(attribute, &value)) + return false; + return true; +} + bool AXNodeData::GetHtmlAttribute(const char* attribute, std::string* value) const { for (const std::pair<std::string, std::string>& html_attribute : @@ -447,7 +455,6 @@ return true; } } - return false; }
diff --git a/ui/accessibility/ax_node_data.h b/ui/accessibility/ax_node_data.h index 3415122..75e6edb 100644 --- a/ui/accessibility/ax_node_data.h +++ b/ui/accessibility/ax_node_data.h
@@ -108,6 +108,7 @@ bool GetStringListAttribute(ax::mojom::StringListAttribute attribute, std::vector<std::string>* value) const; + bool HasHtmlAttribute(const char* attribute) const; bool GetHtmlAttribute(const char* attribute, std::string* value) const; bool GetHtmlAttribute(const char* attribute, std::u16string* value) const;
diff --git a/ui/accessibility/platform/ax_platform_node_base.cc b/ui/accessibility/platform/ax_platform_node_base.cc index 16c04eb..3f70d69 100644 --- a/ui/accessibility/platform/ax_platform_node_base.cc +++ b/ui/accessibility/platform/ax_platform_node_base.cc
@@ -649,6 +649,12 @@ return delegate_->GetStringListAttribute(attribute, value); } +bool AXPlatformNodeBase::HasHtmlAttribute(const char* attribute) const { + if (!delegate_) + return false; + return delegate_->HasHtmlAttribute(attribute); +} + const base::StringPairs& AXPlatformNodeBase::GetHtmlAttributes() const { static const base::NoDestructor<base::StringPairs> empty_data; if (!delegate_)
diff --git a/ui/accessibility/platform/ax_platform_node_base.h b/ui/accessibility/platform/ax_platform_node_base.h index d40d89d..1bc8204 100644 --- a/ui/accessibility/platform/ax_platform_node_base.h +++ b/ui/accessibility/platform/ax_platform_node_base.h
@@ -174,6 +174,7 @@ bool GetStringListAttribute(ax::mojom::StringListAttribute attribute, std::vector<std::string>* value) const; + bool HasHtmlAttribute(const char* attribute) const; const base::StringPairs& GetHtmlAttributes() const; bool GetHtmlAttribute(const char* attribute, std::string* value) const; bool GetHtmlAttribute(const char* attribute, std::u16string* value) const;
diff --git a/ui/accessibility/platform/ax_platform_node_cocoa.mm b/ui/accessibility/platform/ax_platform_node_cocoa.mm index e3e0d94a..9c5dda1b 100644 --- a/ui/accessibility/platform/ax_platform_node_cocoa.mm +++ b/ui/accessibility/platform/ax_platform_node_cocoa.mm
@@ -806,6 +806,10 @@ [axAttributes addObject:NSAccessibilityDetailsElementsAttribute]; } + // Drop effect. + if (_node->HasHtmlAttribute("aria-dropeffect")) + [axAttributes addObject:NSAccessibilityDropEffectsAttribute]; + if (ui::SupportsRequired(role)) { [axAttributes addObject:NSAccessibilityRequiredAttributeChrome]; } @@ -1072,6 +1076,17 @@ return @""; } +- (NSString*)AXDropEffects { + if (![self instanceActive]) + return nil; + + std::string dropEffects; + if (_node->GetHtmlAttribute("aria-dropeffect", &dropEffects)) + return base::SysUTF8ToNSString(dropEffects); + + return nil; +} + - (NSNumber*)AXHasPopup { if (![self instanceActive]) return nil;
diff --git a/ui/accessibility/platform/ax_platform_node_delegate.h b/ui/accessibility/platform/ax_platform_node_delegate.h index 758f2a6..48ac607 100644 --- a/ui/accessibility/platform/ax_platform_node_delegate.h +++ b/ui/accessibility/platform/ax_platform_node_delegate.h
@@ -158,6 +158,7 @@ virtual bool GetStringListAttribute( ax::mojom::StringListAttribute attribute, std::vector<std::string>* value) const = 0; + virtual bool HasHtmlAttribute(const char* attribute) const = 0; virtual const base::StringPairs& GetHtmlAttributes() const = 0; virtual bool GetHtmlAttribute(const char* attribute, std::string* value) const = 0;
diff --git a/ui/accessibility/platform/ax_platform_node_delegate_base.cc b/ui/accessibility/platform/ax_platform_node_delegate_base.cc index 8df112d..b4e561d 100644 --- a/ui/accessibility/platform/ax_platform_node_delegate_base.cc +++ b/ui/accessibility/platform/ax_platform_node_delegate_base.cc
@@ -170,6 +170,10 @@ return GetData().GetStringListAttribute(attribute, value); } +bool AXPlatformNodeDelegateBase::HasHtmlAttribute(const char* attribute) const { + return GetData().HasHtmlAttribute(attribute); +} + const base::StringPairs& AXPlatformNodeDelegateBase::GetHtmlAttributes() const { return GetData().html_attributes; }
diff --git a/ui/accessibility/platform/ax_platform_node_delegate_base.h b/ui/accessibility/platform/ax_platform_node_delegate_base.h index 617ac42f..e13d282 100644 --- a/ui/accessibility/platform/ax_platform_node_delegate_base.h +++ b/ui/accessibility/platform/ax_platform_node_delegate_base.h
@@ -82,6 +82,7 @@ ax::mojom::StringListAttribute attribute) const override; bool GetStringListAttribute(ax::mojom::StringListAttribute attribute, std::vector<std::string>* value) const override; + bool HasHtmlAttribute(const char* attribute) const override; const base::StringPairs& GetHtmlAttributes() const override; bool GetHtmlAttribute(const char* attribute, std::string* value) const override;
diff --git a/ui/accessibility/platform/ax_private_attributes_mac.h b/ui/accessibility/platform/ax_private_attributes_mac.h index bf19e99..dd19a3f 100644 --- a/ui/accessibility/platform/ax_private_attributes_mac.h +++ b/ui/accessibility/platform/ax_private_attributes_mac.h
@@ -44,6 +44,8 @@ @"AXDOMClassList"; AX_EXPORT constexpr NSString* const NSAccessibilityDOMIdentifierAttribute = @"AXDOMIdentifier"; +AX_EXPORT constexpr NSString* const NSAccessibilityDropEffectsAttribute = + @"AXDropEffects"; AX_EXPORT constexpr NSString* const NSAccessibilityHasPopupAttribute = @"AXHasPopup"; AX_EXPORT constexpr NSString* const NSAccessibilityInvalidAttribute =
diff --git a/ui/accessibility/platform/inspect/ax_inspect_utils_mac.mm b/ui/accessibility/platform/inspect/ax_inspect_utils_mac.mm index 94f9c50..43a38b2 100644 --- a/ui/accessibility/platform/inspect/ax_inspect_utils_mac.mm +++ b/ui/accessibility/platform/inspect/ax_inspect_utils_mac.mm
@@ -51,6 +51,7 @@ NSAccessibilityColumnHeaderUIElementsAttribute, NSAccessibilityDetailsElementsAttribute, NSAccessibilityDOMClassList, + NSAccessibilityDropEffectsAttribute, NSAccessibilityHasPopupAttribute, NSAccessibilityInvalidAttribute, NSAccessibilityMathFractionNumeratorAttribute,
diff --git a/ui/gfx/color_utils.cc b/ui/gfx/color_utils.cc index 996f232..5f3e813a 100644 --- a/ui/gfx/color_utils.cc +++ b/ui/gfx/color_utils.cc
@@ -157,8 +157,7 @@ // then when this ratio is closest to 1, we have the contrast ratio closest to // our target. const auto ratio_of_ratios = [&](float contrast) { - float min, max; - std::tie(min, max) = std::minmax(contrast, target_contrast); + auto [min, max] = std::minmax(contrast, target_contrast); return max / min; }; absl::optional<size_t> best_index;
diff --git a/ui/gfx/color_utils_unittest.cc b/ui/gfx/color_utils_unittest.cc index d3d35e1..002aaf2 100644 --- a/ui/gfx/color_utils_unittest.cc +++ b/ui/gfx/color_utils_unittest.cc
@@ -182,8 +182,7 @@ TEST(ColorUtils, MidpointLuminanceMatches) { const SkColor old_darkest_color = SetDarkestColorForTesting(SK_ColorBLACK); - float darkest, midpoint, lightest; - std::tie(darkest, midpoint, lightest) = GetLuminancesForTesting(); + auto [darkest, midpoint, lightest] = GetLuminancesForTesting(); EXPECT_FLOAT_EQ(GetContrastRatio(darkest, midpoint), GetContrastRatio(midpoint, lightest));
diff --git a/ui/message_center/views/message_view.cc b/ui/message_center/views/message_view.cc index 5345f09f..98813e2 100644 --- a/ui/message_center/views/message_view.cc +++ b/ui/message_center/views/message_view.cc
@@ -350,7 +350,10 @@ void MessageView::OnSlideChanged(bool in_progress) { for (auto& observer : observers_) { - observer.OnSlideChanged(notification_id_); + if (in_progress) + observer.OnSlideChanged(notification_id_); + else + observer.OnSlideEnded(notification_id_); } }
diff --git a/ui/message_center/views/message_view.h b/ui/message_center/views/message_view.h index 67ad582..6a49d35 100644 --- a/ui/message_center/views/message_view.h +++ b/ui/message_center/views/message_view.h
@@ -52,6 +52,7 @@ public: virtual void OnSlideStarted(const std::string& notification_id) {} virtual void OnSlideChanged(const std::string& notification_id) {} + virtual void OnSlideEnded(const std::string& notification_id) {} virtual void OnPreSlideOut(const std::string& notification_id) {} virtual void OnSlideOut(const std::string& notification_id) {} virtual void OnCloseButtonPressed(const std::string& notification_id) {} @@ -161,7 +162,7 @@ Mode GetMode() const; // Gets the current horizontal scroll offset of the view by slide gesture. - float GetSlideAmount() const; + virtual float GetSlideAmount() const; // Set "setting" mode. This overrides "pinned" mode. See the comment of // MessageView::Mode enum for detail.
diff --git a/ui/views/controls/animated_image_view.cc b/ui/views/controls/animated_image_view.cc index 36501bf7..9aea798 100644 --- a/ui/views/controls/animated_image_view.cc +++ b/ui/views/controls/animated_image_view.cc
@@ -51,7 +51,8 @@ void AnimatedImageView::Play() { DCHECK(animated_image_); - DCHECK_EQ(state_, State::kStopped); + if (state_ == State::kPlaying) + return; state_ = State::kPlaying;
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc index 979189f..3546308 100644 --- a/ui/views/controls/textfield/textfield.cc +++ b/ui/views/controls/textfield/textfield.cc
@@ -1838,8 +1838,7 @@ OnBeforeUserAction(); gfx::SelectionModel selection_model = GetSelectionModel(); - bool text_changed, cursor_changed; - std::tie(text_changed, cursor_changed) = DoExecuteTextEditCommand(command); + auto [text_changed, cursor_changed] = DoExecuteTextEditCommand(command); cursor_changed |= (GetSelectionModel() != selection_model); if (cursor_changed && HasSelection())
diff --git a/weblayer/browser/java/org/chromium/weblayer_private/InterceptNavigationDelegateClientImpl.java b/weblayer/browser/java/org/chromium/weblayer_private/InterceptNavigationDelegateClientImpl.java index 1d6105d..acbb1a8c 100644 --- a/weblayer/browser/java/org/chromium/weblayer_private/InterceptNavigationDelegateClientImpl.java +++ b/weblayer/browser/java/org/chromium/weblayer_private/InterceptNavigationDelegateClientImpl.java
@@ -142,7 +142,7 @@ @Override public void onNavigationStarted(NavigationParams params) { - if (params.hasUserGesture || params.hasUserGestureCarryover) { + if (params.hasUserGesture) { mLastNavigationWithUserGestureTime = SystemClock.elapsedRealtime(); } }