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/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 const char kDumpRenderTreeDir[] = "/data/local/tmp/drt"; | 29 const char kDumpRenderTreeDir[] = "/data/local/tmp/drt"; |
30 | 30 |
31 } | 31 } |
32 | 32 |
33 namespace webkit_support { | 33 namespace webkit_support { |
34 | 34 |
35 void BeforeInitialize(bool unit_test_mode) { | 35 void BeforeInitialize(bool unit_test_mode) { |
36 base::InitAndroidTestPaths(); | 36 base::InitAndroidTestPaths(); |
37 | 37 |
38 // Place cache under kDumpRenderTreeDir to allow the NRWT script to clear it. | 38 // Place cache under kDumpRenderTreeDir to allow the NRWT script to clear it. |
39 FilePath path(kDumpRenderTreeDir); | 39 base::FilePath path(kDumpRenderTreeDir); |
40 path = path.Append("cache"); | 40 path = path.Append("cache"); |
41 PathService::Override(base::DIR_CACHE, path); | 41 PathService::Override(base::DIR_CACHE, path); |
42 | 42 |
43 // Set XML_CATALOG_FILES environment variable to blank to prevent libxml from | 43 // Set XML_CATALOG_FILES environment variable to blank to prevent libxml from |
44 // loading and complaining the non-exsistent /etc/xml/catalog file. | 44 // loading and complaining the non-exsistent /etc/xml/catalog file. |
45 setenv("XML_CATALOG_FILES", "", 0); | 45 setenv("XML_CATALOG_FILES", "", 0); |
46 | 46 |
47 JNIEnv* env = base::android::AttachCurrentThread(); | 47 JNIEnv* env = base::android::AttachCurrentThread(); |
48 net::android::RegisterNetworkLibrary(env); | 48 net::android::RegisterNetworkLibrary(env); |
49 | 49 |
50 // Chromium binaries will register their Jni bindings through the library | 50 // Chromium binaries will register their Jni bindings through the library |
51 // loader that is part of content/. WebKit uses a different path, so the | 51 // loader that is part of content/. WebKit uses a different path, so the |
52 // bindings have to be initialized separately as well. | 52 // bindings have to be initialized separately as well. |
53 if (!unit_test_mode) { | 53 if (!unit_test_mode) { |
54 media::RegisterJni(env); | 54 media::RegisterJni(env); |
55 net::android::RegisterJni(env); | 55 net::android::RegisterJni(env); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 void AfterInitialize(bool unit_test_mode) { | 59 void AfterInitialize(bool unit_test_mode) { |
60 FilePath data_path(kDumpRenderTreeDir); | 60 base::FilePath data_path(kDumpRenderTreeDir); |
61 data_path = data_path.Append("DumpRenderTree.pak"); | 61 data_path = data_path.Append("DumpRenderTree.pak"); |
62 ResourceBundle::InitSharedInstanceWithPakPath(data_path); | 62 ResourceBundle::InitSharedInstanceWithPakPath(data_path); |
63 | 63 |
64 if (unit_test_mode) | 64 if (unit_test_mode) |
65 return; | 65 return; |
66 | 66 |
67 // We enable file-over-http to bridge the file protocol to http protocol | 67 // We enable file-over-http to bridge the file protocol to http protocol |
68 // in here, which can | 68 // in here, which can |
69 // (1) run the layout and performance tests on android target device, but | 69 // (1) run the layout and performance tests on android target device, but |
70 // never need to push the test files and corresponding resources to device, | 70 // never need to push the test files and corresponding resources to device, |
(...skipping 18 matching lines...) Expand all Loading... |
89 | 89 |
90 } // namespace webkit_support | 90 } // namespace webkit_support |
91 | 91 |
92 string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { | 92 string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { |
93 return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); | 93 return ResourceBundle::GetSharedInstance().GetLocalizedString(message_id); |
94 } | 94 } |
95 | 95 |
96 base::StringPiece TestWebKitPlatformSupport::GetDataResource( | 96 base::StringPiece TestWebKitPlatformSupport::GetDataResource( |
97 int resource_id, | 97 int resource_id, |
98 ui::ScaleFactor scale_factor) { | 98 ui::ScaleFactor scale_factor) { |
99 FilePath resources_path(kDumpRenderTreeDir); | 99 base::FilePath resources_path(kDumpRenderTreeDir); |
100 resources_path = resources_path.Append("DumpRenderTree_resources"); | 100 resources_path = resources_path.Append("DumpRenderTree_resources"); |
101 switch (resource_id) { | 101 switch (resource_id) { |
102 case IDR_BROKENIMAGE: { | 102 case IDR_BROKENIMAGE: { |
103 CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ()); | 103 CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ()); |
104 if (broken_image_data.empty()) { | 104 if (broken_image_data.empty()) { |
105 FilePath path = resources_path.Append("missingImage.gif"); | 105 base::FilePath path = resources_path.Append("missingImage.gif"); |
106 bool success = file_util::ReadFileToString(path, &broken_image_data); | 106 bool success = file_util::ReadFileToString(path, &broken_image_data); |
107 if (!success) | 107 if (!success) |
108 LOG(FATAL) << "Failed reading: " << path.value(); | 108 LOG(FATAL) << "Failed reading: " << path.value(); |
109 } | 109 } |
110 return broken_image_data; | 110 return broken_image_data; |
111 } | 111 } |
112 case IDR_TEXTAREA_RESIZER: { | 112 case IDR_TEXTAREA_RESIZER: { |
113 CR_DEFINE_STATIC_LOCAL(std::string, resize_corner_data, ()); | 113 CR_DEFINE_STATIC_LOCAL(std::string, resize_corner_data, ()); |
114 if (resize_corner_data.empty()) { | 114 if (resize_corner_data.empty()) { |
115 FilePath path = resources_path.Append("textAreaResizeCorner.png"); | 115 base::FilePath path = resources_path.Append("textAreaResizeCorner.png"); |
116 bool success = file_util::ReadFileToString(path, &resize_corner_data); | 116 bool success = file_util::ReadFileToString(path, &resize_corner_data); |
117 if (!success) | 117 if (!success) |
118 LOG(FATAL) << "Failed reading: " << path.value(); | 118 LOG(FATAL) << "Failed reading: " << path.value(); |
119 } | 119 } |
120 return resize_corner_data; | 120 return resize_corner_data; |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( | 124 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( |
125 resource_id, scale_factor); | 125 resource_id, scale_factor); |
126 } | 126 } |
OLD | NEW |