OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Download utility implementation | 5 // Download utility implementation |
6 | 6 |
7 #include "chrome/browser/download/download_util.h" | 7 #include "chrome/browser/download/download_util.h" |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <shobjidl.h> | 10 #include <shobjidl.h> |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 SkShader::CreateBitmapShader(*foreground, | 441 SkShader::CreateBitmapShader(*foreground, |
442 SkShader::kClamp_TileMode, | 442 SkShader::kClamp_TileMode, |
443 SkShader::kClamp_TileMode); | 443 SkShader::kClamp_TileMode); |
444 SkMatrix shader_scale; | 444 SkMatrix shader_scale; |
445 shader_scale.setTranslate(SkIntToScalar(foreground_bounds.x()), | 445 shader_scale.setTranslate(SkIntToScalar(foreground_bounds.x()), |
446 SkIntToScalar(foreground_bounds.y())); | 446 SkIntToScalar(foreground_bounds.y())); |
447 shader->setLocalMatrix(shader_scale); | 447 shader->setLocalMatrix(shader_scale); |
448 foreground_paint.setShader(shader); | 448 foreground_paint.setShader(shader); |
449 foreground_paint.setAntiAlias(true); | 449 foreground_paint.setAntiAlias(true); |
450 shader->unref(); | 450 shader->unref(); |
451 canvas->AsCanvasSkia()->drawPath(path, foreground_paint); | 451 canvas->AsCanvasSkia()->skia_canvas()->drawPath(path, foreground_paint); |
452 return; | 452 return; |
453 } | 453 } |
454 | 454 |
455 canvas->DrawBitmapInt(*foreground, | 455 canvas->DrawBitmapInt(*foreground, |
456 foreground_bounds.x(), | 456 foreground_bounds.x(), |
457 foreground_bounds.y(), | 457 foreground_bounds.y(), |
458 foreground_paint); | 458 foreground_paint); |
459 } | 459 } |
460 | 460 |
461 void PaintDownloadComplete(gfx::Canvas* canvas, | 461 void PaintDownloadComplete(gfx::Canvas* canvas, |
(...skipping 19 matching lines...) Expand all Loading... |
481 // Mirror the positions if necessary. | 481 // Mirror the positions if necessary. |
482 complete_bounds.set_x(containing_view->GetMirroredXForRect(complete_bounds)); | 482 complete_bounds.set_x(containing_view->GetMirroredXForRect(complete_bounds)); |
483 #endif | 483 #endif |
484 | 484 |
485 // Start at full opacity, then loop back and forth five times before ending | 485 // Start at full opacity, then loop back and forth five times before ending |
486 // at zero opacity. | 486 // at zero opacity. |
487 double opacity = sin(animation_progress * PI * kCompleteAnimationCycles + | 487 double opacity = sin(animation_progress * PI * kCompleteAnimationCycles + |
488 PI/2) / 2 + 0.5; | 488 PI/2) / 2 + 0.5; |
489 | 489 |
490 canvas->SaveLayerAlpha(static_cast<int>(255.0 * opacity), complete_bounds); | 490 canvas->SaveLayerAlpha(static_cast<int>(255.0 * opacity), complete_bounds); |
491 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); | 491 canvas->AsCanvasSkia()->skia_canvas()->drawARGB( |
| 492 0, 255, 255, 255, SkXfermode::kClear_Mode); |
492 canvas->DrawBitmapInt(*complete, complete_bounds.x(), complete_bounds.y()); | 493 canvas->DrawBitmapInt(*complete, complete_bounds.x(), complete_bounds.y()); |
493 canvas->Restore(); | 494 canvas->Restore(); |
494 } | 495 } |
495 | 496 |
496 void PaintDownloadInterrupted(gfx::Canvas* canvas, | 497 void PaintDownloadInterrupted(gfx::Canvas* canvas, |
497 #if defined(TOOLKIT_VIEWS) | 498 #if defined(TOOLKIT_VIEWS) |
498 views::View* containing_view, | 499 views::View* containing_view, |
499 #endif | 500 #endif |
500 int origin_x, | 501 int origin_x, |
501 int origin_y, | 502 int origin_y, |
(...skipping 15 matching lines...) Expand all Loading... |
517 complete_bounds.set_x(containing_view->GetMirroredXForRect(complete_bounds)); | 518 complete_bounds.set_x(containing_view->GetMirroredXForRect(complete_bounds)); |
518 #endif | 519 #endif |
519 | 520 |
520 // Start at zero opacity, then loop back and forth five times before ending | 521 // Start at zero opacity, then loop back and forth five times before ending |
521 // at full opacity. | 522 // at full opacity. |
522 double opacity = sin( | 523 double opacity = sin( |
523 (1.0 - animation_progress) * PI * kCompleteAnimationCycles + PI/2) / 2 + | 524 (1.0 - animation_progress) * PI * kCompleteAnimationCycles + PI/2) / 2 + |
524 0.5; | 525 0.5; |
525 | 526 |
526 canvas->SaveLayerAlpha(static_cast<int>(255.0 * opacity), complete_bounds); | 527 canvas->SaveLayerAlpha(static_cast<int>(255.0 * opacity), complete_bounds); |
527 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); | 528 canvas->AsCanvasSkia()->skia_canvas()->drawARGB( |
| 529 0, 255, 255, 255, SkXfermode::kClear_Mode); |
528 canvas->DrawBitmapInt(*complete, complete_bounds.x(), complete_bounds.y()); | 530 canvas->DrawBitmapInt(*complete, complete_bounds.x(), complete_bounds.y()); |
529 canvas->Restore(); | 531 canvas->Restore(); |
530 } | 532 } |
531 | 533 |
532 // Load a language dependent height so that the dangerous download confirmation | 534 // Load a language dependent height so that the dangerous download confirmation |
533 // message doesn't overlap with the download link label. | 535 // message doesn't overlap with the download link label. |
534 int GetBigProgressIconSize() { | 536 int GetBigProgressIconSize() { |
535 static int big_progress_icon_size = 0; | 537 static int big_progress_icon_size = 0; |
536 if (big_progress_icon_size == 0) { | 538 if (big_progress_icon_size == 0) { |
537 string16 locale_size_str = | 539 string16 locale_size_str = |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 // Extensions that are not from the gallery are considered dangerous. | 892 // Extensions that are not from the gallery are considered dangerous. |
891 ExtensionService* service = profile->GetExtensionService(); | 893 ExtensionService* service = profile->GetExtensionService(); |
892 if (!service || | 894 if (!service || |
893 !service->IsDownloadFromGallery(info->url, info->referrer_url)) | 895 !service->IsDownloadFromGallery(info->url, info->referrer_url)) |
894 return true; | 896 return true; |
895 } | 897 } |
896 return false; | 898 return false; |
897 } | 899 } |
898 | 900 |
899 } // namespace download_util | 901 } // namespace download_util |
OLD | NEW |