| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 const char kJSDocumentWidth[] = "width"; | 66 const char kJSDocumentWidth[] = "width"; |
| 67 const char kJSDocumentHeight[] = "height"; | 67 const char kJSDocumentHeight[] = "height"; |
| 68 const char kJSPageDimensions[] = "pageDimensions"; | 68 const char kJSPageDimensions[] = "pageDimensions"; |
| 69 const char kJSPageX[] = "x"; | 69 const char kJSPageX[] = "x"; |
| 70 const char kJSPageY[] = "y"; | 70 const char kJSPageY[] = "y"; |
| 71 const char kJSPageWidth[] = "width"; | 71 const char kJSPageWidth[] = "width"; |
| 72 const char kJSPageHeight[] = "height"; | 72 const char kJSPageHeight[] = "height"; |
| 73 // Document load progress arguments (Plugin -> Page) | 73 // Document load progress arguments (Plugin -> Page) |
| 74 const char kJSLoadProgressType[] = "loadProgress"; | 74 const char kJSLoadProgressType[] = "loadProgress"; |
| 75 const char kJSProgressPercentage[] = "progress"; | 75 const char kJSProgressPercentage[] = "progress"; |
| 76 // Bookmarks |
| 77 const char kJSBookmarksType[] = "bookmarks"; |
| 78 const char kJSBookmarks[] = "bookmarks"; |
| 76 // Get password arguments (Plugin -> Page) | 79 // Get password arguments (Plugin -> Page) |
| 77 const char kJSGetPasswordType[] = "getPassword"; | 80 const char kJSGetPasswordType[] = "getPassword"; |
| 78 // Get password complete arguments (Page -> Plugin) | 81 // Get password complete arguments (Page -> Plugin) |
| 79 const char kJSGetPasswordCompleteType[] = "getPasswordComplete"; | 82 const char kJSGetPasswordCompleteType[] = "getPasswordComplete"; |
| 80 const char kJSPassword[] = "password"; | 83 const char kJSPassword[] = "password"; |
| 81 // Print (Page -> Plugin) | 84 // Print (Page -> Plugin) |
| 82 const char kJSPrintType[] = "print"; | 85 const char kJSPrintType[] = "print"; |
| 83 // Save (Page -> Plugin) | 86 // Save (Page -> Plugin) |
| 84 const char kJSSaveType[] = "save"; | 87 const char kJSSaveType[] = "save"; |
| 85 // Go to page (Plugin -> Page) | 88 // Go to page (Plugin -> Page) |
| (...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 if (IsPrintPreview()) { | 1107 if (IsPrintPreview()) { |
| 1105 AppendBlankPrintPreviewPages(); | 1108 AppendBlankPrintPreviewPages(); |
| 1106 OnGeometryChanged(0, 0); | 1109 OnGeometryChanged(0, 0); |
| 1107 } | 1110 } |
| 1108 | 1111 |
| 1109 pp::VarDictionary message; | 1112 pp::VarDictionary message; |
| 1110 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); | 1113 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); |
| 1111 message.Set(pp::Var(kJSProgressPercentage), pp::Var(100)) ; | 1114 message.Set(pp::Var(kJSProgressPercentage), pp::Var(100)) ; |
| 1112 PostMessage(message); | 1115 PostMessage(message); |
| 1113 | 1116 |
| 1117 pp::VarDictionary bookmarksMessage; |
| 1118 bookmarksMessage.Set(pp::Var(kType), pp::Var(kJSBookmarksType)); |
| 1119 bookmarksMessage.Set(pp::Var(kJSBookmarks), engine_->GetBookmarks()); |
| 1120 PostMessage(bookmarksMessage); |
| 1121 |
| 1114 if (!full_) | 1122 if (!full_) |
| 1115 return; | 1123 return; |
| 1116 | 1124 |
| 1117 if (did_call_start_loading_) { | 1125 if (did_call_start_loading_) { |
| 1118 pp::PDF::DidStopLoading(this); | 1126 pp::PDF::DidStopLoading(this); |
| 1119 did_call_start_loading_ = false; | 1127 did_call_start_loading_ = false; |
| 1120 } | 1128 } |
| 1121 | 1129 |
| 1122 int content_restrictions = | 1130 int content_restrictions = |
| 1123 CONTENT_RESTRICTION_CUT | CONTENT_RESTRICTION_PASTE; | 1131 CONTENT_RESTRICTION_CUT | CONTENT_RESTRICTION_PASTE; |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( | 1403 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( |
| 1396 const pp::FloatPoint& scroll_offset) { | 1404 const pp::FloatPoint& scroll_offset) { |
| 1397 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1405 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
| 1398 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1406 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
| 1399 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1407 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
| 1400 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); | 1408 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); |
| 1401 return pp::FloatPoint(x, y); | 1409 return pp::FloatPoint(x, y); |
| 1402 } | 1410 } |
| 1403 | 1411 |
| 1404 } // namespace chrome_pdf | 1412 } // namespace chrome_pdf |
| OLD | NEW |