Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1053)

Unified Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 10083059: [Print Preview] Modified PP_PrintSettings_Dev interface to support auto fit to page functionality. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/plugins/ppapi/ppapi_plugin_instance.cc
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 0c42e1d8764bc17df40aad4090d64ae2eb2b7a72..1f49191c806e94413d8e1d9c476dc45c06c85efd 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -121,6 +121,7 @@ using WebKit::WebFrame;
using WebKit::WebInputEvent;
using WebKit::WebPlugin;
using WebKit::WebPluginContainer;
+using WebKit::WebPrintScalingOption;
using WebKit::WebScopedUserGesture;
using WebKit::WebString;
using WebKit::WebURLRequest;
@@ -163,6 +164,11 @@ const ui::TextInputType kPluginDefaultTextInputType = ui::TEXT_INPUT_TYPE_TEXT;
== static_cast<int>(np_name), \
mismatching_enums)
+#define COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(webkit_name, pp_name) \
+ COMPILE_ASSERT(static_cast<int>(webkit_name) \
+ == static_cast<int>(pp_name), \
+ mismatching_enums)
+
// <embed>/<object> attributes.
const char kWidth[] = "width";
const char kHeight[] = "height";
@@ -232,6 +238,14 @@ COMPILE_ASSERT_MATCHING_ENUM(TypeGrabbing, PP_MOUSECURSOR_TYPE_GRABBING);
// Do not assert WebCursorInfo::TypeCustom == PP_CURSORTYPE_CUSTOM;
// PP_CURSORTYPE_CUSTOM is pinned to allow new cursor types.
+COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(WebKit::WebPrintScaleNone,
+ PP_PRINTSCALINGOPTION_NONE);
+COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(
+ WebKit::WebPrintFitToPrintableArea,
+ PP_PRINTSCALINGOPTION_FIT_TO_PRINTABLE_AREA);
+COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(WebKit::WebPrintSourceSize,
+ PP_PRINTSCALINGOPTION_SOURCE_SIZE);
+
// Sets |*security_origin| to be the WebKit security origin associated with the
// document containing the given plugin instance. On success, returns true. If
// the instance is invalid, returns false and |*security_origin| will be
@@ -1135,7 +1149,10 @@ bool PluginInstance::IsPrintScalingDisabled() {
return plugin_print_interface_->IsScalingDisabled(pp_instance()) == PP_TRUE;
}
-int PluginInstance::PrintBegin(const gfx::Rect& printable_area,
+int PluginInstance::PrintBegin(const gfx::Rect& content_area,
+ const gfx::Rect& printable_area,
+ const gfx::Size& paper_size,
+ WebPrintScalingOption print_scaling_option,
int printer_dpi) {
// Keep a reference on the stack. See NOTE above.
scoped_refptr<PluginInstance> ref(this);
@@ -1146,13 +1163,16 @@ int PluginInstance::PrintBegin(const gfx::Rect& printable_area,
NOTREACHED();
return 0;
}
-
int num_pages = 0;
PP_PrintSettings_Dev print_settings;
print_settings.printable_area = PP_FromGfxRect(printable_area);
+ print_settings.content_area = PP_FromGfxRect(content_area);
+ print_settings.paper_size = PP_FromGfxSize(paper_size);
print_settings.dpi = printer_dpi;
print_settings.orientation = PP_PRINTORIENTATION_NORMAL;
print_settings.grayscale = PP_FALSE;
+ print_settings.print_scaling_option = static_cast<PP_PrintScalingOption_Dev>(
+ print_scaling_option);
print_settings.format = format;
num_pages = plugin_print_interface_->Begin(pp_instance(),
&print_settings);

Powered by Google App Engine
This is Rietveld 408576698