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 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 void OutOfProcessInstance::DidOpen(int32_t result) { | 848 void OutOfProcessInstance::DidOpen(int32_t result) { |
849 if (result == PP_OK) { | 849 if (result == PP_OK) { |
850 if (!engine_->HandleDocumentLoad(embed_loader_)) { | 850 if (!engine_->HandleDocumentLoad(embed_loader_)) { |
851 document_load_state_ = LOAD_STATE_LOADING; | 851 document_load_state_ = LOAD_STATE_LOADING; |
852 DocumentLoadFailed(); | 852 DocumentLoadFailed(); |
853 } | 853 } |
854 } else if (result != PP_ERROR_ABORTED) { // Can happen in tests. | 854 } else if (result != PP_ERROR_ABORTED) { // Can happen in tests. |
855 NOTREACHED(); | 855 NOTREACHED(); |
856 DocumentLoadFailed(); | 856 DocumentLoadFailed(); |
857 } | 857 } |
| 858 |
| 859 // If it's a progressive load, cancel the stream URL request so that requests |
| 860 // can be made on the original URL. |
| 861 // TODO(raymes): Make this clearer once the in-process plugin is deleted. |
| 862 if (engine_->IsProgressiveLoad()) { |
| 863 pp::VarDictionary message; |
| 864 message.Set(kType, kJSCancelStreamUrlType); |
| 865 PostMessage(message); |
| 866 } |
858 } | 867 } |
859 | 868 |
860 void OutOfProcessInstance::DidOpenPreview(int32_t result) { | 869 void OutOfProcessInstance::DidOpenPreview(int32_t result) { |
861 if (result == PP_OK) { | 870 if (result == PP_OK) { |
862 preview_client_.reset(new PreviewModeClient(this)); | 871 preview_client_.reset(new PreviewModeClient(this)); |
863 preview_engine_.reset(PDFEngine::Create(preview_client_.get())); | 872 preview_engine_.reset(PDFEngine::Create(preview_client_.get())); |
864 preview_engine_->HandleDocumentLoad(embed_preview_loader_); | 873 preview_engine_->HandleDocumentLoad(embed_preview_loader_); |
865 } else { | 874 } else { |
866 NOTREACHED(); | 875 NOTREACHED(); |
867 } | 876 } |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1485 } | 1494 } |
1486 | 1495 |
1487 bool OutOfProcessInstance::IsPrintPreview() { | 1496 bool OutOfProcessInstance::IsPrintPreview() { |
1488 return IsPrintPreviewUrl(url_); | 1497 return IsPrintPreviewUrl(url_); |
1489 } | 1498 } |
1490 | 1499 |
1491 uint32_t OutOfProcessInstance::GetBackgroundColor() { | 1500 uint32_t OutOfProcessInstance::GetBackgroundColor() { |
1492 return background_color_; | 1501 return background_color_; |
1493 } | 1502 } |
1494 | 1503 |
1495 void OutOfProcessInstance::CancelBrowserDownload() { | |
1496 pp::VarDictionary message; | |
1497 message.Set(kType, kJSCancelStreamUrlType); | |
1498 PostMessage(message); | |
1499 } | |
1500 | |
1501 void OutOfProcessInstance::IsSelectingChanged(bool is_selecting) { | 1504 void OutOfProcessInstance::IsSelectingChanged(bool is_selecting) { |
1502 pp::VarDictionary message; | 1505 pp::VarDictionary message; |
1503 message.Set(kType, kJSSetIsSelectingType); | 1506 message.Set(kType, kJSSetIsSelectingType); |
1504 message.Set(kJSIsSelecting, pp::Var(is_selecting)); | 1507 message.Set(kJSIsSelecting, pp::Var(is_selecting)); |
1505 PostMessage(message); | 1508 PostMessage(message); |
1506 } | 1509 } |
1507 | 1510 |
1508 void OutOfProcessInstance::ProcessPreviewPageInfo(const std::string& url, | 1511 void OutOfProcessInstance::ProcessPreviewPageInfo(const std::string& url, |
1509 int dst_page_index) { | 1512 int dst_page_index) { |
1510 if (!IsPrintPreview()) | 1513 if (!IsPrintPreview()) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 const pp::FloatPoint& scroll_offset) { | 1550 const pp::FloatPoint& scroll_offset) { |
1548 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1551 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
1549 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); |
1550 float min_y = -top_toolbar_height_; | 1553 float min_y = -top_toolbar_height_; |
1551 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1554 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
1552 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); |
1553 return pp::FloatPoint(x, y); | 1556 return pp::FloatPoint(x, y); |
1554 } | 1557 } |
1555 | 1558 |
1556 } // namespace chrome_pdf | 1559 } // namespace chrome_pdf |
OLD | NEW |