Commit 45339aec authored by Justin Carlson's avatar Justin Carlson Committed by Commit Bot

Rename PrintersManager to SyncedPrintersManager.

Also rename factory class.  This is in preparation for subsuming
some of this functionality into a higher level printers manager.

BUG=742487

Change-Id: I4929a4faa6bbdade248c9bdb710a3b53d8ebb262
Reviewed-on: https://chromium-review.googlesource.com/569849Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarSean Kau <skau@chromium.org>
Reviewed-by: default avatarSky Malice <skym@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarAnthony Vallee-Dubois <anthonyvd@chromium.org>
Commit-Queue: Justin Carlson <justincarlson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487292}
parent 946720eb
...@@ -1327,14 +1327,14 @@ source_set("chromeos") { ...@@ -1327,14 +1327,14 @@ source_set("chromeos") {
"printing/printer_configurer.h", "printing/printer_configurer.h",
"printing/printer_detector.h", "printing/printer_detector.h",
"printing/printer_info.h", "printing/printer_info.h",
"printing/printers_manager.cc",
"printing/printers_manager.h",
"printing/printers_manager_factory.cc",
"printing/printers_manager_factory.h",
"printing/printers_sync_bridge.cc", "printing/printers_sync_bridge.cc",
"printing/printers_sync_bridge.h", "printing/printers_sync_bridge.h",
"printing/specifics_translation.cc", "printing/specifics_translation.cc",
"printing/specifics_translation.h", "printing/specifics_translation.h",
"printing/synced_printers_manager.cc",
"printing/synced_printers_manager.h",
"printing/synced_printers_manager_factory.cc",
"printing/synced_printers_manager_factory.h",
"printing/usb_printer_detector.cc", "printing/usb_printer_detector.cc",
"printing/usb_printer_detector.h", "printing/usb_printer_detector.h",
"printing/usb_printer_detector_factory.cc", "printing/usb_printer_detector_factory.cc",
...@@ -1847,8 +1847,8 @@ source_set("unit_tests") { ...@@ -1847,8 +1847,8 @@ source_set("unit_tests") {
"power/renderer_freezer_unittest.cc", "power/renderer_freezer_unittest.cc",
"preferences_unittest.cc", "preferences_unittest.cc",
"printing/combining_printer_detector_unittest.cc", "printing/combining_printer_detector_unittest.cc",
"printing/printers_manager_unittest.cc",
"printing/specifics_translation_unittest.cc", "printing/specifics_translation_unittest.cc",
"printing/synced_printers_manager_unittest.cc",
"profiles/profile_list_chromeos_unittest.cc", "profiles/profile_list_chromeos_unittest.cc",
"proxy_config_service_impl_unittest.cc", "proxy_config_service_impl_unittest.cc",
"resource_reporter/resource_reporter_unittest.cc", "resource_reporter/resource_reporter_unittest.cc",
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "chrome/browser/chromeos/printing/cups_print_job_manager_factory.h" #include "chrome/browser/chromeos/printing/cups_print_job_manager_factory.h"
#include "chrome/browser/chromeos/printing/cups_print_job_manager.h" #include "chrome/browser/chromeos/printing/cups_print_job_manager.h"
#include "chrome/browser/chromeos/printing/printers_manager_factory.h" #include "chrome/browser/chromeos/printing/synced_printers_manager_factory.h"
#include "chrome/browser/profiles/incognito_helpers.h" #include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/content/browser_context_dependency_manager.h"
...@@ -39,7 +39,7 @@ CupsPrintJobManagerFactory::CupsPrintJobManagerFactory() ...@@ -39,7 +39,7 @@ CupsPrintJobManagerFactory::CupsPrintJobManagerFactory()
: BrowserContextKeyedServiceFactory( : BrowserContextKeyedServiceFactory(
"CupsPrintJobManagerFactory", "CupsPrintJobManagerFactory",
BrowserContextDependencyManager::GetInstance()) { BrowserContextDependencyManager::GetInstance()) {
DependsOn(chromeos::PrintersManagerFactory::GetInstance()); DependsOn(chromeos::SyncedPrintersManagerFactory::GetInstance());
} }
CupsPrintJobManagerFactory::~CupsPrintJobManagerFactory() {} CupsPrintJobManagerFactory::~CupsPrintJobManagerFactory() {}
......
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/printing/cups_print_job.h" #include "chrome/browser/chromeos/printing/cups_print_job.h"
#include "chrome/browser/chromeos/printing/printers_manager.h" #include "chrome/browser/chromeos/printing/synced_printers_manager.h"
#include "chrome/browser/chromeos/printing/printers_manager_factory.h" #include "chrome/browser/chromeos/printing/synced_printers_manager_factory.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 "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
...@@ -336,9 +336,8 @@ class CupsPrintJobManagerImpl : public CupsPrintJobManager, ...@@ -336,9 +336,8 @@ class CupsPrintJobManagerImpl : public CupsPrintJobManager,
int total_page_number) { int total_page_number) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
auto printer = auto printer = SyncedPrintersManagerFactory::GetForBrowserContext(profile_)
PrintersManagerFactory::GetForBrowserContext(profile_)->GetPrinter( ->GetPrinter(printer_name);
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 "
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/chromeos/printing/printers_manager.h" #include "chrome/browser/chromeos/printing/synced_printers_manager.h"
#include <memory> #include <memory>
#include <string> #include <string>
...@@ -51,29 +51,30 @@ bool UpdatePrinterPref(PrintersSyncBridge* sync_bridge, ...@@ -51,29 +51,30 @@ bool UpdatePrinterPref(PrintersSyncBridge* sync_bridge,
} // anonymous namespace } // anonymous namespace
PrintersManager::PrintersManager( SyncedPrintersManager::SyncedPrintersManager(
Profile* profile, Profile* profile,
std::unique_ptr<PrintersSyncBridge> sync_bridge) std::unique_ptr<PrintersSyncBridge> sync_bridge)
: profile_(profile), sync_bridge_(std::move(sync_bridge)) { : profile_(profile), sync_bridge_(std::move(sync_bridge)) {
pref_change_registrar_.Init(profile->GetPrefs()); pref_change_registrar_.Init(profile->GetPrefs());
pref_change_registrar_.Add( pref_change_registrar_.Add(
prefs::kRecommendedNativePrinters, prefs::kRecommendedNativePrinters,
base::Bind(&PrintersManager::UpdateRecommendedPrinters, base::Bind(&SyncedPrintersManager::UpdateRecommendedPrinters,
base::Unretained(this))); base::Unretained(this)));
UpdateRecommendedPrinters(); UpdateRecommendedPrinters();
} }
PrintersManager::~PrintersManager() {} SyncedPrintersManager::~SyncedPrintersManager() {}
// static // static
void PrintersManager::RegisterProfilePrefs( void SyncedPrintersManager::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) { user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterListPref(prefs::kPrintingDevices, registry->RegisterListPref(prefs::kPrintingDevices,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterListPref(prefs::kRecommendedNativePrinters); registry->RegisterListPref(prefs::kRecommendedNativePrinters);
} }
std::vector<std::unique_ptr<Printer>> PrintersManager::GetPrinters() const { std::vector<std::unique_ptr<Printer>> SyncedPrintersManager::GetPrinters()
const {
std::vector<std::unique_ptr<Printer>> printers; std::vector<std::unique_ptr<Printer>> printers;
std::vector<sync_pb::PrinterSpecifics> values = std::vector<sync_pb::PrinterSpecifics> values =
...@@ -85,8 +86,8 @@ std::vector<std::unique_ptr<Printer>> PrintersManager::GetPrinters() const { ...@@ -85,8 +86,8 @@ std::vector<std::unique_ptr<Printer>> PrintersManager::GetPrinters() const {
return printers; return printers;
} }
std::vector<std::unique_ptr<Printer>> PrintersManager::GetRecommendedPrinters() std::vector<std::unique_ptr<Printer>>
const { SyncedPrintersManager::GetRecommendedPrinters() const {
std::vector<std::unique_ptr<Printer>> printers; std::vector<std::unique_ptr<Printer>> printers;
for (const std::string& key : recommended_printer_ids_) { for (const std::string& key : recommended_printer_ids_) {
...@@ -99,7 +100,7 @@ std::vector<std::unique_ptr<Printer>> PrintersManager::GetRecommendedPrinters() ...@@ -99,7 +100,7 @@ std::vector<std::unique_ptr<Printer>> PrintersManager::GetRecommendedPrinters()
return printers; return printers;
} }
std::unique_ptr<Printer> PrintersManager::GetPrinter( std::unique_ptr<Printer> SyncedPrintersManager::GetPrinter(
const std::string& printer_id) const { const std::string& printer_id) const {
// check for a policy printer first // check for a policy printer first
const auto& policy_printers = recommended_printers_; const auto& policy_printers = recommended_printers_;
...@@ -114,7 +115,7 @@ std::unique_ptr<Printer> PrintersManager::GetPrinter( ...@@ -114,7 +115,7 @@ std::unique_ptr<Printer> PrintersManager::GetPrinter(
return printer.has_value() ? printing::SpecificsToPrinter(*printer) : nullptr; return printer.has_value() ? printing::SpecificsToPrinter(*printer) : nullptr;
} }
void PrintersManager::RegisterPrinter(std::unique_ptr<Printer> printer) { void SyncedPrintersManager::RegisterPrinter(std::unique_ptr<Printer> printer) {
if (printer->id().empty()) { if (printer->id().empty()) {
printer->set_id(base::GenerateGUID()); printer->set_id(base::GenerateGUID());
} }
...@@ -134,7 +135,7 @@ void PrintersManager::RegisterPrinter(std::unique_ptr<Printer> printer) { ...@@ -134,7 +135,7 @@ void PrintersManager::RegisterPrinter(std::unique_ptr<Printer> printer) {
} }
} }
bool PrintersManager::RemovePrinter(const std::string& printer_id) { bool SyncedPrintersManager::RemovePrinter(const std::string& printer_id) {
DCHECK(!printer_id.empty()); DCHECK(!printer_id.empty());
base::Optional<sync_pb::PrinterSpecifics> printer = base::Optional<sync_pb::PrinterSpecifics> printer =
...@@ -155,21 +156,21 @@ bool PrintersManager::RemovePrinter(const std::string& printer_id) { ...@@ -155,21 +156,21 @@ bool PrintersManager::RemovePrinter(const std::string& printer_id) {
return success; return success;
} }
void PrintersManager::AddObserver(Observer* observer) { void SyncedPrintersManager::AddObserver(Observer* observer) {
observers_.AddObserver(observer); observers_.AddObserver(observer);
} }
void PrintersManager::RemoveObserver(Observer* observer) { void SyncedPrintersManager::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer); observers_.RemoveObserver(observer);
} }
PrintersSyncBridge* PrintersManager::GetSyncBridge() { PrintersSyncBridge* SyncedPrintersManager::GetSyncBridge() {
return sync_bridge_.get(); return sync_bridge_.get();
} }
// This method is not thread safe and could interact poorly with readers of // This method is not thread safe and could interact poorly with readers of
// |recommended_printers_|. // |recommended_printers_|.
void PrintersManager::UpdateRecommendedPrinters() { void SyncedPrintersManager::UpdateRecommendedPrinters() {
const PrefService* prefs = profile_->GetPrefs(); const PrefService* prefs = profile_->GetPrefs();
const base::ListValue* values = const base::ListValue* values =
...@@ -227,12 +228,13 @@ void PrintersManager::UpdateRecommendedPrinters() { ...@@ -227,12 +228,13 @@ void PrintersManager::UpdateRecommendedPrinters() {
recommended_printers_.swap(new_printers); recommended_printers_.swap(new_printers);
} }
void PrintersManager::PrinterInstalled(const Printer& printer) { void SyncedPrintersManager::PrinterInstalled(const Printer& printer) {
DCHECK(!printer.last_updated().is_null()); DCHECK(!printer.last_updated().is_null());
installed_printer_timestamps_[printer.id()] = printer.last_updated(); installed_printer_timestamps_[printer.id()] = printer.last_updated();
} }
bool PrintersManager::IsConfigurationCurrent(const Printer& printer) const { bool SyncedPrintersManager::IsConfigurationCurrent(
const Printer& printer) const {
auto found = installed_printer_timestamps_.find(printer.id()); auto found = installed_printer_timestamps_.find(printer.id());
if (found == installed_printer_timestamps_.end()) if (found == installed_printer_timestamps_.end())
return false; return false;
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_PRINTING_PRINTERS_MANAGER_H_ #ifndef CHROME_BROWSER_CHROMEOS_PRINTING_SYNCED_PRINTERS_MANAGER_H_
#define CHROME_BROWSER_CHROMEOS_PRINTING_PRINTERS_MANAGER_H_ #define CHROME_BROWSER_CHROMEOS_PRINTING_SYNCED_PRINTERS_MANAGER_H_
#include <map> #include <map>
#include <memory> #include <memory>
...@@ -26,10 +26,11 @@ class PrefRegistrySyncable; ...@@ -26,10 +26,11 @@ class PrefRegistrySyncable;
namespace chromeos { namespace chromeos {
// Manages printer information. Provides an interface to a user's printers and // Manages information about synced local printers classes (CONFIGURED
// and ENTERPRISE). Provides an interface to a user's printers and
// printers provided by policy. User printers are backed by the // printers provided by policy. User printers are backed by the
// PrintersSyncBridge. // PrintersSyncBridge.
class PrintersManager : public KeyedService { class SyncedPrintersManager : public KeyedService {
public: public:
class Observer { class Observer {
public: public:
...@@ -38,9 +39,9 @@ class PrintersManager : public KeyedService { ...@@ -38,9 +39,9 @@ class PrintersManager : public KeyedService {
virtual void OnPrinterRemoved(const Printer& printer) = 0; virtual void OnPrinterRemoved(const Printer& printer) = 0;
}; };
PrintersManager(Profile* profile, SyncedPrintersManager(Profile* profile,
std::unique_ptr<PrintersSyncBridge> sync_bridge); std::unique_ptr<PrintersSyncBridge> sync_bridge);
~PrintersManager() override; ~SyncedPrintersManager() override;
// Register the printing preferences with the |registry|. // Register the printing preferences with the |registry|.
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
...@@ -68,11 +69,11 @@ class PrintersManager : public KeyedService { ...@@ -68,11 +69,11 @@ class PrintersManager : public KeyedService {
// live on the same thread (UI) as this object. OnPrinter* methods are // live on the same thread (UI) as this object. OnPrinter* methods are
// invoked inline so calling RegisterPrinter in response to OnPrinterAdded is // invoked inline so calling RegisterPrinter in response to OnPrinterAdded is
// forbidden. // forbidden.
void AddObserver(PrintersManager::Observer* observer); void AddObserver(SyncedPrintersManager::Observer* observer);
// Remove |observer| so that it no longer receives notifications. After the // Remove |observer| so that it no longer receives notifications. After the
// completion of this method, the |observer| can be safely destroyed. // completion of this method, the |observer| can be safely destroyed.
void RemoveObserver(PrintersManager::Observer* observer); void RemoveObserver(SyncedPrintersManager::Observer* observer);
// Returns a ModelTypeSyncBridge for the sync client. // Returns a ModelTypeSyncBridge for the sync client.
PrintersSyncBridge* GetSyncBridge(); PrintersSyncBridge* GetSyncBridge();
...@@ -104,9 +105,9 @@ class PrintersManager : public KeyedService { ...@@ -104,9 +105,9 @@ class PrintersManager : public KeyedService {
base::ObserverList<Observer> observers_; base::ObserverList<Observer> observers_;
DISALLOW_COPY_AND_ASSIGN(PrintersManager); DISALLOW_COPY_AND_ASSIGN(SyncedPrintersManager);
}; };
} // namespace chromeos } // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_PRINTING_PRINTERS_MANAGER_H_ #endif // CHROME_BROWSER_CHROMEOS_PRINTING_SYNCED_PRINTERS_MANAGER_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/chromeos/printing/printers_manager_factory.h" #include "chrome/browser/chromeos/printing/synced_printers_manager_factory.h"
#include <memory> #include <memory>
#include <utility> #include <utility>
...@@ -22,36 +22,36 @@ namespace chromeos { ...@@ -22,36 +22,36 @@ namespace chromeos {
namespace { namespace {
base::LazyInstance<PrintersManagerFactory>::DestructorAtExit base::LazyInstance<SyncedPrintersManagerFactory>::DestructorAtExit
g_printers_manager = LAZY_INSTANCE_INITIALIZER; g_printers_manager = LAZY_INSTANCE_INITIALIZER;
} // namespace } // namespace
// static // static
PrintersManager* PrintersManagerFactory::GetForBrowserContext( SyncedPrintersManager* SyncedPrintersManagerFactory::GetForBrowserContext(
content::BrowserContext* context) { content::BrowserContext* context) {
return static_cast<PrintersManager*>( return static_cast<SyncedPrintersManager*>(
GetInstance()->GetServiceForBrowserContext(context, true)); GetInstance()->GetServiceForBrowserContext(context, true));
} }
// static // static
PrintersManagerFactory* PrintersManagerFactory::GetInstance() { SyncedPrintersManagerFactory* SyncedPrintersManagerFactory::GetInstance() {
return g_printers_manager.Pointer(); return g_printers_manager.Pointer();
} }
content::BrowserContext* PrintersManagerFactory::GetBrowserContextToUse( content::BrowserContext* SyncedPrintersManagerFactory::GetBrowserContextToUse(
content::BrowserContext* context) const { content::BrowserContext* context) const {
return chrome::GetBrowserContextRedirectedInIncognito(context); return chrome::GetBrowserContextRedirectedInIncognito(context);
} }
PrintersManagerFactory::PrintersManagerFactory() SyncedPrintersManagerFactory::SyncedPrintersManagerFactory()
: BrowserContextKeyedServiceFactory( : BrowserContextKeyedServiceFactory(
"PrintersManager", "SyncedPrintersManager",
BrowserContextDependencyManager::GetInstance()) {} BrowserContextDependencyManager::GetInstance()) {}
PrintersManagerFactory::~PrintersManagerFactory() {} SyncedPrintersManagerFactory::~SyncedPrintersManagerFactory() {}
PrintersManager* PrintersManagerFactory::BuildServiceInstanceFor( SyncedPrintersManager* SyncedPrintersManagerFactory::BuildServiceInstanceFor(
content::BrowserContext* browser_context) const { content::BrowserContext* browser_context) const {
Profile* profile = Profile::FromBrowserContext(browser_context); Profile* profile = Profile::FromBrowserContext(browser_context);
...@@ -61,11 +61,10 @@ PrintersManager* PrintersManagerFactory::BuildServiceInstanceFor( ...@@ -61,11 +61,10 @@ PrintersManager* PrintersManagerFactory::BuildServiceInstanceFor(
std::unique_ptr<PrintersSyncBridge> sync_bridge = std::unique_ptr<PrintersSyncBridge> sync_bridge =
base::MakeUnique<PrintersSyncBridge>( base::MakeUnique<PrintersSyncBridge>(
store_factory, store_factory, base::BindRepeating(base::IgnoreResult(
base::BindRepeating( &base::debug::DumpWithoutCrashing)));
base::IgnoreResult(&base::debug::DumpWithoutCrashing)));
return new PrintersManager(profile, std::move(sync_bridge)); return new SyncedPrintersManager(profile, std::move(sync_bridge));
} }
} // namespace chromeos } // namespace chromeos
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_PRINTING_PRINTERS_MANAGER_FACTORY_H_ #ifndef CHROME_BROWSER_CHROMEOS_PRINTING_SYNCED_PRINTERS_MANAGER_FACTORY_H_
#define CHROME_BROWSER_CHROMEOS_PRINTING_PRINTERS_MANAGER_FACTORY_H_ #define CHROME_BROWSER_CHROMEOS_PRINTING_SYNCED_PRINTERS_MANAGER_FACTORY_H_
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/chromeos/printing/printers_manager.h" #include "chrome/browser/chromeos/printing/synced_printers_manager.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h" #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
namespace content { namespace content {
...@@ -16,30 +16,30 @@ class BrowserContext; ...@@ -16,30 +16,30 @@ class BrowserContext;
namespace chromeos { namespace chromeos {
class PrintersManagerFactory : public BrowserContextKeyedServiceFactory { class SyncedPrintersManagerFactory : public BrowserContextKeyedServiceFactory {
public: public:
static PrintersManager* GetForBrowserContext( static SyncedPrintersManager* GetForBrowserContext(
content::BrowserContext* context); content::BrowserContext* context);
static PrintersManagerFactory* GetInstance(); static SyncedPrintersManagerFactory* GetInstance();
protected: protected:
content::BrowserContext* GetBrowserContextToUse( content::BrowserContext* GetBrowserContextToUse(
content::BrowserContext* context) const override; content::BrowserContext* context) const override;
private: private:
friend struct base::LazyInstanceTraitsBase<PrintersManagerFactory>; friend struct base::LazyInstanceTraitsBase<SyncedPrintersManagerFactory>;
PrintersManagerFactory(); SyncedPrintersManagerFactory();
~PrintersManagerFactory() override; ~SyncedPrintersManagerFactory() override;
// BrowserContextKeyedServiceFactory implementation: // BrowserContextKeyedServiceFactory implementation:
PrintersManager* BuildServiceInstanceFor( SyncedPrintersManager* BuildServiceInstanceFor(
content::BrowserContext* browser_context) const override; content::BrowserContext* browser_context) const override;
DISALLOW_COPY_AND_ASSIGN(PrintersManagerFactory); DISALLOW_COPY_AND_ASSIGN(SyncedPrintersManagerFactory);
}; };
} // namespace chromeos } // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_PRINTING_PRINTERS_MANAGER_FACTORY_H_ #endif // CHROME_BROWSER_CHROMEOS_PRINTING_SYNCED_PRINTERS_MANAGER_FACTORY_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/chromeos/printing/printers_manager.h" #include "chrome/browser/chromeos/printing/synced_printers_manager.h"
#include <memory> #include <memory>
#include <utility> #include <utility>
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
#include "base/optional.h" #include "base/optional.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/chromeos/printing/printers_manager_factory.h"
#include "chrome/browser/chromeos/printing/printers_sync_bridge.h" #include "chrome/browser/chromeos/printing/printers_sync_bridge.h"
#include "chrome/browser/chromeos/printing/synced_printers_manager_factory.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "components/sync/model/fake_model_type_change_processor.h" #include "components/sync/model/fake_model_type_change_processor.h"
...@@ -43,7 +43,7 @@ const char kLexJson[] = R"json({ ...@@ -43,7 +43,7 @@ const char kLexJson[] = R"json({
} )json"; } )json";
// Helper class to record observed events. // Helper class to record observed events.
class LoggingObserver : public PrintersManager::Observer { class LoggingObserver : public SyncedPrintersManager::Observer {
public: public:
void OnPrinterAdded(const Printer& printer) override { void OnPrinterAdded(const Printer& printer) override {
last_added_ = printer; last_added_ = printer;
...@@ -84,9 +84,9 @@ class LoggingObserver : public PrintersManager::Observer { ...@@ -84,9 +84,9 @@ class LoggingObserver : public PrintersManager::Observer {
} // namespace } // namespace
class PrintersManagerTest : public testing::Test { class SyncedPrintersManagerTest : public testing::Test {
protected: protected:
PrintersManagerTest() SyncedPrintersManagerTest()
: manager_( : manager_(
&profile_, &profile_,
base::MakeUnique<PrintersSyncBridge>( base::MakeUnique<PrintersSyncBridge>(
...@@ -103,10 +103,10 @@ class PrintersManagerTest : public testing::Test { ...@@ -103,10 +103,10 @@ class PrintersManagerTest : public testing::Test {
// Must outlive |manager_|. // Must outlive |manager_|.
TestingProfile profile_; TestingProfile profile_;
PrintersManager manager_; SyncedPrintersManager manager_;
}; };
TEST_F(PrintersManagerTest, AddPrinter) { TEST_F(SyncedPrintersManagerTest, AddPrinter) {
LoggingObserver observer; LoggingObserver observer;
manager_.AddObserver(&observer); manager_.AddObserver(&observer);
manager_.RegisterPrinter(base::MakeUnique<Printer>(kPrinterId)); manager_.RegisterPrinter(base::MakeUnique<Printer>(kPrinterId));
...@@ -120,7 +120,7 @@ TEST_F(PrintersManagerTest, AddPrinter) { ...@@ -120,7 +120,7 @@ TEST_F(PrintersManagerTest, AddPrinter) {
EXPECT_FALSE(observer.UpdateCalled()); EXPECT_FALSE(observer.UpdateCalled());
} }
TEST_F(PrintersManagerTest, UpdatePrinterAssignsId) { TEST_F(SyncedPrintersManagerTest, UpdatePrinterAssignsId) {
manager_.RegisterPrinter(base::MakeUnique<Printer>()); manager_.RegisterPrinter(base::MakeUnique<Printer>());
auto printers = manager_.GetPrinters(); auto printers = manager_.GetPrinters();
...@@ -128,7 +128,7 @@ TEST_F(PrintersManagerTest, UpdatePrinterAssignsId) { ...@@ -128,7 +128,7 @@ TEST_F(PrintersManagerTest, UpdatePrinterAssignsId) {
EXPECT_FALSE(printers[0]->id().empty()); EXPECT_FALSE(printers[0]->id().empty());
} }
TEST_F(PrintersManagerTest, UpdatePrinter) { TEST_F(SyncedPrintersManagerTest, UpdatePrinter) {
manager_.RegisterPrinter(base::MakeUnique<Printer>(kPrinterId)); manager_.RegisterPrinter(base::MakeUnique<Printer>(kPrinterId));
auto updated_printer = base::MakeUnique<Printer>(kPrinterId); auto updated_printer = base::MakeUnique<Printer>(kPrinterId);
updated_printer->set_uri(kUri); updated_printer->set_uri(kUri);
...@@ -147,7 +147,7 @@ TEST_F(PrintersManagerTest, UpdatePrinter) { ...@@ -147,7 +147,7 @@ TEST_F(PrintersManagerTest, UpdatePrinter) {
EXPECT_FALSE(observer.AddCalled()); EXPECT_FALSE(observer.AddCalled());
} }
TEST_F(PrintersManagerTest, RemovePrinter) { TEST_F(SyncedPrintersManagerTest, RemovePrinter) {
manager_.RegisterPrinter(base::MakeUnique<Printer>("OtherUUID")); manager_.RegisterPrinter(base::MakeUnique<Printer>("OtherUUID"));
manager_.RegisterPrinter(base::MakeUnique<Printer>(kPrinterId)); manager_.RegisterPrinter(base::MakeUnique<Printer>(kPrinterId));
manager_.RegisterPrinter(base::MakeUnique<Printer>()); manager_.RegisterPrinter(base::MakeUnique<Printer>());
...@@ -162,7 +162,7 @@ TEST_F(PrintersManagerTest, RemovePrinter) { ...@@ -162,7 +162,7 @@ TEST_F(PrintersManagerTest, RemovePrinter) {
// Tests for policy printers // Tests for policy printers
TEST_F(PrintersManagerTest, RecommendedPrinters) { TEST_F(SyncedPrintersManagerTest, RecommendedPrinters) {
std::string first_printer = std::string first_printer =
R"json({ R"json({
"display_name": "Color Laser", "display_name": "Color Laser",
...@@ -195,7 +195,7 @@ TEST_F(PrintersManagerTest, RecommendedPrinters) { ...@@ -195,7 +195,7 @@ TEST_F(PrintersManagerTest, RecommendedPrinters) {
EXPECT_EQ(Printer::Source::SRC_POLICY, printers[1]->source()); EXPECT_EQ(Printer::Source::SRC_POLICY, printers[1]->source());
} }
TEST_F(PrintersManagerTest, GetRecommendedPrinter) { TEST_F(SyncedPrintersManagerTest, GetRecommendedPrinter) {
std::string printer = kLexJson; std::string printer = kLexJson;
auto value = base::MakeUnique<base::ListValue>(); auto value = base::MakeUnique<base::ListValue>();
value->AppendString(printer); value->AppendString(printer);
...@@ -215,18 +215,18 @@ TEST_F(PrintersManagerTest, GetRecommendedPrinter) { ...@@ -215,18 +215,18 @@ TEST_F(PrintersManagerTest, GetRecommendedPrinter) {
EXPECT_EQ(Printer::Source::SRC_POLICY, from_list.source()); EXPECT_EQ(Printer::Source::SRC_POLICY, from_list.source());
} }
TEST_F(PrintersManagerTest, PrinterNotInstalled) { TEST_F(SyncedPrintersManagerTest, PrinterNotInstalled) {
Printer printer(kPrinterId, base::Time::FromInternalValue(1000)); Printer printer(kPrinterId, base::Time::FromInternalValue(1000));
EXPECT_FALSE(manager_.IsConfigurationCurrent(printer)); EXPECT_FALSE(manager_.IsConfigurationCurrent(printer));
} }
TEST_F(PrintersManagerTest, PrinterIsInstalled) { TEST_F(SyncedPrintersManagerTest, PrinterIsInstalled) {
Printer printer(kPrinterId, base::Time::FromInternalValue(1000)); Printer printer(kPrinterId, base::Time::FromInternalValue(1000));
manager_.PrinterInstalled(printer); manager_.PrinterInstalled(printer);
EXPECT_TRUE(manager_.IsConfigurationCurrent(printer)); EXPECT_TRUE(manager_.IsConfigurationCurrent(printer));
} }
TEST_F(PrintersManagerTest, UpdatedPrinterConfiguration) { TEST_F(SyncedPrintersManagerTest, UpdatedPrinterConfiguration) {
Printer printer(kPrinterId, base::Time::FromInternalValue(1000)); Printer printer(kPrinterId, base::Time::FromInternalValue(1000));
manager_.PrinterInstalled(printer); manager_.PrinterInstalled(printer);
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/printing/ppd_provider_factory.h" #include "chrome/browser/chromeos/printing/ppd_provider_factory.h"
#include "chrome/browser/chromeos/printing/printer_configurer.h" #include "chrome/browser/chromeos/printing/printer_configurer.h"
#include "chrome/browser/chromeos/printing/printers_manager_factory.h" #include "chrome/browser/chromeos/printing/synced_printers_manager_factory.h"
#include "chrome/browser/chromeos/printing/usb_printer_detector.h" #include "chrome/browser/chromeos/printing/usb_printer_detector.h"
#include "chrome/browser/chromeos/printing/usb_printer_util.h" #include "chrome/browser/chromeos/printing/usb_printer_util.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/chromeos/profiles/profile_helper.h"
...@@ -195,8 +195,8 @@ class UsbPrinterDetectorImpl : public UsbPrinterDetector, ...@@ -195,8 +195,8 @@ class UsbPrinterDetectorImpl : public UsbPrinterDetector,
// one for the one we generated automatically and skip the parts where we // one for the one we generated automatically and skip the parts where we
// try to automagically figure out the driver. // try to automagically figure out the driver.
std::unique_ptr<Printer> existing_printer_configuration = std::unique_ptr<Printer> existing_printer_configuration =
PrintersManagerFactory::GetForBrowserContext(profile_)->GetPrinter( SyncedPrintersManagerFactory::GetForBrowserContext(profile_)
data->printer->id()); ->GetPrinter(data->printer->id());
if (existing_printer_configuration != nullptr) { if (existing_printer_configuration != nullptr) {
data->is_new = false; data->is_new = false;
data->printer = std::move(existing_printer_configuration); data->printer = std::move(existing_printer_configuration);
...@@ -267,8 +267,8 @@ class UsbPrinterDetectorImpl : public UsbPrinterDetector, ...@@ -267,8 +267,8 @@ class UsbPrinterDetectorImpl : public UsbPrinterDetector,
// We aren't done with data->printer yet, so we have to copy it instead // We aren't done with data->printer yet, so we have to copy it instead
// of moving it. // of moving it.
auto printer_copy = base::MakeUnique<Printer>(*data->printer); auto printer_copy = base::MakeUnique<Printer>(*data->printer);
PrintersManagerFactory::GetForBrowserContext(profile_)->RegisterPrinter( SyncedPrintersManagerFactory::GetForBrowserContext(profile_)
std::move(printer_copy)); ->RegisterPrinter(std::move(printer_copy));
} }
// TODO(justincarlson): If the device was hotplugged, pop a timed // TODO(justincarlson): If the device was hotplugged, pop a timed
// notification that says the printer is now available for printing. // notification that says the printer is now available for printing.
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "chrome/browser/chromeos/printing/usb_printer_detector_factory.h" #include "chrome/browser/chromeos/printing/usb_printer_detector_factory.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "chrome/browser/chromeos/printing/printers_manager_factory.h" #include "chrome/browser/chromeos/printing/synced_printers_manager_factory.h"
#include "chrome/browser/chromeos/printing/usb_printer_detector.h" #include "chrome/browser/chromeos/printing/usb_printer_detector.h"
#include "chrome/browser/profiles/incognito_helpers.h" #include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
...@@ -39,7 +39,7 @@ UsbPrinterDetectorFactory::UsbPrinterDetectorFactory() ...@@ -39,7 +39,7 @@ UsbPrinterDetectorFactory::UsbPrinterDetectorFactory()
BrowserContextDependencyManager::GetInstance()) { BrowserContextDependencyManager::GetInstance()) {
DependsOn( DependsOn(
extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
DependsOn(PrintersManagerFactory::GetInstance()); DependsOn(SyncedPrintersManagerFactory::GetInstance());
} }
UsbPrinterDetectorFactory::~UsbPrinterDetectorFactory() {} UsbPrinterDetectorFactory::~UsbPrinterDetectorFactory() {}
......
...@@ -218,7 +218,7 @@ ...@@ -218,7 +218,7 @@
#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
#include "chrome/browser/chromeos/power/power_prefs.h" #include "chrome/browser/chromeos/power/power_prefs.h"
#include "chrome/browser/chromeos/preferences.h" #include "chrome/browser/chromeos/preferences.h"
#include "chrome/browser/chromeos/printing/printers_manager.h" #include "chrome/browser/chromeos/printing/synced_printers_manager.h"
#include "chrome/browser/chromeos/resource_reporter/resource_reporter.h" #include "chrome/browser/chromeos/resource_reporter/resource_reporter.h"
#include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
#include "chrome/browser/chromeos/settings/device_settings_cache.h" #include "chrome/browser/chromeos/settings/device_settings_cache.h"
...@@ -592,7 +592,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { ...@@ -592,7 +592,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
chromeos::quick_unlock::FingerprintStorage::RegisterProfilePrefs(registry); chromeos::quick_unlock::FingerprintStorage::RegisterProfilePrefs(registry);
chromeos::quick_unlock::PinStorage::RegisterProfilePrefs(registry); chromeos::quick_unlock::PinStorage::RegisterProfilePrefs(registry);
chromeos::Preferences::RegisterProfilePrefs(registry); chromeos::Preferences::RegisterProfilePrefs(registry);
chromeos::PrintersManager::RegisterProfilePrefs(registry); chromeos::SyncedPrintersManager::RegisterProfilePrefs(registry);
chromeos::quick_unlock::RegisterProfilePrefs(registry); chromeos::quick_unlock::RegisterProfilePrefs(registry);
chromeos::SAMLOfflineSigninLimiter::RegisterProfilePrefs(registry); chromeos::SAMLOfflineSigninLimiter::RegisterProfilePrefs(registry);
chromeos::ServicesCustomizationDocument::RegisterProfilePrefs(registry); chromeos::ServicesCustomizationDocument::RegisterProfilePrefs(registry);
......
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/printing/cups_print_job_manager_factory.h" #include "chrome/browser/chromeos/printing/cups_print_job_manager_factory.h"
#include "chrome/browser/chromeos/printing/printers_manager_factory.h" #include "chrome/browser/chromeos/printing/synced_printers_manager_factory.h"
#include "chrome/browser/chromeos/printing/usb_printer_detector_factory.h" #include "chrome/browser/chromeos/printing/usb_printer_detector_factory.h"
#include "chrome/browser/chromeos/tether/tether_service_factory.h" #include "chrome/browser/chromeos/tether/tether_service_factory.h"
#include "chrome/browser/extensions/api/platform_keys/verify_trust_api.h" #include "chrome/browser/extensions/api/platform_keys/verify_trust_api.h"
...@@ -233,7 +233,7 @@ EnsureBrowserContextKeyedServiceFactoriesBuilt() { ...@@ -233,7 +233,7 @@ EnsureBrowserContextKeyedServiceFactoriesBuilt() {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
chromeos::UsbPrinterDetectorFactory::GetInstance(); chromeos::UsbPrinterDetectorFactory::GetInstance();
chromeos::CupsPrintJobManagerFactory::GetInstance(); chromeos::CupsPrintJobManagerFactory::GetInstance();
chromeos::PrintersManagerFactory::GetInstance(); chromeos::SyncedPrintersManagerFactory::GetInstance();
TetherServiceFactory::GetInstance(); TetherServiceFactory::GetInstance();
extensions::VerifyTrustAPI::GetFactoryInstance(); extensions::VerifyTrustAPI::GetFactoryInstance();
#endif #endif
......
...@@ -114,9 +114,9 @@ ...@@ -114,9 +114,9 @@
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/arc/arc_util.h" #include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/printing/printers_manager.h"
#include "chrome/browser/chromeos/printing/printers_manager_factory.h"
#include "chrome/browser/chromeos/printing/printers_sync_bridge.h" #include "chrome/browser/chromeos/printing/printers_sync_bridge.h"
#include "chrome/browser/chromeos/printing/synced_printers_manager.h"
#include "chrome/browser/chromeos/printing/synced_printers_manager_factory.h"
#include "chrome/browser/ui/app_list/arc/arc_package_sync_data_type_controller.h" #include "chrome/browser/ui/app_list/arc/arc_package_sync_data_type_controller.h"
#include "chrome/browser/ui/app_list/arc/arc_package_syncable_service.h" #include "chrome/browser/ui/app_list/arc/arc_package_syncable_service.h"
#include "components/sync_wifi/wifi_credential_syncable_service.h" #include "components/sync_wifi/wifi_credential_syncable_service.h"
...@@ -507,7 +507,8 @@ ChromeSyncClient::GetSyncBridgeForModelType(syncer::ModelType type) { ...@@ -507,7 +507,8 @@ ChromeSyncClient::GetSyncBridgeForModelType(syncer::ModelType type) {
web_data_service_.get()); web_data_service_.get());
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
case syncer::PRINTERS: case syncer::PRINTERS:
return chromeos::PrintersManagerFactory::GetForBrowserContext(profile_) return chromeos::SyncedPrintersManagerFactory::GetForBrowserContext(
profile_)
->GetSyncBridge() ->GetSyncBridge()
->AsWeakPtr(); ->AsWeakPtr();
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
#endif // !defined(OS_ANDROID) #endif // !defined(OS_ANDROID)
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/printing/printers_manager_factory.h" #include "chrome/browser/chromeos/printing/synced_printers_manager_factory.h"
#include "components/sync_wifi/wifi_credential_syncable_service_factory.h" #include "components/sync_wifi/wifi_credential_syncable_service_factory.h"
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
...@@ -159,7 +159,7 @@ ProfileSyncServiceFactory::ProfileSyncServiceFactory() ...@@ -159,7 +159,7 @@ ProfileSyncServiceFactory::ProfileSyncServiceFactory()
extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
#endif // BUILDFLAG(ENABLE_EXTENSIONS) #endif // BUILDFLAG(ENABLE_EXTENSIONS)
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
DependsOn(chromeos::PrintersManagerFactory::GetInstance()); DependsOn(chromeos::SyncedPrintersManagerFactory::GetInstance());
DependsOn(sync_wifi::WifiCredentialSyncableServiceFactory::GetInstance()); DependsOn(sync_wifi::WifiCredentialSyncableServiceFactory::GetInstance());
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/threading/sequenced_worker_pool.h" #include "base/threading/sequenced_worker_pool.h"
#include "chrome/browser/chromeos/printing/printers_manager.h" #include "chrome/browser/chromeos/printing/synced_printers_manager.h"
#include "chrome/browser/chromeos/printing/printers_manager_factory.h" #include "chrome/browser/chromeos/printing/synced_printers_manager_factory.h"
#include "chrome/browser/sync/test/integration/sync_datatype_helper.h" #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
#include "chrome/browser/sync/test/integration/sync_test.h" #include "chrome/browser/sync/test/integration/sync_test.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
...@@ -67,9 +67,10 @@ std::string PrinterId(int index) { ...@@ -67,9 +67,10 @@ std::string PrinterId(int index) {
return base::StringPrintf("printer%d", index); return base::StringPrintf("printer%d", index);
} }
chromeos::PrintersManager* GetPrinterStore(content::BrowserContext* context) { chromeos::SyncedPrintersManager* GetPrinterStore(
chromeos::PrintersManager* manager = content::BrowserContext* context) {
chromeos::PrintersManagerFactory::GetForBrowserContext(context); chromeos::SyncedPrintersManager* manager =
chromeos::SyncedPrintersManagerFactory::GetForBrowserContext(context);
// TODO(sync): crbug.com/709094: Remove all of this once the bug is fixed. // TODO(sync): crbug.com/709094: Remove all of this once the bug is fixed.
// Must wait for ModelTypeStore initialization. It is fairly difficult to get // Must wait for ModelTypeStore initialization. It is fairly difficult to get
...@@ -85,17 +86,17 @@ chromeos::PrintersManager* GetPrinterStore(content::BrowserContext* context) { ...@@ -85,17 +86,17 @@ chromeos::PrintersManager* GetPrinterStore(content::BrowserContext* context) {
} // namespace } // namespace
void AddPrinter(chromeos::PrintersManager* manager, void AddPrinter(chromeos::SyncedPrintersManager* manager,
const chromeos::Printer& printer) { const chromeos::Printer& printer) {
manager->RegisterPrinter(base::MakeUnique<chromeos::Printer>(printer)); manager->RegisterPrinter(base::MakeUnique<chromeos::Printer>(printer));
} }
void RemovePrinter(chromeos::PrintersManager* manager, int index) { void RemovePrinter(chromeos::SyncedPrintersManager* manager, int index) {
chromeos::Printer testPrinter(CreateTestPrinter(index)); chromeos::Printer testPrinter(CreateTestPrinter(index));
manager->RemovePrinter(testPrinter.id()); manager->RemovePrinter(testPrinter.id());
} }
bool EditPrinterDescription(chromeos::PrintersManager* manager, bool EditPrinterDescription(chromeos::SyncedPrintersManager* manager,
int index, int index,
const std::string& description) { const std::string& description) {
PrinterList printers = manager->GetPrinters(); PrinterList printers = manager->GetPrinters();
...@@ -123,15 +124,15 @@ chromeos::Printer CreateTestPrinter(int index) { ...@@ -123,15 +124,15 @@ chromeos::Printer CreateTestPrinter(int index) {
return printer; return printer;
} }
chromeos::PrintersManager* GetVerifierPrinterStore() { chromeos::SyncedPrintersManager* GetVerifierPrinterStore() {
chromeos::PrintersManager* manager = chromeos::SyncedPrintersManager* manager =
GetPrinterStore(sync_datatype_helper::test()->verifier()); GetPrinterStore(sync_datatype_helper::test()->verifier());
return manager; return manager;
} }
chromeos::PrintersManager* GetPrinterStore(int index) { chromeos::SyncedPrintersManager* GetPrinterStore(int index) {
chromeos::PrintersManager* manager = chromeos::SyncedPrintersManager* manager =
GetPrinterStore(sync_datatype_helper::test()->GetProfile(index)); GetPrinterStore(sync_datatype_helper::test()->GetProfile(index));
return manager; return manager;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "chrome/browser/chromeos/printing/printers_manager.h" #include "chrome/browser/chromeos/printing/synced_printers_manager.h"
#include "chrome/browser/sync/test/integration/await_match_status_change_checker.h" #include "chrome/browser/sync/test/integration/await_match_status_change_checker.h"
#include "chromeos/printing/printer_configuration.h" #include "chromeos/printing/printer_configuration.h"
...@@ -22,23 +22,23 @@ void SetupClients(); ...@@ -22,23 +22,23 @@ void SetupClients();
chromeos::Printer CreateTestPrinter(int index); chromeos::Printer CreateTestPrinter(int index);
// Add printer to the supplied store. // Add printer to the supplied store.
void AddPrinter(chromeos::PrintersManager* manager, void AddPrinter(chromeos::SyncedPrintersManager* manager,
const chromeos::Printer& printer); const chromeos::Printer& printer);
// Remove printer |index| from the |manager|. // Remove printer |index| from the |manager|.
void RemovePrinter(chromeos::PrintersManager* manager, int index); void RemovePrinter(chromeos::SyncedPrintersManager* manager, int index);
// Change the description of the printer at |index| with |description|. Returns // Change the description of the printer at |index| with |description|. Returns
// false if the printer is not tracked by the manager. // false if the printer is not tracked by the manager.
bool EditPrinterDescription(chromeos::PrintersManager* manager, bool EditPrinterDescription(chromeos::SyncedPrintersManager* manager,
int index, int index,
const std::string& description); const std::string& description);
// Returns the verifier store. // Returns the verifier store.
chromeos::PrintersManager* GetVerifierPrinterStore(); chromeos::SyncedPrintersManager* GetVerifierPrinterStore();
// Returns printer store at |index|. // Returns printer store at |index|.
chromeos::PrintersManager* GetPrinterStore(int index); chromeos::SyncedPrintersManager* GetPrinterStore(int index);
// Returns the number of printers in the verifier store. // Returns the number of printers in the verifier store.
int GetVerifierPrinterCount(); int GetVerifierPrinterCount();
......
...@@ -88,8 +88,6 @@ ...@@ -88,8 +88,6 @@
#include "third_party/icu/source/i18n/unicode/ulocdata.h" #include "third_party/icu/source/i18n/unicode/ulocdata.h"
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/printing/printers_manager.h"
#include "chrome/browser/chromeos/printing/printers_manager_factory.h"
#include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
#include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h" #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
#include "chrome/browser/chromeos/printing/cups_print_job_manager_factory.h" #include "chrome/browser/chromeos/printing/cups_print_job_manager_factory.h"
#include "chrome/browser/chromeos/printing/ppd_provider_factory.h" #include "chrome/browser/chromeos/printing/ppd_provider_factory.h"
#include "chrome/browser/chromeos/printing/printer_configurer.h" #include "chrome/browser/chromeos/printing/printer_configurer.h"
#include "chrome/browser/chromeos/printing/printers_manager.h" #include "chrome/browser/chromeos/printing/synced_printers_manager.h"
#include "chrome/browser/chromeos/printing/printers_manager_factory.h" #include "chrome/browser/chromeos/printing/synced_printers_manager_factory.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/print_preview/printer_capabilities.h" #include "chrome/browser/ui/webui/print_preview/printer_capabilities.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
...@@ -74,7 +74,8 @@ void FetchCapabilities(std::unique_ptr<chromeos::Printer> printer, ...@@ -74,7 +74,8 @@ void FetchCapabilities(std::unique_ptr<chromeos::Printer> printer,
class PrinterBackendProxyChromeos : public PrinterBackendProxy { class PrinterBackendProxyChromeos : public PrinterBackendProxy {
public: public:
explicit PrinterBackendProxyChromeos(Profile* profile) explicit PrinterBackendProxyChromeos(Profile* profile)
: prefs_(chromeos::PrintersManagerFactory::GetForBrowserContext(profile)), : prefs_(chromeos::SyncedPrintersManagerFactory::GetForBrowserContext(
profile)),
printer_configurer_(chromeos::PrinterConfigurer::Create(profile)), printer_configurer_(chromeos::PrinterConfigurer::Create(profile)),
weak_factory_(this) { weak_factory_(this) {
// Construct the CupsPrintJobManager to listen for printing events. // Construct the CupsPrintJobManager to listen for printing events.
...@@ -94,7 +95,7 @@ class PrinterBackendProxyChromeos : public PrinterBackendProxy { ...@@ -94,7 +95,7 @@ class PrinterBackendProxyChromeos : public PrinterBackendProxy {
}; };
void EnumeratePrinters(const EnumeratePrintersCallback& cb) override { void EnumeratePrinters(const EnumeratePrintersCallback& cb) override {
// PrintersManager is not thread safe and must be called from the UI // SyncedPrintersManager is not thread safe and must be called from the UI
// thread. // thread.
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
...@@ -183,7 +184,7 @@ class PrinterBackendProxyChromeos : public PrinterBackendProxy { ...@@ -183,7 +184,7 @@ class PrinterBackendProxyChromeos : public PrinterBackendProxy {
cb.Run(nullptr); cb.Run(nullptr);
} }
chromeos::PrintersManager* prefs_; chromeos::SyncedPrintersManager* prefs_;
scoped_refptr<chromeos::printing::PpdProvider> ppd_provider_; scoped_refptr<chromeos::printing::PpdProvider> ppd_provider_;
std::unique_ptr<chromeos::PrinterConfigurer> printer_configurer_; std::unique_ptr<chromeos::PrinterConfigurer> printer_configurer_;
base::WeakPtrFactory<PrinterBackendProxyChromeos> weak_factory_; base::WeakPtrFactory<PrinterBackendProxyChromeos> weak_factory_;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "chrome/browser/chromeos/printing/ppd_provider_factory.h" #include "chrome/browser/chromeos/printing/ppd_provider_factory.h"
#include "chrome/browser/chromeos/printing/printer_configurer.h" #include "chrome/browser/chromeos/printing/printer_configurer.h"
#include "chrome/browser/chromeos/printing/printer_info.h" #include "chrome/browser/chromeos/printing/printer_info.h"
#include "chrome/browser/chromeos/printing/printers_manager_factory.h" #include "chrome/browser/chromeos/printing/synced_printers_manager_factory.h"
#include "chrome/browser/chromeos/printing/usb_printer_detector.h" #include "chrome/browser/chromeos/printing/usb_printer_detector.h"
#include "chrome/browser/chromeos/printing/usb_printer_detector_factory.h" #include "chrome/browser/chromeos/printing/usb_printer_detector_factory.h"
#include "chrome/browser/download/download_prefs.h" #include "chrome/browser/download/download_prefs.h"
...@@ -186,7 +186,8 @@ void CupsPrintersHandler::HandleGetCupsPrintersList( ...@@ -186,7 +186,8 @@ void CupsPrintersHandler::HandleGetCupsPrintersList(
CHECK(args->GetString(0, &callback_id)); CHECK(args->GetString(0, &callback_id));
std::vector<std::unique_ptr<Printer>> printers = std::vector<std::unique_ptr<Printer>> printers =
PrintersManagerFactory::GetForBrowserContext(profile_)->GetPrinters(); SyncedPrintersManagerFactory::GetForBrowserContext(profile_)
->GetPrinters();
auto printers_list = base::MakeUnique<base::ListValue>(); auto printers_list = base::MakeUnique<base::ListValue>();
for (const std::unique_ptr<Printer>& printer : printers) { for (const std::unique_ptr<Printer>& printer : printers) {
...@@ -208,7 +209,7 @@ void CupsPrintersHandler::HandleUpdateCupsPrinter(const base::ListValue* args) { ...@@ -208,7 +209,7 @@ void CupsPrintersHandler::HandleUpdateCupsPrinter(const base::ListValue* args) {
std::unique_ptr<Printer> printer = base::MakeUnique<Printer>(printer_id); std::unique_ptr<Printer> printer = base::MakeUnique<Printer>(printer_id);
printer->set_display_name(printer_name); printer->set_display_name(printer_name);
PrintersManagerFactory::GetForBrowserContext(profile_)->RegisterPrinter( SyncedPrintersManagerFactory::GetForBrowserContext(profile_)->RegisterPrinter(
std::move(printer)); std::move(printer));
} }
...@@ -217,8 +218,8 @@ void CupsPrintersHandler::HandleRemoveCupsPrinter(const base::ListValue* args) { ...@@ -217,8 +218,8 @@ void CupsPrintersHandler::HandleRemoveCupsPrinter(const base::ListValue* args) {
std::string printer_name; std::string printer_name;
CHECK(args->GetString(0, &printer_id)); CHECK(args->GetString(0, &printer_id));
CHECK(args->GetString(1, &printer_name)); CHECK(args->GetString(1, &printer_name));
PrintersManager* prefs = SyncedPrintersManager* prefs =
PrintersManagerFactory::GetForBrowserContext(profile_); SyncedPrintersManagerFactory::GetForBrowserContext(profile_);
auto printer = prefs->GetPrinter(printer_id); auto printer = prefs->GetPrinter(printer_id);
if (!printer) if (!printer)
return; return;
...@@ -419,7 +420,8 @@ void CupsPrintersHandler::OnAddedPrinter(std::unique_ptr<Printer> printer, ...@@ -419,7 +420,8 @@ void CupsPrintersHandler::OnAddedPrinter(std::unique_ptr<Printer> printer,
case PrinterSetupResult::kSuccess: { case PrinterSetupResult::kSuccess: {
UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.PrinterAdded", UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.PrinterAdded",
printer->GetProtocol(), Printer::kProtocolMax); printer->GetProtocol(), Printer::kProtocolMax);
auto* manager = PrintersManagerFactory::GetForBrowserContext(profile_); auto* manager =
SyncedPrintersManagerFactory::GetForBrowserContext(profile_);
manager->PrinterInstalled(*printer); manager->PrinterInstalled(*printer);
manager->RegisterPrinter(std::move(printer)); manager->RegisterPrinter(std::move(printer));
break; break;
...@@ -571,8 +573,8 @@ void CupsPrintersHandler::OnPrintersFound( ...@@ -571,8 +573,8 @@ void CupsPrintersHandler::OnPrintersFound(
std::unique_ptr<base::ListValue> printers_list = std::unique_ptr<base::ListValue> printers_list =
base::MakeUnique<base::ListValue>(); base::MakeUnique<base::ListValue>();
// Filter out already-configured printers as we go. // Filter out already-configured printers as we go.
PrintersManager* printers_manager = SyncedPrintersManager* printers_manager =
PrintersManagerFactory::GetForBrowserContext(profile_); SyncedPrintersManagerFactory::GetForBrowserContext(profile_);
if (printers_manager != nullptr) { if (printers_manager != nullptr) {
for (const auto& printer : printers) { for (const auto& printer : printers) {
if (printers_manager->GetPrinter(printer.id()).get() == nullptr) { if (printers_manager->GetPrinter(printer.id()).get() == nullptr) {
...@@ -581,7 +583,7 @@ void CupsPrintersHandler::OnPrintersFound( ...@@ -581,7 +583,7 @@ void CupsPrintersHandler::OnPrintersFound(
} }
} else { } else {
LOG(WARNING) << "Failing to get available printers because no " LOG(WARNING) << "Failing to get available printers because no "
"PrintersManager exists."; "SyncedPrintersManager exists.";
} }
FireWebUIListener("on-printer-discovered", *printers_list); FireWebUIListener("on-printer-discovered", *printers_list);
} }
......
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