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:

committed by
Chromium LUCI CQ

parent
6dbbfbd67b
commit
7d6fce267b
chrome/browser
content/shell/browser
headless/lib/browser
services/device/public/cpp/geolocation
@ -13,7 +13,7 @@
|
||||
#include "chrome/browser/apps/platform_apps/extension_app_shim_manager_delegate_mac.h"
|
||||
#include "chrome/browser/browser_process.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;
|
||||
|
||||
@ -67,8 +67,8 @@ void BrowserProcessPlatformPart::PreMainMessageLoopRun() {
|
||||
|
||||
if (!device::GeolocationSystemPermissionManager::GetInstance()) {
|
||||
device::GeolocationSystemPermissionManager::SetInstance(
|
||||
device::SystemGeolocationSourceMac::
|
||||
CreateGeolocationSystemPermissionManagerOnMac());
|
||||
device::SystemGeolocationSourceApple::
|
||||
CreateGeolocationSystemPermissionManager());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#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 {
|
||||
|
||||
@ -12,8 +12,8 @@ device::GeolocationSystemPermissionManager*
|
||||
ShellBrowserMainParts::GetGeolocationSystemPermissionManager() {
|
||||
if (!device::GeolocationSystemPermissionManager::GetInstance()) {
|
||||
device::GeolocationSystemPermissionManager::SetInstance(
|
||||
device::SystemGeolocationSourceMac::
|
||||
CreateGeolocationSystemPermissionManagerOnMac());
|
||||
device::SystemGeolocationSourceApple::
|
||||
CreateGeolocationSystemPermissionManager());
|
||||
}
|
||||
return device::GeolocationSystemPermissionManager::GetInstance();
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ specific_include_rules = {
|
||||
"+device/bluetooth",
|
||||
],
|
||||
"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",
|
||||
"+components/policy",
|
||||
"+components/prefs",
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "content/public/browser/render_widget_host_view.h"
|
||||
#include "content/public/browser/web_contents.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/gfx/mac/coordinate_conversion.h"
|
||||
|
||||
@ -71,8 +71,8 @@ const NSActivityOptions kActivityOptions =
|
||||
void HeadlessBrowserImpl::PlatformInitialize() {
|
||||
if (!geolocation_system_permission_manager_) {
|
||||
geolocation_system_permission_manager_ =
|
||||
device::SystemGeolocationSourceMac::
|
||||
CreateGeolocationSystemPermissionManagerOnMac();
|
||||
device::SystemGeolocationSourceApple::
|
||||
CreateGeolocationSystemPermissionManager();
|
||||
}
|
||||
screen_ = std::make_unique<display::ScopedNativeScreen>();
|
||||
HeadlessPopUpMethods::Init();
|
||||
|
@ -27,8 +27,8 @@ component("geolocation") {
|
||||
}
|
||||
if (is_apple) {
|
||||
sources += [
|
||||
"system_geolocation_source_mac.h",
|
||||
"system_geolocation_source_mac.mm",
|
||||
"system_geolocation_source_apple.h",
|
||||
"system_geolocation_source_apple.mm",
|
||||
]
|
||||
frameworks = [
|
||||
"CoreLocation.framework",
|
||||
|
@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SERVICES_DEVICE_PUBLIC_CPP_GEOLOCATION_SYSTEM_GEOLOCATION_SOURCE_MAC_H_
|
||||
#define 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_APPLE_H_
|
||||
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "services/device/public/cpp/geolocation/geolocation_system_permission_manager.h"
|
||||
@ -14,14 +14,14 @@
|
||||
|
||||
namespace device {
|
||||
|
||||
class COMPONENT_EXPORT(GEOLOCATION) SystemGeolocationSourceMac
|
||||
class COMPONENT_EXPORT(GEOLOCATION) SystemGeolocationSourceApple
|
||||
: public SystemGeolocationSource {
|
||||
public:
|
||||
static std::unique_ptr<GeolocationSystemPermissionManager>
|
||||
CreateGeolocationSystemPermissionManagerOnMac();
|
||||
CreateGeolocationSystemPermissionManager();
|
||||
|
||||
SystemGeolocationSourceMac();
|
||||
~SystemGeolocationSourceMac() override;
|
||||
SystemGeolocationSourceApple();
|
||||
~SystemGeolocationSourceApple() override;
|
||||
|
||||
// SystemGeolocationSource implementation:
|
||||
void RegisterPermissionUpdateCallback(
|
||||
@ -51,9 +51,9 @@ class COMPONENT_EXPORT(GEOLOCATION) SystemGeolocationSourceMac
|
||||
SEQUENCE_CHECKER(sequence_checker_);
|
||||
PermissionUpdateCallback permission_update_callback_;
|
||||
scoped_refptr<PositionObserverList> position_observers_;
|
||||
base::WeakPtrFactory<SystemGeolocationSourceMac> weak_ptr_factory_{this};
|
||||
base::WeakPtrFactory<SystemGeolocationSourceApple> weak_ptr_factory_{this};
|
||||
};
|
||||
|
||||
} // 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
|
||||
// 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>
|
||||
|
||||
@ -17,11 +17,11 @@
|
||||
: NSObject <CLLocationManagerDelegate> {
|
||||
BOOL _permissionInitialized;
|
||||
BOOL _hasPermission;
|
||||
base::WeakPtr<device::SystemGeolocationSourceMac> _manager;
|
||||
base::WeakPtr<device::SystemGeolocationSourceApple> _manager;
|
||||
}
|
||||
|
||||
- (instancetype)initWithManager:
|
||||
(base::WeakPtr<device::SystemGeolocationSourceMac>)manager;
|
||||
(base::WeakPtr<device::SystemGeolocationSourceApple>)manager;
|
||||
|
||||
// CLLocationManagerDelegate
|
||||
- (void)locationManager:(CLLocationManager*)manager
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
namespace device {
|
||||
|
||||
SystemGeolocationSourceMac::SystemGeolocationSourceMac()
|
||||
SystemGeolocationSourceApple::SystemGeolocationSourceApple()
|
||||
: location_manager_([[CLLocationManager alloc] init]),
|
||||
permission_update_callback_(base::DoNothing()),
|
||||
position_observers_(base::MakeRefCounted<PositionObserverList>()) {
|
||||
@ -44,38 +44,38 @@ SystemGeolocationSourceMac::SystemGeolocationSourceMac()
|
||||
location_manager_.delegate = delegate_;
|
||||
}
|
||||
|
||||
SystemGeolocationSourceMac::~SystemGeolocationSourceMac() = default;
|
||||
SystemGeolocationSourceApple::~SystemGeolocationSourceApple() = default;
|
||||
|
||||
// static
|
||||
std::unique_ptr<GeolocationSystemPermissionManager>
|
||||
SystemGeolocationSourceMac::CreateGeolocationSystemPermissionManagerOnMac() {
|
||||
SystemGeolocationSourceApple::CreateGeolocationSystemPermissionManager() {
|
||||
return std::make_unique<GeolocationSystemPermissionManager>(
|
||||
std::make_unique<SystemGeolocationSourceMac>());
|
||||
std::make_unique<SystemGeolocationSourceApple>());
|
||||
}
|
||||
|
||||
void SystemGeolocationSourceMac::RegisterPermissionUpdateCallback(
|
||||
void SystemGeolocationSourceApple::RegisterPermissionUpdateCallback(
|
||||
PermissionUpdateCallback callback) {
|
||||
permission_update_callback_ = callback;
|
||||
permission_update_callback_.Run(GetSystemPermission());
|
||||
}
|
||||
|
||||
void SystemGeolocationSourceMac::PermissionUpdated() {
|
||||
void SystemGeolocationSourceApple::PermissionUpdated() {
|
||||
permission_update_callback_.Run(GetSystemPermission());
|
||||
}
|
||||
|
||||
void SystemGeolocationSourceMac::PositionUpdated(
|
||||
void SystemGeolocationSourceApple::PositionUpdated(
|
||||
const mojom::Geoposition& position) {
|
||||
position_observers_->Notify(FROM_HERE, &PositionObserver::OnPositionUpdated,
|
||||
position);
|
||||
}
|
||||
|
||||
void SystemGeolocationSourceMac::PositionError(
|
||||
void SystemGeolocationSourceApple::PositionError(
|
||||
const mojom::GeopositionError& error) {
|
||||
position_observers_->Notify(FROM_HERE, &PositionObserver::OnPositionError,
|
||||
error);
|
||||
}
|
||||
|
||||
void SystemGeolocationSourceMac::StartWatchingPosition(bool high_accuracy) {
|
||||
void SystemGeolocationSourceApple::StartWatchingPosition(bool high_accuracy) {
|
||||
if (high_accuracy) {
|
||||
location_manager_.desiredAccuracy = kCLLocationAccuracyBest;
|
||||
} else {
|
||||
@ -85,11 +85,11 @@ void SystemGeolocationSourceMac::StartWatchingPosition(bool high_accuracy) {
|
||||
[location_manager_ startUpdatingLocation];
|
||||
}
|
||||
|
||||
void SystemGeolocationSourceMac::StopWatchingPosition() {
|
||||
void SystemGeolocationSourceApple::StopWatchingPosition() {
|
||||
[location_manager_ stopUpdatingLocation];
|
||||
}
|
||||
|
||||
LocationSystemPermissionStatus SystemGeolocationSourceMac::GetSystemPermission()
|
||||
LocationSystemPermissionStatus SystemGeolocationSourceApple::GetSystemPermission()
|
||||
const {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
if (![delegate_ permissionInitialized]) {
|
||||
@ -103,23 +103,23 @@ LocationSystemPermissionStatus SystemGeolocationSourceMac::GetSystemPermission()
|
||||
return LocationSystemPermissionStatus::kDenied;
|
||||
}
|
||||
|
||||
void SystemGeolocationSourceMac::OpenSystemPermissionSetting() {
|
||||
void SystemGeolocationSourceApple::OpenSystemPermissionSetting() {
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
base::mac::OpenSystemSettingsPane(
|
||||
base::mac::SystemSettingsPane::kPrivacySecurity_LocationServices);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SystemGeolocationSourceMac::RequestPermission() {
|
||||
void SystemGeolocationSourceApple::RequestPermission() {
|
||||
[location_manager_ requestWhenInUseAuthorization];
|
||||
}
|
||||
|
||||
void SystemGeolocationSourceMac::AddPositionUpdateObserver(
|
||||
void SystemGeolocationSourceApple::AddPositionUpdateObserver(
|
||||
PositionObserver* observer) {
|
||||
position_observers_->AddObserver(observer);
|
||||
}
|
||||
|
||||
void SystemGeolocationSourceMac::RemovePositionUpdateObserver(
|
||||
void SystemGeolocationSourceApple::RemovePositionUpdateObserver(
|
||||
PositionObserver* observer) {
|
||||
position_observers_->RemoveObserver(observer);
|
||||
}
|
||||
@ -129,7 +129,7 @@ void SystemGeolocationSourceMac::RemovePositionUpdateObserver(
|
||||
@implementation GeolocationSystemPermissionManagerDelegate
|
||||
|
||||
- (instancetype)initWithManager:
|
||||
(base::WeakPtr<device::SystemGeolocationSourceMac>)manager {
|
||||
(base::WeakPtr<device::SystemGeolocationSourceApple>)manager {
|
||||
if (self = [super init]) {
|
||||
_permissionInitialized = NO;
|
||||
_hasPermission = NO;
|
Reference in New Issue
Block a user