| 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 |
| 11 #include "base/base_paths.h" | 11 #include "base/base_paths.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/mac/mac_util.h" | 14 #include "base/mac/mac_util.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/string16.h" | 16 #include "base/string16.h" |
| 17 #include "base/utf_string_conversions.h" |
| 17 #include "grit/webkit_resources.h" | 18 #include "grit/webkit_resources.h" |
| 18 #include "third_party/WebKit/Source/WebKit/mac/WebCoreSupport/WebSystemInterface
.h" | 19 #include "third_party/WebKit/Source/WebKit/mac/WebCoreSupport/WebSystemInterface
.h" |
| 19 #include "ui/base/resource/data_pack.h" | 20 #include "ui/base/resource/data_pack.h" |
| 20 #include "webkit/plugins/npapi/plugin_list.h" | 21 #include "webkit/plugins/npapi/plugin_list.h" |
| 21 #import "webkit/support/drt_application_mac.h" | 22 #import "webkit/support/drt_application_mac.h" |
| 22 #import "webkit/tools/test_shell/mac/DumpRenderTreePasteboard.h" | 23 #import "webkit/tools/test_shell/mac/DumpRenderTreePasteboard.h" |
| 23 | 24 |
| 24 static ui::DataPack* g_resource_data_pack = NULL; | 25 static ui::DataPack* g_resource_data_pack = NULL; |
| 25 | 26 |
| 26 namespace webkit_support { | 27 namespace webkit_support { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 156 |
| 156 } // namespace webkit_support | 157 } // namespace webkit_support |
| 157 | 158 |
| 158 namespace webkit_glue { | 159 namespace webkit_glue { |
| 159 | 160 |
| 160 string16 GetLocalizedString(int message_id) { | 161 string16 GetLocalizedString(int message_id) { |
| 161 base::StringPiece res; | 162 base::StringPiece res; |
| 162 if (!g_resource_data_pack->GetStringPiece(message_id, &res)) { | 163 if (!g_resource_data_pack->GetStringPiece(message_id, &res)) { |
| 163 LOG(FATAL) << "failed to load webkit string with id " << message_id; | 164 LOG(FATAL) << "failed to load webkit string with id " << message_id; |
| 164 } | 165 } |
| 165 return string16(reinterpret_cast<const char16*>(res.data()), | 166 |
| 166 res.length() / 2); | 167 // Data packs hold strings as either UTF8 or UTF16. |
| 168 string16 msg; |
| 169 switch (g_resource_data_pack->GetTextEncodingType()) { |
| 170 case ui::DataPack::UTF8: |
| 171 msg = UTF8ToUTF16(res); |
| 172 break; |
| 173 case ui::DataPack::UTF16: |
| 174 msg = string16(reinterpret_cast<const char16*>(res.data()), |
| 175 res.length() / 2); |
| 176 break; |
| 177 case ui::DataPack::BINARY: |
| 178 default: |
| 179 break; |
| 180 } |
| 181 |
| 182 return msg; |
| 167 } | 183 } |
| 168 | 184 |
| 169 // Helper method for getting the path to the test shell resources directory. | 185 // Helper method for getting the path to the test shell resources directory. |
| 170 static FilePath GetResourcesFilePath() { | 186 static FilePath GetResourcesFilePath() { |
| 171 FilePath path; | 187 FilePath path; |
| 172 // We assume the application is bundled. | 188 // We assume the application is bundled. |
| 173 if (!base::mac::AmIBundled()) { | 189 if (!base::mac::AmIBundled()) { |
| 174 LOG(FATAL) << "Failed to locate resources. The applicaiton is not bundled."; | 190 LOG(FATAL) << "Failed to locate resources. The applicaiton is not bundled."; |
| 175 } | 191 } |
| 176 PathService::Get(base::DIR_EXE, &path); | 192 PathService::Get(base::DIR_EXE, &path); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 return resize_corner_data; | 226 return resize_corner_data; |
| 211 } | 227 } |
| 212 } | 228 } |
| 213 base::StringPiece res; | 229 base::StringPiece res; |
| 214 if (g_resource_data_pack) | 230 if (g_resource_data_pack) |
| 215 g_resource_data_pack->GetStringPiece(resource_id, &res); | 231 g_resource_data_pack->GetStringPiece(resource_id, &res); |
| 216 return res; | 232 return res; |
| 217 } | 233 } |
| 218 | 234 |
| 219 } // namespace webkit_glue | 235 } // namespace webkit_glue |
| OLD | NEW |