| 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() |
| 11 #define _USE_MATH_DEFINES // for M_PI | 11 #define _USE_MATH_DEFINES // for M_PI |
| 12 #include <cmath> // for log() and pow() | 12 #include <cmath> // for log() and pow() |
| 13 #include <math.h> | 13 #include <math.h> |
| 14 #include <list> | 14 #include <list> |
| 15 | 15 |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/memory/ptr_util.h" |
| 17 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/string_split.h" | 19 #include "base/strings/string_split.h" |
| 19 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/values.h" | 22 #include "base/values.h" |
| 22 #include "chrome/common/content_restriction.h" | 23 #include "chrome/common/content_restriction.h" |
| 23 #include "net/base/escape.h" | 24 #include "net/base/escape.h" |
| 24 #include "pdf/pdf.h" | 25 #include "pdf/pdf.h" |
| 25 #include "ppapi/c/dev/ppb_cursor_control_dev.h" | 26 #include "ppapi/c/dev/ppb_cursor_control_dev.h" |
| 26 #include "ppapi/c/pp_errors.h" | 27 #include "ppapi/c/pp_errors.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 38 #include "ppapi/cpp/private/var_private.h" | 39 #include "ppapi/cpp/private/var_private.h" |
| 39 #include "ppapi/cpp/rect.h" | 40 #include "ppapi/cpp/rect.h" |
| 40 #include "ppapi/cpp/resource.h" | 41 #include "ppapi/cpp/resource.h" |
| 41 #include "ppapi/cpp/url_request_info.h" | 42 #include "ppapi/cpp/url_request_info.h" |
| 42 #include "ppapi/cpp/var_array.h" | 43 #include "ppapi/cpp/var_array.h" |
| 43 #include "ppapi/cpp/var_dictionary.h" | 44 #include "ppapi/cpp/var_dictionary.h" |
| 44 #include "ui/events/keycodes/keyboard_codes.h" | 45 #include "ui/events/keycodes/keyboard_codes.h" |
| 45 | 46 |
| 46 namespace chrome_pdf { | 47 namespace chrome_pdf { |
| 47 | 48 |
| 49 namespace { |
| 50 |
| 48 const char kChromePrint[] = "chrome://print/"; | 51 const char kChromePrint[] = "chrome://print/"; |
| 49 const char kChromeExtension[] = | 52 const char kChromeExtension[] = |
| 50 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai"; | 53 "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai"; |
| 51 | 54 |
| 52 // Constants used in handling postMessage() messages. | 55 // Constants used in handling postMessage() messages. |
| 53 const char kType[] = "type"; | 56 const char kType[] = "type"; |
| 54 // Viewport message arguments. (Page -> Plugin). | 57 // Viewport message arguments. (Page -> Plugin). |
| 55 const char kJSViewportType[] = "viewport"; | 58 const char kJSViewportType[] = "viewport"; |
| 56 const char kJSXOffset[] = "xOffset"; | 59 const char kJSXOffset[] = "xOffset"; |
| 57 const char kJSYOffset[] = "yOffset"; | 60 const char kJSYOffset[] = "yOffset"; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 const char kJSFieldFocus[] = "focused"; | 149 const char kJSFieldFocus[] = "focused"; |
| 147 | 150 |
| 148 const int kFindResultCooldownMs = 100; | 151 const int kFindResultCooldownMs = 100; |
| 149 | 152 |
| 150 // A delay to wait between each accessibility page to keep the system | 153 // A delay to wait between each accessibility page to keep the system |
| 151 // responsive. | 154 // responsive. |
| 152 const int kAccessibilityPageDelayMs = 100; | 155 const int kAccessibilityPageDelayMs = 100; |
| 153 | 156 |
| 154 const double kMinZoom = 0.01; | 157 const double kMinZoom = 0.01; |
| 155 | 158 |
| 156 namespace { | 159 const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1; |
| 157 | |
| 158 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1; | |
| 159 | 160 |
| 160 // Used for UMA. Do not delete entries, and keep in sync with histograms.xml. | 161 // Used for UMA. Do not delete entries, and keep in sync with histograms.xml. |
| 161 enum PDFFeatures { | 162 enum PDFFeatures { |
| 162 LOADED_DOCUMENT = 0, | 163 LOADED_DOCUMENT = 0, |
| 163 HAS_TITLE = 1, | 164 HAS_TITLE = 1, |
| 164 HAS_BOOKMARKS = 2, | 165 HAS_BOOKMARKS = 2, |
| 165 FEATURES_COUNT | 166 FEATURES_COUNT |
| 166 }; | 167 }; |
| 167 | 168 |
| 168 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { | 169 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 const std::string& message, | 263 const std::string& message, |
| 263 const std::string& default_answer) { | 264 const std::string& default_answer) { |
| 264 const PPB_Instance_Private* interface = | 265 const PPB_Instance_Private* interface = |
| 265 reinterpret_cast<const PPB_Instance_Private*>( | 266 reinterpret_cast<const PPB_Instance_Private*>( |
| 266 pp::Module::Get()->GetBrowserInterface( | 267 pp::Module::Get()->GetBrowserInterface( |
| 267 PPB_INSTANCE_PRIVATE_INTERFACE)); | 268 PPB_INSTANCE_PRIVATE_INTERFACE)); |
| 268 pp::VarPrivate window(pp::PASS_REF, | 269 pp::VarPrivate window(pp::PASS_REF, |
| 269 interface->GetWindowObject(instance->pp_instance())); | 270 interface->GetWindowObject(instance->pp_instance())); |
| 270 if (default_answer.empty()) | 271 if (default_answer.empty()) |
| 271 return window.Call(type, message); | 272 return window.Call(type, message); |
| 272 else | 273 return window.Call(type, message, default_answer); |
| 273 return window.Call(type, message, default_answer); | |
| 274 } | 274 } |
| 275 | 275 |
| 276 } // namespace | 276 } // namespace |
| 277 | 277 |
| 278 OutOfProcessInstance::OutOfProcessInstance(PP_Instance instance) | 278 OutOfProcessInstance::OutOfProcessInstance(PP_Instance instance) |
| 279 : pp::Instance(instance), | 279 : pp::Instance(instance), |
| 280 pp::Find_Private(this), | 280 pp::Find_Private(this), |
| 281 pp::Printing_Dev(this), | 281 pp::Printing_Dev(this), |
| 282 cursor_(PP_CURSORTYPE_POINTER), | 282 cursor_(PP_CURSORTYPE_POINTER), |
| 283 zoom_(1.0), | 283 zoom_(1.0), |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 if (strcmp(argn[i], "full-frame") == 0) { | 345 if (strcmp(argn[i], "full-frame") == 0) { |
| 346 full_ = true; | 346 full_ = true; |
| 347 break; | 347 break; |
| 348 } | 348 } |
| 349 } | 349 } |
| 350 | 350 |
| 351 // Only allow the plugin to handle find requests if it is full frame. | 351 // Only allow the plugin to handle find requests if it is full frame. |
| 352 if (full_) | 352 if (full_) |
| 353 SetPluginToHandleFindRequests(); | 353 SetPluginToHandleFindRequests(); |
| 354 | 354 |
| 355 text_input_.reset(new pp::TextInput_Dev(this)); | 355 text_input_ = base::MakeUnique<pp::TextInput_Dev>(this); |
| 356 | 356 |
| 357 const char* stream_url = nullptr; | 357 const char* stream_url = nullptr; |
| 358 const char* original_url = nullptr; | 358 const char* original_url = nullptr; |
| 359 const char* top_level_url = nullptr; | 359 const char* top_level_url = nullptr; |
| 360 const char* headers = nullptr; | 360 const char* headers = nullptr; |
| 361 for (uint32_t i = 0; i < argc; ++i) { | 361 for (uint32_t i = 0; i < argc; ++i) { |
| 362 bool success = true; | 362 bool success = true; |
| 363 if (strcmp(argn[i], "src") == 0) | 363 if (strcmp(argn[i], "src") == 0) |
| 364 original_url = argv[i]; | 364 original_url = argv[i]; |
| 365 else if (strcmp(argn[i], "stream-url") == 0) | 365 else if (strcmp(argn[i], "stream-url") == 0) |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 engine_->SetGrayscale(dict.Get(pp::Var(kJSPrintPreviewGrayscale)).AsBool()); | 537 engine_->SetGrayscale(dict.Get(pp::Var(kJSPrintPreviewGrayscale)).AsBool()); |
| 538 engine_->New(url_.c_str(), nullptr /* empty header */); | 538 engine_->New(url_.c_str(), nullptr /* empty header */); |
| 539 | 539 |
| 540 print_preview_page_count_ = | 540 print_preview_page_count_ = |
| 541 std::max(dict.Get(pp::Var(kJSPrintPreviewPageCount)).AsInt(), 0); | 541 std::max(dict.Get(pp::Var(kJSPrintPreviewPageCount)).AsInt(), 0); |
| 542 | 542 |
| 543 paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); | 543 paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); |
| 544 } else if (type == kJSLoadPreviewPageType && | 544 } else if (type == kJSLoadPreviewPageType && |
| 545 dict.Get(pp::Var(kJSPreviewPageUrl)).is_string() && | 545 dict.Get(pp::Var(kJSPreviewPageUrl)).is_string() && |
| 546 dict.Get(pp::Var(kJSPreviewPageIndex)).is_int()) { | 546 dict.Get(pp::Var(kJSPreviewPageIndex)).is_int()) { |
| 547 | |
| 548 std::string url = dict.Get(pp::Var(kJSPreviewPageUrl)).AsString(); | 547 std::string url = dict.Get(pp::Var(kJSPreviewPageUrl)).AsString(); |
| 549 // For security reasons we crash if the URL that is trying to be loaded here | 548 // For security reasons we crash if the URL that is trying to be loaded here |
| 550 // isn't a print preview one. | 549 // isn't a print preview one. |
| 551 CHECK(IsPrintPreview()); | 550 CHECK(IsPrintPreview()); |
| 552 CHECK(IsPrintPreviewUrl(url)); | 551 CHECK(IsPrintPreviewUrl(url)); |
| 553 ProcessPreviewPageInfo(url, | 552 ProcessPreviewPageInfo(url, |
| 554 dict.Get(pp::Var(kJSPreviewPageIndex)).AsInt()); | 553 dict.Get(pp::Var(kJSPreviewPageIndex)).AsInt()); |
| 555 } else if (type == kJSStopScrollingType) { | 554 } else if (type == kJSStopScrollingType) { |
| 556 stop_scrolling_ = true; | 555 stop_scrolling_ = true; |
| 557 } else if (type == kJSGetSelectedTextType) { | 556 } else if (type == kJSGetSelectedTextType) { |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 engine_->PostPaint(); | 942 engine_->PostPaint(); |
| 944 } | 943 } |
| 945 | 944 |
| 946 void OutOfProcessInstance::DidOpen(int32_t result) { | 945 void OutOfProcessInstance::DidOpen(int32_t result) { |
| 947 if (result != PP_OK || !engine_->HandleDocumentLoad(embed_loader_)) | 946 if (result != PP_OK || !engine_->HandleDocumentLoad(embed_loader_)) |
| 948 DocumentLoadFailed(); | 947 DocumentLoadFailed(); |
| 949 } | 948 } |
| 950 | 949 |
| 951 void OutOfProcessInstance::DidOpenPreview(int32_t result) { | 950 void OutOfProcessInstance::DidOpenPreview(int32_t result) { |
| 952 if (result == PP_OK) { | 951 if (result == PP_OK) { |
| 953 preview_client_.reset(new PreviewModeClient(this)); | 952 preview_client_ = base::MakeUnique<PreviewModeClient>(this); |
| 954 preview_engine_.reset(PDFEngine::Create(preview_client_.get())); | 953 preview_engine_.reset(PDFEngine::Create(preview_client_.get())); |
| 955 preview_engine_->HandleDocumentLoad(embed_preview_loader_); | 954 preview_engine_->HandleDocumentLoad(embed_preview_loader_); |
| 956 } else { | 955 } else { |
| 957 NOTREACHED(); | 956 NOTREACHED(); |
| 958 } | 957 } |
| 959 } | 958 } |
| 960 | 959 |
| 961 void OutOfProcessInstance::OnClientTimerFired(int32_t id) { | 960 void OutOfProcessInstance::OnClientTimerFired(int32_t id) { |
| 962 engine_->OnCallback(id); | 961 engine_->OnCallback(id); |
| 963 } | 962 } |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 SelectedFindResultChanged(current_find_index); | 1133 SelectedFindResultChanged(current_find_index); |
| 1135 } | 1134 } |
| 1136 | 1135 |
| 1137 void OutOfProcessInstance::GetDocumentPassword( | 1136 void OutOfProcessInstance::GetDocumentPassword( |
| 1138 pp::CompletionCallbackWithOutput<pp::Var> callback) { | 1137 pp::CompletionCallbackWithOutput<pp::Var> callback) { |
| 1139 if (password_callback_) { | 1138 if (password_callback_) { |
| 1140 NOTREACHED(); | 1139 NOTREACHED(); |
| 1141 return; | 1140 return; |
| 1142 } | 1141 } |
| 1143 | 1142 |
| 1144 password_callback_.reset( | 1143 password_callback_ = |
| 1145 new pp::CompletionCallbackWithOutput<pp::Var>(callback)); | 1144 base::MakeUnique<pp::CompletionCallbackWithOutput<pp::Var>>(callback); |
| 1146 pp::VarDictionary message; | 1145 pp::VarDictionary message; |
| 1147 message.Set(pp::Var(kType), pp::Var(kJSGetPasswordType)); | 1146 message.Set(pp::Var(kType), pp::Var(kJSGetPasswordType)); |
| 1148 PostMessage(message); | 1147 PostMessage(message); |
| 1149 } | 1148 } |
| 1150 | 1149 |
| 1151 void OutOfProcessInstance::Alert(const std::string& message) { | 1150 void OutOfProcessInstance::Alert(const std::string& message) { |
| 1152 ModalDialog(this, "alert", message, std::string()); | 1151 ModalDialog(this, "alert", message, std::string()); |
| 1153 } | 1152 } |
| 1154 | 1153 |
| 1155 bool OutOfProcessInstance::Confirm(const std::string& message) { | 1154 bool OutOfProcessInstance::Confirm(const std::string& message) { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1279 memory.MemFree(pp_results); | 1278 memory.MemFree(pp_results); |
| 1280 } | 1279 } |
| 1281 | 1280 |
| 1282 void OutOfProcessInstance::DocumentPaintOccurred() { | 1281 void OutOfProcessInstance::DocumentPaintOccurred() { |
| 1283 } | 1282 } |
| 1284 | 1283 |
| 1285 void OutOfProcessInstance::DocumentLoadComplete(int page_count) { | 1284 void OutOfProcessInstance::DocumentLoadComplete(int page_count) { |
| 1286 // Clear focus state for OSK. | 1285 // Clear focus state for OSK. |
| 1287 FormTextFieldFocusChange(false); | 1286 FormTextFieldFocusChange(false); |
| 1288 | 1287 |
| 1289 DCHECK(document_load_state_ == LOAD_STATE_LOADING); | 1288 DCHECK_EQ(LOAD_STATE_LOADING, document_load_state_); |
| 1290 document_load_state_ = LOAD_STATE_COMPLETE; | 1289 document_load_state_ = LOAD_STATE_COMPLETE; |
| 1291 UserMetricsRecordAction("PDF.LoadSuccess"); | 1290 UserMetricsRecordAction("PDF.LoadSuccess"); |
| 1292 uma_.HistogramEnumeration("PDF.DocumentFeature", LOADED_DOCUMENT, | 1291 uma_.HistogramEnumeration("PDF.DocumentFeature", LOADED_DOCUMENT, |
| 1293 FEATURES_COUNT); | 1292 FEATURES_COUNT); |
| 1294 if (!font_substitution_reported_) | 1293 if (!font_substitution_reported_) |
| 1295 uma_.HistogramEnumeration("PDF.IsFontSubstituted", 0, 2); | 1294 uma_.HistogramEnumeration("PDF.IsFontSubstituted", 0, 2); |
| 1296 | 1295 |
| 1297 // Note: If we are in print preview mode the scroll location is retained | 1296 // Note: If we are in print preview mode the scroll location is retained |
| 1298 // across document loads so we don't want to scroll again and override it. | 1297 // across document loads so we don't want to scroll again and override it. |
| 1299 if (IsPrintPreview()) { | 1298 if (IsPrintPreview()) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 // |print_preview_page_count_| is not updated yet. Do not load any | 1373 // |print_preview_page_count_| is not updated yet. Do not load any |
| 1375 // other preview pages till we get this information. | 1374 // other preview pages till we get this information. |
| 1376 if (print_preview_page_count_ == 0) | 1375 if (print_preview_page_count_ == 0) |
| 1377 return; | 1376 return; |
| 1378 | 1377 |
| 1379 if (!preview_pages_info_.empty()) | 1378 if (!preview_pages_info_.empty()) |
| 1380 LoadAvailablePreviewPage(); | 1379 LoadAvailablePreviewPage(); |
| 1381 } | 1380 } |
| 1382 | 1381 |
| 1383 void OutOfProcessInstance::DocumentLoadFailed() { | 1382 void OutOfProcessInstance::DocumentLoadFailed() { |
| 1384 DCHECK(document_load_state_ == LOAD_STATE_LOADING); | 1383 DCHECK_EQ(LOAD_STATE_LOADING, document_load_state_); |
| 1385 UserMetricsRecordAction("PDF.LoadFailure"); | 1384 UserMetricsRecordAction("PDF.LoadFailure"); |
| 1386 | 1385 |
| 1387 if (did_call_start_loading_) { | 1386 if (did_call_start_loading_) { |
| 1388 pp::PDF::DidStopLoading(this); | 1387 pp::PDF::DidStopLoading(this); |
| 1389 did_call_start_loading_ = false; | 1388 did_call_start_loading_ = false; |
| 1390 } | 1389 } |
| 1391 | 1390 |
| 1392 document_load_state_ = LOAD_STATE_FAILED; | 1391 document_load_state_ = LOAD_STATE_FAILED; |
| 1393 paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); | 1392 paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); |
| 1394 | 1393 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1440 if (told_browser_about_unsupported_feature_) | 1439 if (told_browser_about_unsupported_feature_) |
| 1441 return; | 1440 return; |
| 1442 told_browser_about_unsupported_feature_ = true; | 1441 told_browser_about_unsupported_feature_ = true; |
| 1443 | 1442 |
| 1444 pp::PDF::HasUnsupportedFeature(this); | 1443 pp::PDF::HasUnsupportedFeature(this); |
| 1445 } | 1444 } |
| 1446 | 1445 |
| 1447 void OutOfProcessInstance::DocumentLoadProgress(uint32_t available, | 1446 void OutOfProcessInstance::DocumentLoadProgress(uint32_t available, |
| 1448 uint32_t doc_size) { | 1447 uint32_t doc_size) { |
| 1449 double progress = 0.0; | 1448 double progress = 0.0; |
| 1450 if (doc_size == 0) { | 1449 if (doc_size) { |
| 1450 progress = 100.0 * static_cast<double>(available) / doc_size; |
| 1451 } else { |
| 1451 // Document size is unknown. Use heuristics. | 1452 // Document size is unknown. Use heuristics. |
| 1452 // We'll make progress logarithmic from 0 to 100M. | 1453 // We'll make progress logarithmic from 0 to 100M. |
| 1453 static const double kFactor = log(100000000.0) / 100.0; | 1454 static const double kFactor = log(100000000.0) / 100.0; |
| 1454 if (available > 0) { | 1455 if (available > 0) |
| 1455 progress = log(static_cast<double>(available)) / kFactor; | 1456 progress = std::min(log(static_cast<double>(available)) / kFactor, 100.0); |
| 1456 if (progress > 100.0) | |
| 1457 progress = 100.0; | |
| 1458 } | |
| 1459 } else { | |
| 1460 progress = 100.0 * static_cast<double>(available) / doc_size; | |
| 1461 } | 1457 } |
| 1462 | 1458 |
| 1463 // We send 100% load progress in DocumentLoadComplete. | 1459 // We send 100% load progress in DocumentLoadComplete. |
| 1464 if (progress >= 100) | 1460 if (progress >= 100) |
| 1465 return; | 1461 return; |
| 1466 | 1462 |
| 1467 // Avoid sending too many progress messages over PostMessage. | 1463 // Avoid sending too many progress messages over PostMessage. |
| 1468 if (progress > last_progress_sent_ + 1) { | 1464 if (progress > last_progress_sent_ + 1) { |
| 1469 last_progress_sent_ = progress; | 1465 last_progress_sent_ = progress; |
| 1470 pp::VarDictionary message; | 1466 pp::VarDictionary message; |
| 1471 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); | 1467 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); |
| 1472 message.Set(pp::Var(kJSProgressPercentage), pp::Var(progress)); | 1468 message.Set(pp::Var(kJSProgressPercentage), pp::Var(progress)); |
| 1473 PostMessage(message); | 1469 PostMessage(message); |
| 1474 } | 1470 } |
| 1475 } | 1471 } |
| 1476 | 1472 |
| 1477 void OutOfProcessInstance::FormTextFieldFocusChange(bool in_focus) { | 1473 void OutOfProcessInstance::FormTextFieldFocusChange(bool in_focus) { |
| 1478 if (!text_input_.get()) | 1474 if (!text_input_.get()) |
| 1479 return; | 1475 return; |
| 1480 | 1476 |
| 1481 pp::VarDictionary message; | 1477 pp::VarDictionary message; |
| 1482 message.Set(pp::Var(kType), pp::Var(kJSFieldFocusType)); | 1478 message.Set(pp::Var(kType), pp::Var(kJSFieldFocusType)); |
| 1483 message.Set(pp::Var(kJSFieldFocus), pp::Var(in_focus)); | 1479 message.Set(pp::Var(kJSFieldFocus), pp::Var(in_focus)); |
| 1484 PostMessage(message); | 1480 PostMessage(message); |
| 1485 | 1481 |
| 1486 if (in_focus) | 1482 text_input_->SetTextInputType(in_focus ? PP_TEXTINPUT_TYPE_DEV_TEXT |
| 1487 text_input_->SetTextInputType(PP_TEXTINPUT_TYPE_DEV_TEXT); | 1483 : PP_TEXTINPUT_TYPE_DEV_NONE); |
| 1488 else | |
| 1489 text_input_->SetTextInputType(PP_TEXTINPUT_TYPE_DEV_NONE); | |
| 1490 } | 1484 } |
| 1491 | 1485 |
| 1492 void OutOfProcessInstance::ResetRecentlySentFindUpdate(int32_t /* unused */) { | 1486 void OutOfProcessInstance::ResetRecentlySentFindUpdate(int32_t /* unused */) { |
| 1493 recently_sent_find_update_ = false; | 1487 recently_sent_find_update_ = false; |
| 1494 } | 1488 } |
| 1495 | 1489 |
| 1496 void OutOfProcessInstance::OnGeometryChanged(double old_zoom, | 1490 void OutOfProcessInstance::OnGeometryChanged(double old_zoom, |
| 1497 float old_device_scale) { | 1491 float old_device_scale) { |
| 1498 if (zoom_ != old_zoom || device_scale_ != old_device_scale) | 1492 if (zoom_ != old_zoom || device_scale_ != old_device_scale) |
| 1499 engine_->ZoomUpdated(zoom_ * device_scale_); | 1493 engine_->ZoomUpdated(zoom_ * device_scale_); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 const pp::FloatPoint& scroll_offset) { | 1628 const pp::FloatPoint& scroll_offset) { |
| 1635 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1629 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
| 1636 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1630 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
| 1637 float min_y = -top_toolbar_height_; | 1631 float min_y = -top_toolbar_height_; |
| 1638 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1632 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
| 1639 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1633 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
| 1640 return pp::FloatPoint(x, y); | 1634 return pp::FloatPoint(x, y); |
| 1641 } | 1635 } |
| 1642 | 1636 |
| 1643 } // namespace chrome_pdf | 1637 } // namespace chrome_pdf |
| OLD | NEW |