| 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/test_webkit_platform_support.h" | 5 #include "webkit/support/test_webkit_platform_support.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/metrics/stats_counters.h" | 9 #include "base/metrics/stats_counters.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 WebKit::WebRuntimeFeatures::enableSockets(true); | 85 WebKit::WebRuntimeFeatures::enableSockets(true); |
| 86 WebKit::WebRuntimeFeatures::enableApplicationCache(true); | 86 WebKit::WebRuntimeFeatures::enableApplicationCache(true); |
| 87 WebKit::WebRuntimeFeatures::enableDatabase(true); | 87 WebKit::WebRuntimeFeatures::enableDatabase(true); |
| 88 WebKit::WebRuntimeFeatures::enableDataTransferItems(true); | 88 WebKit::WebRuntimeFeatures::enableDataTransferItems(true); |
| 89 WebKit::WebRuntimeFeatures::enableNotifications(true); | 89 WebKit::WebRuntimeFeatures::enableNotifications(true); |
| 90 WebKit::WebRuntimeFeatures::enableTouch(true); | 90 WebKit::WebRuntimeFeatures::enableTouch(true); |
| 91 WebKit::WebRuntimeFeatures::enableGamepad(true); | 91 WebKit::WebRuntimeFeatures::enableGamepad(true); |
| 92 | 92 |
| 93 // Load libraries for media and enable the media player. | 93 // Load libraries for media and enable the media player. |
| 94 bool enable_media = false; | 94 bool enable_media = false; |
| 95 FilePath module_path; | 95 base::FilePath module_path; |
| 96 if (PathService::Get(base::DIR_MODULE, &module_path)) { | 96 if (PathService::Get(base::DIR_MODULE, &module_path)) { |
| 97 #if defined(OS_MACOSX) | 97 #if defined(OS_MACOSX) |
| 98 if (base::mac::AmIBundled()) | 98 if (base::mac::AmIBundled()) |
| 99 module_path = module_path.DirName().DirName().DirName(); | 99 module_path = module_path.DirName().DirName().DirName(); |
| 100 #endif | 100 #endif |
| 101 if (media::InitializeMediaLibrary(module_path)) | 101 if (media::InitializeMediaLibrary(module_path)) |
| 102 enable_media = true; | 102 enable_media = true; |
| 103 } | 103 } |
| 104 WebKit::WebRuntimeFeatures::enableMediaPlayer(enable_media); | 104 WebKit::WebRuntimeFeatures::enableMediaPlayer(enable_media); |
| 105 LOG_IF(WARNING, !enable_media) << "Failed to initialize the media library.\n"; | 105 LOG_IF(WARNING, !enable_media) << "Failed to initialize the media library.\n"; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 134 #if defined(OS_WIN) | 134 #if defined(OS_WIN) |
| 135 // Ensure we pick up the default theme engine. | 135 // Ensure we pick up the default theme engine. |
| 136 SetThemeEngine(NULL); | 136 SetThemeEngine(NULL); |
| 137 #endif | 137 #endif |
| 138 | 138 |
| 139 net::HttpCache::Mode cache_mode = net::HttpCache::NORMAL; | 139 net::HttpCache::Mode cache_mode = net::HttpCache::NORMAL; |
| 140 net::CookieMonster::EnableFileScheme(); | 140 net::CookieMonster::EnableFileScheme(); |
| 141 | 141 |
| 142 // Initializing with a default context, which means no on-disk cookie DB, | 142 // Initializing with a default context, which means no on-disk cookie DB, |
| 143 // and no support for directory listings. | 143 // and no support for directory listings. |
| 144 SimpleResourceLoaderBridge::Init(FilePath(), cache_mode, true); | 144 SimpleResourceLoaderBridge::Init(base::FilePath(), cache_mode, true); |
| 145 | 145 |
| 146 // Test shell always exposes the GC. | 146 // Test shell always exposes the GC. |
| 147 webkit_glue::SetJavaScriptFlags(" --expose-gc"); | 147 webkit_glue::SetJavaScriptFlags(" --expose-gc"); |
| 148 // Expose GCController to JavaScript. | 148 // Expose GCController to JavaScript. |
| 149 WebScriptController::registerExtension(extensions_v8::GCExtension::Get()); | 149 WebScriptController::registerExtension(extensions_v8::GCExtension::Get()); |
| 150 } | 150 } |
| 151 | 151 |
| 152 TestWebKitPlatformSupport::~TestWebKitPlatformSupport() { | 152 TestWebKitPlatformSupport::~TestWebKitPlatformSupport() { |
| 153 if (hyphen_dictionary_) | 153 if (hyphen_dictionary_) |
| 154 hnj_hyphen_free(hyphen_dictionary_); | 154 hnj_hyphen_free(hyphen_dictionary_); |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 gamepad_data_ = data; | 476 gamepad_data_ = data; |
| 477 } | 477 } |
| 478 | 478 |
| 479 void TestWebKitPlatformSupport::GetPlugins( | 479 void TestWebKitPlatformSupport::GetPlugins( |
| 480 bool refresh, std::vector<webkit::WebPluginInfo>* plugins) { | 480 bool refresh, std::vector<webkit::WebPluginInfo>* plugins) { |
| 481 if (refresh) | 481 if (refresh) |
| 482 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); | 482 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); |
| 483 webkit::npapi::PluginList::Singleton()->GetPlugins(plugins); | 483 webkit::npapi::PluginList::Singleton()->GetPlugins(plugins); |
| 484 // Don't load the forked npapi_layout_test_plugin in DRT, we only want to | 484 // Don't load the forked npapi_layout_test_plugin in DRT, we only want to |
| 485 // use the upstream version TestNetscapePlugIn. | 485 // use the upstream version TestNetscapePlugIn. |
| 486 const FilePath::StringType kPluginBlackList[] = { | 486 const base::FilePath::StringType kPluginBlackList[] = { |
| 487 FILE_PATH_LITERAL("npapi_layout_test_plugin.dll"), | 487 FILE_PATH_LITERAL("npapi_layout_test_plugin.dll"), |
| 488 FILE_PATH_LITERAL("WebKitTestNetscapePlugIn.plugin"), | 488 FILE_PATH_LITERAL("WebKitTestNetscapePlugIn.plugin"), |
| 489 FILE_PATH_LITERAL("libnpapi_layout_test_plugin.so"), | 489 FILE_PATH_LITERAL("libnpapi_layout_test_plugin.so"), |
| 490 }; | 490 }; |
| 491 for (int i = plugins->size() - 1; i >= 0; --i) { | 491 for (int i = plugins->size() - 1; i >= 0; --i) { |
| 492 webkit::WebPluginInfo plugin_info = plugins->at(i); | 492 webkit::WebPluginInfo plugin_info = plugins->at(i); |
| 493 for (size_t j = 0; j < arraysize(kPluginBlackList); ++j) { | 493 for (size_t j = 0; j < arraysize(kPluginBlackList); ++j) { |
| 494 if (plugin_info.path.BaseName() == FilePath(kPluginBlackList[j])) { | 494 if (plugin_info.path.BaseName() == base::FilePath(kPluginBlackList[j])) { |
| 495 plugins->erase(plugins->begin() + i); | 495 plugins->erase(plugins->begin() + i); |
| 496 } | 496 } |
| 497 } | 497 } |
| 498 } | 498 } |
| 499 } | 499 } |
| 500 | 500 |
| 501 webkit_glue::ResourceLoaderBridge* | 501 webkit_glue::ResourceLoaderBridge* |
| 502 TestWebKitPlatformSupport::CreateResourceLoader( | 502 TestWebKitPlatformSupport::CreateResourceLoader( |
| 503 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { | 503 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { |
| 504 return SimpleResourceLoaderBridge::Create(request_info); | 504 return SimpleResourceLoaderBridge::Create(request_info); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 size_t TestWebKitPlatformSupport::computeLastHyphenLocation( | 539 size_t TestWebKitPlatformSupport::computeLastHyphenLocation( |
| 540 const char16* characters, | 540 const char16* characters, |
| 541 size_t length, | 541 size_t length, |
| 542 size_t before_index, | 542 size_t before_index, |
| 543 const WebKit::WebString& locale) { | 543 const WebKit::WebString& locale) { |
| 544 DCHECK(locale.isEmpty() || locale.equals("en") || locale.equals("en_US") || | 544 DCHECK(locale.isEmpty() || locale.equals("en") || locale.equals("en_US") || |
| 545 locale.equals("en_GB")); | 545 locale.equals("en_GB")); |
| 546 if (!hyphen_dictionary_) { | 546 if (!hyphen_dictionary_) { |
| 547 // Initialize the hyphen library with a sample dictionary. To avoid test | 547 // Initialize the hyphen library with a sample dictionary. To avoid test |
| 548 // flakiness, this code synchronously loads the dictionary. | 548 // flakiness, this code synchronously loads the dictionary. |
| 549 FilePath path = webkit_support::GetChromiumRootDirFilePath(); | 549 base::FilePath path = webkit_support::GetChromiumRootDirFilePath(); |
| 550 path = path.Append(FILE_PATH_LITERAL("third_party/hyphen/hyph_en_US.dic")); | 550 path = path.Append(FILE_PATH_LITERAL("third_party/hyphen/hyph_en_US.dic")); |
| 551 std::string dictionary; | 551 std::string dictionary; |
| 552 if (!file_util::ReadFileToString(path, &dictionary)) | 552 if (!file_util::ReadFileToString(path, &dictionary)) |
| 553 return 0; | 553 return 0; |
| 554 hyphen_dictionary_ = hnj_hyphen_load( | 554 hyphen_dictionary_ = hnj_hyphen_load( |
| 555 reinterpret_cast<const unsigned char*>(dictionary.data()), | 555 reinterpret_cast<const unsigned char*>(dictionary.data()), |
| 556 dictionary.length()); | 556 dictionary.length()); |
| 557 if (!hyphen_dictionary_) | 557 if (!hyphen_dictionary_) |
| 558 return 0; | 558 return 0; |
| 559 } | 559 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 return 0; | 604 return 0; |
| 605 } | 605 } |
| 606 | 606 |
| 607 WebKit::WebGestureCurve* TestWebKitPlatformSupport::createFlingAnimationCurve( | 607 WebKit::WebGestureCurve* TestWebKitPlatformSupport::createFlingAnimationCurve( |
| 608 int device_source, | 608 int device_source, |
| 609 const WebKit::WebFloatPoint& velocity, | 609 const WebKit::WebFloatPoint& velocity, |
| 610 const WebKit::WebSize& cumulative_scroll) { | 610 const WebKit::WebSize& cumulative_scroll) { |
| 611 // Caller will retain and release. | 611 // Caller will retain and release. |
| 612 return new WebGestureCurveMock(velocity, cumulative_scroll); | 612 return new WebGestureCurveMock(velocity, cumulative_scroll); |
| 613 } | 613 } |
| OLD | NEW |