OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/extension_printer_handler.h" | 5 #include "chrome/browser/ui/webui/print_preview/extension_printer_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 std::string GenerateProvisionalUsbPrinterId(const Extension* extension, | 97 std::string GenerateProvisionalUsbPrinterId(const Extension* extension, |
98 const UsbDevice* device) { | 98 const UsbDevice* device) { |
99 return base::StringPrintf("%s:%s:%s", kProvisionalUsbLabel, | 99 return base::StringPrintf("%s:%s:%s", kProvisionalUsbLabel, |
100 extension->id().c_str(), device->guid().c_str()); | 100 extension->id().c_str(), device->guid().c_str()); |
101 } | 101 } |
102 | 102 |
103 bool ParseProvisionalUsbPrinterId(const std::string& printer_id, | 103 bool ParseProvisionalUsbPrinterId(const std::string& printer_id, |
104 std::string* extension_id, | 104 std::string* extension_id, |
105 std::string* device_guid) { | 105 std::string* device_guid) { |
106 std::vector<std::string> components; | 106 std::vector<std::string> components = base::SplitString( |
107 base::SplitString(printer_id, ':', &components); | 107 printer_id, ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
108 | 108 |
109 if (components.size() != 3) | 109 if (components.size() != 3) |
110 return false; | 110 return false; |
111 | 111 |
112 if (components[0] != kProvisionalUsbLabel) | 112 if (components[0] != kProvisionalUsbLabel) |
113 return false; | 113 return false; |
114 | 114 |
115 *extension_id = components[1]; | 115 *extension_id = components[1]; |
116 *device_guid = components[2]; | 116 *device_guid = components[2]; |
117 return true; | 117 return true; |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 .Set("extensionName", extension->name()) | 364 .Set("extensionName", extension->name()) |
365 .Set("provisional", true)); | 365 .Set("provisional", true)); |
366 } | 366 } |
367 } | 367 } |
368 } | 368 } |
369 | 369 |
370 DCHECK_GT(pending_enumeration_count_, 0); | 370 DCHECK_GT(pending_enumeration_count_, 0); |
371 pending_enumeration_count_--; | 371 pending_enumeration_count_--; |
372 callback.Run(*printer_list.Build().get(), pending_enumeration_count_ == 0); | 372 callback.Run(*printer_list.Build().get(), pending_enumeration_count_ == 0); |
373 } | 373 } |
OLD | NEW |