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