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

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
« no previous file with comments | « pdf/document_loader.cc ('k') | pdf/pdfium/pdfium_engine.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_)) {
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(); 850 DocumentLoadFailed();
857 }
858 } 851 }
859 852
860 void OutOfProcessInstance::DidOpenPreview(int32_t result) { 853 void OutOfProcessInstance::DidOpenPreview(int32_t result) {
861 if (result == PP_OK) { 854 if (result == PP_OK) {
862 preview_client_.reset(new PreviewModeClient(this)); 855 preview_client_.reset(new PreviewModeClient(this));
863 preview_engine_.reset(PDFEngine::Create(preview_client_.get())); 856 preview_engine_.reset(PDFEngine::Create(preview_client_.get()));
864 preview_engine_->HandleDocumentLoad(embed_preview_loader_); 857 preview_engine_->HandleDocumentLoad(embed_preview_loader_);
865 } else { 858 } else {
866 NOTREACHED(); 859 NOTREACHED();
867 } 860 }
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 &OutOfProcessInstance::DidOpenPreview); 1436 &OutOfProcessInstance::DidOpenPreview);
1444 } 1437 }
1445 1438
1446 void OutOfProcessInstance::LoadUrlInternal( 1439 void OutOfProcessInstance::LoadUrlInternal(
1447 const std::string& url, 1440 const std::string& url,
1448 pp::URLLoader* loader, 1441 pp::URLLoader* loader,
1449 void (OutOfProcessInstance::* method)(int32_t)) { 1442 void (OutOfProcessInstance::* method)(int32_t)) {
1450 pp::URLRequestInfo request(this); 1443 pp::URLRequestInfo request(this);
1451 request.SetURL(url); 1444 request.SetURL(url);
1452 request.SetMethod("GET"); 1445 request.SetMethod("GET");
1446 request.SetFollowRedirects(false);
1453 1447
1454 *loader = CreateURLLoaderInternal(); 1448 *loader = CreateURLLoaderInternal();
1455 pp::CompletionCallback callback = loader_factory_.NewCallback(method); 1449 pp::CompletionCallback callback = loader_factory_.NewCallback(method);
1456 int rv = loader->Open(request, callback); 1450 int rv = loader->Open(request, callback);
1457 if (rv != PP_OK_COMPLETIONPENDING) 1451 if (rv != PP_OK_COMPLETIONPENDING)
1458 callback.Run(rv); 1452 callback.Run(rv);
1459 } 1453 }
1460 1454
1461 pp::URLLoader OutOfProcessInstance::CreateURLLoaderInternal() { 1455 pp::URLLoader OutOfProcessInstance::CreateURLLoaderInternal() {
1462 pp::URLLoader loader(this); 1456 pp::URLLoader loader(this);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 const pp::FloatPoint& scroll_offset) { 1541 const pp::FloatPoint& scroll_offset) {
1548 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); 1542 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); 1543 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f);
1550 float min_y = -top_toolbar_height_; 1544 float min_y = -top_toolbar_height_;
1551 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); 1545 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); 1546 float y = std::max(std::min(scroll_offset.y(), max_y), min_y);
1553 return pp::FloatPoint(x, y); 1547 return pp::FloatPoint(x, y);
1554 } 1548 }
1555 1549
1556 } // namespace chrome_pdf 1550 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « pdf/document_loader.cc ('k') | pdf/pdfium/pdfium_engine.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698