| 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 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 ready->push_back( | 839 ready->push_back( |
| 840 PaintManager::ReadyRect(intersection, image_data_, false)); | 840 PaintManager::ReadyRect(intersection, image_data_, false)); |
| 841 } | 841 } |
| 842 } | 842 } |
| 843 } | 843 } |
| 844 | 844 |
| 845 engine_->PostPaint(); | 845 engine_->PostPaint(); |
| 846 } | 846 } |
| 847 | 847 |
| 848 void OutOfProcessInstance::DidOpen(int32_t result) { | 848 void OutOfProcessInstance::DidOpen(int32_t result) { |
| 849 if (result == PP_OK) { | 849 if (result != PP_OK || !engine_->HandleDocumentLoad(embed_loader_)) { |
| 850 if (!engine_->HandleDocumentLoad(embed_loader_)) { | 850 document_load_state_ = LOAD_STATE_LOADING; |
| 851 document_load_state_ = LOAD_STATE_LOADING; | |
| 852 DocumentLoadFailed(); | |
| 853 } | |
| 854 } else if (result != PP_ERROR_ABORTED) { // Can happen in tests. | |
| 855 NOTREACHED(); | |
| 856 DocumentLoadFailed(); | 851 DocumentLoadFailed(); |
| 857 } | 852 } |
| 858 | 853 |
| 859 // If it's a progressive load, cancel the stream URL request so that requests | 854 // If it's a progressive load, cancel the stream URL request so that requests |
| 860 // can be made on the original URL. | 855 // can be made on the original URL. |
| 861 // TODO(raymes): Make this clearer once the in-process plugin is deleted. | 856 // TODO(raymes): Make this clearer once the in-process plugin is deleted. |
| 862 if (engine_->IsProgressiveLoad()) { | 857 if (engine_->IsProgressiveLoad()) { |
| 863 pp::VarDictionary message; | 858 pp::VarDictionary message; |
| 864 message.Set(kType, kJSCancelStreamUrlType); | 859 message.Set(kType, kJSCancelStreamUrlType); |
| 865 PostMessage(message); | 860 PostMessage(message); |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 &OutOfProcessInstance::DidOpenPreview); | 1447 &OutOfProcessInstance::DidOpenPreview); |
| 1453 } | 1448 } |
| 1454 | 1449 |
| 1455 void OutOfProcessInstance::LoadUrlInternal( | 1450 void OutOfProcessInstance::LoadUrlInternal( |
| 1456 const std::string& url, | 1451 const std::string& url, |
| 1457 pp::URLLoader* loader, | 1452 pp::URLLoader* loader, |
| 1458 void (OutOfProcessInstance::* method)(int32_t)) { | 1453 void (OutOfProcessInstance::* method)(int32_t)) { |
| 1459 pp::URLRequestInfo request(this); | 1454 pp::URLRequestInfo request(this); |
| 1460 request.SetURL(url); | 1455 request.SetURL(url); |
| 1461 request.SetMethod("GET"); | 1456 request.SetMethod("GET"); |
| 1457 request.SetFollowRedirects(false); |
| 1462 | 1458 |
| 1463 *loader = CreateURLLoaderInternal(); | 1459 *loader = CreateURLLoaderInternal(); |
| 1464 pp::CompletionCallback callback = loader_factory_.NewCallback(method); | 1460 pp::CompletionCallback callback = loader_factory_.NewCallback(method); |
| 1465 int rv = loader->Open(request, callback); | 1461 int rv = loader->Open(request, callback); |
| 1466 if (rv != PP_OK_COMPLETIONPENDING) | 1462 if (rv != PP_OK_COMPLETIONPENDING) |
| 1467 callback.Run(rv); | 1463 callback.Run(rv); |
| 1468 } | 1464 } |
| 1469 | 1465 |
| 1470 pp::URLLoader OutOfProcessInstance::CreateURLLoaderInternal() { | 1466 pp::URLLoader OutOfProcessInstance::CreateURLLoaderInternal() { |
| 1471 pp::URLLoader loader(this); | 1467 pp::URLLoader loader(this); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1550 const pp::FloatPoint& scroll_offset) { | 1546 const pp::FloatPoint& scroll_offset) { |
| 1551 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1547 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
| 1552 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1548 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
| 1553 float min_y = -top_toolbar_height_; | 1549 float min_y = -top_toolbar_height_; |
| 1554 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1550 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
| 1555 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1551 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
| 1556 return pp::FloatPoint(x, y); | 1552 return pp::FloatPoint(x, y); |
| 1557 } | 1553 } |
| 1558 | 1554 |
| 1559 } // namespace chrome_pdf | 1555 } // namespace chrome_pdf |
| OLD | NEW |