OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #define PEPPER_APIS_ENABLED 1 | 5 #define PEPPER_APIS_ENABLED 1 |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #if defined(OS_WIN) | 8 #if defined(OS_WIN) |
9 #include <vsstyle.h> | 9 #include <vsstyle.h> |
10 #endif | 10 #endif |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 WebPluginResourceClient* WebPluginDelegatePepper::CreateResourceClient( | 314 WebPluginResourceClient* WebPluginDelegatePepper::CreateResourceClient( |
315 unsigned long resource_id, const GURL& url, int notify_id) { | 315 unsigned long resource_id, const GURL& url, int notify_id) { |
316 return instance()->CreateStream(resource_id, url, std::string(), notify_id); | 316 return instance()->CreateStream(resource_id, url, std::string(), notify_id); |
317 } | 317 } |
318 | 318 |
319 WebPluginResourceClient* WebPluginDelegatePepper::CreateSeekableResourceClient( | 319 WebPluginResourceClient* WebPluginDelegatePepper::CreateSeekableResourceClient( |
320 unsigned long resource_id, int range_request_id) { | 320 unsigned long resource_id, int range_request_id) { |
321 return instance()->GetRangeRequest(range_request_id); | 321 return instance()->GetRangeRequest(range_request_id); |
322 } | 322 } |
323 | 323 |
| 324 void WebPluginDelegatePepper::StartFind(const std::string& search_text, |
| 325 bool case_sensitive, |
| 326 int identifier) { |
| 327 find_identifier_ = identifier; |
| 328 GetFindExtensions()->startFind( |
| 329 instance()->npp(), search_text.c_str(), case_sensitive); |
| 330 } |
| 331 |
| 332 void WebPluginDelegatePepper::SelectFindResult(bool forward) { |
| 333 GetFindExtensions()->selectFindResult(instance()->npp(), forward); |
| 334 } |
| 335 |
| 336 void WebPluginDelegatePepper::StopFind() { |
| 337 find_identifier_ = -1; |
| 338 GetFindExtensions()->stopFind(instance()->npp()); |
| 339 } |
| 340 |
| 341 void WebPluginDelegatePepper::NumberOfFindResultsChanged(int total, |
| 342 bool final_result) { |
| 343 DCHECK(find_identifier_ != -1); |
| 344 |
| 345 if (total == 0) { |
| 346 render_view_->ReportNoFindInPageResults(find_identifier_); |
| 347 } else { |
| 348 render_view_->reportFindInPageMatchCount( |
| 349 find_identifier_, total, final_result); |
| 350 } |
| 351 } |
| 352 |
| 353 void WebPluginDelegatePepper::SelectedFindResultChanged(int index) { |
| 354 render_view_->reportFindInPageSelection( |
| 355 find_identifier_, index + 1, WebKit::WebRect()); |
| 356 } |
| 357 |
324 NPError WebPluginDelegatePepper::Device2DQueryCapability(int32 capability, | 358 NPError WebPluginDelegatePepper::Device2DQueryCapability(int32 capability, |
325 int32* value) { | 359 int32* value) { |
326 return NPERR_GENERIC_ERROR; | 360 return NPERR_GENERIC_ERROR; |
327 } | 361 } |
328 | 362 |
329 NPError WebPluginDelegatePepper::Device2DQueryConfig( | 363 NPError WebPluginDelegatePepper::Device2DQueryConfig( |
330 const NPDeviceContext2DConfig* request, | 364 const NPDeviceContext2DConfig* request, |
331 NPDeviceContext2DConfig* obtain) { | 365 NPDeviceContext2DConfig* obtain) { |
332 return NPERR_GENERIC_ERROR; | 366 return NPERR_GENERIC_ERROR; |
333 } | 367 } |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 #endif // defined(OS_WIN) || defined(OS_LINUX) | 1009 #endif // defined(OS_WIN) || defined(OS_LINUX) |
976 } | 1010 } |
977 | 1011 |
978 void WebPluginDelegatePepper::PrintEnd() { | 1012 void WebPluginDelegatePepper::PrintEnd() { |
979 NPPPrintExtensions* print_extensions = GetPrintExtensions(); | 1013 NPPPrintExtensions* print_extensions = GetPrintExtensions(); |
980 if (print_extensions) | 1014 if (print_extensions) |
981 print_extensions->printEnd(instance()->npp()); | 1015 print_extensions->printEnd(instance()->npp()); |
982 current_printable_area_ = gfx::Rect(); | 1016 current_printable_area_ = gfx::Rect(); |
983 } | 1017 } |
984 | 1018 |
| 1019 bool WebPluginDelegatePepper::SupportsFind() { |
| 1020 return GetFindExtensions() != NULL; |
| 1021 } |
| 1022 |
985 | 1023 |
986 WebPluginDelegatePepper::WebPluginDelegatePepper( | 1024 WebPluginDelegatePepper::WebPluginDelegatePepper( |
987 const base::WeakPtr<RenderView>& render_view, | 1025 const base::WeakPtr<RenderView>& render_view, |
988 NPAPI::PluginInstance *instance) | 1026 NPAPI::PluginInstance *instance) |
989 : render_view_(render_view), | 1027 : render_view_(render_view), |
990 plugin_(NULL), | 1028 plugin_(NULL), |
991 instance_(instance), | 1029 instance_(instance), |
992 nested_delegate_(NULL), | 1030 nested_delegate_(NULL), |
993 #if defined(ENABLE_GPU) | 1031 #if defined(ENABLE_GPU) |
994 command_buffer_(NULL), | 1032 command_buffer_(NULL), |
995 #endif | 1033 #endif |
| 1034 find_identifier_(-1), |
996 method_factory3d_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 1035 method_factory3d_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
997 // For now we keep a window struct, although it isn't used. | 1036 // For now we keep a window struct, although it isn't used. |
998 memset(&window_, 0, sizeof(window_)); | 1037 memset(&window_, 0, sizeof(window_)); |
999 // All Pepper plugins are windowless and transparent. | 1038 // All Pepper plugins are windowless and transparent. |
1000 // TODO(sehr): disable resetting these NPPVs by plugins. | 1039 // TODO(sehr): disable resetting these NPPVs by plugins. |
1001 instance->set_windowless(true); | 1040 instance->set_windowless(true); |
1002 instance->set_transparent(true); | 1041 instance->set_transparent(true); |
1003 } | 1042 } |
1004 | 1043 |
1005 WebPluginDelegatePepper::~WebPluginDelegatePepper() { | 1044 WebPluginDelegatePepper::~WebPluginDelegatePepper() { |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 | 1295 |
1257 NPPPrintExtensions* WebPluginDelegatePepper::GetPrintExtensions() { | 1296 NPPPrintExtensions* WebPluginDelegatePepper::GetPrintExtensions() { |
1258 NPPPrintExtensions* ret = NULL; | 1297 NPPPrintExtensions* ret = NULL; |
1259 NPPExtensions* extensions = NULL; | 1298 NPPExtensions* extensions = NULL; |
1260 instance()->NPP_GetValue(NPPVPepperExtensions, &extensions); | 1299 instance()->NPP_GetValue(NPPVPepperExtensions, &extensions); |
1261 if (extensions && extensions->getPrintExtensions) | 1300 if (extensions && extensions->getPrintExtensions) |
1262 ret = extensions->getPrintExtensions(instance()->npp()); | 1301 ret = extensions->getPrintExtensions(instance()->npp()); |
1263 return ret; | 1302 return ret; |
1264 } | 1303 } |
1265 | 1304 |
| 1305 NPPFindExtensions* WebPluginDelegatePepper::GetFindExtensions() { |
| 1306 NPPFindExtensions* ret = NULL; |
| 1307 NPPExtensions* extensions = NULL; |
| 1308 instance()->NPP_GetValue(NPPVPepperExtensions, &extensions); |
| 1309 if (extensions && extensions->getFindExtensions) |
| 1310 ret = extensions->getFindExtensions(instance()->npp()); |
| 1311 return ret; |
| 1312 } |
| 1313 |
1266 #if defined(OS_WIN) | 1314 #if defined(OS_WIN) |
1267 bool WebPluginDelegatePepper::DrawJPEGToPlatformDC( | 1315 bool WebPluginDelegatePepper::DrawJPEGToPlatformDC( |
1268 const SkBitmap& bitmap, | 1316 const SkBitmap& bitmap, |
1269 const gfx::Rect& printable_area, | 1317 const gfx::Rect& printable_area, |
1270 WebKit::WebCanvas* canvas) { | 1318 WebKit::WebCanvas* canvas) { |
1271 skia::VectorPlatformDevice& device = | 1319 skia::VectorPlatformDevice& device = |
1272 static_cast<skia::VectorPlatformDevice&>( | 1320 static_cast<skia::VectorPlatformDevice&>( |
1273 canvas->getTopPlatformDevice()); | 1321 canvas->getTopPlatformDevice()); |
1274 HDC dc = device.getBitmapDC(); | 1322 HDC dc = device.getBitmapDC(); |
1275 // TODO(sanjeevr): This is a temporary hack. If we output a JPEG | 1323 // TODO(sanjeevr): This is a temporary hack. If we output a JPEG |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 StretchDIBits(dc, printable_area.x(), printable_area.y(), | 1355 StretchDIBits(dc, printable_area.x(), printable_area.y(), |
1308 printable_area.width(), printable_area.height(), | 1356 printable_area.width(), printable_area.height(), |
1309 0, 0, bitmap.width(), bitmap.height(), | 1357 0, 0, bitmap.width(), bitmap.height(), |
1310 &compressed_image.front(), | 1358 &compressed_image.front(), |
1311 reinterpret_cast<const BITMAPINFO*>(&bmi), | 1359 reinterpret_cast<const BITMAPINFO*>(&bmi), |
1312 DIB_RGB_COLORS, SRCCOPY); | 1360 DIB_RGB_COLORS, SRCCOPY); |
1313 return true; | 1361 return true; |
1314 } | 1362 } |
1315 #endif // OS_WIN | 1363 #endif // OS_WIN |
1316 | 1364 |
OLD | NEW |