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

Side by Side Diff: chrome/renderer/webplugin_delegate_pepper.cc

Issue 2827047: Make RenderView call the plugin through WebKit::WebPlugin (instead of casting... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: compile until webkit is rolled Created 10 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/renderer/webplugin_delegate_pepper.h" 7 #include "chrome/renderer/webplugin_delegate_pepper.h"
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "third_party/npapi/bindings/npapi_extensions.h" 48 #include "third_party/npapi/bindings/npapi_extensions.h"
49 #include "third_party/npapi/bindings/npapi_extensions_private.h" 49 #include "third_party/npapi/bindings/npapi_extensions_private.h"
50 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" 50 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h"
51 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" 51 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h"
52 #include "webkit/glue/plugins/plugin_constants_win.h" 52 #include "webkit/glue/plugins/plugin_constants_win.h"
53 #include "webkit/glue/plugins/plugin_instance.h" 53 #include "webkit/glue/plugins/plugin_instance.h"
54 #include "webkit/glue/plugins/plugin_lib.h" 54 #include "webkit/glue/plugins/plugin_lib.h"
55 #include "webkit/glue/plugins/plugin_list.h" 55 #include "webkit/glue/plugins/plugin_list.h"
56 #include "webkit/glue/plugins/plugin_host.h" 56 #include "webkit/glue/plugins/plugin_host.h"
57 #include "webkit/glue/plugins/plugin_stream_url.h" 57 #include "webkit/glue/plugins/plugin_stream_url.h"
58 #include "webkit/glue/scoped_clipboard_writer_glue.h"
59 #include "webkit/glue/webkit_glue.h" 58 #include "webkit/glue/webkit_glue.h"
60 59
61 #if defined(ENABLE_GPU) 60 #if defined(ENABLE_GPU)
62 #include "webkit/glue/plugins/plugin_constants_win.h" 61 #include "webkit/glue/plugins/plugin_constants_win.h"
63 #endif 62 #endif
64 63
65 using gpu::Buffer; 64 using gpu::Buffer;
66 using webkit_glue::WebPlugin; 65 using webkit_glue::WebPlugin;
67 using webkit_glue::WebPluginDelegate; 66 using webkit_glue::WebPluginDelegate;
68 using webkit_glue::WebPluginResourceClient; 67 using webkit_glue::WebPluginResourceClient;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 WebPluginResourceClient* WebPluginDelegatePepper::CreateResourceClient( 314 WebPluginResourceClient* WebPluginDelegatePepper::CreateResourceClient(
316 unsigned long resource_id, const GURL& url, int notify_id) { 315 unsigned long resource_id, const GURL& url, int notify_id) {
317 return instance()->CreateStream(resource_id, url, std::string(), notify_id); 316 return instance()->CreateStream(resource_id, url, std::string(), notify_id);
318 } 317 }
319 318
320 WebPluginResourceClient* WebPluginDelegatePepper::CreateSeekableResourceClient( 319 WebPluginResourceClient* WebPluginDelegatePepper::CreateSeekableResourceClient(
321 unsigned long resource_id, int range_request_id) { 320 unsigned long resource_id, int range_request_id) {
322 return instance()->GetRangeRequest(range_request_id); 321 return instance()->GetRangeRequest(range_request_id);
323 } 322 }
324 323
325 void WebPluginDelegatePepper::StartFind(const std::string& search_text, 324 void WebPluginDelegatePepper::StartFind(const string16& search_text,
326 bool case_sensitive, 325 bool case_sensitive,
327 int identifier) { 326 int identifier) {
328 find_identifier_ = identifier; 327 find_identifier_ = identifier;
329 GetFindExtensions()->startFind( 328 GetFindExtensions()->startFind(
330 instance()->npp(), search_text.c_str(), case_sensitive); 329 instance()->npp(), UTF16ToUTF8(search_text).c_str(), case_sensitive);
331 } 330 }
332 331
333 void WebPluginDelegatePepper::SelectFindResult(bool forward) { 332 void WebPluginDelegatePepper::SelectFindResult(bool forward) {
334 GetFindExtensions()->selectFindResult(instance()->npp(), forward); 333 GetFindExtensions()->selectFindResult(instance()->npp(), forward);
335 } 334 }
336 335
337 void WebPluginDelegatePepper::StopFind() { 336 void WebPluginDelegatePepper::StopFind() {
338 find_identifier_ = -1; 337 find_identifier_ = -1;
339 GetFindExtensions()->stopFind(instance()->npp()); 338 GetFindExtensions()->stopFind(instance()->npp());
340 } 339 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 NPFontExtensions g_font_extensions = { 494 NPFontExtensions g_font_extensions = {
496 NPMatchFontWithFallback, 495 NPMatchFontWithFallback,
497 GetFontTable, 496 GetFontTable,
498 NPDestroyFont 497 NPDestroyFont
499 }; 498 };
500 499
501 NPFontExtensions* WebPluginDelegatePepper::GetFontExtensions() { 500 NPFontExtensions* WebPluginDelegatePepper::GetFontExtensions() {
502 return &g_font_extensions; 501 return &g_font_extensions;
503 } 502 }
504 503
505 void WebPluginDelegatePepper::Zoom(int factor) { 504 void WebPluginDelegatePepper::SetZoomFactor(float scale, bool text_only) {
506 NPPExtensions* extensions = NULL; 505 NPPExtensions* extensions = NULL;
507 instance()->NPP_GetValue(NPPVPepperExtensions, &extensions); 506 instance()->NPP_GetValue(NPPVPepperExtensions, &extensions);
508 if (extensions && extensions->zoom) 507 if (extensions && extensions->zoom)
509 extensions->zoom(instance()->npp(), factor); 508 extensions->zoom(instance()->npp(), scale, text_only);
510 } 509 }
511 510
512 void WebPluginDelegatePepper::Copy() { 511 bool WebPluginDelegatePepper::HasSelection() const {
513 ScopedClipboardWriterGlue scw(webkit_glue::ClipboardGetClipboard()); 512 return !GetSelectedText(false).empty();
514 string16 text = GetSelectedText(true);
515 if (!text.empty()) {
516 // Got html data.
517 scw.WriteHTML(text, std::string());
518 return;
519 }
520
521 text = GetSelectedText(false);
522 if (!text.empty())
523 scw.WriteText(text);
524 } 513 }
525 514
526 string16 WebPluginDelegatePepper::GetSelectedText() { 515 string16 WebPluginDelegatePepper::GetSelectionAsText() const {
527 return GetSelectedText(false); 516 return GetSelectedText(false);
528 } 517 }
529 518
530 string16 WebPluginDelegatePepper::GetSelectedText(bool html) { 519 string16 WebPluginDelegatePepper::GetSelectionAsMarkup() const {
520 return GetSelectedText(true);
521 }
522
523 string16 WebPluginDelegatePepper::GetSelectedText(bool html) const {
531 NPPExtensions* extensions = NULL; 524 NPPExtensions* extensions = NULL;
532 instance()->NPP_GetValue(NPPVPepperExtensions, &extensions); 525 instance_->NPP_GetValue(NPPVPepperExtensions, &extensions);
533 if (!extensions || !extensions->getSelection) 526 if (!extensions || !extensions->getSelection)
534 return string16(); 527 return string16();
535 528
536 void* text; 529 void* text;
537 NPSelectionType type = html ? NPSelectionTypeHTML : NPSelectionTypePlainText; 530 NPSelectionType type = html ? NPSelectionTypeHTML : NPSelectionTypePlainText;
538 NPP npp = instance()->npp(); 531 NPP npp = instance_->npp();
539 if (extensions->getSelection(npp, &type, &text) != NPERR_NO_ERROR) 532 if (extensions->getSelection(npp, &type, &text) != NPERR_NO_ERROR)
540 return string16(); 533 return string16();
541 534
542 string16 rv = UTF8ToUTF16(static_cast<char*>(text)); 535 string16 rv = UTF8ToUTF16(static_cast<char*>(text));
543 NPAPI::PluginHost::Singleton()->host_functions()->memfree(text); 536 NPAPI::PluginHost::Singleton()->host_functions()->memfree(text);
544 return rv; 537 return rv;
545 } 538 }
546 539
547 NPError WebPluginDelegatePepper::Device2DQueryCapability(int32 capability, 540 NPError WebPluginDelegatePepper::Device2DQueryCapability(int32 capability,
548 int32* value) { 541 int32* value) {
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 npevent->u.wheel.deltaX = mouse_wheel_event->deltaX; 1529 npevent->u.wheel.deltaX = mouse_wheel_event->deltaX;
1537 npevent->u.wheel.deltaY = mouse_wheel_event->deltaY; 1530 npevent->u.wheel.deltaY = mouse_wheel_event->deltaY;
1538 npevent->u.wheel.wheelTicksX = mouse_wheel_event->wheelTicksX; 1531 npevent->u.wheel.wheelTicksX = mouse_wheel_event->wheelTicksX;
1539 npevent->u.wheel.wheelTicksY = mouse_wheel_event->wheelTicksY; 1532 npevent->u.wheel.wheelTicksY = mouse_wheel_event->wheelTicksY;
1540 npevent->u.wheel.scrollByPage = mouse_wheel_event->scrollByPage; 1533 npevent->u.wheel.scrollByPage = mouse_wheel_event->scrollByPage;
1541 } 1534 }
1542 } // namespace 1535 } // namespace
1543 1536
1544 bool WebPluginDelegatePepper::HandleInputEvent(const WebInputEvent& event, 1537 bool WebPluginDelegatePepper::HandleInputEvent(const WebInputEvent& event,
1545 WebCursorInfo* cursor_info) { 1538 WebCursorInfo* cursor_info) {
1546 if (event.type == WebInputEvent::KeyDown) {
1547 const WebKeyboardEvent* key_event =
1548 reinterpret_cast<const WebKeyboardEvent*>(&event);
1549 #if defined(OS_MACOSX)
1550 if (key_event->modifiers == NPEventModifier_MetaKey &&
1551 #else
1552 if (key_event->modifiers == NPEventModifier_ControlKey &&
1553 #endif
1554 key_event->windowsKeyCode == base::VKEY_C) {
1555 Copy();
1556 return true;
1557 }
1558 }
1559
1560 NPPepperEvent npevent; 1539 NPPepperEvent npevent;
1561 1540
1562 npevent.type = ConvertEventTypes(event.type); 1541 npevent.type = ConvertEventTypes(event.type);
1563 npevent.size = sizeof(npevent); 1542 npevent.size = sizeof(npevent);
1564 npevent.timeStampSeconds = event.timeStampSeconds; 1543 npevent.timeStampSeconds = event.timeStampSeconds;
1565 switch (npevent.type) { 1544 switch (npevent.type) {
1566 case NPEventType_Undefined: 1545 case NPEventType_Undefined:
1567 return false; 1546 return false;
1568 case NPEventType_MouseDown: 1547 case NPEventType_MouseDown:
1569 case NPEventType_MouseUp: 1548 case NPEventType_MouseUp:
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 bounds.origin.x = dest_rect.x(); 1751 bounds.origin.x = dest_rect.x();
1773 bounds.origin.y = canvas_height - dest_rect.y() - dest_rect.height(); 1752 bounds.origin.y = canvas_height - dest_rect.y() - dest_rect.height();
1774 bounds.size.width = dest_rect.width(); 1753 bounds.size.width = dest_rect.width();
1775 bounds.size.height = dest_rect.height(); 1754 bounds.size.height = dest_rect.height();
1776 1755
1777 CGContextDrawImage(canvas, bounds, image); 1756 CGContextDrawImage(canvas, bounds, image);
1778 CGContextRestoreGState(canvas); 1757 CGContextRestoreGState(canvas);
1779 } 1758 }
1780 #endif // defined(OS_MACOSX) 1759 #endif // defined(OS_MACOSX)
1781 1760
OLDNEW
« no previous file with comments | « chrome/renderer/webplugin_delegate_pepper.h ('k') | third_party/npapi/bindings/npapi_extensions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698