| OLD | NEW |
| 1 // Copyright (c) 2012 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/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 #include "webkit/glue/webkit_glue.h" | 55 #include "webkit/glue/webkit_glue.h" |
| 56 #include "webkit/glue/webkitplatformsupport_impl.h" | 56 #include "webkit/glue/webkitplatformsupport_impl.h" |
| 57 #include "webkit/glue/weburlrequest_extradata_impl.h" | 57 #include "webkit/glue/weburlrequest_extradata_impl.h" |
| 58 #include "webkit/plugins/npapi/plugin_list.h" | 58 #include "webkit/plugins/npapi/plugin_list.h" |
| 59 #include "webkit/plugins/npapi/webplugin_impl.h" | 59 #include "webkit/plugins/npapi/webplugin_impl.h" |
| 60 #include "webkit/plugins/npapi/webplugin_page_delegate.h" | 60 #include "webkit/plugins/npapi/webplugin_page_delegate.h" |
| 61 #include "webkit/plugins/webplugininfo.h" | 61 #include "webkit/plugins/webplugininfo.h" |
| 62 #include "webkit/renderer/appcache/web_application_cache_host_impl.h" | 62 #include "webkit/renderer/appcache/web_application_cache_host_impl.h" |
| 63 #include "webkit/renderer/compositor_bindings/web_compositor_support_impl.h" | 63 #include "webkit/renderer/compositor_bindings/web_compositor_support_impl.h" |
| 64 #include "webkit/support/platform_support.h" | 64 #include "webkit/support/platform_support.h" |
| 65 #include "webkit/support/simple_appcache_system.h" | |
| 66 #include "webkit/support/simple_database_system.h" | |
| 67 #include "webkit/support/simple_dom_storage_system.h" | |
| 68 #include "webkit/support/simple_file_system.h" | |
| 69 #include "webkit/support/simple_resource_loader_bridge.h" | |
| 70 #include "webkit/support/test_webkit_platform_support.h" | 65 #include "webkit/support/test_webkit_platform_support.h" |
| 71 #include "webkit/support/test_webplugin_page_delegate.h" | 66 #include "webkit/support/test_webplugin_page_delegate.h" |
| 72 #include "webkit/support/web_layer_tree_view_impl_for_testing.h" | 67 #include "webkit/support/web_layer_tree_view_impl_for_testing.h" |
| 73 | 68 |
| 74 #if defined(OS_ANDROID) | 69 #if defined(OS_ANDROID) |
| 75 #include "base/test/test_support_android.h" | 70 #include "base/test/test_support_android.h" |
| 76 #endif | 71 #endif |
| 77 | 72 |
| 78 using WebKit::WebCString; | 73 using WebKit::WebCString; |
| 79 using WebKit::WebDevToolsAgentClient; | 74 using WebKit::WebDevToolsAgentClient; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 #endif | 138 #endif |
| 144 | 139 |
| 145 TestEnvironment() { | 140 TestEnvironment() { |
| 146 logging::SetLogAssertHandler(UnitTestAssertHandler); | 141 logging::SetLogAssertHandler(UnitTestAssertHandler); |
| 147 main_message_loop_.reset(new MessageLoopType); | 142 main_message_loop_.reset(new MessageLoopType); |
| 148 | 143 |
| 149 // TestWebKitPlatformSupport must be instantiated after MessageLoopType. | 144 // TestWebKitPlatformSupport must be instantiated after MessageLoopType. |
| 150 webkit_platform_support_.reset(new TestWebKitPlatformSupport); | 145 webkit_platform_support_.reset(new TestWebKitPlatformSupport); |
| 151 } | 146 } |
| 152 | 147 |
| 153 ~TestEnvironment() { | |
| 154 SimpleResourceLoaderBridge::Shutdown(); | |
| 155 } | |
| 156 | |
| 157 TestWebKitPlatformSupport* webkit_platform_support() const { | 148 TestWebKitPlatformSupport* webkit_platform_support() const { |
| 158 return webkit_platform_support_.get(); | 149 return webkit_platform_support_.get(); |
| 159 } | 150 } |
| 160 | 151 |
| 161 #if defined(OS_WIN) || defined(OS_MACOSX) | 152 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 162 void set_theme_engine(WebKit::WebThemeEngine* engine) { | 153 void set_theme_engine(WebKit::WebThemeEngine* engine) { |
| 163 DCHECK(webkit_platform_support_ != 0); | 154 DCHECK(webkit_platform_support_ != 0); |
| 164 webkit_platform_support_->SetThemeEngine(engine); | 155 webkit_platform_support_->SetThemeEngine(engine); |
| 165 } | 156 } |
| 166 | 157 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 NULL, &plugins, &mime_types); | 310 NULL, &plugins, &mime_types); |
| 320 if (plugins.empty()) | 311 if (plugins.empty()) |
| 321 return NULL; | 312 return NULL; |
| 322 | 313 |
| 323 WebPluginParams new_params = params; | 314 WebPluginParams new_params = params; |
| 324 new_params.mimeType = WebString::fromUTF8(mime_types.front()); | 315 new_params.mimeType = WebString::fromUTF8(mime_types.front()); |
| 325 return new WebPluginImplWithPageDelegate( | 316 return new WebPluginImplWithPageDelegate( |
| 326 frame, new_params, plugins.front().path); | 317 frame, new_params, plugins.front().path); |
| 327 } | 318 } |
| 328 | 319 |
| 329 WebKit::WebApplicationCacheHost* CreateApplicationCacheHost( | |
| 330 WebFrame*, WebKit::WebApplicationCacheHostClient* client) { | |
| 331 return SimpleAppCacheSystem::CreateApplicationCacheHost(client); | |
| 332 } | |
| 333 | |
| 334 WebKit::WebStorageNamespace* CreateSessionStorageNamespace(unsigned quota) { | |
| 335 return SimpleDomStorageSystem::instance().CreateSessionStorageNamespace(); | |
| 336 } | |
| 337 | |
| 338 WebKit::WebString GetWebKitRootDir() { | 320 WebKit::WebString GetWebKitRootDir() { |
| 339 base::FilePath path = GetWebKitRootDirFilePath(); | 321 base::FilePath path = GetWebKitRootDirFilePath(); |
| 340 std::string path_ascii = path.MaybeAsASCII(); | 322 std::string path_ascii = path.MaybeAsASCII(); |
| 341 CHECK(!path_ascii.empty()); | 323 CHECK(!path_ascii.empty()); |
| 342 return WebKit::WebString::fromUTF8(path_ascii.c_str()); | 324 return WebKit::WebString::fromUTF8(path_ascii.c_str()); |
| 343 } | 325 } |
| 344 | 326 |
| 345 void SetUpGLBindings(GLBindingPreferences bindingPref) { | 327 void SetUpGLBindings(GLBindingPreferences bindingPref) { |
| 346 switch (bindingPref) { | 328 switch (bindingPref) { |
| 347 case GL_BINDING_DEFAULT: | 329 case GL_BINDING_DEFAULT: |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 error.unreachableURL = request.url(); | 627 error.unreachableURL = request.url(); |
| 646 return error; | 628 return error; |
| 647 } | 629 } |
| 648 | 630 |
| 649 WebKit::WebURLRequest::ExtraData* CreateWebURLRequestExtraData( | 631 WebKit::WebURLRequest::ExtraData* CreateWebURLRequestExtraData( |
| 650 WebKit::WebReferrerPolicy referrer_policy) { | 632 WebKit::WebReferrerPolicy referrer_policy) { |
| 651 return new webkit_glue::WebURLRequestExtraDataImpl(referrer_policy, | 633 return new webkit_glue::WebURLRequestExtraDataImpl(referrer_policy, |
| 652 WebKit::WebString()); | 634 WebKit::WebString()); |
| 653 } | 635 } |
| 654 | 636 |
| 655 // Bridge for SimpleDatabaseSystem | |
| 656 | |
| 657 void SetDatabaseQuota(int quota) { | |
| 658 SimpleDatabaseSystem::GetInstance()->SetDatabaseQuota(quota); | |
| 659 } | |
| 660 | |
| 661 void ClearAllDatabases() { | |
| 662 SimpleDatabaseSystem::GetInstance()->ClearAllDatabases(); | |
| 663 } | |
| 664 | |
| 665 // Bridge for SimpleResourceLoaderBridge | |
| 666 | |
| 667 void SetAcceptAllCookies(bool accept) { | |
| 668 SimpleResourceLoaderBridge::SetAcceptAllCookies(accept); | |
| 669 } | |
| 670 | |
| 671 // Theme engine | 637 // Theme engine |
| 672 #if defined(OS_WIN) || defined(OS_MACOSX) | 638 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 673 | 639 |
| 674 void SetThemeEngine(WebKit::WebThemeEngine* engine) { | 640 void SetThemeEngine(WebKit::WebThemeEngine* engine) { |
| 675 DCHECK(test_environment); | 641 DCHECK(test_environment); |
| 676 test_environment->set_theme_engine(engine); | 642 test_environment->set_theme_engine(engine); |
| 677 } | 643 } |
| 678 | 644 |
| 679 WebKit::WebThemeEngine* GetThemeEngine() { | 645 WebKit::WebThemeEngine* GetThemeEngine() { |
| 680 DCHECK(test_environment); | 646 DCHECK(test_environment); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 691 return WebURL(); | 657 return WebURL(); |
| 692 } | 658 } |
| 693 #if defined(OS_MACOSX) | 659 #if defined(OS_MACOSX) |
| 694 dirExe = dirExe.AppendASCII("../../.."); | 660 dirExe = dirExe.AppendASCII("../../.."); |
| 695 #endif | 661 #endif |
| 696 base::FilePath devToolsPath = dirExe.AppendASCII( | 662 base::FilePath devToolsPath = dirExe.AppendASCII( |
| 697 "resources/inspector/devtools.html"); | 663 "resources/inspector/devtools.html"); |
| 698 return net::FilePathToFileURL(devToolsPath); | 664 return net::FilePathToFileURL(devToolsPath); |
| 699 } | 665 } |
| 700 | 666 |
| 701 // FileSystem | |
| 702 void OpenFileSystem(WebFrame* frame, | |
| 703 WebKit::WebFileSystemType type, | |
| 704 long long size, bool create, WebFileSystemCallbacks* callbacks) { | |
| 705 SimpleFileSystem* fileSystem = static_cast<SimpleFileSystem*>( | |
| 706 test_environment->webkit_platform_support()->fileSystem()); | |
| 707 fileSystem->OpenFileSystem(frame, type, size, create, callbacks); | |
| 708 } | |
| 709 | |
| 710 void DeleteFileSystem(WebFrame* frame, | |
| 711 WebKit::WebFileSystemType type, | |
| 712 WebFileSystemCallbacks* callbacks) { | |
| 713 SimpleFileSystem* fileSystem = static_cast<SimpleFileSystem*>( | |
| 714 test_environment->webkit_platform_support()->fileSystem()); | |
| 715 fileSystem->DeleteFileSystem(frame, type, callbacks); | |
| 716 } | |
| 717 | |
| 718 WebKit::WebString RegisterIsolatedFileSystem( | 667 WebKit::WebString RegisterIsolatedFileSystem( |
| 719 const WebKit::WebVector<WebKit::WebString>& filenames) { | 668 const WebKit::WebVector<WebKit::WebString>& filenames) { |
| 720 fileapi::IsolatedContext::FileInfoSet files; | 669 fileapi::IsolatedContext::FileInfoSet files; |
| 721 for (size_t i = 0; i < filenames.size(); ++i) { | 670 for (size_t i = 0; i < filenames.size(); ++i) { |
| 722 base::FilePath path = webkit_base::WebStringToFilePath(filenames[i]); | 671 base::FilePath path = webkit_base::WebStringToFilePath(filenames[i]); |
| 723 files.AddPath(path, NULL); | 672 files.AddPath(path, NULL); |
| 724 } | 673 } |
| 725 std::string filesystemId = | 674 std::string filesystemId = |
| 726 fileapi::IsolatedContext::GetInstance()->RegisterDraggedFileSystem(files); | 675 fileapi::IsolatedContext::GetInstance()->RegisterDraggedFileSystem(files); |
| 727 return UTF8ToUTF16(filesystemId); | 676 return UTF8ToUTF16(filesystemId); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 738 // Logging | 687 // Logging |
| 739 void EnableWebCoreLogChannels(const std::string& channels) { | 688 void EnableWebCoreLogChannels(const std::string& channels) { |
| 740 webkit_glue::EnableWebCoreLogChannels(channels); | 689 webkit_glue::EnableWebCoreLogChannels(channels); |
| 741 } | 690 } |
| 742 | 691 |
| 743 void SetGamepadData(const WebKit::WebGamepads& pads) { | 692 void SetGamepadData(const WebKit::WebGamepads& pads) { |
| 744 test_environment->webkit_platform_support()->setGamepadData(pads); | 693 test_environment->webkit_platform_support()->setGamepadData(pads); |
| 745 } | 694 } |
| 746 | 695 |
| 747 } // namespace webkit_support | 696 } // namespace webkit_support |
| OLD | NEW |