OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
9 #import <objc/objc-runtime.h> | 9 #import <objc/objc-runtime.h> |
10 | 10 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } | 191 } |
192 PathService::Get(base::DIR_EXE, &path); | 192 PathService::Get(base::DIR_EXE, &path); |
193 path = path.Append(FilePath::kParentDirectory); | 193 path = path.Append(FilePath::kParentDirectory); |
194 return path.AppendASCII("Resources"); | 194 return path.AppendASCII("Resources"); |
195 } | 195 } |
196 | 196 |
197 base::StringPiece GetDataResource(int resource_id) { | 197 base::StringPiece GetDataResource(int resource_id) { |
198 switch (resource_id) { | 198 switch (resource_id) { |
199 case IDR_BROKENIMAGE: { | 199 case IDR_BROKENIMAGE: { |
200 // Use webkit's broken image icon (16x16) | 200 // Use webkit's broken image icon (16x16) |
201 static std::string broken_image_data; | 201 CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ()); |
202 if (broken_image_data.empty()) { | 202 if (broken_image_data.empty()) { |
203 FilePath path = GetResourcesFilePath(); | 203 FilePath path = GetResourcesFilePath(); |
204 // In order to match WebKit's colors for the missing image, we have to | 204 // In order to match WebKit's colors for the missing image, we have to |
205 // use a PNG. The GIF doesn't have the color range needed to correctly | 205 // use a PNG. The GIF doesn't have the color range needed to correctly |
206 // match the TIFF they use in Safari. | 206 // match the TIFF they use in Safari. |
207 path = path.AppendASCII("missingImage.png"); | 207 path = path.AppendASCII("missingImage.png"); |
208 bool success = file_util::ReadFileToString(path, &broken_image_data); | 208 bool success = file_util::ReadFileToString(path, &broken_image_data); |
209 if (!success) { | 209 if (!success) { |
210 LOG(FATAL) << "Failed reading: " << path.value(); | 210 LOG(FATAL) << "Failed reading: " << path.value(); |
211 } | 211 } |
212 } | 212 } |
213 return broken_image_data; | 213 return broken_image_data; |
214 } | 214 } |
215 case IDR_TEXTAREA_RESIZER: { | 215 case IDR_TEXTAREA_RESIZER: { |
216 // Use webkit's text area resizer image. | 216 // Use webkit's text area resizer image. |
217 static std::string resize_corner_data; | 217 CR_DEFINE_STATIC_LOCAL(std::string, resize_corner_data, ()); |
218 if (resize_corner_data.empty()) { | 218 if (resize_corner_data.empty()) { |
219 FilePath path = GetResourcesFilePath(); | 219 FilePath path = GetResourcesFilePath(); |
220 path = path.AppendASCII("textAreaResizeCorner.png"); | 220 path = path.AppendASCII("textAreaResizeCorner.png"); |
221 bool success = file_util::ReadFileToString(path, &resize_corner_data); | 221 bool success = file_util::ReadFileToString(path, &resize_corner_data); |
222 if (!success) { | 222 if (!success) { |
223 LOG(FATAL) << "Failed reading: " << path.value(); | 223 LOG(FATAL) << "Failed reading: " << path.value(); |
224 } | 224 } |
225 } | 225 } |
226 return resize_corner_data; | 226 return resize_corner_data; |
227 } | 227 } |
228 } | 228 } |
229 base::StringPiece res; | 229 base::StringPiece res; |
230 if (g_resource_data_pack) | 230 if (g_resource_data_pack) |
231 g_resource_data_pack->GetStringPiece(resource_id, &res); | 231 g_resource_data_pack->GetStringPiece(resource_id, &res); |
232 return res; | 232 return res; |
233 } | 233 } |
234 | 234 |
235 } // namespace webkit_glue | 235 } // namespace webkit_glue |
OLD | NEW |