Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: pdf/out_of_process_instance.cc

Issue 2455663004: Add test to ensure that URLs that redirect inside the PDF plugin fail to load (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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;
Lei Zhang 2016/11/08 01:28:10 Side note: I wonder if this is actually needed to
raymes 2016/11/08 06:00:01 Done.
Lei Zhang 2016/11/08 07:19:31 Wasn't expecting this change, but if it works, the
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 854
860 void OutOfProcessInstance::DidOpenPreview(int32_t result) { 855 void OutOfProcessInstance::DidOpenPreview(int32_t result) {
861 if (result == PP_OK) { 856 if (result == PP_OK) {
862 preview_client_.reset(new PreviewModeClient(this)); 857 preview_client_.reset(new PreviewModeClient(this));
863 preview_engine_.reset(PDFEngine::Create(preview_client_.get())); 858 preview_engine_.reset(PDFEngine::Create(preview_client_.get()));
864 preview_engine_->HandleDocumentLoad(embed_preview_loader_); 859 preview_engine_->HandleDocumentLoad(embed_preview_loader_);
865 } else { 860 } else {
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 &OutOfProcessInstance::DidOpenPreview); 1438 &OutOfProcessInstance::DidOpenPreview);
1444 } 1439 }
1445 1440
1446 void OutOfProcessInstance::LoadUrlInternal( 1441 void OutOfProcessInstance::LoadUrlInternal(
1447 const std::string& url, 1442 const std::string& url,
1448 pp::URLLoader* loader, 1443 pp::URLLoader* loader,
1449 void (OutOfProcessInstance::* method)(int32_t)) { 1444 void (OutOfProcessInstance::* method)(int32_t)) {
1450 pp::URLRequestInfo request(this); 1445 pp::URLRequestInfo request(this);
1451 request.SetURL(url); 1446 request.SetURL(url);
1452 request.SetMethod("GET"); 1447 request.SetMethod("GET");
1448 request.SetFollowRedirects(false);
1453 1449
1454 *loader = CreateURLLoaderInternal(); 1450 *loader = CreateURLLoaderInternal();
1455 pp::CompletionCallback callback = loader_factory_.NewCallback(method); 1451 pp::CompletionCallback callback = loader_factory_.NewCallback(method);
1456 int rv = loader->Open(request, callback); 1452 int rv = loader->Open(request, callback);
1457 if (rv != PP_OK_COMPLETIONPENDING) 1453 if (rv != PP_OK_COMPLETIONPENDING)
1458 callback.Run(rv); 1454 callback.Run(rv);
1459 } 1455 }
1460 1456
1461 pp::URLLoader OutOfProcessInstance::CreateURLLoaderInternal() { 1457 pp::URLLoader OutOfProcessInstance::CreateURLLoaderInternal() {
1462 pp::URLLoader loader(this); 1458 pp::URLLoader loader(this);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 const pp::FloatPoint& scroll_offset) { 1543 const pp::FloatPoint& scroll_offset) {
1548 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); 1544 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); 1545 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f);
1550 float min_y = -top_toolbar_height_; 1546 float min_y = -top_toolbar_height_;
1551 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); 1547 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); 1548 float y = std::max(std::min(scroll_offset.y(), max_y), min_y);
1553 return pp::FloatPoint(x, y); 1549 return pp::FloatPoint(x, y);
1554 } 1550 }
1555 1551
1556 } // namespace chrome_pdf 1552 } // namespace chrome_pdf
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698