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 "extensions/browser/api/printer_provider/printer_provider_api.h" | 5 #include "extensions/browser/api/printer_provider/printer_provider_api.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 int request_id, | 272 int request_id, |
273 api::printer_provider_internal::PrintError error) override; | 273 api::printer_provider_internal::PrintError error) override; |
274 void OnGetUsbPrinterInfoResult( | 274 void OnGetUsbPrinterInfoResult( |
275 const Extension* extension, | 275 const Extension* extension, |
276 int request_id, | 276 int request_id, |
277 const api::printer_provider::PrinterInfo* printer_info) override; | 277 const api::printer_provider::PrinterInfo* printer_info) override; |
278 | 278 |
279 // ExtensionRegistryObserver implementation: | 279 // ExtensionRegistryObserver implementation: |
280 void OnExtensionUnloaded(content::BrowserContext* browser_context, | 280 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
281 const Extension* extension, | 281 const Extension* extension, |
282 UnloadedExtensionInfo::Reason reason) override; | 282 UnloadedExtensionReason reason) override; |
283 | 283 |
284 // Called before chrome.printerProvider.onGetPrintersRequested event is | 284 // Called before chrome.printerProvider.onGetPrintersRequested event is |
285 // dispatched to an extension. It returns whether the extension is interested | 285 // dispatched to an extension. It returns whether the extension is interested |
286 // in the event. If the extension listens to the event, it's added to the set | 286 // in the event. If the extension listens to the event, it's added to the set |
287 // of |request| sources. |request| is |GetPrintersRequest| object associated | 287 // of |request| sources. |request| is |GetPrintersRequest| object associated |
288 // with the event. | 288 // with the event. |
289 bool WillRequestPrinters(int request_id, | 289 bool WillRequestPrinters(int request_id, |
290 content::BrowserContext* browser_context, | 290 content::BrowserContext* browser_context, |
291 const Extension* extension, | 291 const Extension* extension, |
292 Event* event, | 292 Event* event, |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 *printer); | 709 *printer); |
710 } else { | 710 } else { |
711 pending_usb_printer_info_requests_[extension->id()].Complete( | 711 pending_usb_printer_info_requests_[extension->id()].Complete( |
712 request_id, base::DictionaryValue()); | 712 request_id, base::DictionaryValue()); |
713 } | 713 } |
714 } | 714 } |
715 | 715 |
716 void PrinterProviderAPIImpl::OnExtensionUnloaded( | 716 void PrinterProviderAPIImpl::OnExtensionUnloaded( |
717 content::BrowserContext* browser_context, | 717 content::BrowserContext* browser_context, |
718 const Extension* extension, | 718 const Extension* extension, |
719 UnloadedExtensionInfo::Reason reason) { | 719 UnloadedExtensionReason reason) { |
720 pending_get_printers_requests_.FailAllForExtension(extension->id()); | 720 pending_get_printers_requests_.FailAllForExtension(extension->id()); |
721 | 721 |
722 auto print_it = pending_print_requests_.find(extension->id()); | 722 auto print_it = pending_print_requests_.find(extension->id()); |
723 if (print_it != pending_print_requests_.end()) { | 723 if (print_it != pending_print_requests_.end()) { |
724 print_it->second.FailAll(); | 724 print_it->second.FailAll(); |
725 pending_print_requests_.erase(print_it); | 725 pending_print_requests_.erase(print_it); |
726 } | 726 } |
727 | 727 |
728 auto capability_it = pending_capability_requests_.find(extension->id()); | 728 auto capability_it = pending_capability_requests_.find(extension->id()); |
729 if (capability_it != pending_capability_requests_.end()) { | 729 if (capability_it != pending_capability_requests_.end()) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 return new PrinterProviderAPIImpl(context); | 764 return new PrinterProviderAPIImpl(context); |
765 } | 765 } |
766 | 766 |
767 // static | 767 // static |
768 std::string PrinterProviderAPI::GetDefaultPrintError() { | 768 std::string PrinterProviderAPI::GetDefaultPrintError() { |
769 return api::printer_provider_internal::ToString( | 769 return api::printer_provider_internal::ToString( |
770 api::printer_provider_internal::PRINT_ERROR_FAILED); | 770 api::printer_provider_internal::PRINT_ERROR_FAILED); |
771 } | 771 } |
772 | 772 |
773 } // namespace extensions | 773 } // namespace extensions |
OLD | NEW |