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/out_of_process_instance.h" | 5 #include "pdf/out_of_process_instance.h" |
6 | 6 |
7 #include <algorithm> // for min/max() | 7 #include <algorithm> // for min/max() |
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 22 matching lines...) Expand all Loading... |
33 #include "ppapi/cpp/module.h" | 33 #include "ppapi/cpp/module.h" |
34 #include "ppapi/cpp/point.h" | 34 #include "ppapi/cpp/point.h" |
35 #include "ppapi/cpp/private/pdf.h" | 35 #include "ppapi/cpp/private/pdf.h" |
36 #include "ppapi/cpp/private/var_private.h" | 36 #include "ppapi/cpp/private/var_private.h" |
37 #include "ppapi/cpp/rect.h" | 37 #include "ppapi/cpp/rect.h" |
38 #include "ppapi/cpp/resource.h" | 38 #include "ppapi/cpp/resource.h" |
39 #include "ppapi/cpp/url_request_info.h" | 39 #include "ppapi/cpp/url_request_info.h" |
40 #include "ppapi/cpp/var_array.h" | 40 #include "ppapi/cpp/var_array.h" |
41 #include "ppapi/cpp/var_dictionary.h" | 41 #include "ppapi/cpp/var_dictionary.h" |
42 #include "ui/events/keycodes/keyboard_codes.h" | 42 #include "ui/events/keycodes/keyboard_codes.h" |
43 #include "v8/include/v8.h" | |
44 | 43 |
45 #if defined(OS_MACOSX) | 44 #if defined(OS_MACOSX) |
46 #include "base/mac/mac_util.h" | 45 #include "base/mac/mac_util.h" |
47 #endif | 46 #endif |
48 | 47 |
49 namespace chrome_pdf { | 48 namespace chrome_pdf { |
50 | 49 |
51 const char kChromePrint[] = "chrome://print/"; | 50 const char kChromePrint[] = "chrome://print/"; |
52 const char kChromeExtension[] = | 51 const char kChromeExtension[] = |
53 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai"; | 52 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai"; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_TOUCH); | 274 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_TOUCH); |
276 } | 275 } |
277 | 276 |
278 OutOfProcessInstance::~OutOfProcessInstance() { | 277 OutOfProcessInstance::~OutOfProcessInstance() { |
279 RemovePerInstanceObject(kPPPPdfInterface, this); | 278 RemovePerInstanceObject(kPPPPdfInterface, this); |
280 } | 279 } |
281 | 280 |
282 bool OutOfProcessInstance::Init(uint32_t argc, | 281 bool OutOfProcessInstance::Init(uint32_t argc, |
283 const char* argn[], | 282 const char* argn[], |
284 const char* argv[]) { | 283 const char* argv[]) { |
285 v8::StartupData natives; | |
286 v8::StartupData snapshot; | |
287 pp::PDF::GetV8ExternalSnapshotData(this, &natives.data, &natives.raw_size, | |
288 &snapshot.data, &snapshot.raw_size); | |
289 if (natives.data) { | |
290 v8::V8::SetNativesDataBlob(&natives); | |
291 v8::V8::SetSnapshotDataBlob(&snapshot); | |
292 } | |
293 | |
294 // Check if the PDF is being loaded in the PDF chrome extension. We only allow | 284 // Check if the PDF is being loaded in the PDF chrome extension. We only allow |
295 // the plugin to be put into "full frame" mode when it is being loaded in the | 285 // the plugin to be put into "full frame" mode when it is being loaded in the |
296 // extension because this enables some features that we don't want pages | 286 // extension because this enables some features that we don't want pages |
297 // abusing outside of the extension. | 287 // abusing outside of the extension. |
298 pp::Var document_url_var = pp::URLUtil_Dev::Get()->GetDocumentURL(this); | 288 pp::Var document_url_var = pp::URLUtil_Dev::Get()->GetDocumentURL(this); |
299 std::string document_url = document_url_var.is_string() ? | 289 std::string document_url = document_url_var.is_string() ? |
300 document_url_var.AsString() : std::string(); | 290 document_url_var.AsString() : std::string(); |
301 std::string extension_url = std::string(kChromeExtension); | 291 std::string extension_url = std::string(kChromeExtension); |
302 bool in_extension = | 292 bool in_extension = |
303 !document_url.compare(0, extension_url.size(), extension_url); | 293 !document_url.compare(0, extension_url.size(), extension_url); |
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1396 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( | 1386 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( |
1397 const pp::FloatPoint& scroll_offset) { | 1387 const pp::FloatPoint& scroll_offset) { |
1398 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1388 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
1399 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1389 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
1400 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1390 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
1401 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); | 1391 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); |
1402 return pp::FloatPoint(x, y); | 1392 return pp::FloatPoint(x, y); |
1403 } | 1393 } |
1404 | 1394 |
1405 } // namespace chrome_pdf | 1395 } // namespace chrome_pdf |
OLD | NEW |