| 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/instance.h" | 5 #include "pdf/instance.h" |
| 6 | 6 |
| 7 #include <algorithm> // for min() | 7 #include <algorithm> // for min() |
| 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 2305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2316 const PPB_URLLoaderTrusted* trusted_interface = | 2316 const PPB_URLLoaderTrusted* trusted_interface = |
| 2317 reinterpret_cast<const PPB_URLLoaderTrusted*>( | 2317 reinterpret_cast<const PPB_URLLoaderTrusted*>( |
| 2318 pp::Module::Get()->GetBrowserInterface( | 2318 pp::Module::Get()->GetBrowserInterface( |
| 2319 PPB_URLLOADERTRUSTED_INTERFACE)); | 2319 PPB_URLLOADERTRUSTED_INTERFACE)); |
| 2320 if (trusted_interface) | 2320 if (trusted_interface) |
| 2321 trusted_interface->GrantUniversalAccess(loader.pp_resource()); | 2321 trusted_interface->GrantUniversalAccess(loader.pp_resource()); |
| 2322 return loader; | 2322 return loader; |
| 2323 } | 2323 } |
| 2324 | 2324 |
| 2325 int Instance::GetInitialPage(const std::string& url) { | 2325 int Instance::GetInitialPage(const std::string& url) { |
| 2326 #if defined(OS_NACL) | |
| 2327 return -1; | |
| 2328 #else | |
| 2329 size_t found_idx = url.find('#'); | 2326 size_t found_idx = url.find('#'); |
| 2330 if (found_idx == std::string::npos) | 2327 if (found_idx == std::string::npos) |
| 2331 return -1; | 2328 return -1; |
| 2332 | 2329 |
| 2333 const std::string& ref = url.substr(found_idx + 1); | 2330 const std::string& ref = url.substr(found_idx + 1); |
| 2334 std::vector<std::string> fragments; | 2331 std::vector<std::string> fragments; |
| 2335 Tokenize(ref, kDelimiters, &fragments); | 2332 Tokenize(ref, kDelimiters, &fragments); |
| 2336 | 2333 |
| 2337 // Page number to return, zero-based. | 2334 // Page number to return, zero-based. |
| 2338 int page = -1; | 2335 int page = -1; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2359 } | 2356 } |
| 2360 if (base::strcasecmp(kNamedDest, key.c_str()) == 0) { | 2357 if (base::strcasecmp(kNamedDest, key.c_str()) == 0) { |
| 2361 // |page_value| is 0-based. | 2358 // |page_value| is 0-based. |
| 2362 int page_value = engine_->GetNamedDestinationPage(value); | 2359 int page_value = engine_->GetNamedDestinationPage(value); |
| 2363 if (page_value >= 0) | 2360 if (page_value >= 0) |
| 2364 page = page_value; | 2361 page = page_value; |
| 2365 continue; | 2362 continue; |
| 2366 } | 2363 } |
| 2367 } | 2364 } |
| 2368 return page; | 2365 return page; |
| 2369 #endif | |
| 2370 } | 2366 } |
| 2371 | 2367 |
| 2372 void Instance::UpdateToolbarPosition(bool invalidate) { | 2368 void Instance::UpdateToolbarPosition(bool invalidate) { |
| 2373 pp::Rect ctrl_rc = toolbar_->GetControlsRect(); | 2369 pp::Rect ctrl_rc = toolbar_->GetControlsRect(); |
| 2374 int min_toolbar_width = ctrl_rc.width() + GetToolbarRightOffset() + | 2370 int min_toolbar_width = ctrl_rc.width() + GetToolbarRightOffset() + |
| 2375 GetScaled(kToolbarFadingOffsetLeft); | 2371 GetScaled(kToolbarFadingOffsetLeft); |
| 2376 int min_toolbar_height = ctrl_rc.width() + GetToolbarBottomOffset() + | 2372 int min_toolbar_height = ctrl_rc.width() + GetToolbarBottomOffset() + |
| 2377 GetScaled(kToolbarFadingOffsetBottom); | 2373 GetScaled(kToolbarFadingOffsetBottom); |
| 2378 | 2374 |
| 2379 // Update toolbar position | 2375 // Update toolbar position |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2723 return instance_->HasScriptableMethod(name, exception); | 2719 return instance_->HasScriptableMethod(name, exception); |
| 2724 } | 2720 } |
| 2725 | 2721 |
| 2726 pp::Var PDFScriptableObject::Call(const pp::Var& method, | 2722 pp::Var PDFScriptableObject::Call(const pp::Var& method, |
| 2727 const std::vector<pp::Var>& args, | 2723 const std::vector<pp::Var>& args, |
| 2728 pp::Var* exception) { | 2724 pp::Var* exception) { |
| 2729 return instance_->CallScriptableMethod(method, args, exception); | 2725 return instance_->CallScriptableMethod(method, args, exception); |
| 2730 } | 2726 } |
| 2731 | 2727 |
| 2732 } // namespace chrome_pdf | 2728 } // namespace chrome_pdf |
| OLD | NEW |