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

Side by Side Diff: chrome/browser/ui/webui/print_preview/print_preview_handler.cc

Issue 214443007: Pass location and description of local printers into print preview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h" 5 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #include "content/public/browser/browser_context.h" 55 #include "content/public/browser/browser_context.h"
56 #include "content/public/browser/browser_thread.h" 56 #include "content/public/browser/browser_thread.h"
57 #include "content/public/browser/navigation_controller.h" 57 #include "content/public/browser/navigation_controller.h"
58 #include "content/public/browser/navigation_entry.h" 58 #include "content/public/browser/navigation_entry.h"
59 #include "content/public/browser/render_view_host.h" 59 #include "content/public/browser/render_view_host.h"
60 #include "content/public/browser/web_contents.h" 60 #include "content/public/browser/web_contents.h"
61 #include "content/public/browser/web_contents_view.h" 61 #include "content/public/browser/web_contents_view.h"
62 #include "content/public/browser/web_ui.h" 62 #include "content/public/browser/web_ui.h"
63 #include "google_apis/gaia/oauth2_token_service.h" 63 #include "google_apis/gaia/oauth2_token_service.h"
64 #include "printing/backend/print_backend.h" 64 #include "printing/backend/print_backend.h"
65 #include "printing/backend/print_backend_consts.h"
65 #include "printing/metafile.h" 66 #include "printing/metafile.h"
66 #include "printing/metafile_impl.h" 67 #include "printing/metafile_impl.h"
67 #include "printing/pdf_render_settings.h" 68 #include "printing/pdf_render_settings.h"
68 #include "printing/print_settings.h" 69 #include "printing/print_settings.h"
69 #include "printing/units.h" 70 #include "printing/units.h"
70 #include "third_party/icu/source/i18n/unicode/ulocdata.h" 71 #include "third_party/icu/source/i18n/unicode/ulocdata.h"
71 72
72 #if defined(OS_CHROMEOS) 73 #if defined(OS_CHROMEOS)
73 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" 74 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
74 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h " 75 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h "
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 base::ListValue* printers) { 280 base::ListValue* printers) {
280 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
281 282
282 VLOG(1) << "Enumerate printers start"; 283 VLOG(1) << "Enumerate printers start";
283 printing::PrinterList printer_list; 284 printing::PrinterList printer_list;
284 print_backend->EnumeratePrinters(&printer_list); 285 print_backend->EnumeratePrinters(&printer_list);
285 286
286 for (printing::PrinterList::iterator it = printer_list.begin(); 287 for (printing::PrinterList::iterator it = printer_list.begin();
287 it != printer_list.end(); ++it) { 288 it != printer_list.end(); ++it) {
288 base::DictionaryValue* printer_info = new base::DictionaryValue; 289 base::DictionaryValue* printer_info = new base::DictionaryValue;
290 printers->Append(printer_info);
289 std::string printer_name; 291 std::string printer_name;
292 std::string printer_description;
290 #if defined(OS_MACOSX) 293 #if defined(OS_MACOSX)
291 // On Mac, |it->printer_description| specifies the printer name and 294 // On Mac, |it->printer_description| specifies the printer name and
292 // |it->printer_name| specifies the device name / printer queue name. 295 // |it->printer_name| specifies the device name / printer queue name.
293 printer_name = it->printer_description; 296 printer_name = it->printer_description;
297 if (!it->options[kDriverNameTagName].empty())
298 printer_description = it->options[kDriverNameTagName];
294 #else 299 #else
295 printer_name = it->printer_name; 300 printer_name = it->printer_name;
301 printer_description = it->printer_description;
296 #endif 302 #endif
303 printer_info->SetString(printing::kSettingDeviceName, it->printer_name);
304 printer_info->SetString(printing::kSettingPrinterDescription,
305 printer_description);
297 printer_info->SetString(printing::kSettingPrinterName, printer_name); 306 printer_info->SetString(printing::kSettingPrinterName, printer_name);
298 printer_info->SetString(printing::kSettingDeviceName, it->printer_name);
299 VLOG(1) << "Found printer " << printer_name 307 VLOG(1) << "Found printer " << printer_name
300 << " with device name " << it->printer_name; 308 << " with device name " << it->printer_name;
301 printers->Append(printer_info); 309
310 base::DictionaryValue* options = new base::DictionaryValue;
311 printer_info->Set(printing::kSettingPrinterOptions, options);
312 for (std::map<std::string, std::string>::iterator opt = it->options.begin();
313 opt != it->options.end();
314 ++opt) {
315 options->SetString(opt->first, opt->second);
316 }
317
318 VLOG(1) << "Found printer " << printer_name << " with device name "
319 << it->printer_name;
302 } 320 }
303 VLOG(1) << "Enumerate printers finished, found " << printers->GetSize() 321 VLOG(1) << "Enumerate printers finished, found " << printers->GetSize()
304 << " printers"; 322 << " printers";
305 } 323 }
306 324
307 typedef base::Callback<void(const base::DictionaryValue*)> 325 typedef base::Callback<void(const base::DictionaryValue*)>
308 GetPrinterCapabilitiesSuccessCallback; 326 GetPrinterCapabilitiesSuccessCallback;
309 typedef base::Callback<void(const std::string&)> 327 typedef base::Callback<void(const std::string&)>
310 GetPrinterCapabilitiesFailureCallback; 328 GetPrinterCapabilitiesFailureCallback;
311 329
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 printer_value->SetString("name", description.name); 1564 printer_value->SetString("name", description.name);
1547 printer_value->SetBoolean("hasLocalPrinting", has_local_printing); 1565 printer_value->SetBoolean("hasLocalPrinting", has_local_printing);
1548 printer_value->SetBoolean( 1566 printer_value->SetBoolean(
1549 "isUnregistered", 1567 "isUnregistered",
1550 description.id.empty() && 1568 description.id.empty() &&
1551 command_line->HasSwitch(switches::kEnablePrintPreviewRegisterPromos)); 1569 command_line->HasSwitch(switches::kEnablePrintPreviewRegisterPromos));
1552 printer_value->SetString("cloudID", description.id); 1570 printer_value->SetString("cloudID", description.id);
1553 } 1571 }
1554 1572
1555 #endif 1573 #endif
OLDNEW
« no previous file with comments | « chrome/browser/resources/print_preview/data/local_parsers.js ('k') | printing/print_job_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698