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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 const char kJSNavigateType[] = "navigate"; | 117 const char kJSNavigateType[] = "navigate"; |
118 const char kJSNavigateUrl[] = "url"; | 118 const char kJSNavigateUrl[] = "url"; |
119 const char kJSNavigateNewTab[] = "newTab"; | 119 const char kJSNavigateNewTab[] = "newTab"; |
120 // Open the email editor with the given parameters (Plugin -> Page) | 120 // Open the email editor with the given parameters (Plugin -> Page) |
121 const char kJSEmailType[] = "email"; | 121 const char kJSEmailType[] = "email"; |
122 const char kJSEmailTo[] = "to"; | 122 const char kJSEmailTo[] = "to"; |
123 const char kJSEmailCc[] = "cc"; | 123 const char kJSEmailCc[] = "cc"; |
124 const char kJSEmailBcc[] = "bcc"; | 124 const char kJSEmailBcc[] = "bcc"; |
125 const char kJSEmailSubject[] = "subject"; | 125 const char kJSEmailSubject[] = "subject"; |
126 const char kJSEmailBody[] = "body"; | 126 const char kJSEmailBody[] = "body"; |
| 127 // Rotation (Page -> Plugin) |
| 128 const char kJSRotateClockwiseType[] = "rotateClockwise"; |
| 129 const char kJSRotateCounterclockwiseType[] = "rotateCounterclockwise"; |
127 | 130 |
128 const int kFindResultCooldownMs = 100; | 131 const int kFindResultCooldownMs = 100; |
129 | 132 |
130 const double kMinZoom = 0.01; | 133 const double kMinZoom = 0.01; |
131 | 134 |
132 namespace { | 135 namespace { |
133 | 136 |
134 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1; | 137 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1; |
135 | 138 |
136 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { | 139 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 if (password_callback_) { | 370 if (password_callback_) { |
368 pp::CompletionCallbackWithOutput<pp::Var> callback = *password_callback_; | 371 pp::CompletionCallbackWithOutput<pp::Var> callback = *password_callback_; |
369 password_callback_.reset(); | 372 password_callback_.reset(); |
370 *callback.output() = dict.Get(pp::Var(kJSPassword)).pp_var(); | 373 *callback.output() = dict.Get(pp::Var(kJSPassword)).pp_var(); |
371 callback.Run(PP_OK); | 374 callback.Run(PP_OK); |
372 } else { | 375 } else { |
373 NOTREACHED(); | 376 NOTREACHED(); |
374 } | 377 } |
375 } else if (type == kJSPrintType) { | 378 } else if (type == kJSPrintType) { |
376 Print(); | 379 Print(); |
| 380 } else if (type == kJSRotateClockwiseType) { |
| 381 RotateClockwise(); |
| 382 } else if (type == kJSRotateCounterclockwiseType) { |
| 383 RotateCounterclockwise(); |
377 } else if (type == kJSResetPrintPreviewModeType && | 384 } else if (type == kJSResetPrintPreviewModeType && |
378 dict.Get(pp::Var(kJSPrintPreviewUrl)).is_string() && | 385 dict.Get(pp::Var(kJSPrintPreviewUrl)).is_string() && |
379 dict.Get(pp::Var(kJSPrintPreviewGrayscale)).is_bool() && | 386 dict.Get(pp::Var(kJSPrintPreviewGrayscale)).is_bool() && |
380 dict.Get(pp::Var(kJSPrintPreviewPageCount)).is_int()) { | 387 dict.Get(pp::Var(kJSPrintPreviewPageCount)).is_int()) { |
381 url_ = dict.Get(pp::Var(kJSPrintPreviewUrl)).AsString(); | 388 url_ = dict.Get(pp::Var(kJSPrintPreviewUrl)).AsString(); |
382 preview_pages_info_ = std::queue<PreviewPageInfo>(); | 389 preview_pages_info_ = std::queue<PreviewPageInfo>(); |
383 preview_document_load_state_ = LOAD_STATE_COMPLETE; | 390 preview_document_load_state_ = LOAD_STATE_COMPLETE; |
384 document_load_state_ = LOAD_STATE_LOADING; | 391 document_load_state_ = LOAD_STATE_LOADING; |
385 LoadUrl(url_); | 392 LoadUrl(url_); |
386 preview_engine_.reset(); | 393 preview_engine_.reset(); |
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 pp::Point OutOfProcessInstance::BoundScrollOffsetToDocument( | 1366 pp::Point OutOfProcessInstance::BoundScrollOffsetToDocument( |
1360 const pp::Point& scroll_offset) { | 1367 const pp::Point& scroll_offset) { |
1361 int max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1368 int max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
1362 int x = std::max(std::min(scroll_offset.x(), max_x), 0); | 1369 int x = std::max(std::min(scroll_offset.x(), max_x), 0); |
1363 int max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1370 int max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
1364 int y = std::max(std::min(scroll_offset.y(), max_y), 0); | 1371 int y = std::max(std::min(scroll_offset.y(), max_y), 0); |
1365 return pp::Point(x, y); | 1372 return pp::Point(x, y); |
1366 } | 1373 } |
1367 | 1374 |
1368 } // namespace chrome_pdf | 1375 } // namespace chrome_pdf |
OLD | NEW |