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

Side by Side Diff: pdf/out_of_process_instance.cc

Issue 1266303003: Set the content restriction to disable printing in PDFs that disallow it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months 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 | « no previous file | no next file » | 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 <algorithm> // for min/max() 7 #include <algorithm> // for min/max()
8 #define _USE_MATH_DEFINES // for M_PI 8 #define _USE_MATH_DEFINES // for M_PI
9 #include <cmath> // for log() and pow() 9 #include <cmath> // for log() and pow()
10 #include <math.h> 10 #include <math.h>
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 if (did_call_start_loading_) { 1123 if (did_call_start_loading_) {
1124 pp::PDF::DidStopLoading(this); 1124 pp::PDF::DidStopLoading(this);
1125 did_call_start_loading_ = false; 1125 did_call_start_loading_ = false;
1126 } 1126 }
1127 1127
1128 int content_restrictions = 1128 int content_restrictions =
1129 CONTENT_RESTRICTION_CUT | CONTENT_RESTRICTION_PASTE; 1129 CONTENT_RESTRICTION_CUT | CONTENT_RESTRICTION_PASTE;
1130 if (!engine_->HasPermission(PDFEngine::PERMISSION_COPY)) 1130 if (!engine_->HasPermission(PDFEngine::PERMISSION_COPY))
1131 content_restrictions |= CONTENT_RESTRICTION_COPY; 1131 content_restrictions |= CONTENT_RESTRICTION_COPY;
1132 1132
1133 if (!engine_->HasPermission(PDFEngine::PERMISSION_PRINT_LOW_QUALITY) &&
1134 !engine_->HasPermission(PDFEngine::PERMISSION_PRINT_HIGH_QUALITY)) {
1135 content_restrictions |= CONTENT_RESTRICTION_PRINT;
1136 }
1137
1133 pp::PDF::SetContentRestriction(this, content_restrictions); 1138 pp::PDF::SetContentRestriction(this, content_restrictions);
1134 1139
1135 uma_.HistogramCustomCounts("PDF.PageCount", page_count, 1140 uma_.HistogramCustomCounts("PDF.PageCount", page_count,
1136 1, 1000000, 50); 1141 1, 1000000, 50);
1137 } 1142 }
1138 1143
1139 void OutOfProcessInstance::RotateClockwise() { 1144 void OutOfProcessInstance::RotateClockwise() {
1140 engine_->RotateClockwise(); 1145 engine_->RotateClockwise();
1141 } 1146 }
1142 1147
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( 1412 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument(
1408 const pp::FloatPoint& scroll_offset) { 1413 const pp::FloatPoint& scroll_offset) {
1409 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); 1414 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width();
1410 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); 1415 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f);
1411 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); 1416 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height();
1412 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); 1417 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f);
1413 return pp::FloatPoint(x, y); 1418 return pp::FloatPoint(x, y);
1414 } 1419 }
1415 1420
1416 } // namespace chrome_pdf 1421 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698