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 <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1424 bool PrintPreviewHandler::PrivetUpdateClient( | 1424 bool PrintPreviewHandler::PrivetUpdateClient( |
1425 scoped_ptr<local_discovery::PrivetHTTPClient> http_client) { | 1425 scoped_ptr<local_discovery::PrivetHTTPClient> http_client) { |
1426 if (!http_client) { | 1426 if (!http_client) { |
1427 SendPrivetCapabilitiesError(privet_http_resolution_->GetName()); | 1427 SendPrivetCapabilitiesError(privet_http_resolution_->GetName()); |
1428 privet_http_resolution_.reset(); | 1428 privet_http_resolution_.reset(); |
1429 return false; | 1429 return false; |
1430 } | 1430 } |
1431 | 1431 |
1432 privet_local_print_operation_.reset(); | 1432 privet_local_print_operation_.reset(); |
1433 privet_capabilities_operation_.reset(); | 1433 privet_capabilities_operation_.reset(); |
1434 privet_http_client_ = http_client.Pass(); | 1434 privet_http_client_ = |
| 1435 local_discovery::PrivetV1HTTPClient::CreateDefault(http_client.Pass()); |
1435 | 1436 |
1436 privet_http_resolution_.reset(); | 1437 privet_http_resolution_.reset(); |
1437 | 1438 |
1438 return true; | 1439 return true; |
1439 } | 1440 } |
1440 | 1441 |
1441 void PrintPreviewHandler::PrivetLocalPrintUpdateClient( | 1442 void PrintPreviewHandler::PrivetLocalPrintUpdateClient( |
1442 std::string print_ticket, | 1443 std::string print_ticket, |
1443 std::string capabilities, | 1444 std::string capabilities, |
1444 gfx::Size page_size, | 1445 gfx::Size page_size, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1529 base::Bind(&PrintPreviewHandler::PrivetLocalPrintUpdateClient, | 1530 base::Bind(&PrintPreviewHandler::PrivetLocalPrintUpdateClient, |
1530 base::Unretained(this), | 1531 base::Unretained(this), |
1531 ticket, | 1532 ticket, |
1532 capabilities, | 1533 capabilities, |
1533 page_size)); | 1534 page_size)); |
1534 } | 1535 } |
1535 | 1536 |
1536 bool PrintPreviewHandler::CreatePrivetHTTP( | 1537 bool PrintPreviewHandler::CreatePrivetHTTP( |
1537 const std::string& name, | 1538 const std::string& name, |
1538 const local_discovery::PrivetHTTPAsynchronousFactory::ResultCallback& | 1539 const local_discovery::PrivetHTTPAsynchronousFactory::ResultCallback& |
1539 callback) { | 1540 callback) { |
1540 const local_discovery::DeviceDescription* device_description = | 1541 const local_discovery::DeviceDescription* device_description = |
1541 printer_lister_->GetDeviceDescription(name); | 1542 printer_lister_->GetDeviceDescription(name); |
1542 | 1543 |
1543 if (!device_description) { | 1544 if (!device_description) { |
1544 SendPrivetCapabilitiesError(name); | 1545 SendPrivetCapabilitiesError(name); |
1545 return false; | 1546 return false; |
1546 } | 1547 } |
1547 | 1548 |
1548 privet_http_factory_ = | 1549 privet_http_factory_ = |
1549 local_discovery::PrivetHTTPAsynchronousFactory::CreateInstance( | 1550 local_discovery::PrivetHTTPAsynchronousFactory::CreateInstance( |
1550 service_discovery_client_, | 1551 service_discovery_client_, |
1551 Profile::FromWebUI(web_ui())->GetRequestContext()); | 1552 Profile::FromWebUI(web_ui())->GetRequestContext()); |
1552 privet_http_resolution_ = privet_http_factory_->CreatePrivetHTTP( | 1553 privet_http_resolution_ = privet_http_factory_->CreatePrivetHTTP( |
1553 name, | 1554 name, device_description->address, callback); |
1554 device_description->address, | |
1555 callback); | |
1556 privet_http_resolution_->Start(); | 1555 privet_http_resolution_->Start(); |
1557 | 1556 |
1558 return true; | 1557 return true; |
1559 } | 1558 } |
1560 | 1559 |
1561 void PrintPreviewHandler::OnPrivetPrintingDone( | 1560 void PrintPreviewHandler::OnPrivetPrintingDone( |
1562 const local_discovery::PrivetLocalPrintOperation* print_operation) { | 1561 const local_discovery::PrivetLocalPrintOperation* print_operation) { |
1563 ClosePreviewDialog(); | 1562 ClosePreviewDialog(); |
1564 } | 1563 } |
1565 | 1564 |
(...skipping 15 matching lines...) Expand all Loading... |
1581 printer_value->SetString("name", description.name); | 1580 printer_value->SetString("name", description.name); |
1582 printer_value->SetBoolean("hasLocalPrinting", has_local_printing); | 1581 printer_value->SetBoolean("hasLocalPrinting", has_local_printing); |
1583 printer_value->SetBoolean( | 1582 printer_value->SetBoolean( |
1584 "isUnregistered", | 1583 "isUnregistered", |
1585 description.id.empty() && | 1584 description.id.empty() && |
1586 command_line->HasSwitch(switches::kEnablePrintPreviewRegisterPromos)); | 1585 command_line->HasSwitch(switches::kEnablePrintPreviewRegisterPromos)); |
1587 printer_value->SetString("cloudID", description.id); | 1586 printer_value->SetString("cloudID", description.id); |
1588 } | 1587 } |
1589 | 1588 |
1590 #endif // defined(ENABLE_SERVICE_DISCOVERY) | 1589 #endif // defined(ENABLE_SERVICE_DISCOVERY) |
OLD | NEW |