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 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 ready->push_back( | 936 ready->push_back( |
937 PaintManager::ReadyRect(intersection, image_data_, false)); | 937 PaintManager::ReadyRect(intersection, image_data_, false)); |
938 } | 938 } |
939 } | 939 } |
940 } | 940 } |
941 | 941 |
942 engine_->PostPaint(); | 942 engine_->PostPaint(); |
943 } | 943 } |
944 | 944 |
945 void OutOfProcessInstance::DidOpen(int32_t result) { | 945 void OutOfProcessInstance::DidOpen(int32_t result) { |
946 if (result != PP_OK || !engine_->HandleDocumentLoad(embed_loader_)) | 946 if (result == PP_OK) { |
| 947 if (!engine_->HandleDocumentLoad(embed_loader_)) { |
| 948 document_load_state_ = LOAD_STATE_LOADING; |
| 949 DocumentLoadFailed(); |
| 950 } |
| 951 } else if (result != PP_ERROR_ABORTED) { // Can happen in tests. |
| 952 NOTREACHED(); |
947 DocumentLoadFailed(); | 953 DocumentLoadFailed(); |
| 954 } |
| 955 |
| 956 // If it's a progressive load, cancel the stream URL request so that requests |
| 957 // can be made on the original URL. |
| 958 // TODO(raymes): Make this clearer once the in-process plugin is deleted. |
| 959 if (engine_->IsProgressiveLoad()) { |
| 960 pp::VarDictionary message; |
| 961 message.Set(kType, kJSCancelStreamUrlType); |
| 962 PostMessage(message); |
| 963 } |
948 } | 964 } |
949 | 965 |
950 void OutOfProcessInstance::DidOpenPreview(int32_t result) { | 966 void OutOfProcessInstance::DidOpenPreview(int32_t result) { |
951 if (result == PP_OK) { | 967 if (result == PP_OK) { |
952 preview_client_ = base::MakeUnique<PreviewModeClient>(this); | 968 preview_client_ = base::MakeUnique<PreviewModeClient>(this); |
953 preview_engine_.reset(PDFEngine::Create(preview_client_.get())); | 969 preview_engine_.reset(PDFEngine::Create(preview_client_.get())); |
954 preview_engine_->HandleDocumentLoad(embed_preview_loader_); | 970 preview_engine_->HandleDocumentLoad(embed_preview_loader_); |
955 } else { | 971 } else { |
956 NOTREACHED(); | 972 NOTREACHED(); |
957 } | 973 } |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1567 } | 1583 } |
1568 | 1584 |
1569 bool OutOfProcessInstance::IsPrintPreview() { | 1585 bool OutOfProcessInstance::IsPrintPreview() { |
1570 return is_print_preview_; | 1586 return is_print_preview_; |
1571 } | 1587 } |
1572 | 1588 |
1573 uint32_t OutOfProcessInstance::GetBackgroundColor() { | 1589 uint32_t OutOfProcessInstance::GetBackgroundColor() { |
1574 return background_color_; | 1590 return background_color_; |
1575 } | 1591 } |
1576 | 1592 |
1577 void OutOfProcessInstance::CancelBrowserDownload() { | |
1578 pp::VarDictionary message; | |
1579 message.Set(kType, kJSCancelStreamUrlType); | |
1580 PostMessage(message); | |
1581 } | |
1582 | |
1583 void OutOfProcessInstance::IsSelectingChanged(bool is_selecting) { | 1593 void OutOfProcessInstance::IsSelectingChanged(bool is_selecting) { |
1584 pp::VarDictionary message; | 1594 pp::VarDictionary message; |
1585 message.Set(kType, kJSSetIsSelectingType); | 1595 message.Set(kType, kJSSetIsSelectingType); |
1586 message.Set(kJSIsSelecting, pp::Var(is_selecting)); | 1596 message.Set(kJSIsSelecting, pp::Var(is_selecting)); |
1587 PostMessage(message); | 1597 PostMessage(message); |
1588 } | 1598 } |
1589 | 1599 |
1590 void OutOfProcessInstance::ProcessPreviewPageInfo(const std::string& url, | 1600 void OutOfProcessInstance::ProcessPreviewPageInfo(const std::string& url, |
1591 int dst_page_index) { | 1601 int dst_page_index) { |
1592 DCHECK(IsPrintPreview()); | 1602 DCHECK(IsPrintPreview()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1628 const pp::FloatPoint& scroll_offset) { | 1638 const pp::FloatPoint& scroll_offset) { |
1629 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1639 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
1630 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1640 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
1631 float min_y = -top_toolbar_height_; | 1641 float min_y = -top_toolbar_height_; |
1632 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1642 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
1633 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1643 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
1634 return pp::FloatPoint(x, y); | 1644 return pp::FloatPoint(x, y); |
1635 } | 1645 } |
1636 | 1646 |
1637 } // namespace chrome_pdf | 1647 } // namespace chrome_pdf |
OLD | NEW |