Commit eace69bd authored by Sean Kau's avatar Sean Kau Committed by Commit Bot

Prevent PrintJobHistoryService from being created on lock screen.

We do not need the PrintJobHistoryService on the lock screen to support
extensions.  If we create the PrintJobHistoryService on the lock screen,
it creates a CupsPrintJobManager which results in multiple notifications
for each print job.

Bug: chromium:1011532
Change-Id: I16399186031a334d3b98ceda5ec9ab22f23a7e77
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1842557Reviewed-by: default avatarBailey Berro <baileyberro@chromium.org>
Reviewed-by: default avatarNikita Podguzov <nikitapodguzov@chromium.org>
Commit-Queue: Sean Kau <skau@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704229}
parent 4a68af46
......@@ -26,9 +26,14 @@ PrintJobFinishedEventDispatcher::PrintJobFinishedEventDispatcher(
: browser_context_(browser_context),
event_router_(EventRouter::Get(browser_context)),
print_job_history_service_observer_(this) {
print_job_history_service_observer_.Add(
auto* history_service =
chromeos::PrintJobHistoryServiceFactory::GetForBrowserContext(
browser_context));
browser_context);
// The print job history service is not available on the lock screen.
if (history_service) {
print_job_history_service_observer_.Add(history_service);
}
}
PrintJobFinishedEventDispatcher::~PrintJobFinishedEventDispatcher() {}
......
......@@ -4,9 +4,13 @@
#include "chrome/browser/chromeos/printing/history/print_job_history_service_factory.h"
#include <memory>
#include <utility>
#include "chrome/browser/chromeos/printing/cups_print_job_manager_factory.h"
#include "chrome/browser/chromeos/printing/history/print_job_database_impl.h"
#include "chrome/browser/chromeos/printing/history/print_job_history_service_impl.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "content/public/browser/storage_partition.h"
......@@ -38,6 +42,13 @@ KeyedService* PrintJobHistoryServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Profile* profile = Profile::FromBrowserContext(context);
// We do not want an instance of PrintJobHistory on the lock screen. The
// result is multiple print job notifications. https://crbug.com/1011532
if (ProfileHelper::IsLockScreenAppProfile(profile) ||
ProfileHelper::IsSigninProfile(profile)) {
return nullptr;
}
leveldb_proto::ProtoDatabaseProvider* database_provider =
content::BrowserContext::GetDefaultStoragePartition(profile)
->GetProtoDatabaseProvider();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment