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 28 matching lines...) Expand all Loading... | |
| 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 | 44 |
| 45 #if defined(OS_MACOSX) | 45 #if defined(OS_MACOSX) |
| 46 #include "base/mac/mac_util.h" | 46 #include "base/mac/mac_util.h" |
| 47 #endif | 47 #endif |
| 48 | 48 |
| 49 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | |
| 50 #include "v8/include/v8.h" | |
| 51 #endif | |
| 52 | |
| 49 namespace chrome_pdf { | 53 namespace chrome_pdf { |
| 50 | 54 |
| 51 struct ToolbarButtonInfo { | 55 struct ToolbarButtonInfo { |
| 52 uint32 id; | 56 uint32 id; |
| 53 Button::ButtonStyle style; | 57 Button::ButtonStyle style; |
| 54 PP_ResourceImage normal; | 58 PP_ResourceImage normal; |
| 55 PP_ResourceImage highlighted; | 59 PP_ResourceImage highlighted; |
| 56 PP_ResourceImage pressed; | 60 PP_ResourceImage pressed; |
| 57 }; | 61 }; |
| 58 | 62 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 312 timer_factory_.CancelAll(); | 316 timer_factory_.CancelAll(); |
| 313 timer_pending_ = false; | 317 timer_pending_ = false; |
| 314 } | 318 } |
| 315 // The engine may try to access this instance during its destruction. | 319 // The engine may try to access this instance during its destruction. |
| 316 // Make sure this happens early while the instance is still intact. | 320 // Make sure this happens early while the instance is still intact. |
| 317 engine_.reset(); | 321 engine_.reset(); |
| 318 RemovePerInstanceObject(kPPPPdfInterface, this); | 322 RemovePerInstanceObject(kPPPPdfInterface, this); |
| 319 } | 323 } |
| 320 | 324 |
| 321 bool Instance::Init(uint32_t argc, const char* argn[], const char* argv[]) { | 325 bool Instance::Init(uint32_t argc, const char* argn[], const char* argv[]) { |
| 326 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | |
|
raymes
2014/11/10 03:29:06
It would be better not to use the #ifdef here. Ins
baixo1
2014/11/10 15:59:48
Done.
| |
| 327 v8::StartupData natives; | |
| 328 v8::StartupData snapshot; | |
| 329 pp::PDF::GetV8ExternalSnapshotData(this, &natives.data, &natives.raw_size, | |
| 330 &snapshot.data, &snapshot.raw_size); | |
| 331 natives.compressed_size = natives.raw_size; | |
| 332 snapshot.compressed_size = snapshot.raw_size; | |
| 333 v8::V8::SetNativesDataBlob(&natives); | |
| 334 v8::V8::SetSnapshotDataBlob(&snapshot); | |
| 335 #endif | |
| 336 | |
| 322 // For now, we hide HiDPI support behind a flag. | 337 // For now, we hide HiDPI support behind a flag. |
| 323 if (pp::PDF::IsFeatureEnabled(this, PP_PDFFEATURE_HIDPI)) | 338 if (pp::PDF::IsFeatureEnabled(this, PP_PDFFEATURE_HIDPI)) |
| 324 hidpi_enabled_ = true; | 339 hidpi_enabled_ = true; |
| 325 | 340 |
| 326 printing_enabled_ = pp::PDF::IsFeatureEnabled(this, PP_PDFFEATURE_PRINTING); | 341 printing_enabled_ = pp::PDF::IsFeatureEnabled(this, PP_PDFFEATURE_PRINTING); |
| 327 if (printing_enabled_) { | 342 if (printing_enabled_) { |
| 328 CreateToolbar(kPDFToolbarButtons, arraysize(kPDFToolbarButtons)); | 343 CreateToolbar(kPDFToolbarButtons, arraysize(kPDFToolbarButtons)); |
| 329 } else { | 344 } else { |
| 330 CreateToolbar(kPDFNoPrintToolbarButtons, | 345 CreateToolbar(kPDFNoPrintToolbarButtons, |
| 331 arraysize(kPDFNoPrintToolbarButtons)); | 346 arraysize(kPDFNoPrintToolbarButtons)); |
| (...skipping 2439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2771 return instance_->HasScriptableMethod(name, exception); | 2786 return instance_->HasScriptableMethod(name, exception); |
| 2772 } | 2787 } |
| 2773 | 2788 |
| 2774 pp::Var PDFScriptableObject::Call(const pp::Var& method, | 2789 pp::Var PDFScriptableObject::Call(const pp::Var& method, |
| 2775 const std::vector<pp::Var>& args, | 2790 const std::vector<pp::Var>& args, |
| 2776 pp::Var* exception) { | 2791 pp::Var* exception) { |
| 2777 return instance_->CallScriptableMethod(method, args, exception); | 2792 return instance_->CallScriptableMethod(method, args, exception); |
| 2778 } | 2793 } |
| 2779 | 2794 |
| 2780 } // namespace chrome_pdf | 2795 } // namespace chrome_pdf |
| OLD | NEW |