Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/tools/test_shell/test_shell.h" | 5 #include "webkit/tools/test_shell/test_shell.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <fontconfig/fontconfig.h> | 9 #include <fontconfig/fontconfig.h> |
| 10 #include <gtk/gtk.h> | 10 #include <gtk/gtk.h> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 } | 42 } |
| 43 | 43 |
| 44 // Data resources on linux. This is a pointer to the mmapped resources file. | 44 // Data resources on linux. This is a pointer to the mmapped resources file. |
| 45 static base::DataPack* g_resource_data_pack = NULL; | 45 static base::DataPack* g_resource_data_pack = NULL; |
| 46 | 46 |
| 47 // Used to keep track of the temporary ahem file we extract to disk. | 47 // Used to keep track of the temporary ahem file we extract to disk. |
| 48 static FilePath* g_ahem_path = NULL; | 48 static FilePath* g_ahem_path = NULL; |
| 49 | 49 |
| 50 } | 50 } |
| 51 | 51 |
| 52 static void TerminationSignalHandler(int signatl) { | |
| 53 TestShell::ShutdownTestShell(); | |
| 54 exit(0); | |
| 55 } | |
| 56 | |
| 52 // static | 57 // static |
| 53 void TestShell::InitializeTestShell(bool layout_test_mode) { | 58 void TestShell::InitializeTestShell(bool layout_test_mode) { |
| 54 window_list_ = new WindowList; | 59 window_list_ = new WindowList; |
| 55 layout_test_mode_ = layout_test_mode; | 60 layout_test_mode_ = layout_test_mode; |
| 56 | 61 |
| 57 web_prefs_ = new WebPreferences; | 62 web_prefs_ = new WebPreferences; |
| 58 | 63 |
| 59 g_resource_data_pack = new base::DataPack; | 64 g_resource_data_pack = new base::DataPack; |
| 60 FilePath data_path; | 65 FilePath data_path; |
| 61 PathService::Get(base::DIR_EXE, &data_path); | 66 PathService::Get(base::DIR_EXE, &data_path); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 if (-1 == file_util::WriteFile(g_ahem_path->ToWStringHack(), ahem_font.data(), | 180 if (-1 == file_util::WriteFile(g_ahem_path->ToWStringHack(), ahem_font.data(), |
| 176 ahem_font.length())) { | 181 ahem_font.length())) { |
| 177 LOG(FATAL) << "failed to write temp ahem font"; | 182 LOG(FATAL) << "failed to write temp ahem font"; |
| 178 } | 183 } |
| 179 if (!FcConfigAppFontAddFile(fontcfg, FilePathAsFcChar(*g_ahem_path))) { | 184 if (!FcConfigAppFontAddFile(fontcfg, FilePathAsFcChar(*g_ahem_path))) { |
| 180 LOG(FATAL) << "Failed to load font " << g_ahem_path->value().c_str(); | 185 LOG(FATAL) << "Failed to load font " << g_ahem_path->value().c_str(); |
| 181 } | 186 } |
| 182 | 187 |
| 183 if (!FcConfigSetCurrent(fontcfg)) | 188 if (!FcConfigSetCurrent(fontcfg)) |
| 184 LOG(FATAL) << "Failed to set the default font configuration"; | 189 LOG(FATAL) << "Failed to set the default font configuration"; |
| 190 | |
| 191 // Install an signal handler so we clean up after ourselves. | |
|
Evan Stade
2009/03/11 01:26:38
nit: an->a
| |
| 192 signal(SIGINT, TerminationSignalHandler); | |
| 193 signal(SIGTERM, TerminationSignalHandler); | |
| 185 } | 194 } |
| 186 | 195 |
| 187 void TestShell::PlatformShutdown() { | 196 void TestShell::PlatformShutdown() { |
| 188 delete g_resource_data_pack; | 197 delete g_resource_data_pack; |
| 189 g_resource_data_pack = NULL; | 198 g_resource_data_pack = NULL; |
| 190 | 199 |
| 191 if (g_ahem_path) { | 200 if (g_ahem_path) { |
| 192 file_util::Delete(*g_ahem_path, false); | 201 file_util::Delete(*g_ahem_path, false); |
| 193 delete g_ahem_path; | 202 delete g_ahem_path; |
| 194 g_ahem_path = NULL; | 203 g_ahem_path = NULL; |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 663 StringPiece res; | 672 StringPiece res; |
| 664 g_resource_data_pack->Get(resource_id, &res); | 673 g_resource_data_pack->Get(resource_id, &res); |
| 665 return res.as_string(); | 674 return res.as_string(); |
| 666 } | 675 } |
| 667 | 676 |
| 668 bool GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { | 677 bool GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { |
| 669 return NPAPI::PluginList::Singleton()->GetPlugins(refresh, plugins); | 678 return NPAPI::PluginList::Singleton()->GetPlugins(refresh, plugins); |
| 670 } | 679 } |
| 671 | 680 |
| 672 } // namespace webkit_glue | 681 } // namespace webkit_glue |
| OLD | NEW |