| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> // for min/max() | 10 #include <algorithm> // for min/max() |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 const char kJSPreviewPageIndex[] = "index"; | 97 const char kJSPreviewPageIndex[] = "index"; |
| 98 // Set scroll position (Plugin -> Page) | 98 // Set scroll position (Plugin -> Page) |
| 99 const char kJSSetScrollPositionType[] = "setScrollPosition"; | 99 const char kJSSetScrollPositionType[] = "setScrollPosition"; |
| 100 const char kJSPositionX[] = "x"; | 100 const char kJSPositionX[] = "x"; |
| 101 const char kJSPositionY[] = "y"; | 101 const char kJSPositionY[] = "y"; |
| 102 // Cancel the stream URL request (Plugin -> Page) | 102 // Cancel the stream URL request (Plugin -> Page) |
| 103 const char kJSCancelStreamUrlType[] = "cancelStreamUrl"; | 103 const char kJSCancelStreamUrlType[] = "cancelStreamUrl"; |
| 104 // Navigate to the given URL (Plugin -> Page) | 104 // Navigate to the given URL (Plugin -> Page) |
| 105 const char kJSNavigateType[] = "navigate"; | 105 const char kJSNavigateType[] = "navigate"; |
| 106 const char kJSNavigateUrl[] = "url"; | 106 const char kJSNavigateUrl[] = "url"; |
| 107 const char kJSNavigateNewTab[] = "newTab"; | 107 const char kJSNavigateOption[] = "option"; |
| 108 // Open the email editor with the given parameters (Plugin -> Page) | 108 // Open the email editor with the given parameters (Plugin -> Page) |
| 109 const char kJSEmailType[] = "email"; | 109 const char kJSEmailType[] = "email"; |
| 110 const char kJSEmailTo[] = "to"; | 110 const char kJSEmailTo[] = "to"; |
| 111 const char kJSEmailCc[] = "cc"; | 111 const char kJSEmailCc[] = "cc"; |
| 112 const char kJSEmailBcc[] = "bcc"; | 112 const char kJSEmailBcc[] = "bcc"; |
| 113 const char kJSEmailSubject[] = "subject"; | 113 const char kJSEmailSubject[] = "subject"; |
| 114 const char kJSEmailBody[] = "body"; | 114 const char kJSEmailBody[] = "body"; |
| 115 // Rotation (Page -> Plugin) | 115 // Rotation (Page -> Plugin) |
| 116 const char kJSRotateClockwiseType[] = "rotateClockwise"; | 116 const char kJSRotateClockwiseType[] = "rotateClockwise"; |
| 117 const char kJSRotateCounterclockwiseType[] = "rotateCounterclockwise"; | 117 const char kJSRotateCounterclockwiseType[] = "rotateCounterclockwise"; |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 if (engine_->GetNumberOfPages() == 0) | 970 if (engine_->GetNumberOfPages() == 0) |
| 971 return; | 971 return; |
| 972 | 972 |
| 973 pp::VarDictionary message; | 973 pp::VarDictionary message; |
| 974 message.Set(kType, kJSGoToPageType); | 974 message.Set(kType, kJSGoToPageType); |
| 975 message.Set(kJSPageNumber, pp::Var(page)); | 975 message.Set(kJSPageNumber, pp::Var(page)); |
| 976 PostMessage(message); | 976 PostMessage(message); |
| 977 } | 977 } |
| 978 | 978 |
| 979 void OutOfProcessInstance::NavigateTo(const std::string& url, | 979 void OutOfProcessInstance::NavigateTo(const std::string& url, |
| 980 bool open_in_new_tab) { | 980 int option) { |
| 981 pp::VarDictionary message; | 981 pp::VarDictionary message; |
| 982 message.Set(kType, kJSNavigateType); | 982 message.Set(kType, kJSNavigateType); |
| 983 message.Set(kJSNavigateUrl, url); | 983 message.Set(kJSNavigateUrl, url); |
| 984 message.Set(kJSNavigateNewTab, open_in_new_tab); | 984 message.Set(kJSNavigateOption, pp::Var(option)); |
| 985 PostMessage(message); | 985 PostMessage(message); |
| 986 } | 986 } |
| 987 | 987 |
| 988 void OutOfProcessInstance::UpdateCursor(PP_CursorType_Dev cursor) { | 988 void OutOfProcessInstance::UpdateCursor(PP_CursorType_Dev cursor) { |
| 989 if (cursor == cursor_) | 989 if (cursor == cursor_) |
| 990 return; | 990 return; |
| 991 cursor_ = cursor; | 991 cursor_ = cursor; |
| 992 | 992 |
| 993 const PPB_CursorControl_Dev* cursor_interface = | 993 const PPB_CursorControl_Dev* cursor_interface = |
| 994 reinterpret_cast<const PPB_CursorControl_Dev*>( | 994 reinterpret_cast<const PPB_CursorControl_Dev*>( |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1523 const pp::FloatPoint& scroll_offset) { | 1523 const pp::FloatPoint& scroll_offset) { |
| 1524 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1524 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
| 1525 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1525 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
| 1526 float min_y = -top_toolbar_height_; | 1526 float min_y = -top_toolbar_height_; |
| 1527 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1527 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
| 1528 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1528 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
| 1529 return pp::FloatPoint(x, y); | 1529 return pp::FloatPoint(x, y); |
| 1530 } | 1530 } |
| 1531 | 1531 |
| 1532 } // namespace chrome_pdf | 1532 } // namespace chrome_pdf |
| OLD | NEW |