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

Side by Side Diff: webkit/plugins/ppapi/ppb_pdf_impl.cc

Issue 5828003: Move the Pepper implementation from webkit/glue/plugins/pepper_* to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years 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/plugins/ppapi/ppb_pdf_impl.h ('k') | webkit/plugins/ppapi/ppb_scrollbar_impl.h » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "build/build_config.h" 5 #include "webkit/plugins/ppapi/ppb_pdf_impl.h"
6
7 #include "webkit/glue/plugins/pepper_private.h"
8
9 #include "unicode/usearch.h"
10 6
11 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
12 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
13 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "build/build_config.h"
14 #include "grit/webkit_resources.h" 11 #include "grit/webkit_resources.h"
15 #include "grit/webkit_strings.h" 12 #include "grit/webkit_strings.h"
16 #include "skia/ext/platform_canvas.h" 13 #include "skia/ext/platform_canvas.h"
17 #include "ppapi/c/pp_resource.h" 14 #include "ppapi/c/pp_resource.h"
18 #include "third_party/skia/include/core/SkBitmap.h" 15 #include "third_party/skia/include/core/SkBitmap.h"
16 #include "third_party/icu/public/i18n/unicode/usearch.h"
19 #include "webkit/glue/webkit_glue.h" 17 #include "webkit/glue/webkit_glue.h"
20 #include "webkit/glue/plugins/pepper_image_data.h" 18 #include "webkit/plugins/ppapi/plugin_delegate.h"
21 #include "webkit/glue/plugins/pepper_plugin_delegate.h" 19 #include "webkit/plugins/ppapi/plugin_instance.h"
22 #include "webkit/glue/plugins/pepper_plugin_instance.h" 20 #include "webkit/plugins/ppapi/plugin_module.h"
23 #include "webkit/glue/plugins/pepper_plugin_module.h" 21 #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
24 #include "webkit/glue/plugins/pepper_var.h" 22 #include "webkit/plugins/ppapi/ppb_pdf.h"
25 #include "webkit/glue/plugins/ppb_private.h" 23 #include "webkit/plugins/ppapi/var.h"
26 #include "webkit/glue/plugins/pepper_var.h"
27 24
28 namespace pepper { 25 namespace webkit {
26 namespace ppapi {
29 27
30 #if defined(OS_LINUX) 28 #if defined(OS_LINUX)
31 class PrivateFontFile : public Resource { 29 class PrivateFontFile : public Resource {
32 public: 30 public:
33 PrivateFontFile(PluginModule* module, int fd) 31 PrivateFontFile(PluginModule* module, int fd)
34 : Resource(module), 32 : Resource(module),
35 fd_(fd) { 33 fd_(fd) {
36 } 34 }
37 virtual ~PrivateFontFile() { 35 virtual ~PrivateFontFile() {
38 } 36 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 111 }
114 if (res_id == 0) 112 if (res_id == 0)
115 return 0; 113 return 0;
116 114
117 SkBitmap* res_bitmap = 115 SkBitmap* res_bitmap =
118 ResourceBundle::GetSharedInstance().GetBitmapNamed(res_id); 116 ResourceBundle::GetSharedInstance().GetBitmapNamed(res_id);
119 117
120 PluginModule* module = ResourceTracker::Get()->GetModule(module_id); 118 PluginModule* module = ResourceTracker::Get()->GetModule(module_id);
121 if (!module) 119 if (!module)
122 return 0; 120 return 0;
123 scoped_refptr<pepper::ImageData> image_data(new pepper::ImageData(module)); 121 scoped_refptr<PPB_ImageData_Impl> image_data(new PPB_ImageData_Impl(module));
124 if (!image_data->Init(ImageData::GetNativeImageDataFormat(), 122 if (!image_data->Init(PPB_ImageData_Impl::GetNativeImageDataFormat(),
125 res_bitmap->width(), res_bitmap->height(), false)) { 123 res_bitmap->width(), res_bitmap->height(), false)) {
126 return 0; 124 return 0;
127 } 125 }
128 126
129 ImageDataAutoMapper mapper(image_data); 127 ImageDataAutoMapper mapper(image_data);
130 if (!mapper.is_valid()) 128 if (!mapper.is_valid())
131 return 0; 129 return 0;
132 130
133 skia::PlatformCanvas* canvas = image_data->mapped_canvas(); 131 skia::PlatformCanvas* canvas = image_data->mapped_canvas();
134 SkBitmap& ret_bitmap = 132 SkBitmap& ret_bitmap =
(...skipping 23 matching lines...) Expand all
158 description->weight >= PP_FONTWEIGHT_BOLD, 156 description->weight >= PP_FONTWEIGHT_BOLD,
159 description->italic, 157 description->italic,
160 charset); 158 charset);
161 if (fd == -1) 159 if (fd == -1)
162 return 0; 160 return 0;
163 161
164 scoped_refptr<PrivateFontFile> font(new PrivateFontFile(module, fd)); 162 scoped_refptr<PrivateFontFile> font(new PrivateFontFile(module, fd));
165 163
166 return font->GetReference(); 164 return font->GetReference();
167 #else 165 #else
168 // For trusted pepper plugins, this is only needed in Linux since font loading 166 // For trusted PPAPI plugins, this is only needed in Linux since font loading
169 // on Windows and Mac works through the renderer sandbox. 167 // on Windows and Mac works through the renderer sandbox.
170 return 0; 168 return 0;
171 #endif 169 #endif
172 } 170 }
173 171
174 bool GetFontTableForPrivateFontFile(PP_Resource font_file, 172 bool GetFontTableForPrivateFontFile(PP_Resource font_file,
175 uint32_t table, 173 uint32_t table,
176 void* output, 174 void* output,
177 uint32_t* output_length) { 175 uint32_t* output_length) {
178 #if defined(OS_LINUX) 176 #if defined(OS_LINUX)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 void HistogramPDFPageCount(int count) { 258 void HistogramPDFPageCount(int count) {
261 UMA_HISTOGRAM_COUNTS_10000("PDF.PageCount", count); 259 UMA_HISTOGRAM_COUNTS_10000("PDF.PageCount", count);
262 } 260 }
263 261
264 void UserMetricsRecordAction(PP_Var action) { 262 void UserMetricsRecordAction(PP_Var action) {
265 scoped_refptr<StringVar> action_str(StringVar::FromPPVar(action)); 263 scoped_refptr<StringVar> action_str(StringVar::FromPPVar(action));
266 if (action_str) 264 if (action_str)
267 webkit_glue::UserMetricsRecordAction(action_str->value()); 265 webkit_glue::UserMetricsRecordAction(action_str->value());
268 } 266 }
269 267
270 const PPB_Private ppb_private = { 268 const PPB_PDF ppb_pdf = {
271 &GetLocalizedString, 269 &GetLocalizedString,
272 &GetResourceImage, 270 &GetResourceImage,
273 &GetFontFileWithFallback, 271 &GetFontFileWithFallback,
274 &GetFontTableForPrivateFontFile, 272 &GetFontTableForPrivateFontFile,
275 &SearchString, 273 &SearchString,
276 &DidStartLoading, 274 &DidStartLoading,
277 &DidStopLoading, 275 &DidStopLoading,
278 &SetContentRestriction, 276 &SetContentRestriction,
279 &HistogramPDFPageCount, 277 &HistogramPDFPageCount,
280 &UserMetricsRecordAction 278 &UserMetricsRecordAction
281 }; 279 };
282 280
283 } // namespace 281 } // namespace
284 282
285 // static 283 // static
286 const PPB_Private* Private::GetInterface() { 284 const PPB_PDF* PPB_PDF_Impl::GetInterface() {
287 return &ppb_private; 285 return &ppb_pdf;
288 } 286 }
289 287
290 #if defined(OS_LINUX) 288 #if defined(OS_LINUX)
291 bool PrivateFontFile::GetFontTable(uint32_t table, 289 bool PrivateFontFile::GetFontTable(uint32_t table,
292 void* output, 290 void* output,
293 uint32_t* output_length) { 291 uint32_t* output_length) {
294 size_t temp_size = static_cast<size_t>(*output_length); 292 size_t temp_size = static_cast<size_t>(*output_length);
295 bool rv = webkit_glue::GetFontTable( 293 bool rv = webkit_glue::GetFontTable(
296 fd_, table, static_cast<uint8_t*>(output), &temp_size); 294 fd_, table, static_cast<uint8_t*>(output), &temp_size);
297 *output_length = static_cast<uint32_t>(temp_size); 295 *output_length = static_cast<uint32_t>(temp_size);
298 return rv; 296 return rv;
299 } 297 }
300 #endif 298 #endif
301 299
302 } // namespace pepper 300 } // namespace ppapi
301 } // namespace webkit
302
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_pdf_impl.h ('k') | webkit/plugins/ppapi/ppb_scrollbar_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698