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

Side by Side Diff: components/test_runner/test_plugin.cc

Issue 2707183003: Move //components/test_runner back into //content/shell (Closed)
Patch Set: Trim DEPS Created 3 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/test_runner/test_plugin.h"
6
7 #include <stddef.h>
8 #include <stdint.h>
9
10 #include <utility>
11
12 #include "base/bind.h"
13 #include "base/logging.h"
14 #include "base/memory/ptr_util.h"
15 #include "base/memory/shared_memory.h"
16 #include "base/strings/stringprintf.h"
17 #include "cc/blink/web_layer_impl.h"
18 #include "cc/layers/texture_layer.h"
19 #include "cc/resources/shared_bitmap_manager.h"
20 #include "components/test_runner/web_test_delegate.h"
21 #include "gpu/command_buffer/client/gles2_interface.h"
22 #include "third_party/WebKit/public/platform/Platform.h"
23 #include "third_party/WebKit/public/platform/WebCompositorSupport.h"
24 #include "third_party/WebKit/public/platform/WebGestureEvent.h"
25 #include "third_party/WebKit/public/platform/WebGraphicsContext3DProvider.h"
26 #include "third_party/WebKit/public/platform/WebInputEvent.h"
27 #include "third_party/WebKit/public/platform/WebMouseEvent.h"
28 #include "third_party/WebKit/public/platform/WebThread.h"
29 #include "third_party/WebKit/public/platform/WebTouchEvent.h"
30 #include "third_party/WebKit/public/platform/WebTouchPoint.h"
31 #include "third_party/WebKit/public/platform/WebTraceLocation.h"
32 #include "third_party/WebKit/public/platform/WebURL.h"
33 #include "third_party/WebKit/public/web/WebFrame.h"
34 #include "third_party/WebKit/public/web/WebKit.h"
35 #include "third_party/WebKit/public/web/WebPluginParams.h"
36 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
37 #include "third_party/skia/include/core/SkBitmap.h"
38 #include "third_party/skia/include/core/SkCanvas.h"
39 #include "third_party/skia/include/core/SkColor.h"
40 #include "third_party/skia/include/core/SkPaint.h"
41 #include "third_party/skia/include/core/SkPath.h"
42
43 namespace test_runner {
44
45 namespace {
46
47 void PremultiplyAlpha(const uint8_t color_in[3],
48 float alpha,
49 float color_out[4]) {
50 for (int i = 0; i < 3; ++i)
51 color_out[i] = (color_in[i] / 255.0f) * alpha;
52
53 color_out[3] = alpha;
54 }
55
56 const char* PointState(blink::WebTouchPoint::State state) {
57 switch (state) {
58 case blink::WebTouchPoint::StateReleased:
59 return "Released";
60 case blink::WebTouchPoint::StatePressed:
61 return "Pressed";
62 case blink::WebTouchPoint::StateMoved:
63 return "Moved";
64 case blink::WebTouchPoint::StateCancelled:
65 return "Cancelled";
66 default:
67 return "Unknown";
68 }
69 }
70
71 void PrintTouchList(WebTestDelegate* delegate,
72 const blink::WebTouchPoint* points,
73 int length) {
74 for (int i = 0; i < length; ++i) {
75 delegate->PrintMessage(base::StringPrintf("* %.2f, %.2f: %s\n",
76 points[i].position.x,
77 points[i].position.y,
78 PointState(points[i].state)));
79 }
80 }
81
82 void PrintEventDetails(WebTestDelegate* delegate,
83 const blink::WebInputEvent& event) {
84 if (blink::WebInputEvent::isTouchEventType(event.type())) {
85 const blink::WebTouchEvent& touch =
86 static_cast<const blink::WebTouchEvent&>(event);
87 PrintTouchList(delegate, touch.touches, touch.touchesLength);
88 } else if (blink::WebInputEvent::isMouseEventType(event.type()) ||
89 event.type() == blink::WebInputEvent::MouseWheel) {
90 const blink::WebMouseEvent& mouse =
91 static_cast<const blink::WebMouseEvent&>(event);
92 delegate->PrintMessage(base::StringPrintf("* %d, %d\n", mouse.x, mouse.y));
93 } else if (blink::WebInputEvent::isGestureEventType(event.type())) {
94 const blink::WebGestureEvent& gesture =
95 static_cast<const blink::WebGestureEvent&>(event);
96 delegate->PrintMessage(
97 base::StringPrintf("* %d, %d\n", gesture.x, gesture.y));
98 }
99 }
100
101 blink::WebPluginContainer::TouchEventRequestType ParseTouchEventRequestType(
102 const blink::WebString& string) {
103 if (string == blink::WebString::fromUTF8("raw"))
104 return blink::WebPluginContainer::TouchEventRequestTypeRaw;
105 if (string == blink::WebString::fromUTF8("synthetic"))
106 return blink::WebPluginContainer::TouchEventRequestTypeSynthesizedMouse;
107 return blink::WebPluginContainer::TouchEventRequestTypeNone;
108 }
109
110 } // namespace
111
112 TestPlugin::TestPlugin(blink::WebFrame* frame,
113 const blink::WebPluginParams& params,
114 WebTestDelegate* delegate)
115 : frame_(frame),
116 delegate_(delegate),
117 container_(nullptr),
118 gl_(nullptr),
119 color_texture_(0),
120 mailbox_changed_(false),
121 framebuffer_(0),
122 touch_event_request_(
123 blink::WebPluginContainer::TouchEventRequestTypeNone),
124 re_request_touch_events_(false),
125 print_event_details_(false),
126 print_user_gesture_status_(false),
127 can_process_drag_(false),
128 supports_keyboard_focus_(false),
129 is_persistent_(params.mimeType == PluginPersistsMimeType()),
130 can_create_without_renderer_(params.mimeType ==
131 CanCreateWithoutRendererMimeType()) {
132 DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size());
133 size_t size = params.attributeNames.size();
134 for (size_t i = 0; i < size; ++i) {
135 const blink::WebString& attribute_name = params.attributeNames[i];
136 const blink::WebString& attribute_value = params.attributeValues[i];
137
138 if (attribute_name == "primitive")
139 scene_.primitive = ParsePrimitive(attribute_value);
140 else if (attribute_name == "background-color")
141 ParseColor(attribute_value, scene_.background_color);
142 else if (attribute_name == "primitive-color")
143 ParseColor(attribute_value, scene_.primitive_color);
144 else if (attribute_name == "opacity")
145 scene_.opacity = ParseOpacity(attribute_value);
146 else if (attribute_name == "accepts-touch")
147 touch_event_request_ = ParseTouchEventRequestType(attribute_value);
148 else if (attribute_name == "re-request-touch")
149 re_request_touch_events_ = ParseBoolean(attribute_value);
150 else if (attribute_name == "print-event-details")
151 print_event_details_ = ParseBoolean(attribute_value);
152 else if (attribute_name == "can-process-drag")
153 can_process_drag_ = ParseBoolean(attribute_value);
154 else if (attribute_name == "supports-keyboard-focus")
155 supports_keyboard_focus_ = ParseBoolean(attribute_value);
156 else if (attribute_name == "print-user-gesture-status")
157 print_user_gesture_status_ = ParseBoolean(attribute_value);
158 }
159 if (can_create_without_renderer_)
160 delegate_->PrintMessage(
161 std::string("TestPlugin: canCreateWithoutRenderer\n"));
162 }
163
164 TestPlugin::~TestPlugin() {
165 }
166
167 bool TestPlugin::initialize(blink::WebPluginContainer* container) {
168 DCHECK(container);
169 DCHECK_EQ(this, container->plugin());
170
171 container_ = container;
172
173 blink::Platform::ContextAttributes attrs;
174 attrs.webGLVersion = 1; // We are creating a context through the WebGL APIs.
175 blink::WebURL url = container->document().url();
176 blink::Platform::GraphicsInfo gl_info;
177 context_provider_ = base::WrapUnique(
178 blink::Platform::current()->createOffscreenGraphicsContext3DProvider(
179 attrs, url, nullptr, &gl_info));
180 if (!context_provider_->bindToCurrentThread())
181 context_provider_ = nullptr;
182 gl_ = context_provider_ ? context_provider_->contextGL() : nullptr;
183
184 if (!InitScene())
185 return false;
186
187 layer_ = cc::TextureLayer::CreateForMailbox(this);
188 web_layer_ = base::WrapUnique(new cc_blink::WebLayerImpl(layer_));
189 container_->setWebLayer(web_layer_.get());
190 if (re_request_touch_events_) {
191 container_->requestTouchEventType(
192 blink::WebPluginContainer::TouchEventRequestTypeSynthesizedMouse);
193 container_->requestTouchEventType(
194 blink::WebPluginContainer::TouchEventRequestTypeRaw);
195 }
196 container_->requestTouchEventType(touch_event_request_);
197 container_->setWantsWheelEvents(true);
198 return true;
199 }
200
201 void TestPlugin::destroy() {
202 if (layer_.get())
203 layer_->ClearTexture();
204 if (container_)
205 container_->setWebLayer(0);
206 web_layer_.reset();
207 layer_ = NULL;
208 DestroyScene();
209
210 gl_ = nullptr;
211 context_provider_.reset();
212
213 container_ = nullptr;
214 frame_ = nullptr;
215
216 blink::Platform::current()
217 ->mainThread()
218 ->getSingleThreadTaskRunner()
219 ->DeleteSoon(FROM_HERE, this);
220 }
221
222 blink::WebPluginContainer* TestPlugin::container() const {
223 return container_;
224 }
225
226 bool TestPlugin::canProcessDrag() const {
227 return can_process_drag_;
228 }
229
230 bool TestPlugin::supportsKeyboardFocus() const {
231 return supports_keyboard_focus_;
232 }
233
234 void TestPlugin::updateGeometry(
235 const blink::WebRect& window_rect,
236 const blink::WebRect& clip_rect,
237 const blink::WebRect& unobscured_rect,
238 const blink::WebVector<blink::WebRect>& cut_outs_rects,
239 bool is_visible) {
240 if (clip_rect == rect_)
241 return;
242 rect_ = clip_rect;
243
244 if (rect_.isEmpty()) {
245 texture_mailbox_ = cc::TextureMailbox();
246 } else if (gl_) {
247 gl_->Viewport(0, 0, rect_.width, rect_.height);
248
249 gl_->BindTexture(GL_TEXTURE_2D, color_texture_);
250 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
251 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
252 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
253 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
254 gl_->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rect_.width, rect_.height, 0,
255 GL_RGBA, GL_UNSIGNED_BYTE, 0);
256 gl_->BindFramebuffer(GL_FRAMEBUFFER, framebuffer_);
257 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
258 GL_TEXTURE_2D, color_texture_, 0);
259
260 DrawSceneGL();
261
262 gpu::Mailbox mailbox;
263 gl_->GenMailboxCHROMIUM(mailbox.name);
264 gl_->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
265 const GLuint64 fence_sync = gl_->InsertFenceSyncCHROMIUM();
266 gl_->Flush();
267
268 gpu::SyncToken sync_token;
269 gl_->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData());
270 texture_mailbox_ = cc::TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D);
271 } else {
272 std::unique_ptr<cc::SharedBitmap> bitmap =
273 delegate_->GetSharedBitmapManager()->AllocateSharedBitmap(
274 gfx::Rect(rect_).size());
275 if (!bitmap) {
276 texture_mailbox_ = cc::TextureMailbox();
277 } else {
278 DrawSceneSoftware(bitmap->pixels());
279 texture_mailbox_ = cc::TextureMailbox(
280 bitmap.get(), gfx::Size(rect_.width, rect_.height));
281 shared_bitmap_ = std::move(bitmap);
282 }
283 }
284
285 mailbox_changed_ = true;
286 layer_->SetNeedsDisplay();
287 }
288
289 bool TestPlugin::isPlaceholder() {
290 return false;
291 }
292
293 static void IgnoreReleaseCallback(const gpu::SyncToken& sync_token, bool lost) {
294 }
295
296 static void ReleaseSharedMemory(std::unique_ptr<cc::SharedBitmap> bitmap,
297 const gpu::SyncToken& sync_token,
298 bool lost) {}
299
300 bool TestPlugin::PrepareTextureMailbox(
301 cc::TextureMailbox* mailbox,
302 std::unique_ptr<cc::SingleReleaseCallback>* release_callback) {
303 if (!mailbox_changed_)
304 return false;
305 *mailbox = texture_mailbox_;
306 if (texture_mailbox_.IsTexture()) {
307 *release_callback =
308 cc::SingleReleaseCallback::Create(base::Bind(&IgnoreReleaseCallback));
309 } else if (texture_mailbox_.IsSharedMemory()) {
310 *release_callback = cc::SingleReleaseCallback::Create(
311 base::Bind(&ReleaseSharedMemory, base::Passed(&shared_bitmap_)));
312 }
313 mailbox_changed_ = false;
314 return true;
315 }
316
317 TestPlugin::Primitive TestPlugin::ParsePrimitive(
318 const blink::WebString& string) {
319 const CR_DEFINE_STATIC_LOCAL(blink::WebString, kPrimitiveNone, ("none"));
320 const CR_DEFINE_STATIC_LOCAL(
321 blink::WebString, kPrimitiveTriangle, ("triangle"));
322
323 Primitive primitive = PrimitiveNone;
324 if (string == kPrimitiveNone)
325 primitive = PrimitiveNone;
326 else if (string == kPrimitiveTriangle)
327 primitive = PrimitiveTriangle;
328 else
329 NOTREACHED();
330 return primitive;
331 }
332
333 // FIXME: This method should already exist. Use it.
334 // For now just parse primary colors.
335 void TestPlugin::ParseColor(const blink::WebString& string, uint8_t color[3]) {
336 color[0] = color[1] = color[2] = 0;
337 if (string == "black")
338 return;
339
340 if (string == "red")
341 color[0] = 255;
342 else if (string == "green")
343 color[1] = 255;
344 else if (string == "blue")
345 color[2] = 255;
346 else
347 NOTREACHED();
348 }
349
350 float TestPlugin::ParseOpacity(const blink::WebString& string) {
351 return static_cast<float>(atof(string.utf8().data()));
352 }
353
354 bool TestPlugin::ParseBoolean(const blink::WebString& string) {
355 const CR_DEFINE_STATIC_LOCAL(blink::WebString, kPrimitiveTrue, ("true"));
356 return string == kPrimitiveTrue;
357 }
358
359 bool TestPlugin::InitScene() {
360 if (!gl_)
361 return true;
362
363 float color[4];
364 PremultiplyAlpha(scene_.background_color, scene_.opacity, color);
365
366 gl_->GenTextures(1, &color_texture_);
367 gl_->GenFramebuffers(1, &framebuffer_);
368
369 gl_->Viewport(0, 0, rect_.width, rect_.height);
370 gl_->Disable(GL_DEPTH_TEST);
371 gl_->Disable(GL_SCISSOR_TEST);
372
373 gl_->ClearColor(color[0], color[1], color[2], color[3]);
374
375 gl_->Enable(GL_BLEND);
376 gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
377
378 return scene_.primitive != PrimitiveNone ? InitProgram() && InitPrimitive()
379 : true;
380 }
381
382 void TestPlugin::DrawSceneGL() {
383 gl_->Viewport(0, 0, rect_.width, rect_.height);
384 gl_->Clear(GL_COLOR_BUFFER_BIT);
385
386 if (scene_.primitive != PrimitiveNone)
387 DrawPrimitive();
388 }
389
390 void TestPlugin::DrawSceneSoftware(void* memory) {
391 SkColor background_color = SkColorSetARGB(
392 static_cast<uint8_t>(scene_.opacity * 255), scene_.background_color[0],
393 scene_.background_color[1], scene_.background_color[2]);
394
395 const SkImageInfo info =
396 SkImageInfo::MakeN32Premul(rect_.width, rect_.height);
397 SkBitmap bitmap;
398 bitmap.installPixels(info, memory, info.minRowBytes());
399 SkCanvas canvas(bitmap);
400 canvas.clear(background_color);
401
402 if (scene_.primitive != PrimitiveNone) {
403 DCHECK_EQ(PrimitiveTriangle, scene_.primitive);
404 SkColor foreground_color = SkColorSetARGB(
405 static_cast<uint8_t>(scene_.opacity * 255), scene_.primitive_color[0],
406 scene_.primitive_color[1], scene_.primitive_color[2]);
407 SkPath triangle_path;
408 triangle_path.moveTo(0.5f * rect_.width, 0.9f * rect_.height);
409 triangle_path.lineTo(0.1f * rect_.width, 0.1f * rect_.height);
410 triangle_path.lineTo(0.9f * rect_.width, 0.1f * rect_.height);
411 SkPaint paint;
412 paint.setColor(foreground_color);
413 paint.setStyle(SkPaint::kFill_Style);
414 canvas.drawPath(triangle_path, paint);
415 }
416 }
417
418 void TestPlugin::DestroyScene() {
419 if (scene_.program) {
420 gl_->DeleteProgram(scene_.program);
421 scene_.program = 0;
422 }
423 if (scene_.vbo) {
424 gl_->DeleteBuffers(1, &scene_.vbo);
425 scene_.vbo = 0;
426 }
427
428 if (framebuffer_) {
429 gl_->DeleteFramebuffers(1, &framebuffer_);
430 framebuffer_ = 0;
431 }
432
433 if (color_texture_) {
434 gl_->DeleteTextures(1, &color_texture_);
435 color_texture_ = 0;
436 }
437 }
438
439 bool TestPlugin::InitProgram() {
440 const std::string vertex_source(
441 "attribute vec4 position; \n"
442 "void main() { \n"
443 " gl_Position = position; \n"
444 "} \n");
445
446 const std::string fragment_source(
447 "precision mediump float; \n"
448 "uniform vec4 color; \n"
449 "void main() { \n"
450 " gl_FragColor = color; \n"
451 "} \n");
452
453 scene_.program = LoadProgram(vertex_source, fragment_source);
454 if (!scene_.program)
455 return false;
456
457 scene_.color_location = gl_->GetUniformLocation(scene_.program, "color");
458 scene_.position_location = gl_->GetAttribLocation(scene_.program, "position");
459 return true;
460 }
461
462 bool TestPlugin::InitPrimitive() {
463 DCHECK_EQ(scene_.primitive, PrimitiveTriangle);
464
465 gl_->GenBuffers(1, &scene_.vbo);
466 if (!scene_.vbo)
467 return false;
468
469 const float vertices[] = {0.0f, 0.8f, 0.0f, -0.8f, -0.8f,
470 0.0f, 0.8f, -0.8f, 0.0f};
471 gl_->BindBuffer(GL_ARRAY_BUFFER, scene_.vbo);
472 gl_->BufferData(GL_ARRAY_BUFFER, sizeof(vertices), 0, GL_STATIC_DRAW);
473 gl_->BufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices);
474 return true;
475 }
476
477 void TestPlugin::DrawPrimitive() {
478 DCHECK_EQ(scene_.primitive, PrimitiveTriangle);
479 DCHECK(scene_.vbo);
480 DCHECK(scene_.program);
481
482 gl_->UseProgram(scene_.program);
483
484 // Bind primitive color.
485 float color[4];
486 PremultiplyAlpha(scene_.primitive_color, scene_.opacity, color);
487 gl_->Uniform4f(scene_.color_location, color[0], color[1], color[2], color[3]);
488
489 // Bind primitive vertices.
490 gl_->BindBuffer(GL_ARRAY_BUFFER, scene_.vbo);
491 gl_->EnableVertexAttribArray(scene_.position_location);
492 gl_->VertexAttribPointer(scene_.position_location, 3, GL_FLOAT, GL_FALSE, 0,
493 nullptr);
494 gl_->DrawArrays(GL_TRIANGLES, 0, 3);
495 }
496
497 GLuint TestPlugin::LoadShader(GLenum type, const std::string& source) {
498 GLuint shader = gl_->CreateShader(type);
499 if (shader) {
500 const GLchar* shader_data = source.data();
501 GLint shader_length = strlen(shader_data); //source.length();
502 gl_->ShaderSource(shader, 1, &shader_data, &shader_length);
503 gl_->CompileShader(shader);
504
505 int compiled = 0;
506 gl_->GetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
507 if (!compiled) {
508 gl_->DeleteShader(shader);
509 shader = 0;
510 }
511 }
512 return shader;
513 }
514
515 GLuint TestPlugin::LoadProgram(const std::string& vertex_source,
516 const std::string& fragment_source) {
517 GLuint vertex_shader = LoadShader(GL_VERTEX_SHADER, vertex_source);
518 GLuint fragment_shader = LoadShader(GL_FRAGMENT_SHADER, fragment_source);
519 GLuint program = gl_->CreateProgram();
520 if (vertex_shader && fragment_shader && program) {
521 gl_->AttachShader(program, vertex_shader);
522 gl_->AttachShader(program, fragment_shader);
523 gl_->LinkProgram(program);
524
525 int linked = 0;
526 gl_->GetProgramiv(program, GL_LINK_STATUS, &linked);
527 if (!linked) {
528 gl_->DeleteProgram(program);
529 program = 0;
530 }
531 }
532 if (vertex_shader)
533 gl_->DeleteShader(vertex_shader);
534 if (fragment_shader)
535 gl_->DeleteShader(fragment_shader);
536
537 return program;
538 }
539
540 blink::WebInputEventResult TestPlugin::handleInputEvent(
541 const blink::WebInputEvent& event,
542 blink::WebCursorInfo& info) {
543 const char* event_name = blink::WebInputEvent::GetName(event.type());
544 if (!strcmp(event_name, "") || !strcmp(event_name, "Undefined"))
545 event_name = "unknown";
546 delegate_->PrintMessage(std::string("Plugin received event: ") + event_name +
547 "\n");
548 if (print_event_details_)
549 PrintEventDetails(delegate_, event);
550 if (print_user_gesture_status_)
551 delegate_->PrintMessage(
552 std::string("* ") +
553 (blink::WebUserGestureIndicator::isProcessingUserGesture() ? ""
554 : "not ") +
555 "handling user gesture\n");
556 if (is_persistent_)
557 delegate_->PrintMessage(std::string("TestPlugin: isPersistent\n"));
558 return blink::WebInputEventResult::NotHandled;
559 }
560
561 bool TestPlugin::handleDragStatusUpdate(
562 blink::WebDragStatus drag_status,
563 const blink::WebDragData& data,
564 blink::WebDragOperationsMask mask,
565 const blink::WebPoint& position,
566 const blink::WebPoint& screen_position) {
567 const char* drag_status_name = 0;
568 switch (drag_status) {
569 case blink::WebDragStatusEnter:
570 drag_status_name = "DragEnter";
571 break;
572 case blink::WebDragStatusOver:
573 drag_status_name = "DragOver";
574 break;
575 case blink::WebDragStatusLeave:
576 drag_status_name = "DragLeave";
577 break;
578 case blink::WebDragStatusDrop:
579 drag_status_name = "DragDrop";
580 break;
581 case blink::WebDragStatusUnknown:
582 NOTREACHED();
583 }
584 delegate_->PrintMessage(std::string("Plugin received event: ") +
585 drag_status_name + "\n");
586 return false;
587 }
588
589 TestPlugin* TestPlugin::create(blink::WebFrame* frame,
590 const blink::WebPluginParams& params,
591 WebTestDelegate* delegate) {
592 return new TestPlugin(frame, params, delegate);
593 }
594
595 const blink::WebString& TestPlugin::MimeType() {
596 const CR_DEFINE_STATIC_LOCAL(
597 blink::WebString, kMimeType, ("application/x-webkit-test-webplugin"));
598 return kMimeType;
599 }
600
601 const blink::WebString& TestPlugin::CanCreateWithoutRendererMimeType() {
602 const CR_DEFINE_STATIC_LOCAL(
603 blink::WebString,
604 kCanCreateWithoutRendererMimeType,
605 ("application/x-webkit-test-webplugin-can-create-without-renderer"));
606 return kCanCreateWithoutRendererMimeType;
607 }
608
609 const blink::WebString& TestPlugin::PluginPersistsMimeType() {
610 const CR_DEFINE_STATIC_LOCAL(
611 blink::WebString,
612 kPluginPersistsMimeType,
613 ("application/x-webkit-test-webplugin-persistent"));
614 return kPluginPersistsMimeType;
615 }
616
617 bool TestPlugin::IsSupportedMimeType(const blink::WebString& mime_type) {
618 return mime_type == TestPlugin::MimeType() ||
619 mime_type == PluginPersistsMimeType() ||
620 mime_type == CanCreateWithoutRendererMimeType();
621 }
622
623 } // namespace test_runner
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698