0

Rename SystemGeolocationSourceMac to SystemGeolocationSourceApple

Rename SystemGeolocationSourceMac to reflect that it is used both in
macOS and iOS.

Additionally, rename its method
`CreateGeolocationSystemPermissionManagerOnMac` to
`CreateGeolocationSystemPermissionManager`, since there's no need to
disambiguate the platform.

Change-Id: Iccc337fe03fec26a4277ba09751de9746e6703db
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5371735
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1274326}
This commit is contained in:
Henrique Ferreiro
2024-03-18 18:35:48 +00:00
committed by Chromium LUCI CQ
parent 6dbbfbd67b
commit 7d6fce267b
7 changed files with 39 additions and 39 deletions

@@ -13,7 +13,7 @@
#include "chrome/browser/apps/platform_apps/extension_app_shim_manager_delegate_mac.h" #include "chrome/browser/apps/platform_apps/extension_app_shim_manager_delegate_mac.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_browser_application_mac.h" #include "chrome/browser/chrome_browser_application_mac.h"
#include "services/device/public/cpp/geolocation/system_geolocation_source_mac.h" #include "services/device/public/cpp/geolocation/system_geolocation_source_apple.h"
BrowserProcessPlatformPart::BrowserProcessPlatformPart() = default; BrowserProcessPlatformPart::BrowserProcessPlatformPart() = default;
@@ -67,8 +67,8 @@ void BrowserProcessPlatformPart::PreMainMessageLoopRun() {
if (!device::GeolocationSystemPermissionManager::GetInstance()) { if (!device::GeolocationSystemPermissionManager::GetInstance()) {
device::GeolocationSystemPermissionManager::SetInstance( device::GeolocationSystemPermissionManager::SetInstance(
device::SystemGeolocationSourceMac:: device::SystemGeolocationSourceApple::
CreateGeolocationSystemPermissionManagerOnMac()); CreateGeolocationSystemPermissionManager());
} }
} }

@@ -4,7 +4,7 @@
#include "content/shell/browser/shell_browser_main_parts.h" #include "content/shell/browser/shell_browser_main_parts.h"
#include "services/device/public/cpp/geolocation/system_geolocation_source_mac.h" #include "services/device/public/cpp/geolocation/system_geolocation_source_apple.h"
namespace content { namespace content {
@@ -12,8 +12,8 @@ device::GeolocationSystemPermissionManager*
ShellBrowserMainParts::GetGeolocationSystemPermissionManager() { ShellBrowserMainParts::GetGeolocationSystemPermissionManager() {
if (!device::GeolocationSystemPermissionManager::GetInstance()) { if (!device::GeolocationSystemPermissionManager::GetInstance()) {
device::GeolocationSystemPermissionManager::SetInstance( device::GeolocationSystemPermissionManager::SetInstance(
device::SystemGeolocationSourceMac:: device::SystemGeolocationSourceApple::
CreateGeolocationSystemPermissionManagerOnMac()); CreateGeolocationSystemPermissionManager());
} }
return device::GeolocationSystemPermissionManager::GetInstance(); return device::GeolocationSystemPermissionManager::GetInstance();
} }

@@ -32,7 +32,7 @@ specific_include_rules = {
"+device/bluetooth", "+device/bluetooth",
], ],
"headless_browser_impl.*": [ "headless_browser_impl.*": [
"+services/device/public/cpp/geolocation/system_geolocation_source_mac.h", "+services/device/public/cpp/geolocation/system_geolocation_source_apple.h",
"+services/device/public/cpp/geolocation/geolocation_system_permission_manager.h", "+services/device/public/cpp/geolocation/geolocation_system_permission_manager.h",
"+components/policy", "+components/policy",
"+components/prefs", "+components/prefs",

@@ -12,7 +12,7 @@
#include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "headless/lib/browser/headless_web_contents_impl.h" #include "headless/lib/browser/headless_web_contents_impl.h"
#include "services/device/public/cpp/geolocation/system_geolocation_source_mac.h" #include "services/device/public/cpp/geolocation/system_geolocation_source_apple.h"
#import "ui/base/cocoa/base_view.h" #import "ui/base/cocoa/base_view.h"
#import "ui/gfx/mac/coordinate_conversion.h" #import "ui/gfx/mac/coordinate_conversion.h"
@@ -71,8 +71,8 @@ const NSActivityOptions kActivityOptions =
void HeadlessBrowserImpl::PlatformInitialize() { void HeadlessBrowserImpl::PlatformInitialize() {
if (!geolocation_system_permission_manager_) { if (!geolocation_system_permission_manager_) {
geolocation_system_permission_manager_ = geolocation_system_permission_manager_ =
device::SystemGeolocationSourceMac:: device::SystemGeolocationSourceApple::
CreateGeolocationSystemPermissionManagerOnMac(); CreateGeolocationSystemPermissionManager();
} }
screen_ = std::make_unique<display::ScopedNativeScreen>(); screen_ = std::make_unique<display::ScopedNativeScreen>();
HeadlessPopUpMethods::Init(); HeadlessPopUpMethods::Init();

@@ -27,8 +27,8 @@ component("geolocation") {
} }
if (is_apple) { if (is_apple) {
sources += [ sources += [
"system_geolocation_source_mac.h", "system_geolocation_source_apple.h",
"system_geolocation_source_mac.mm", "system_geolocation_source_apple.mm",
] ]
frameworks = [ frameworks = [
"CoreLocation.framework", "CoreLocation.framework",

@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef SERVICES_DEVICE_PUBLIC_CPP_GEOLOCATION_SYSTEM_GEOLOCATION_SOURCE_MAC_H_ #ifndef SERVICES_DEVICE_PUBLIC_CPP_GEOLOCATION_SYSTEM_GEOLOCATION_SOURCE_APPLE_H_
#define SERVICES_DEVICE_PUBLIC_CPP_GEOLOCATION_SYSTEM_GEOLOCATION_SOURCE_MAC_H_ #define SERVICES_DEVICE_PUBLIC_CPP_GEOLOCATION_SYSTEM_GEOLOCATION_SOURCE_APPLE_H_
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "services/device/public/cpp/geolocation/geolocation_system_permission_manager.h" #include "services/device/public/cpp/geolocation/geolocation_system_permission_manager.h"
@@ -14,14 +14,14 @@
namespace device { namespace device {
class COMPONENT_EXPORT(GEOLOCATION) SystemGeolocationSourceMac class COMPONENT_EXPORT(GEOLOCATION) SystemGeolocationSourceApple
: public SystemGeolocationSource { : public SystemGeolocationSource {
public: public:
static std::unique_ptr<GeolocationSystemPermissionManager> static std::unique_ptr<GeolocationSystemPermissionManager>
CreateGeolocationSystemPermissionManagerOnMac(); CreateGeolocationSystemPermissionManager();
SystemGeolocationSourceMac(); SystemGeolocationSourceApple();
~SystemGeolocationSourceMac() override; ~SystemGeolocationSourceApple() override;
// SystemGeolocationSource implementation: // SystemGeolocationSource implementation:
void RegisterPermissionUpdateCallback( void RegisterPermissionUpdateCallback(
@@ -51,9 +51,9 @@ class COMPONENT_EXPORT(GEOLOCATION) SystemGeolocationSourceMac
SEQUENCE_CHECKER(sequence_checker_); SEQUENCE_CHECKER(sequence_checker_);
PermissionUpdateCallback permission_update_callback_; PermissionUpdateCallback permission_update_callback_;
scoped_refptr<PositionObserverList> position_observers_; scoped_refptr<PositionObserverList> position_observers_;
base::WeakPtrFactory<SystemGeolocationSourceMac> weak_ptr_factory_{this}; base::WeakPtrFactory<SystemGeolocationSourceApple> weak_ptr_factory_{this};
}; };
} // namespace device } // namespace device
#endif // SERVICES_DEVICE_PUBLIC_CPP_GEOLOCATION_SYSTEM_GEOLOCATION_SOURCE_MAC_H_ #endif // SERVICES_DEVICE_PUBLIC_CPP_GEOLOCATION_SYSTEM_GEOLOCATION_SOURCE_APPLE_H_

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "services/device/public/cpp/geolocation/system_geolocation_source_mac.h" #include "services/device/public/cpp/geolocation/system_geolocation_source_apple.h"
#import <CoreLocation/CoreLocation.h> #import <CoreLocation/CoreLocation.h>
@@ -17,11 +17,11 @@
: NSObject <CLLocationManagerDelegate> { : NSObject <CLLocationManagerDelegate> {
BOOL _permissionInitialized; BOOL _permissionInitialized;
BOOL _hasPermission; BOOL _hasPermission;
base::WeakPtr<device::SystemGeolocationSourceMac> _manager; base::WeakPtr<device::SystemGeolocationSourceApple> _manager;
} }
- (instancetype)initWithManager: - (instancetype)initWithManager:
(base::WeakPtr<device::SystemGeolocationSourceMac>)manager; (base::WeakPtr<device::SystemGeolocationSourceApple>)manager;
// CLLocationManagerDelegate // CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager*)manager - (void)locationManager:(CLLocationManager*)manager
@@ -35,7 +35,7 @@
namespace device { namespace device {
SystemGeolocationSourceMac::SystemGeolocationSourceMac() SystemGeolocationSourceApple::SystemGeolocationSourceApple()
: location_manager_([[CLLocationManager alloc] init]), : location_manager_([[CLLocationManager alloc] init]),
permission_update_callback_(base::DoNothing()), permission_update_callback_(base::DoNothing()),
position_observers_(base::MakeRefCounted<PositionObserverList>()) { position_observers_(base::MakeRefCounted<PositionObserverList>()) {
@@ -44,38 +44,38 @@ SystemGeolocationSourceMac::SystemGeolocationSourceMac()
location_manager_.delegate = delegate_; location_manager_.delegate = delegate_;
} }
SystemGeolocationSourceMac::~SystemGeolocationSourceMac() = default; SystemGeolocationSourceApple::~SystemGeolocationSourceApple() = default;
// static // static
std::unique_ptr<GeolocationSystemPermissionManager> std::unique_ptr<GeolocationSystemPermissionManager>
SystemGeolocationSourceMac::CreateGeolocationSystemPermissionManagerOnMac() { SystemGeolocationSourceApple::CreateGeolocationSystemPermissionManager() {
return std::make_unique<GeolocationSystemPermissionManager>( return std::make_unique<GeolocationSystemPermissionManager>(
std::make_unique<SystemGeolocationSourceMac>()); std::make_unique<SystemGeolocationSourceApple>());
} }
void SystemGeolocationSourceMac::RegisterPermissionUpdateCallback( void SystemGeolocationSourceApple::RegisterPermissionUpdateCallback(
PermissionUpdateCallback callback) { PermissionUpdateCallback callback) {
permission_update_callback_ = callback; permission_update_callback_ = callback;
permission_update_callback_.Run(GetSystemPermission()); permission_update_callback_.Run(GetSystemPermission());
} }
void SystemGeolocationSourceMac::PermissionUpdated() { void SystemGeolocationSourceApple::PermissionUpdated() {
permission_update_callback_.Run(GetSystemPermission()); permission_update_callback_.Run(GetSystemPermission());
} }
void SystemGeolocationSourceMac::PositionUpdated( void SystemGeolocationSourceApple::PositionUpdated(
const mojom::Geoposition& position) { const mojom::Geoposition& position) {
position_observers_->Notify(FROM_HERE, &PositionObserver::OnPositionUpdated, position_observers_->Notify(FROM_HERE, &PositionObserver::OnPositionUpdated,
position); position);
} }
void SystemGeolocationSourceMac::PositionError( void SystemGeolocationSourceApple::PositionError(
const mojom::GeopositionError& error) { const mojom::GeopositionError& error) {
position_observers_->Notify(FROM_HERE, &PositionObserver::OnPositionError, position_observers_->Notify(FROM_HERE, &PositionObserver::OnPositionError,
error); error);
} }
void SystemGeolocationSourceMac::StartWatchingPosition(bool high_accuracy) { void SystemGeolocationSourceApple::StartWatchingPosition(bool high_accuracy) {
if (high_accuracy) { if (high_accuracy) {
location_manager_.desiredAccuracy = kCLLocationAccuracyBest; location_manager_.desiredAccuracy = kCLLocationAccuracyBest;
} else { } else {
@@ -85,11 +85,11 @@ void SystemGeolocationSourceMac::StartWatchingPosition(bool high_accuracy) {
[location_manager_ startUpdatingLocation]; [location_manager_ startUpdatingLocation];
} }
void SystemGeolocationSourceMac::StopWatchingPosition() { void SystemGeolocationSourceApple::StopWatchingPosition() {
[location_manager_ stopUpdatingLocation]; [location_manager_ stopUpdatingLocation];
} }
LocationSystemPermissionStatus SystemGeolocationSourceMac::GetSystemPermission() LocationSystemPermissionStatus SystemGeolocationSourceApple::GetSystemPermission()
const { const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (![delegate_ permissionInitialized]) { if (![delegate_ permissionInitialized]) {
@@ -103,23 +103,23 @@ LocationSystemPermissionStatus SystemGeolocationSourceMac::GetSystemPermission()
return LocationSystemPermissionStatus::kDenied; return LocationSystemPermissionStatus::kDenied;
} }
void SystemGeolocationSourceMac::OpenSystemPermissionSetting() { void SystemGeolocationSourceApple::OpenSystemPermissionSetting() {
#if BUILDFLAG(IS_MAC) #if BUILDFLAG(IS_MAC)
base::mac::OpenSystemSettingsPane( base::mac::OpenSystemSettingsPane(
base::mac::SystemSettingsPane::kPrivacySecurity_LocationServices); base::mac::SystemSettingsPane::kPrivacySecurity_LocationServices);
#endif #endif
} }
void SystemGeolocationSourceMac::RequestPermission() { void SystemGeolocationSourceApple::RequestPermission() {
[location_manager_ requestWhenInUseAuthorization]; [location_manager_ requestWhenInUseAuthorization];
} }
void SystemGeolocationSourceMac::AddPositionUpdateObserver( void SystemGeolocationSourceApple::AddPositionUpdateObserver(
PositionObserver* observer) { PositionObserver* observer) {
position_observers_->AddObserver(observer); position_observers_->AddObserver(observer);
} }
void SystemGeolocationSourceMac::RemovePositionUpdateObserver( void SystemGeolocationSourceApple::RemovePositionUpdateObserver(
PositionObserver* observer) { PositionObserver* observer) {
position_observers_->RemoveObserver(observer); position_observers_->RemoveObserver(observer);
} }
@@ -129,7 +129,7 @@ void SystemGeolocationSourceMac::RemovePositionUpdateObserver(
@implementation GeolocationSystemPermissionManagerDelegate @implementation GeolocationSystemPermissionManagerDelegate
- (instancetype)initWithManager: - (instancetype)initWithManager:
(base::WeakPtr<device::SystemGeolocationSourceMac>)manager { (base::WeakPtr<device::SystemGeolocationSourceApple>)manager {
if (self = [super init]) { if (self = [super init]) {
_permissionInitialized = NO; _permissionInitialized = NO;
_hasPermission = NO; _hasPermission = NO;