Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: webkit/support/platform_support_mac.mm

Issue 8602002: Move some webkit_glue embedder functions into WebKitPlatformSupport virtual methods (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: copyright year Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/support/platform_support_linux.cc ('k') | webkit/support/platform_support_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/utf_string_conversions.h"
18 #include "grit/webkit_resources.h" 18 #include "grit/webkit_resources.h"
19 #include "third_party/WebKit/Source/WebKit/mac/WebCoreSupport/WebSystemInterface .h" 19 #include "third_party/WebKit/Source/WebKit/mac/WebCoreSupport/WebSystemInterface .h"
20 #include "ui/base/resource/data_pack.h" 20 #include "ui/base/resource/data_pack.h"
21 #include "webkit/plugins/npapi/plugin_list.h" 21 #include "webkit/plugins/npapi/plugin_list.h"
22 #include "webkit/support/test_webkit_platform_support.h"
22 #import "webkit/support/drt_application_mac.h" 23 #import "webkit/support/drt_application_mac.h"
23 #import "webkit/tools/test_shell/mac/DumpRenderTreePasteboard.h" 24 #import "webkit/tools/test_shell/mac/DumpRenderTreePasteboard.h"
24 25
25 static ui::DataPack* g_resource_data_pack = NULL; 26 static ui::DataPack* g_resource_data_pack = NULL;
26 27
27 namespace webkit_support { 28 namespace webkit_support {
28 29
29 static NSAutoreleasePool* autorelease_pool; 30 static NSAutoreleasePool* autorelease_pool;
30 31
31 void BeforeInitialize(bool unit_test_mode) { 32 void BeforeInitialize(bool unit_test_mode) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 150 }
150 151
151 void AfterShutdown() { 152 void AfterShutdown() {
152 [DumpRenderTreePasteboard releaseLocalPasteboards]; 153 [DumpRenderTreePasteboard releaseLocalPasteboards];
153 [autorelease_pool drain]; 154 [autorelease_pool drain];
154 delete g_resource_data_pack; 155 delete g_resource_data_pack;
155 } 156 }
156 157
157 } // namespace webkit_support 158 } // namespace webkit_support
158 159
159 namespace webkit_glue { 160 string16 TestWebKitPlatformSupport::GetLocalizedString(int message_id) {
160
161 string16 GetLocalizedString(int message_id) {
162 base::StringPiece res; 161 base::StringPiece res;
163 if (!g_resource_data_pack->GetStringPiece(message_id, &res)) { 162 if (!g_resource_data_pack->GetStringPiece(message_id, &res)) {
164 LOG(FATAL) << "failed to load webkit string with id " << message_id; 163 LOG(FATAL) << "failed to load webkit string with id " << message_id;
165 } 164 }
166 165
167 // Data packs hold strings as either UTF8 or UTF16. 166 // Data packs hold strings as either UTF8 or UTF16.
168 string16 msg; 167 string16 msg;
169 switch (g_resource_data_pack->GetTextEncodingType()) { 168 switch (g_resource_data_pack->GetTextEncodingType()) {
170 case ui::DataPack::UTF8: 169 case ui::DataPack::UTF8:
171 msg = UTF8ToUTF16(res); 170 msg = UTF8ToUTF16(res);
(...skipping 15 matching lines...) Expand all
187 FilePath path; 186 FilePath path;
188 // We assume the application is bundled. 187 // We assume the application is bundled.
189 if (!base::mac::AmIBundled()) { 188 if (!base::mac::AmIBundled()) {
190 LOG(FATAL) << "Failed to locate resources. The applicaiton is not bundled."; 189 LOG(FATAL) << "Failed to locate resources. The applicaiton is not bundled.";
191 } 190 }
192 PathService::Get(base::DIR_EXE, &path); 191 PathService::Get(base::DIR_EXE, &path);
193 path = path.Append(FilePath::kParentDirectory); 192 path = path.Append(FilePath::kParentDirectory);
194 return path.AppendASCII("Resources"); 193 return path.AppendASCII("Resources");
195 } 194 }
196 195
197 base::StringPiece GetDataResource(int resource_id) { 196 base::StringPiece TestWebKitPlatformSupport::GetDataResource(int resource_id) {
198 switch (resource_id) { 197 switch (resource_id) {
199 case IDR_BROKENIMAGE: { 198 case IDR_BROKENIMAGE: {
200 // Use webkit's broken image icon (16x16) 199 // Use webkit's broken image icon (16x16)
201 CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ()); 200 CR_DEFINE_STATIC_LOCAL(std::string, broken_image_data, ());
202 if (broken_image_data.empty()) { 201 if (broken_image_data.empty()) {
203 FilePath path = GetResourcesFilePath(); 202 FilePath path = GetResourcesFilePath();
204 // In order to match WebKit's colors for the missing image, we have to 203 // 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 204 // use a PNG. The GIF doesn't have the color range needed to correctly
206 // match the TIFF they use in Safari. 205 // match the TIFF they use in Safari.
207 path = path.AppendASCII("missingImage.png"); 206 path = path.AppendASCII("missingImage.png");
(...skipping 16 matching lines...) Expand all
224 } 223 }
225 } 224 }
226 return resize_corner_data; 225 return resize_corner_data;
227 } 226 }
228 } 227 }
229 base::StringPiece res; 228 base::StringPiece res;
230 if (g_resource_data_pack) 229 if (g_resource_data_pack)
231 g_resource_data_pack->GetStringPiece(resource_id, &res); 230 g_resource_data_pack->GetStringPiece(resource_id, &res);
232 return res; 231 return res;
233 } 232 }
234
235 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/support/platform_support_linux.cc ('k') | webkit/support/platform_support_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698