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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 url = argv[i]; | 360 url = argv[i]; |
361 break; | 361 break; |
362 } | 362 } |
363 } | 363 } |
364 | 364 |
365 if (!url) | 365 if (!url) |
366 return false; | 366 return false; |
367 | 367 |
368 CreatePageIndicator(IsPrintPreviewUrl(url)); | 368 CreatePageIndicator(IsPrintPreviewUrl(url)); |
369 | 369 |
370 engine_->SetBackgroundColor(kBackgroundColor); | |
371 | |
372 if (!full_) { | 370 if (!full_) { |
373 // For PDFs embedded in a frame, we don't get the data automatically like we | 371 // For PDFs embedded in a frame, we don't get the data automatically like we |
374 // do for full-frame loads. Start loading the data manually. | 372 // do for full-frame loads. Start loading the data manually. |
375 LoadUrl(url); | 373 LoadUrl(url); |
376 } else { | 374 } else { |
377 DCHECK(!did_call_start_loading_); | 375 DCHECK(!did_call_start_loading_); |
378 pp::PDF::DidStartLoading(this); | 376 pp::PDF::DidStartLoading(this); |
379 did_call_start_loading_ = true; | 377 did_call_start_loading_ = true; |
380 } | 378 } |
381 | 379 |
(...skipping 2254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2636 ScrollToPage(0); | 2634 ScrollToPage(0); |
2637 engine_->AppendBlankPages(print_preview_page_count_); | 2635 engine_->AppendBlankPages(print_preview_page_count_); |
2638 if (preview_pages_info_.size() > 0) | 2636 if (preview_pages_info_.size() > 0) |
2639 LoadAvailablePreviewPage(); | 2637 LoadAvailablePreviewPage(); |
2640 } | 2638 } |
2641 | 2639 |
2642 bool Instance::IsPrintPreview() { | 2640 bool Instance::IsPrintPreview() { |
2643 return IsPrintPreviewUrl(url_); | 2641 return IsPrintPreviewUrl(url_); |
2644 } | 2642 } |
2645 | 2643 |
| 2644 uint32 Instance::GetBackgroundColor() { |
| 2645 return kBackgroundColor; |
| 2646 } |
| 2647 |
2646 int Instance::GetPageNumberToDisplay() { | 2648 int Instance::GetPageNumberToDisplay() { |
2647 int page = engine_->GetMostVisiblePage(); | 2649 int page = engine_->GetMostVisiblePage(); |
2648 if (IsPrintPreview() && !print_preview_page_numbers_.empty()) { | 2650 if (IsPrintPreview() && !print_preview_page_numbers_.empty()) { |
2649 page = ClipToRange<int>(page, 0, print_preview_page_numbers_.size() - 1); | 2651 page = ClipToRange<int>(page, 0, print_preview_page_numbers_.size() - 1); |
2650 return print_preview_page_numbers_[page]; | 2652 return print_preview_page_numbers_[page]; |
2651 } | 2653 } |
2652 return page + 1; | 2654 return page + 1; |
2653 } | 2655 } |
2654 | 2656 |
2655 void Instance::ProcessPreviewPageInfo(const std::string& url, | 2657 void Instance::ProcessPreviewPageInfo(const std::string& url, |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2816 return instance_->HasScriptableMethod(name, exception); | 2818 return instance_->HasScriptableMethod(name, exception); |
2817 } | 2819 } |
2818 | 2820 |
2819 pp::Var PDFScriptableObject::Call(const pp::Var& method, | 2821 pp::Var PDFScriptableObject::Call(const pp::Var& method, |
2820 const std::vector<pp::Var>& args, | 2822 const std::vector<pp::Var>& args, |
2821 pp::Var* exception) { | 2823 pp::Var* exception) { |
2822 return instance_->CallScriptableMethod(method, args, exception); | 2824 return instance_->CallScriptableMethod(method, args, exception); |
2823 } | 2825 } |
2824 | 2826 |
2825 } // namespace chrome_pdf | 2827 } // namespace chrome_pdf |
OLD | NEW |