Commit 5c3feaef authored by justincarlson's avatar justincarlson Committed by Commit Bot

Make chromeos CUPS printing code namespaces consistent.

Previously printing code was in a mix of chromeos:: and
chromeos::printing.  This standardizes everything on chromeos::,
removing the chromeos::printing namespace completely.

These changes are almost entirely mechanical.  I did rename the factory function "CreateProvider" to the less generic "CreatePpdProvider" since it's now in ::chromeos directly.

BUG=702710

Review-Url: https://codereview.chromium.org/2975013002
Cr-Commit-Position: refs/heads/master@{#487334}
parent a1d23fe4
...@@ -15,9 +15,8 @@ ...@@ -15,9 +15,8 @@
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
namespace chromeos { namespace chromeos {
namespace printing {
scoped_refptr<PpdProvider> CreateProvider(Profile* profile) { scoped_refptr<PpdProvider> CreatePpdProvider(Profile* profile) {
base::FilePath ppd_cache_path = base::FilePath ppd_cache_path =
profile->GetPath().Append(FILE_PATH_LITERAL("PPDCache")); profile->GetPath().Append(FILE_PATH_LITERAL("PPDCache"));
...@@ -26,5 +25,4 @@ scoped_refptr<PpdProvider> CreateProvider(Profile* profile) { ...@@ -26,5 +25,4 @@ scoped_refptr<PpdProvider> CreateProvider(Profile* profile) {
PpdCache::Create(ppd_cache_path)); PpdCache::Create(ppd_cache_path));
} }
} // namespace printing
} // namespace chromeos } // namespace chromeos
...@@ -10,13 +10,11 @@ ...@@ -10,13 +10,11 @@
class Profile; class Profile;
namespace chromeos { namespace chromeos {
namespace printing {
class PpdProvider; class PpdProvider;
scoped_refptr<PpdProvider> CreateProvider(Profile* profile); scoped_refptr<PpdProvider> CreatePpdProvider(Profile* profile);
} // namespace printing } // namespace chromeos
} // namsepace chromeos
#endif // CHROME_BROWSER_CHROMEOS_PRINTING_PPD_PROVIDER_FACTORY_H_ #endif // CHROME_BROWSER_CHROMEOS_PRINTING_PPD_PROVIDER_FACTORY_H_
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
#include "chrome/browser/chromeos/printing/printer_configurer.h" #include "chrome/browser/chromeos/printing/printer_configurer.h"
#include <map>
#include <memory> #include <memory>
#include <set>
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -43,7 +45,7 @@ namespace { ...@@ -43,7 +45,7 @@ namespace {
class PrinterConfigurerImpl : public PrinterConfigurer { class PrinterConfigurerImpl : public PrinterConfigurer {
public: public:
explicit PrinterConfigurerImpl(Profile* profile) explicit PrinterConfigurerImpl(Profile* profile)
: ppd_provider_(printing::CreateProvider(profile)), weak_factory_(this) {} : ppd_provider_(CreatePpdProvider(profile)), weak_factory_(this) {}
PrinterConfigurerImpl(const PrinterConfigurerImpl&) = delete; PrinterConfigurerImpl(const PrinterConfigurerImpl&) = delete;
PrinterConfigurerImpl& operator=(const PrinterConfigurerImpl&) = delete; PrinterConfigurerImpl& operator=(const PrinterConfigurerImpl&) = delete;
...@@ -64,7 +66,7 @@ class PrinterConfigurerImpl : public PrinterConfigurer { ...@@ -64,7 +66,7 @@ class PrinterConfigurerImpl : public PrinterConfigurer {
return; return;
} }
auto* client = chromeos::DBusThreadManager::Get()->GetDebugDaemonClient(); auto* client = DBusThreadManager::Get()->GetDebugDaemonClient();
client->CupsAddAutoConfiguredPrinter( client->CupsAddAutoConfiguredPrinter(
printer.id(), printer.uri(), printer.id(), printer.uri(),
...@@ -119,7 +121,7 @@ class PrinterConfigurerImpl : public PrinterConfigurer { ...@@ -119,7 +121,7 @@ class PrinterConfigurerImpl : public PrinterConfigurer {
void AddPrinter(const Printer& printer, void AddPrinter(const Printer& printer,
const std::string& ppd_contents, const std::string& ppd_contents,
const PrinterSetupCallback& cb) { const PrinterSetupCallback& cb) {
auto* client = chromeos::DBusThreadManager::Get()->GetDebugDaemonClient(); auto* client = DBusThreadManager::Get()->GetDebugDaemonClient();
client->CupsAddManuallyConfiguredPrinter( client->CupsAddManuallyConfiguredPrinter(
printer.id(), printer.uri(), ppd_contents, printer.id(), printer.uri(), ppd_contents,
...@@ -179,31 +181,31 @@ class PrinterConfigurerImpl : public PrinterConfigurer { ...@@ -179,31 +181,31 @@ class PrinterConfigurerImpl : public PrinterConfigurer {
void ResolvePpdDone(const Printer& printer, void ResolvePpdDone(const Printer& printer,
const PrinterSetupCallback& cb, const PrinterSetupCallback& cb,
printing::PpdProvider::CallbackResultCode result, PpdProvider::CallbackResultCode result,
const std::string& ppd_contents, const std::string& ppd_contents,
const std::vector<std::string>& ppd_filters) { const std::vector<std::string>& ppd_filters) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
switch (result) { switch (result) {
case chromeos::printing::PpdProvider::SUCCESS: case PpdProvider::SUCCESS:
DCHECK(!ppd_contents.empty()); DCHECK(!ppd_contents.empty());
if (!RequiresComponent(printer, cb, ppd_contents, ppd_filters)) { if (!RequiresComponent(printer, cb, ppd_contents, ppd_filters)) {
AddPrinter(printer, ppd_contents, cb); AddPrinter(printer, ppd_contents, cb);
} }
break; break;
case printing::PpdProvider::CallbackResultCode::NOT_FOUND: case PpdProvider::CallbackResultCode::NOT_FOUND:
cb.Run(PrinterSetupResult::kPpdNotFound); cb.Run(PrinterSetupResult::kPpdNotFound);
break; break;
case printing::PpdProvider::CallbackResultCode::SERVER_ERROR: case PpdProvider::CallbackResultCode::SERVER_ERROR:
cb.Run(PrinterSetupResult::kPpdUnretrievable); cb.Run(PrinterSetupResult::kPpdUnretrievable);
break; break;
case printing::PpdProvider::CallbackResultCode::INTERNAL_ERROR: case PpdProvider::CallbackResultCode::INTERNAL_ERROR:
// TODO(skau): Add kPpdTooLarge when it's reported by the PpdProvider. // TODO(skau): Add kPpdTooLarge when it's reported by the PpdProvider.
cb.Run(PrinterSetupResult::kFatalError); cb.Run(PrinterSetupResult::kFatalError);
break; break;
} }
} }
scoped_refptr<printing::PpdProvider> ppd_provider_; scoped_refptr<PpdProvider> ppd_provider_;
base::WeakPtrFactory<PrinterConfigurerImpl> weak_factory_; base::WeakPtrFactory<PrinterConfigurerImpl> weak_factory_;
}; };
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "components/sync/protocol/printer_specifics.pb.h" #include "components/sync/protocol/printer_specifics.pb.h"
namespace chromeos { namespace chromeos {
namespace printing {
namespace { namespace {
...@@ -125,5 +124,4 @@ void MergePrinterToSpecifics(const Printer& printer, ...@@ -125,5 +124,4 @@ void MergePrinterToSpecifics(const Printer& printer,
printer.ppd_reference()); printer.ppd_reference());
} }
} // namespace printing
} // namespace chromeos } // namespace chromeos
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "components/sync/protocol/printer_specifics.pb.h" #include "components/sync/protocol/printer_specifics.pb.h"
namespace chromeos { namespace chromeos {
namespace printing {
// Convert |printer| into its local representation. Enforces that only one // Convert |printer| into its local representation. Enforces that only one
// field in PpdReference is filled in. In order of preference, we populate // field in PpdReference is filled in. In order of preference, we populate
...@@ -31,7 +30,6 @@ std::unique_ptr<sync_pb::PrinterSpecifics> PrinterToSpecifics( ...@@ -31,7 +30,6 @@ std::unique_ptr<sync_pb::PrinterSpecifics> PrinterToSpecifics(
void MergePrinterToSpecifics(const Printer& printer, void MergePrinterToSpecifics(const Printer& printer,
sync_pb::PrinterSpecifics* specifics); sync_pb::PrinterSpecifics* specifics);
} // namespace printing
} // namespace chromeos } // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_PRINTING_SPECIFICS_TRANSLATION_H_ #endif // CHROME_BROWSER_CHROMEOS_PRINTING_SPECIFICS_TRANSLATION_H_
...@@ -30,7 +30,6 @@ constexpr char kEffectiveMakeAndModel[] = "Manufacturer Model T1000"; ...@@ -30,7 +30,6 @@ constexpr char kEffectiveMakeAndModel[] = "Manufacturer Model T1000";
} // namespace } // namespace
namespace chromeos { namespace chromeos {
namespace printing {
TEST(SpecificsTranslationTest, SpecificsToPrinter) { TEST(SpecificsTranslationTest, SpecificsToPrinter) {
sync_pb::PrinterSpecifics specifics; sync_pb::PrinterSpecifics specifics;
...@@ -223,5 +222,4 @@ TEST(SpecificsTranslationTest, MakeAndModelPreferred) { ...@@ -223,5 +222,4 @@ TEST(SpecificsTranslationTest, MakeAndModelPreferred) {
EXPECT_EQ(kMakeAndModel, printer->make_and_model()); EXPECT_EQ(kMakeAndModel, printer->make_and_model());
} }
} // namespace printing
} // namespace chromeos } // namespace chromeos
...@@ -36,14 +36,14 @@ bool UpdatePrinterPref(PrintersSyncBridge* sync_bridge, ...@@ -36,14 +36,14 @@ bool UpdatePrinterPref(PrintersSyncBridge* sync_bridge,
base::Optional<sync_pb::PrinterSpecifics> specifics = base::Optional<sync_pb::PrinterSpecifics> specifics =
sync_bridge->GetPrinter(id); sync_bridge->GetPrinter(id);
if (!specifics.has_value()) { if (!specifics.has_value()) {
sync_bridge->AddPrinter(printing::PrinterToSpecifics(printer)); sync_bridge->AddPrinter(PrinterToSpecifics(printer));
return true; return true;
} }
// Preserve fields in the proto which we don't understand. // Preserve fields in the proto which we don't understand.
std::unique_ptr<sync_pb::PrinterSpecifics> updated_printer = std::unique_ptr<sync_pb::PrinterSpecifics> updated_printer =
base::MakeUnique<sync_pb::PrinterSpecifics>(*specifics); base::MakeUnique<sync_pb::PrinterSpecifics>(*specifics);
printing::MergePrinterToSpecifics(printer, updated_printer.get()); MergePrinterToSpecifics(printer, updated_printer.get());
sync_bridge->AddPrinter(std::move(updated_printer)); sync_bridge->AddPrinter(std::move(updated_printer));
return false; return false;
...@@ -80,7 +80,7 @@ std::vector<std::unique_ptr<Printer>> SyncedPrintersManager::GetPrinters() ...@@ -80,7 +80,7 @@ std::vector<std::unique_ptr<Printer>> SyncedPrintersManager::GetPrinters()
std::vector<sync_pb::PrinterSpecifics> values = std::vector<sync_pb::PrinterSpecifics> values =
sync_bridge_->GetAllPrinters(); sync_bridge_->GetAllPrinters();
for (const auto& value : values) { for (const auto& value : values) {
printers.push_back(printing::SpecificsToPrinter(value)); printers.push_back(SpecificsToPrinter(value));
} }
return printers; return printers;
...@@ -112,7 +112,7 @@ std::unique_ptr<Printer> SyncedPrintersManager::GetPrinter( ...@@ -112,7 +112,7 @@ std::unique_ptr<Printer> SyncedPrintersManager::GetPrinter(
base::Optional<sync_pb::PrinterSpecifics> printer = base::Optional<sync_pb::PrinterSpecifics> printer =
sync_bridge_->GetPrinter(printer_id); sync_bridge_->GetPrinter(printer_id);
return printer.has_value() ? printing::SpecificsToPrinter(*printer) : nullptr; return printer.has_value() ? SpecificsToPrinter(*printer) : nullptr;
} }
void SyncedPrintersManager::RegisterPrinter(std::unique_ptr<Printer> printer) { void SyncedPrintersManager::RegisterPrinter(std::unique_ptr<Printer> printer) {
...@@ -142,7 +142,7 @@ bool SyncedPrintersManager::RemovePrinter(const std::string& printer_id) { ...@@ -142,7 +142,7 @@ bool SyncedPrintersManager::RemovePrinter(const std::string& printer_id) {
sync_bridge_->GetPrinter(printer_id); sync_bridge_->GetPrinter(printer_id);
bool success = false; bool success = false;
if (printer.has_value()) { if (printer.has_value()) {
std::unique_ptr<Printer> p = printing::SpecificsToPrinter(*printer); std::unique_ptr<Printer> p = SpecificsToPrinter(*printer);
success = sync_bridge_->RemovePrinter(p->id()); success = sync_bridge_->RemovePrinter(p->id());
if (success) { if (success) {
for (Observer& obs : observers_) { for (Observer& obs : observers_) {
...@@ -201,7 +201,7 @@ void SyncedPrintersManager::UpdateRecommendedPrinters() { ...@@ -201,7 +201,7 @@ void SyncedPrintersManager::UpdateRecommendedPrinters() {
// unique so we'll hash the record. This will not collide with the UUIDs // unique so we'll hash the record. This will not collide with the UUIDs
// generated for user entries. // generated for user entries.
std::string id = base::MD5String(printer_json); std::string id = base::MD5String(printer_json);
printer_dictionary->SetString(printing::kPrinterId, id); printer_dictionary->SetString(kPrinterId, id);
if (base::ContainsKey(new_printers, id)) { if (base::ContainsKey(new_printers, id)) {
// Skip duplicated entries. // Skip duplicated entries.
...@@ -216,7 +216,7 @@ void SyncedPrintersManager::UpdateRecommendedPrinters() { ...@@ -216,7 +216,7 @@ void SyncedPrintersManager::UpdateRecommendedPrinters() {
new_printers[id] = std::move(old->second); new_printers[id] = std::move(old->second);
} else { } else {
auto printer = auto printer =
printing::RecommendedPrinterToPrinter(*printer_dictionary, timestamp); RecommendedPrinterToPrinter(*printer_dictionary, timestamp);
printer->set_source(Printer::SRC_POLICY); printer->set_source(Printer::SRC_POLICY);
new_printers[id] = std::move(printer); new_printers[id] = std::move(printer);
......
...@@ -27,8 +27,8 @@ namespace chromeos { ...@@ -27,8 +27,8 @@ namespace chromeos {
namespace { namespace {
const char kPrinterId[] = "UUID-UUID-UUID-PRINTER"; const char kTestPrinterId[] = "UUID-UUID-UUID-PRINTER";
const char kUri[] = "ipps://printer.chromium.org/ipp/print"; const char kTestUri[] = "ipps://printer.chromium.org/ipp/print";
const char kLexJson[] = R"json({ const char kLexJson[] = R"json({
"display_name": "LexaPrint", "display_name": "LexaPrint",
...@@ -109,11 +109,11 @@ class SyncedPrintersManagerTest : public testing::Test { ...@@ -109,11 +109,11 @@ class SyncedPrintersManagerTest : public testing::Test {
TEST_F(SyncedPrintersManagerTest, 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>(kTestPrinterId));
auto printers = manager_.GetPrinters(); auto printers = manager_.GetPrinters();
ASSERT_EQ(1U, printers.size()); ASSERT_EQ(1U, printers.size());
EXPECT_EQ(kPrinterId, printers[0]->id()); EXPECT_EQ(kTestPrinterId, printers[0]->id());
EXPECT_EQ(Printer::Source::SRC_USER_PREFS, printers[0]->source()); EXPECT_EQ(Printer::Source::SRC_USER_PREFS, printers[0]->source());
EXPECT_TRUE(observer.AddCalled()); EXPECT_TRUE(observer.AddCalled());
...@@ -129,9 +129,9 @@ TEST_F(SyncedPrintersManagerTest, UpdatePrinterAssignsId) { ...@@ -129,9 +129,9 @@ TEST_F(SyncedPrintersManagerTest, UpdatePrinterAssignsId) {
} }
TEST_F(SyncedPrintersManagerTest, UpdatePrinter) { TEST_F(SyncedPrintersManagerTest, UpdatePrinter) {
manager_.RegisterPrinter(base::MakeUnique<Printer>(kPrinterId)); manager_.RegisterPrinter(base::MakeUnique<Printer>(kTestPrinterId));
auto updated_printer = base::MakeUnique<Printer>(kPrinterId); auto updated_printer = base::MakeUnique<Printer>(kTestPrinterId);
updated_printer->set_uri(kUri); updated_printer->set_uri(kTestUri);
// Register observer so it only receives the update event. // Register observer so it only receives the update event.
LoggingObserver observer; LoggingObserver observer;
...@@ -141,7 +141,7 @@ TEST_F(SyncedPrintersManagerTest, UpdatePrinter) { ...@@ -141,7 +141,7 @@ TEST_F(SyncedPrintersManagerTest, UpdatePrinter) {
auto printers = manager_.GetPrinters(); auto printers = manager_.GetPrinters();
ASSERT_EQ(1U, printers.size()); ASSERT_EQ(1U, printers.size());
EXPECT_EQ(kUri, printers[0]->uri()); EXPECT_EQ(kTestUri, printers[0]->uri());
EXPECT_TRUE(observer.UpdateCalled()); EXPECT_TRUE(observer.UpdateCalled());
EXPECT_FALSE(observer.AddCalled()); EXPECT_FALSE(observer.AddCalled());
...@@ -149,15 +149,15 @@ TEST_F(SyncedPrintersManagerTest, UpdatePrinter) { ...@@ -149,15 +149,15 @@ TEST_F(SyncedPrintersManagerTest, UpdatePrinter) {
TEST_F(SyncedPrintersManagerTest, 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>(kTestPrinterId));
manager_.RegisterPrinter(base::MakeUnique<Printer>()); manager_.RegisterPrinter(base::MakeUnique<Printer>());
manager_.RemovePrinter(kPrinterId); manager_.RemovePrinter(kTestPrinterId);
auto printers = manager_.GetPrinters(); auto printers = manager_.GetPrinters();
ASSERT_EQ(2U, printers.size()); ASSERT_EQ(2U, printers.size());
EXPECT_NE(kPrinterId, printers.at(0)->id()); EXPECT_NE(kTestPrinterId, printers.at(0)->id());
EXPECT_NE(kPrinterId, printers.at(1)->id()); EXPECT_NE(kTestPrinterId, printers.at(1)->id());
} }
// Tests for policy printers // Tests for policy printers
...@@ -216,21 +216,21 @@ TEST_F(SyncedPrintersManagerTest, GetRecommendedPrinter) { ...@@ -216,21 +216,21 @@ TEST_F(SyncedPrintersManagerTest, GetRecommendedPrinter) {
} }
TEST_F(SyncedPrintersManagerTest, PrinterNotInstalled) { TEST_F(SyncedPrintersManagerTest, PrinterNotInstalled) {
Printer printer(kPrinterId, base::Time::FromInternalValue(1000)); Printer printer(kTestPrinterId, base::Time::FromInternalValue(1000));
EXPECT_FALSE(manager_.IsConfigurationCurrent(printer)); EXPECT_FALSE(manager_.IsConfigurationCurrent(printer));
} }
TEST_F(SyncedPrintersManagerTest, PrinterIsInstalled) { TEST_F(SyncedPrintersManagerTest, PrinterIsInstalled) {
Printer printer(kPrinterId, base::Time::FromInternalValue(1000)); Printer printer(kTestPrinterId, base::Time::FromInternalValue(1000));
manager_.PrinterInstalled(printer); manager_.PrinterInstalled(printer);
EXPECT_TRUE(manager_.IsConfigurationCurrent(printer)); EXPECT_TRUE(manager_.IsConfigurationCurrent(printer));
} }
TEST_F(SyncedPrintersManagerTest, UpdatedPrinterConfiguration) { TEST_F(SyncedPrintersManagerTest, UpdatedPrinterConfiguration) {
Printer printer(kPrinterId, base::Time::FromInternalValue(1000)); Printer printer(kTestPrinterId, base::Time::FromInternalValue(1000));
manager_.PrinterInstalled(printer); manager_.PrinterInstalled(printer);
Printer updated_printer(kPrinterId, base::Time::FromInternalValue(2000)); Printer updated_printer(kTestPrinterId, base::Time::FromInternalValue(2000));
EXPECT_FALSE(manager_.IsConfigurationCurrent(updated_printer)); EXPECT_FALSE(manager_.IsConfigurationCurrent(updated_printer));
} }
......
...@@ -37,8 +37,6 @@ ...@@ -37,8 +37,6 @@
namespace chromeos { namespace chromeos {
namespace { namespace {
using printing::PpdProvider;
// Aggregates the information needed for printer setup so it's easier to pass it // Aggregates the information needed for printer setup so it's easier to pass it
// around. // around.
struct SetUpPrinterData { struct SetUpPrinterData {
...@@ -211,8 +209,7 @@ class UsbPrinterDetectorImpl : public UsbPrinterDetector, ...@@ -211,8 +209,7 @@ class UsbPrinterDetectorImpl : public UsbPrinterDetector,
data->is_new = true; data->is_new = true;
// Look for an exact match based on USB ids. // Look for an exact match based on USB ids.
scoped_refptr<PpdProvider> ppd_provider = scoped_refptr<PpdProvider> ppd_provider = CreatePpdProvider(profile_);
printing::CreateProvider(profile_);
ppd_provider->ResolveUsbIds( ppd_provider->ResolveUsbIds(
device->vendor_id(), device->product_id(), device->vendor_id(), device->product_id(),
base::Bind(&UsbPrinterDetectorImpl::ResolveUsbIdsDone, base::Bind(&UsbPrinterDetectorImpl::ResolveUsbIdsDone,
......
...@@ -185,7 +185,7 @@ class PrinterBackendProxyChromeos : public PrinterBackendProxy { ...@@ -185,7 +185,7 @@ class PrinterBackendProxyChromeos : public PrinterBackendProxy {
} }
chromeos::SyncedPrintersManager* prefs_; chromeos::SyncedPrintersManager* prefs_;
scoped_refptr<chromeos::printing::PpdProvider> ppd_provider_; scoped_refptr<chromeos::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_;
......
...@@ -131,7 +131,7 @@ CupsPrintersHandler::CupsPrintersHandler(content::WebUI* webui) ...@@ -131,7 +131,7 @@ CupsPrintersHandler::CupsPrintersHandler(content::WebUI* webui)
: printer_detector_(nullptr), : printer_detector_(nullptr),
profile_(Profile::FromWebUI(webui)), profile_(Profile::FromWebUI(webui)),
weak_factory_(this) { weak_factory_(this) {
ppd_provider_ = printing::CreateProvider(profile_); ppd_provider_ = CreatePpdProvider(profile_);
printer_configurer_ = PrinterConfigurer::Create(profile_); printer_configurer_ = PrinterConfigurer::Create(profile_);
} }
...@@ -516,28 +516,28 @@ void CupsPrintersHandler::HandleSelectPPDFile(const base::ListValue* args) { ...@@ -516,28 +516,28 @@ void CupsPrintersHandler::HandleSelectPPDFile(const base::ListValue* args) {
void CupsPrintersHandler::ResolveManufacturersDone( void CupsPrintersHandler::ResolveManufacturersDone(
const std::string& js_callback, const std::string& js_callback,
printing::PpdProvider::CallbackResultCode result_code, PpdProvider::CallbackResultCode result_code,
const std::vector<std::string>& manufacturers) { const std::vector<std::string>& manufacturers) {
auto manufacturers_value = base::MakeUnique<base::ListValue>(); auto manufacturers_value = base::MakeUnique<base::ListValue>();
if (result_code == printing::PpdProvider::SUCCESS) { if (result_code == PpdProvider::SUCCESS) {
manufacturers_value->AppendStrings(manufacturers); manufacturers_value->AppendStrings(manufacturers);
} }
base::DictionaryValue response; base::DictionaryValue response;
response.SetBoolean("success", result_code == printing::PpdProvider::SUCCESS); response.SetBoolean("success", result_code == PpdProvider::SUCCESS);
response.Set("manufacturers", std::move(manufacturers_value)); response.Set("manufacturers", std::move(manufacturers_value));
ResolveJavascriptCallback(base::Value(js_callback), response); ResolveJavascriptCallback(base::Value(js_callback), response);
} }
void CupsPrintersHandler::ResolvePrintersDone( void CupsPrintersHandler::ResolvePrintersDone(
const std::string& js_callback, const std::string& js_callback,
printing::PpdProvider::CallbackResultCode result_code, PpdProvider::CallbackResultCode result_code,
const std::vector<std::string>& printers) { const std::vector<std::string>& printers) {
auto printers_value = base::MakeUnique<base::ListValue>(); auto printers_value = base::MakeUnique<base::ListValue>();
if (result_code == printing::PpdProvider::SUCCESS) { if (result_code == PpdProvider::SUCCESS) {
printers_value->AppendStrings(printers); printers_value->AppendStrings(printers);
} }
base::DictionaryValue response; base::DictionaryValue response;
response.SetBoolean("success", result_code == printing::PpdProvider::SUCCESS); response.SetBoolean("success", result_code == PpdProvider::SUCCESS);
response.Set("models", std::move(printers_value)); response.Set("models", std::move(printers_value));
ResolveJavascriptCallback(base::Value(js_callback), response); ResolveJavascriptCallback(base::Value(js_callback), response);
} }
......
...@@ -25,11 +25,9 @@ class ListValue; ...@@ -25,11 +25,9 @@ class ListValue;
class Profile; class Profile;
namespace chromeos { namespace chromeos {
namespace printing {
class PpdProvider;
}
class CombiningPrinterDetector; class CombiningPrinterDetector;
class PpdProvider;
namespace settings { namespace settings {
...@@ -89,14 +87,12 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler, ...@@ -89,14 +87,12 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler,
void HandleSelectPPDFile(const base::ListValue* args); void HandleSelectPPDFile(const base::ListValue* args);
// PpdProvider callback handlers. // PpdProvider callback handlers.
void ResolveManufacturersDone( void ResolveManufacturersDone(const std::string& js_callback,
const std::string& js_callback, PpdProvider::CallbackResultCode result_code,
printing::PpdProvider::CallbackResultCode result_code, const std::vector<std::string>& available);
const std::vector<std::string>& available); void ResolvePrintersDone(const std::string& js_callback,
void ResolvePrintersDone( PpdProvider::CallbackResultCode result_code,
const std::string& js_callback, const std::vector<std::string>& available);
printing::PpdProvider::CallbackResultCode result_code,
const std::vector<std::string>& available);
// ui::SelectFileDialog::Listener override: // ui::SelectFileDialog::Listener override:
void FileSelected(const base::FilePath& path, void FileSelected(const base::FilePath& path,
...@@ -120,7 +116,7 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler, ...@@ -120,7 +116,7 @@ class CupsPrintersHandler : public ::settings::SettingsPageUIHandler,
bool ipp_everywhere); bool ipp_everywhere);
std::unique_ptr<CombiningPrinterDetector> printer_detector_; std::unique_ptr<CombiningPrinterDetector> printer_detector_;
scoped_refptr<printing::PpdProvider> ppd_provider_; scoped_refptr<PpdProvider> ppd_provider_;
std::unique_ptr<PrinterConfigurer> printer_configurer_; std::unique_ptr<PrinterConfigurer> printer_configurer_;
Profile* profile_; Profile* profile_;
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "net/filter/gzip_header.h" #include "net/filter/gzip_header.h"
namespace chromeos { namespace chromeos {
namespace printing {
namespace { namespace {
// Return the (full) path to the file we expect to find the given key at. // Return the (full) path to the file we expect to find the given key at.
...@@ -165,5 +164,4 @@ scoped_refptr<PpdCache> PpdCache::Create(const base::FilePath& cache_base_dir) { ...@@ -165,5 +164,4 @@ scoped_refptr<PpdCache> PpdCache::Create(const base::FilePath& cache_base_dir) {
return scoped_refptr<PpdCache>(new PpdCacheImpl(cache_base_dir)); return scoped_refptr<PpdCache>(new PpdCacheImpl(cache_base_dir));
} }
} // namespace printing
} // namespace chromeos } // namespace chromeos
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "chromeos/chromeos_export.h" #include "chromeos/chromeos_export.h"
namespace chromeos { namespace chromeos {
namespace printing {
// PpdCache manages a cache of locally-stored PPD files. At its core, it // PpdCache manages a cache of locally-stored PPD files. At its core, it
// operates like a persistent hash from PpdReference to files. If you give the // operates like a persistent hash from PpdReference to files. If you give the
...@@ -62,7 +61,6 @@ class CHROMEOS_EXPORT PpdCache : public base::RefCounted<PpdCache> { ...@@ -62,7 +61,6 @@ class CHROMEOS_EXPORT PpdCache : public base::RefCounted<PpdCache> {
virtual ~PpdCache() {} virtual ~PpdCache() {}
}; };
} // namespace printing
} // namespace chromeos } // namespace chromeos
#endif // CHROMEOS_PRINTING_PPD_CACHE_H_ #endif // CHROMEOS_PRINTING_PPD_CACHE_H_
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace chromeos { namespace chromeos {
namespace printing {
namespace { namespace {
// This fixture just points the cache at a temporary directory for the life of // This fixture just points the cache at a temporary directory for the life of
...@@ -114,5 +113,4 @@ TEST_F(PpdCacheTest, MissThenHit) { ...@@ -114,5 +113,4 @@ TEST_F(PpdCacheTest, MissThenHit) {
} }
} // namespace } // namespace
} // namespace printing
} // namespace chromeos } // namespace chromeos
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#include "url/gurl.h" #include "url/gurl.h"
namespace chromeos { namespace chromeos {
namespace printing {
namespace { namespace {
// Extract cupsFilter/cupsFilter2 filter names from the contents // Extract cupsFilter/cupsFilter2 filter names from the contents
...@@ -1020,5 +1019,4 @@ scoped_refptr<PpdProvider> PpdProvider::Create( ...@@ -1020,5 +1019,4 @@ scoped_refptr<PpdProvider> PpdProvider::Create(
return scoped_refptr<PpdProvider>(new PpdProviderImpl( return scoped_refptr<PpdProvider>(new PpdProviderImpl(
browser_locale, url_context_getter, ppd_cache, options)); browser_locale, url_context_getter, ppd_cache, options));
} }
} // namespace printing
} // namespace chromeos } // namespace chromeos
...@@ -20,7 +20,6 @@ class URLRequestContextGetter; ...@@ -20,7 +20,6 @@ class URLRequestContextGetter;
} }
namespace chromeos { namespace chromeos {
namespace printing {
class PpdCache; class PpdCache;
...@@ -137,7 +136,6 @@ class CHROMEOS_EXPORT PpdProvider : public base::RefCounted<PpdProvider> { ...@@ -137,7 +136,6 @@ class CHROMEOS_EXPORT PpdProvider : public base::RefCounted<PpdProvider> {
virtual ~PpdProvider() {} virtual ~PpdProvider() {}
}; };
} // namespace printing
} // namespace chromeos } // namespace chromeos
#endif // CHROMEOS_PRINTING_PPD_PROVIDER_H_ #endif // CHROMEOS_PRINTING_PPD_PROVIDER_H_
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace chromeos { namespace chromeos {
namespace printing {
namespace { namespace {
...@@ -556,5 +555,4 @@ TEST_F(PpdProviderTest, ExtractPpdFilters) { ...@@ -556,5 +555,4 @@ TEST_F(PpdProviderTest, ExtractPpdFilters) {
} }
} // namespace } // namespace
} // namespace printing
} // namespace chromeos } // namespace chromeos
...@@ -80,8 +80,6 @@ bool DictionaryToPrinter(const DictionaryValue& value, Printer* printer) { ...@@ -80,8 +80,6 @@ bool DictionaryToPrinter(const DictionaryValue& value, Printer* printer) {
} // namespace } // namespace
namespace printing {
const char kPrinterId[] = "id"; const char kPrinterId[] = "id";
std::unique_ptr<Printer> RecommendedPrinterToPrinter( std::unique_ptr<Printer> RecommendedPrinterToPrinter(
...@@ -90,7 +88,7 @@ std::unique_ptr<Printer> RecommendedPrinterToPrinter( ...@@ -90,7 +88,7 @@ std::unique_ptr<Printer> RecommendedPrinterToPrinter(
DCHECK(!timestamp.is_null()); DCHECK(!timestamp.is_null());
std::string id; std::string id;
if (!pref.GetString(printing::kPrinterId, &id)) { if (!pref.GetString(kPrinterId, &id)) {
LOG(WARNING) << "Record id required"; LOG(WARNING) << "Record id required";
return nullptr; return nullptr;
} }
...@@ -117,5 +115,4 @@ std::unique_ptr<Printer> RecommendedPrinterToPrinter( ...@@ -117,5 +115,4 @@ std::unique_ptr<Printer> RecommendedPrinterToPrinter(
return printer; return printer;
} }
} // namespace printing
} // namespace chromeos } // namespace chromeos
...@@ -16,7 +16,6 @@ class Time; ...@@ -16,7 +16,6 @@ class Time;
} }
namespace chromeos { namespace chromeos {
namespace printing {
CHROMEOS_EXPORT extern const char kPrinterId[]; CHROMEOS_EXPORT extern const char kPrinterId[];
...@@ -26,7 +25,6 @@ CHROMEOS_EXPORT std::unique_ptr<Printer> RecommendedPrinterToPrinter( ...@@ -26,7 +25,6 @@ CHROMEOS_EXPORT std::unique_ptr<Printer> RecommendedPrinterToPrinter(
const base::DictionaryValue& pref, const base::DictionaryValue& pref,
const base::Time& timestamp); const base::Time& timestamp);
} // namespace printing
} // namespace chromeos } // namespace chromeos
#endif // CHROMEOS_PRINTING_PRINTER_TRANSLATOR_H_ #endif // CHROMEOS_PRINTING_PRINTER_TRANSLATOR_H_
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace chromeos { namespace chromeos {
namespace printing {
// Printer test data // Printer test data
const char kHash[] = "ABCDEF123456"; const char kHash[] = "ABCDEF123456";
...@@ -161,5 +160,4 @@ TEST(PrinterTranslatorTest, RecommendedPrinterToPrinterBlankModel) { ...@@ -161,5 +160,4 @@ TEST(PrinterTranslatorTest, RecommendedPrinterToPrinterBlankModel) {
EXPECT_EQ(kMake, printer->make_and_model()); EXPECT_EQ(kMake, printer->make_and_model());
} }
} // namespace printing
} // namespace chromeos } // namespace chromeos
...@@ -6,14 +6,12 @@ ...@@ -6,14 +6,12 @@
#define CHROMEOS_PRINTING_PRINTING_CONSTANTS_H_ #define CHROMEOS_PRINTING_PRINTING_CONSTANTS_H_
namespace chromeos { namespace chromeos {
namespace printing {
// Maximum size of a PPD file that we will accept, currently 250k. This number // Maximum size of a PPD file that we will accept, currently 250k. This number
// is relatively // is relatively
// arbitrary, we just don't want to try to handle ridiculously huge files. // arbitrary, we just don't want to try to handle ridiculously huge files.
constexpr size_t kMaxPpdSizeBytes = 250 * 1024; constexpr size_t kMaxPpdSizeBytes = 250 * 1024;
} // namespace printing
} // namespace chromeos } // namespace chromeos
#endif // CHROMEOS_PRINTING_PRINTING_CONSTANTS_H_ #endif // CHROMEOS_PRINTING_PRINTING_CONSTANTS_H_
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