| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 150 |
| 151 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1; | 151 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1; |
| 152 | 152 |
| 153 // Used for UMA. Do not delete entries, and keep in sync with histograms.xml. | 153 // Used for UMA. Do not delete entries, and keep in sync with histograms.xml. |
| 154 enum PDFFeatures { | 154 enum PDFFeatures { |
| 155 LOADED_DOCUMENT = 0, | 155 LOADED_DOCUMENT = 0, |
| 156 HAS_TITLE = 1, | 156 HAS_TITLE = 1, |
| 157 HAS_BOOKMARKS = 2, | 157 HAS_BOOKMARKS = 2, |
| 158 FEATURES_COUNT | 158 FEATURES_COUNT |
| 159 }; | 159 }; |
| 160 enum PDFFontSubstituted { |
| 161 NO_FONT_SUBST = 0, |
| 162 FONT_SUBSTITUTED = 1, |
| 163 FONT_SUBST_BOOL |
| 164 }; |
| 160 | 165 |
| 161 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { | 166 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { |
| 162 pp::Var var; | 167 pp::Var var; |
| 163 void* object = pp::Instance::GetPerInstanceObject(instance, kPPPPdfInterface); | 168 void* object = pp::Instance::GetPerInstanceObject(instance, kPPPPdfInterface); |
| 164 if (object) { | 169 if (object) { |
| 165 var = static_cast<OutOfProcessInstance*>(object)->GetLinkAtPosition( | 170 var = static_cast<OutOfProcessInstance*>(object)->GetLinkAtPosition( |
| 166 pp::Point(point)); | 171 pp::Point(point)); |
| 167 } | 172 } |
| 168 return var.Detach(); | 173 return var.Detach(); |
| 169 } | 174 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 cursor_(PP_CURSORTYPE_POINTER), | 280 cursor_(PP_CURSORTYPE_POINTER), |
| 276 zoom_(1.0), | 281 zoom_(1.0), |
| 277 device_scale_(1.0), | 282 device_scale_(1.0), |
| 278 full_(false), | 283 full_(false), |
| 279 paint_manager_(this, this, true), | 284 paint_manager_(this, this, true), |
| 280 first_paint_(true), | 285 first_paint_(true), |
| 281 document_load_state_(LOAD_STATE_LOADING), | 286 document_load_state_(LOAD_STATE_LOADING), |
| 282 preview_document_load_state_(LOAD_STATE_COMPLETE), | 287 preview_document_load_state_(LOAD_STATE_COMPLETE), |
| 283 uma_(this), | 288 uma_(this), |
| 284 told_browser_about_unsupported_feature_(false), | 289 told_browser_about_unsupported_feature_(false), |
| 290 font_substitution_reported_(false), |
| 285 print_preview_page_count_(0), | 291 print_preview_page_count_(0), |
| 286 last_progress_sent_(0), | 292 last_progress_sent_(0), |
| 287 recently_sent_find_update_(false), | 293 recently_sent_find_update_(false), |
| 288 received_viewport_message_(false), | 294 received_viewport_message_(false), |
| 289 did_call_start_loading_(false), | 295 did_call_start_loading_(false), |
| 290 stop_scrolling_(false), | 296 stop_scrolling_(false), |
| 291 background_color_(0), | 297 background_color_(0), |
| 292 top_toolbar_height_(0), | 298 top_toolbar_height_(0), |
| 293 accessibility_state_(ACCESSIBILITY_STATE_OFF) { | 299 accessibility_state_(ACCESSIBILITY_STATE_OFF) { |
| 294 loader_factory_.Initialize(this); | 300 loader_factory_.Initialize(this); |
| (...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1199 | 1205 |
| 1200 void OutOfProcessInstance::DocumentLoadComplete(int page_count) { | 1206 void OutOfProcessInstance::DocumentLoadComplete(int page_count) { |
| 1201 // Clear focus state for OSK. | 1207 // Clear focus state for OSK. |
| 1202 FormTextFieldFocusChange(false); | 1208 FormTextFieldFocusChange(false); |
| 1203 | 1209 |
| 1204 DCHECK(document_load_state_ == LOAD_STATE_LOADING); | 1210 DCHECK(document_load_state_ == LOAD_STATE_LOADING); |
| 1205 document_load_state_ = LOAD_STATE_COMPLETE; | 1211 document_load_state_ = LOAD_STATE_COMPLETE; |
| 1206 UserMetricsRecordAction("PDF.LoadSuccess"); | 1212 UserMetricsRecordAction("PDF.LoadSuccess"); |
| 1207 uma_.HistogramEnumeration("PDF.DocumentFeature", LOADED_DOCUMENT, | 1213 uma_.HistogramEnumeration("PDF.DocumentFeature", LOADED_DOCUMENT, |
| 1208 FEATURES_COUNT); | 1214 FEATURES_COUNT); |
| 1215 if (!font_substitution_reported_) |
| 1216 uma_.HistogramEnumeration("PDF.FontSubstituted", NO_FONT_SUBST, |
| 1217 FONT_SUBST_BOOL); |
| 1209 | 1218 |
| 1210 // Note: If we are in print preview mode the scroll location is retained | 1219 // Note: If we are in print preview mode the scroll location is retained |
| 1211 // across document loads so we don't want to scroll again and override it. | 1220 // across document loads so we don't want to scroll again and override it. |
| 1212 if (IsPrintPreview()) { | 1221 if (IsPrintPreview()) { |
| 1213 AppendBlankPrintPreviewPages(); | 1222 AppendBlankPrintPreviewPages(); |
| 1214 OnGeometryChanged(0, 0); | 1223 OnGeometryChanged(0, 0); |
| 1215 } | 1224 } |
| 1216 | 1225 |
| 1217 pp::VarDictionary metadata_message; | 1226 pp::VarDictionary metadata_message; |
| 1218 metadata_message.Set(pp::Var(kType), pp::Var(kJSMetadataType)); | 1227 metadata_message.Set(pp::Var(kType), pp::Var(kJSMetadataType)); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1305 document_load_state_ = LOAD_STATE_FAILED; | 1314 document_load_state_ = LOAD_STATE_FAILED; |
| 1306 paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); | 1315 paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); |
| 1307 | 1316 |
| 1308 // Send a progress value of -1 to indicate a failure. | 1317 // Send a progress value of -1 to indicate a failure. |
| 1309 pp::VarDictionary message; | 1318 pp::VarDictionary message; |
| 1310 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); | 1319 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); |
| 1311 message.Set(pp::Var(kJSProgressPercentage), pp::Var(-1)); | 1320 message.Set(pp::Var(kJSProgressPercentage), pp::Var(-1)); |
| 1312 PostMessage(message); | 1321 PostMessage(message); |
| 1313 } | 1322 } |
| 1314 | 1323 |
| 1324 void OutOfProcessInstance::FontSubstituted() { |
| 1325 if (font_substitution_reported_) |
| 1326 return; |
| 1327 font_substitution_reported_ = true; |
| 1328 uma_.HistogramEnumeration("PDF.FontSubstituted", FONT_SUBSTITUTED, |
| 1329 FONT_SUBST_BOOL); |
| 1330 } |
| 1331 |
| 1315 void OutOfProcessInstance::PreviewDocumentLoadFailed() { | 1332 void OutOfProcessInstance::PreviewDocumentLoadFailed() { |
| 1316 UserMetricsRecordAction("PDF.PreviewDocumentLoadFailure"); | 1333 UserMetricsRecordAction("PDF.PreviewDocumentLoadFailure"); |
| 1317 if (preview_document_load_state_ != LOAD_STATE_LOADING || | 1334 if (preview_document_load_state_ != LOAD_STATE_LOADING || |
| 1318 preview_pages_info_.empty()) { | 1335 preview_pages_info_.empty()) { |
| 1319 return; | 1336 return; |
| 1320 } | 1337 } |
| 1321 | 1338 |
| 1322 preview_document_load_state_ = LOAD_STATE_FAILED; | 1339 preview_document_load_state_ = LOAD_STATE_FAILED; |
| 1323 preview_pages_info_.pop(); | 1340 preview_pages_info_.pop(); |
| 1324 | 1341 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1534 const pp::FloatPoint& scroll_offset) { | 1551 const pp::FloatPoint& scroll_offset) { |
| 1535 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1552 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
| 1536 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1553 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
| 1537 float min_y = -top_toolbar_height_; | 1554 float min_y = -top_toolbar_height_; |
| 1538 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1555 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
| 1539 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1556 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
| 1540 return pp::FloatPoint(x, y); | 1557 return pp::FloatPoint(x, y); |
| 1541 } | 1558 } |
| 1542 | 1559 |
| 1543 } // namespace chrome_pdf | 1560 } // namespace chrome_pdf |
| OLD | NEW |