OLD | NEW |
---|---|
1 // Copyright (c) 2011 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/support/webkit_support.h" | 5 #include "webkit/support/webkit_support.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/base64.h" | 8 #include "base/base64.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 #include "webkit/glue/webkit_glue.h" | 51 #include "webkit/glue/webkit_glue.h" |
52 #include "webkit/glue/webkitplatformsupport_impl.h" | 52 #include "webkit/glue/webkitplatformsupport_impl.h" |
53 #include "webkit/media/video_renderer_impl.h" | 53 #include "webkit/media/video_renderer_impl.h" |
54 #include "webkit/media/webmediaplayer_impl.h" | 54 #include "webkit/media/webmediaplayer_impl.h" |
55 #include "webkit/plugins/npapi/plugin_list.h" | 55 #include "webkit/plugins/npapi/plugin_list.h" |
56 #include "webkit/plugins/npapi/webplugin_impl.h" | 56 #include "webkit/plugins/npapi/webplugin_impl.h" |
57 #include "webkit/plugins/npapi/webplugin_page_delegate.h" | 57 #include "webkit/plugins/npapi/webplugin_page_delegate.h" |
58 #include "webkit/plugins/webplugininfo.h" | 58 #include "webkit/plugins/webplugininfo.h" |
59 #include "webkit/support/platform_support.h" | 59 #include "webkit/support/platform_support.h" |
60 #include "webkit/support/simple_database_system.h" | 60 #include "webkit/support/simple_database_system.h" |
61 #include "webkit/support/test_media_stream_client.h" | |
acolwell GONE FROM CHROMIUM
2012/01/06 18:09:16
nit: If you change CreateMediaPlayer() to take a M
wjia(left Chromium)
2012/01/06 22:18:59
Done.
| |
61 #include "webkit/support/test_webkit_platform_support.h" | 62 #include "webkit/support/test_webkit_platform_support.h" |
62 #include "webkit/support/test_webplugin_page_delegate.h" | 63 #include "webkit/support/test_webplugin_page_delegate.h" |
63 #include "webkit/tools/test_shell/simple_file_system.h" | 64 #include "webkit/tools/test_shell/simple_file_system.h" |
64 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" | 65 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" |
65 | 66 |
66 using WebKit::WebCString; | 67 using WebKit::WebCString; |
67 using WebKit::WebDevToolsAgentClient; | 68 using WebKit::WebDevToolsAgentClient; |
68 using WebKit::WebFileSystem; | 69 using WebKit::WebFileSystem; |
69 using WebKit::WebFileSystemCallbacks; | 70 using WebKit::WebFileSystemCallbacks; |
70 using WebKit::WebFrame; | 71 using WebKit::WebFrame; |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 NULL, &plugins, &mime_types); | 296 NULL, &plugins, &mime_types); |
296 if (plugins.empty()) | 297 if (plugins.empty()) |
297 return NULL; | 298 return NULL; |
298 | 299 |
299 WebPluginParams new_params = params; | 300 WebPluginParams new_params = params; |
300 new_params.mimeType = WebString::fromUTF8(mime_types.front()); | 301 new_params.mimeType = WebString::fromUTF8(mime_types.front()); |
301 return new WebPluginImplWithPageDelegate( | 302 return new WebPluginImplWithPageDelegate( |
302 frame, new_params, plugins.front().path); | 303 frame, new_params, plugins.front().path); |
303 } | 304 } |
304 | 305 |
305 WebKit::WebMediaPlayer* CreateMediaPlayer(WebFrame* frame, | 306 WebKit::WebMediaPlayer* CreateMediaPlayer( |
306 WebMediaPlayerClient* client) { | 307 WebFrame* frame, |
308 WebMediaPlayerClient* client, | |
309 TestMediaStreamClient* test_media_stream_client) { | |
307 #if defined(OS_ANDROID) | 310 #if defined(OS_ANDROID) |
308 // TODO: Implement the WebMediaPlayer that will be used for Android. | 311 // TODO: Implement the WebMediaPlayer that will be used for Android. |
309 return NULL; | 312 return NULL; |
310 #else | 313 #else |
311 scoped_ptr<media::MessageLoopFactory> message_loop_factory( | 314 scoped_ptr<media::MessageLoopFactory> message_loop_factory( |
312 new media::MessageLoopFactoryImpl()); | 315 new media::MessageLoopFactoryImpl()); |
313 | 316 |
314 scoped_ptr<media::FilterCollection> collection( | 317 scoped_ptr<media::FilterCollection> collection( |
315 new media::FilterCollection()); | 318 new media::FilterCollection()); |
316 | 319 |
317 scoped_ptr<webkit_media::WebMediaPlayerImpl> result( | 320 scoped_ptr<webkit_media::WebMediaPlayerImpl> result( |
318 new webkit_media::WebMediaPlayerImpl( | 321 new webkit_media::WebMediaPlayerImpl( |
319 client, | 322 client, |
320 base::WeakPtr<webkit_media::WebMediaPlayerDelegate>(), | 323 base::WeakPtr<webkit_media::WebMediaPlayerDelegate>(), |
321 collection.release(), | 324 collection.release(), |
322 message_loop_factory.release(), | 325 message_loop_factory.release(), |
323 NULL, | 326 test_media_stream_client, |
324 new media::MediaLog())); | 327 new media::MediaLog())); |
325 if (!result->Initialize(frame, false)) { | 328 if (!result->Initialize(frame, false)) { |
326 return NULL; | 329 return NULL; |
327 } | 330 } |
328 return result.release(); | 331 return result.release(); |
329 #endif | 332 #endif |
330 } | 333 } |
331 | 334 |
335 WebKit::WebMediaPlayer* CreateMediaPlayer( | |
336 WebFrame* frame, | |
337 WebMediaPlayerClient* client) { | |
338 return CreateMediaPlayer(frame, client, NULL); | |
339 } | |
340 | |
332 WebKit::WebApplicationCacheHost* CreateApplicationCacheHost( | 341 WebKit::WebApplicationCacheHost* CreateApplicationCacheHost( |
333 WebFrame*, WebKit::WebApplicationCacheHostClient* client) { | 342 WebFrame*, WebKit::WebApplicationCacheHostClient* client) { |
334 return SimpleAppCacheSystem::CreateApplicationCacheHost(client); | 343 return SimpleAppCacheSystem::CreateApplicationCacheHost(client); |
335 } | 344 } |
336 | 345 |
337 WebKit::WebString GetWebKitRootDir() { | 346 WebKit::WebString GetWebKitRootDir() { |
338 FilePath path = GetWebKitRootDirFilePath(); | 347 FilePath path = GetWebKitRootDirFilePath(); |
339 std::string path_ascii = path.MaybeAsASCII(); | 348 std::string path_ascii = path.MaybeAsASCII(); |
340 CHECK(!path_ascii.empty()); | 349 CHECK(!path_ascii.empty()); |
341 return WebKit::WebString::fromUTF8(path_ascii.c_str()); | 350 return WebKit::WebString::fromUTF8(path_ascii.c_str()); |
342 } | 351 } |
343 | 352 |
344 void SetUpGLBindings(GLBindingPreferences bindingPref) { | 353 void SetUpGLBindings(GLBindingPreferences bindingPref) { |
345 switch(bindingPref) { | 354 switch (bindingPref) { |
346 case GL_BINDING_DEFAULT: | 355 case GL_BINDING_DEFAULT: |
347 gfx::GLSurface::InitializeOneOff(); | 356 gfx::GLSurface::InitializeOneOff(); |
348 break; | 357 break; |
349 case GL_BINDING_SOFTWARE_RENDERER: | 358 case GL_BINDING_SOFTWARE_RENDERER: |
350 gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL); | 359 gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL); |
351 break; | 360 break; |
352 default: | 361 default: |
353 NOTREACHED(); | 362 NOTREACHED(); |
354 } | 363 } |
355 } | 364 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
505 return WebURL(); | 514 return WebURL(); |
506 | 515 |
507 const char kDataUrlPrefix[] = "data:text/css;charset=utf-8;base64,"; | 516 const char kDataUrlPrefix[] = "data:text/css;charset=utf-8;base64,"; |
508 return WebURL(GURL(kDataUrlPrefix + contents_base64)); | 517 return WebURL(GURL(kDataUrlPrefix + contents_base64)); |
509 } | 518 } |
510 | 519 |
511 // A wrapper object for exporting ScopedTempDir to be used | 520 // A wrapper object for exporting ScopedTempDir to be used |
512 // by webkit layout tests. | 521 // by webkit layout tests. |
513 class ScopedTempDirectoryInternal : public ScopedTempDirectory { | 522 class ScopedTempDirectoryInternal : public ScopedTempDirectory { |
514 public: | 523 public: |
515 virtual bool CreateUniqueTempDir() { | 524 virtual bool CreateUniqueTempDir() { |
516 return tempDirectory_.CreateUniqueTempDir(); | 525 return tempDirectory_.CreateUniqueTempDir(); |
517 } | 526 } |
518 | 527 |
519 virtual std::string path() const { | 528 virtual std::string path() const { |
520 return tempDirectory_.path().MaybeAsASCII(); | 529 return tempDirectory_.path().MaybeAsASCII(); |
521 } | 530 } |
522 | 531 |
523 private: | 532 private: |
524 ScopedTempDir tempDirectory_; | 533 ScopedTempDir tempDirectory_; |
525 }; | 534 }; |
526 | 535 |
527 ScopedTempDirectory* CreateScopedTempDirectory() { | 536 ScopedTempDirectory* CreateScopedTempDirectory() { |
528 return new ScopedTempDirectoryInternal(); | 537 return new ScopedTempDirectoryInternal(); |
529 } | 538 } |
530 | 539 |
531 int64 GetCurrentTimeInMillisecond() { | 540 int64 GetCurrentTimeInMillisecond() { |
532 return base::TimeTicks::Now().ToInternalValue() | 541 return base::TimeTicks::Now().ToInternalValue() |
533 / base::Time::kMicrosecondsPerMillisecond; | 542 / base::Time::kMicrosecondsPerMillisecond; |
534 } | 543 } |
(...skipping 17 matching lines...) Expand all Loading... | |
552 // make this translation here to match the behavior of stock WebKit. | 561 // make this translation here to match the behavior of stock WebKit. |
553 domain = "WebKitErrorDomain"; | 562 domain = "WebKitErrorDomain"; |
554 code = 103; | 563 code = 103; |
555 break; | 564 break; |
556 case net::ERR_ADDRESS_INVALID: | 565 case net::ERR_ADDRESS_INVALID: |
557 case net::ERR_ADDRESS_UNREACHABLE: | 566 case net::ERR_ADDRESS_UNREACHABLE: |
558 case net::ERR_NETWORK_ACCESS_DENIED: | 567 case net::ERR_NETWORK_ACCESS_DENIED: |
559 code = -1004; // NSURLErrorCannotConnectToHost | 568 code = -1004; // NSURLErrorCannotConnectToHost |
560 break; | 569 break; |
561 } | 570 } |
562 } else | 571 } else { |
563 DLOG(WARNING) << "Unknown error domain"; | 572 DLOG(WARNING) << "Unknown error domain"; |
573 } | |
564 | 574 |
565 return base::StringPrintf("<NSError domain %s, code %d, failing URL \"%s\">", | 575 return base::StringPrintf("<NSError domain %s, code %d, failing URL \"%s\">", |
566 domain.c_str(), code, error.unreachableURL.spec().data()); | 576 domain.c_str(), code, error.unreachableURL.spec().data()); |
567 } | 577 } |
568 | 578 |
569 WebKit::WebURLError CreateCancelledError(const WebKit::WebURLRequest& request) { | 579 WebKit::WebURLError CreateCancelledError(const WebKit::WebURLRequest& request) { |
570 WebKit::WebURLError error; | 580 WebKit::WebURLError error; |
571 error.domain = WebKit::WebString::fromUTF8(net::kErrorDomain); | 581 error.domain = WebKit::WebString::fromUTF8(net::kErrorDomain); |
572 error.reason = net::ERR_ABORTED; | 582 error.reason = net::ERR_ABORTED; |
573 error.unreachableURL = request.url(); | 583 error.unreachableURL = request.url(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
641 // Logging | 651 // Logging |
642 void EnableWebCoreLogChannels(const std::string& channels) { | 652 void EnableWebCoreLogChannels(const std::string& channels) { |
643 webkit_glue::EnableWebCoreLogChannels(channels); | 653 webkit_glue::EnableWebCoreLogChannels(channels); |
644 } | 654 } |
645 | 655 |
646 void SetGamepadData(const WebKit::WebGamepads& pads) { | 656 void SetGamepadData(const WebKit::WebGamepads& pads) { |
647 test_environment->webkit_platform_support()->setGamepadData(pads); | 657 test_environment->webkit_platform_support()->setGamepadData(pads); |
648 } | 658 } |
649 | 659 |
650 } // namespace webkit_support | 660 } // namespace webkit_support |
OLD | NEW |