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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 cursor_(PP_CURSORTYPE_POINTER), | 275 cursor_(PP_CURSORTYPE_POINTER), |
276 zoom_(1.0), | 276 zoom_(1.0), |
277 device_scale_(1.0), | 277 device_scale_(1.0), |
278 full_(false), | 278 full_(false), |
279 paint_manager_(this, this, true), | 279 paint_manager_(this, this, true), |
280 first_paint_(true), | 280 first_paint_(true), |
281 document_load_state_(LOAD_STATE_LOADING), | 281 document_load_state_(LOAD_STATE_LOADING), |
282 preview_document_load_state_(LOAD_STATE_COMPLETE), | 282 preview_document_load_state_(LOAD_STATE_COMPLETE), |
283 uma_(this), | 283 uma_(this), |
284 told_browser_about_unsupported_feature_(false), | 284 told_browser_about_unsupported_feature_(false), |
| 285 #if defined(OS_LINUX) |
| 286 font_substitution_reported_(false), |
| 287 #endif |
285 print_preview_page_count_(0), | 288 print_preview_page_count_(0), |
286 last_progress_sent_(0), | 289 last_progress_sent_(0), |
287 recently_sent_find_update_(false), | 290 recently_sent_find_update_(false), |
288 received_viewport_message_(false), | 291 received_viewport_message_(false), |
289 did_call_start_loading_(false), | 292 did_call_start_loading_(false), |
290 stop_scrolling_(false), | 293 stop_scrolling_(false), |
291 background_color_(0), | 294 background_color_(0), |
292 top_toolbar_height_(0), | 295 top_toolbar_height_(0), |
293 accessibility_state_(ACCESSIBILITY_STATE_OFF) { | 296 accessibility_state_(ACCESSIBILITY_STATE_OFF) { |
294 loader_factory_.Initialize(this); | 297 loader_factory_.Initialize(this); |
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1199 | 1202 |
1200 void OutOfProcessInstance::DocumentLoadComplete(int page_count) { | 1203 void OutOfProcessInstance::DocumentLoadComplete(int page_count) { |
1201 // Clear focus state for OSK. | 1204 // Clear focus state for OSK. |
1202 FormTextFieldFocusChange(false); | 1205 FormTextFieldFocusChange(false); |
1203 | 1206 |
1204 DCHECK(document_load_state_ == LOAD_STATE_LOADING); | 1207 DCHECK(document_load_state_ == LOAD_STATE_LOADING); |
1205 document_load_state_ = LOAD_STATE_COMPLETE; | 1208 document_load_state_ = LOAD_STATE_COMPLETE; |
1206 UserMetricsRecordAction("PDF.LoadSuccess"); | 1209 UserMetricsRecordAction("PDF.LoadSuccess"); |
1207 uma_.HistogramEnumeration("PDF.DocumentFeature", LOADED_DOCUMENT, | 1210 uma_.HistogramEnumeration("PDF.DocumentFeature", LOADED_DOCUMENT, |
1208 FEATURES_COUNT); | 1211 FEATURES_COUNT); |
| 1212 #if defined(OS_LINUX) |
| 1213 if (!font_substitution_reported_) |
| 1214 uma_.HistogramEnumeration("PDF.IsFontSubstituted", 0, 2); |
| 1215 #endif |
1209 | 1216 |
1210 // Note: If we are in print preview mode the scroll location is retained | 1217 // 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. | 1218 // across document loads so we don't want to scroll again and override it. |
1212 if (IsPrintPreview()) { | 1219 if (IsPrintPreview()) { |
1213 AppendBlankPrintPreviewPages(); | 1220 AppendBlankPrintPreviewPages(); |
1214 OnGeometryChanged(0, 0); | 1221 OnGeometryChanged(0, 0); |
1215 } | 1222 } |
1216 | 1223 |
1217 pp::VarDictionary metadata_message; | 1224 pp::VarDictionary metadata_message; |
1218 metadata_message.Set(pp::Var(kType), pp::Var(kJSMetadataType)); | 1225 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; | 1312 document_load_state_ = LOAD_STATE_FAILED; |
1306 paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); | 1313 paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); |
1307 | 1314 |
1308 // Send a progress value of -1 to indicate a failure. | 1315 // Send a progress value of -1 to indicate a failure. |
1309 pp::VarDictionary message; | 1316 pp::VarDictionary message; |
1310 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); | 1317 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); |
1311 message.Set(pp::Var(kJSProgressPercentage), pp::Var(-1)); | 1318 message.Set(pp::Var(kJSProgressPercentage), pp::Var(-1)); |
1312 PostMessage(message); | 1319 PostMessage(message); |
1313 } | 1320 } |
1314 | 1321 |
| 1322 void OutOfProcessInstance::FontSubstituted() { |
| 1323 #if defined(OS_LINUX) |
| 1324 if (font_substitution_reported_) |
| 1325 return; |
| 1326 font_substitution_reported_ = true; |
| 1327 uma_.HistogramEnumeration("PDF.IsFontSubstituted", 1, 2); |
| 1328 #endif |
| 1329 } |
| 1330 |
1315 void OutOfProcessInstance::PreviewDocumentLoadFailed() { | 1331 void OutOfProcessInstance::PreviewDocumentLoadFailed() { |
1316 UserMetricsRecordAction("PDF.PreviewDocumentLoadFailure"); | 1332 UserMetricsRecordAction("PDF.PreviewDocumentLoadFailure"); |
1317 if (preview_document_load_state_ != LOAD_STATE_LOADING || | 1333 if (preview_document_load_state_ != LOAD_STATE_LOADING || |
1318 preview_pages_info_.empty()) { | 1334 preview_pages_info_.empty()) { |
1319 return; | 1335 return; |
1320 } | 1336 } |
1321 | 1337 |
1322 preview_document_load_state_ = LOAD_STATE_FAILED; | 1338 preview_document_load_state_ = LOAD_STATE_FAILED; |
1323 preview_pages_info_.pop(); | 1339 preview_pages_info_.pop(); |
1324 | 1340 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1534 const pp::FloatPoint& scroll_offset) { | 1550 const pp::FloatPoint& scroll_offset) { |
1535 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1551 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); | 1552 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
1537 float min_y = -top_toolbar_height_; | 1553 float min_y = -top_toolbar_height_; |
1538 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1554 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); | 1555 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
1540 return pp::FloatPoint(x, y); | 1556 return pp::FloatPoint(x, y); |
1541 } | 1557 } |
1542 | 1558 |
1543 } // namespace chrome_pdf | 1559 } // namespace chrome_pdf |
OLD | NEW |