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

Side by Side Diff: pdf/out_of_process_instance.cc

Issue 819473002: Load V8 external data prior to initializng PDFium SDK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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/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
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" 43 #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.
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 namespace chrome_pdf { 49 namespace chrome_pdf {
50 50
51 const char kChromePrint[] = "chrome://print/"; 51 const char kChromePrint[] = "chrome://print/";
52 const char kChromeExtension[] = 52 const char kChromeExtension[] =
53 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai"; 53 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai";
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_TOUCH); 275 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_TOUCH);
276 } 276 }
277 277
278 OutOfProcessInstance::~OutOfProcessInstance() { 278 OutOfProcessInstance::~OutOfProcessInstance() {
279 RemovePerInstanceObject(kPPPPdfInterface, this); 279 RemovePerInstanceObject(kPPPPdfInterface, this);
280 } 280 }
281 281
282 bool OutOfProcessInstance::Init(uint32_t argc, 282 bool OutOfProcessInstance::Init(uint32_t argc,
283 const char* argn[], 283 const char* argn[],
284 const char* argv[]) { 284 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 285 // 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 286 // 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 287 // extension because this enables some features that we don't want pages
297 // abusing outside of the extension. 288 // abusing outside of the extension.
298 pp::Var document_url_var = pp::URLUtil_Dev::Get()->GetDocumentURL(this); 289 pp::Var document_url_var = pp::URLUtil_Dev::Get()->GetDocumentURL(this);
299 std::string document_url = document_url_var.is_string() ? 290 std::string document_url = document_url_var.is_string() ?
300 document_url_var.AsString() : std::string(); 291 document_url_var.AsString() : std::string();
301 std::string extension_url = std::string(kChromeExtension); 292 std::string extension_url = std::string(kChromeExtension);
302 bool in_extension = 293 bool in_extension =
303 !document_url.compare(0, extension_url.size(), extension_url); 294 !document_url.compare(0, extension_url.size(), extension_url);
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( 1387 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument(
1397 const pp::FloatPoint& scroll_offset) { 1388 const pp::FloatPoint& scroll_offset) {
1398 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); 1389 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); 1390 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(); 1391 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); 1392 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f);
1402 return pp::FloatPoint(x, y); 1393 return pp::FloatPoint(x, y);
1403 } 1394 }
1404 1395
1405 } // namespace chrome_pdf 1396 } // namespace chrome_pdf
OLDNEW
« pdf/instance.cc ('K') | « pdf/instance.cc ('k') | pdf/pdf.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698