Chromium Code Reviews| 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 "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 Loading... | |
| 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 #include "v8/include/v8.h" |
|
raymes
2014/12/21 22:52:02
nit: I think we can remove this include now
Tom Sepez
2014/12/29 18:18:37
Done.
| |
| 45 | 45 |
| 46 #if defined(OS_MACOSX) | 46 #if defined(OS_MACOSX) |
| 47 #include "base/mac/mac_util.h" | 47 #include "base/mac/mac_util.h" |
| 48 #endif | 48 #endif |
| 49 | 49 |
| 50 namespace chrome_pdf { | 50 namespace chrome_pdf { |
| 51 | 51 |
| 52 struct ToolbarButtonInfo { | 52 struct ToolbarButtonInfo { |
| 53 uint32 id; | 53 uint32 id; |
| 54 Button::ButtonStyle style; | 54 Button::ButtonStyle style; |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 timer_factory_.CancelAll(); | 325 timer_factory_.CancelAll(); |
| 326 timer_pending_ = false; | 326 timer_pending_ = false; |
| 327 } | 327 } |
| 328 // The engine may try to access this instance during its destruction. | 328 // The engine may try to access this instance during its destruction. |
| 329 // Make sure this happens early while the instance is still intact. | 329 // Make sure this happens early while the instance is still intact. |
| 330 engine_.reset(); | 330 engine_.reset(); |
| 331 RemovePerInstanceObject(kPPPPdfInterface, this); | 331 RemovePerInstanceObject(kPPPPdfInterface, this); |
| 332 } | 332 } |
| 333 | 333 |
| 334 bool Instance::Init(uint32_t argc, const char* argn[], const char* argv[]) { | 334 bool Instance::Init(uint32_t argc, const char* argn[], const char* argv[]) { |
| 335 v8::StartupData natives; | |
| 336 v8::StartupData snapshot; | |
| 337 pp::PDF::GetV8ExternalSnapshotData(this, &natives.data, &natives.raw_size, | |
| 338 &snapshot.data, &snapshot.raw_size); | |
| 339 if (natives.data) { | |
| 340 v8::V8::SetNativesDataBlob(&natives); | |
| 341 v8::V8::SetSnapshotDataBlob(&snapshot); | |
| 342 } | |
| 343 | |
| 344 // For now, we hide HiDPI support behind a flag. | 335 // For now, we hide HiDPI support behind a flag. |
| 345 if (pp::PDF::IsFeatureEnabled(this, PP_PDFFEATURE_HIDPI)) | 336 if (pp::PDF::IsFeatureEnabled(this, PP_PDFFEATURE_HIDPI)) |
| 346 hidpi_enabled_ = true; | 337 hidpi_enabled_ = true; |
| 347 | 338 |
| 348 printing_enabled_ = pp::PDF::IsFeatureEnabled(this, PP_PDFFEATURE_PRINTING); | 339 printing_enabled_ = pp::PDF::IsFeatureEnabled(this, PP_PDFFEATURE_PRINTING); |
| 349 if (printing_enabled_) { | 340 if (printing_enabled_) { |
| 350 CreateToolbar(kPDFToolbarButtons, arraysize(kPDFToolbarButtons)); | 341 CreateToolbar(kPDFToolbarButtons, arraysize(kPDFToolbarButtons)); |
| 351 } else { | 342 } else { |
| 352 CreateToolbar(kPDFNoPrintToolbarButtons, | 343 CreateToolbar(kPDFNoPrintToolbarButtons, |
| 353 arraysize(kPDFNoPrintToolbarButtons)); | 344 arraysize(kPDFNoPrintToolbarButtons)); |
| (...skipping 2445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2799 return instance_->HasScriptableMethod(name, exception); | 2790 return instance_->HasScriptableMethod(name, exception); |
| 2800 } | 2791 } |
| 2801 | 2792 |
| 2802 pp::Var PDFScriptableObject::Call(const pp::Var& method, | 2793 pp::Var PDFScriptableObject::Call(const pp::Var& method, |
| 2803 const std::vector<pp::Var>& args, | 2794 const std::vector<pp::Var>& args, |
| 2804 pp::Var* exception) { | 2795 pp::Var* exception) { |
| 2805 return instance_->CallScriptableMethod(method, args, exception); | 2796 return instance_->CallScriptableMethod(method, args, exception); |
| 2806 } | 2797 } |
| 2807 | 2798 |
| 2808 } // namespace chrome_pdf | 2799 } // namespace chrome_pdf |
| OLD | NEW |