| 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 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
| 8 #include <AvailabilityMacros.h> | 8 #include <AvailabilityMacros.h> |
| 9 #import <Foundation/Foundation.h> | 9 #import <Foundation/Foundation.h> |
| 10 #import <objc/objc-runtime.h> | 10 #import <objc/objc-runtime.h> |
| 11 | 11 |
| 12 #include "base/base_paths.h" | 12 #include "base/base_paths.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/mac/bundle_locations.h" | 15 #include "base/mac/bundle_locations.h" |
| 16 #include "base/mac/mac_util.h" | 16 #include "base/mac/mac_util.h" |
| 17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 18 #include "base/string16.h" | 18 #include "base/string16.h.h" |
| 19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 20 #include "grit/webkit_resources.h" | 20 #include "grit/webkit_resources.h" |
| 21 #include "ui/base/resource/data_pack.h" | 21 #include "ui/base/resource/data_pack.h" |
| 22 #include "webkit/plugins/npapi/plugin_list.h" | 22 #include "webkit/plugins/npapi/plugin_list.h" |
| 23 #include "webkit/support/test_webkit_platform_support.h" | 23 #include "webkit/support/test_webkit_platform_support.h" |
| 24 #import "webkit/support/drt_application_mac.h" | 24 #import "webkit/support/drt_application_mac.h" |
| 25 #import "webkit/tools/test_shell/mac/DumpRenderTreePasteboard.h" | 25 #import "webkit/tools/test_shell/mac/DumpRenderTreePasteboard.h" |
| 26 | 26 |
| 27 static ui::DataPack* g_resource_data_pack = NULL; | 27 static ui::DataPack* g_resource_data_pack = NULL; |
| 28 | 28 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 } | 166 } |
| 167 | 167 |
| 168 void AfterShutdown() { | 168 void AfterShutdown() { |
| 169 [DumpRenderTreePasteboard releaseLocalPasteboards]; | 169 [DumpRenderTreePasteboard releaseLocalPasteboards]; |
| 170 [autorelease_pool drain]; | 170 [autorelease_pool drain]; |
| 171 delete g_resource_data_pack; | 171 delete g_resource_data_pack; |
| 172 } | 172 } |
| 173 | 173 |
| 174 } // namespace webkit_support | 174 } // namespace webkit_support |
| 175 | 175 |
| 176 string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { | 176 base::string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) { |
| 177 // |g_resource_data_pack| is null on unit tests. | 177 // |g_resource_data_pack| is null on unit tests. |
| 178 // But som unit tests reach GetLocalizedString(). | 178 // But som unit tests reach GetLocalizedString(). |
| 179 if (!g_resource_data_pack) | 179 if (!g_resource_data_pack) |
| 180 return string16(); | 180 return base::string16(); |
| 181 base::StringPiece res; | 181 base::StringPiece res; |
| 182 if (!g_resource_data_pack->GetStringPiece(message_id, &res)) { | 182 if (!g_resource_data_pack->GetStringPiece(message_id, &res)) { |
| 183 LOG(FATAL) << "failed to load webkit string with id " << message_id; | 183 LOG(FATAL) << "failed to load webkit string with id " << message_id; |
| 184 } | 184 } |
| 185 | 185 |
| 186 // Data packs hold strings as either UTF8 or UTF16. | 186 // Data packs hold strings as either UTF8 or UTF16. |
| 187 string16 msg; | 187 base::string16 msg; |
| 188 switch (g_resource_data_pack->GetTextEncodingType()) { | 188 switch (g_resource_data_pack->GetTextEncodingType()) { |
| 189 case ui::DataPack::UTF8: | 189 case ui::DataPack::UTF8: |
| 190 msg = UTF8ToUTF16(res); | 190 msg = UTF8ToUTF16(res); |
| 191 break; | 191 break; |
| 192 case ui::DataPack::UTF16: | 192 case ui::DataPack::UTF16: |
| 193 msg = string16(reinterpret_cast<const char16*>(res.data()), | 193 msg = base::string16(reinterpret_cast<const char16*>(res.data()), |
| 194 res.length() / 2); | 194 res.length() / 2); |
| 195 break; | 195 break; |
| 196 case ui::DataPack::BINARY: | 196 case ui::DataPack::BINARY: |
| 197 NOTREACHED(); | 197 NOTREACHED(); |
| 198 break; | 198 break; |
| 199 } | 199 } |
| 200 | 200 |
| 201 return msg; | 201 return msg; |
| 202 } | 202 } |
| 203 | 203 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 } | 247 } |
| 248 } | 248 } |
| 249 return resize_corner_data; | 249 return resize_corner_data; |
| 250 } | 250 } |
| 251 } | 251 } |
| 252 base::StringPiece res; | 252 base::StringPiece res; |
| 253 if (g_resource_data_pack) | 253 if (g_resource_data_pack) |
| 254 g_resource_data_pack->GetStringPiece(resource_id, &res); | 254 g_resource_data_pack->GetStringPiece(resource_id, &res); |
| 255 return res; | 255 return res; |
| 256 } | 256 } |
| OLD | NEW |