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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 if (password_callback_) { | 386 if (password_callback_) { |
385 pp::CompletionCallbackWithOutput<pp::Var> callback = *password_callback_; | 387 pp::CompletionCallbackWithOutput<pp::Var> callback = *password_callback_; |
386 password_callback_.reset(); | 388 password_callback_.reset(); |
387 *callback.output() = dict.Get(pp::Var(kJSPassword)).pp_var(); | 389 *callback.output() = dict.Get(pp::Var(kJSPassword)).pp_var(); |
388 callback.Run(PP_OK); | 390 callback.Run(PP_OK); |
389 } else { | 391 } else { |
390 NOTREACHED(); | 392 NOTREACHED(); |
391 } | 393 } |
392 } else if (type == kJSPrintType) { | 394 } else if (type == kJSPrintType) { |
393 Print(); | 395 Print(); |
| 396 } else if (type == kJSSaveType) { |
| 397 pp::PDF::SaveAs(this); |
394 } else if (type == kJSRotateClockwiseType) { | 398 } else if (type == kJSRotateClockwiseType) { |
395 RotateClockwise(); | 399 RotateClockwise(); |
396 } else if (type == kJSRotateCounterclockwiseType) { | 400 } else if (type == kJSRotateCounterclockwiseType) { |
397 RotateCounterclockwise(); | 401 RotateCounterclockwise(); |
398 } else if (type == kJSSelectAllType) { | 402 } else if (type == kJSSelectAllType) { |
399 engine_->SelectAll(); | 403 engine_->SelectAll(); |
400 } else if (type == kJSResetPrintPreviewModeType && | 404 } else if (type == kJSResetPrintPreviewModeType && |
401 dict.Get(pp::Var(kJSPrintPreviewUrl)).is_string() && | 405 dict.Get(pp::Var(kJSPrintPreviewUrl)).is_string() && |
402 dict.Get(pp::Var(kJSPrintPreviewGrayscale)).is_bool() && | 406 dict.Get(pp::Var(kJSPrintPreviewGrayscale)).is_bool() && |
403 dict.Get(pp::Var(kJSPrintPreviewPageCount)).is_int()) { | 407 dict.Get(pp::Var(kJSPrintPreviewPageCount)).is_int()) { |
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1375 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( | 1379 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( |
1376 const pp::FloatPoint& scroll_offset) { | 1380 const pp::FloatPoint& scroll_offset) { |
1377 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1381 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
1378 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1382 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
1379 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1383 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
1380 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); | 1384 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); |
1381 return pp::FloatPoint(x, y); | 1385 return pp::FloatPoint(x, y); |
1382 } | 1386 } |
1383 | 1387 |
1384 } // namespace chrome_pdf | 1388 } // namespace chrome_pdf |
OLD | NEW |