| 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_internal/printer_provider_inte
rnal_api.h" | 5 #include "extensions/browser/api/printer_provider_internal/printer_provider_inte
rnal_api.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/guid.h" | 11 #include "base/guid.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/memory/ref_counted_memory.h" | 14 #include "base/memory/ref_counted_memory.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "content/public/browser/blob_handle.h" | 17 #include "content/public/browser/blob_handle.h" |
| 18 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
| 19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/render_frame_host.h" | 20 #include "content/public/browser/render_frame_host.h" |
| 21 #include "content/public/browser/render_process_host.h" | 21 #include "content/public/browser/render_process_host.h" |
| 22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 23 #include "extensions/browser/api/printer_provider/printer_provider_api.h" | 23 #include "extensions/browser/api/printer_provider/printer_provider_api.h" |
| 24 #include "extensions/browser/api/printer_provider/printer_provider_api_factory.h
" | 24 #include "extensions/browser/api/printer_provider/printer_provider_api_factory.h
" |
| 25 #include "extensions/browser/api/printer_provider/printer_provider_print_job.h" | 25 #include "extensions/browser/api/printer_provider/printer_provider_print_job.h" |
| 26 #include "extensions/browser/blob_holder.h" | 26 #include "extensions/browser/blob_holder.h" |
| 27 #include "extensions/common/api/printer_provider.h" | 27 #include "extensions/common/api/printer_provider.h" |
| 28 #include "extensions/common/api/printer_provider_internal.h" | 28 #include "extensions/common/api/printer_provider_internal.h" |
| 29 | 29 |
| 30 namespace internal_api = extensions::core_api::printer_provider_internal; | 30 namespace internal_api = extensions::api::printer_provider_internal; |
| 31 | 31 |
| 32 namespace extensions { | 32 namespace extensions { |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 static base::LazyInstance< | 36 static base::LazyInstance< |
| 37 BrowserContextKeyedAPIFactory<PrinterProviderInternalAPI>> g_api_factory = | 37 BrowserContextKeyedAPIFactory<PrinterProviderInternalAPI>> g_api_factory = |
| 38 LAZY_INSTANCE_INITIALIZER; | 38 LAZY_INSTANCE_INITIALIZER; |
| 39 | 39 |
| 40 } // namespace | 40 } // namespace |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 const Extension* extension, | 74 const Extension* extension, |
| 75 int request_id, | 75 int request_id, |
| 76 const base::DictionaryValue& capability) { | 76 const base::DictionaryValue& capability) { |
| 77 FOR_EACH_OBSERVER(PrinterProviderInternalAPIObserver, observers_, | 77 FOR_EACH_OBSERVER(PrinterProviderInternalAPIObserver, observers_, |
| 78 OnGetCapabilityResult(extension, request_id, capability)); | 78 OnGetCapabilityResult(extension, request_id, capability)); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void PrinterProviderInternalAPI::NotifyPrintResult( | 81 void PrinterProviderInternalAPI::NotifyPrintResult( |
| 82 const Extension* extension, | 82 const Extension* extension, |
| 83 int request_id, | 83 int request_id, |
| 84 core_api::printer_provider_internal::PrintError error) { | 84 api::printer_provider_internal::PrintError error) { |
| 85 FOR_EACH_OBSERVER(PrinterProviderInternalAPIObserver, observers_, | 85 FOR_EACH_OBSERVER(PrinterProviderInternalAPIObserver, observers_, |
| 86 OnPrintResult(extension, request_id, error)); | 86 OnPrintResult(extension, request_id, error)); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void PrinterProviderInternalAPI::NotifyGetUsbPrinterInfoResult( | 89 void PrinterProviderInternalAPI::NotifyGetUsbPrinterInfoResult( |
| 90 const Extension* extension, | 90 const Extension* extension, |
| 91 int request_id, | 91 int request_id, |
| 92 const core_api::printer_provider::PrinterInfo* printer_info) { | 92 const api::printer_provider::PrinterInfo* printer_info) { |
| 93 FOR_EACH_OBSERVER( | 93 FOR_EACH_OBSERVER( |
| 94 PrinterProviderInternalAPIObserver, observers_, | 94 PrinterProviderInternalAPIObserver, observers_, |
| 95 OnGetUsbPrinterInfoResult(extension, request_id, printer_info)); | 95 OnGetUsbPrinterInfoResult(extension, request_id, printer_info)); |
| 96 } | 96 } |
| 97 | 97 |
| 98 PrinterProviderInternalReportPrintResultFunction:: | 98 PrinterProviderInternalReportPrintResultFunction:: |
| 99 PrinterProviderInternalReportPrintResultFunction() { | 99 PrinterProviderInternalReportPrintResultFunction() { |
| 100 } | 100 } |
| 101 | 101 |
| 102 PrinterProviderInternalReportPrintResultFunction:: | 102 PrinterProviderInternalReportPrintResultFunction:: |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 EXTENSION_FUNCTION_VALIDATE(params.get()); | 260 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 261 | 261 |
| 262 PrinterProviderInternalAPI::GetFactoryInstance() | 262 PrinterProviderInternalAPI::GetFactoryInstance() |
| 263 ->Get(browser_context()) | 263 ->Get(browser_context()) |
| 264 ->NotifyGetUsbPrinterInfoResult(extension(), params->request_id, | 264 ->NotifyGetUsbPrinterInfoResult(extension(), params->request_id, |
| 265 params->printer_info.get()); | 265 params->printer_info.get()); |
| 266 return RespondNow(NoArguments()); | 266 return RespondNow(NoArguments()); |
| 267 } | 267 } |
| 268 | 268 |
| 269 } // namespace extensions | 269 } // namespace extensions |
| OLD | NEW |