| 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> |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 LOG(FATAL) << "failed to load DumpRenderTree.pak"; | 112 LOG(FATAL) << "failed to load DumpRenderTree.pak"; |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Load font files in the resource folder. | 115 // Load font files in the resource folder. |
| 116 static const char* const fontFileNames[] = { | 116 static const char* const fontFileNames[] = { |
| 117 "AHEM____.TTF", | 117 "AHEM____.TTF", |
| 118 // We don't register WebKitWeightWather fonts because of | 118 // We don't register WebKitWeightWather fonts because of |
| 119 // webkit.org/b/50709. | 119 // webkit.org/b/50709. |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 #if defined(MAC_OS_X_VERSION_10_6) && \ | |
| 123 MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 | |
| 124 NSMutableArray* font_urls = [NSMutableArray array]; | 122 NSMutableArray* font_urls = [NSMutableArray array]; |
| 125 NSURL* resources_directory = [[NSBundle mainBundle] resourceURL]; | 123 NSURL* resources_directory = [[NSBundle mainBundle] resourceURL]; |
| 126 for (unsigned i = 0; i < arraysize(fontFileNames); ++i) { | 124 for (unsigned i = 0; i < arraysize(fontFileNames); ++i) { |
| 127 NSURL* font_url = [resources_directory | 125 NSURL* font_url = [resources_directory |
| 128 URLByAppendingPathComponent:[NSString | 126 URLByAppendingPathComponent:[NSString |
| 129 stringWithUTF8String:fontFileNames[i]]]; | 127 stringWithUTF8String:fontFileNames[i]]]; |
| 130 [font_urls addObject:[font_url absoluteURL]]; | 128 [font_urls addObject:[font_url absoluteURL]]; |
| 131 } | 129 } |
| 132 | 130 |
| 133 CFArrayRef errors = 0; | 131 CFArrayRef errors = 0; |
| 134 if (!CTFontManagerRegisterFontsForURLs((CFArrayRef)font_urls, | 132 if (!CTFontManagerRegisterFontsForURLs((CFArrayRef)font_urls, |
| 135 kCTFontManagerScopeProcess, | 133 kCTFontManagerScopeProcess, |
| 136 &errors)) { | 134 &errors)) { |
| 137 DLOG(FATAL) << "Fail to activate fonts."; | 135 DLOG(FATAL) << "Fail to activate fonts."; |
| 138 CFRelease(errors); | 136 CFRelease(errors); |
| 139 } | 137 } |
| 140 #else | |
| 141 NSString* resources = [[NSBundle mainBundle] resourcePath]; | |
| 142 for (unsigned i = 0; i < arraysize(fontFileNames); ++i) { | |
| 143 const char* resource_path = [[resources stringByAppendingPathComponent: | |
| 144 [NSString stringWithUTF8String:fontFileNames[i]]] UTF8String]; | |
| 145 FSRef resource_ref; | |
| 146 const UInt8* uint8_resource_path | |
| 147 = reinterpret_cast<const UInt8*>(resource_path); | |
| 148 if (FSPathMakeRef(uint8_resource_path, &resource_ref, nil) != noErr) { | |
| 149 DLOG(FATAL) << "Fail to open " << resource_path; | |
| 150 } | |
| 151 if (ATSFontActivateFromFileReference(&resource_ref, kATSFontContextLocal, | |
| 152 kATSFontFormatUnspecified, 0, kATSOptionFlagsDefault, 0) != noErr) { | |
| 153 DLOG(FATAL) << "Fail to activate font: " << resource_path; | |
| 154 } | |
| 155 } | |
| 156 #endif | |
| 157 | 138 |
| 158 SwizzleNSPasteboard(); | 139 SwizzleNSPasteboard(); |
| 159 | 140 |
| 160 // Add <app bundle's parent dir>/plugins to the plugin path so we can load | 141 // Add <app bundle's parent dir>/plugins to the plugin path so we can load |
| 161 // test plugins. | 142 // test plugins. |
| 162 FilePath plugins_dir; | 143 FilePath plugins_dir; |
| 163 PathService::Get(base::DIR_EXE, &plugins_dir); | 144 PathService::Get(base::DIR_EXE, &plugins_dir); |
| 164 plugins_dir = plugins_dir.AppendASCII("../../../plugins"); | 145 plugins_dir = plugins_dir.AppendASCII("../../../plugins"); |
| 165 webkit::npapi::PluginList::Singleton()->AddExtraPluginDir(plugins_dir); | 146 webkit::npapi::PluginList::Singleton()->AddExtraPluginDir(plugins_dir); |
| 166 } | 147 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } | 229 } |
| 249 } | 230 } |
| 250 return resize_corner_data; | 231 return resize_corner_data; |
| 251 } | 232 } |
| 252 } | 233 } |
| 253 base::StringPiece res; | 234 base::StringPiece res; |
| 254 if (g_resource_data_pack) | 235 if (g_resource_data_pack) |
| 255 g_resource_data_pack->GetStringPiece(resource_id, &res); | 236 g_resource_data_pack->GetStringPiece(resource_id, &res); |
| 256 return res; | 237 return res; |
| 257 } | 238 } |
| OLD | NEW |