OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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); | |
Noam Samuel
2014/03/28 18:19:31
Why move this here? IMO this makes what's happenin
Vitaly Buka (NO REVIEWS)
2014/03/28 18:23:04
Why?
now it's just created and attached to the dic
Noam Samuel
2014/03/28 18:24:10
Oh, OK. Seems reasonable.
| |
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); | |
Noam Samuel
2014/03/28 18:19:31
Ditto
| |
312 for (std::map<std::string, std::string>::iterator opt = it->options.begin(); | |
313 opt != it->options.end(); ++opt) { | |
314 options->SetString(opt->first, opt->second); | |
315 } | |
316 | |
317 VLOG(1) << "Found printer " << printer_name | |
318 << " with device name " << it->printer_name; | |
Aleksey Shlyapnikov
2014/03/28 20:26:16
This line should be indented more.
| |
302 } | 319 } |
303 VLOG(1) << "Enumerate printers finished, found " << printers->GetSize() | 320 VLOG(1) << "Enumerate printers finished, found " << printers->GetSize() |
304 << " printers"; | 321 << " printers"; |
305 } | 322 } |
306 | 323 |
307 typedef base::Callback<void(const base::DictionaryValue*)> | 324 typedef base::Callback<void(const base::DictionaryValue*)> |
308 GetPrinterCapabilitiesSuccessCallback; | 325 GetPrinterCapabilitiesSuccessCallback; |
309 typedef base::Callback<void(const std::string&)> | 326 typedef base::Callback<void(const std::string&)> |
310 GetPrinterCapabilitiesFailureCallback; | 327 GetPrinterCapabilitiesFailureCallback; |
311 | 328 |
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1546 printer_value->SetString("name", description.name); | 1563 printer_value->SetString("name", description.name); |
1547 printer_value->SetBoolean("hasLocalPrinting", has_local_printing); | 1564 printer_value->SetBoolean("hasLocalPrinting", has_local_printing); |
1548 printer_value->SetBoolean( | 1565 printer_value->SetBoolean( |
1549 "isUnregistered", | 1566 "isUnregistered", |
1550 description.id.empty() && | 1567 description.id.empty() && |
1551 command_line->HasSwitch(switches::kEnablePrintPreviewRegisterPromos)); | 1568 command_line->HasSwitch(switches::kEnablePrintPreviewRegisterPromos)); |
1552 printer_value->SetString("cloudID", description.id); | 1569 printer_value->SetString("cloudID", description.id); |
1553 } | 1570 } |
1554 | 1571 |
1555 #endif | 1572 #endif |
OLD | NEW |