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

Side by Side Diff: content/shell/renderer/test_runner/TestPlugin.cpp

Issue 105633011: BrowserPlugin/WebView - Move plugin lifetime to DOM - The Prequel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove use of npobject. Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/shell/renderer/test_runner/TestPlugin.h" 5 #include "content/shell/renderer/test_runner/TestPlugin.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "content/shell/renderer/test_runner/TestCommon.h" 8 #include "content/shell/renderer/test_runner/TestCommon.h"
9 #include "content/shell/renderer/test_runner/WebTestDelegate.h" 9 #include "content/shell/renderer/test_runner/WebTestDelegate.h"
10 #include "third_party/WebKit/public/platform/Platform.h" 10 #include "third_party/WebKit/public/platform/Platform.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 120 }
121 121
122 void deferredDelete(void* context) 122 void deferredDelete(void* context)
123 { 123 {
124 TestPlugin* plugin = static_cast<TestPlugin*>(context); 124 TestPlugin* plugin = static_cast<TestPlugin*>(context);
125 delete plugin; 125 delete plugin;
126 } 126 }
127 127
128 } 128 }
129 129
130
131 TestPlugin::TestPlugin(WebFrame* frame, const WebPluginParams& params, WebTestDe legate* delegate) 130 TestPlugin::TestPlugin(WebFrame* frame, const WebPluginParams& params, WebTestDe legate* delegate)
132 : m_frame(frame) 131 : m_frame(frame)
133 , m_delegate(delegate) 132 , m_delegate(delegate)
134 , m_container(0) 133 , m_container(0)
135 , m_context(0) 134 , m_context(0)
136 , m_colorTexture(0) 135 , m_colorTexture(0)
137 , m_mailboxChanged(false) 136 , m_mailboxChanged(false)
138 , m_framebuffer(0) 137 , m_framebuffer(0)
139 , m_touchEventRequest(WebPluginContainer::TouchEventRequestTypeNone) 138 , m_touchEventRequest(WebPluginContainer::TouchEventRequestTypeNone)
140 , m_reRequestTouchEvents(false) 139 , m_reRequestTouchEvents(false)
141 , m_printEventDetails(false) 140 , m_printEventDetails(false)
142 , m_printUserGestureStatus(false) 141 , m_printUserGestureStatus(false)
143 , m_canProcessDrag(false) 142 , m_canProcessDrag(false)
143 , m_isPersistent(params.mimeType == pluginPersistsMimeType())
144 , m_canCreateWithoutRenderer(params.mimeType == canCreateWithoutRendererMime Type())
144 { 145 {
145 const CR_DEFINE_STATIC_LOCAL(WebString, kAttributePrimitive, ("primitive")); 146 const CR_DEFINE_STATIC_LOCAL(WebString, kAttributePrimitive, ("primitive"));
146 const CR_DEFINE_STATIC_LOCAL(WebString, kAttributeBackgroundColor, ("backgro und-color")); 147 const CR_DEFINE_STATIC_LOCAL(WebString, kAttributeBackgroundColor, ("backgro und-color"));
147 const CR_DEFINE_STATIC_LOCAL(WebString, kAttributePrimitiveColor, ("primitiv e-color")); 148 const CR_DEFINE_STATIC_LOCAL(WebString, kAttributePrimitiveColor, ("primitiv e-color"));
148 const CR_DEFINE_STATIC_LOCAL(WebString, kAttributeOpacity, ("opacity")); 149 const CR_DEFINE_STATIC_LOCAL(WebString, kAttributeOpacity, ("opacity"));
149 const CR_DEFINE_STATIC_LOCAL(WebString, kAttributeAcceptsTouch, ("accepts-to uch")); 150 const CR_DEFINE_STATIC_LOCAL(WebString, kAttributeAcceptsTouch, ("accepts-to uch"));
150 const CR_DEFINE_STATIC_LOCAL(WebString, kAttributeReRequestTouchEvents, ("re -request-touch")); 151 const CR_DEFINE_STATIC_LOCAL(WebString, kAttributeReRequestTouchEvents, ("re -request-touch"));
151 const CR_DEFINE_STATIC_LOCAL(WebString, kAttributePrintEventDetails, ("print -event-details")); 152 const CR_DEFINE_STATIC_LOCAL(WebString, kAttributePrintEventDetails, ("print -event-details"));
152 const CR_DEFINE_STATIC_LOCAL(WebString, kAttributeCanProcessDrag, ("can-proc ess-drag")); 153 const CR_DEFINE_STATIC_LOCAL(WebString, kAttributeCanProcessDrag, ("can-proc ess-drag"));
153 const CR_DEFINE_STATIC_LOCAL(WebString, kAttributePrintUserGestureStatus, (" print-user-gesture-status")); 154 const CR_DEFINE_STATIC_LOCAL(WebString, kAttributePrintUserGestureStatus, (" print-user-gesture-status"));
(...skipping 16 matching lines...) Expand all
170 m_touchEventRequest = parseTouchEventRequestType(attributeValue); 171 m_touchEventRequest = parseTouchEventRequestType(attributeValue);
171 else if (attributeName == kAttributeReRequestTouchEvents) 172 else if (attributeName == kAttributeReRequestTouchEvents)
172 m_reRequestTouchEvents = parseBoolean(attributeValue); 173 m_reRequestTouchEvents = parseBoolean(attributeValue);
173 else if (attributeName == kAttributePrintEventDetails) 174 else if (attributeName == kAttributePrintEventDetails)
174 m_printEventDetails = parseBoolean(attributeValue); 175 m_printEventDetails = parseBoolean(attributeValue);
175 else if (attributeName == kAttributeCanProcessDrag) 176 else if (attributeName == kAttributeCanProcessDrag)
176 m_canProcessDrag = parseBoolean(attributeValue); 177 m_canProcessDrag = parseBoolean(attributeValue);
177 else if (attributeName == kAttributePrintUserGestureStatus) 178 else if (attributeName == kAttributePrintUserGestureStatus)
178 m_printUserGestureStatus = parseBoolean(attributeValue); 179 m_printUserGestureStatus = parseBoolean(attributeValue);
179 } 180 }
181 if (m_canCreateWithoutRenderer)
182 m_delegate->printMessage(std::string("TestPlugin: canCreateWithoutRender er\n"));
180 } 183 }
181 184
182 TestPlugin::~TestPlugin() 185 TestPlugin::~TestPlugin()
183 { 186 {
184 } 187 }
185 188
186 bool TestPlugin::initialize(WebPluginContainer* container) 189 bool TestPlugin::initialize(WebPluginContainer* container)
187 { 190 {
188 WebGraphicsContext3D::Attributes attrs; 191 WebGraphicsContext3D::Attributes attrs;
189 m_context = Platform::current()->createOffscreenGraphicsContext3D(attrs); 192 m_context = Platform::current()->createOffscreenGraphicsContext3D(attrs);
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 case WebInputEvent::TouchMove: eventName = "TouchMove"; break; 541 case WebInputEvent::TouchMove: eventName = "TouchMove"; break;
539 case WebInputEvent::TouchEnd: eventName = "TouchEnd"; break; 542 case WebInputEvent::TouchEnd: eventName = "TouchEnd"; break;
540 case WebInputEvent::TouchCancel: eventName = "TouchCancel"; break; 543 case WebInputEvent::TouchCancel: eventName = "TouchCancel"; break;
541 } 544 }
542 545
543 m_delegate->printMessage(std::string("Plugin received event: ") + (eventName ? eventName : "unknown") + "\n"); 546 m_delegate->printMessage(std::string("Plugin received event: ") + (eventName ? eventName : "unknown") + "\n");
544 if (m_printEventDetails) 547 if (m_printEventDetails)
545 printEventDetails(m_delegate, event); 548 printEventDetails(m_delegate, event);
546 if (m_printUserGestureStatus) 549 if (m_printUserGestureStatus)
547 m_delegate->printMessage(std::string("* ") + (WebUserGestureIndicator::i sProcessingUserGesture() ? "" : "not ") + "handling user gesture\n"); 550 m_delegate->printMessage(std::string("* ") + (WebUserGestureIndicator::i sProcessingUserGesture() ? "" : "not ") + "handling user gesture\n");
551 if (m_isPersistent)
552 m_delegate->printMessage(std::string("TestPlugin: isPersistent\n"));
548 return false; 553 return false;
549 } 554 }
550 555
551 bool TestPlugin::handleDragStatusUpdate(WebDragStatus dragStatus, const WebDragD ata&, WebDragOperationsMask, const WebPoint& position, const WebPoint& screenPos ition) 556 bool TestPlugin::handleDragStatusUpdate(WebDragStatus dragStatus, const WebDragD ata&, WebDragOperationsMask, const WebPoint& position, const WebPoint& screenPos ition)
552 { 557 {
553 const char* dragStatusName = 0; 558 const char* dragStatusName = 0;
554 switch (dragStatus) { 559 switch (dragStatus) {
555 case WebDragStatusEnter: 560 case WebDragStatusEnter:
556 dragStatusName = "DragEnter"; 561 dragStatusName = "DragEnter";
557 break; 562 break;
(...skipping 17 matching lines...) Expand all
575 { 580 {
576 return new TestPlugin(frame, params, delegate); 581 return new TestPlugin(frame, params, delegate);
577 } 582 }
578 583
579 const WebString& TestPlugin::mimeType() 584 const WebString& TestPlugin::mimeType()
580 { 585 {
581 const CR_DEFINE_STATIC_LOCAL(WebString, kMimeType, ("application/x-webkit-te st-webplugin")); 586 const CR_DEFINE_STATIC_LOCAL(WebString, kMimeType, ("application/x-webkit-te st-webplugin"));
582 return kMimeType; 587 return kMimeType;
583 } 588 }
584 589
590 const WebString& TestPlugin::canCreateWithoutRendererMimeType()
591 {
592 const CR_DEFINE_STATIC_LOCAL(WebString, kCanCreateWithoutRendererMimeType, ( "application/x-webkit-test-webplugin-can-create-without-renderer"));
593 return kCanCreateWithoutRendererMimeType;
585 } 594 }
595
596 const WebString& TestPlugin::pluginPersistsMimeType()
597 {
598 const CR_DEFINE_STATIC_LOCAL(WebString, kPluginPersistsMimeType, ("applicati on/x-webkit-test-webplugin-persistent"));
599 return kPluginPersistsMimeType;
600 }
601
602 bool TestPlugin::isSupportedMimeType(const WebString& mimeType)
603 {
604 return mimeType == TestPlugin::mimeType()
605 || mimeType == pluginPersistsMimeType()
606 || mimeType == canCreateWithoutRendererMimeType();
607 }
608
609 }
OLDNEW
« no previous file with comments | « content/shell/renderer/test_runner/TestPlugin.h ('k') | content/shell/renderer/test_runner/WebFrameTestProxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698