Chromium Code Reviews| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 namespace chrome_pdf { | 49 namespace chrome_pdf { |
| 50 | 50 |
| 51 struct ToolbarButtonInfo { | 51 struct ToolbarButtonInfo { |
| 52 uint32 id; | 52 uint32 id; |
| 53 Button::ButtonStyle style; | 53 Button::ButtonStyle style; |
| 54 PP_ResourceImage normal; | 54 PP_ResourceImage normal; |
| 55 PP_ResourceImage highlighted; | 55 PP_ResourceImage highlighted; |
| 56 PP_ResourceImage pressed; | 56 PP_ResourceImage pressed; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 const uint32 kBackgroundColor = 0xFFCCCCCC; | |
| 60 | |
| 59 namespace { | 61 namespace { |
| 60 | 62 |
| 61 // Uncomment following #define to enable thumbnails. | 63 // Uncomment following #define to enable thumbnails. |
| 62 // #define ENABLE_THUMBNAILS | 64 // #define ENABLE_THUMBNAILS |
| 63 | 65 |
| 64 const uint32 kToolbarSplashTimeoutMs = 6000; | 66 const uint32 kToolbarSplashTimeoutMs = 6000; |
| 65 const uint32 kMessageTextColor = 0xFF575757; | 67 const uint32 kMessageTextColor = 0xFF575757; |
| 66 const uint32 kMessageTextSize = 22; | 68 const uint32 kMessageTextSize = 22; |
| 67 const uint32 kProgressFadeTimeoutMs = 250; | 69 const uint32 kProgressFadeTimeoutMs = 250; |
| 68 const uint32 kProgressDelayTimeoutMs = 1000; | 70 const uint32 kProgressDelayTimeoutMs = 1000; |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 hidpi_enabled_ = true; | 338 hidpi_enabled_ = true; |
| 337 | 339 |
| 338 printing_enabled_ = pp::PDF::IsFeatureEnabled(this, PP_PDFFEATURE_PRINTING); | 340 printing_enabled_ = pp::PDF::IsFeatureEnabled(this, PP_PDFFEATURE_PRINTING); |
| 339 if (printing_enabled_) { | 341 if (printing_enabled_) { |
| 340 CreateToolbar(kPDFToolbarButtons, arraysize(kPDFToolbarButtons)); | 342 CreateToolbar(kPDFToolbarButtons, arraysize(kPDFToolbarButtons)); |
| 341 } else { | 343 } else { |
| 342 CreateToolbar(kPDFNoPrintToolbarButtons, | 344 CreateToolbar(kPDFNoPrintToolbarButtons, |
| 343 arraysize(kPDFNoPrintToolbarButtons)); | 345 arraysize(kPDFNoPrintToolbarButtons)); |
| 344 } | 346 } |
| 345 | 347 |
| 348 engine_->SetBackgroundColor(kBackgroundColor); | |
| 349 | |
| 346 CreateProgressBar(); | 350 CreateProgressBar(); |
| 347 | 351 |
| 348 // Load autoscroll anchor image. | 352 // Load autoscroll anchor image. |
| 349 autoscroll_anchor_ = | 353 autoscroll_anchor_ = |
| 350 CreateResourceImage(PP_RESOURCEIMAGE_PDF_PAN_SCROLL_ICON); | 354 CreateResourceImage(PP_RESOURCEIMAGE_PDF_PAN_SCROLL_ICON); |
| 351 | 355 |
| 352 #ifdef ENABLE_THUMBNAILS | 356 #ifdef ENABLE_THUMBNAILS |
| 353 CreateThumbnails(); | 357 CreateThumbnails(); |
| 354 #endif | 358 #endif |
| 355 const char* url = NULL; | 359 const char* url = NULL; |
| 356 for (uint32_t i = 0; i < argc; ++i) { | 360 for (uint32_t i = 0; i < argc; ++i) { |
| 357 if (strcmp(argn[i], "src") == 0) { | 361 if (strcmp(argn[i], "src") == 0) { |
| 358 url = argv[i]; | 362 url = argv[i]; |
| 359 break; | 363 break; |
| 360 } | 364 } |
| 361 } | 365 } |
| 362 | 366 |
| 363 if (!url) | 367 if (!url) |
| 364 return false; | 368 return false; |
| 365 | 369 |
| 366 CreatePageIndicator(IsPrintPreviewUrl(url)); | 370 CreatePageIndicator(IsPrintPreviewUrl(url)); |
| 367 | 371 |
|
raymes
2015/01/30 03:41:00
nit: Maybe move that line down here so it's in mor
Alexandre Carlton
2015/01/30 03:53:41
Done.
| |
| 368 if (!full_) { | 372 if (!full_) { |
| 369 // For PDFs embedded in a frame, we don't get the data automatically like we | 373 // For PDFs embedded in a frame, we don't get the data automatically like we |
| 370 // do for full-frame loads. Start loading the data manually. | 374 // do for full-frame loads. Start loading the data manually. |
| 371 LoadUrl(url); | 375 LoadUrl(url); |
| 372 } else { | 376 } else { |
| 373 DCHECK(!did_call_start_loading_); | 377 DCHECK(!did_call_start_loading_); |
| 374 pp::PDF::DidStartLoading(this); | 378 pp::PDF::DidStartLoading(this); |
| 375 did_call_start_loading_ = true; | 379 did_call_start_loading_ = true; |
| 376 } | 380 } |
| 377 | 381 |
| (...skipping 2434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2812 return instance_->HasScriptableMethod(name, exception); | 2816 return instance_->HasScriptableMethod(name, exception); |
| 2813 } | 2817 } |
| 2814 | 2818 |
| 2815 pp::Var PDFScriptableObject::Call(const pp::Var& method, | 2819 pp::Var PDFScriptableObject::Call(const pp::Var& method, |
| 2816 const std::vector<pp::Var>& args, | 2820 const std::vector<pp::Var>& args, |
| 2817 pp::Var* exception) { | 2821 pp::Var* exception) { |
| 2818 return instance_->CallScriptableMethod(method, args, exception); | 2822 return instance_->CallScriptableMethod(method, args, exception); |
| 2819 } | 2823 } |
| 2820 | 2824 |
| 2821 } // namespace chrome_pdf | 2825 } // namespace chrome_pdf |
| OLD | NEW |