| 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 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 // Note: If we are in print preview mode the scroll location is retained | 1105 // Note: If we are in print preview mode the scroll location is retained |
| 1106 // across document loads so we don't want to scroll again and override it. | 1106 // across document loads so we don't want to scroll again and override it. |
| 1107 if (IsPrintPreview()) { | 1107 if (IsPrintPreview()) { |
| 1108 AppendBlankPrintPreviewPages(); | 1108 AppendBlankPrintPreviewPages(); |
| 1109 OnGeometryChanged(0, 0); | 1109 OnGeometryChanged(0, 0); |
| 1110 } | 1110 } |
| 1111 | 1111 |
| 1112 pp::VarDictionary metadata_message; | 1112 pp::VarDictionary metadata_message; |
| 1113 metadata_message.Set(pp::Var(kType), pp::Var(kJSMetadataType)); | 1113 metadata_message.Set(pp::Var(kType), pp::Var(kJSMetadataType)); |
| 1114 std::string title = engine_->GetMetadata("Title"); | 1114 std::string title = engine_->GetMetadata("Title"); |
| 1115 if (!base::TrimWhitespace(base::UTF8ToUTF16(title), base::TRIM_ALL).empty()) | 1115 bool has_title = |
| 1116 !base::TrimWhitespace(base::UTF8ToUTF16(title), base::TRIM_ALL).empty(); |
| 1117 if (has_title) |
| 1116 metadata_message.Set(pp::Var(kJSTitle), pp::Var(title)); | 1118 metadata_message.Set(pp::Var(kJSTitle), pp::Var(title)); |
| 1119 uma_.HistogramEnumeration("PDF.HasFeature.Title", has_title ? 1 : 0, 2); |
| 1117 | 1120 |
| 1118 metadata_message.Set(pp::Var(kJSBookmarks), engine_->GetBookmarks()); | 1121 pp::VarArray bookmarks = engine_->GetBookmarks(); |
| 1122 metadata_message.Set(pp::Var(kJSBookmarks), bookmarks); |
| 1123 uma_.HistogramEnumeration("PDF.HasFeature.Bookmarks", |
| 1124 bookmarks.GetLength() > 0 ? 1 : 0, 2); |
| 1119 PostMessage(metadata_message); | 1125 PostMessage(metadata_message); |
| 1120 | 1126 |
| 1121 pp::VarDictionary progress_message; | 1127 pp::VarDictionary progress_message; |
| 1122 progress_message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); | 1128 progress_message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); |
| 1123 progress_message.Set(pp::Var(kJSProgressPercentage), pp::Var(100)); | 1129 progress_message.Set(pp::Var(kJSProgressPercentage), pp::Var(100)); |
| 1124 PostMessage(progress_message); | 1130 PostMessage(progress_message); |
| 1125 | 1131 |
| 1126 if (!full_) | 1132 if (!full_) |
| 1127 return; | 1133 return; |
| 1128 | 1134 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1416 const pp::FloatPoint& scroll_offset) { | 1422 const pp::FloatPoint& scroll_offset) { |
| 1417 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1423 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
| 1418 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1424 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
| 1419 float min_y = -top_toolbar_height_; | 1425 float min_y = -top_toolbar_height_; |
| 1420 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1426 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
| 1421 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1427 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
| 1422 return pp::FloatPoint(x, y); | 1428 return pp::FloatPoint(x, y); |
| 1423 } | 1429 } |
| 1424 | 1430 |
| 1425 } // namespace chrome_pdf | 1431 } // namespace chrome_pdf |
| OLD | NEW |