| 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 <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 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1298 const PPB_URLLoaderTrusted* trusted_interface = | 1298 const PPB_URLLoaderTrusted* trusted_interface = |
| 1299 reinterpret_cast<const PPB_URLLoaderTrusted*>( | 1299 reinterpret_cast<const PPB_URLLoaderTrusted*>( |
| 1300 pp::Module::Get()->GetBrowserInterface( | 1300 pp::Module::Get()->GetBrowserInterface( |
| 1301 PPB_URLLOADERTRUSTED_INTERFACE)); | 1301 PPB_URLLOADERTRUSTED_INTERFACE)); |
| 1302 if (trusted_interface) | 1302 if (trusted_interface) |
| 1303 trusted_interface->GrantUniversalAccess(loader.pp_resource()); | 1303 trusted_interface->GrantUniversalAccess(loader.pp_resource()); |
| 1304 return loader; | 1304 return loader; |
| 1305 } | 1305 } |
| 1306 | 1306 |
| 1307 int OutOfProcessInstance::GetInitialPage(const std::string& url) { | 1307 int OutOfProcessInstance::GetInitialPage(const std::string& url) { |
| 1308 #if defined(OS_NACL) | |
| 1309 return -1; | |
| 1310 #else | |
| 1311 size_t found_idx = url.find('#'); | 1308 size_t found_idx = url.find('#'); |
| 1312 if (found_idx == std::string::npos) | 1309 if (found_idx == std::string::npos) |
| 1313 return -1; | 1310 return -1; |
| 1314 | 1311 |
| 1315 const std::string& ref = url.substr(found_idx + 1); | 1312 const std::string& ref = url.substr(found_idx + 1); |
| 1316 std::vector<std::string> fragments; | 1313 std::vector<std::string> fragments; |
| 1317 Tokenize(ref, kDelimiters, &fragments); | 1314 Tokenize(ref, kDelimiters, &fragments); |
| 1318 | 1315 |
| 1319 // Page number to return, zero-based. | 1316 // Page number to return, zero-based. |
| 1320 int page = -1; | 1317 int page = -1; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1341 } | 1338 } |
| 1342 if (base::strcasecmp(kNamedDest, key.c_str()) == 0) { | 1339 if (base::strcasecmp(kNamedDest, key.c_str()) == 0) { |
| 1343 // |page_value| is 0-based. | 1340 // |page_value| is 0-based. |
| 1344 int page_value = engine_->GetNamedDestinationPage(value); | 1341 int page_value = engine_->GetNamedDestinationPage(value); |
| 1345 if (page_value >= 0) | 1342 if (page_value >= 0) |
| 1346 page = page_value; | 1343 page = page_value; |
| 1347 continue; | 1344 continue; |
| 1348 } | 1345 } |
| 1349 } | 1346 } |
| 1350 return page; | 1347 return page; |
| 1351 #endif | |
| 1352 } | 1348 } |
| 1353 | 1349 |
| 1354 void OutOfProcessInstance::SetZoom(double scale) { | 1350 void OutOfProcessInstance::SetZoom(double scale) { |
| 1355 double old_zoom = zoom_; | 1351 double old_zoom = zoom_; |
| 1356 zoom_ = scale; | 1352 zoom_ = scale; |
| 1357 OnGeometryChanged(old_zoom, device_scale_); | 1353 OnGeometryChanged(old_zoom, device_scale_); |
| 1358 } | 1354 } |
| 1359 | 1355 |
| 1360 std::string OutOfProcessInstance::GetLocalizedString(PP_ResourceString id) { | 1356 std::string OutOfProcessInstance::GetLocalizedString(PP_ResourceString id) { |
| 1361 pp::Var rv(pp::PDF::GetLocalizedString(this, id)); | 1357 pp::Var rv(pp::PDF::GetLocalizedString(this, id)); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1418 pp::Point OutOfProcessInstance::BoundScrollOffsetToDocument( | 1414 pp::Point OutOfProcessInstance::BoundScrollOffsetToDocument( |
| 1419 const pp::Point& scroll_offset) { | 1415 const pp::Point& scroll_offset) { |
| 1420 int max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1416 int max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
| 1421 int x = std::max(std::min(scroll_offset.x(), max_x), 0); | 1417 int x = std::max(std::min(scroll_offset.x(), max_x), 0); |
| 1422 int max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1418 int max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
| 1423 int y = std::max(std::min(scroll_offset.y(), max_y), 0); | 1419 int y = std::max(std::min(scroll_offset.y(), max_y), 0); |
| 1424 return pp::Point(x, y); | 1420 return pp::Point(x, y); |
| 1425 } | 1421 } |
| 1426 | 1422 |
| 1427 } // namespace chrome_pdf | 1423 } // namespace chrome_pdf |
| OLD | NEW |