0

Convert /headless to use ARC

See https://chromium.googlesource.com/chromium/src/+/main/docs/mac/arc.md
for information about this conversion.

This ended up only adding the ARC boilerplate as a marker to indicate
that these files were audited.

Bug: 1280317
Change-Id: Idce5fda8e9b7123cde3195e587e0e221cca0cf47
Include-Ci-Only-Tests: true
Validate-Test-Flakiness: skip
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4532582
Auto-Submit: Avi Drissman <avi@chromium.org>
Commit-Queue: Sami Kyöstilä <skyostil@chromium.org>
Reviewed-by: Sami Kyöstilä <skyostil@chromium.org>
Code-Coverage: Findit <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1144483}
This commit is contained in:
Avi Drissman
2023-05-16 00:24:00 +00:00
committed by Chromium LUCI CQ
parent 0c06b2edd6
commit 0334a4c855
5 changed files with 27 additions and 11 deletions

@ -368,12 +368,17 @@ component("headless_non_renderer") {
"public/util/user_agent.h",
]
if (is_apple) {
configs += [ "//build/config/compiler:enable_arc" ]
}
if (is_mac) {
sources += [
"lib/browser/headless_browser_impl_mac.mm",
"lib/browser/headless_browser_main_parts_mac.mm",
"lib/browser/headless_shell_application_mac.h",
"lib/browser/headless_shell_application_mac.mm",
"lib/headless_content_main_delegate_mac.mm",
]
}
@ -513,10 +518,6 @@ component("headless_non_renderer") {
deps += [ "//ui/ozone" ]
}
if (is_mac) {
sources += [ "lib/headless_content_main_delegate_mac.mm" ]
}
if (headless_use_prefs) {
deps += [
"//components/origin_trials:browser",

@ -15,6 +15,10 @@
#import "ui/base/cocoa/base_view.h"
#import "ui/gfx/mac/coordinate_conversion.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
// Overrides events and actions for NSPopUpButtonCell.
@interface FakeNSPopUpButtonCell : NSObject
@end
@ -33,7 +37,7 @@ namespace headless {
namespace {
// Swizzles all event and acctions for NSPopUpButtonCell to avoid showing in
// Swizzles all event and actions for NSPopUpButtonCell to avoid showing in
// headless mode.
class HeadlessPopUpMethods {
public:
@ -74,8 +78,8 @@ void HeadlessBrowserImpl::PlatformInitialize() {
void HeadlessBrowserImpl::PlatformStart() {
// Disallow headless to be throttled as a background process.
[[NSProcessInfo processInfo] beginActivityWithOptions:kActivityOptions
reason:kActivityReason];
[NSProcessInfo.processInfo beginActivityWithOptions:kActivityOptions
reason:kActivityReason];
}
void HeadlessBrowserImpl::PlatformInitializeWebContents(
@ -94,8 +98,7 @@ void HeadlessBrowserImpl::PlatformSetWebContentsBounds(
content::WebContents* content_web_contents = web_contents->web_contents();
NSView* web_view = content_web_contents->GetNativeView().GetNativeNSView();
NSRect frame = gfx::ScreenRectToNSRect(bounds);
[web_view setFrame:frame];
web_view.frame = gfx::ScreenRectToNSRect(bounds);
// Render widget host view is not ready at this point, so post a task to set
// bounds at later time.

@ -9,11 +9,15 @@
#include "headless/lib/browser/headless_shell_application_mac.h"
#include "services/device/public/cpp/geolocation/system_geolocation_source_mac.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace headless {
void HeadlessBrowserMainParts::PreCreateMainMessageLoop() {
// Force hide dock and menu bar.
[NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];
NSApp.activationPolicy = NSApplicationActivationPolicyAccessory;
if (!geolocation_manager_)
geolocation_manager_ =
device::SystemGeolocationSourceMac::CreateGeolocationManagerOnMac();

@ -9,7 +9,11 @@
#include "content/public/browser/native_event_processor_mac.h"
#include "content/public/browser/native_event_processor_observer_mac.h"
@interface HeadlessShellCrApplication ()<NativeEventProcessor> {
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface HeadlessShellCrApplication () <NativeEventProcessor> {
base::ObserverList<content::NativeEventProcessorObserver>::Unchecked
_observers;
}

@ -6,6 +6,10 @@
#include "headless/lib/browser/headless_shell_application_mac.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace headless {
void HeadlessContentMainDelegate::PlatformPreBrowserMain() {