| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" | 
| (...skipping 40 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" | 
| 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   scoped_ptr<media::MessageLoopFactory> message_loop_factory( | 310   scoped_ptr<media::MessageLoopFactory> message_loop_factory( | 
| 308       new media::MessageLoopFactoryImpl()); | 311       new media::MessageLoopFactoryImpl()); | 
| 309 | 312 | 
| 310   scoped_ptr<media::FilterCollection> collection( | 313   scoped_ptr<media::FilterCollection> collection( | 
| 311       new media::FilterCollection()); | 314       new media::FilterCollection()); | 
| 312 | 315 | 
| 313   scoped_ptr<webkit_media::WebMediaPlayerImpl> result( | 316   scoped_ptr<webkit_media::WebMediaPlayerImpl> result( | 
| 314       new webkit_media::WebMediaPlayerImpl( | 317       new webkit_media::WebMediaPlayerImpl( | 
| 315           client, | 318           client, | 
| 316           base::WeakPtr<webkit_media::WebMediaPlayerDelegate>(), | 319           base::WeakPtr<webkit_media::WebMediaPlayerDelegate>(), | 
| 317           collection.release(), | 320           collection.release(), | 
| 318           message_loop_factory.release(), | 321           message_loop_factory.release(), | 
| 319           NULL, | 322           test_media_stream_client, | 
| 320           new media::MediaLog())); | 323           new media::MediaLog())); | 
| 321   if (!result->Initialize(frame, false)) { | 324   if (!result->Initialize(frame, false)) { | 
| 322     return NULL; | 325     return NULL; | 
| 323   } | 326   } | 
| 324   return result.release(); | 327   return result.release(); | 
| 325 } | 328 } | 
| 326 | 329 | 
| 327 WebKit::WebApplicationCacheHost* CreateApplicationCacheHost( | 330 WebKit::WebApplicationCacheHost* CreateApplicationCacheHost( | 
| 328     WebFrame*, WebKit::WebApplicationCacheHostClient* client) { | 331     WebFrame*, WebKit::WebApplicationCacheHostClient* client) { | 
| 329   return SimpleAppCacheSystem::CreateApplicationCacheHost(client); | 332   return SimpleAppCacheSystem::CreateApplicationCacheHost(client); | 
| 330 } | 333 } | 
| 331 | 334 | 
| 332 WebKit::WebString GetWebKitRootDir() { | 335 WebKit::WebString GetWebKitRootDir() { | 
| 333   FilePath path = GetWebKitRootDirFilePath(); | 336   FilePath path = GetWebKitRootDirFilePath(); | 
| 334   std::string path_ascii = path.MaybeAsASCII(); | 337   std::string path_ascii = path.MaybeAsASCII(); | 
| 335   CHECK(!path_ascii.empty()); | 338   CHECK(!path_ascii.empty()); | 
| 336   return WebKit::WebString::fromUTF8(path_ascii.c_str()); | 339   return WebKit::WebString::fromUTF8(path_ascii.c_str()); | 
| 337 } | 340 } | 
| 338 | 341 | 
| 339 void SetUpGLBindings(GLBindingPreferences bindingPref) { | 342 void SetUpGLBindings(GLBindingPreferences bindingPref) { | 
| 340   switch(bindingPref) { | 343   switch (bindingPref) { | 
| 341     case GL_BINDING_DEFAULT: | 344     case GL_BINDING_DEFAULT: | 
| 342       gfx::GLSurface::InitializeOneOff(); | 345       gfx::GLSurface::InitializeOneOff(); | 
| 343       break; | 346       break; | 
| 344     case GL_BINDING_SOFTWARE_RENDERER: | 347     case GL_BINDING_SOFTWARE_RENDERER: | 
| 345       gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL); | 348       gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL); | 
| 346       break; | 349       break; | 
| 347     default: | 350     default: | 
| 348       NOTREACHED(); | 351       NOTREACHED(); | 
| 349   } | 352   } | 
| 350 } | 353 } | 
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 500     return WebURL(); | 503     return WebURL(); | 
| 501 | 504 | 
| 502   const char kDataUrlPrefix[] = "data:text/css;charset=utf-8;base64,"; | 505   const char kDataUrlPrefix[] = "data:text/css;charset=utf-8;base64,"; | 
| 503   return WebURL(GURL(kDataUrlPrefix + contents_base64)); | 506   return WebURL(GURL(kDataUrlPrefix + contents_base64)); | 
| 504 } | 507 } | 
| 505 | 508 | 
| 506 // A wrapper object for exporting ScopedTempDir to be used | 509 // A wrapper object for exporting ScopedTempDir to be used | 
| 507 // by webkit layout tests. | 510 // by webkit layout tests. | 
| 508 class ScopedTempDirectoryInternal : public ScopedTempDirectory { | 511 class ScopedTempDirectoryInternal : public ScopedTempDirectory { | 
| 509  public: | 512  public: | 
| 510    virtual bool CreateUniqueTempDir() { | 513   virtual bool CreateUniqueTempDir() { | 
| 511      return tempDirectory_.CreateUniqueTempDir(); | 514     return tempDirectory_.CreateUniqueTempDir(); | 
| 512    } | 515   } | 
| 513 | 516 | 
| 514    virtual std::string path() const { | 517   virtual std::string path() const { | 
| 515      return tempDirectory_.path().MaybeAsASCII(); | 518     return tempDirectory_.path().MaybeAsASCII(); | 
| 516    } | 519   } | 
| 517 | 520 | 
| 518  private: | 521  private: | 
| 519    ScopedTempDir tempDirectory_; | 522   ScopedTempDir tempDirectory_; | 
| 520 }; | 523 }; | 
| 521 | 524 | 
| 522 ScopedTempDirectory* CreateScopedTempDirectory() { | 525 ScopedTempDirectory* CreateScopedTempDirectory() { | 
| 523   return new ScopedTempDirectoryInternal(); | 526   return new ScopedTempDirectoryInternal(); | 
| 524 } | 527 } | 
| 525 | 528 | 
| 526 int64 GetCurrentTimeInMillisecond() { | 529 int64 GetCurrentTimeInMillisecond() { | 
| 527   return base::TimeTicks::Now().ToInternalValue() | 530   return base::TimeTicks::Now().ToInternalValue() | 
| 528       / base::Time::kMicrosecondsPerMillisecond; | 531       / base::Time::kMicrosecondsPerMillisecond; | 
| 529 } | 532 } | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 547       // make this translation here to match the behavior of stock WebKit. | 550       // make this translation here to match the behavior of stock WebKit. | 
| 548       domain = "WebKitErrorDomain"; | 551       domain = "WebKitErrorDomain"; | 
| 549       code = 103; | 552       code = 103; | 
| 550       break; | 553       break; | 
| 551     case net::ERR_ADDRESS_INVALID: | 554     case net::ERR_ADDRESS_INVALID: | 
| 552     case net::ERR_ADDRESS_UNREACHABLE: | 555     case net::ERR_ADDRESS_UNREACHABLE: | 
| 553     case net::ERR_NETWORK_ACCESS_DENIED: | 556     case net::ERR_NETWORK_ACCESS_DENIED: | 
| 554       code = -1004;  // NSURLErrorCannotConnectToHost | 557       code = -1004;  // NSURLErrorCannotConnectToHost | 
| 555       break; | 558       break; | 
| 556     } | 559     } | 
| 557   } else | 560   } else { | 
| 558     DLOG(WARNING) << "Unknown error domain"; | 561     DLOG(WARNING) << "Unknown error domain"; | 
|  | 562   } | 
| 559 | 563 | 
| 560   return base::StringPrintf("<NSError domain %s, code %d, failing URL \"%s\">", | 564   return base::StringPrintf("<NSError domain %s, code %d, failing URL \"%s\">", | 
| 561       domain.c_str(), code, error.unreachableURL.spec().data()); | 565       domain.c_str(), code, error.unreachableURL.spec().data()); | 
| 562 } | 566 } | 
| 563 | 567 | 
| 564 WebKit::WebURLError CreateCancelledError(const WebKit::WebURLRequest& request) { | 568 WebKit::WebURLError CreateCancelledError(const WebKit::WebURLRequest& request) { | 
| 565   WebKit::WebURLError error; | 569   WebKit::WebURLError error; | 
| 566   error.domain = WebKit::WebString::fromUTF8(net::kErrorDomain); | 570   error.domain = WebKit::WebString::fromUTF8(net::kErrorDomain); | 
| 567   error.reason = net::ERR_ABORTED; | 571   error.reason = net::ERR_ABORTED; | 
| 568   error.unreachableURL = request.url(); | 572   error.unreachableURL = request.url(); | 
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 636 // Logging | 640 // Logging | 
| 637 void EnableWebCoreLogChannels(const std::string& channels) { | 641 void EnableWebCoreLogChannels(const std::string& channels) { | 
| 638   webkit_glue::EnableWebCoreLogChannels(channels); | 642   webkit_glue::EnableWebCoreLogChannels(channels); | 
| 639 } | 643 } | 
| 640 | 644 | 
| 641 void SetGamepadData(const WebKit::WebGamepads& pads) { | 645 void SetGamepadData(const WebKit::WebGamepads& pads) { | 
| 642   test_environment->webkit_platform_support()->setGamepadData(pads); | 646   test_environment->webkit_platform_support()->setGamepadData(pads); | 
| 643 } | 647 } | 
| 644 | 648 | 
| 645 }  // namespace webkit_support | 649 }  // namespace webkit_support | 
| OLD | NEW | 
|---|