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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 bool OutOfProcessInstance::Init(uint32_t argc, | 314 bool OutOfProcessInstance::Init(uint32_t argc, |
315 const char* argn[], | 315 const char* argn[], |
316 const char* argv[]) { | 316 const char* argv[]) { |
317 // Check if the PDF is being loaded in the PDF chrome extension. We only allow | 317 // Check if the PDF is being loaded in the PDF chrome extension. We only allow |
318 // the plugin to be loaded in the extension and print preview to avoid | 318 // the plugin to be loaded in the extension and print preview to avoid |
319 // exposing sensitive APIs directly to external websites. | 319 // exposing sensitive APIs directly to external websites. |
320 pp::Var document_url_var = pp::URLUtil_Dev::Get()->GetDocumentURL(this); | 320 pp::Var document_url_var = pp::URLUtil_Dev::Get()->GetDocumentURL(this); |
321 if (!document_url_var.is_string()) | 321 if (!document_url_var.is_string()) |
322 return false; | 322 return false; |
323 std::string document_url = document_url_var.AsString(); | 323 std::string document_url = document_url_var.AsString(); |
324 std::string extension_url = std::string(kChromeExtension); | 324 base::StringPiece document_url_piece(document_url); |
325 std::string print_preview_url = std::string(kChromePrint); | 325 if (!document_url_piece.starts_with(kChromeExtension) && |
326 if (!base::StringPiece(document_url).starts_with(kChromeExtension) && | 326 !document_url_piece.starts_with(kChromePrint)) { |
327 !base::StringPiece(document_url).starts_with(kChromePrint)) { | |
328 return false; | 327 return false; |
329 } | 328 } |
330 | 329 |
331 // Check if the plugin is full frame. This is passed in from JS. | 330 // Check if the plugin is full frame. This is passed in from JS. |
332 for (uint32_t i = 0; i < argc; ++i) { | 331 for (uint32_t i = 0; i < argc; ++i) { |
333 if (strcmp(argn[i], "full-frame") == 0) { | 332 if (strcmp(argn[i], "full-frame") == 0) { |
334 full_ = true; | 333 full_ = true; |
335 break; | 334 break; |
336 } | 335 } |
337 } | 336 } |
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1523 const pp::FloatPoint& scroll_offset) { | 1522 const pp::FloatPoint& scroll_offset) { |
1524 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1523 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
1525 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1524 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
1526 float min_y = -top_toolbar_height_; | 1525 float min_y = -top_toolbar_height_; |
1527 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1526 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
1528 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1527 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
1529 return pp::FloatPoint(x, y); | 1528 return pp::FloatPoint(x, y); |
1530 } | 1529 } |
1531 | 1530 |
1532 } // namespace chrome_pdf | 1531 } // namespace chrome_pdf |
OLD | NEW |