| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 using ppapi::ViewData; | 114 using ppapi::ViewData; |
| 115 using WebKit::WebBindings; | 115 using WebKit::WebBindings; |
| 116 using WebKit::WebCanvas; | 116 using WebKit::WebCanvas; |
| 117 using WebKit::WebCursorInfo; | 117 using WebKit::WebCursorInfo; |
| 118 using WebKit::WebDocument; | 118 using WebKit::WebDocument; |
| 119 using WebKit::WebElement; | 119 using WebKit::WebElement; |
| 120 using WebKit::WebFrame; | 120 using WebKit::WebFrame; |
| 121 using WebKit::WebInputEvent; | 121 using WebKit::WebInputEvent; |
| 122 using WebKit::WebPlugin; | 122 using WebKit::WebPlugin; |
| 123 using WebKit::WebPluginContainer; | 123 using WebKit::WebPluginContainer; |
| 124 using WebKit::WebPrintScalingOption; |
| 124 using WebKit::WebScopedUserGesture; | 125 using WebKit::WebScopedUserGesture; |
| 125 using WebKit::WebString; | 126 using WebKit::WebString; |
| 126 using WebKit::WebURLRequest; | 127 using WebKit::WebURLRequest; |
| 127 using WebKit::WebView; | 128 using WebKit::WebView; |
| 128 | 129 |
| 129 namespace webkit { | 130 namespace webkit { |
| 130 namespace ppapi { | 131 namespace ppapi { |
| 131 | 132 |
| 132 #if defined(OS_WIN) | 133 #if defined(OS_WIN) |
| 133 // Exported by pdf.dll | 134 // Exported by pdf.dll |
| (...skipping 22 matching lines...) Expand all Loading... |
| 156 // unaware plugins (e.g., PPAPI Flash or PDF plugin for M16). | 157 // unaware plugins (e.g., PPAPI Flash or PDF plugin for M16). |
| 157 // Plugins need to explicitly opt out the text input mode if they know | 158 // Plugins need to explicitly opt out the text input mode if they know |
| 158 // that they don't accept texts. | 159 // that they don't accept texts. |
| 159 const ui::TextInputType kPluginDefaultTextInputType = ui::TEXT_INPUT_TYPE_TEXT; | 160 const ui::TextInputType kPluginDefaultTextInputType = ui::TEXT_INPUT_TYPE_TEXT; |
| 160 | 161 |
| 161 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, np_name) \ | 162 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, np_name) \ |
| 162 COMPILE_ASSERT(static_cast<int>(WebCursorInfo::webkit_name) \ | 163 COMPILE_ASSERT(static_cast<int>(WebCursorInfo::webkit_name) \ |
| 163 == static_cast<int>(np_name), \ | 164 == static_cast<int>(np_name), \ |
| 164 mismatching_enums) | 165 mismatching_enums) |
| 165 | 166 |
| 167 #define COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(webkit_name, pp_name) \ |
| 168 COMPILE_ASSERT(static_cast<int>(webkit_name) \ |
| 169 == static_cast<int>(pp_name), \ |
| 170 mismatching_enums) |
| 171 |
| 166 // <embed>/<object> attributes. | 172 // <embed>/<object> attributes. |
| 167 const char kWidth[] = "width"; | 173 const char kWidth[] = "width"; |
| 168 const char kHeight[] = "height"; | 174 const char kHeight[] = "height"; |
| 169 const char kBorder[] = "border"; // According to w3c, deprecated. | 175 const char kBorder[] = "border"; // According to w3c, deprecated. |
| 170 const char kStyle[] = "style"; | 176 const char kStyle[] = "style"; |
| 171 | 177 |
| 172 COMPILE_ASSERT_MATCHING_ENUM(TypePointer, PP_MOUSECURSOR_TYPE_POINTER); | 178 COMPILE_ASSERT_MATCHING_ENUM(TypePointer, PP_MOUSECURSOR_TYPE_POINTER); |
| 173 COMPILE_ASSERT_MATCHING_ENUM(TypeCross, PP_MOUSECURSOR_TYPE_CROSS); | 179 COMPILE_ASSERT_MATCHING_ENUM(TypeCross, PP_MOUSECURSOR_TYPE_CROSS); |
| 174 COMPILE_ASSERT_MATCHING_ENUM(TypeHand, PP_MOUSECURSOR_TYPE_HAND); | 180 COMPILE_ASSERT_MATCHING_ENUM(TypeHand, PP_MOUSECURSOR_TYPE_HAND); |
| 175 COMPILE_ASSERT_MATCHING_ENUM(TypeIBeam, PP_MOUSECURSOR_TYPE_IBEAM); | 181 COMPILE_ASSERT_MATCHING_ENUM(TypeIBeam, PP_MOUSECURSOR_TYPE_IBEAM); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 COMPILE_ASSERT_MATCHING_ENUM(TypeCopy, PP_MOUSECURSOR_TYPE_COPY); | 231 COMPILE_ASSERT_MATCHING_ENUM(TypeCopy, PP_MOUSECURSOR_TYPE_COPY); |
| 226 COMPILE_ASSERT_MATCHING_ENUM(TypeNone, PP_MOUSECURSOR_TYPE_NONE); | 232 COMPILE_ASSERT_MATCHING_ENUM(TypeNone, PP_MOUSECURSOR_TYPE_NONE); |
| 227 COMPILE_ASSERT_MATCHING_ENUM(TypeNotAllowed, PP_MOUSECURSOR_TYPE_NOTALLOWED); | 233 COMPILE_ASSERT_MATCHING_ENUM(TypeNotAllowed, PP_MOUSECURSOR_TYPE_NOTALLOWED); |
| 228 COMPILE_ASSERT_MATCHING_ENUM(TypeZoomIn, PP_MOUSECURSOR_TYPE_ZOOMIN); | 234 COMPILE_ASSERT_MATCHING_ENUM(TypeZoomIn, PP_MOUSECURSOR_TYPE_ZOOMIN); |
| 229 COMPILE_ASSERT_MATCHING_ENUM(TypeZoomOut, PP_MOUSECURSOR_TYPE_ZOOMOUT); | 235 COMPILE_ASSERT_MATCHING_ENUM(TypeZoomOut, PP_MOUSECURSOR_TYPE_ZOOMOUT); |
| 230 COMPILE_ASSERT_MATCHING_ENUM(TypeGrab, PP_MOUSECURSOR_TYPE_GRAB); | 236 COMPILE_ASSERT_MATCHING_ENUM(TypeGrab, PP_MOUSECURSOR_TYPE_GRAB); |
| 231 COMPILE_ASSERT_MATCHING_ENUM(TypeGrabbing, PP_MOUSECURSOR_TYPE_GRABBING); | 237 COMPILE_ASSERT_MATCHING_ENUM(TypeGrabbing, PP_MOUSECURSOR_TYPE_GRABBING); |
| 232 // Do not assert WebCursorInfo::TypeCustom == PP_CURSORTYPE_CUSTOM; | 238 // Do not assert WebCursorInfo::TypeCustom == PP_CURSORTYPE_CUSTOM; |
| 233 // PP_CURSORTYPE_CUSTOM is pinned to allow new cursor types. | 239 // PP_CURSORTYPE_CUSTOM is pinned to allow new cursor types. |
| 234 | 240 |
| 241 COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(WebKit::WebPrintScaleNone, |
| 242 PP_PRINTSCALINGOPTION_NONE); |
| 243 COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM( |
| 244 WebKit::WebPrintFitToPrintableArea, |
| 245 PP_PRINTSCALINGOPTION_FIT_TO_PRINTABLE_AREA); |
| 246 COMPILE_ASSERT_PRINT_SCALING_MATCHING_ENUM(WebKit::WebPrintSourceSize, |
| 247 PP_PRINTSCALINGOPTION_SOURCE_SIZE); |
| 248 |
| 235 // Sets |*security_origin| to be the WebKit security origin associated with the | 249 // Sets |*security_origin| to be the WebKit security origin associated with the |
| 236 // document containing the given plugin instance. On success, returns true. If | 250 // document containing the given plugin instance. On success, returns true. If |
| 237 // the instance is invalid, returns false and |*security_origin| will be | 251 // the instance is invalid, returns false and |*security_origin| will be |
| 238 // unchanged. | 252 // unchanged. |
| 239 bool SecurityOriginForInstance(PP_Instance instance_id, | 253 bool SecurityOriginForInstance(PP_Instance instance_id, |
| 240 WebKit::WebSecurityOrigin* security_origin) { | 254 WebKit::WebSecurityOrigin* security_origin) { |
| 241 PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id); | 255 PluginInstance* instance = HostGlobals::Get()->GetInstance(instance_id); |
| 242 if (!instance) | 256 if (!instance) |
| 243 return false; | 257 return false; |
| 244 | 258 |
| (...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 return GetPreferredPrintOutputFormat(&format); | 1142 return GetPreferredPrintOutputFormat(&format); |
| 1129 } | 1143 } |
| 1130 | 1144 |
| 1131 bool PluginInstance::IsPrintScalingDisabled() { | 1145 bool PluginInstance::IsPrintScalingDisabled() { |
| 1132 DCHECK(plugin_print_interface_); | 1146 DCHECK(plugin_print_interface_); |
| 1133 if (!plugin_print_interface_) | 1147 if (!plugin_print_interface_) |
| 1134 return false; | 1148 return false; |
| 1135 return plugin_print_interface_->IsScalingDisabled(pp_instance()) == PP_TRUE; | 1149 return plugin_print_interface_->IsScalingDisabled(pp_instance()) == PP_TRUE; |
| 1136 } | 1150 } |
| 1137 | 1151 |
| 1138 int PluginInstance::PrintBegin(const gfx::Rect& printable_area, | 1152 int PluginInstance::PrintBegin(const gfx::Rect& content_area, |
| 1153 const gfx::Rect& printable_area, |
| 1154 const gfx::Size& paper_size, |
| 1155 WebPrintScalingOption print_scaling_option, |
| 1139 int printer_dpi) { | 1156 int printer_dpi) { |
| 1140 // Keep a reference on the stack. See NOTE above. | 1157 // Keep a reference on the stack. See NOTE above. |
| 1141 scoped_refptr<PluginInstance> ref(this); | 1158 scoped_refptr<PluginInstance> ref(this); |
| 1142 PP_PrintOutputFormat_Dev format; | 1159 PP_PrintOutputFormat_Dev format; |
| 1143 if (!GetPreferredPrintOutputFormat(&format)) { | 1160 if (!GetPreferredPrintOutputFormat(&format)) { |
| 1144 // PrintBegin should not have been called since SupportsPrintInterface | 1161 // PrintBegin should not have been called since SupportsPrintInterface |
| 1145 // would have returned false; | 1162 // would have returned false; |
| 1146 NOTREACHED(); | 1163 NOTREACHED(); |
| 1147 return 0; | 1164 return 0; |
| 1148 } | 1165 } |
| 1149 | |
| 1150 int num_pages = 0; | 1166 int num_pages = 0; |
| 1151 PP_PrintSettings_Dev print_settings; | 1167 PP_PrintSettings_Dev print_settings; |
| 1152 print_settings.printable_area = PP_FromGfxRect(printable_area); | 1168 print_settings.printable_area = PP_FromGfxRect(printable_area); |
| 1169 print_settings.content_area = PP_FromGfxRect(content_area); |
| 1170 print_settings.paper_size = PP_FromGfxSize(paper_size); |
| 1153 print_settings.dpi = printer_dpi; | 1171 print_settings.dpi = printer_dpi; |
| 1154 print_settings.orientation = PP_PRINTORIENTATION_NORMAL; | 1172 print_settings.orientation = PP_PRINTORIENTATION_NORMAL; |
| 1155 print_settings.grayscale = PP_FALSE; | 1173 print_settings.grayscale = PP_FALSE; |
| 1174 print_settings.print_scaling_option = static_cast<PP_PrintScalingOption_Dev>( |
| 1175 print_scaling_option); |
| 1156 print_settings.format = format; | 1176 print_settings.format = format; |
| 1157 num_pages = plugin_print_interface_->Begin(pp_instance(), | 1177 num_pages = plugin_print_interface_->Begin(pp_instance(), |
| 1158 &print_settings); | 1178 &print_settings); |
| 1159 if (!num_pages) | 1179 if (!num_pages) |
| 1160 return 0; | 1180 return 0; |
| 1161 current_print_settings_ = print_settings; | 1181 current_print_settings_ = print_settings; |
| 1162 #if defined(USE_SKIA) | 1182 #if defined(USE_SKIA) |
| 1163 canvas_ = NULL; | 1183 canvas_ = NULL; |
| 1164 ranges_.clear(); | 1184 ranges_.clear(); |
| 1165 #endif // USE_SKIA | 1185 #endif // USE_SKIA |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2043 screen_size_for_fullscreen_ = gfx::Size(); | 2063 screen_size_for_fullscreen_ = gfx::Size(); |
| 2044 WebElement element = container_->element(); | 2064 WebElement element = container_->element(); |
| 2045 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2065 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
| 2046 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2066 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
| 2047 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2067 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
| 2048 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2068 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
| 2049 } | 2069 } |
| 2050 | 2070 |
| 2051 } // namespace ppapi | 2071 } // namespace ppapi |
| 2052 } // namespace webkit | 2072 } // namespace webkit |
| OLD | NEW |