| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 return true; | 1013 return true; |
| 1014 } | 1014 } |
| 1015 return false; | 1015 return false; |
| 1016 } | 1016 } |
| 1017 | 1017 |
| 1018 bool PluginInstance::SupportsPrintInterface() { | 1018 bool PluginInstance::SupportsPrintInterface() { |
| 1019 PP_PrintOutputFormat_Dev format; | 1019 PP_PrintOutputFormat_Dev format; |
| 1020 return GetPreferredPrintOutputFormat(&format); | 1020 return GetPreferredPrintOutputFormat(&format); |
| 1021 } | 1021 } |
| 1022 | 1022 |
| 1023 bool PluginInstance::IsPrintScalingDisabled() { |
| 1024 DCHECK(plugin_print_interface_); |
| 1025 if (!plugin_print_interface_) |
| 1026 return false; |
| 1027 return plugin_print_interface_->IsScalingDisabled(pp_instance()) == PP_TRUE; |
| 1028 } |
| 1029 |
| 1023 int PluginInstance::PrintBegin(const gfx::Rect& printable_area, | 1030 int PluginInstance::PrintBegin(const gfx::Rect& printable_area, |
| 1024 int printer_dpi) { | 1031 int printer_dpi) { |
| 1025 // Keep a reference on the stack. See NOTE above. | 1032 // Keep a reference on the stack. See NOTE above. |
| 1026 scoped_refptr<PluginInstance> ref(this); | 1033 scoped_refptr<PluginInstance> ref(this); |
| 1027 PP_PrintOutputFormat_Dev format; | 1034 PP_PrintOutputFormat_Dev format; |
| 1028 if (!GetPreferredPrintOutputFormat(&format)) { | 1035 if (!GetPreferredPrintOutputFormat(&format)) { |
| 1029 // PrintBegin should not have been called since SupportsPrintInterface | 1036 // PrintBegin should not have been called since SupportsPrintInterface |
| 1030 // would have returned false; | 1037 // would have returned false; |
| 1031 NOTREACHED(); | 1038 NOTREACHED(); |
| 1032 return 0; | 1039 return 0; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 { | 1078 { |
| 1072 return PrintPageHelper(&page_range, 1, canvas); | 1079 return PrintPageHelper(&page_range, 1, canvas); |
| 1073 } | 1080 } |
| 1074 } | 1081 } |
| 1075 | 1082 |
| 1076 bool PluginInstance::PrintPageHelper(PP_PrintPageNumberRange_Dev* page_ranges, | 1083 bool PluginInstance::PrintPageHelper(PP_PrintPageNumberRange_Dev* page_ranges, |
| 1077 int num_ranges, | 1084 int num_ranges, |
| 1078 WebKit::WebCanvas* canvas) { | 1085 WebKit::WebCanvas* canvas) { |
| 1079 // Keep a reference on the stack. See NOTE above. | 1086 // Keep a reference on the stack. See NOTE above. |
| 1080 scoped_refptr<PluginInstance> ref(this); | 1087 scoped_refptr<PluginInstance> ref(this); |
| 1088 DCHECK(plugin_print_interface_); |
| 1089 if (!plugin_print_interface_) |
| 1090 return false; |
| 1081 PP_Resource print_output = plugin_print_interface_->PrintPages( | 1091 PP_Resource print_output = plugin_print_interface_->PrintPages( |
| 1082 pp_instance(), page_ranges, num_ranges); | 1092 pp_instance(), page_ranges, num_ranges); |
| 1083 if (!print_output) | 1093 if (!print_output) |
| 1084 return false; | 1094 return false; |
| 1085 | 1095 |
| 1086 bool ret = false; | 1096 bool ret = false; |
| 1087 | 1097 |
| 1088 if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_PDF) | 1098 if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_PDF) |
| 1089 ret = PrintPDFOutput(print_output, canvas); | 1099 ret = PrintPDFOutput(print_output, canvas); |
| 1090 else if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_RASTER) | 1100 else if (current_print_settings_.format == PP_PRINTOUTPUTFORMAT_RASTER) |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1968 } | 1978 } |
| 1969 WebKit::WebDocument main_document = | 1979 WebKit::WebDocument main_document = |
| 1970 containing_document.frame()->view()->mainFrame()->document(); | 1980 containing_document.frame()->view()->mainFrame()->document(); |
| 1971 | 1981 |
| 1972 return containing_document.securityOrigin().canAccess( | 1982 return containing_document.securityOrigin().canAccess( |
| 1973 main_document.securityOrigin()); | 1983 main_document.securityOrigin()); |
| 1974 } | 1984 } |
| 1975 | 1985 |
| 1976 } // namespace ppapi | 1986 } // namespace ppapi |
| 1977 } // namespace webkit | 1987 } // namespace webkit |
| OLD | NEW |