OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 #include "third_party/skia/include/core/SkRect.h" | 43 #include "third_party/skia/include/core/SkRect.h" |
44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli ne.h" | 45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderli ne.h" |
46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 46 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 49 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
50 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGamepads. h" | 50 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGamepads. h" |
51 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 51 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
52 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 52 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
53 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPrintParams.h" | |
54 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPrintScalingOption .h" | |
53 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScopedUserGesture. h" | 55 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScopedUserGesture. h" |
54 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 56 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
55 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 57 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
56 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 58 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
57 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques t.h" | 59 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques t.h" |
58 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 60 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
59 #include "ui/base/range/range.h" | 61 #include "ui/base/range/range.h" |
60 #include "webkit/plugins/plugin_constants.h" | 62 #include "webkit/plugins/plugin_constants.h" |
61 #include "webkit/plugins/ppapi/common.h" | 63 #include "webkit/plugins/ppapi/common.h" |
62 #include "webkit/plugins/ppapi/event_conversion.h" | 64 #include "webkit/plugins/ppapi/event_conversion.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 using ppapi::ViewData; | 115 using ppapi::ViewData; |
114 using WebKit::WebBindings; | 116 using WebKit::WebBindings; |
115 using WebKit::WebCanvas; | 117 using WebKit::WebCanvas; |
116 using WebKit::WebCursorInfo; | 118 using WebKit::WebCursorInfo; |
117 using WebKit::WebDocument; | 119 using WebKit::WebDocument; |
118 using WebKit::WebElement; | 120 using WebKit::WebElement; |
119 using WebKit::WebFrame; | 121 using WebKit::WebFrame; |
120 using WebKit::WebInputEvent; | 122 using WebKit::WebInputEvent; |
121 using WebKit::WebPlugin; | 123 using WebKit::WebPlugin; |
122 using WebKit::WebPluginContainer; | 124 using WebKit::WebPluginContainer; |
125 using WebKit::WebPrintScalingOption; | |
126 using WebKit::WebPrintParams; | |
dmichael (off chromium)
2012/05/14 17:16:39
nit: these should be in alphabetical order
kmadhusu
2012/05/14 18:00:33
Done.
| |
123 using WebKit::WebScopedUserGesture; | 127 using WebKit::WebScopedUserGesture; |
124 using WebKit::WebString; | 128 using WebKit::WebString; |
125 using WebKit::WebURLRequest; | 129 using WebKit::WebURLRequest; |
126 using WebKit::WebView; | 130 using WebKit::WebView; |
127 | 131 |
128 namespace webkit { | 132 namespace webkit { |
129 namespace ppapi { | 133 namespace ppapi { |
130 | 134 |
131 #if defined(OS_WIN) | 135 #if defined(OS_WIN) |
132 // Exported by pdf.dll | 136 // Exported by pdf.dll |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 // unaware plugins (e.g., PPAPI Flash or PDF plugin for M16). | 177 // unaware plugins (e.g., PPAPI Flash or PDF plugin for M16). |
174 // Plugins need to explicitly opt out the text input mode if they know | 178 // Plugins need to explicitly opt out the text input mode if they know |
175 // that they don't accept texts. | 179 // that they don't accept texts. |
176 const ui::TextInputType kPluginDefaultTextInputType = ui::TEXT_INPUT_TYPE_TEXT; | 180 const ui::TextInputType kPluginDefaultTextInputType = ui::TEXT_INPUT_TYPE_TEXT; |
177 | 181 |
178 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, np_name) \ | 182 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, np_name) \ |
179 COMPILE_ASSERT(static_cast<int>(WebCursorInfo::webkit_name) \ | 183 COMPILE_ASSERT(static_cast<int>(WebCursorInfo::webkit_name) \ |
180 == static_cast<int>(np_name), \ | 184 == static_cast<int>(np_name), \ |
181 mismatching_enums) | 185 mismatching_enums) |
182 | 186 |
187 #define COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(webkit_name, pp_name) \ | |
188 COMPILE_ASSERT(static_cast<int>(webkit_name) \ | |
189 == static_cast<int>(pp_name), \ | |
190 mismatching_enums) | |
191 | |
183 // <embed>/<object> attributes. | 192 // <embed>/<object> attributes. |
184 const char kWidth[] = "width"; | 193 const char kWidth[] = "width"; |
185 const char kHeight[] = "height"; | 194 const char kHeight[] = "height"; |
186 const char kBorder[] = "border"; // According to w3c, deprecated. | 195 const char kBorder[] = "border"; // According to w3c, deprecated. |
187 const char kStyle[] = "style"; | 196 const char kStyle[] = "style"; |
188 | 197 |
189 COMPILE_ASSERT_MATCHING_ENUM(TypePointer, PP_MOUSECURSOR_TYPE_POINTER); | 198 COMPILE_ASSERT_MATCHING_ENUM(TypePointer, PP_MOUSECURSOR_TYPE_POINTER); |
190 COMPILE_ASSERT_MATCHING_ENUM(TypeCross, PP_MOUSECURSOR_TYPE_CROSS); | 199 COMPILE_ASSERT_MATCHING_ENUM(TypeCross, PP_MOUSECURSOR_TYPE_CROSS); |
191 COMPILE_ASSERT_MATCHING_ENUM(TypeHand, PP_MOUSECURSOR_TYPE_HAND); | 200 COMPILE_ASSERT_MATCHING_ENUM(TypeHand, PP_MOUSECURSOR_TYPE_HAND); |
192 COMPILE_ASSERT_MATCHING_ENUM(TypeIBeam, PP_MOUSECURSOR_TYPE_IBEAM); | 201 COMPILE_ASSERT_MATCHING_ENUM(TypeIBeam, PP_MOUSECURSOR_TYPE_IBEAM); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 COMPILE_ASSERT_MATCHING_ENUM(TypeCopy, PP_MOUSECURSOR_TYPE_COPY); | 251 COMPILE_ASSERT_MATCHING_ENUM(TypeCopy, PP_MOUSECURSOR_TYPE_COPY); |
243 COMPILE_ASSERT_MATCHING_ENUM(TypeNone, PP_MOUSECURSOR_TYPE_NONE); | 252 COMPILE_ASSERT_MATCHING_ENUM(TypeNone, PP_MOUSECURSOR_TYPE_NONE); |
244 COMPILE_ASSERT_MATCHING_ENUM(TypeNotAllowed, PP_MOUSECURSOR_TYPE_NOTALLOWED); | 253 COMPILE_ASSERT_MATCHING_ENUM(TypeNotAllowed, PP_MOUSECURSOR_TYPE_NOTALLOWED); |
245 COMPILE_ASSERT_MATCHING_ENUM(TypeZoomIn, PP_MOUSECURSOR_TYPE_ZOOMIN); | 254 COMPILE_ASSERT_MATCHING_ENUM(TypeZoomIn, PP_MOUSECURSOR_TYPE_ZOOMIN); |
246 COMPILE_ASSERT_MATCHING_ENUM(TypeZoomOut, PP_MOUSECURSOR_TYPE_ZOOMOUT); | 255 COMPILE_ASSERT_MATCHING_ENUM(TypeZoomOut, PP_MOUSECURSOR_TYPE_ZOOMOUT); |
247 COMPILE_ASSERT_MATCHING_ENUM(TypeGrab, PP_MOUSECURSOR_TYPE_GRAB); | 256 COMPILE_ASSERT_MATCHING_ENUM(TypeGrab, PP_MOUSECURSOR_TYPE_GRAB); |
248 COMPILE_ASSERT_MATCHING_ENUM(TypeGrabbing, PP_MOUSECURSOR_TYPE_GRABBING); | 257 COMPILE_ASSERT_MATCHING_ENUM(TypeGrabbing, PP_MOUSECURSOR_TYPE_GRABBING); |
249 // Do not assert WebCursorInfo::TypeCustom == PP_CURSORTYPE_CUSTOM; | 258 // Do not assert WebCursorInfo::TypeCustom == PP_CURSORTYPE_CUSTOM; |
250 // PP_CURSORTYPE_CUSTOM is pinned to allow new cursor types. | 259 // PP_CURSORTYPE_CUSTOM is pinned to allow new cursor types. |
251 | 260 |
261 COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(WebKit::WebPrintScalingOptionNone, | |
262 PP_PRINTSCALINGOPTION_NONE); | |
263 COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM( | |
264 WebKit::WebPrintScalingOptionFitToPrintableArea, | |
265 PP_PRINTSCALINGOPTION_FIT_TO_PRINTABLE_AREA); | |
266 COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM( | |
267 WebKit::WebPrintScalingOptionSourceSize, PP_PRINTSCALINGOPTION_SOURCE_SIZE); | |
268 | |
252 // Sets |*security_origin| to be the WebKit security origin associated with the | 269 // Sets |*security_origin| to be the WebKit security origin associated with the |
253 // document containing the given plugin instance. On success, returns true. If | 270 // document containing the given plugin instance. On success, returns true. If |
254 // the instance is invalid, returns false and |*security_origin| will be | 271 // the instance is invalid, returns false and |*security_origin| will be |
255 // unchanged. | 272 // unchanged. |
256 bool SecurityOriginForInstance(PP_Instance instance_id, | 273 bool SecurityOriginForInstance(PP_Instance instance_id, |
257 WebKit::WebSecurityOrigin* security_origin) { | 274 WebKit::WebSecurityOrigin* security_origin) { |
258 PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id); | 275 PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id); |
259 if (!instance) | 276 if (!instance) |
260 return false; | 277 return false; |
261 | 278 |
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1111 return GetPreferredPrintOutputFormat(&format); | 1128 return GetPreferredPrintOutputFormat(&format); |
1112 } | 1129 } |
1113 | 1130 |
1114 bool PluginInstance::IsPrintScalingDisabled() { | 1131 bool PluginInstance::IsPrintScalingDisabled() { |
1115 DCHECK(plugin_print_interface_); | 1132 DCHECK(plugin_print_interface_); |
1116 if (!plugin_print_interface_) | 1133 if (!plugin_print_interface_) |
1117 return false; | 1134 return false; |
1118 return plugin_print_interface_->IsScalingDisabled(pp_instance()) == PP_TRUE; | 1135 return plugin_print_interface_->IsScalingDisabled(pp_instance()) == PP_TRUE; |
1119 } | 1136 } |
1120 | 1137 |
1121 int PluginInstance::PrintBegin(const gfx::Rect& printable_area, | 1138 int PluginInstance::PrintBegin(const WebPrintParams& print_params) { |
1122 int printer_dpi) { | |
1123 // Keep a reference on the stack. See NOTE above. | 1139 // Keep a reference on the stack. See NOTE above. |
1124 scoped_refptr<PluginInstance> ref(this); | 1140 scoped_refptr<PluginInstance> ref(this); |
1125 PP_PrintOutputFormat_Dev format; | 1141 PP_PrintOutputFormat_Dev format; |
1126 if (!GetPreferredPrintOutputFormat(&format)) { | 1142 if (!GetPreferredPrintOutputFormat(&format)) { |
1127 // PrintBegin should not have been called since SupportsPrintInterface | 1143 // PrintBegin should not have been called since SupportsPrintInterface |
1128 // would have returned false; | 1144 // would have returned false; |
1129 NOTREACHED(); | 1145 NOTREACHED(); |
1130 return 0; | 1146 return 0; |
1131 } | 1147 } |
1132 | |
1133 int num_pages = 0; | 1148 int num_pages = 0; |
1134 PP_PrintSettings_Dev print_settings; | 1149 PP_PrintSettings_Dev print_settings; |
1135 print_settings.printable_area = PP_FromGfxRect(printable_area); | 1150 print_settings.printable_area = PP_FromGfxRect(print_params.printableArea); |
1136 print_settings.dpi = printer_dpi; | 1151 print_settings.content_area = PP_FromGfxRect(print_params.printContentArea); |
1152 print_settings.paper_size = PP_FromGfxSize(print_params.paperSize); | |
1153 print_settings.dpi = print_params.printerDPI; | |
1137 print_settings.orientation = PP_PRINTORIENTATION_NORMAL; | 1154 print_settings.orientation = PP_PRINTORIENTATION_NORMAL; |
1138 print_settings.grayscale = PP_FALSE; | 1155 print_settings.grayscale = PP_FALSE; |
1156 print_settings.print_scaling_option = static_cast<PP_PrintScalingOption_Dev>( | |
1157 print_params.printScalingOption); | |
1139 print_settings.format = format; | 1158 print_settings.format = format; |
1140 num_pages = plugin_print_interface_->Begin(pp_instance(), | 1159 num_pages = plugin_print_interface_->Begin(pp_instance(), |
1141 &print_settings); | 1160 &print_settings); |
1142 if (!num_pages) | 1161 if (!num_pages) |
1143 return 0; | 1162 return 0; |
1144 current_print_settings_ = print_settings; | 1163 current_print_settings_ = print_settings; |
1145 #if defined(USE_SKIA) | 1164 #if defined(USE_SKIA) |
1146 canvas_ = NULL; | 1165 canvas_ = NULL; |
1147 ranges_.clear(); | 1166 ranges_.clear(); |
1148 #endif // USE_SKIA | 1167 #endif // USE_SKIA |
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2071 screen_size_for_fullscreen_ = gfx::Size(); | 2090 screen_size_for_fullscreen_ = gfx::Size(); |
2072 WebElement element = container_->element(); | 2091 WebElement element = container_->element(); |
2073 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2092 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
2074 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2093 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
2075 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2094 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
2076 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2095 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
2077 } | 2096 } |
2078 | 2097 |
2079 } // namespace ppapi | 2098 } // namespace ppapi |
2080 } // namespace webkit | 2099 } // namespace webkit |
OLD | NEW |