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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 const char kJSDocumentWidth[] = "width"; | 70 const char kJSDocumentWidth[] = "width"; |
71 const char kJSDocumentHeight[] = "height"; | 71 const char kJSDocumentHeight[] = "height"; |
72 const char kJSPageDimensions[] = "pageDimensions"; | 72 const char kJSPageDimensions[] = "pageDimensions"; |
73 const char kJSPageX[] = "x"; | 73 const char kJSPageX[] = "x"; |
74 const char kJSPageY[] = "y"; | 74 const char kJSPageY[] = "y"; |
75 const char kJSPageWidth[] = "width"; | 75 const char kJSPageWidth[] = "width"; |
76 const char kJSPageHeight[] = "height"; | 76 const char kJSPageHeight[] = "height"; |
77 // Document load progress arguments (Plugin -> Page) | 77 // Document load progress arguments (Plugin -> Page) |
78 const char kJSLoadProgressType[] = "loadProgress"; | 78 const char kJSLoadProgressType[] = "loadProgress"; |
79 const char kJSProgressPercentage[] = "progress"; | 79 const char kJSProgressPercentage[] = "progress"; |
80 // Bookmarks | 80 // Metadata |
81 const char kJSBookmarksType[] = "bookmarks"; | 81 const char kJSMetadataType[] = "metadata"; |
82 const char kJSBookmarks[] = "bookmarks"; | 82 const char kJSBookmarks[] = "bookmarks"; |
| 83 const char kJSTitle[] = "title"; |
83 // Get password arguments (Plugin -> Page) | 84 // Get password arguments (Plugin -> Page) |
84 const char kJSGetPasswordType[] = "getPassword"; | 85 const char kJSGetPasswordType[] = "getPassword"; |
85 // Get password complete arguments (Page -> Plugin) | 86 // Get password complete arguments (Page -> Plugin) |
86 const char kJSGetPasswordCompleteType[] = "getPasswordComplete"; | 87 const char kJSGetPasswordCompleteType[] = "getPasswordComplete"; |
87 const char kJSPassword[] = "password"; | 88 const char kJSPassword[] = "password"; |
88 // Print (Page -> Plugin) | 89 // Print (Page -> Plugin) |
89 const char kJSPrintType[] = "print"; | 90 const char kJSPrintType[] = "print"; |
90 // Save (Page -> Plugin) | 91 // Save (Page -> Plugin) |
91 const char kJSSaveType[] = "save"; | 92 const char kJSSaveType[] = "save"; |
92 // Go to page (Plugin -> Page) | 93 // Go to page (Plugin -> Page) |
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 document_load_state_ = LOAD_STATE_COMPLETE; | 1120 document_load_state_ = LOAD_STATE_COMPLETE; |
1120 UserMetricsRecordAction("PDF.LoadSuccess"); | 1121 UserMetricsRecordAction("PDF.LoadSuccess"); |
1121 | 1122 |
1122 // Note: If we are in print preview mode the scroll location is retained | 1123 // Note: If we are in print preview mode the scroll location is retained |
1123 // across document loads so we don't want to scroll again and override it. | 1124 // across document loads so we don't want to scroll again and override it. |
1124 if (IsPrintPreview()) { | 1125 if (IsPrintPreview()) { |
1125 AppendBlankPrintPreviewPages(); | 1126 AppendBlankPrintPreviewPages(); |
1126 OnGeometryChanged(0, 0); | 1127 OnGeometryChanged(0, 0); |
1127 } | 1128 } |
1128 | 1129 |
1129 pp::VarDictionary bookmarks_message; | 1130 pp::VarDictionary metadata_message; |
1130 bookmarks_message.Set(pp::Var(kType), pp::Var(kJSBookmarksType)); | 1131 metadata_message.Set(pp::Var(kType), pp::Var(kJSMetadataType)); |
1131 bookmarks_message.Set(pp::Var(kJSBookmarks), engine_->GetBookmarks()); | 1132 std::string title = engine_->GetMetadata("Title"); |
1132 PostMessage(bookmarks_message); | 1133 if (!title.empty()) |
| 1134 metadata_message.Set(pp::Var(kJSTitle), pp::Var(title)); |
| 1135 |
| 1136 metadata_message.Set(pp::Var(kJSBookmarks), engine_->GetBookmarks()); |
| 1137 PostMessage(metadata_message); |
1133 | 1138 |
1134 pp::VarDictionary progress_message; | 1139 pp::VarDictionary progress_message; |
1135 progress_message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); | 1140 progress_message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); |
1136 progress_message.Set(pp::Var(kJSProgressPercentage), pp::Var(100)); | 1141 progress_message.Set(pp::Var(kJSProgressPercentage), pp::Var(100)); |
1137 PostMessage(progress_message); | 1142 PostMessage(progress_message); |
1138 | 1143 |
1139 if (!full_) | 1144 if (!full_) |
1140 return; | 1145 return; |
1141 | 1146 |
1142 if (did_call_start_loading_) { | 1147 if (did_call_start_loading_) { |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 const pp::FloatPoint& scroll_offset) { | 1436 const pp::FloatPoint& scroll_offset) { |
1432 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1437 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
1433 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1438 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
1434 float min_y = -top_toolbar_height_; | 1439 float min_y = -top_toolbar_height_; |
1435 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1440 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
1436 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1441 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
1437 return pp::FloatPoint(x, y); | 1442 return pp::FloatPoint(x, y); |
1438 } | 1443 } |
1439 | 1444 |
1440 } // namespace chrome_pdf | 1445 } // namespace chrome_pdf |
OLD | NEW |