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

Side by Side Diff: pdf/instance.cc

Issue 705623002: Initialize V8 in PDFium from external files (in-renderer process only). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove pieces that don't belong to this CL Created 6 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
OLDNEW
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 "pdf/instance.h" 5 #include "pdf/instance.h"
6 6
7 #include <algorithm> // for min() 7 #include <algorithm> // for min()
8 #define _USE_MATH_DEFINES // for M_PI 8 #define _USE_MATH_DEFINES // for M_PI
9 #include <cmath> // for log() and pow() 9 #include <cmath> // for log() and pow()
10 #include <math.h> 10 #include <math.h>
(...skipping 23 matching lines...) Expand all
34 #include "ppapi/cpp/dev/font_dev.h" 34 #include "ppapi/cpp/dev/font_dev.h"
35 #include "ppapi/cpp/dev/memory_dev.h" 35 #include "ppapi/cpp/dev/memory_dev.h"
36 #include "ppapi/cpp/dev/text_input_dev.h" 36 #include "ppapi/cpp/dev/text_input_dev.h"
37 #include "ppapi/cpp/module.h" 37 #include "ppapi/cpp/module.h"
38 #include "ppapi/cpp/point.h" 38 #include "ppapi/cpp/point.h"
39 #include "ppapi/cpp/private/pdf.h" 39 #include "ppapi/cpp/private/pdf.h"
40 #include "ppapi/cpp/rect.h" 40 #include "ppapi/cpp/rect.h"
41 #include "ppapi/cpp/resource.h" 41 #include "ppapi/cpp/resource.h"
42 #include "ppapi/cpp/url_request_info.h" 42 #include "ppapi/cpp/url_request_info.h"
43 #include "ui/events/keycodes/keyboard_codes.h" 43 #include "ui/events/keycodes/keyboard_codes.h"
44 #include "v8/include/v8.h"
44 45
45 #if defined(OS_MACOSX) 46 #if defined(OS_MACOSX)
46 #include "base/mac/mac_util.h" 47 #include "base/mac/mac_util.h"
47 #endif 48 #endif
48 49
49 namespace chrome_pdf { 50 namespace chrome_pdf {
50 51
51 struct ToolbarButtonInfo { 52 struct ToolbarButtonInfo {
52 uint32 id; 53 uint32 id;
53 Button::ButtonStyle style; 54 Button::ButtonStyle style;
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 timer_factory_.CancelAll(); 313 timer_factory_.CancelAll();
313 timer_pending_ = false; 314 timer_pending_ = false;
314 } 315 }
315 // The engine may try to access this instance during its destruction. 316 // The engine may try to access this instance during its destruction.
316 // Make sure this happens early while the instance is still intact. 317 // Make sure this happens early while the instance is still intact.
317 engine_.reset(); 318 engine_.reset();
318 RemovePerInstanceObject(kPPPPdfInterface, this); 319 RemovePerInstanceObject(kPPPPdfInterface, this);
319 } 320 }
320 321
321 bool Instance::Init(uint32_t argc, const char* argn[], const char* argv[]) { 322 bool Instance::Init(uint32_t argc, const char* argn[], const char* argv[]) {
323 v8::StartupData natives;
324 v8::StartupData snapshot;
325 pp::PDF::GetV8ExternalSnapshotData(&natives.data, &natives.raw_size,
326 &snapshot.data, &snapshot.raw_size);
327 if (natives.data) {
328 natives.compressed_size = natives.raw_size;
329 snapshot.compressed_size = snapshot.raw_size;
330 v8::V8::SetNativesDataBlob(&natives);
331 v8::V8::SetSnapshotDataBlob(&snapshot);
332 }
333
322 // For now, we hide HiDPI support behind a flag. 334 // For now, we hide HiDPI support behind a flag.
323 if (pp::PDF::IsFeatureEnabled(this, PP_PDFFEATURE_HIDPI)) 335 if (pp::PDF::IsFeatureEnabled(this, PP_PDFFEATURE_HIDPI))
324 hidpi_enabled_ = true; 336 hidpi_enabled_ = true;
325 337
326 printing_enabled_ = pp::PDF::IsFeatureEnabled(this, PP_PDFFEATURE_PRINTING); 338 printing_enabled_ = pp::PDF::IsFeatureEnabled(this, PP_PDFFEATURE_PRINTING);
327 if (printing_enabled_) { 339 if (printing_enabled_) {
328 CreateToolbar(kPDFToolbarButtons, arraysize(kPDFToolbarButtons)); 340 CreateToolbar(kPDFToolbarButtons, arraysize(kPDFToolbarButtons));
329 } else { 341 } else {
330 CreateToolbar(kPDFNoPrintToolbarButtons, 342 CreateToolbar(kPDFNoPrintToolbarButtons,
331 arraysize(kPDFNoPrintToolbarButtons)); 343 arraysize(kPDFNoPrintToolbarButtons));
(...skipping 2439 matching lines...) Expand 10 before | Expand all | Expand 10 after
2771 return instance_->HasScriptableMethod(name, exception); 2783 return instance_->HasScriptableMethod(name, exception);
2772 } 2784 }
2773 2785
2774 pp::Var PDFScriptableObject::Call(const pp::Var& method, 2786 pp::Var PDFScriptableObject::Call(const pp::Var& method,
2775 const std::vector<pp::Var>& args, 2787 const std::vector<pp::Var>& args,
2776 pp::Var* exception) { 2788 pp::Var* exception) {
2777 return instance_->CallScriptableMethod(method, args, exception); 2789 return instance_->CallScriptableMethod(method, args, exception);
2778 } 2790 }
2779 2791
2780 } // namespace chrome_pdf 2792 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « pdf/DEPS ('k') | ppapi/c/private/ppb_pdf.h » ('j') | ppapi/c/private/ppb_pdf.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698