| 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"; |
| 88 // Go to page (Plugin -> Page) | 90 // Go to page (Plugin -> Page) |
| 89 const char kJSGoToPageType[] = "goToPage"; | 91 const char kJSGoToPageType[] = "goToPage"; |
| 90 const char kJSPageNumber[] = "page"; | 92 const char kJSPageNumber[] = "page"; |
| 91 // Reset print preview mode (Page -> Plugin) | 93 // Reset print preview mode (Page -> Plugin) |
| 92 const char kJSResetPrintPreviewModeType[] = "resetPrintPreviewMode"; | 94 const char kJSResetPrintPreviewModeType[] = "resetPrintPreviewMode"; |
| 93 const char kJSPrintPreviewUrl[] = "url"; | 95 const char kJSPrintPreviewUrl[] = "url"; |
| 94 const char kJSPrintPreviewGrayscale[] = "grayscale"; | 96 const char kJSPrintPreviewGrayscale[] = "grayscale"; |
| 95 const char kJSPrintPreviewPageCount[] = "pageCount"; | 97 const char kJSPrintPreviewPageCount[] = "pageCount"; |
| 96 // Load preview page (Page -> Plugin) | 98 // Load preview page (Page -> Plugin) |
| 97 const char kJSLoadPreviewPageType[] = "loadPreviewPage"; | 99 const char kJSLoadPreviewPageType[] = "loadPreviewPage"; |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 if (password_callback_) { | 370 if (password_callback_) { |
| 369 pp::CompletionCallbackWithOutput<pp::Var> callback = *password_callback_; | 371 pp::CompletionCallbackWithOutput<pp::Var> callback = *password_callback_; |
| 370 password_callback_.reset(); | 372 password_callback_.reset(); |
| 371 *callback.output() = dict.Get(pp::Var(kJSPassword)).pp_var(); | 373 *callback.output() = dict.Get(pp::Var(kJSPassword)).pp_var(); |
| 372 callback.Run(PP_OK); | 374 callback.Run(PP_OK); |
| 373 } else { | 375 } else { |
| 374 NOTREACHED(); | 376 NOTREACHED(); |
| 375 } | 377 } |
| 376 } else if (type == kJSPrintType) { | 378 } else if (type == kJSPrintType) { |
| 377 Print(); | 379 Print(); |
| 380 } else if (type == kJSSaveType) { |
| 381 printf("url_: %s\n", url_.c_str()); |
| 382 pp::PDF::SaveAs(this, url_); |
| 378 } else if (type == kJSResetPrintPreviewModeType && | 383 } else if (type == kJSResetPrintPreviewModeType && |
| 379 dict.Get(pp::Var(kJSPrintPreviewUrl)).is_string() && | 384 dict.Get(pp::Var(kJSPrintPreviewUrl)).is_string() && |
| 380 dict.Get(pp::Var(kJSPrintPreviewGrayscale)).is_bool() && | 385 dict.Get(pp::Var(kJSPrintPreviewGrayscale)).is_bool() && |
| 381 dict.Get(pp::Var(kJSPrintPreviewPageCount)).is_int()) { | 386 dict.Get(pp::Var(kJSPrintPreviewPageCount)).is_int()) { |
| 382 url_ = dict.Get(pp::Var(kJSPrintPreviewUrl)).AsString(); | 387 url_ = dict.Get(pp::Var(kJSPrintPreviewUrl)).AsString(); |
| 383 preview_pages_info_ = std::queue<PreviewPageInfo>(); | 388 preview_pages_info_ = std::queue<PreviewPageInfo>(); |
| 384 preview_document_load_state_ = LOAD_STATE_COMPLETE; | 389 preview_document_load_state_ = LOAD_STATE_COMPLETE; |
| 385 document_load_state_ = LOAD_STATE_LOADING; | 390 document_load_state_ = LOAD_STATE_LOADING; |
| 386 LoadUrl(url_); | 391 LoadUrl(url_); |
| 387 preview_engine_.reset(); | 392 preview_engine_.reset(); |
| (...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1360 pp::Point OutOfProcessInstance::BoundScrollOffsetToDocument( | 1365 pp::Point OutOfProcessInstance::BoundScrollOffsetToDocument( |
| 1361 const pp::Point& scroll_offset) { | 1366 const pp::Point& scroll_offset) { |
| 1362 int max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1367 int max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
| 1363 int x = std::max(std::min(scroll_offset.x(), max_x), 0); | 1368 int x = std::max(std::min(scroll_offset.x(), max_x), 0); |
| 1364 int max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1369 int max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
| 1365 int y = std::max(std::min(scroll_offset.y(), max_y), 0); | 1370 int y = std::max(std::min(scroll_offset.y(), max_y), 0); |
| 1366 return pp::Point(x, y); | 1371 return pp::Point(x, y); |
| 1367 } | 1372 } |
| 1368 | 1373 |
| 1369 } // namespace chrome_pdf | 1374 } // namespace chrome_pdf |
| OLD | NEW |