summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzabolcs David <davidsz@inf.u-szeged.hu>2022-05-31 13:24:22 +0200
committerSzabolcs David <davidsz@inf.u-szeged.hu>2022-06-02 12:45:21 +0000
commitcdcaf52a046858b60a6d19c77f7ebf0f3d35cbd9 (patch)
tree609ec2d0a614d420aaadebc3d2baa24c584d84cf
parent6559e00a366dac58b3467bd8475cc936baa1e5b1 (diff)
downloadqtwebengine-chromium-cdcaf52a046858b60a6d19c77f7ebf0f3d35cbd9.tar.gz
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 <allan.jensen@qt.io>
-rw-r--r--chromium/chrome/browser/gcm/gcm_profile_service_factory.cc6
-rw-r--r--chromium/chrome/browser/profiles/profile.cc22
-rw-r--r--chromium/chrome/browser/profiles/profile.h18
-rw-r--r--chromium/chrome/browser/push_messaging/push_messaging_notification_manager.cc29
-rw-r--r--chromium/chrome/browser/push_messaging/push_messaging_notification_manager.h2
-rw-r--r--chromium/chrome/browser/push_messaging/push_messaging_service_factory.cc6
-rw-r--r--chromium/chrome/browser/push_messaging/push_messaging_service_impl.cc109
-rw-r--r--chromium/chrome/browser/push_messaging/push_messaging_service_impl.h14
-rw-r--r--chromium/chrome/browser/signin/chrome_signin_client.cc30
-rw-r--r--chromium/chrome/browser/signin/chrome_signin_client_factory.cc4
-rw-r--r--chromium/chrome/browser/signin/force_signin_verifier.cc8
-rw-r--r--chromium/chrome/browser/signin/identity_manager_factory.cc14
-rw-r--r--chromium/chrome/browser/signin/signin_util.cc16
13 files changed, 272 insertions, 6 deletions
diff --git a/chromium/chrome/browser/gcm/gcm_profile_service_factory.cc b/chromium/chrome/browser/gcm/gcm_profile_service_factory.cc
index b3207963fdb..1e69411dfb8 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<GCMClientFactory>(), content::GetUIThreadTaskRunner({}),
diff --git a/chromium/chrome/browser/profiles/profile.cc b/chromium/chrome/browser/profiles/profile.cc
index b68749fd01f..8b24a6aa0a7 100644
--- a/chromium/chrome/browser/profiles/profile.cc
+++ b/chromium/chrome/browser/profiles/profile.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/profiles/profile.h"
+#include "components/profile_metrics/browser_profile_type.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
@@ -25,3 +26,24 @@ Profile* Profile::GetOriginalProfile() {
const Profile* Profile::GetOriginalProfile() const {
return this;
}
+
+bool Profile::IsRegularProfile() const {
+ return profile_metrics::GetBrowserProfileType(this) ==
+ profile_metrics::BrowserProfileType::kRegular;
+}
+
+bool Profile::IsGuestSession() const {
+ return profile_metrics::GetBrowserProfileType(this) ==
+ profile_metrics::BrowserProfileType::kGuest;
+}
+
+bool Profile::IsSystemProfile() const {
+ return profile_metrics::GetBrowserProfileType(this) ==
+ profile_metrics::BrowserProfileType::kSystem;
+}
+
+#ifdef TOOLKIT_QT
+std::string Profile::GetPushMessagingEndpoint() const {
+ return "";
+}
+#endif
diff --git a/chromium/chrome/browser/profiles/profile.h b/chromium/chrome/browser/profiles/profile.h
index 269b3700b90..97c7f4f52b9 100644
--- a/chromium/chrome/browser/profiles/profile.h
+++ b/chromium/chrome/browser/profiles/profile.h
@@ -31,6 +31,24 @@ class Profile : public content::BrowserContext {
Profile *GetOriginalProfile();
const Profile *GetOriginalProfile() const;
+
+ // Returns whether the profile is new. A profile is new if the browser has
+ // not been shut down since the profile was created.
+ virtual bool IsNewProfile() const = 0;
+
+ // Returns whether it's a regular profile.
+ bool IsRegularProfile() const;
+
+ // Returns whether it is a system profile.
+ bool IsSystemProfile() const;
+
+ // Returns whether it is a Guest session. This covers both regular and
+ // off-the-record profiles of a Guest session.
+ virtual bool IsGuestSession() const;
+
+#ifdef TOOLKIT_QT
+ virtual std::string GetPushMessagingEndpoint() const;
+#endif
};
#endif // CHROME_BROWSER_PROFILES_PROFILE_H_
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 e2a8f2adc42..bd5ff1843ce 100644
--- a/chromium/chrome/browser/push_messaging/push_messaging_notification_manager.cc
+++ b/chromium/chrome/browser/push_messaging/push_messaging_notification_manager.cc
@@ -18,12 +18,18 @@
#include "base/task/post_task.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"
@@ -43,6 +49,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
+#ifndef TOOLKIT_QT
#if defined(OS_ANDROID)
#include "chrome/browser/ui/android/tab_model/tab_model.h"
#include "chrome/browser/ui/android/tab_model/tab_model_list.h"
@@ -51,6 +58,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"
@@ -58,6 +66,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;
@@ -105,7 +117,11 @@ NotificationDatabaseData CreateDatabaseData(
PushMessagingNotificationManager::PushMessagingNotificationManager(
Profile* profile)
+#ifndef TOOLKIT_QT
: profile_(profile), budget_database_(profile) {}
+#else
+ : profile_(profile) {}
+#endif
PushMessagingNotificationManager::~PushMessagingNotificationManager() = default;
@@ -155,6 +171,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 defined(OS_ANDROID)
for (const TabModel* model : TabModelList::models()) {
@@ -171,6 +188,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.
@@ -185,12 +203,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;
}
@@ -269,8 +293,13 @@ void PushMessagingNotificationManager::ProcessSilentPush(
scoped_refptr<PlatformNotificationContext> 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 b2621f55c53..a8cdb50afcf 100644
--- a/chromium/chrome/browser/push_messaging/push_messaging_notification_manager.h
+++ b/chromium/chrome/browser/push_messaging/push_messaging_notification_manager.h
@@ -106,7 +106,9 @@ class PushMessagingNotificationManager {
// Weak. This manager is owned by a keyed service on this profile.
raw_ptr<Profile> profile_;
+#ifndef TOOLKIT_QT
BudgetDatabase budget_database_;
+#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
chromeos::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 2987c24efdf..8f82520d9dc 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/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/push_messaging/push_messaging_service_impl.h"
@@ -48,9 +52,11 @@ PushMessagingServiceFactory::PushMessagingServiceFactory()
BrowserContextDependencyManager::GetInstance()) {
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 6313d399760..6438b081d07 100644
--- a/chromium/chrome/browser/push_messaging/push_messaging_service_impl.cc
+++ b/chromium/chrome/browser/push_messaging/push_messaging_service_impl.cc
@@ -21,22 +21,32 @@
#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"
+#endif
#include "chrome/browser/chrome_notification_types.h"
+#ifndef TOOLKIT_QT
#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"
+#ifndef TOOLKIT_QT
#include "chrome/browser/permissions/abusive_origin_permission_revocation_request.h"
#include "chrome/browser/permissions/permission_manager_factory.h"
+#endif
#include "chrome/browser/profiles/profile.h"
+#ifndef TOOLKIT_QT
#include "chrome/browser/profiles/profile_keep_alive_types.h"
#include "chrome/browser/profiles/scoped_profile_keep_alive.h"
+#endif
#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"
@@ -81,6 +91,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";
@@ -262,7 +280,9 @@ PushMessagingServiceImpl::PushMessagingServiceImpl(Profile* profile)
pending_push_subscription_count_(0),
notification_manager_(profile) {
DCHECK(profile);
+#ifndef TOOLKIT_QT
HostContentSettingsMapFactory::GetForProfile(profile_)->AddObserver(this);
+#endif
registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING,
content::NotificationService::AllSources());
@@ -328,11 +348,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()) {
@@ -376,10 +398,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 origin verification only if no other verification is in
// progress.
if (!abusive_origin_revocation_request_)
CheckOriginForAbuseAndDispatchNextMessage();
+#else
+ DispatchNextMessage();
+#endif
} else {
// Drop message and unregister if origin has lost push permission.
DeliverMessageCallback(app_id, app_identifier.origin(),
@@ -389,6 +415,7 @@ void PushMessagingServiceImpl::OnMessage(const std::string& app_id,
}
}
+#ifndef TOOLKIT_QT
void PushMessagingServiceImpl::CheckOriginForAbuseAndDispatchNextMessage() {
if (messages_pending_permission_check_.empty())
return;
@@ -464,6 +491,43 @@ void PushMessagingServiceImpl::OnCheckedOriginForAbuse(
// Verify the next message in the queue.
CheckOriginForAbuseAndDispatchNextMessage();
}
+#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<PendingMessage>& 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(
@@ -781,6 +845,7 @@ void PushMessagingServiceImpl::SubscribeFromDocument(
}
// Push does not allow permission requests from iframes.
+#ifndef TOOLKIT_QT
PermissionManagerFactory::GetForProfile(profile_)->RequestPermission(
ContentSettingsType::NOTIFICATIONS, render_frame_host, requesting_origin,
user_gesture,
@@ -788,6 +853,20 @@ void PushMessagingServiceImpl::SubscribeFromDocument(
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()->RequestPermission(
+ content::PermissionType::NOTIFICATIONS, render_frame_host, requesting_origin,
+ 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(
@@ -823,7 +902,11 @@ void PushMessagingServiceImpl::SubscribeFromWorker(
DoSubscribe(std::move(app_identifier), std::move(options),
std::move(register_callback),
/* render_process_id= */ -1, /* render_frame_id= */ -1,
+#ifndef TOOLKIT_QT
CONTENT_SETTING_ALLOW);
+#else
+ blink::mojom::PermissionStatus::GRANTED);
+#endif
}
blink::mojom::PermissionStatus PushMessagingServiceImpl::GetPermissionStatus(
@@ -832,6 +915,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.
@@ -840,6 +924,11 @@ blink::mojom::PermissionStatus PushMessagingServiceImpl::GetPermissionStatus(
->GetPermissionStatus(ContentSettingsType::NOTIFICATIONS, origin,
origin)
.content_setting);
+#else
+ return profile_->GetPermissionControllerDelegate()
+ ->GetPermissionStatus(content::PermissionType::NOTIFICATIONS,
+ origin, origin);
+#endif
}
bool PushMessagingServiceImpl::SupportNonVisibleMessages() {
@@ -852,8 +941,13 @@ void PushMessagingServiceImpl::DoSubscribe(
RegisterCallback register_callback,
int render_process_id,
int render_frame_id,
+#ifndef TOOLKIT_QT
ContentSetting content_setting) {
if (content_setting != CONTENT_SETTING_ALLOW) {
+#else
+ blink::mojom::PermissionStatus permission_status) {
+ if (permission_status != blink::mojom::PermissionStatus::GRANTED) {
+#endif
SubscribeEndWithError(
std::move(register_callback),
blink::mojom::PushRegistrationStatus::PERMISSION_DENIED);
@@ -947,7 +1041,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
@@ -1022,7 +1120,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<base::Time> expiration_time = app_identifier.expiration_time();
@@ -1455,7 +1558,9 @@ void PushMessagingServiceImpl::SetContentSettingChangedCallbackForTesting(
void PushMessagingServiceImpl::Shutdown() {
GetGCMDriver()->RemoveAppHandler(kPushMessagingAppIdentifierPrefix);
+#ifndef TOOLKIT_QT
HostContentSettingsMapFactory::GetForProfile(profile_)->RemoveObserver(this);
+#endif
}
// content::NotificationObserver methods ---------------------------------------
@@ -1552,7 +1657,11 @@ void PushMessagingServiceImpl::UpdateSubscription(
// the expiration time of |app_identifier|
DoSubscribe(app_identifier, std::move(options), std::move(register_callback),
-1 /* render_process_id */, -1 /* render_frame_id */,
+#ifndef TOOLKIT_QT
CONTENT_SETTING_ALLOW);
+#else
+ blink::mojom::PermissionStatus::GRANTED);
+#endif
}
void PushMessagingServiceImpl::DidUpdateSubscription(
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 a99e6e578f4..6c3946293a8 100644
--- a/chromium/chrome/browser/push_messaging/push_messaging_service_impl.h
+++ b/chromium/chrome/browser/push_messaging/push_messaging_service_impl.h
@@ -19,7 +19,9 @@
#include "base/memory/weak_ptr.h"
#include "base/scoped_observation.h"
#include "base/time/time.h"
+#ifndef TOOLKIT_QT
#include "chrome/browser/permissions/abusive_origin_permission_revocation_request.h"
+#endif
#include "chrome/browser/push_messaging/push_messaging_notification_manager.h"
#include "chrome/browser/push_messaging/push_messaging_refresher.h"
#include "chrome/common/buildflags.h"
@@ -226,15 +228,21 @@ class PushMessagingServiceImpl : public content::PushMessagingService,
const std::string& push_message_id,
bool did_show_generic_notification);
+#ifndef TOOLKIT_QT
void OnCheckedOriginForAbuse(
PendingMessage message,
AbusiveOriginPermissionRevocationRequest::Outcome outcome);
+#endif
void DeliverNextQueuedMessageForServiceWorkerRegistration(
const GURL& origin,
int64_t service_worker_registration_id);
+#ifndef TOOLKIT_QT
void CheckOriginForAbuseAndDispatchNextMessage();
+#else
+ void DispatchNextMessage();
+#endif
// Subscribe methods ---------------------------------------------------------
@@ -243,7 +251,11 @@ class PushMessagingServiceImpl : public content::PushMessagingService,
RegisterCallback callback,
int render_process_id,
int render_frame_id,
+#ifndef TOOLKIT_QT
ContentSetting permission_status);
+#else
+ blink::mojom::PermissionStatus permission_status);
+#endif
void SubscribeEnd(RegisterCallback callback,
const std::string& subscription_id,
@@ -419,8 +431,10 @@ class PushMessagingServiceImpl : public content::PushMessagingService,
}
raw_ptr<Profile> profile_;
+#ifndef TOOLKIT_QT
std::unique_ptr<AbusiveOriginPermissionRevocationRequest>
abusive_origin_revocation_request_;
+#endif
std::queue<PendingMessage> 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 3a5ea106adb..74dcf207845 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 !defined(OS_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 {
@@ -131,9 +139,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(); }
@@ -157,21 +169,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(
@@ -181,7 +201,7 @@ void ChromeSigninClient::PreSignOut(
DCHECK(!on_signout_decision_reached_) << "SignOut already in-progress!";
on_signout_decision_reached_ = std::move(on_signout_decision_reached);
-#if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
+#if !defined(OS_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.
@@ -285,7 +305,11 @@ void ChromeSigninClient::VerifySyncToken() {
}
bool ChromeSigninClient::IsNonEnterpriseUser(const std::string& username) {
+#ifndef TOOLKIT_QT
return policy::BrowserPolicyConnector::IsNonEnterpriseUser(username);
+#else
+ return true;
+#endif
}
#if BUILDFLAG(IS_CHROMEOS_LACROS)
@@ -353,6 +377,7 @@ void ChromeSigninClient::OnCloseBrowsersAborted(
void ChromeSigninClient::LockForceSigninProfile(
const base::FilePath& profile_path) {
+#ifndef TOOLKIT_QT
ProfileAttributesEntry* entry =
g_browser_process->profile_manager()
->GetProfileAttributesStorage()
@@ -360,10 +385,11 @@ void ChromeSigninClient::LockForceSigninProfile(
if (!entry)
return;
entry->LockForceSigninProfile(true);
+#endif
}
void ChromeSigninClient::ShowUserManager(const base::FilePath& profile_path) {
-#if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
+#if !defined(OS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH) && !defined(TOOLKIT_QT)
ProfilePicker::Show(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 62c0d638cbd..41fdc87993e 100644
--- a/chromium/chrome/browser/signin/chrome_signin_client_factory.cc
+++ b/chromium/chrome/browser/signin/chrome_signin_client_factory.cc
@@ -4,7 +4,9 @@
#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"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
@@ -12,7 +14,9 @@ ChromeSigninClientFactory::ChromeSigninClientFactory()
: BrowserContextKeyedServiceFactory(
"ChromeSigninClient",
BrowserContextDependencyManager::GetInstance()) {
+#ifndef TOOLKIT_QT
DependsOn(ProfileNetworkContextServiceFactory::GetInstance());
+#endif
}
ChromeSigninClientFactory::~ChromeSigninClientFactory() {}
diff --git a/chromium/chrome/browser/signin/force_signin_verifier.cc b/chromium/chrome/browser/signin/force_signin_verifier.cc
index 951efcd003c..b9a36f8f28c 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 =
@@ -179,6 +186,7 @@ void ForceSigninVerifier::OnCloseBrowsersSuccess(
return;
entry->LockForceSigninProfile(true);
ProfilePicker::Show(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 cac771bf1e2..28a86cd0f77 100644
--- a/chromium/chrome/browser/signin/identity_manager_factory.cc
+++ b/chromium/chrome/browser/signin/identity_manager_factory.cc
@@ -10,8 +10,10 @@
#include "base/files/file_path.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)
+#if BUILDFLAG(ENABLE_DICE_SUPPORT) && !defined(TOOLKIT_QT)
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/web_data_service_factory.h"
#include "components/content_settings/core/browser/cookie_settings.h"
@@ -59,7 +61,7 @@ IdentityManagerFactory::IdentityManagerFactory()
: BrowserContextKeyedServiceFactory(
"IdentityManager",
BrowserContextDependencyManager::GetInstance()) {
-#if BUILDFLAG(ENABLE_DICE_SUPPORT)
+#if BUILDFLAG(ENABLE_DICE_SUPPORT) && !defined(TOOLKIT_QT)
DependsOn(WebDataServiceFactory::GetInstance());
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
@@ -115,21 +117,29 @@ 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<ImageDecoderImpl>();
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)
+#if !defined(TOOLKIT_QT)
params.delete_signin_cookies_on_exit =
signin::SettingsDeleteSigninCookiesOnExit(
CookieSettingsFactory::GetForProfile(profile).get());
params.token_web_data = WebDataServiceFactory::GetTokenWebDataForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS);
+#else
+ params.delete_signin_cookies_on_exit = true;
+#endif
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
diff --git a/chromium/chrome/browser/signin/signin_util.cc b/chromium/chrome/browser/signin/signin_util.cc
index d3ab11f8671..e1ffcfde5fd 100644
--- a/chromium/chrome/browser/signin/signin_util.cc
+++ b/chromium/chrome/browser/signin/signin_util.cc
@@ -17,15 +17,21 @@
#include "base/task/post_task.h"
#include "base/threading/thread_task_runner_handle.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/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/signin_features.h"
+#ifndef TOOLKIT_QT
#include "chrome/browser/ui/simple_message_box.h"
#include "chrome/browser/ui/startup/startup_types.h"
#include "chrome/browser/ui/webui/profile_helper.h"
+#endif
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
@@ -39,6 +45,7 @@
#include "google_apis/gaia/gaia_auth_util.h"
#include "ui/base/l10n/l10n_util.h"
+#ifndef TOOLKIT_QT
#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \
defined(OS_MAC)
#include "chrome/browser/ui/browser_finder.h"
@@ -47,6 +54,7 @@
#include "chrome/browser/ui/browser_window.h"
#define CAN_DELETE_PROFILE
#endif
+#endif // !TOOLKIT_QT
namespace signin_util {
namespace {
@@ -254,7 +262,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
@@ -293,7 +305,7 @@ void SetUserSignoutAllowedForProfile(Profile* profile, bool is_allowed) {
void EnsurePrimaryAccountAllowedForProfile(Profile* profile) {
// All primary accounts are allowed on ChromeOS, so this method is a no-op on
// ChromeOS.
-#if !BUILDFLAG(IS_CHROMEOS_ASH)
+#if !BUILDFLAG(IS_CHROMEOS_ASH) && !defined(TOOLKIT_QT)
auto* identity_manager = IdentityManagerFactory::GetForProfile(profile);
if (!identity_manager->HasPrimaryAccount(signin::ConsentLevel::kSync))
return;
@@ -342,7 +354,7 @@ void EnsurePrimaryAccountAllowedForProfile(Profile* profile) {
#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
}
-#if !defined(OS_ANDROID)
+#if !defined(OS_ANDROID) && !defined(TOOLKIT_QT)
bool ProfileSeparationEnforcedByPolicy(
Profile* profile,
const std::string& intercepted_account_level_policy_value) {