Commit e42c347c authored by Jesse Schettler's avatar Jesse Schettler Committed by Commit Bot

Use GetPrimaryUserProfile() when creating a CupsPrintJob

This ensures a profile is obtained even when outside a user window,
which resolves an issue that occurred when printing from ARC apps using
the ArcPrintService.

Bug: 1010228
Test: Print from an ARC app using an ArcPrintService printer
Change-Id: I4fa5759519aef11773045ff79612342583cf66e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1836984
Commit-Queue: Jesse Schettler <jschettler@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702461}
parent fbe25450
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/optional.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
...@@ -28,6 +29,7 @@ ...@@ -28,6 +29,7 @@
#include "chrome/browser/chromeos/printing/history/print_job_info_proto_conversions.h" #include "chrome/browser/chromeos/printing/history/print_job_info_proto_conversions.h"
#include "chrome/browser/printing/print_job.h" #include "chrome/browser/printing/print_job.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
...@@ -343,9 +345,20 @@ class CupsPrintJobManagerImpl : public CupsPrintJobManager, ...@@ -343,9 +345,20 @@ class CupsPrintJobManagerImpl : public CupsPrintJobManager,
const printing::proto::PrintSettings& settings) { const printing::proto::PrintSettings& settings) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
auto printer = Profile* profile = ProfileManager::GetPrimaryUserProfile();
CupsPrintersManagerFactory::GetForBrowserContext(profile_)->GetPrinter( if (!profile) {
printer_name); LOG(WARNING) << "Cannot find printer without a valid profile.";
return false;
}
auto* manager = CupsPrintersManagerFactory::GetForBrowserContext(profile);
if (!manager) {
LOG(WARNING)
<< "CupsPrintersManager could not be found for the current profile.";
return false;
}
base::Optional<Printer> printer = manager->GetPrinter(printer_name);
if (!printer) { if (!printer) {
LOG(WARNING) LOG(WARNING)
<< "Printer was removed while job was in progress. It cannot " << "Printer was removed while job was in progress. It cannot "
......
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