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> |
11 #include <list> | 11 #include <list> |
12 | 12 |
13 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
14 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/string_split.h" | 17 #include "base/strings/string_split.h" |
18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 19 #include "base/strings/utf_string_conversions.h" |
19 #include "base/values.h" | 20 #include "base/values.h" |
20 #include "chrome/common/content_restriction.h" | 21 #include "chrome/common/content_restriction.h" |
21 #include "net/base/escape.h" | 22 #include "net/base/escape.h" |
22 #include "pdf/pdf.h" | 23 #include "pdf/pdf.h" |
23 #include "ppapi/c/dev/ppb_cursor_control_dev.h" | 24 #include "ppapi/c/dev/ppb_cursor_control_dev.h" |
24 #include "ppapi/c/pp_errors.h" | 25 #include "ppapi/c/pp_errors.h" |
25 #include "ppapi/c/pp_rect.h" | 26 #include "ppapi/c/pp_rect.h" |
26 #include "ppapi/c/private/ppb_instance_private.h" | 27 #include "ppapi/c/private/ppb_instance_private.h" |
27 #include "ppapi/c/private/ppp_pdf.h" | 28 #include "ppapi/c/private/ppp_pdf.h" |
28 #include "ppapi/c/trusted/ppb_url_loader_trusted.h" | 29 #include "ppapi/c/trusted/ppb_url_loader_trusted.h" |
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 // Note: If we are in print preview mode the scroll location is retained | 1124 // Note: If we are in print preview mode the scroll location is retained |
1124 // across document loads so we don't want to scroll again and override it. | 1125 // across document loads so we don't want to scroll again and override it. |
1125 if (IsPrintPreview()) { | 1126 if (IsPrintPreview()) { |
1126 AppendBlankPrintPreviewPages(); | 1127 AppendBlankPrintPreviewPages(); |
1127 OnGeometryChanged(0, 0); | 1128 OnGeometryChanged(0, 0); |
1128 } | 1129 } |
1129 | 1130 |
1130 pp::VarDictionary metadata_message; | 1131 pp::VarDictionary metadata_message; |
1131 metadata_message.Set(pp::Var(kType), pp::Var(kJSMetadataType)); | 1132 metadata_message.Set(pp::Var(kType), pp::Var(kJSMetadataType)); |
1132 std::string title = engine_->GetMetadata("Title"); | 1133 std::string title = engine_->GetMetadata("Title"); |
1133 if (!title.empty()) | 1134 if (!base::TrimWhitespace(base::UTF8ToUTF16(title), base::TRIM_ALL).empty()) |
1134 metadata_message.Set(pp::Var(kJSTitle), pp::Var(title)); | 1135 metadata_message.Set(pp::Var(kJSTitle), pp::Var(title)); |
1135 | 1136 |
1136 metadata_message.Set(pp::Var(kJSBookmarks), engine_->GetBookmarks()); | 1137 metadata_message.Set(pp::Var(kJSBookmarks), engine_->GetBookmarks()); |
1137 PostMessage(metadata_message); | 1138 PostMessage(metadata_message); |
1138 | 1139 |
1139 pp::VarDictionary progress_message; | 1140 pp::VarDictionary progress_message; |
1140 progress_message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); | 1141 progress_message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); |
1141 progress_message.Set(pp::Var(kJSProgressPercentage), pp::Var(100)); | 1142 progress_message.Set(pp::Var(kJSProgressPercentage), pp::Var(100)); |
1142 PostMessage(progress_message); | 1143 PostMessage(progress_message); |
1143 | 1144 |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1436 const pp::FloatPoint& scroll_offset) { | 1437 const pp::FloatPoint& scroll_offset) { |
1437 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1438 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
1438 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1439 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
1439 float min_y = -top_toolbar_height_; | 1440 float min_y = -top_toolbar_height_; |
1440 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1441 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
1441 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1442 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
1442 return pp::FloatPoint(x, y); | 1443 return pp::FloatPoint(x, y); |
1443 } | 1444 } |
1444 | 1445 |
1445 } // namespace chrome_pdf | 1446 } // namespace chrome_pdf |
OLD | NEW |