| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // Document load progress arguments (Plugin -> Page) | 78 // Document load progress arguments (Plugin -> Page) |
| 79 const char kJSLoadProgressType[] = "loadProgress"; | 79 const char kJSLoadProgressType[] = "loadProgress"; |
| 80 const char kJSProgressPercentage[] = "progress"; | 80 const char kJSProgressPercentage[] = "progress"; |
| 81 // Get password arguments (Plugin -> Page) | 81 // Get password arguments (Plugin -> Page) |
| 82 const char kJSGetPasswordType[] = "getPassword"; | 82 const char kJSGetPasswordType[] = "getPassword"; |
| 83 // Get password complete arguments (Page -> Plugin) | 83 // Get password complete arguments (Page -> Plugin) |
| 84 const char kJSGetPasswordCompleteType[] = "getPasswordComplete"; | 84 const char kJSGetPasswordCompleteType[] = "getPasswordComplete"; |
| 85 const char kJSPassword[] = "password"; | 85 const char kJSPassword[] = "password"; |
| 86 // Print (Page -> Plugin) | 86 // Print (Page -> Plugin) |
| 87 const char kJSPrintType[] = "print"; | 87 const char kJSPrintType[] = "print"; |
| 88 // Save (Page -> Plugin) |
| 89 const char kJSSaveType[] = "save"; |
| 90 const char kJSSaveURL[] = "saveurl"; |
| 88 // Go to page (Plugin -> Page) | 91 // Go to page (Plugin -> Page) |
| 89 const char kJSGoToPageType[] = "goToPage"; | 92 const char kJSGoToPageType[] = "goToPage"; |
| 90 const char kJSPageNumber[] = "page"; | 93 const char kJSPageNumber[] = "page"; |
| 91 // Reset print preview mode (Page -> Plugin) | 94 // Reset print preview mode (Page -> Plugin) |
| 92 const char kJSResetPrintPreviewModeType[] = "resetPrintPreviewMode"; | 95 const char kJSResetPrintPreviewModeType[] = "resetPrintPreviewMode"; |
| 93 const char kJSPrintPreviewUrl[] = "url"; | 96 const char kJSPrintPreviewUrl[] = "url"; |
| 94 const char kJSPrintPreviewGrayscale[] = "grayscale"; | 97 const char kJSPrintPreviewGrayscale[] = "grayscale"; |
| 95 const char kJSPrintPreviewPageCount[] = "pageCount"; | 98 const char kJSPrintPreviewPageCount[] = "pageCount"; |
| 96 // Load preview page (Page -> Plugin) | 99 // Load preview page (Page -> Plugin) |
| 97 const char kJSLoadPreviewPageType[] = "loadPreviewPage"; | 100 const char kJSLoadPreviewPageType[] = "loadPreviewPage"; |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 if (password_callback_) { | 371 if (password_callback_) { |
| 369 pp::CompletionCallbackWithOutput<pp::Var> callback = *password_callback_; | 372 pp::CompletionCallbackWithOutput<pp::Var> callback = *password_callback_; |
| 370 password_callback_.reset(); | 373 password_callback_.reset(); |
| 371 *callback.output() = dict.Get(pp::Var(kJSPassword)).pp_var(); | 374 *callback.output() = dict.Get(pp::Var(kJSPassword)).pp_var(); |
| 372 callback.Run(PP_OK); | 375 callback.Run(PP_OK); |
| 373 } else { | 376 } else { |
| 374 NOTREACHED(); | 377 NOTREACHED(); |
| 375 } | 378 } |
| 376 } else if (type == kJSPrintType) { | 379 } else if (type == kJSPrintType) { |
| 377 Print(); | 380 Print(); |
| 381 } else if (type == kJSSaveType) { |
| 382 printf("type == kJSSaveType\n"); |
| 383 if (!dict.Get(pp::Var(kJSSaveURL)).is_string()) { |
| 384 printf("saveurl was not string\n"); |
| 385 } else { |
| 386 printf("saveurl WAS string\n"); |
| 387 printf("Got url here: %s\n", dict.Get(pp::Var(kJSSaveURL)).AsString().c_st
r()); |
| 388 } |
| 389 printf("url_: %s\n", url_.c_str()); |
| 390 pp::PDF::SaveAs(this, url_); |
| 378 } else if (type == kJSResetPrintPreviewModeType && | 391 } else if (type == kJSResetPrintPreviewModeType && |
| 379 dict.Get(pp::Var(kJSPrintPreviewUrl)).is_string() && | 392 dict.Get(pp::Var(kJSPrintPreviewUrl)).is_string() && |
| 380 dict.Get(pp::Var(kJSPrintPreviewGrayscale)).is_bool() && | 393 dict.Get(pp::Var(kJSPrintPreviewGrayscale)).is_bool() && |
| 381 dict.Get(pp::Var(kJSPrintPreviewPageCount)).is_int()) { | 394 dict.Get(pp::Var(kJSPrintPreviewPageCount)).is_int()) { |
| 382 url_ = dict.Get(pp::Var(kJSPrintPreviewUrl)).AsString(); | 395 url_ = dict.Get(pp::Var(kJSPrintPreviewUrl)).AsString(); |
| 383 preview_pages_info_ = std::queue<PreviewPageInfo>(); | 396 preview_pages_info_ = std::queue<PreviewPageInfo>(); |
| 384 preview_document_load_state_ = LOAD_STATE_COMPLETE; | 397 preview_document_load_state_ = LOAD_STATE_COMPLETE; |
| 385 document_load_state_ = LOAD_STATE_LOADING; | 398 document_load_state_ = LOAD_STATE_LOADING; |
| 386 LoadUrl(url_); | 399 LoadUrl(url_); |
| 387 preview_engine_.reset(); | 400 preview_engine_.reset(); |
| (...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1360 pp::Point OutOfProcessInstance::BoundScrollOffsetToDocument( | 1373 pp::Point OutOfProcessInstance::BoundScrollOffsetToDocument( |
| 1361 const pp::Point& scroll_offset) { | 1374 const pp::Point& scroll_offset) { |
| 1362 int max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1375 int max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
| 1363 int x = std::max(std::min(scroll_offset.x(), max_x), 0); | 1376 int x = std::max(std::min(scroll_offset.x(), max_x), 0); |
| 1364 int max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1377 int max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
| 1365 int y = std::max(std::min(scroll_offset.y(), max_y), 0); | 1378 int y = std::max(std::min(scroll_offset.y(), max_y), 0); |
| 1366 return pp::Point(x, y); | 1379 return pp::Point(x, y); |
| 1367 } | 1380 } |
| 1368 | 1381 |
| 1369 } // namespace chrome_pdf | 1382 } // namespace chrome_pdf |
| OLD | NEW |