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

Side by Side Diff: pdf/out_of_process_instance.cc

Issue 718453003: Initialize V8 in PDFium from external files (plugin process only) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/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 44
44 #if defined(OS_MACOSX) 45 #if defined(OS_MACOSX)
45 #include "base/mac/mac_util.h" 46 #include "base/mac/mac_util.h"
46 #endif 47 #endif
47 48
48 namespace chrome_pdf { 49 namespace chrome_pdf {
49 50
50 const char kChromePrint[] = "chrome://print/"; 51 const char kChromePrint[] = "chrome://print/";
51 const char kChromeExtension[] = 52 const char kChromeExtension[] =
52 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai"; 53 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai";
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_TOUCH); 260 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_TOUCH);
260 } 261 }
261 262
262 OutOfProcessInstance::~OutOfProcessInstance() { 263 OutOfProcessInstance::~OutOfProcessInstance() {
263 RemovePerInstanceObject(kPPPPdfInterface, this); 264 RemovePerInstanceObject(kPPPPdfInterface, this);
264 } 265 }
265 266
266 bool OutOfProcessInstance::Init(uint32_t argc, 267 bool OutOfProcessInstance::Init(uint32_t argc,
267 const char* argn[], 268 const char* argn[],
268 const char* argv[]) { 269 const char* argv[]) {
270 v8::StartupData natives;
271 v8::StartupData snapshot;
272 pp::PDF::GetV8ExternalSnapshotData(this, &natives.data, &natives.raw_size,
273 &snapshot.data, &snapshot.raw_size);
274 if (natives.data) {
275 natives.compressed_size = natives.raw_size;
276 snapshot.compressed_size = snapshot.raw_size;
277 v8::V8::SetNativesDataBlob(&natives);
278 v8::V8::SetSnapshotDataBlob(&snapshot);
279 }
280
269 // Check if the PDF is being loaded in the PDF chrome extension. We only allow 281 // Check if the PDF is being loaded in the PDF chrome extension. We only allow
270 // the plugin to be put into "full frame" mode when it is being loaded in the 282 // the plugin to be put into "full frame" mode when it is being loaded in the
271 // extension because this enables some features that we don't want pages 283 // extension because this enables some features that we don't want pages
272 // abusing outside of the extension. 284 // abusing outside of the extension.
273 pp::Var document_url_var = pp::URLUtil_Dev::Get()->GetDocumentURL(this); 285 pp::Var document_url_var = pp::URLUtil_Dev::Get()->GetDocumentURL(this);
274 std::string document_url = document_url_var.is_string() ? 286 std::string document_url = document_url_var.is_string() ?
275 document_url_var.AsString() : std::string(); 287 document_url_var.AsString() : std::string();
276 std::string extension_url = std::string(kChromeExtension); 288 std::string extension_url = std::string(kChromeExtension);
277 bool in_extension = 289 bool in_extension =
278 !document_url.compare(0, extension_url.size(), extension_url); 290 !document_url.compare(0, extension_url.size(), extension_url);
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( 1375 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument(
1364 const pp::FloatPoint& scroll_offset) { 1376 const pp::FloatPoint& scroll_offset) {
1365 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); 1377 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width();
1366 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); 1378 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f);
1367 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); 1379 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height();
1368 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); 1380 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f);
1369 return pp::FloatPoint(x, y); 1381 return pp::FloatPoint(x, y);
1370 } 1382 }
1371 1383
1372 } // namespace chrome_pdf 1384 } // namespace chrome_pdf
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698