Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1946)

Unified Diff: chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc

Issue 12769009: Pass list of printers to chrome using file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/printing/cloud_print/cloud_print_proxy_service.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc
diff --git a/chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc b/chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc
index 62ca666e26fb7c057bfe1b621b9de0d1c855322e..1dde9bdb5373a60d2d62146ad91aa9d70260abe2 100644
--- a/chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc
+++ b/chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc
@@ -9,6 +9,9 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/command_line.h"
+#include "base/file_util.h"
+#include "base/json/json_reader.h"
#include "base/message_loop.h"
#include "base/prefs/pref_service.h"
#include "base/utf_string_conversions.h"
@@ -21,11 +24,13 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/service/service_process_control.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/cloud_print/cloud_print_proxy_info.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/service_messages.h"
#include "content/public/browser/browser_thread.h"
#include "grit/generated_resources.h"
+#include "printing/backend/print_backend.h"
#include "ui/base/l10n/l10n_util.h"
using content::BrowserThread;
@@ -128,6 +133,34 @@ void CloudPrintProxyService::OnCloudPrintSetupClosed() {
base::Bind(&chrome::EndKeepAlive));
}
+void CloudPrintProxyService::GetPrintersAvalibleForRegistration(
+ std::vector<std::string>* printers) {
+ base::FilePath list_path(
+ CommandLine::ForCurrentProcess()->GetSwitchValuePath(
+ switches::kCloudPrintConnectoEnablePrinters));
+ if (!list_path.empty()) {
+ std::string printers_json;
+ file_util::ReadFileToString(list_path, &printers_json);
+ scoped_ptr<Value> value(base::JSONReader::Read(printers_json));
+ base::ListValue* list = NULL;
+ if (value && value->GetAsList(&list) && list) {
+ for (size_t i = 0; i < list->GetSize(); ++i) {
+ std::string printer;
+ if (list->GetString(i, &printer))
+ printers->push_back(printer);
+ }
+ }
+ } else {
+ printing::PrinterList printer_list;
+ scoped_refptr<printing::PrintBackend> backend(
+ printing::PrintBackend::CreateInstance(NULL));
+ if (backend)
+ backend->EnumeratePrinters(&printer_list);
+ for (size_t i = 0; i < printer_list.size(); ++i)
+ printers->push_back(printer_list[i].printer_name);
+ }
+}
+
void CloudPrintProxyService::RefreshCloudPrintProxyStatus() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
ServiceProcessControl* process_control = GetServiceProcessControl();
« no previous file with comments | « chrome/browser/printing/cloud_print/cloud_print_proxy_service.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698