From 2276b59890d820ce5343697ca2f6b250a720d9f5 Mon Sep 17 00:00:00 2001 From: Szabolcs David Date: Tue, 31 May 2022 13:24:22 +0200 Subject: Trim down some dependencies of push messaging Make push messaging working in WebEngine by guarding out code parts with large dependencies. Task-number: QTBUG-98904 Task-number: QTBUG-53457 Change-Id: Idd0a4d4c8ff8e1632e1802d027bd98f8838be921 Reviewed-by: Allan Sandfeld Jensen --- .../browser/gcm/gcm_profile_service_factory.cc | 6 ++ .../push_messaging_app_identifier.cc | 4 +- .../push_messaging_notification_manager.cc | 29 +++++++ .../push_messaging_notification_manager.h | 2 + .../push_messaging_service_factory.cc | 6 ++ .../push_messaging/push_messaging_service_impl.cc | 92 ++++++++++++++++++++++ .../push_messaging/push_messaging_service_impl.h | 8 ++ .../chrome/browser/signin/chrome_signin_client.cc | 26 +++++- .../browser/signin/chrome_signin_client_factory.cc | 6 ++ .../chrome/browser/signin/force_signin_verifier.cc | 8 ++ .../browser/signin/identity_manager_factory.cc | 20 +++-- chromium/chrome/browser/signin/signin_ui_util.cc | 2 +- chromium/chrome/browser/signin/signin_util.cc | 10 ++- chromium/google_apis/gcm/base/gcm_constants.cc | 2 +- 14 files changed, 209 insertions(+), 12 deletions(-) diff --git a/chromium/chrome/browser/gcm/gcm_profile_service_factory.cc b/chromium/chrome/browser/gcm/gcm_profile_service_factory.cc index 064e2df8721..d92e7e25aa6 100644 --- a/chromium/chrome/browser/gcm/gcm_profile_service_factory.cc +++ b/chromium/chrome/browser/gcm/gcm_profile_service_factory.cc @@ -12,7 +12,9 @@ #include "build/build_config.h" #include "chrome/browser/profiles/incognito_helpers.h" #include "chrome/browser/profiles/profile.h" +#ifndef TOOLKIT_QT #include "chrome/browser/profiles/profile_key.h" +#endif #include "chrome/browser/signin/identity_manager_factory.h" #include "components/gcm_driver/gcm_profile_service.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" @@ -145,7 +147,11 @@ KeyedService* GCMProfileServiceFactory::BuildServiceInstanceFor( base::BindRepeating(&RequestProxyResolvingSocketFactory, profile), profile->GetDefaultStoragePartition() ->GetURLLoaderFactoryForBrowserProcess(), +#ifndef TOOLKIT_QT content::GetNetworkConnectionTracker(), chrome::GetChannel(), +#else + content::GetNetworkConnectionTracker(), version_info::Channel::STABLE, +#endif gcm::GetProductCategoryForSubtypes(profile->GetPrefs()), IdentityManagerFactory::GetForProfile(profile), std::make_unique(), content::GetUIThreadTaskRunner({}), diff --git a/chromium/chrome/browser/push_messaging/push_messaging_app_identifier.cc b/chromium/chrome/browser/push_messaging/push_messaging_app_identifier.cc index 1e536d36f9d..db552bdfffa 100644 --- a/chromium/chrome/browser/push_messaging/push_messaging_app_identifier.cc +++ b/chromium/chrome/browser/push_messaging/push_messaging_app_identifier.cc @@ -19,8 +19,8 @@ #include "components/prefs/pref_service.h" #include "components/prefs/scoped_user_pref_update.h" -constexpr char kPushMessagingAppIdentifierPrefix[] = "wp:"; -constexpr char kInstanceIDGuidSuffix[] = "-V2"; +const char kPushMessagingAppIdentifierPrefix[] = "wp:"; +const char kInstanceIDGuidSuffix[] = "-V2"; namespace { diff --git a/chromium/chrome/browser/push_messaging/push_messaging_notification_manager.cc b/chromium/chrome/browser/push_messaging/push_messaging_notification_manager.cc index 9e089d23993..fb224b0d523 100644 --- a/chromium/chrome/browser/push_messaging/push_messaging_notification_manager.cc +++ b/chromium/chrome/browser/push_messaging/push_messaging_notification_manager.cc @@ -17,12 +17,18 @@ #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" #include "build/chromeos_buildflags.h" +#ifndef TOOLKIT_QT #include "chrome/browser/notifications/platform_notification_service_factory.h" #include "chrome/browser/notifications/platform_notification_service_impl.h" +#else +#include "content/public/browser/platform_notification_service.h" +#endif #include "chrome/browser/profiles/profile.h" #include "chrome/browser/push_messaging/push_messaging_constants.h" #include "chrome/grit/generated_resources.h" +#ifndef TOOLKIT_QT #include "components/site_engagement/content/site_engagement_service.h" +#endif #include "components/url_formatter/elide_url.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_task_traits.h" @@ -42,6 +48,7 @@ #include "ui/base/l10n/l10n_util.h" #include "url/gurl.h" +#ifndef TOOLKIT_QT #if BUILDFLAG(IS_ANDROID) #include "chrome/browser/ui/android/tab_model/tab_model.h" #include "chrome/browser/ui/android/tab_model/tab_model_list.h" @@ -50,6 +57,7 @@ #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #endif +#endif // !TOOLKIT_QT #if BUILDFLAG(IS_CHROMEOS_ASH) #include "chrome/browser/ash/android_sms/android_sms_service_factory.h" @@ -57,6 +65,10 @@ #include "chrome/browser/ash/multidevice_setup/multidevice_setup_client_factory.h" #endif +#ifdef TOOLKIT_QT +#include "content/public/common/content_client.h" +#endif + using content::BrowserThread; using content::NotificationDatabaseData; using content::PlatformNotificationContext; @@ -104,7 +116,11 @@ NotificationDatabaseData CreateDatabaseData( PushMessagingNotificationManager::PushMessagingNotificationManager( Profile* profile) +#ifndef TOOLKIT_QT : profile_(profile), budget_database_(profile) {} +#else + : profile_(profile) {} +#endif PushMessagingNotificationManager::~PushMessagingNotificationManager() = default; @@ -154,6 +170,7 @@ void PushMessagingNotificationManager::DidCountVisibleNotifications( base::UmaHistogramCounts100("PushMessaging.VisibleNotificationCount", notification_count); +#ifndef TOOLKIT_QT // Sites with a currently visible tab don't need to show notifications. #if BUILDFLAG(IS_ANDROID) for (const TabModel* model : TabModelList::models()) { @@ -170,6 +187,7 @@ void PushMessagingNotificationManager::DidCountVisibleNotifications( break; } } +#endif // !TOOLKIT_QT // If more than one notification is showing for this Service Worker, close // the default notification if it happens to be part of this group. @@ -184,12 +202,18 @@ void PushMessagingNotificationManager::DidCountVisibleNotifications( if (notification_needed && !notification_shown) { // If the worker needed to show a notification and didn't, see if a silent // push was allowed. +#ifndef TOOLKIT_QT budget_database_.SpendBudget( url::Origin::Create(origin), base::BindOnce(&PushMessagingNotificationManager::ProcessSilentPush, weak_factory_.GetWeakPtr(), origin, service_worker_registration_id, std::move(message_handled_callback))); +#else + PushMessagingNotificationManager::ProcessSilentPush(origin, + service_worker_registration_id, + std::move(message_handled_callback), true /* silent_push_allowed */); +#endif // !TOOLKIT_QT return; } @@ -268,8 +292,13 @@ void PushMessagingNotificationManager::ProcessSilentPush( scoped_refptr notification_context = GetStoragePartition(profile_, origin)->GetPlatformNotificationContext(); int64_t next_persistent_notification_id = +#ifndef TOOLKIT_QT PlatformNotificationServiceFactory::GetForProfile(profile_) ->ReadNextPersistentNotificationId(); +#else + profile_->GetPlatformNotificationService() + ->ReadNextPersistentNotificationId(); +#endif notification_context->WriteNotificationData( next_persistent_notification_id, service_worker_registration_id, origin, diff --git a/chromium/chrome/browser/push_messaging/push_messaging_notification_manager.h b/chromium/chrome/browser/push_messaging/push_messaging_notification_manager.h index ddcc1b1c685..2729135ebec 100644 --- a/chromium/chrome/browser/push_messaging/push_messaging_notification_manager.h +++ b/chromium/chrome/browser/push_messaging/push_messaging_notification_manager.h @@ -105,7 +105,9 @@ class PushMessagingNotificationManager { // Weak. This manager is owned by a keyed service on this profile. raw_ptr profile_; +#ifndef TOOLKIT_QT BudgetDatabase budget_database_; +#endif #if BUILDFLAG(IS_CHROMEOS_ASH) ash::multidevice_setup::MultiDeviceSetupClient* diff --git a/chromium/chrome/browser/push_messaging/push_messaging_service_factory.cc b/chromium/chrome/browser/push_messaging/push_messaging_service_factory.cc index 1b02dd1df46..e50f39fa76c 100644 --- a/chromium/chrome/browser/push_messaging/push_messaging_service_factory.cc +++ b/chromium/chrome/browser/push_messaging/push_messaging_service_factory.cc @@ -9,11 +9,15 @@ #include "base/bind.h" #include "base/memory/ptr_util.h" #include "build/chromeos_buildflags.h" +#ifndef TOOLKIT_QT #include "chrome/browser/content_settings/host_content_settings_map_factory.h" #include "chrome/browser/engagement/site_engagement_service_factory.h" +#endif #include "chrome/browser/gcm/gcm_profile_service_factory.h" #include "chrome/browser/gcm/instance_id/instance_id_profile_service_factory.h" +#ifndef TOOLKIT_QT #include "chrome/browser/permissions/permission_manager_factory.h" +#endif #include "chrome/browser/profiles/profile.h" #include "chrome/browser/push_messaging/push_messaging_service_impl.h" #include "components/gcm_driver/instance_id/instance_id_profile_service.h" @@ -46,9 +50,11 @@ PushMessagingServiceFactory::PushMessagingServiceFactory() ProfileSelections::BuildForRegularAndIncognito()) { DependsOn(gcm::GCMProfileServiceFactory::GetInstance()); DependsOn(instance_id::InstanceIDProfileServiceFactory::GetInstance()); +#ifndef TOOLKIT_QT DependsOn(HostContentSettingsMapFactory::GetInstance()); DependsOn(PermissionManagerFactory::GetInstance()); DependsOn(site_engagement::SiteEngagementServiceFactory::GetInstance()); +#endif #if BUILDFLAG(IS_CHROMEOS_ASH) DependsOn(ash::android_sms::AndroidSmsServiceFactory::GetInstance()); DependsOn( diff --git a/chromium/chrome/browser/push_messaging/push_messaging_service_impl.cc b/chromium/chrome/browser/push_messaging/push_messaging_service_impl.cc index bbbf4d8ac0a..392bb06b4d1 100644 --- a/chromium/chrome/browser/push_messaging/push_messaging_service_impl.cc +++ b/chromium/chrome/browser/push_messaging/push_messaging_service_impl.cc @@ -21,21 +21,27 @@ #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" #include "build/build_config.h" +#ifndef TOOLKIT_QT #include "chrome/browser/browser_process.h" #include "chrome/browser/content_settings/host_content_settings_map_factory.h" +#endif #include "chrome/browser/gcm/gcm_profile_service_factory.h" #include "chrome/browser/gcm/instance_id/instance_id_profile_service_factory.h" #include "chrome/browser/lifetime/termination_notification.h" +#ifndef TOOLKIT_QT #include "chrome/browser/permissions/permission_revocation_request.h" #include "chrome/browser/profiles/keep_alive/profile_keep_alive_types.h" #include "chrome/browser/profiles/keep_alive/scoped_profile_keep_alive.h" +#endif #include "chrome/browser/profiles/profile.h" #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" #include "chrome/browser/push_messaging/push_messaging_constants.h" #include "chrome/browser/push_messaging/push_messaging_features.h" #include "chrome/browser/push_messaging/push_messaging_service_factory.h" #include "chrome/browser/push_messaging/push_messaging_utils.h" +#ifndef TOOLKIT_QT #include "chrome/browser/ui/chrome_pages.h" +#endif #include "chrome/common/buildflags.h" #include "chrome/common/chrome_features.h" #include "chrome/common/chrome_switches.h" @@ -88,6 +94,14 @@ using instance_id::InstanceID; namespace { +#ifdef TOOLKIT_QT +GURL CreateCustomEndpoint(Profile *profile, const std::string& subscription_id) { + const GURL endpoint(profile->GetPushMessagingEndpoint() + subscription_id); + DCHECK(endpoint.is_valid()); + return endpoint; +} +#endif + // Scope passed to getToken to obtain GCM registration tokens. // Must match Java GoogleCloudMessaging.INSTANCE_ID_SCOPE. const char kGCMScope[] = "GCM"; @@ -271,7 +285,9 @@ PushMessagingServiceImpl::PushMessagingServiceImpl(Profile* profile) pending_push_subscription_count_(0), notification_manager_(profile) { DCHECK(profile); +#ifndef TOOLKIT_QT HostContentSettingsMapFactory::GetForProfile(profile_)->AddObserver(this); +#endif on_app_terminating_subscription_ = browser_shutdown::AddAppTerminatingCallback(base::BindOnce( @@ -338,11 +354,13 @@ void PushMessagingServiceImpl::OnStoreReset() { void PushMessagingServiceImpl::OnMessage(const std::string& app_id, const gcm::IncomingMessage& message) { +#ifndef TOOLKIT_QT // We won't have time to process and act on the message. // TODO(peter) This should be checked at the level of the GCMDriver, so that // the message is not consumed. See https://crbug.com/612815 if (g_browser_process->IsShuttingDown() || shutdown_started_) return; +#endif // !TOOLKIT_QT #if BUILDFLAG(ENABLE_BACKGROUND_MODE) if (g_browser_process->background_mode_manager()) { @@ -395,10 +413,14 @@ void PushMessagingServiceImpl::OnMessage(const std::string& app_id, if (IsPermissionSet(app_identifier.origin())) { messages_pending_permission_check_.emplace(app_id, message); +#ifndef TOOLKIT_QT // Start abusive and disruptive origin verifications only if no other // respective verification is in progress. if (!origin_revocation_request_) CheckOriginAndDispatchNextMessage(); +#else + DispatchNextMessage(); +#endif } else { // Drop message and unregister if origin has lost push permission. DeliverMessageCallback(app_id, app_identifier.origin(), @@ -408,6 +430,7 @@ void PushMessagingServiceImpl::OnMessage(const std::string& app_id, } } +#ifndef TOOLKIT_QT void PushMessagingServiceImpl::CheckOriginAndDispatchNextMessage() { if (messages_pending_permission_check_.empty()) return; @@ -561,6 +584,43 @@ void PushMessagingServiceImpl::OnCheckedOrigin( // Verify the next message in the queue. CheckOriginAndDispatchNextMessage(); } +#else +void PushMessagingServiceImpl::DispatchNextMessage() +{ + if (messages_pending_permission_check_.empty()) + return; + + PendingMessage message = + std::move(messages_pending_permission_check_.front()); + messages_pending_permission_check_.pop(); + + PushMessagingAppIdentifier app_identifier = + PushMessagingAppIdentifier::FindByAppId(profile_, message.app_id); + + if (app_identifier.is_null()) { + DispatchNextMessage(); + return; + } + + const GURL& origin = app_identifier.origin(); + int64_t service_worker_registration_id = + app_identifier.service_worker_registration_id(); + + std::queue& delivery_queue = + message_delivery_queue_[{origin, service_worker_registration_id}]; + delivery_queue.push(std::move(message)); + + // Start delivering push messages to this service worker if this was the + // first message. Otherwise just enqueue the message to be delivered once + // all previous messages have been handled. + if (delivery_queue.size() == 1) { + DeliverNextQueuedMessageForServiceWorkerRegistration( + origin, service_worker_registration_id); + } + + DispatchNextMessage(); +} +#endif // !TOOLKIT_QT void PushMessagingServiceImpl:: DeliverNextQueuedMessageForServiceWorkerRegistration( @@ -900,12 +960,26 @@ void PushMessagingServiceImpl::SubscribeFromDocument( // It is OK to ignore `requesting_origin` because it will be calculated from // `render_frame_host` and we always use `requesting_origin` for // NOTIFICATIONS. +#ifndef TOOLKIT_QT profile_->GetPermissionController()->RequestPermissionFromCurrentDocument( blink::PermissionType::NOTIFICATIONS, render_frame_host, user_gesture, base::BindOnce(&PushMessagingServiceImpl::DoSubscribe, weak_factory_.GetWeakPtr(), std::move(app_identifier), std::move(options), std::move(callback), render_process_id, render_frame_id)); +#else + if (!IsPermissionSet(requesting_origin)) { + profile_->GetPermissionControllerDelegate()->RequestPermissionFromCurrentDocument( + content::PermissionType::NOTIFICATIONS, render_frame_host, user_gesture, + base::BindOnce(&PushMessagingServiceImpl::DoSubscribe, + weak_factory_.GetWeakPtr(), std::move(app_identifier), + std::move(options), std::move(callback), render_process_id, + render_frame_id)); + } else { + DoSubscribe(std::move(app_identifier), std::move(options), std::move(callback), + render_process_id, render_frame_id, blink::mojom::PermissionStatus::GRANTED); + } +#endif } void PushMessagingServiceImpl::SubscribeFromWorker( @@ -952,6 +1026,7 @@ blink::mojom::PermissionStatus PushMessagingServiceImpl::GetPermissionStatus( if (!user_visible) return blink::mojom::PermissionStatus::DENIED; +#ifndef TOOLKIT_QT // Because the Push API is tied to Service Workers, many usages of the API // won't have an embedding origin at all. Only consider the requesting // |origin| when checking whether permission to use the API has been granted. @@ -966,6 +1041,12 @@ blink::mojom::PermissionStatus PushMessagingServiceImpl::GetPermissionStatus( blink::PermissionType::NOTIFICATIONS, url::Origin::Create(origin)) .status; } +#else + return profile_->GetPermissionController() + ->GetPermissionResultForOriginWithoutContext( + blink::PermissionType::NOTIFICATIONS, url::Origin::Create(origin)) + .status; +#endif } #if BUILDFLAG(IS_ANDROID) @@ -1081,7 +1162,11 @@ void PushMessagingServiceImpl::DidSubscribe( switch (result) { case InstanceID::SUCCESS: { +#ifndef TOOLKIT_QT const GURL endpoint = push_messaging::CreateEndpoint(subscription_id); +#else + const GURL endpoint = CreateCustomEndpoint(profile_, subscription_id); +#endif // Make sure that this subscription has associated encryption keys prior // to returning it to the developer - they'll need this information in @@ -1156,7 +1241,12 @@ void PushMessagingServiceImpl::GetSubscriptionInfo( return; } +#ifndef TOOLKIT_QT const GURL endpoint = push_messaging::CreateEndpoint(subscription_id); +#else + const GURL endpoint = CreateCustomEndpoint(profile_, subscription_id); +#endif + const std::string& app_id = app_identifier.app_id(); absl::optional expiration_time = app_identifier.expiration_time(); @@ -1589,7 +1679,9 @@ void PushMessagingServiceImpl::SetContentSettingChangedCallbackForTesting( void PushMessagingServiceImpl::Shutdown() { GetGCMDriver()->RemoveAppHandler(kPushMessagingAppIdentifierPrefix); +#ifndef TOOLKIT_QT HostContentSettingsMapFactory::GetForProfile(profile_)->RemoveObserver(this); +#endif } void PushMessagingServiceImpl::OnAppTerminating() { diff --git a/chromium/chrome/browser/push_messaging/push_messaging_service_impl.h b/chromium/chrome/browser/push_messaging/push_messaging_service_impl.h index 5b5a7d62158..bfd93111727 100644 --- a/chromium/chrome/browser/push_messaging/push_messaging_service_impl.h +++ b/chromium/chrome/browser/push_messaging/push_messaging_service_impl.h @@ -243,14 +243,20 @@ class PushMessagingServiceImpl : public content::PushMessagingService, const std::string& push_message_id, bool did_show_generic_notification); +#ifndef TOOLKIT_QT void OnCheckedOrigin(PendingMessage message, PermissionRevocationRequest::Outcome outcome); +#endif void DeliverNextQueuedMessageForServiceWorkerRegistration( const GURL& origin, int64_t service_worker_registration_id); +#ifndef TOOLKIT_QT void CheckOriginAndDispatchNextMessage(); +#else + void DispatchNextMessage(); +#endif #if BUILDFLAG(IS_ANDROID) // Verifies if Chrome has Android app-level Notifications permission. If @@ -448,7 +454,9 @@ class PushMessagingServiceImpl : public content::PushMessagingService, void OnAppTerminating(); raw_ptr profile_; +#ifndef TOOLKIT_QT std::unique_ptr origin_revocation_request_; +#endif std::queue messages_pending_permission_check_; // {Origin, ServiceWokerRegistratonId} key for message delivery queue. This diff --git a/chromium/chrome/browser/signin/chrome_signin_client.cc b/chromium/chrome/browser/signin/chrome_signin_client.cc index 5b037d51ce9..14dfc453337 100644 --- a/chromium/chrome/browser/signin/chrome_signin_client.cc +++ b/chromium/chrome/browser/signin/chrome_signin_client.cc @@ -15,6 +15,7 @@ #include "build/build_config.h" #include "build/buildflag.h" #include "build/chromeos_buildflags.h" +#ifndef TOOLKIT_QT #include "chrome/browser/browser_process.h" #include "chrome/browser/content_settings/cookie_settings_factory.h" #include "chrome/browser/content_settings/host_content_settings_map_factory.h" @@ -23,6 +24,9 @@ #include "chrome/browser/profiles/profile_attributes_storage.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_metrics.h" +#else +#include "chrome/browser/profiles/profile.h" +#endif #include "chrome/browser/signin/account_consistency_mode_manager.h" #include "chrome/browser/signin/chrome_device_id_helper.h" #include "chrome/browser/signin/force_signin_verifier.h" @@ -34,7 +38,9 @@ #include "chrome/common/pref_names.h" #include "components/content_settings/core/browser/cookie_settings.h" #include "components/metrics/metrics_service.h" +#ifndef TOOLKIT_QT #include "components/policy/core/browser/browser_policy_connector.h" +#endif #include "components/prefs/pref_service.h" #include "components/signin/core/browser/cookie_settings_util.h" #include "components/signin/public/base/signin_buildflags.h" @@ -67,6 +73,7 @@ #include "third_party/abseil-cpp/absl/types/optional.h" #endif +#ifndef TOOLKIT_QT #if !BUILDFLAG(IS_ANDROID) #include "chrome/browser/profiles/profile_window.h" #endif @@ -75,6 +82,7 @@ #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/profile_picker.h" #endif +#endif // !TOOLKIT_QT namespace { @@ -145,9 +153,13 @@ void ChromeSigninClient::DoFinalInit() { // static bool ChromeSigninClient::ProfileAllowsSigninCookies(Profile* profile) { +#ifndef TOOLKIT_QT content_settings::CookieSettings* cookie_settings = CookieSettingsFactory::GetForProfile(profile).get(); return signin::SettingsAllowSigninCookies(cookie_settings); +#else + return true; +#endif } PrefService* ChromeSigninClient::GetPrefs() { return profile_->GetPrefs(); } @@ -171,21 +183,29 @@ bool ChromeSigninClient::AreSigninCookiesAllowed() { } bool ChromeSigninClient::AreSigninCookiesDeletedOnExit() { +#ifndef TOOLKIT_QT content_settings::CookieSettings* cookie_settings = CookieSettingsFactory::GetForProfile(profile_).get(); return signin::SettingsDeleteSigninCookiesOnExit(cookie_settings); +#else + return false; +#endif } void ChromeSigninClient::AddContentSettingsObserver( content_settings::Observer* observer) { +#ifndef TOOLKIT_QT HostContentSettingsMapFactory::GetForProfile(profile_) ->AddObserver(observer); +#endif } void ChromeSigninClient::RemoveContentSettingsObserver( content_settings::Observer* observer) { +#ifndef TOOLKIT_QT HostContentSettingsMapFactory::GetForProfile(profile_) ->RemoveObserver(observer); +#endif } void ChromeSigninClient::PreSignOut( @@ -195,7 +215,7 @@ void ChromeSigninClient::PreSignOut( DCHECK(!on_signout_decision_reached_) << "SignOut already in-progress!"; on_signout_decision_reached_ = std::move(on_signout_decision_reached); -#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) && !defined(TOOLKIT_QT) // `signout_source_metric` is `signin_metrics::ABORT_SIGNIN` if the user // declines sync in the signin process. In case the user accepts the managed // account but declines sync, we should keep the window open. @@ -404,6 +424,7 @@ void ChromeSigninClient::OnCloseBrowsersAborted( void ChromeSigninClient::LockForceSigninProfile( const base::FilePath& profile_path) { +#ifndef TOOLKIT_QT ProfileAttributesEntry* entry = g_browser_process->profile_manager() ->GetProfileAttributesStorage() @@ -411,10 +432,11 @@ void ChromeSigninClient::LockForceSigninProfile( if (!entry) return; entry->LockForceSigninProfile(true); +#endif } void ChromeSigninClient::ShowUserManager(const base::FilePath& profile_path) { -#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) && !defined(TOOLKIT_QT) ProfilePicker::Show(ProfilePicker::Params::FromEntryPoint( ProfilePicker::EntryPoint::kProfileLocked)); #endif diff --git a/chromium/chrome/browser/signin/chrome_signin_client_factory.cc b/chromium/chrome/browser/signin/chrome_signin_client_factory.cc index 7dee9e1430c..78d3cad6d38 100644 --- a/chromium/chrome/browser/signin/chrome_signin_client_factory.cc +++ b/chromium/chrome/browser/signin/chrome_signin_client_factory.cc @@ -4,12 +4,18 @@ #include "chrome/browser/signin/chrome_signin_client_factory.h" +#ifndef TOOLKIT_QT #include "chrome/browser/net/profile_network_context_service_factory.h" +#endif #include "chrome/browser/profiles/profile.h" ChromeSigninClientFactory::ChromeSigninClientFactory() +#ifndef TOOLKIT_QT : ProfileKeyedServiceFactory("ChromeSigninClient") { DependsOn(ProfileNetworkContextServiceFactory::GetInstance()); +#else +{ +#endif } ChromeSigninClientFactory::~ChromeSigninClientFactory() {} diff --git a/chromium/chrome/browser/signin/force_signin_verifier.cc b/chromium/chrome/browser/signin/force_signin_verifier.cc index aa74dae3249..0389d165f03 100644 --- a/chromium/chrome/browser/signin/force_signin_verifier.cc +++ b/chromium/chrome/browser/signin/force_signin_verifier.cc @@ -10,14 +10,18 @@ #include "base/callback_helpers.h" #include "base/files/file_path.h" #include "base/metrics/histogram_macros.h" +#ifndef TOOLKIT_QT #include "chrome/browser/browser_process.h" +#endif #include "chrome/browser/profiles/profile.h" +#ifndef TOOLKIT_QT #include "chrome/browser/profiles/profile_attributes_entry.h" #include "chrome/browser/profiles/profile_attributes_storage.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/profile_picker.h" #include "chrome/browser/ui/ui_features.h" +#endif #include "components/signin/public/base/signin_metrics.h" #include "components/signin/public/identity_manager/access_token_info.h" #include "components/signin/public/identity_manager/identity_manager.h" @@ -145,6 +149,7 @@ bool ForceSigninVerifier::ShouldSendRequest() { } void ForceSigninVerifier::CloseAllBrowserWindows() { +#ifndef TOOLKIT_QT if (base::FeatureList::IsEnabled(features::kForceSignInReauth)) { // Do not sign the user out to allow them to reauthenticate from the profile // picker. @@ -165,10 +170,12 @@ void ForceSigninVerifier::CloseAllBrowserWindows() { signin_metrics::AUTHENTICATION_FAILED_WITH_FORCE_SIGNIN, signin_metrics::SignoutDelete::kIgnoreMetric); } +#endif } void ForceSigninVerifier::OnCloseBrowsersSuccess( const base::FilePath& profile_path) { +#ifndef TOOLKIT_QT Cancel(); ProfileAttributesEntry* entry = @@ -180,6 +187,7 @@ void ForceSigninVerifier::OnCloseBrowsersSuccess( entry->LockForceSigninProfile(true); ProfilePicker::Show(ProfilePicker::Params::FromEntryPoint( ProfilePicker::EntryPoint::kProfileLocked)); +#endif } signin::PrimaryAccountAccessTokenFetcher* diff --git a/chromium/chrome/browser/signin/identity_manager_factory.cc b/chromium/chrome/browser/signin/identity_manager_factory.cc index bc37f69fb79..33a0ad2d345 100644 --- a/chromium/chrome/browser/signin/identity_manager_factory.cc +++ b/chromium/chrome/browser/signin/identity_manager_factory.cc @@ -11,8 +11,10 @@ #include "base/observer_list.h" #include "build/build_config.h" #include "build/chromeos_buildflags.h" +#ifndef TOOLKIT_QT #include "chrome/browser/browser_process.h" #include "chrome/browser/image_fetcher/image_decoder_impl.h" +#endif #include "chrome/browser/profiles/profile.h" #include "chrome/browser/signin/account_consistency_mode_manager.h" #include "chrome/browser/signin/chrome_signin_client_factory.h" @@ -25,7 +27,7 @@ #include "components/signin/public/webdata/token_web_data.h" #include "content/public/browser/network_service_instance.h" -#if BUILDFLAG(ENABLE_DICE_SUPPORT) || BUILDFLAG(IS_CHROMEOS_LACROS) +#if BUILDFLAG((ENABLE_DICE_SUPPORT) || BUILDFLAG(IS_CHROMEOS_LACROS)) && !defined(TOOLKIT_QT) #include "chrome/browser/content_settings/cookie_settings_factory.h" #include "components/content_settings/core/browser/cookie_settings.h" #include "components/signin/core/browser/cookie_settings_util.h" @@ -48,7 +50,7 @@ #include "components/account_manager_core/chromeos/account_manager_facade_factory.h" #endif -#if BUILDFLAG(IS_WIN) +#if BUILDFLAG(IS_WIN) && !defined(TOOLKIT_QT) #include "base/bind.h" #include "chrome/browser/signin/signin_util_win.h" #endif @@ -60,7 +62,7 @@ void IdentityManagerFactory::RegisterProfilePrefs( IdentityManagerFactory::IdentityManagerFactory() : ProfileKeyedServiceFactory("IdentityManager") { -#if BUILDFLAG(ENABLE_DICE_SUPPORT) +#if BUILDFLAG(ENABLE_DICE_SUPPORT) && !defined(TOOLKIT_QT) DependsOn(WebDataServiceFactory::GetInstance()); #endif #if BUILDFLAG(IS_CHROMEOS_LACROS) @@ -116,25 +118,33 @@ KeyedService* IdentityManagerFactory::BuildServiceInstanceFor( Profile* profile = Profile::FromBrowserContext(context); signin::IdentityManagerBuildParams params; +#ifndef TOOLKIT_QT params.account_consistency = AccountConsistencyModeManager::GetMethodForProfile(profile), params.image_decoder = std::make_unique(); params.local_state = g_browser_process->local_state(); +#else + params.account_consistency = signin::AccountConsistencyMethod::kDisabled; +#endif params.network_connection_tracker = content::GetNetworkConnectionTracker(); params.pref_service = profile->GetPrefs(); params.profile_path = profile->GetPath(); params.signin_client = ChromeSigninClientFactory::GetForProfile(profile); #if BUILDFLAG(ENABLE_DICE_SUPPORT) || BUILDFLAG(IS_CHROMEOS_LACROS) +#if !defined(TOOLKIT_QT) params.delete_signin_cookies_on_exit = signin::SettingsDeleteSigninCookiesOnExit( CookieSettingsFactory::GetForProfile(profile).get()); +#else + params.delete_signin_cookies_on_exit = true; +#endif #endif // BUILDFLAG(ENABLE_DICE_SUPPORT) || BUILDFLAG(IS_CHROMEOS_LACROS) #if BUILDFLAG(ENABLE_DICE_SUPPORT) params.token_web_data = WebDataServiceFactory::GetTokenWebDataForProfile( profile, ServiceAccessType::EXPLICIT_ACCESS); -#endif // #if BUILDFLAG(ENABLE_DICE_SUPPORT) +#endif #if BUILDFLAG(IS_CHROMEOS_ASH) params.account_manager_facade = @@ -158,7 +168,7 @@ KeyedService* IdentityManagerFactory::BuildServiceInstanceFor( params.is_regular_profile = is_regular_profile; #endif -#if BUILDFLAG(IS_WIN) +#if BUILDFLAG(IS_WIN) && !defined(TOOLKIT_QT) params.reauth_callback = base::BindRepeating(&signin_util::ReauthWithCredentialProviderIfPossible, base::Unretained(profile)); diff --git a/chromium/chrome/browser/signin/signin_ui_util.cc b/chromium/chrome/browser/signin/signin_ui_util.cc index 1ffa52fdb4f..37c82bd7a6a 100644 --- a/chromium/chrome/browser/signin/signin_ui_util.cc +++ b/chromium/chrome/browser/signin/signin_ui_util.cc @@ -55,7 +55,7 @@ #include "components/account_manager_core/chromeos/account_manager_facade_factory.h" #endif // BUILDFLAG(IS_CHROMEOS_ASH) -#if BUILDFLAG(ENABLE_DICE_SUPPORT) +#if BUILDFLAG(ENABLE_DICE_SUPPORT) && !defined(TOOLKIT_QT) #include "chrome/browser/signin/signin_ui_delegate_impl_dice.h" #endif // BUILDFLAG(ENABLE_DICE_SUPPORT) diff --git a/chromium/chrome/browser/signin/signin_util.cc b/chromium/chrome/browser/signin/signin_util.cc index c7ba92aa3c6..0628059ded7 100644 --- a/chromium/chrome/browser/signin/signin_util.cc +++ b/chromium/chrome/browser/signin/signin_util.cc @@ -13,10 +13,14 @@ #include "base/strings/utf_string_conversions.h" #include "base/supports_user_data.h" #include "build/chromeos_buildflags.h" +#ifndef TOOLKIT_QT #include "chrome/browser/browser_process.h" #include "chrome/browser/policy/cloud/user_policy_signin_service_internal.h" +#endif #include "chrome/browser/profiles/profile.h" +#ifndef TOOLKIT_QT #include "chrome/browser/profiles/profiles_state.h" +#endif #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "chrome/grit/generated_resources.h" @@ -95,7 +99,11 @@ ScopedForceSigninSetterForTesting::~ScopedForceSigninSetterForTesting() { bool IsForceSigninEnabled() { if (g_is_force_signin_enabled_cache == NOT_CACHED) { +#ifndef TOOLKIT_QT PrefService* prefs = g_browser_process->local_state(); +#else + PrefService* prefs = nullptr; +#endif if (prefs) SetForceSigninPolicy(prefs->GetBoolean(prefs::kForceBrowserSignin)); else @@ -128,7 +136,7 @@ void EnsureUserSignoutAllowedIsInitializedForProfile(Profile* profile) { } } -#if !BUILDFLAG(IS_ANDROID) +#if !BUILDFLAG(IS_ANDROID) && !defined(TOOLKIT_QT) #if !BUILDFLAG(IS_CHROMEOS) bool ProfileSeparationEnforcedByPolicy( Profile* profile, diff --git a/chromium/google_apis/gcm/base/gcm_constants.cc b/chromium/google_apis/gcm/base/gcm_constants.cc index b0bd3f52ac7..150167601f1 100644 --- a/chromium/google_apis/gcm/base/gcm_constants.cc +++ b/chromium/google_apis/gcm/base/gcm_constants.cc @@ -6,6 +6,6 @@ namespace gcm { -constexpr base::TimeDelta kIncomingMessageTTL = base::Days(7); +const base::TimeDelta kIncomingMessageTTL = base::Days(7); } // namespace gcm -- cgit v1.2.1