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/platform_support.h" | 5 #include "webkit/support/platform_support.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
13 #include "grit/webkit_resources.h" | 13 #include "grit/webkit_resources.h" |
14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
15 #include "webkit/support/test_webkit_platform_support.h" | 15 #include "webkit/support/test_webkit_platform_support.h" |
16 | 16 |
17 namespace webkit_support { | 17 namespace webkit_support { |
18 | 18 |
19 // TODO(tkent): Implement some of the followings for platform-dependent tasks | 19 // TODO(tkent): Implement some of the followings for platform-dependent tasks |
20 // such as loading resource. | 20 // such as loading resource. |
21 | 21 |
22 void BeforeInitialize() { | 22 void BeforeInitialize() { |
23 } | 23 } |
24 | 24 |
25 void AfterInitialize() { | 25 void AfterInitialize() { |
26 base::FilePath data_path; | |
27 PathService::Get(base::DIR_EXE, &data_path); | |
28 data_path = data_path.Append("DumpRenderTree.pak"); | |
29 ResourceBundle::InitSharedInstanceWithPakPath(data_path); | |
30 } | 26 } |
31 | 27 |
32 void BeforeShutdown() { | 28 void BeforeShutdown() { |
33 ResourceBundle::CleanupSharedInstance(); | |
34 } | 29 } |
35 | 30 |
36 void AfterShutdown() { | 31 void AfterShutdown() { |
37 } | 32 } |
38 | 33 |
39 } // namespace webkit_support | 34 } // namespace webkit_support |
40 | 35 |
41 base::string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { | |
42 return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); | |
43 } | |
44 | |
45 base::StringPiece TestWebKitPlatformSupport::GetDataResource( | |
46 int resource_id, | |
47 ui::ScaleFactor scale_factor) { | |
48 base::FilePath resources_path; | |
49 PathService::Get(base::DIR_EXE, &resources_path); | |
50 resources_path = resources_path.Append("DumpRenderTree_resources"); | |
51 switch (resource_id) { | |
52 case IDR_BROKENIMAGE: { | |
53 CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ()); | |
54 if (broken_image_data.empty()) { | |
55 base::FilePath path = resources_path.Append("missingImage.gif"); | |
56 bool success = file_util::ReadFileToString(path, &broken_image_data); | |
57 if (!success) | |
58 LOG(FATAL) << "Failed reading: " << path.value(); | |
59 } | |
60 return broken_image_data; | |
61 } | |
62 case IDR_TEXTAREA_RESIZER: { | |
63 CR_DEFINE_STATIC_LOCAL(std::string, resize_corner_data, ()); | |
64 if (resize_corner_data.empty()) { | |
65 base::FilePath path = resources_path.Append("textAreaResizeCorner.png"); | |
66 bool success = file_util::ReadFileToString(path, &resize_corner_data); | |
67 if (!success) | |
68 LOG(FATAL) << "Failed reading: " << path.value(); | |
69 } | |
70 return resize_corner_data; | |
71 } | |
72 } | |
73 | |
74 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( | |
75 resource_id, scale_factor); | |
76 } | |
OLD | NEW |